python/lib/moresetuptools.py: also check for HAVE_AUBIO_DOUBLE
authorPaul Brossier <piem@piem.org>
Fri, 2 Dec 2016 12:03:41 +0000 (13:03 +0100)
committerPaul Brossier <piem@piem.org>
Fri, 2 Dec 2016 12:03:41 +0000 (13:03 +0100)
.travis.yml
Makefile
python/lib/gen_external.py
python/lib/moresetuptools.py

index 2ae4548..2dca23c 100644 (file)
@@ -29,19 +29,19 @@ matrix:
     - python: 2.7
       os: linux
       compiler: gcc
-      env: ARCH=x86_64 HAVE_DOUBLE=1 WAFOPTS=--enable-fftw3
+      env: ARCH=x86_64 HAVE_AUBIO_DOUBLE=1 WAFOPTS=--enable-fftw3
     - python: 2.7
       os: linux
       compiler: gcc
-      env: ARCH=i386 HAVE_DOUBLE=1
+      env: ARCH=i386 HAVE_AUBIO_DOUBLE=1
     - python: 3.4
       os: linux
       compiler: gcc
-      env: ARCH=x86_64 HAVE_DOUBLE=1
+      env: ARCH=x86_64 HAVE_AUBIO_DOUBLE=1
     - python: 3.4
       os: linux
       compiler: gcc
-      env: ARCH=i386 HAVE_DOUBLE=1
+      env: ARCH=i386 HAVE_AUBIO_DOUBLE=1
     - language: C
       os: osx
       compiler: clang
index daedae9..8fb7219 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -8,6 +8,9 @@ WAFOPTS += --verbose
 WAFOPTS += --destdir $(DESTDIR)
 # multiple jobs
 WAFOPTS += --jobs 4
+# if HAVE_AUBIO_DOUBLE is defined, pass --enable-double to waf
+# python/lib/moresetuptools.py also checks for HAVE_AUBIO_DOUBLE
+WAFOPTS += $(shell [ -z $(HAVE_AUBIO_DOUBLE) ] || echo --enable-double )
 
 DESTDIR:=$(PWD)/build/dist
 PYDESTDIR:=$(PWD)/build/pydist
@@ -22,7 +25,6 @@ MANDIR?=$(DATAROOTDIR)/man
 
 SOX=sox
 
-ENABLE_DOUBLE := $(shell [ -z $(HAVE_DOUBLE) ] || echo --enable-double )
 TESTSOUNDS := python/tests/sounds
 
 all: build
@@ -44,7 +46,7 @@ cleanwaf:
        rm -rf waf waflib .waf*
 
 configure: checkwaf
-       $(WAFCMD) configure $(WAFOPTS) $(ENABLE_DOUBLE)
+       $(WAFCMD) configure $(WAFOPTS)
 
 build: configure
        $(WAFCMD) build $(WAFOPTS)
@@ -81,7 +83,7 @@ delete_install:
 
 build_python:
        # build python-aubio, using locally built libaubio if found
-       python ./setup.py build_ext $(ENABLE_DOUBLE)
+       python ./setup.py build
 
 build_python_extlib:
        # build python-aubio using (locally) installed libaubio
@@ -162,7 +164,7 @@ check_distclean:
        make distclean
 
 distcheck: checkwaf
-       $(WAFCMD) distcheck $(WAFOPTS) $(ENABLE_DOUBLE)
+       $(WAFCMD) distcheck $(WAFOPTS)
 
 help:
        $(WAFCMD) --help
index c6a13d4..bbd7e5d 100644 (file)
@@ -75,10 +75,12 @@ def get_preprocessor():
 
     return cpp_cmd
 
-def get_cpp_objects(header=header):
+def get_cpp_objects(header=header, usedouble=False):
     cpp_cmd = get_preprocessor()
 
     macros = [('AUBIO_UNSTABLE', 1)]
+    if usedouble:
+        macros += [('HAVE_AUBIO_DOUBLE', 1)]
 
     if not os.path.isfile(header):
         raise Exception("could not find include file " + header)
@@ -176,7 +178,7 @@ def generate_external(header=header, output_path=output_path, usedouble=False, o
     if not os.path.isdir(output_path): os.mkdir(output_path)
     elif not overwrite: return sorted(glob.glob(os.path.join(output_path, '*.c')))
 
-    cpp_output, cpp_objects = get_cpp_objects(header)
+    cpp_output, cpp_objects = get_cpp_objects(header, usedouble=usedouble)
 
     lib = analyze_cpp_output(cpp_objects, cpp_output)
     # print_cpp_output_results(lib, cpp_output)
index 519e8aa..d3567f9 100644 (file)
@@ -151,8 +151,11 @@ class build_ext(_build_ext):
                     level=distutils.log.INFO)
 
     def build_extension(self, extension):
-        if self.enable_double:
+        if self.enable_double or 'HAVE_AUBIO_DOUBLE' in os.environ:
             extension.define_macros += [('HAVE_AUBIO_DOUBLE', 1)]
+            enable_double = True
+        else:
+            enable_double = False
         # seack for aubio headers and lib in PKG_CONFIG_PATH
         add_system_aubio(extension)
         # the lib was not installed on this system
@@ -166,10 +169,10 @@ class build_ext(_build_ext):
                 add_local_aubio_lib(extension)
             else:
                 # check for external dependencies
-                add_external_deps(extension, usedouble=self.enable_double)
+                add_external_deps(extension, usedouble=enable_double)
                 # add libaubio sources and look for optional deps with pkg-config
-                add_local_aubio_sources(extension, usedouble=self.enable_double)
+                add_local_aubio_sources(extension, usedouble=enable_double)
         # generate files python/gen/*.c, python/gen/aubio-generated.h
         extension.sources += generate_external(header, output_path, overwrite = False,
-                usedouble=self.enable_double)
+                usedouble=enable_double)
         return _build_ext.build_extension(self, extension)