Mercurial > pub > dyncall > dyncall
annotate configure @ 253:5cfe4322c500
- improved support for older OS versions for dynloads dlGetLibraryPath
author | Tassilo Philipp |
---|---|
date | Mon, 15 May 2017 02:50:03 +0200 |
parents | 700c67984c08 |
children | 7520e2260097 |
rev | line source |
---|---|
0 | 1 #!/bin/sh |
2 C=Makefile.config | |
3 | |
4 # get full path | |
5 case $0 in | |
6 /*) | |
7 FULL=$0 | |
8 ;; | |
9 *) | |
10 FULL=$PWD/$0 | |
11 ;; | |
12 esac | |
13 | |
14 printf "# auto-generated by $0\n" >$C | |
15 while [ $# -gt 0 ]; do | |
16 X=$1 | |
17 shift 1 | |
18 # Shell common: | |
19 case $X in | |
20 --help|-h|-?) | |
21 cat <<EOF | |
22 usage: $0 --<option>=<value> <var>=<value> .. | |
23 | |
24 --prefix=<dir> | |
25 --target=<platform> uname/special targets: MacOSX,iOS,iPhoneSimulator | |
30
c16bc7736bb4
- added configure (only sh-version) option to display list of settable targets
cslag
parents:
5
diff
changeset
|
26 use "?" to get a list of explicitly specifiable |
c16bc7736bb4
- added configure (only sh-version) option to display list of settable targets
cslag
parents:
5
diff
changeset
|
27 targets |
0 | 28 --sdk=<version> Mac OS X/iOS SDK version (e.g. '6.1' or '10.9.3') |
29 Tested iOS SDK versions: 4.3, 6.1, 8.1 | |
30 --sdkroot=<dir> | |
31 | |
32 Useful variables CC, CXX, CFLAGS, CXXFLAGS, etc.. | |
33 | |
34 EOF | |
35 exit 1 | |
36 ;; | |
37 # GNU Compatibility: | |
38 --prefix=*) | |
39 PREFIX=`printf -- "${X}" | cut -c 10-` | |
40 ;; | |
41 --target=*) | |
42 TARGET=`printf -- "${X}" | cut -c 10-` | |
43 ;; | |
44 --sdk=*) | |
45 SDK=`printf -- "${X}" | cut -c 7-` | |
46 ;; | |
47 --sdkroot=*) | |
48 SDKROOT=`printf -- "${X}" | cut -c 11-` | |
49 ;; | |
50 # Environment variables: | |
51 [A-Za-z_]*=*) | |
52 printf "${X}\n" >>$C | |
53 k=`printf "${X}" | cut -d = -f 1` | |
54 v=`printf "${X}" | cut -d = -f 2` | |
55 export $k="$v" | |
56 ;; | |
57 # Others fail: | |
58 *) | |
59 printf "error: invalid option ${X}\n" >&2 | |
60 exit 1 | |
61 ;; | |
62 esac | |
63 done | |
64 printf "PREFIX=${PREFIX:=/usr/local}\n" >>$C | |
65 case ${TARGET:=`uname`} in | |
253
5cfe4322c500
- improved support for older OS versions for dynloads dlGetLibraryPath
Tassilo Philipp
parents:
222
diff
changeset
|
66 Linux|GNU/kFreeBSD) |
0 | 67 if [ -z "${CFLAGS}" ]; then |
68 printf "CFLAGS=-fPIC\n" >>$C | |
69 fi | |
70 printf "LDLIBS=-lm -ldl\n" >>$C | |
71 ;; | |
72 OpenBSD) | |
253
5cfe4322c500
- improved support for older OS versions for dynloads dlGetLibraryPath
Tassilo Philipp
parents:
222
diff
changeset
|
73 if [ -z "${CFLAGS}" ]; then |
5cfe4322c500
- improved support for older OS versions for dynloads dlGetLibraryPath
Tassilo Philipp
parents:
222
diff
changeset
|
74 # dl_iterate_phdr() got introduced in 3.7, so for older versions force DL_DLADDR_TO_LIBPATH |
5cfe4322c500
- improved support for older OS versions for dynloads dlGetLibraryPath
Tassilo Philipp
parents:
222
diff
changeset
|
75 if (uname -r | grep '^\([0-2]\.\|3\.[0-6]\)' > /dev/null); then |
5cfe4322c500
- improved support for older OS versions for dynloads dlGetLibraryPath
Tassilo Philipp
parents:
222
diff
changeset
|
76 printf "CFLAGS=-fPIC -DDL_DLADDR_TO_LIBPATH\n" >>$C |
5cfe4322c500
- improved support for older OS versions for dynloads dlGetLibraryPath
Tassilo Philipp
parents:
222
diff
changeset
|
77 else |
5cfe4322c500
- improved support for older OS versions for dynloads dlGetLibraryPath
Tassilo Philipp
parents:
222
diff
changeset
|
78 printf "CFLAGS=-fPIC\n" >>$C |
5cfe4322c500
- improved support for older OS versions for dynloads dlGetLibraryPath
Tassilo Philipp
parents:
222
diff
changeset
|
79 fi |
5cfe4322c500
- improved support for older OS versions for dynloads dlGetLibraryPath
Tassilo Philipp
parents:
222
diff
changeset
|
80 fi |
0 | 81 printf "LDLIBS=-lm\n" >>$C |
82 ;; | |
253
5cfe4322c500
- improved support for older OS versions for dynloads dlGetLibraryPath
Tassilo Philipp
parents:
222
diff
changeset
|
83 NetBSD|DragonFly) |
0 | 84 if [ -z "${CFLAGS}" ]; then |
85 printf "CFLAGS=-fPIC\n" >>$C | |
86 fi | |
87 printf "LDLIBS=-lm\n" >>$C | |
88 ;; | |
89 FreeBSD) | |
90 if [ -z "${CFLAGS}" ]; then | |
91 printf "CFLAGS=-fPIC\n" >>$C | |
92 fi | |
93 printf "LDLIBS=-lm\n" >>$C | |
94 printf "RM=rm -f\n" >>$C | |
95 ;; | |
96 MacOSX|Darwin) | |
97 # if Apple's libtool (not to be confused with GNU's) is available, which is according to libtool(1) "with -static [...] intended | |
98 # to replace ar(5) and ranlib", use it - if it is shadowed by some install of GNU's libtool assume that a foreign environment is | |
99 # intentionally used, and fall back to using 'ar rs' (the equivalent to 'libtool -static'), for compatibility: | |
100 if libtool -V >/dev/null 2>/dev/null; then # Apple's libtool has -V for version, which GNU does not. | |
101 printf "AR=libtool\n" >>$C | |
102 printf "ARFLAGS=-static -o\n" >>$C | |
103 else | |
104 printf "AR=ar\n" >>$C | |
105 printf "ARFLAGS=rs\n" >>$C # 's' is crucial for universal binary archives | |
106 fi | |
107 if [ `uname -n` = 'iPhone' ]; then # building on iPhone itself, uname yields Darwin (gcc setup for current/correct arch) | |
108 printf "CC=gcc\n" >>$C | |
109 elif [ -z ${SDK} ]; then | |
110 case `sw_vers -productVersion` in | |
111 10.4.*) | |
112 ARCHS="-arch ppc -arch i386 -arch x86_64" | |
113 ;; | |
5
52deacbdd2b1
- fix from MoarVM team and Tobi Leich for osx configure
cslag
parents:
0
diff
changeset
|
114 10.5.*) |
0 | 115 ARCHS="-arch i386 -arch x86_64 -arch ppc" |
116 ;; | |
117 10.6.*) | |
118 ARCHS="-arch i386 -arch x86_64" | |
119 ;; | |
222
700c67984c08
- fix to configure for universal binary support for >= macos el capitan
Tassilo Philipp
parents:
170
diff
changeset
|
120 10.[789].*|10.1?.*|10.1?) |
0 | 121 ARCHS="-arch x86_64 -arch i386" |
122 ;; | |
123 esac | |
124 printf "ASFLAGS=${ARCHS}\n" >>$C | |
125 printf "CFLAGS=${ARCHS}\n" >>$C | |
126 printf "CXXFLAGS=${ARCHS}\n" >>$C | |
127 else | |
128 if [ -z ${SDKROOT} ]; then | |
129 SDKROOT="`xcode-select -print-path`/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${SDK}.sdk" | |
130 fi | |
131 printf "CFLAGS=-isysroot ${SDKROOT}\n" >>$C | |
132 printf "CXXFLAGS=-isysroot ${SDKROOT}\n" >>$C | |
133 fi | |
134 ;; | |
135 iPhoneOS|iOS) | |
136 if [ -z ${SDKROOT} ]; then | |
137 SDKROOT="`xcode-select -print-path`/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${SDK}.sdk" | |
138 fi | |
139 if [ -z "${ARCHS}" ]; then | |
140 case "${SDK}" in | |
141 [45].*) | |
142 ARCHS="-arch armv6" | |
143 ;; | |
144 [67].*) | |
145 ARCHS="-arch armv7" | |
146 ;; | |
53 | 147 [89].*) |
0 | 148 ARCHS="-arch armv7 -arch arm64" |
149 ;; | |
150 esac | |
151 fi | |
152 printf "ARFLAGS=rs\n" >>$C # 's' is crucial for universal binary archives | |
153 printf "ASFLAGS=${ARCHS} -isysroot ${SDKROOT}\n" >>$C | |
154 printf "CFLAGS=${ARCHS} -isysroot ${SDKROOT}\n" >>$C | |
155 printf "CXXFLAGS=${ARCHS} -isysroot ${SDKROOT}\n" >>$C | |
156 printf "LDFLAGS=-Wl,-syslibroot ${SDKROOT}\n" >>$C | |
157 ;; | |
158 iPhoneSimulator) | |
159 if [ -z ${SDKROOT} ]; then | |
160 SDKROOT="`xcode-select -print-path`/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator${SDK}.sdk" | |
161 fi | |
162 ARCHS="-arch i386" | |
163 printf "ASFLAGS=${ARCHS} -isysroot ${SDKROOT}\n" >>$C | |
164 printf "CFLAGS=${ARCHS} -isysroot ${SDKROOT}\n" >>$C | |
165 printf "CXXFLAGS=${ARCHS} -isysroot ${SDKROOT}\n" >>$C | |
166 printf "LDFLAGS=-Wl,-syslibroot ${SDKROOT}\n" >>$C | |
167 ;; | |
168 SunOS) | |
169 # open distributions often don't come with default cc and CC, check for common alternatives. | |
170 | 170 printf "CC=` (which cc gcc clang ) | grep -v '^no ' | head -1`\n" >>$C |
171 printf "CXX=`(which CC g++ clang++) | grep -v '^no ' | head -1`\n" >>$C # C++ compiler traditionally named CC | |
172 printf "CCC=\${CXX}\n" >>$C # Sun make's rules use CCC for c++ compiler | |
253
5cfe4322c500
- improved support for older OS versions for dynloads dlGetLibraryPath
Tassilo Philipp
parents:
222
diff
changeset
|
173 printf "LDLIBS=-lm -ldl\n" >>$C |
0 | 174 ;; |
175 Minix) | |
176 printf "CC=gcc\n" >>$C | |
177 printf "CXX=g++\n">>$C | |
178 printf "AR=ar\n" >>$C | |
179 ;; | |
180 PSP) | |
181 SDKROOT="`psp-config --pspsdk-path`" | |
182 printf "CC=psp-gcc\n" >>$C | |
183 printf "CXX=psp-gcc\n">>$C # don't use psp-g++, buggy | |
184 printf "AR=psp-ar\n" >>$C | |
185 printf "CFLAGS=-I${SDKROOT}/include/\n" >>$C | |
186 printf "CXXFLAGS=-I${SDKROOT}/include/\n" >>$C | |
187 # Pulling in dyncall libs below is a hack, for some reason psp-ld is super-picky about order. | |
188 # Use your C lib of choice, from the PSPSDK, or... | |
189 #printf "LDLIBS=-L${SDKROOT}/lib/ -L`dirname ${FULL}`/dyncall -L`dirname ${FULL}`/dyncallback -ldyncall_s -ldyncallback_s -lm -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lstdc++ -lpsplibc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser \n" >>$C | |
190 # ... newlib. | |
191 printf "LDLIBS=-L${SDKROOT}/lib/ -L`dirname ${FULL}`/dyncall -L`dirname ${FULL}`/dyncallback -ldyncall_s -ldyncallback_s -lm -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lstdc++ -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser \n" >>$C | |
192 ;; | |
30
c16bc7736bb4
- added configure (only sh-version) option to display list of settable targets
cslag
parents:
5
diff
changeset
|
193 ?) |
c16bc7736bb4
- added configure (only sh-version) option to display list of settable targets
cslag
parents:
5
diff
changeset
|
194 cat $0 | awk '/^esac$/{b=0}/^ [A-Za-z0-9|]+\)/{if(b==1) print substr($1,1,length($1)-1)}BEGIN{b=0}/^case.*TARGET.*uname.*in$/{b=1}' | tr '|' '\n' |
c16bc7736bb4
- added configure (only sh-version) option to display list of settable targets
cslag
parents:
5
diff
changeset
|
195 exit 0 |
c16bc7736bb4
- added configure (only sh-version) option to display list of settable targets
cslag
parents:
5
diff
changeset
|
196 ;; |
0 | 197 esac |
198 | |
199 BLDTOP="$PWD" | |
200 SRCTOP=`dirname ${FULL}` | |
201 | |
202 FILES=`( cd $SRCTOP ; find . -name "Makefile.generic" )` | |
203 for FILE in $FILES ; do | |
204 SRCFILE="$SRCTOP/$FILE" | |
205 BLDFILE="$BLDTOP/$FILE" | |
206 SRCDIR=`dirname $SRCFILE` | |
207 BLDDIR=`dirname $BLDFILE` | |
208 mkdir -p "$BLDDIR" | |
209 cat <<EOF >$BLDDIR/Makefile | |
210 VPATH = $SRCDIR | |
211 include $BLDTOP/Makefile.config | |
212 include \${VPATH}/Makefile.generic | |
213 EOF | |
214 done |