aboutsummaryrefslogtreecommitdiff
path: root/configure2
diff options
context:
space:
mode:
Diffstat (limited to 'configure2')
-rwxr-xr-xconfigure2235
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
27set_all(){
28 value=$1
29 shift
30 for var in $*; do
31 eval $var=$value
32 done
33}
34
35enable(){
36 set_all yes $*
37}
38
39disable(){
40 set_all no $*
41}
42
43enabled(){
44 eval test "x\$$1" = "xyes"
45}
46
47disabled(){
48 eval test "x\$$1" = "xno"
49}
50
51show_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
71die_unknown(){
72 echo "Unknown option \"$1\"."
73 echo "See $0 --help for available options."
74 exit 1
75}
76
77prefix="/mingw"
78libdir='${prefix}/lib'
79incdir='${prefix}/include'
80ar="ar"
81cc_default="gcc"
82ranlib="ranlib"
83strip="strip"
84winecmd="wine"
85
86DEFAULT="msvc
87 wine
88"
89
90DEFAULT_NO="shared
91"
92
93DEFAULT_YES="static
94 stripping
95"
96
97CMDLINE_SELECT="$DEFAULT
98 $DEFAULT_NO
99 $DEFAULT_YES
100"
101
102enable $DEFAULT_YES
103disable $DEFAULT_NO
104
105for 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
139done
140
141ar="${cross_prefix}${ar}"
142cc_default="${cross_prefix}${cc_default}"
143ranlib="${cross_prefix}${ranlib}"
144strip="${cross_prefix}${strip}"
145
146if ! test -z $cc; then
147 cc_default="${cc}"
148fi
149cc="${cc_default}"
150
151disabled shared && disabled static && {
152 echo "At least one library type must be set.";
153 exit 1;
154}
155
156# simple cc test
157cat > /tmp/test.c << EOF
158#include <windows.h>
159void function(void)
160{ LoadLibrary(NULL); }
161EOF
162echo testing compiler: $cc -shared -o /tmp/test.dll /tmp/test.c
163$cc -shared -o /tmp/test.dll /tmp/test.c
164
165test "$?" != 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
171if 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 }
177elif disabled wine; then # explicitly disabled
178 winecmd=""
179else # autodetect
180 $winecmd --version > /dev/null 2>&1 /dev/null && enable wine || winecmd=""
181fi
182
183if ! enabled stripping; then
184 strip="@echo ignoring strip"
185fi
186
187if 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 }
198fi
199
200if enabled shared; then # msvc autodetected
201 lib /? > /dev/null 2>&1 /dev/null && enable msvc || disable msvc
202fi
203
204enabled msvc && libcmd="lib" || libcmd="@echo ignoring lib"
205
206echo "# Automatically generated by configure2" > config.mak
207echo "prefix=$prefix" >> config.mak
208echo "libdir=$libdir" >> config.mak
209echo "incdir=$incdir" >> config.mak
210echo "AR=$ar" >> config.mak
211echo "CC=$cc" >> config.mak
212echo "RANLIB=$ranlib" >> config.mak
213echo "STRIP=$strip" >> config.mak
214echo "BUILD_SHARED=$shared" >> config.mak
215echo "BUILD_STATIC=$static" >> config.mak
216echo "BUILD_MSVC=$msvc" >> config.mak
217echo "LIBCMD=$libcmd" >> config.mak
218echo "WINE=$winecmd" >> config.mak
219
220echo "prefix: $prefix"
221echo "libdir: $libdir"
222echo "incdir: $incdir"
223echo "ar: $ar"
224echo "cc: $cc"
225echo "ranlib: $ranlib"
226echo "strip: $strip"
227echo "static: $static"
228echo "shared: $shared"
229if enabled shared; then
230 echo "msvc: $msvc";
231 echo "strip: $stripping";
232fi
233echo "wine: $wine $winecmd"
234
235echo "Run `make -f Makefile2` to build." \ No newline at end of file