Build sys additions * wine support for testing * License boilerplate * Reorder configure checks
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
diff --git a/Makefile b/Makefile
index 377a0e2..4d11de8 100644
--- a/Makefile
+++ b/Makefile
@@ -64,7 +64,7 @@ testdll.dll: testdll.c
$(CC) -shared -o $@ $^
test: $(TARGETS) test.exe testdll.dll
- test.exe
+ $(WINE) test.exe
clean::
rm -f dlfcn.o libdl.dll libdl.a libdl.def libdl.dll.a libdl.lib libdl.exp test.exe testdll.dll
diff --git a/configure b/configure
index 5b5e409..91f7d07 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,9 @@
#!/bin/sh
# dlfcn-win32 configure script
#
+# Copyright (c) 2007, 2009, 2012 Ramiro Polla
+# Copyright (c) 2014 Tiancheng "Timothy" Gu
+#
# Parts copied from FFmpeg's configure. Original license was:
#
# Copyright (c) 2000-2002 Fabrice Bellard
@@ -58,6 +61,7 @@ show_help(){
echo " --enable-static build static libraries [yes]"
echo " --enable-msvc create msvc-compatible import lib [auto]"
echo " --enable-stripping strip shared library [yes]"
+ echo " --enable-wine[=cmd] use wine in tests [auto,cmd=$winecmd]"
echo
echo " --cc=CC use C compiler CC [$cc_default]"
echo " --cross-prefix=PREFIX use PREFIX for compilation tools [$cross_prefix]"
@@ -77,8 +81,10 @@ ar="ar"
cc_default="gcc"
ranlib="ranlib"
strip="strip"
+winecmd="wine"
DEFAULT="msvc
+ wine
"
DEFAULT_NO="shared
@@ -117,6 +123,10 @@ for opt do
--cross-prefix=*)
cross_prefix="$optval"
;;
+ --enable-wine=*)
+ winecmd="$optval"
+ enable wine
+ ;;
--enable-?*|--disable-?*)
eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
echo "$CMDLINE_SELECT" | grep -q "^ *$option\$" || die_unknown $opt
@@ -158,7 +168,23 @@ test "$?" != 0 && {
exit 1;
}
-if enabled msvc; then
+if enabled wine; then # wine explicitly enabled
+ $winecmd --version > /dev/null 2>&1 /dev/null || {
+ echo "wine command not found."
+ echo "Make sure wine is installed and its bin folder is in your \$PATH."
+ exit 1
+ }
+elif disabled wine; then # explicitly disabled
+ winecmd=""
+else # autodetect
+ $winecmd --version > /dev/null 2>&1 /dev/null && enable wine || winecmd=""
+fi
+
+if ! enabled stripping; then
+ strip="@echo ignoring strip"
+fi
+
+if enabled msvc; then # msvc explicitly enabled
disabled shared && {
echo "MSVC understands static libraries created by gcc."
echo "There's no need to create an import lib."
@@ -171,11 +197,7 @@ if enabled msvc; then
}
fi
-if ! enabled stripping; then
- strip="@echo ignoring strip"
-fi
-
-if enabled shared; then
+if enabled shared; then # msvc autodetected
lib /? > /dev/null 2>&1 /dev/null && enable msvc || disable msvc
fi
@@ -193,6 +215,7 @@ echo "BUILD_SHARED=$shared" >> config.mak
echo "BUILD_STATIC=$static" >> config.mak
echo "BUILD_MSVC=$msvc" >> config.mak
echo "LIBCMD=$libcmd" >> config.mak
+echo "WINE=$winecmd" >> config.mak
echo "prefix: $prefix"
echo "libdir: $libdir"
@@ -207,3 +230,4 @@ if enabled shared; then
echo "msvc: $msvc";
echo "strip: $stripping";
fi
+echo "wine: $wine $winecmd"