wscript: small tweaks to with mingw32
authorPaul Brossier <piem@piem.org>
Tue, 10 Dec 2013 13:39:47 +0000 (08:39 -0500)
committerPaul Brossier <piem@piem.org>
Tue, 10 Dec 2013 13:39:47 +0000 (08:39 -0500)
Signed-off-by: Paul Brossier <piem@piem.org>
src/wscript_build
tests/utils_tests.h
wscript

index e755216..2bf8261 100644 (file)
@@ -21,6 +21,8 @@ ctx(features = 'c',
 # build libaubio.so (cshlib) and/or libaubio.a (cstlib)
 if ctx.env['DEST_OS'] in ['ios', 'iosimulator']:
     build_features = ['cstlib']
+elif ctx.env['DEST_OS'] in ['win32', 'win64']:
+    build_features = ['cshlib']
 else: #linux, darwin, android, mingw, ...
     build_features = ['cshlib', 'cstlib']
 
index 17fc369..8ab5fe7 100644 (file)
@@ -3,12 +3,29 @@
 #include <stdio.h>
 #include <math.h>
 #include <assert.h>
+#include "config.h"
 
 #define PRINT_ERR(format, args...)   fprintf(stderr, "AUBIO-TESTS ERROR: " format , ##args)
 #define PRINT_MSG(format, args...)   fprintf(stdout, format , ##args)
 #define PRINT_DBG(format, args...)   fprintf(stderr, format , ##args)
 #define PRINT_WRN(format, args...)   fprintf(stderr, "AUBIO-TESTS WARNING: " format, ##args)
 
+#ifdef HAVE_WIN_HACKS
+// http://en.wikipedia.org/wiki/Linear_congruential_generator
+// no srandom/random on win32
+
+uint_t srandom_seed = 1029;
+
+void srandom(uint_t new_seed) {
+    srandom_seed = new_seed;
+}
+
+uint_t random(void) {
+    srandom_seed = 1664525 * srandom_seed + 1013904223;
+    return srandom_seed;
+}
+#endif
+
 void utils_init_random () {
   time_t now = time(0);
   struct tm *tm_struct = localtime(&now);
diff --git a/wscript b/wscript
index 94f0d04..58d942a 100644 (file)
--- a/wscript
+++ b/wscript
@@ -84,15 +84,19 @@ def configure(ctx):
     ctx.load('compiler_c')
     ctx.load('waf_unit_test')
     ctx.load('gnu_dirs')
-    ctx.env.CFLAGS += ['-g', '-Wall', '-Wextra', '-fPIC']
+
+    ctx.env.CFLAGS += ['-g', '-Wall', '-Wextra']
 
     target_platform = Options.platform
     if ctx.options.target_platform:
         target_platform = ctx.options.target_platform
     ctx.env['DEST_OS'] = target_platform
 
-    if target_platform == 'win32':
-        ctx.env['shlib_PATTERN'] = 'lib%s.dll'
+    if target_platform not in ['win32', 'win64']:
+        ctx.env.CFLAGS += ['-fPIC']
+    else:
+        ctx.define('HAVE_WIN_HACKS', 1)
+        ctx.env['cshlib_PATTERN'] = 'lib%s.dll'
 
     if target_platform == 'darwin':
         ctx.env.CFLAGS += ['-arch', 'i386', '-arch', 'x86_64']