diff options
Diffstat (limited to 'configure2')
-rwxr-xr-x | configure2 | 235 |
1 files changed, 235 insertions, 0 deletions
diff --git a/configure2 b/configure2 new file mode 100755 index 0000000..ba5fcd7 --- /dev/null +++ b/configure2 | |||
@@ -0,0 +1,235 @@ | |||
1 | #!/bin/sh | ||
2 | # dlfcn-win32 configure script | ||
3 | # | ||
4 | # Copyright (c) 2007, 2009, 2012 Ramiro Polla | ||
5 | # Copyright (c) 2014 Tiancheng "Timothy" Gu | ||
6 | # | ||
7 | # Parts copied from FFmpeg's configure. Original license was: | ||
8 | # | ||
9 | # Copyright (c) 2000-2002 Fabrice Bellard | ||
10 | # Copyright (c) 2005-2007 Diego Biurrun | ||
11 | # Copyright (c) 2005-2007 Mans Rullgard | ||
12 | # | ||
13 | # dlfcn-win32 is free software; you can redistribute it and/or | ||
14 | # modify it under the terms of the GNU Lesser General Public | ||
15 | # License as published by the Free Software Foundation; either | ||
16 | # version 2.1 of the License, or (at your option) any later version. | ||
17 | |||
18 | # dlfcn-win32 is distributed in the hope that it will be useful, | ||
19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
21 | # Lesser General Public License for more details. | ||
22 | # | ||
23 | # You should have received a copy of the GNU Lesser General Public | ||
24 | # License along with dlfcn-win32; if not, write to the Free Software | ||
25 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
26 | |||
27 | set_all(){ | ||
28 | value=$1 | ||
29 | shift | ||
30 | for var in $*; do | ||
31 | eval $var=$value | ||
32 | done | ||
33 | } | ||
34 | |||
35 | enable(){ | ||
36 | set_all yes $* | ||
37 | } | ||
38 | |||
39 | disable(){ | ||
40 | set_all no $* | ||
41 | } | ||
42 | |||
43 | enabled(){ | ||
44 | eval test "x\$$1" = "xyes" | ||
45 | } | ||
46 | |||
47 | disabled(){ | ||
48 | eval test "x\$$1" = "xno" | ||
49 | } | ||
50 | |||
51 | show_help(){ | ||
52 | echo "Usage: configure [options]" | ||
53 | echo "Options: [defaults in brackets after descriptions]" | ||
54 | echo "All \"enable\" options have \"disable\" counterparts" | ||
55 | echo | ||
56 | echo " --help print this message" | ||
57 | echo " --prefix=PREFIX install in PREFIX [$prefix]" | ||
58 | echo " --libdir=DIR install libs in DIR [$libdir]" | ||
59 | echo " --incdir=DIR install includes in DIR [$incdir]" | ||
60 | echo " --enable-shared build shared libraries [no]" | ||
61 | echo " --enable-static build static libraries [yes]" | ||
62 | echo " --enable-msvc create msvc-compatible import lib [auto]" | ||
63 | echo " --enable-stripping strip shared library [yes]" | ||
64 | echo " --enable-wine[=cmd] use wine in tests [auto,cmd=$winecmd]" | ||
65 | echo | ||
66 | echo " --cc=CC use C compiler CC [$cc_default]" | ||
67 | echo " --cross-prefix=PREFIX use PREFIX for compilation tools [$cross_prefix]" | ||
68 | exit 1 | ||
69 | } | ||
70 | |||
71 | die_unknown(){ | ||
72 | echo "Unknown option \"$1\"." | ||
73 | echo "See $0 --help for available options." | ||
74 | exit 1 | ||
75 | } | ||
76 | |||
77 | prefix="/mingw" | ||
78 | libdir='${prefix}/lib' | ||
79 | incdir='${prefix}/include' | ||
80 | ar="ar" | ||
81 | cc_default="gcc" | ||
82 | ranlib="ranlib" | ||
83 | strip="strip" | ||
84 | winecmd="wine" | ||
85 | |||
86 | DEFAULT="msvc | ||
87 | wine | ||
88 | " | ||
89 | |||
90 | DEFAULT_NO="shared | ||
91 | " | ||
92 | |||
93 | DEFAULT_YES="static | ||
94 | stripping | ||
95 | " | ||
96 | |||
97 | CMDLINE_SELECT="$DEFAULT | ||
98 | $DEFAULT_NO | ||
99 | $DEFAULT_YES | ||
100 | " | ||
101 | |||
102 | enable $DEFAULT_YES | ||
103 | disable $DEFAULT_NO | ||
104 | |||
105 | for opt do | ||
106 | optval="${opt#*=}" | ||
107 | case "$opt" in | ||
108 | --help) | ||
109 | show_help | ||
110 | ;; | ||
111 | --prefix=*) | ||
112 | prefix="$optval" | ||
113 | ;; | ||
114 | --libdir=*) | ||
115 | libdir="$optval" | ||
116 | ;; | ||
117 | --incdir=*) | ||
118 | incdir="$optval" | ||
119 | ;; | ||
120 | --cc=*) | ||
121 | cc="$optval" | ||
122 | ;; | ||
123 | --cross-prefix=*) | ||
124 | cross_prefix="$optval" | ||
125 | ;; | ||
126 | --enable-wine=*) | ||
127 | winecmd="$optval" | ||
128 | enable wine | ||
129 | ;; | ||
130 | --enable-?*|--disable-?*) | ||
131 | eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'` | ||
132 | echo "$CMDLINE_SELECT" | grep -q "^ *$option\$" || die_unknown $opt | ||
133 | $action $option | ||
134 | ;; | ||
135 | *) | ||
136 | die_unknown $opt | ||
137 | ;; | ||
138 | esac | ||
139 | done | ||
140 | |||
141 | ar="${cross_prefix}${ar}" | ||
142 | cc_default="${cross_prefix}${cc_default}" | ||
143 | ranlib="${cross_prefix}${ranlib}" | ||
144 | strip="${cross_prefix}${strip}" | ||
145 | |||
146 | if ! test -z $cc; then | ||
147 | cc_default="${cc}" | ||
148 | fi | ||
149 | cc="${cc_default}" | ||
150 | |||
151 | disabled shared && disabled static && { | ||
152 | echo "At least one library type must be set."; | ||
153 | exit 1; | ||
154 | } | ||
155 | |||
156 | # simple cc test | ||
157 | cat > /tmp/test.c << EOF | ||
158 | #include <windows.h> | ||
159 | void function(void) | ||
160 | { LoadLibrary(NULL); } | ||
161 | EOF | ||
162 | echo testing compiler: $cc -shared -o /tmp/test.dll /tmp/test.c | ||
163 | $cc -shared -o /tmp/test.dll /tmp/test.c | ||
164 | |||
165 | test "$?" != 0 && { | ||
166 | echo "$cc could not create shared file with Windows API functions."; | ||
167 | echo "Make sure your MinGW system is working properly."; | ||
168 | exit 1; | ||
169 | } | ||
170 | |||
171 | if enabled wine; then # wine explicitly enabled | ||
172 | $winecmd --version > /dev/null 2>&1 /dev/null || { | ||
173 | echo "wine command not found." | ||
174 | echo "Make sure wine is installed and its bin folder is in your \$PATH." | ||
175 | exit 1 | ||
176 | } | ||
177 | elif disabled wine; then # explicitly disabled | ||
178 | winecmd="" | ||
179 | else # autodetect | ||
180 | $winecmd --version > /dev/null 2>&1 /dev/null && enable wine || winecmd="" | ||
181 | fi | ||
182 | |||
183 | if ! enabled stripping; then | ||
184 | strip="@echo ignoring strip" | ||
185 | fi | ||
186 | |||
187 | if enabled msvc; then # msvc explicitly enabled | ||
188 | disabled shared && { | ||
189 | echo "MSVC understands static libraries created by gcc." | ||
190 | echo "There's no need to create an import lib." | ||
191 | exit 1 | ||
192 | } | ||
193 | lib /? > /dev/null 2>&1 /dev/null || { | ||
194 | echo "MSVC's lib command not found." | ||
195 | echo "Make sure MSVC is installed and its bin folder is in your \$PATH." | ||
196 | exit 1 | ||
197 | } | ||
198 | fi | ||
199 | |||
200 | if enabled shared; then # msvc autodetected | ||
201 | lib /? > /dev/null 2>&1 /dev/null && enable msvc || disable msvc | ||
202 | fi | ||
203 | |||
204 | enabled msvc && libcmd="lib" || libcmd="@echo ignoring lib" | ||
205 | |||
206 | echo "# Automatically generated by configure2" > config.mak | ||
207 | echo "prefix=$prefix" >> config.mak | ||
208 | echo "libdir=$libdir" >> config.mak | ||
209 | echo "incdir=$incdir" >> config.mak | ||
210 | echo "AR=$ar" >> config.mak | ||
211 | echo "CC=$cc" >> config.mak | ||
212 | echo "RANLIB=$ranlib" >> config.mak | ||
213 | echo "STRIP=$strip" >> config.mak | ||
214 | echo "BUILD_SHARED=$shared" >> config.mak | ||
215 | echo "BUILD_STATIC=$static" >> config.mak | ||
216 | echo "BUILD_MSVC=$msvc" >> config.mak | ||
217 | echo "LIBCMD=$libcmd" >> config.mak | ||
218 | echo "WINE=$winecmd" >> config.mak | ||
219 | |||
220 | echo "prefix: $prefix" | ||
221 | echo "libdir: $libdir" | ||
222 | echo "incdir: $incdir" | ||
223 | echo "ar: $ar" | ||
224 | echo "cc: $cc" | ||
225 | echo "ranlib: $ranlib" | ||
226 | echo "strip: $strip" | ||
227 | echo "static: $static" | ||
228 | echo "shared: $shared" | ||
229 | if enabled shared; then | ||
230 | echo "msvc: $msvc"; | ||
231 | echo "strip: $stripping"; | ||
232 | fi | ||
233 | echo "wine: $wine $winecmd" | ||
234 | |||
235 | echo "Run `make -f Makefile2` to build." \ No newline at end of file | ||