wscript: make foo mandatory only when --enable-foo is passed
authorPaul Brossier <piem@piem.org>
Wed, 12 Aug 2015 17:01:34 +0000 (19:01 +0200)
committerPaul Brossier <piem@piem.org>
Wed, 12 Aug 2015 17:01:34 +0000 (19:01 +0200)
wscript

diff --git a/wscript b/wscript
index f7f74b0..ac1f81d 100644 (file)
--- a/wscript
+++ b/wscript
@@ -178,17 +178,22 @@ def configure(ctx):
         # one of fftwf or fftw3f
         if (ctx.options.enable_fftw3f != False):
             ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0',
-                    args = '--cflags --libs', mandatory = False)
+                    args = '--cflags --libs',
+                    mandatory = ctx.options.enable_fftw3f)
             if (ctx.options.enable_double == True):
-                ctx.msg('Warning', 'fftw3f enabled, but compiling in double precision!')
+                ctx.msg('Warning',
+                        'fftw3f enabled, but compiling in double precision!')
         else:
-            # fftw3f not enabled, take most sensible one according to enable_double
+            # fftw3f disabled, take most sensible one according to
+            # enable_double
             if (ctx.options.enable_double == True):
                 ctx.check_cfg(package = 'fftw3', atleast_version = '3.0.0',
-                        args = '--cflags --libs', mandatory = False)
+                        args = '--cflags --libs', mandatory =
+                        ctx.options.enable_fftw3)
             else:
                 ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0',
-                        args = '--cflags --libs', mandatory = False)
+                        args = '--cflags --libs',
+                        mandatory = ctx.options.enable_fftw3)
         ctx.define('HAVE_FFTW3', 1)
 
     # fftw not enabled, use vDSP or ooura
@@ -204,28 +209,35 @@ def configure(ctx):
     # check for libsndfile
     if (ctx.options.enable_sndfile != False):
         ctx.check_cfg(package = 'sndfile', atleast_version = '1.0.4',
-                args = '--cflags --libs', mandatory = False)
+                args = '--cflags --libs',
+                mandatory = ctx.options.enable_sndfile)
 
     # check for libsamplerate
     if (ctx.options.enable_samplerate != False):
         ctx.check_cfg(package = 'samplerate', atleast_version = '0.0.15',
-                args = '--cflags --libs', mandatory = False)
+                args = '--cflags --libs',
+                mandatory = ctx.options.enable_samplerate)
 
     # check for jack
     if (ctx.options.enable_jack != False):
         ctx.check_cfg(package = 'jack',
-                args = '--cflags --libs', mandatory = False)
+                args = '--cflags --libs',
+                mandatory = ctx.options.enable_jack)
 
     # check for libav
     if (ctx.options.enable_avcodec != False):
         ctx.check_cfg(package = 'libavcodec', atleast_version = '54.35.0',
-                args = '--cflags --libs', uselib_store = 'AVCODEC', mandatory = False)
+                args = '--cflags --libs', uselib_store = 'AVCODEC',
+                mandatory = ctx.options.enable_avcodec)
         ctx.check_cfg(package = 'libavformat', atleast_version = '52.3.0',
-                args = '--cflags --libs', uselib_store = 'AVFORMAT', mandatory = False)
+                args = '--cflags --libs', uselib_store = 'AVFORMAT',
+                mandatory = ctx.options.enable_avcodec)
         ctx.check_cfg(package = 'libavutil', atleast_version = '52.3.0',
-                args = '--cflags --libs', uselib_store = 'AVUTIL', mandatory = False)
+                args = '--cflags --libs', uselib_store = 'AVUTIL',
+                mandatory = ctx.options.enable_avcodec)
         ctx.check_cfg(package = 'libavresample', atleast_version = '1.0.1',
-                args = '--cflags --libs', uselib_store = 'AVRESAMPLE', mandatory = False)
+                args = '--cflags --libs', uselib_store = 'AVRESAMPLE',
+                mandatory = ctx.options.enable_avcodec)
         if all ( 'HAVE_' + i in ctx.env.define_key
                 for i in ['AVCODEC', 'AVFORMAT', 'AVUTIL', 'AVRESAMPLE'] ):
             ctx.define('HAVE_LIBAV', 1)