shithub: aubio

Download patch

ref: 3d148298842da32516a81f05446dda7f1b905c93
parent: bee6e965c0212093724680bacf3c3f6594fefe70
author: Paul Brossier <piem@piem.org>
date: Fri Dec 2 08:03:41 EST 2016

python/lib/moresetuptools.py: also check for HAVE_AUBIO_DOUBLE

--- a/.travis.yml
+++ b/.travis.yml
@@ -29,19 +29,19 @@
     - 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
--- a/Makefile
+++ b/Makefile
@@ -8,6 +8,9 @@
 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 @@
 
 SOX=sox
 
-ENABLE_DOUBLE := $(shell [ -z $(HAVE_DOUBLE) ] || echo --enable-double )
 TESTSOUNDS := python/tests/sounds
 
 all: build
@@ -44,7 +46,7 @@
 	rm -rf waf waflib .waf*
 
 configure: checkwaf
-	$(WAFCMD) configure $(WAFOPTS) $(ENABLE_DOUBLE)
+	$(WAFCMD) configure $(WAFOPTS)
 
 build: configure
 	$(WAFCMD) build $(WAFOPTS)
@@ -81,7 +83,7 @@
 
 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 @@
 	make distclean
 
 distcheck: checkwaf
-	$(WAFCMD) distcheck $(WAFOPTS) $(ENABLE_DOUBLE)
+	$(WAFCMD) distcheck $(WAFOPTS)
 
 help:
 	$(WAFCMD) --help
--- a/python/lib/gen_external.py
+++ b/python/lib/gen_external.py
@@ -75,10 +75,12 @@
 
     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 @@
     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)
--- a/python/lib/moresetuptools.py
+++ b/python/lib/moresetuptools.py
@@ -151,8 +151,11 @@
                     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 @@
                 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)