1 #!/bin/sh |
1 #!/bin/sh |
2 |
|
3 failed() |
|
4 { |
|
5 $@ |
|
6 if [ $? -ne 0 ]; then |
|
7 return 0 |
|
8 else |
|
9 return 1 |
|
10 fi |
|
11 } |
|
12 |
|
13 |
2 |
14 # create temporary directory |
3 # create temporary directory |
15 TEMP_DIR=".tmp-`uname -n`" |
4 TEMP_DIR=".tmp-`uname -n`" |
16 rm -Rf "$TEMP_DIR" |
5 rm -Rf "$TEMP_DIR" |
17 if failed mkdir -p "$TEMP_DIR"; then |
6 if mkdir -p "$TEMP_DIR"; then |
|
7 : |
|
8 else |
18 echo "Cannot create tmp dir $TEMP_DIR" |
9 echo "Cannot create tmp dir $TEMP_DIR" |
19 echo "Abort" |
10 echo "Abort" |
20 exit 1 |
11 exit 1 |
21 fi |
12 fi |
22 touch "$TEMP_DIR/options" |
13 touch "$TEMP_DIR/options" |
111 esac |
102 esac |
112 done |
103 done |
113 |
104 |
114 |
105 |
115 # set dir variables |
106 # set dir variables |
116 BINDIR=${BINDIR:-"$EPREFIX/bin"} |
107 : ${BINDIR:="$EPREFIX/bin"} |
117 SBINDIR=${SBINDIR:-"$EPREFIX/sbin"} |
108 : ${SBINDIR:="$EPREFIX/sbin"} |
118 LIBDIR=${LIBDIR:-"$EPREFIX/lib"} |
109 : ${LIBDIR:="$EPREFIX/lib"} |
119 LIBEXECDIR=${LIBEXECDIR:-"$EPREFIX/libexec"} |
110 : ${LIBEXECDIR:="$EPREFIX/libexec"} |
120 DATADIR=${DATADIR:-"$PREFIX/share"} |
111 : ${DATADIR:="$PREFIX/share"} |
121 SYSCONFDIR=${SYSCONFDIR:-"$PREFIX/etc"} |
112 : ${SYSCONFDIR:="$PREFIX/etc"} |
122 SHAREDSTATEDIR=${SHAREDSTATEDIR:-"$PREFIX/com"} |
113 : ${SHAREDSTATEDIR:="$PREFIX/com"} |
123 LOCALSTATEDIR=${LOCALSTATEDIR:-"$PREFIX/var"} |
114 : ${LOCALSTATEDIR:="$PREFIX/var"} |
124 INCLUDEDIR=${INCLUDEDIR:-"$PREFIX/include"} |
115 : ${INCLUDEDIR:="$PREFIX/include"} |
125 INFODIR=${INFODIR:-"$PREFIX/info"} |
116 : ${INFODIR:="$PREFIX/info"} |
126 MANDIR=${MANDIR:-"$PREFIX/man"} |
117 : ${MANDIR:="$PREFIX/man"} |
127 |
118 |
128 # Test for availability of pkg-config |
119 # Test for availability of pkg-config |
129 PKG_CONFIG=`command -v pkg-config` |
120 PKG_CONFIG=`command -v pkg-config` |
130 PKG_CONFIG=${PKG_CONFIG:-"false"} |
121 : ${PKG_CONFIG:="false"} |
131 |
122 |
132 # Simple uname based platform detection |
123 # Simple uname based platform detection |
133 # $PLATFORM is used for platform dependent dependency selection |
124 # $PLATFORM is used for platform dependent dependency selection |
134 OS=`uname -s` |
125 OS=`uname -s` |
135 OS_VERSION=`uname -r` |
126 OS_VERSION=`uname -r` |
147 PLATFORM="macos osx bsd unix" |
138 PLATFORM="macos osx bsd unix" |
148 fi |
139 fi |
149 if echo "$OS" | grep -i "MINGW" > /dev/null; then |
140 if echo "$OS" | grep -i "MINGW" > /dev/null; then |
150 PLATFORM="windows mingw" |
141 PLATFORM="windows mingw" |
151 fi |
142 fi |
152 PLATFORM=${PLATFORM:-"unix"} |
143 : ${PLATFORM:="unix"} |
153 |
144 |
154 PLATFORM_NAME=`echo "$PLATFORM" | cut -f1 -d' ' -` |
145 PLATFORM_NAME=`echo "$PLATFORM" | cut -f1 -d' ' -` |
155 echo "$PLATFORM_NAME" |
146 echo "$PLATFORM_NAME" |
156 |
147 |
157 isplatform() |
148 isplatform() |
200 echo "Toolchain error: $TOOLCHAIN_ERROR" |
201 echo "Toolchain error: $TOOLCHAIN_ERROR" |
201 echo "Abort." |
202 echo "Abort." |
202 abort_configure |
203 abort_configure |
203 fi |
204 fi |
204 |
205 |
205 |
|
206 # |
206 # |
207 # DEPENDENCIES |
207 # DEPENDENCIES |
208 # |
208 # |
209 |
209 |
210 # create buffer for make variables required by dependencies |
210 # create buffer for make variables required by dependencies |
211 echo > "$TEMP_DIR/make.mk" |
211 echo > "$TEMP_DIR/make.mk" |
212 |
212 |
213 dependency_libpq() |
213 dependency_error_libpq() |
214 { |
214 { |
215 printf "checking for libpq... " |
215 printf "checking for libpq... " |
216 # dependency libpq |
216 # dependency libpq |
217 while true |
217 while true |
218 do |
218 do |
219 if [ -z "$PKG_CONFIG" ]; then |
219 if [ -z "$PKG_CONFIG" ]; then |
220 break |
220 break |
221 fi |
221 fi |
222 if failed $PKG_CONFIG libpq ; then |
222 if $PKG_CONFIG libpq ; then |
223 break |
223 TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags libpq`" |
224 fi |
224 TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs libpq`" |
225 TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags libpq`" |
225 else |
226 TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs libpq`" |
226 break |
|
227 fi |
227 echo yes |
228 echo yes |
228 return 0 |
229 return 1 |
229 done |
230 done |
230 |
231 |
231 echo no |
232 echo no |
232 return 1 |
233 return 0 |
233 } |
234 } |
234 dependency_openssl() |
235 dependency_error_openssl() |
235 { |
236 { |
236 printf "checking for openssl... " |
237 printf "checking for openssl... " |
237 # dependency openssl |
238 # dependency openssl |
238 while true |
239 while true |
239 do |
240 do |
240 if [ -z "$PKG_CONFIG" ]; then |
241 if [ -z "$PKG_CONFIG" ]; then |
241 break |
242 break |
242 fi |
243 fi |
243 if failed $PKG_CONFIG openssl ; then |
244 if $PKG_CONFIG openssl ; then |
244 break |
245 TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags openssl`" |
245 fi |
246 TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs openssl`" |
246 TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags openssl`" |
247 else |
247 TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs openssl`" |
248 break |
|
249 fi |
248 echo yes |
250 echo yes |
249 return 0 |
251 return 1 |
250 done |
252 done |
251 |
253 |
252 # dependency openssl platform="bsd" |
254 # dependency openssl platform="bsd" |
253 while true |
255 while true |
254 do |
256 do |
255 if failed isplatform "bsd"; then |
257 if notisplatform "bsd"; then |
256 break |
258 break |
257 fi |
259 fi |
258 TEMP_LDFLAGS="$TEMP_LDFLAGS -lssl -lcrypto" |
260 TEMP_LDFLAGS="$TEMP_LDFLAGS -lssl -lcrypto" |
259 echo yes |
261 echo yes |
260 return 0 |
262 return 1 |
261 done |
263 done |
262 |
264 |
263 echo no |
265 echo no |
264 return 1 |
266 return 0 |
265 } |
267 } |
266 dependency_libxml2() |
268 dependency_error_libxml2() |
267 { |
269 { |
268 printf "checking for libxml2... " |
270 printf "checking for libxml2... " |
269 # dependency libxml2 platform="macos" |
271 # dependency libxml2 platform="macos" |
270 while true |
272 while true |
271 do |
273 do |
272 if failed isplatform "macos"; then |
274 if notisplatform "macos"; then |
273 break |
275 break |
274 fi |
276 fi |
275 if tmp_flags=`xml2-config --cflags` ; then |
277 if tmp_flags=`xml2-config --cflags` ; then |
276 TEMP_CFLAGS="$TEMP_CFLAGS $tmp_flags" |
278 TEMP_CFLAGS="$TEMP_CFLAGS $tmp_flags" |
277 else |
279 else |
281 TEMP_LDFLAGS="$TEMP_LDFLAGS $tmp_flags" |
283 TEMP_LDFLAGS="$TEMP_LDFLAGS $tmp_flags" |
282 else |
284 else |
283 break |
285 break |
284 fi |
286 fi |
285 echo yes |
287 echo yes |
286 return 0 |
288 return 1 |
287 done |
289 done |
288 |
290 |
289 # dependency libxml2 |
291 # dependency libxml2 |
290 while true |
292 while true |
291 do |
293 do |
292 if [ -z "$PKG_CONFIG" ]; then |
294 if [ -z "$PKG_CONFIG" ]; then |
293 break |
295 break |
294 fi |
296 fi |
295 if failed $PKG_CONFIG libxml-2.0 ; then |
297 if $PKG_CONFIG libxml-2.0 ; then |
296 break |
298 TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags libxml-2.0`" |
297 fi |
299 TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs libxml-2.0`" |
298 TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags libxml-2.0`" |
300 else |
299 TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs libxml-2.0`" |
301 break |
|
302 fi |
300 echo yes |
303 echo yes |
301 return 0 |
304 return 1 |
302 done |
305 done |
303 |
306 |
304 echo no |
307 echo no |
305 return 1 |
308 return 0 |
306 } |
309 } |
307 |
310 |
308 DEPENDENCIES_FAILED= |
311 DEPENDENCIES_FAILED= |
309 ERROR=0 |
312 ERROR=0 |
310 # unnamed dependencies |
313 # unnamed dependencies |
339 |
342 |
340 # Target |
343 # Target |
341 TEMP_CFLAGS= |
344 TEMP_CFLAGS= |
342 TEMP_LDFLAGS= |
345 TEMP_LDFLAGS= |
343 |
346 |
344 if failed dependency_libxml2; then |
347 if dependency_error_libxml2; then |
345 DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED libxml2 " |
348 DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED libxml2 " |
346 ERROR=1 |
349 ERROR=1 |
347 fi |
350 fi |
348 if failed dependency_openssl; then |
351 if dependency_error_openssl; then |
349 DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED openssl " |
352 DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED openssl " |
350 ERROR=1 |
353 ERROR=1 |
351 fi |
354 fi |
352 |
355 |
353 # Features |
356 # Features |
354 if [ -n "$FEATURE_PG" ]; then |
357 if [ -n "$FEATURE_PG" ]; then |
355 # check dependency |
358 # check dependency |
356 if failed dependency_libpq ; then |
359 if dependency_error_libpq ; then |
357 # "auto" features can fail and are just disabled in this case |
360 # "auto" features can fail and are just disabled in this case |
358 if [ "$FEATURE_PG" = "auto" ]; then |
361 if [ "$FEATURE_PG" = "auto" ]; then |
359 unset FEATURE_PG |
362 unset FEATURE_PG |
360 else |
363 else |
361 DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED libpq " |
364 DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED libpq " |