internalize private cecil
[mono.git] / mono / wrapper / build-dll
1 #!/bin/bash\r
2 \r
3 # Temporary hack until building dlls is easier with gcc -mno-cygwin\r
4 # ("mingw32").\r
5 \r
6 # This is usable with cygwin 1.1.x and gcc-2.95.2 for mingw as\r
7 # distributed by Mumit Khan. For other combinations, no idea.\r
8 \r
9 GCC="gcc"\r
10 DLLTOOL="dlltool"\r
11 AS=as\r
12 \r
13 library=$1; shift\r
14 version=$1; shift;\r
15 def=$1; shift\r
16 ldargs="$*"\r
17 \r
18 defswitch=""\r
19 [ -n "$def" -a "$def" != '-' ] && defswitch="--def $def"\r
20 \r
21 libname=$library\r
22 [ $version != '-' ] && libname=$library-$version\r
23 dllfile=$libname.dll\r
24 \r
25 for F in $ldargs; do\r
26     case $F in\r
27         *.[ao]) objs="$objs $F";;\r
28     esac\r
29 done\r
30 \r
31 # Check if we have a resource file for this DLL.\r
32 resfile=""\r
33 if [ -f $library.rc ]; then\r
34     resfile=$library-win32res.o\r
35     objs="$objs $resfile"\r
36     ldargs="$ldargs $resfile"\r
37 \r
38     # Check if we have a build number stamp file.\r
39     if [ -f $library-build.stamp ]; then\r
40         read number <$library-build.stamp\r
41         buildnumber=$[number+1]\r
42         echo Build number is $buildnumber\r
43         echo $buildnumber >$library-build.stamp\r
44     else\r
45         echo Using zero as build number\r
46         buildnumber=0\r
47     fi\r
48 \r
49     m4 -DBUILDNUMBER=$buildnumber <$library.rc >$library-win32res.rc\r
50     windres $library-win32res.rc $library-win32res.o\r
51     rm $library-win32res.rc\r
52 fi\r
53 \r
54 # Build the DLL.\r
55 \r
56 $GCC -mdll -mno-cygwin -Wl,--base-file,$library.base -o $dllfile $ldargs &&\r
57 $DLLTOOL --as=$AS --dllname $dllfile $defswitch --base-file $library.base --output-exp $library.exp $objs &&\r
58 $GCC -mdll -mno-cygwin -Wl,--base-file,$library.base,$library.exp -o $dllfile $ldargs &&\r
59 $DLLTOOL --as=$AS --dllname $dllfile $defswitch --base-file $library.base --output-exp $library.exp $objs &&\r
60 $GCC -mdll -mno-cygwin -Wl,$library.exp -o $dllfile $ldargs &&\r
61 $DLLTOOL --as=$AS --dllname $dllfile $defswitch --output-lib lib$libname.a $objs\r
62 \r
63 # Finally, also build import libraries for the Microsoft linker. You\r
64 # will either need to have some decent version of MSVC, or get lib.exe\r
65 # (and link.exe) from the (freely downloadable) Microsoft Platform SDK.\r
66 \r
67 if type -p lib.exe && [ -n "$def" -a "$def" != '-' ]; then\r
68     lib -name:$libname.dll -def:$def -out:$libname.lib\r
69 fi\r
70 \r
71 rm $library.base $library.exp 2>/dev/null\r