Interpret EINTR as G_IO_ERROR_AGAIN.
[platform/upstream/glib.git] / build-dll
index a02d644..3ad30ac 100644 (file)
--- a/build-dll
+++ b/build-dll
@@ -1,9 +1,14 @@
-#!/bin/sh
+#!/bin/bash
 
-# Temporary hack until building dlls with gcc -mno-cygwin is easier
+# Temporary hack until building dlls is easier with gcc -mno-cygwin
+# ("mingw32").
 
-LD=ld
-DLLTOOL=dlltool
+# This is usable with cygwin b20.1 and egcs-2.91.66 19990314
+# (egcs-1.1.2 release) or gcc-2.95(.2) as distributed by Mumit Khan. For
+# other combinations, no idea.
+
+GCC="gcc"
+DLLTOOL="dlltool"
 AS=as
 
 library=$1; shift
@@ -20,14 +25,23 @@ dllfile=$libname.dll
 
 for F in $ldargs; do
     case $F in
-       *.o)    objs="$objs $F";;
+       *.[ao]) objs="$objs $F";;
     esac
 done
 
-$LD -s --base-file $library.base --dll -o $dllfile $ldargs -e _DllMain@12 -lmingw32
-$DLLTOOL --as=$AS --dllname $dllfile $defswitch --base-file $library.base --output-exp $library.exp $objs
-$LD -s --base-file $library.base $library.exp --dll -o $dllfile $ldargs -e _DllMain@12 -lmingw32
-$DLLTOOL --as=$AS --dllname $dllfile $defswitch --base-file $library.base --output-exp $library.exp $objs
-$LD $library.exp --dll -o $dllfile $ldargs -e _DllMain@12 -lmingw32
+$GCC -mdll -mno-cygwin -Wl,--base-file,$library.base -o $dllfile $ldargs &&
+$DLLTOOL --as=$AS --dllname $dllfile $defswitch --base-file $library.base --output-exp $library.exp $objs &&
+$GCC -mdll -mno-cygwin -Wl,--base-file,$library.base,$library.exp -o $dllfile $ldargs &&
+$DLLTOOL --as=$AS --dllname $dllfile $defswitch --base-file $library.base --output-exp $library.exp $objs &&
+$GCC -mdll -mno-cygwin -Wl,$library.exp -o $dllfile $ldargs &&
 $DLLTOOL --as=$AS --dllname $dllfile $defswitch --output-lib lib$libname.a $objs
-rm $library.base $library.exp
+
+# Finally, also build import libraries for the Microsoft linker. You
+# will either need to have some decent version of MSVC, or get lib.exe
+# (and link.exe) from the (freely downloadable) Microsoft Platform SDK.
+
+if type -p lib.exe && [ -n "$def" -a "$def" != '-' ]; then
+    lib -name:$libname.dll -def:$def -out:$libname.lib
+fi
+
+rm $library.base $library.exp 2>/dev/null