|
1 #!/bin/sh |
|
2 |
|
3 PREFIX=/usr |
|
4 EPREFIX=$PREFIX |
|
5 |
|
6 BINDIR= |
|
7 SBINDIR= |
|
8 LIBDIR= |
|
9 LIBEXECDIR= |
|
10 DATADIR= |
|
11 SYSCONFDIR= |
|
12 SHAREDSTATEDIR= |
|
13 LOCALSTATEDIR= |
|
14 INCLUDEDIR= |
|
15 INFODIR= |
|
16 MANDIR= |
|
17 |
|
18 OS=`uname -s` |
|
19 OS_VERSION=`uname -r` |
|
20 |
|
21 TEMP_DIR=".tmp-`uname -n`" |
|
22 mkdir -p $TEMP_DIR |
|
23 if [ $? -ne 0 ]; then |
|
24 echo "Cannot create tmp dir" |
|
25 echo "Abort" |
|
26 fi |
|
27 touch $TEMP_DIR/options |
|
28 touch $TEMP_DIR/features |
|
29 |
|
30 # features |
|
31 FEATURE_DB=on |
|
32 |
|
33 # help text |
|
34 printhelp() |
|
35 { |
|
36 echo "Usage: $0 [OPTIONS]..." |
|
37 cat << __EOF__ |
|
38 Installation directories: |
|
39 --prefix=PREFIX path prefix for architecture-independent files |
|
40 [/usr] |
|
41 --exec-prefix=EPREFIX path prefix for architecture-dependent files |
|
42 [PREFIX] |
|
43 |
|
44 --bindir=DIR user executables [EPREFIX/bin] |
|
45 --sbindir=DIR system admin executables [EPREFIX/sbin] |
|
46 --libexecdir=DIR program executables [EPREFIX/libexec] |
|
47 --sysconfdir=DIR system configuration files [PREFIX/etc] |
|
48 --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] |
|
49 --localstatedir=DIR modifiable single-machine data [PREFIX/var] |
|
50 --libdir=DIR object code libraries [EPREFIX/lib] |
|
51 --includedir=DIR C header files [PREFIX/include] |
|
52 --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] |
|
53 --datadir=DIR read-only architecture-independent data [DATAROOTDIR] |
|
54 --infodir=DIR info documentation [DATAROOTDIR/info] |
|
55 --mandir=DIR man documentation [DATAROOTDIR/man] |
|
56 |
|
57 Options: |
|
58 --toolkit=(gtk3|cli|gtk2|wpf) |
|
59 |
|
60 Optional Features: |
|
61 --disable-db |
|
62 --enable-gui |
|
63 |
|
64 __EOF__ |
|
65 } |
|
66 |
|
67 # |
|
68 # parse arguments |
|
69 # |
|
70 for ARG in $@ |
|
71 do |
|
72 if [[ $ARG == --prefix=* ]]; then |
|
73 PREFIX=${ARG:9} |
|
74 elif [[ $ARG = --exec-prefix=* ]]; then |
|
75 EPREFIX=${ARG:14} |
|
76 elif [[ $ARG = --bindir=* ]]; then |
|
77 BINDIR=${ARG:9} |
|
78 elif [[ $ARG = --sbindir=* ]]; then |
|
79 SBINDIR=${ARG:10} |
|
80 elif [[ $ARG = --libdir=* ]]; then |
|
81 LIBDIR=${ARG:9} |
|
82 elif [[ $ARG = --libexecdir=* ]]; then |
|
83 LIBEXECDIR=${ARG:13} |
|
84 elif [[ $ARG = --datadir=* ]]; then |
|
85 DATADIR=${ARG:10} |
|
86 elif [[ $ARG = --sysconfdir=* ]]; then |
|
87 SYSCONFDIR=${ARG:13} |
|
88 elif [[ $ARG = --sharedstatedir=* ]]; then |
|
89 SHAREDSTATEDIR=${ARG:17} |
|
90 elif [[ $ARG = --localstatedir=* ]]; then |
|
91 LOCALSTATEDIR=${ARG:16} |
|
92 elif [[ $ARG = --includedir=* ]]; then |
|
93 INCLUDEDIR=${ARG:12} |
|
94 elif [[ $ARG = --infodir=* ]]; then |
|
95 INFODIR=${ARG:10} |
|
96 elif [[ $ARG = --mandir=* ]]; then |
|
97 MANDIR=${ARG:9} |
|
98 elif [ $ARG = "--help" ]; then |
|
99 printhelp |
|
100 exit 0 |
|
101 elif [[ $ARG == --toolkit=* ]]; then |
|
102 OPT_TOOLKIT=${ARG:10} |
|
103 elif [[ $ARG == --enable-db ]]; then |
|
104 FEATURE_DB=on |
|
105 elif [[ $ARG == --disable-db ]]; then |
|
106 unset FEATURE_DB |
|
107 elif [[ $ARG == --enable-gui ]]; then |
|
108 FEATURE_GUI=on |
|
109 elif [[ $ARG == --disable-gui ]]; then |
|
110 unset FEATURE_GUI |
|
111 fi |
|
112 done |
|
113 |
|
114 # set dir variables |
|
115 if [ -z $BINDIR ]; then |
|
116 BINDIR=$EPREFIX/bin |
|
117 fi |
|
118 if [ -z $SBINDIR ]; then |
|
119 SBINDIR=$EPREFIX/sbin |
|
120 fi |
|
121 if [ -z $LIBDIR ]; then |
|
122 LIBDIRDIR=$EPREFIX/lib |
|
123 fi |
|
124 if [ -z $LIBEXEC ]; then |
|
125 LIBExECDIR=$EPREFIX/libexec |
|
126 fi |
|
127 if [ -z $DATADIR ]; then |
|
128 DATADIR=$PREFIX/share |
|
129 fi |
|
130 if [ -z $SYSCONFDIR]; then |
|
131 SYSCONFDIR=$PREFIX/etc |
|
132 fi |
|
133 if [ -z $SHAREDSTATEDIR ]; then |
|
134 SHAREDSTATEDIR=$PREFIX/com |
|
135 fi |
|
136 if [ -z $LOCALSTATEDIR ]; then |
|
137 LOCALSTATEDIR=$PREFIX/var |
|
138 fi |
|
139 if [ -z $INCLUDEDIR ]; then |
|
140 INCLUDEDIR=$PREFIX/include |
|
141 fi |
|
142 if [ -z $INFODIR ]; then |
|
143 INFODIR=$PREFIX/info |
|
144 fi |
|
145 if [ -z $MANDIR ]; then |
|
146 MANDIR=$PREFIX/man |
|
147 fi |
|
148 |
|
149 which pkg-config > /dev/null |
|
150 if [ $? -ne 0 ]; then |
|
151 PKG_CONFIG=pkg-config |
|
152 else |
|
153 PKG_CONFIG=false |
|
154 fi |
|
155 |
|
156 # Simple uname based platform detection |
|
157 # $PLATFORM is used for platform dependent dependency selection |
|
158 printf "detect platform... " |
|
159 if [ $OS = SunOS ]; then |
|
160 PLATFORM="solaris sunos unix svr4" |
|
161 fi |
|
162 if [ $OS = Linux ]; then |
|
163 PLATFORM="linux unix" |
|
164 fi |
|
165 if [ $OS = FreeBSD ]; then |
|
166 PLATFORM="freebsd bsd unix" |
|
167 fi |
|
168 if [ $OS = Darwin ]; then |
|
169 PLATFORM="macos osx bsd unix" |
|
170 fi |
|
171 echo $OS | grep "MINGW" > /dev/null |
|
172 if [ $? -eq 0 ]; then |
|
173 PLATFORM="windows mingw" |
|
174 fi |
|
175 |
|
176 if [ -z "$PLATFORM" ]; then |
|
177 PLATFORM="unix" |
|
178 fi |
|
179 |
|
180 for p in $PLATFORM |
|
181 do |
|
182 PLATFORM_NAME=$p |
|
183 break |
|
184 done |
|
185 echo $PLATFORM_NAME |
|
186 |
|
187 isplatform() |
|
188 { |
|
189 for p in $PLATFORM |
|
190 do |
|
191 if [ $p = $1 ]; then |
|
192 return 0 |
|
193 fi |
|
194 done |
|
195 return 1 |
|
196 } |
|
197 |
|
198 # generate config.mk and config.h |
|
199 cat > $TEMP_DIR/config.mk << __EOF__ |
|
200 # |
|
201 # config.mk generated by configure |
|
202 # |
|
203 __EOF__ |
|
204 |
|
205 echo > $TEMP_DIR/make.mk |
|
206 |
|
207 ENV_CFLAGS=$CFLAGS |
|
208 ENV_LDFLAGS=$LDFLAGS |
|
209 ENV_CXXFLAGS=$CXXFLAGS |
|
210 |
|
211 # Toolchain detection |
|
212 # this will insert make vars to config.mk |
|
213 source make/toolchain.sh |
|
214 |
|
215 # add user specified flags to config.mk |
|
216 echo >> $TEMP_DIR/config.mk |
|
217 if [[ ! -z ${ENV_CFLAGS} ]]; then |
|
218 echo "CFLAGS += $ENV_CFLAGS" >> $TEMP_DIR/config.mk |
|
219 fi |
|
220 if [[ ! -z ${ENV_CXXFLAGS} ]]; then |
|
221 echo "CXXFLAGS += $ENV_CXXFLAGS" >> $TEMP_DIR/config.mk |
|
222 fi |
|
223 if [[ ! -z ${ENV_LDFLAGS} ]]; then |
|
224 echo "LDFLAGS += $ENV_LDFLAGS" >> $TEMP_DIR/config.mk |
|
225 fi |
|
226 |
|
227 # |
|
228 # DEPENDENCIES |
|
229 # |
|
230 |
|
231 dependency_qt4() |
|
232 { |
|
233 printf "checking for qt4... " |
|
234 # dependency qt4 |
|
235 while true |
|
236 do |
|
237 which qmake-qt4 > /dev/null |
|
238 if [ $? -ne 0 ]; then |
|
239 break |
|
240 fi |
|
241 echo yes |
|
242 return 0 |
|
243 done |
|
244 |
|
245 echo no |
|
246 return 1 |
|
247 } |
|
248 dependency_curl() |
|
249 { |
|
250 printf "checking for curl... " |
|
251 # dependency curl platform="windows" |
|
252 while true |
|
253 do |
|
254 if ! isplatform "windows"; then |
|
255 break |
|
256 fi |
|
257 CFLAGS+="-I/mingw/include" |
|
258 LDFLAGS+="-lcurl" |
|
259 echo yes |
|
260 return 0 |
|
261 done |
|
262 |
|
263 # dependency curl platform="macos" |
|
264 while true |
|
265 do |
|
266 if ! isplatform "macos"; then |
|
267 break |
|
268 fi |
|
269 curl-config --cflags > /dev/null |
|
270 if [ $? -eq 0 ]; then |
|
271 CFLAGS+=" `curl-config --cflags`" |
|
272 else |
|
273 break |
|
274 fi |
|
275 curl-config --ldflags > /dev/null |
|
276 if [ $? -eq 0 ]; then |
|
277 LDFLAGS+=" `curl-config --ldflags`" |
|
278 else |
|
279 break |
|
280 fi |
|
281 echo yes |
|
282 return 0 |
|
283 done |
|
284 |
|
285 # dependency curl |
|
286 while true |
|
287 do |
|
288 if [ -z "PKG_CONFIG" ]; then |
|
289 break |
|
290 fi |
|
291 if ! pkg-config libcurl ; then |
|
292 break |
|
293 fi |
|
294 CFLAGS+=" `pkg-config --cflags libcurl`" |
|
295 LDFLAGS+=" `pkg-config --libs libcurl`" |
|
296 echo yes |
|
297 return 0 |
|
298 done |
|
299 |
|
300 echo no |
|
301 return 1 |
|
302 } |
|
303 dependency_sqlite() |
|
304 { |
|
305 printf "checking for sqlite... " |
|
306 # dependency sqlite |
|
307 while true |
|
308 do |
|
309 if [ -z "PKG_CONFIG" ]; then |
|
310 break |
|
311 fi |
|
312 if ! pkg-config sqlite3 ; then |
|
313 break |
|
314 fi |
|
315 CFLAGS+=" `pkg-config --cflags sqlite3`" |
|
316 LDFLAGS+=" `pkg-config --libs sqlite3`" |
|
317 echo yes |
|
318 return 0 |
|
319 done |
|
320 |
|
321 echo no |
|
322 return 1 |
|
323 } |
|
324 dependency_test() |
|
325 { |
|
326 printf "checking for test... " |
|
327 # dependency test |
|
328 while true |
|
329 do |
|
330 CFLAGS+="-DTEST" |
|
331 echo yes |
|
332 return 0 |
|
333 done |
|
334 |
|
335 echo no |
|
336 return 1 |
|
337 } |
|
338 dependency_gtk2() |
|
339 { |
|
340 printf "checking for gtk2... " |
|
341 # dependency gtk2 |
|
342 while true |
|
343 do |
|
344 if [ -z "PKG_CONFIG" ]; then |
|
345 break |
|
346 fi |
|
347 if ! pkg-config gtk+-2.0 ; then |
|
348 break |
|
349 fi |
|
350 CFLAGS+=" `pkg-config --cflags gtk+-2.0`" |
|
351 LDFLAGS+=" `pkg-config --libs gtk+-2.0`" |
|
352 echo yes |
|
353 return 0 |
|
354 done |
|
355 |
|
356 echo no |
|
357 return 1 |
|
358 } |
|
359 dependency_gtk3() |
|
360 { |
|
361 printf "checking for gtk3... " |
|
362 # dependency gtk3 |
|
363 while true |
|
364 do |
|
365 if [ -z "PKG_CONFIG" ]; then |
|
366 break |
|
367 fi |
|
368 if ! pkg-config gtk+-5.0 ; then |
|
369 break |
|
370 fi |
|
371 CFLAGS+=" `pkg-config --cflags gtk+-5.0`" |
|
372 LDFLAGS+=" `pkg-config --libs gtk+-5.0`" |
|
373 echo yes |
|
374 return 0 |
|
375 done |
|
376 |
|
377 echo no |
|
378 return 1 |
|
379 } |
|
380 dependency_libxml2() |
|
381 { |
|
382 printf "checking for libxml2... " |
|
383 # dependency libxml2 |
|
384 while true |
|
385 do |
|
386 if [ -z "PKG_CONFIG" ]; then |
|
387 break |
|
388 fi |
|
389 if ! pkg-config libxml-2.0 ; then |
|
390 break |
|
391 fi |
|
392 CFLAGS+=" `pkg-config --cflags libxml-2.0`" |
|
393 LDFLAGS+=" `pkg-config --libs libxml-2.0`" |
|
394 echo yes |
|
395 return 0 |
|
396 done |
|
397 |
|
398 echo no |
|
399 return 1 |
|
400 } |
|
401 |
|
402 DEPENDENCIES_FAILED= |
|
403 ERROR=0 |
|
404 |
|
405 # |
|
406 # OPTION VALUES |
|
407 # |
|
408 checkopt_toolkit_gtk3() |
|
409 { |
|
410 VERR=0 |
|
411 dependency_gtk3 |
|
412 if [ $? -ne 0 ]; then |
|
413 VERR=1 |
|
414 fi |
|
415 if [ $VERR -ne 0 ]; then |
|
416 return 1 |
|
417 fi |
|
418 CFLAGS+=" -Da=b" |
|
419 cat >> $TEMP_DIR/make.mk << __EOF__ |
|
420 UIOBJ += graphics_cairo.o |
|
421 |
|
422 __EOF__ |
|
423 return 0 |
|
424 } |
|
425 checkopt_toolkit_cli() |
|
426 { |
|
427 VERR=0 |
|
428 dependency_curl |
|
429 if [ $? -ne 0 ]; then |
|
430 VERR=1 |
|
431 fi |
|
432 dependency_test |
|
433 if [ $? -ne 0 ]; then |
|
434 VERR=1 |
|
435 fi |
|
436 if [ $VERR -ne 0 ]; then |
|
437 return 1 |
|
438 fi |
|
439 return 0 |
|
440 } |
|
441 checkopt_toolkit_gtk2() |
|
442 { |
|
443 VERR=0 |
|
444 dependency_gtk2 |
|
445 if [ $? -ne 0 ]; then |
|
446 VERR=1 |
|
447 fi |
|
448 if [ $VERR -ne 0 ]; then |
|
449 return 1 |
|
450 fi |
|
451 return 0 |
|
452 } |
|
453 checkopt_toolkit_wpf() |
|
454 { |
|
455 VERR=0 |
|
456 dependency_test |
|
457 if [ $? -ne 0 ]; then |
|
458 VERR=1 |
|
459 fi |
|
460 if [ $VERR -ne 0 ]; then |
|
461 return 1 |
|
462 fi |
|
463 return 0 |
|
464 } |
|
465 |
|
466 # |
|
467 # TARGETS |
|
468 # |
|
469 CFLAGS= |
|
470 CXXFLAGS= |
|
471 LDFLAGS= |
|
472 |
|
473 # Target: dav |
|
474 CFLAGS= |
|
475 LDFLAGS= |
|
476 CXXFLAGS= |
|
477 |
|
478 dependency_curl |
|
479 if [ $? -ne 0 ]; then |
|
480 DEPENDENCIES_FAILED+="curl " |
|
481 ERROR=1 |
|
482 fi |
|
483 dependency_libxml2 |
|
484 if [ $? -ne 0 ]; then |
|
485 DEPENDENCIES_FAILED+="libxml2 " |
|
486 ERROR=1 |
|
487 fi |
|
488 dependency_test |
|
489 if [ $? -ne 0 ]; then |
|
490 DEPENDENCIES_FAILED+="test " |
|
491 ERROR=1 |
|
492 fi |
|
493 |
|
494 # Option: --toolkit |
|
495 if [ -z $OPT_TOOLKIT ]; then |
|
496 SAVED_ERROR=$ERROR |
|
497 SAVED_DEPENDENCIES_FAILED=$DEPENDENCIES_FAILED |
|
498 ERROR=0 |
|
499 while true |
|
500 do |
|
501 if isplatform "windows"; then |
|
502 checkopt_toolkit_wpf |
|
503 if [ $? -eq 0 ]; then |
|
504 echo " toolkit: wpf" >> $TEMP_DIR/options |
|
505 ERROR=0 |
|
506 break |
|
507 fi |
|
508 fi |
|
509 checkopt_toolkit_gtk3 |
|
510 if [ $? -eq 0 ]; then |
|
511 echo " toolkit: gtk3" >> $TEMP_DIR/options |
|
512 ERROR=0 |
|
513 break |
|
514 fi |
|
515 checkopt_toolkit_gtk2 |
|
516 if [ $? -eq 0 ]; then |
|
517 echo " toolkit: gtk2" >> $TEMP_DIR/options |
|
518 ERROR=0 |
|
519 break |
|
520 fi |
|
521 break |
|
522 done |
|
523 if [ $ERROR -ne 0 ]; then |
|
524 SAVED_ERROR=1 |
|
525 fi |
|
526 ERROR=$SAVED_ERROR |
|
527 DEPENDENCIES_FAILED=$SAVED_DEPENDENCIES_FAILED= |
|
528 else |
|
529 if false; then |
|
530 false |
|
531 elif [ $OPT_TOOLKIT = "gtk3" ]; then |
|
532 echo " toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options |
|
533 checkopt_toolkit_gtk3 |
|
534 if [ $? -ne 0 ]; then |
|
535 ERROR=1 |
|
536 fi |
|
537 elif [ $OPT_TOOLKIT = "cli" ]; then |
|
538 echo " toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options |
|
539 checkopt_toolkit_cli |
|
540 if [ $? -ne 0 ]; then |
|
541 ERROR=1 |
|
542 fi |
|
543 elif [ $OPT_TOOLKIT = "gtk2" ]; then |
|
544 echo " toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options |
|
545 checkopt_toolkit_gtk2 |
|
546 if [ $? -ne 0 ]; then |
|
547 ERROR=1 |
|
548 fi |
|
549 elif [ $OPT_TOOLKIT = "wpf" ]; then |
|
550 echo " toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options |
|
551 checkopt_toolkit_wpf |
|
552 if [ $? -ne 0 ]; then |
|
553 ERROR=1 |
|
554 fi |
|
555 fi |
|
556 fi |
|
557 |
|
558 echo >> $TEMP_DIR/config.mk |
|
559 if [[ ! -z ${CFLAGS} ]]; then |
|
560 echo "DAV_CFLAGS += $CFLAGS" >> $TEMP_DIR/config.mk |
|
561 fi |
|
562 if [[ ! -z ${CXXFLAGS} ]]; then |
|
563 echo "DAV_CXXFLAGS += $CXXFLAGS" >> $TEMP_DIR/config.mk |
|
564 fi |
|
565 if [[ ! -z ${LDFLAGS} ]]; then |
|
566 echo "DAV_LDFLAGS += $LDFLAGS" >> $TEMP_DIR/config.mk |
|
567 fi |
|
568 |
|
569 if [ $ERROR -ne 0 ]; then |
|
570 echo |
|
571 echo "Error: Unresolved dependencies" |
|
572 echo $DEPENCIES_FAILED |
|
573 rm -Rf $TEMP_DIR |
|
574 exit 1 |
|
575 fi |
|
576 |
|
577 echo "configure finished" |
|
578 echo |
|
579 echo "Build Config:" |
|
580 echo " PREFIX: $PREFIX" |
|
581 echo " TOOLCHAIN: $TOOLCHAIN_NAME" |
|
582 echo "Options:" |
|
583 cat $TEMP_DIR/options |
|
584 echo |
|
585 cat $TEMP_DIR/config.mk $TEMP_DIR/make.mk > config.mk |
|
586 rm -Rf $TEMP_DIR |
|
587 |
|
588 |