configure

changeset 158
4bde241c49b1
parent 156
62f1a55535e7
child 159
84a6e7a7b457
equal deleted inserted replaced
157:0b33b9396851 158:4bde241c49b1
1 #!/bin/sh 1 #!/bin/sh
2
2 3
3 PREFIX=/usr 4 PREFIX=/usr
4 EPREFIX=$PREFIX 5 EPREFIX=$PREFIX
5 6
6 BINDIR= 7 BINDIR=
62 # 63 #
63 # parse arguments 64 # parse arguments
64 # 65 #
65 for ARG in $@ 66 for ARG in $@
66 do 67 do
67 if [[ $ARG == --prefix=* ]]; then 68 case "$ARG" in
68 PREFIX=${ARG:9} 69 "--prefix="*) PREFIX=${ARG#--prefix=} ;;
69 elif [[ $ARG = --exec-prefix=* ]]; then 70 "--exec-prefix="*) EPREFIX=${ARG#--exec-prefix=} ;;
70 EPREFIX=${ARG:14} 71 "--bindir="*) BINDIR=${ARG#----bindir=} ;;
71 elif [[ $ARG = --bindir=* ]]; then 72 "--sbindir="*) SBINDIR=${ARG#--sbindir=} ;;
72 BINDIR=${ARG:9} 73 "--libdir="*) LIBDIR=${ARG#--libdir=} ;;
73 elif [[ $ARG = --sbindir=* ]]; then 74 "--libexecdir="*) LIBEXECDIR=${ARG#--libexecdir=} ;;
74 SBINDIR=${ARG:10} 75 "--datadir="*) DATADIR=${ARG#--datadir=} ;;
75 elif [[ $ARG = --libdir=* ]]; then 76 "--sysconfdir="*) SYSCONFDIR=${ARG#--sysconfdir=} ;;
76 LIBDIR=${ARG:9} 77 "--sharedstatedir="*) SHAREDSTATEDIR=${ARG#--sharedstatedir=} ;;
77 elif [[ $ARG = --libexecdir=* ]]; then 78 "--localstatedir="*) LOCALSTATEDIR=${ARG#--localstatedir=} ;;
78 LIBEXECDIR=${ARG:13} 79 "--includedir="*) INCLUDEDIR=${ARG#--includedir=} ;;
79 elif [[ $ARG = --datadir=* ]]; then 80 "--infodir="*) INFODIR=${ARG#--infodir=} ;;
80 DATADIR=${ARG:10} 81 "--mandir"*) MANDIR=${ARG#--mandir} ;;
81 elif [[ $ARG = --sysconfdir=* ]]; then 82 "--help"*) printhelp; exit 1 ;;
82 SYSCONFDIR=${ARG:13} 83 "--toolkit="*) OPT_TOOLKIT={ARG#toolkit=} ;;
83 elif [[ $ARG = --sharedstatedir=* ]]; then 84 "-"*) echo "unknown option: $ARG"; exit 1 ;;
84 SHAREDSTATEDIR=${ARG:17} 85 esac
85 elif [[ $ARG = --localstatedir=* ]]; then
86 LOCALSTATEDIR=${ARG:16}
87 elif [[ $ARG = --includedir=* ]]; then
88 INCLUDEDIR=${ARG:12}
89 elif [[ $ARG = --infodir=* ]]; then
90 INFODIR=${ARG:10}
91 elif [[ $ARG = --mandir=* ]]; then
92 MANDIR=${ARG:9}
93 elif [ $ARG = "--help" ]; then
94 printhelp
95 exit 0
96 elif [[ $ARG == --toolkit=* ]]; then
97 OPT_TOOLKIT=${ARG:10}
98 fi
99 done 86 done
100 87
101 # set dir variables 88 # set dir variables
102 if [ -z $BINDIR ]; then 89 if [ -z "$BINDIR" ]; then
103 BINDIR=$EPREFIX/bin 90 BINDIR=$EPREFIX/bin
104 fi 91 fi
105 if [ -z $SBINDIR ]; then 92 if [ -z "$SBINDIR" ]; then
106 SBINDIR=$EPREFIX/sbin 93 SBINDIR=$EPREFIX/sbin
107 fi 94 fi
108 if [ -z $LIBDIR ]; then 95 if [ -z "$LIBDIR" ]; then
109 LIBDIRDIR=$EPREFIX/lib 96 LIBDIR=$EPREFIX/lib
110 fi 97 fi
111 if [ -z $LIBEXEC ]; then 98 if [ -z "$LIBEXEC" ]; then
112 LIBExECDIR=$EPREFIX/libexec 99 LIBEXECDIR=$EPREFIX/libexec
113 fi 100 fi
114 if [ -z $DATADIR ]; then 101 if [ -z "$DATADIR" ]; then
115 DATADIR=$PREFIX/share 102 DATADIR=$PREFIX/share
116 fi 103 fi
117 if [ -z $SYSCONFDIR]; then 104 if [ -z "$SYSCONFDIR" ]; then
118 SYSCONFDIR=$PREFIX/etc 105 SYSCONFDIR=$PREFIX/etc
119 fi 106 fi
120 if [ -z $SHAREDSTATEDIR ]; then 107 if [ -z "$SHAREDSTATEDIR" ]; then
121 SHAREDSTATEDIR=$PREFIX/com 108 SHAREDSTATEDIR=$PREFIX/com
122 fi 109 fi
123 if [ -z $LOCALSTATEDIR ]; then 110 if [ -z "$LOCALSTATEDIR" ]; then
124 LOCALSTATEDIR=$PREFIX/var 111 LOCALSTATEDIR=$PREFIX/var
125 fi 112 fi
126 if [ -z $INCLUDEDIR ]; then 113 if [ -z "$INCLUDEDIR" ]; then
127 INCLUDEDIR=$PREFIX/include 114 INCLUDEDIR=$PREFIX/include
128 fi 115 fi
129 if [ -z $INFODIR ]; then 116 if [ -z "$INFODIR" ]; then
130 INFODIR=$PREFIX/info 117 INFODIR=$PREFIX/info
131 fi 118 fi
132 if [ -z $MANDIR ]; then 119 if [ -z "$MANDIR" ]; then
133 MANDIR=$PREFIX/man 120 MANDIR=$PREFIX/man
134 fi 121 fi
135 122
136 which pkg-config > /dev/null 123 which pkg-config > /dev/null
137 if [ $? -ne 0 ]; then 124 if [ $? -eq 0 ]; then
138 PKG_CONFIG=pkg-config 125 PKG_CONFIG=pkg-config
139 else 126 else
140 PKG_CONFIG=false 127 PKG_CONFIG=false
141 fi 128 fi
142 129
179 return 0 166 return 0
180 fi 167 fi
181 done 168 done
182 return 1 169 return 1
183 } 170 }
171 isnotplatform()
172 {
173 for p in $PLATFORM
174 do
175 if [ $p = $1 ]; then
176 return 1
177 fi
178 done
179 return 0
180 }
184 181
185 # generate config.mk and config.h 182 # generate config.mk and config.h
186 cat > $TEMP_DIR/config.mk << __EOF__ 183 cat > $TEMP_DIR/config.mk << __EOF__
187 # 184 #
188 # config.mk generated by configure 185 # config.mk generated by configure
189 # 186 #
187
188 # general vars
189
190 PREFIX=$PREFIX
191 EPREFIX=$EPREFIX
192
193 BINDIR=$BINDIR
194 SBINDIR=$SBINDIR
195 LIBDIR=$LIBDIR
196 LIBEXECDIR=$LIBEXECDIR
197 DATADIR=$DATADIR
198 SYSCONFDIR=$SYSCONFDIR
199 SHAREDSTATEDIR=$SHAREDSTATEDIR
200 LOCALSTATEDIR=$LOCALSTATEDIR
201 INCLUDEDIR=$INCLUDEDIR
202 INFODIR=$INFODIR
203 MANDIR=$MANDIR
204
190 __EOF__ 205 __EOF__
191 206
192 echo > $TEMP_DIR/make.mk 207 echo > $TEMP_DIR/make.mk
193 208
194 ENV_CFLAGS=$CFLAGS 209 ENV_CFLAGS=$CFLAGS
195 ENV_LDFLAGS=$LDFLAGS 210 ENV_LDFLAGS=$LDFLAGS
196 ENV_CXXFLAGS=$CXXFLAGS 211 ENV_CXXFLAGS=$CXXFLAGS
197 212
198 # Toolchain detection 213 # Toolchain detection
199 # this will insert make vars to config.mk 214 # this will insert make vars to config.mk
200 source make/toolchain.sh 215 . make/toolchain.sh
201 216
202 # add user specified flags to config.mk 217 # add user specified flags to config.mk
203 echo >> $TEMP_DIR/config.mk 218 echo >> $TEMP_DIR/config.mk
204 if [[ ! -z ${ENV_CFLAGS} ]]; then 219 if [ ! -z "${ENV_CFLAGS}" ]; then
205 echo "CFLAGS += $ENV_CFLAGS" >> $TEMP_DIR/config.mk 220 echo "CFLAGS += $ENV_CFLAGS" >> $TEMP_DIR/config.mk
206 fi 221 fi
207 if [[ ! -z ${ENV_CXXFLAGS} ]]; then 222 if [ ! -z "${ENV_CXXFLAGS}" ]; then
208 echo "CXXFLAGS += $ENV_CXXFLAGS" >> $TEMP_DIR/config.mk 223 echo "CXXFLAGS += $ENV_CXXFLAGS" >> $TEMP_DIR/config.mk
209 fi 224 fi
210 if [[ ! -z ${ENV_LDFLAGS} ]]; then 225 if [ ! -z "${ENV_LDFLAGS}" ]; then
211 echo "LDFLAGS += $ENV_LDFLAGS" >> $TEMP_DIR/config.mk 226 echo "LDFLAGS += $ENV_LDFLAGS" >> $TEMP_DIR/config.mk
212 fi 227 fi
213 228
214 # 229 #
215 # DEPENDENCIES 230 # DEPENDENCIES
221 # dependency qt4 236 # dependency qt4
222 while true 237 while true
223 do 238 do
224 qmake-qt4 -o - /dev/null | grep DEFINES\ > /dev/null 239 qmake-qt4 -o - /dev/null | grep DEFINES\ > /dev/null
225 if [ $? -eq 0 ]; then 240 if [ $? -eq 0 ]; then
226 CFLAGS+=" `qmake-qt4 -o - /dev/null | grep DEFINES\ `" 241 CFLAGS="$CFLAGS `qmake-qt4 -o - /dev/null | grep DEFINES\ `"
227 else 242 else
228 break 243 break
229 fi 244 fi
230 qmake-qt4 -o - /dev/null | grep INCPATH\ > /dev/null 245 qmake-qt4 -o - /dev/null | grep INCPATH\ > /dev/null
231 if [ $? -eq 0 ]; then 246 if [ $? -eq 0 ]; then
232 CFLAGS+=" `qmake-qt4 -o - /dev/null | grep INCPATH\ `" 247 CFLAGS="$CFLAGS `qmake-qt4 -o - /dev/null | grep INCPATH\ `"
233 else 248 else
234 break 249 break
235 fi 250 fi
236 > /dev/null 251 > /dev/null
237 if [ $? -eq 0 ]; then 252 if [ $? -eq 0 ]; then
238 LDFLAGS+=" ``" 253 LDFLAGS="$LDFLAGS ``"
239 else 254 else
240 break 255 break
241 fi 256 fi
242 which qmake-qt4 > /dev/null 257 which qmake-qt4 > /dev/null
243 if [ $? -ne 0 ]; then 258 if [ $? -ne 0 ]; then
244 break 259 break
245 fi 260 fi
246 echo yes 261 echo yes
247 return 0 262 return 0
248 done 263 done
249 264
250 echo no 265 echo no
251 return 1 266 return 1
254 { 269 {
255 printf "checking for gtk2legacy... " 270 printf "checking for gtk2legacy... "
256 # dependency gtk2legacy 271 # dependency gtk2legacy
257 while true 272 while true
258 do 273 do
259 if [ -z "PKG_CONFIG" ]; then 274 if [ -z "$PKG_CONFIG" ]; then
260 break 275 break
261 fi 276 fi
262 if ! pkg-config gtk+-2.0 ; then 277 $PKG_CONFIG gtk+-2.0
263 break 278 if [ $? -ne 0 ] ; then
264 fi 279 break
265 CFLAGS+=" `pkg-config --cflags gtk+-2.0`" 280 fi
266 LDFLAGS+=" `pkg-config --libs gtk+-2.0`" 281 CFLAGS="$CFLAGS `$PKG_CONFIG --cflags gtk+-2.0`"
267 CFLAGS+="-DUI_GTK2 -DUI_GTK2LEGACY" 282 LDFLAGS="$LDFLAGS `$PKG_CONFIG --libs gtk+-2.0`"
268 LDFLAGS+="-lpthread" 283 CFLAGS="$CFLAGS -DUI_GTK2 -DUI_GTK2LEGACY"
269 echo yes 284 LDFLAGS="$LDFLAGS -lpthread"
285 echo yes
270 return 0 286 return 0
271 done 287 done
272 288
273 echo no 289 echo no
274 return 1 290 return 1
279 # dependency qt5 295 # dependency qt5
280 while true 296 while true
281 do 297 do
282 qmake-qt5 -o - /dev/null | grep DEFINES\ > /dev/null 298 qmake-qt5 -o - /dev/null | grep DEFINES\ > /dev/null
283 if [ $? -eq 0 ]; then 299 if [ $? -eq 0 ]; then
284 CFLAGS+=" `qmake-qt5 -o - /dev/null | grep DEFINES\ `" 300 CFLAGS="$CFLAGS `qmake-qt5 -o - /dev/null | grep DEFINES\ `"
285 else 301 else
286 break 302 break
287 fi 303 fi
288 qmake-qt5 -o - /dev/null | grep INCPATH\ > /dev/null 304 qmake-qt5 -o - /dev/null | grep INCPATH\ > /dev/null
289 if [ $? -eq 0 ]; then 305 if [ $? -eq 0 ]; then
290 CFLAGS+=" `qmake-qt5 -o - /dev/null | grep INCPATH\ `" 306 CFLAGS="$CFLAGS `qmake-qt5 -o - /dev/null | grep INCPATH\ `"
291 else 307 else
292 break 308 break
293 fi 309 fi
294 > /dev/null 310 > /dev/null
295 if [ $? -eq 0 ]; then 311 if [ $? -eq 0 ]; then
296 LDFLAGS+=" ``" 312 LDFLAGS="$LDFLAGS ``"
297 else 313 else
298 break 314 break
299 fi 315 fi
300 which qmake-qt5 > /dev/null 316 which qmake-qt5 > /dev/null
301 if [ $? -ne 0 ]; then 317 if [ $? -ne 0 ]; then
302 break 318 break
303 fi 319 fi
304 echo yes 320 echo yes
305 return 0 321 return 0
306 done 322 done
307 323
308 echo no 324 echo no
309 return 1 325 return 1
312 { 328 {
313 printf "checking for gtk2... " 329 printf "checking for gtk2... "
314 # dependency gtk2 330 # dependency gtk2
315 while true 331 while true
316 do 332 do
317 if [ -z "PKG_CONFIG" ]; then 333 if [ -z "$PKG_CONFIG" ]; then
318 break 334 break
319 fi 335 fi
320 if ! pkg-config gtk+-2.0 ; then 336 $PKG_CONFIG gtk+-2.0
321 break 337 if [ $? -ne 0 ] ; then
322 fi 338 break
323 CFLAGS+=" `pkg-config --cflags gtk+-2.0`" 339 fi
324 LDFLAGS+=" `pkg-config --libs gtk+-2.0`" 340 CFLAGS="$CFLAGS `$PKG_CONFIG --cflags gtk+-2.0`"
325 CFLAGS+="-DUI_GTK2" 341 LDFLAGS="$LDFLAGS `$PKG_CONFIG --libs gtk+-2.0`"
326 LDFLAGS+="-lpthread" 342 CFLAGS="$CFLAGS -DUI_GTK2"
343 LDFLAGS="$LDFLAGS -lpthread"
327 pkg-config --atleast-version=2.20 gtk+-2.0 > /dev/null 344 pkg-config --atleast-version=2.20 gtk+-2.0 > /dev/null
328 if [ $? -ne 0 ]; then 345 if [ $? -ne 0 ]; then
329 break 346 break
330 fi 347 fi
331 echo yes 348 echo yes
332 return 0 349 return 0
333 done 350 done
334 351
335 echo no 352 echo no
336 return 1 353 return 1
339 { 356 {
340 printf "checking for gtk3... " 357 printf "checking for gtk3... "
341 # dependency gtk3 358 # dependency gtk3
342 while true 359 while true
343 do 360 do
344 if [ -z "PKG_CONFIG" ]; then 361 if [ -z "$PKG_CONFIG" ]; then
345 break 362 break
346 fi 363 fi
347 if ! pkg-config gtk+-3.0 ; then 364 $PKG_CONFIG gtk+-3.0
348 break 365 if [ $? -ne 0 ] ; then
349 fi 366 break
350 CFLAGS+=" `pkg-config --cflags gtk+-3.0`" 367 fi
351 LDFLAGS+=" `pkg-config --libs gtk+-3.0`" 368 CFLAGS="$CFLAGS `$PKG_CONFIG --cflags gtk+-3.0`"
352 CFLAGS+="-DUI_GTK3" 369 LDFLAGS="$LDFLAGS `$PKG_CONFIG --libs gtk+-3.0`"
353 LDFLAGS+="-lpthread" 370 CFLAGS="$CFLAGS -DUI_GTK3"
354 echo yes 371 LDFLAGS="$LDFLAGS -lpthread"
372 echo yes
355 return 0 373 return 0
356 done 374 done
357 375
358 echo no 376 echo no
359 return 1 377 return 1
362 { 380 {
363 printf "checking for motif... " 381 printf "checking for motif... "
364 # dependency motif 382 # dependency motif
365 while true 383 while true
366 do 384 do
367 CFLAGS+="-DUI_MOTIF" 385 CFLAGS="$CFLAGS -DUI_MOTIF"
368 LDFLAGS+="-lXm -lXt -lX11 -lpthread" 386 LDFLAGS="$LDFLAGS -lXm -lXt -lX11 -lpthread"
369 echo yes 387 echo yes
370 return 0 388 return 0
371 done 389 done
372 390
373 echo no 391 echo no
374 return 1 392 return 1
377 { 395 {
378 printf "checking for wpf... " 396 printf "checking for wpf... "
379 # dependency wpf platform="windows" 397 # dependency wpf platform="windows"
380 while true 398 while true
381 do 399 do
382 if ! isplatform "windows"; then 400 if isnotplatform "windows"; then
383 break 401 break
384 fi 402 fi
385 CFLAGS+="-DUI_WPF" 403 CFLAGS="$CFLAGS -DUI_WPF"
386 echo yes 404 echo yes
387 return 0 405 return 0
388 done 406 done
389 407
390 echo no 408 echo no
391 return 1 409 return 1
394 { 412 {
395 printf "checking for cocoa... " 413 printf "checking for cocoa... "
396 # dependency cocoa platform="macos" 414 # dependency cocoa platform="macos"
397 while true 415 while true
398 do 416 do
399 if ! isplatform "macos"; then 417 if isnotplatform "macos"; then
400 break 418 break
401 fi 419 fi
402 CFLAGS+="-DUI_COCOA" 420 CFLAGS="$CFLAGS -DUI_COCOA"
403 LDFLAGS+="-lobjc -framework Cocoa" 421 LDFLAGS="$LDFLAGS -lobjc -framework Cocoa"
404 echo yes 422 echo yes
405 return 0 423 return 0
406 done 424 done
407 425
408 echo no 426 echo no
409 return 1 427 return 1
410 } 428 }
411 429
412 DEPENDENCIES_FAILED= 430 DEPENDENCIES_FAILED=
413 ERROR=0 431 ERROR=0
432 # general dependencies
433 CFLAGS=
434 LDFLAGS=
435 while true
436 do
437 if isnotplatform "macos"; then
438 break
439 fi
440 while true
441 do
442
443 cat >> $TEMP_DIR/make.mk << __EOF__
444 OBJ_EXT = o
445 LIB_EXT = a
446 PACKAGE_SCRIPT = package_osx.sh
447
448 __EOF__
449
450 break
451 done
452
453 break
454 done
455 while true
456 do
457 if isnotplatform "unix"; then
458 break
459 fi
460 if isplatform "macos"; then
461 break
462 fi
463 while true
464 do
465
466 cat >> $TEMP_DIR/make.mk << __EOF__
467 OBJ_EXT = o
468 LIB_EXT = a
469 PACKAGE_SCRIPT = package_unix.sh
470
471 __EOF__
472
473 break
474 done
475
476 break
477 done
478
479 # add general dependency flags to config.mk
480 echo >> $TEMP_DIR/config.mk
481 if [ ! -z "${CFLAGS}" ]; then
482 echo "CFLAGS += $CFLAGS" >> $TEMP_DIR/config.mk
483 fi
484 if [ ! -z "${CXXFLAGS}" ]; then
485 echo "CXXFLAGS += $CXXFLAGS" >> $TEMP_DIR/config.mk
486 fi
487 if [ ! -z "${LDFLAGS}" ]; then
488 echo "LDFLAGS += $LDFLAGS" >> $TEMP_DIR/config.mk
489 fi
414 490
415 # 491 #
416 # OPTION VALUES 492 # OPTION VALUES
417 # 493 #
418 checkopt_toolkit_gtk3() 494 checkopt_toolkit_gtk3()
527 # Target: tk 603 # Target: tk
528 CFLAGS= 604 CFLAGS=
529 LDFLAGS= 605 LDFLAGS=
530 CXXFLAGS= 606 CXXFLAGS=
531 607
608
609 # Features
532 610
533 # Option: --toolkit 611 # Option: --toolkit
534 if [ -z $OPT_TOOLKIT ]; then 612 if [ -z $OPT_TOOLKIT ]; then
535 SAVED_ERROR=$ERROR 613 SAVED_ERROR=$ERROR
536 SAVED_DEPENDENCIES_FAILED=$DEPENDENCIES_FAILED 614 SAVED_DEPENDENCIES_FAILED=$DEPENDENCIES_FAILED
631 fi 709 fi
632 fi 710 fi
633 fi 711 fi
634 712
635 echo >> $TEMP_DIR/config.mk 713 echo >> $TEMP_DIR/config.mk
636 if [[ ! -z ${CFLAGS} ]]; then 714 if [ ! -z "${CFLAGS}" ]; then
637 echo "TK_CFLAGS += $CFLAGS" >> $TEMP_DIR/config.mk 715 echo "TK_CFLAGS += $CFLAGS" >> $TEMP_DIR/config.mk
638 fi 716 fi
639 if [[ ! -z ${CXXFLAGS} ]]; then 717 if [ ! -z "${CXXFLAGS}" ]; then
640 echo "TK_CXXFLAGS += $CXXFLAGS" >> $TEMP_DIR/config.mk 718 echo "TK_CXXFLAGS += $CXXFLAGS" >> $TEMP_DIR/config.mk
641 fi 719 fi
642 if [[ ! -z ${LDFLAGS} ]]; then 720 if [ ! -z "${LDFLAGS}" ]; then
643 echo "TK_LDFLAGS += $LDFLAGS" >> $TEMP_DIR/config.mk 721 echo "TK_LDFLAGS += $LDFLAGS" >> $TEMP_DIR/config.mk
644 fi 722 fi
645 723
646 if [ $ERROR -ne 0 ]; then 724 if [ $ERROR -ne 0 ]; then
647 echo 725 echo
648 echo "Error: Unresolved dependencies" 726 echo "Error: Unresolved dependencies"
649 echo $DEPENCIES_FAILED 727 echo $DEPENDENCIES_FAILED
650 rm -Rf $TEMP_DIR 728 rm -Rf $TEMP_DIR
651 exit 1 729 exit 1
652 fi 730 fi
653 731
654 echo "configure finished" 732 echo "configure finished"

mercurial