| 1 #!/bin/sh |
1 #!/bin/sh |
| |
2 |
| |
3 |
| |
4 # some utility functions |
| |
5 isplatform() |
| |
6 { |
| |
7 for p in $PLATFORM |
| |
8 do |
| |
9 if [ "$p" = "$1" ]; then |
| |
10 return 0 |
| |
11 fi |
| |
12 done |
| |
13 return 1 |
| |
14 } |
| |
15 notisplatform() |
| |
16 { |
| |
17 for p in $PLATFORM |
| |
18 do |
| |
19 if [ "$p" = "$1" ]; then |
| |
20 return 1 |
| |
21 fi |
| |
22 done |
| |
23 return 0 |
| |
24 } |
| |
25 istoolchain() |
| |
26 { |
| |
27 for t in $TOOLCHAIN |
| |
28 do |
| |
29 if [ "$t" = "$1" ]; then |
| |
30 return 0 |
| |
31 fi |
| |
32 done |
| |
33 return 1 |
| |
34 } |
| |
35 notistoolchain() |
| |
36 { |
| |
37 for t in $TOOLCHAIN |
| |
38 do |
| |
39 if [ "$t" = "$1" ]; then |
| |
40 return 1 |
| |
41 fi |
| |
42 done |
| |
43 return 0 |
| |
44 } |
| |
45 |
| |
46 # clean abort |
| |
47 abort_configure() |
| |
48 { |
| |
49 rm -Rf "$TEMP_DIR" |
| |
50 exit 1 |
| |
51 } |
| |
52 |
| |
53 # Test for availability of pkg-config |
| |
54 PKG_CONFIG=`command -v pkg-config` |
| |
55 : ${PKG_CONFIG:="false"} |
| |
56 |
| |
57 # Simple uname based platform detection |
| |
58 # $PLATFORM is used for platform dependent dependency selection |
| |
59 OS=`uname -s` |
| |
60 OS_VERSION=`uname -r` |
| |
61 printf "detect platform... " |
| |
62 if [ "$OS" = "SunOS" ]; then |
| |
63 PLATFORM="solaris sunos unix svr4" |
| |
64 elif [ "$OS" = "Linux" ]; then |
| |
65 PLATFORM="linux unix" |
| |
66 elif [ "$OS" = "FreeBSD" ]; then |
| |
67 PLATFORM="freebsd bsd unix" |
| |
68 elif [ "$OS" = "OpenBSD" ]; then |
| |
69 PLATFORM="openbsd bsd unix" |
| |
70 elif [ "$OS" = "NetBSD" ]; then |
| |
71 PLATFORM="netbsd bsd unix" |
| |
72 elif [ "$OS" = "Darwin" ]; then |
| |
73 PLATFORM="macos osx bsd unix" |
| |
74 elif echo "$OS" | grep -i "MINGW" > /dev/null; then |
| |
75 PLATFORM="windows mingw" |
| |
76 fi |
| |
77 : ${PLATFORM:="unix"} |
| |
78 |
| |
79 PLATFORM_NAME=`echo "$PLATFORM" | cut -f1 -d' ' -` |
| |
80 echo "$PLATFORM_NAME" |
| |
81 |
| |
82 |
| |
83 # help text |
| |
84 printhelp() |
| |
85 { |
| |
86 echo "Usage: $0 [OPTIONS]..." |
| |
87 cat << __EOF__ |
| |
88 Installation directories: |
| |
89 --prefix=PREFIX path prefix for architecture-independent files |
| |
90 [$prefix] |
| |
91 --exec-prefix=EPREFIX path prefix for architecture-dependent files |
| |
92 [PREFIX] |
| |
93 |
| |
94 --bindir=DIR user executables [EPREFIX/bin] |
| |
95 --sbindir=DIR system admin executables [EPREFIX/sbin] |
| |
96 --libexecdir=DIR program executables [EPREFIX/libexec] |
| |
97 --sysconfdir=DIR system configuration files [PREFIX/etc] |
| |
98 --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] |
| |
99 --localstatedir=DIR modifiable single-machine data [PREFIX/var] |
| |
100 --runstatedir=DIR run-time variable data [LOCALSTATEDIR/run] |
| |
101 --libdir=DIR object code libraries [EPREFIX/lib] |
| |
102 --includedir=DIR C header files [PREFIX/include] |
| |
103 --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] |
| |
104 --datadir=DIR read-only architecture-independent data [DATAROOTDIR] |
| |
105 --infodir=DIR info documentation [DATAROOTDIR/info] |
| |
106 --mandir=DIR man documentation [DATAROOTDIR/man] |
| |
107 --localedir=DIR locale-dependent data [DATAROOTDIR/locale] |
| |
108 |
| |
109 Build Types: |
| |
110 --debug add extra compile flags for debug builds |
| |
111 --release add extra compile flags for release builds |
| |
112 |
| |
113 __EOF__ |
| |
114 } |
| 2 |
115 |
| 3 # create temporary directory |
116 # create temporary directory |
| 4 TEMP_DIR=".tmp-`uname -n`" |
117 TEMP_DIR=".tmp-`uname -n`" |
| 5 rm -Rf "$TEMP_DIR" |
118 rm -Rf "$TEMP_DIR" |
| 6 if mkdir -p "$TEMP_DIR"; then |
119 if mkdir -p "$TEMP_DIR"; then |
| 33 mandir= |
146 mandir= |
| 34 |
147 |
| 35 # custom variables |
148 # custom variables |
| 36 |
149 |
| 37 # features |
150 # features |
| 38 |
|
| 39 # clean abort |
|
| 40 abort_configure() |
|
| 41 { |
|
| 42 rm -Rf "$TEMP_DIR" |
|
| 43 exit 1 |
|
| 44 } |
|
| 45 |
|
| 46 # help text |
|
| 47 printhelp() |
|
| 48 { |
|
| 49 echo "Usage: $0 [OPTIONS]..." |
|
| 50 cat << __EOF__ |
|
| 51 Installation directories: |
|
| 52 --prefix=PREFIX path prefix for architecture-independent files |
|
| 53 [/usr] |
|
| 54 --exec-prefix=EPREFIX path prefix for architecture-dependent files |
|
| 55 [PREFIX] |
|
| 56 |
|
| 57 --bindir=DIR user executables [EPREFIX/bin] |
|
| 58 --sbindir=DIR system admin executables [EPREFIX/sbin] |
|
| 59 --libexecdir=DIR program executables [EPREFIX/libexec] |
|
| 60 --sysconfdir=DIR system configuration files [PREFIX/etc] |
|
| 61 --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] |
|
| 62 --localstatedir=DIR modifiable single-machine data [PREFIX/var] |
|
| 63 --runstatedir=DIR run-time variable data [LOCALSTATEDIR/run] |
|
| 64 --libdir=DIR object code libraries [EPREFIX/lib] |
|
| 65 --includedir=DIR C header files [PREFIX/include] |
|
| 66 --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] |
|
| 67 --datadir=DIR read-only architecture-independent data [DATAROOTDIR] |
|
| 68 --infodir=DIR info documentation [DATAROOTDIR/info] |
|
| 69 --mandir=DIR man documentation [DATAROOTDIR/man] |
|
| 70 --localedir=DIR locale-dependent data [DATAROOTDIR/locale] |
|
| 71 |
|
| 72 __EOF__ |
|
| 73 } |
|
| 74 |
151 |
| 75 # |
152 # |
| 76 # parse arguments |
153 # parse arguments |
| 77 # |
154 # |
| 78 BUILD_TYPE="default" |
155 BUILD_TYPE="default" |
| 92 "--localstatedir="*) localstatedir=${ARG#--localstatedir=} ;; |
169 "--localstatedir="*) localstatedir=${ARG#--localstatedir=} ;; |
| 93 "--includedir="*) includedir=${ARG#--includedir=} ;; |
170 "--includedir="*) includedir=${ARG#--includedir=} ;; |
| 94 "--infodir="*) infodir=${ARG#--infodir=} ;; |
171 "--infodir="*) infodir=${ARG#--infodir=} ;; |
| 95 "--mandir"*) mandir=${ARG#--mandir} ;; |
172 "--mandir"*) mandir=${ARG#--mandir} ;; |
| 96 "--localedir"*) localedir=${ARG#--localedir} ;; |
173 "--localedir"*) localedir=${ARG#--localedir} ;; |
| 97 "--help"*) printhelp; abort_configure ;; |
174 "--help"*) printhelp; abort_configure ;; |
| 98 "--debug") BUILD_TYPE="debug" ;; |
175 "--debug") BUILD_TYPE="debug" ;; |
| 99 "--release") BUILD_TYPE="release" ;; |
176 "--release") BUILD_TYPE="release" ;; |
| 100 "-"*) echo "unknown option: $ARG"; abort_configure ;; |
177 "-"*) echo "unknown option: $ARG"; abort_configure ;; |
| 101 esac |
178 esac |
| 102 done |
179 done |
| 103 |
180 |
| 104 |
181 |
| 118 : ${includedir:='${prefix}/include'} |
195 : ${includedir:='${prefix}/include'} |
| 119 : ${infodir:='${datarootdir}/info'} |
196 : ${infodir:='${datarootdir}/info'} |
| 120 : ${mandir:='${datarootdir}/man'} |
197 : ${mandir:='${datarootdir}/man'} |
| 121 : ${localedir:='${datarootdir}/locale'} |
198 : ${localedir:='${datarootdir}/locale'} |
| 122 |
199 |
| |
200 # remember the above values and compare them later |
| |
201 orig_bindir="$bindir" |
| |
202 orig_sbindir="$sbindir" |
| |
203 orig_libdir="$libdir" |
| |
204 orig_libexecdir="$libexecdir" |
| |
205 orig_datarootdir="$datarootdir" |
| |
206 orig_datadir="$datadir" |
| |
207 orig_sysconfdir="$sysconfdir" |
| |
208 orig_sharedstatedir="$sharedstatedir" |
| |
209 orig_localstatedir="$localstatedir" |
| |
210 orig_runstatedir="$runstatedir" |
| |
211 orig_includedir="$includedir" |
| |
212 orig_infodir="$infodir" |
| |
213 orig_mandir="$mandir" |
| |
214 orig_localedir="$localedir" |
| |
215 |
| 123 # check if a config.site exists and load it |
216 # check if a config.site exists and load it |
| 124 if [ -n "$CONFIG_SITE" ]; then |
217 if [ -n "$CONFIG_SITE" ]; then |
| 125 # CONFIG_SITE may contain space separated file names |
218 # CONFIG_SITE may contain space separated file names |
| 126 for cs in $CONFIG_SITE; do |
219 for cs in $CONFIG_SITE; do |
| 127 printf "loading defaults from $cs... " |
220 printf "loading defaults from $cs... " |
| 135 elif [ -f "$prefix/etc/config.site" ]; then |
228 elif [ -f "$prefix/etc/config.site" ]; then |
| 136 printf "loading site defaults... " |
229 printf "loading site defaults... " |
| 137 . "$prefix/etc/config.site" |
230 . "$prefix/etc/config.site" |
| 138 echo ok |
231 echo ok |
| 139 fi |
232 fi |
| 140 |
|
| 141 # Test for availability of pkg-config |
|
| 142 PKG_CONFIG=`command -v pkg-config` |
|
| 143 : ${PKG_CONFIG:="false"} |
|
| 144 |
|
| 145 # Simple uname based platform detection |
|
| 146 # $PLATFORM is used for platform dependent dependency selection |
|
| 147 OS=`uname -s` |
|
| 148 OS_VERSION=`uname -r` |
|
| 149 printf "detect platform... " |
|
| 150 if [ "$OS" = "SunOS" ]; then |
|
| 151 PLATFORM="solaris sunos unix svr4" |
|
| 152 elif [ "$OS" = "Linux" ]; then |
|
| 153 PLATFORM="linux unix" |
|
| 154 elif [ "$OS" = "FreeBSD" ]; then |
|
| 155 PLATFORM="freebsd bsd unix" |
|
| 156 elif [ "$OS" = "OpenBSD" ]; then |
|
| 157 PLATFORM="openbsd bsd unix" |
|
| 158 elif [ "$OS" = "NetBSD" ]; then |
|
| 159 PLATFORM="netbsd bsd unix" |
|
| 160 elif [ "$OS" = "Darwin" ]; then |
|
| 161 PLATFORM="macos osx bsd unix" |
|
| 162 elif echo "$OS" | grep -i "MINGW" > /dev/null; then |
|
| 163 PLATFORM="windows mingw" |
|
| 164 fi |
|
| 165 : ${PLATFORM:="unix"} |
|
| 166 |
|
| 167 PLATFORM_NAME=`echo "$PLATFORM" | cut -f1 -d' ' -` |
|
| 168 echo "$PLATFORM_NAME" |
|
| 169 |
|
| 170 isplatform() |
|
| 171 { |
|
| 172 for p in $PLATFORM |
|
| 173 do |
|
| 174 if [ "$p" = "$1" ]; then |
|
| 175 return 0 |
|
| 176 fi |
|
| 177 done |
|
| 178 return 1 |
|
| 179 } |
|
| 180 notisplatform() |
|
| 181 { |
|
| 182 for p in $PLATFORM |
|
| 183 do |
|
| 184 if [ "$p" = "$1" ]; then |
|
| 185 return 1 |
|
| 186 fi |
|
| 187 done |
|
| 188 return 0 |
|
| 189 } |
|
| 190 istoolchain() |
|
| 191 { |
|
| 192 for t in $TOOLCHAIN |
|
| 193 do |
|
| 194 if [ "$t" = "$1" ]; then |
|
| 195 return 0 |
|
| 196 fi |
|
| 197 done |
|
| 198 return 1 |
|
| 199 } |
|
| 200 notistoolchain() |
|
| 201 { |
|
| 202 for t in $TOOLCHAIN |
|
| 203 do |
|
| 204 if [ "$t" = "$1" ]; then |
|
| 205 return 1 |
|
| 206 fi |
|
| 207 done |
|
| 208 return 0 |
|
| 209 } |
|
| 210 |
233 |
| 211 |
234 |
| 212 # generate vars.mk |
235 # generate vars.mk |
| 213 cat > "$TEMP_DIR/vars.mk" << __EOF__ |
236 cat > "$TEMP_DIR/vars.mk" << __EOF__ |
| 214 prefix=$prefix |
237 prefix=$prefix |
| 564 __EOF__ |
587 __EOF__ |
| 565 break |
588 break |
| 566 done |
589 done |
| 567 break |
590 break |
| 568 done |
591 done |
| |
592 |
| |
593 # build type |
| |
594 if [ "$BUILD_TYPE" = "debug" ]; then |
| |
595 TEMP_CFLAGS="\${DEBUG_CFLAGS}$TEMP_CFLAGS" |
| |
596 TEMP_CXXFLAGS="\${DEBUG_CXXFLAGS}$TEMP_CXXFLAGS" |
| |
597 fi |
| |
598 if [ "$BUILD_TYPE" = "release" ]; then |
| |
599 TEMP_CFLAGS="\${RELEASE_CFLAGS}$TEMP_CFLAGS" |
| |
600 TEMP_CXXFLAGS="\${RELEASE_CXXFLAGS}$TEMP_CXXFLAGS" |
| |
601 fi |
| 569 |
602 |
| 570 # add general dependency flags to flags.mk |
603 # add general dependency flags to flags.mk |
| 571 echo "# general flags" >> "$TEMP_DIR/flags.mk" |
604 echo "# general flags" >> "$TEMP_DIR/flags.mk" |
| 572 if [ -n "${TEMP_CFLAGS}" ] && [ -n "$lang_c" ]; then |
605 if [ -n "${TEMP_CFLAGS}" ] && [ -n "$lang_c" ]; then |
| 573 echo "CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk" |
606 echo "CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk" |
| 614 echo "DAV_CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk" |
647 echo "DAV_CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk" |
| 615 fi |
648 fi |
| 616 if [ -n "${TEMP_CXXFLAGS}" ] && [ -n "$lang_cpp" ]; then |
649 if [ -n "${TEMP_CXXFLAGS}" ] && [ -n "$lang_cpp" ]; then |
| 617 echo "DAV_CXXFLAGS += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk" |
650 echo "DAV_CXXFLAGS += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk" |
| 618 fi |
651 fi |
| 619 if [ "$BUILD_TYPE" = "debug" ]; then |
|
| 620 if [ -n "$lang_c" ]; then |
|
| 621 echo 'DAV_CFLAGS += ${DEBUG_CC_FLAGS}' >> "$TEMP_DIR/flags.mk" |
|
| 622 fi |
|
| 623 if [ -n "$lang_cpp" ]; then |
|
| 624 echo 'DAV_CXXFLAGS += ${DEBUG_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk" |
|
| 625 fi |
|
| 626 fi |
|
| 627 if [ "$BUILD_TYPE" = "release" ]; then |
|
| 628 if [ -n "$lang_c" ]; then |
|
| 629 echo 'DAV_CFLAGS += ${RELEASE_CC_FLAGS}' >> "$TEMP_DIR/flags.mk" |
|
| 630 fi |
|
| 631 if [ -n "$lang_cpp" ]; then |
|
| 632 echo 'DAV_CXXFLAGS += ${RELEASE_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk" |
|
| 633 fi |
|
| 634 fi |
|
| 635 if [ -n "${TEMP_LDFLAGS}" ]; then |
652 if [ -n "${TEMP_LDFLAGS}" ]; then |
| 636 echo "DAV_LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk" |
653 echo "DAV_LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk" |
| 637 fi |
654 fi |
| 638 |
655 |
| 639 |
656 |
| 645 abort_configure |
662 abort_configure |
| 646 fi |
663 fi |
| 647 |
664 |
| 648 echo "configure finished" |
665 echo "configure finished" |
| 649 echo |
666 echo |
| |
667 echo "Toolchain" |
| |
668 echo " name: $TOOLCHAIN_NAME" |
| |
669 if [ -n "$TOOLCHAIN_CC" ]; then |
| |
670 echo " cc: $TOOLCHAIN_CC" |
| |
671 fi |
| |
672 if [ -n "$TOOLCHAIN_CXX" ]; then |
| |
673 echo " cxx: $TOOLCHAIN_CXX" |
| |
674 fi |
| |
675 if [ -n "$TOOLCHAIN_WSIZE" ]; then |
| |
676 echo " word size: $TOOLCHAIN_WSIZE bit" |
| |
677 fi |
| |
678 if [ -n "$TOOLCHAIN_CSTD" ]; then |
| |
679 echo " default C std: $TOOLCHAIN_CSTD" |
| |
680 fi |
| |
681 echo |
| 650 echo "Build Config:" |
682 echo "Build Config:" |
| 651 echo " PREFIX: $prefix" |
683 echo " prefix: $prefix" |
| 652 echo " TOOLCHAIN: $TOOLCHAIN_NAME" |
684 echo " exec_prefix: $exec_prefix" |
| |
685 if [ "$orig_bindir" != "$bindir" ]; then |
| |
686 echo " bindir: $bindir" |
| |
687 fi |
| |
688 if [ "$orig_sbindir" != "$sbindir" ]; then |
| |
689 echo " sbindir: $sbindir" |
| |
690 fi |
| |
691 if [ "$orig_libdir" != "$libdir" ]; then |
| |
692 echo " libdir: $libdir" |
| |
693 fi |
| |
694 if [ "$orig_libexecdir" != "$libexecdir" ]; then |
| |
695 echo " libexecdir: $libexecdir" |
| |
696 fi |
| |
697 if [ "$orig_datarootdir" != "$datarootdir" ]; then |
| |
698 echo " datarootdir: $datarootdir" |
| |
699 fi |
| |
700 if [ "$orig_datadir" != "$datadir" ]; then |
| |
701 echo " datadir: $datadir" |
| |
702 fi |
| |
703 if [ "$orig_sysconfdir" != "$sysconfdir" ]; then |
| |
704 echo " sysconfdir: $sysconfdir" |
| |
705 fi |
| |
706 if [ "$orig_sharedstatedir" != "$sharedstatedir" ]; then |
| |
707 echo " sharedstatedir: $sharedstatedir" |
| |
708 fi |
| |
709 if [ "$orig_localstatedir" != "$localstatedir" ]; then |
| |
710 echo " localstatedir: $localstatedir" |
| |
711 fi |
| |
712 if [ "$orig_runstatedir" != "$runstatedir" ]; then |
| |
713 echo " runstatedir: $runstatedir" |
| |
714 fi |
| |
715 if [ "$orig_includedir" != "$includedir" ]; then |
| |
716 echo " includedir: $includedir" |
| |
717 fi |
| |
718 if [ "$orig_infodir" != "$infodir" ]; then |
| |
719 echo " infodir: $infodir" |
| |
720 fi |
| |
721 if [ "$orig_mandir" != "$mandir" ]; then |
| |
722 echo " mandir: $mandir" |
| |
723 fi |
| |
724 if [ "$orig_localedir" != "$localedir" ]; then |
| |
725 echo " localedir: $localedir" |
| |
726 fi |
| 653 echo |
727 echo |
| 654 |
728 |
| 655 # generate the config.mk file |
729 # generate the config.mk file |
| |
730 pwd=`pwd` |
| 656 cat > "$TEMP_DIR/config.mk" << __EOF__ |
731 cat > "$TEMP_DIR/config.mk" << __EOF__ |
| 657 # |
732 # |
| 658 # config.mk generated by configure |
733 # config.mk generated by: |
| |
734 # pwd: $pwd |
| |
735 # $0 $@ |
| 659 # |
736 # |
| 660 |
737 |
| 661 __EOF__ |
738 __EOF__ |
| 662 write_toolchain_defaults "$TEMP_DIR/toolchain.mk" |
739 write_toolchain_defaults "$TEMP_DIR/toolchain.mk" |
| 663 cat "$TEMP_DIR/vars.mk" "$TEMP_DIR/toolchain.mk" "$TEMP_DIR/flags.mk" "$TEMP_DIR/make.mk" > config.mk |
740 cat "$TEMP_DIR/config.mk" "$TEMP_DIR/vars.mk" "$TEMP_DIR/toolchain.mk" "$TEMP_DIR/flags.mk" "$TEMP_DIR/make.mk" > config.mk |
| 664 rm -Rf "$TEMP_DIR" |
741 rm -Rf "$TEMP_DIR" |