Commit 665499d095190d49a9b70059a6c7225f81abc78b

Timothy Gu 2014-03-27T02:58:02

Build sys additions * wine support for testing * License boilerplate * Reorder configure checks

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"