configure

changeset 32
e5f4d8af567e
parent 0
2483f517c562
child 44
473954dc6b74
equal deleted inserted replaced
31:bf810176ddb8 32:e5f4d8af567e
1 #!/bin/sh 1 #!/bin/sh
2 2
3 3 # create temporary directory
4 PREFIX=/usr
5 EPREFIX=$PREFIX
6
7 BINDIR=
8 SBINDIR=
9 LIBDIR=
10 LIBEXECDIR=
11 DATADIR=
12 SYSCONFDIR=
13 SHAREDSTATEDIR=
14 LOCALSTATEDIR=
15 INCLUDEDIR=
16 INFODIR=
17 MANDIR=
18
19 OS=`uname -s`
20 OS_VERSION=`uname -r`
21
22 TEMP_DIR=".tmp-`uname -n`" 4 TEMP_DIR=".tmp-`uname -n`"
23 mkdir -p $TEMP_DIR 5 rm -Rf "$TEMP_DIR"
24 if [ $? -ne 0 ]; then 6 if mkdir -p "$TEMP_DIR"; then
25 echo "Cannot create tmp dir" 7 :
26 echo "Abort" 8 else
27 fi 9 echo "Cannot create tmp dir $TEMP_DIR"
28 touch $TEMP_DIR/options 10 echo "Abort"
29 touch $TEMP_DIR/features 11 exit 1
12 fi
13 touch "$TEMP_DIR/options"
14 touch "$TEMP_DIR/features"
15
16 # define standard variables
17 # also define standard prefix (this is where we will search for config.site)
18 prefix=/usr
19 exec_prefix=
20 bindir=
21 sbindir=
22 libdir=
23 libexecdir=
24 datarootdir=
25 datadir=
26 sysconfdir=
27 sharedstatedir=
28 localstatedir=
29 runstatedir=
30 includedir=
31 infodir=
32 localedir=
33 mandir=
34
35 # custom variables
30 36
31 # features 37 # features
38
39 # clean abort
40 abort_configure()
41 {
42 rm -Rf "$TEMP_DIR"
43 exit 1
44 }
32 45
33 # help text 46 # help text
34 printhelp() 47 printhelp()
35 { 48 {
36 echo "Usage: $0 [OPTIONS]..." 49 echo "Usage: $0 [OPTIONS]..."
37 cat << __EOF__ 50 cat << __EOF__
38 Installation directories: 51 Installation directories:
39 --prefix=PREFIX path prefix for architecture-independent files 52 --prefix=PREFIX path prefix for architecture-independent files
40 [/usr] 53 [/usr]
41 --exec-prefix=EPREFIX path prefix for architecture-dependent files 54 --exec-prefix=EPREFIX path prefix for architecture-dependent files
42 [PREFIX] 55 [PREFIX]
45 --sbindir=DIR system admin executables [EPREFIX/sbin] 58 --sbindir=DIR system admin executables [EPREFIX/sbin]
46 --libexecdir=DIR program executables [EPREFIX/libexec] 59 --libexecdir=DIR program executables [EPREFIX/libexec]
47 --sysconfdir=DIR system configuration files [PREFIX/etc] 60 --sysconfdir=DIR system configuration files [PREFIX/etc]
48 --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] 61 --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
49 --localstatedir=DIR modifiable single-machine data [PREFIX/var] 62 --localstatedir=DIR modifiable single-machine data [PREFIX/var]
63 --runstatedir=DIR run-time variable data [LOCALSTATEDIR/run]
50 --libdir=DIR object code libraries [EPREFIX/lib] 64 --libdir=DIR object code libraries [EPREFIX/lib]
51 --includedir=DIR C header files [PREFIX/include] 65 --includedir=DIR C header files [PREFIX/include]
52 --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] 66 --datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
53 --datadir=DIR read-only architecture-independent data [DATAROOTDIR] 67 --datadir=DIR read-only architecture-independent data [DATAROOTDIR]
54 --infodir=DIR info documentation [DATAROOTDIR/info] 68 --infodir=DIR info documentation [DATAROOTDIR/info]
55 --mandir=DIR man documentation [DATAROOTDIR/man] 69 --mandir=DIR man documentation [DATAROOTDIR/man]
70 --localedir=DIR locale-dependent data [DATAROOTDIR/locale]
56 71
57 Options: 72 Options:
73 --debug add extra compile flags for debug builds
74 --release add extra compile flags for release builds
58 --toolkit=(gtk4|gtk3|gtk2|gtk2legacy|qt5|qt4|motif) 75 --toolkit=(gtk4|gtk3|gtk2|gtk2legacy|qt5|qt4|motif)
59 76
60 __EOF__ 77 __EOF__
61 } 78 }
62 79
63 # 80 #
64 # parse arguments 81 # parse arguments
65 # 82 #
66 for ARG in $@ 83 BUILD_TYPE="default"
84 for ARG in "$@"
67 do 85 do
68 case "$ARG" in 86 case "$ARG" in
69 "--prefix="*) PREFIX=${ARG#--prefix=} ;; 87 "--prefix="*) prefix=${ARG#--prefix=} ;;
70 "--exec-prefix="*) EPREFIX=${ARG#--exec-prefix=} ;; 88 "--exec-prefix="*) exec_prefix=${ARG#--exec-prefix=} ;;
71 "--bindir="*) BINDIR=${ARG#----bindir=} ;; 89 "--bindir="*) bindir=${ARG#----bindir=} ;;
72 "--sbindir="*) SBINDIR=${ARG#--sbindir=} ;; 90 "--sbindir="*) sbindir=${ARG#--sbindir=} ;;
73 "--libdir="*) LIBDIR=${ARG#--libdir=} ;; 91 "--libdir="*) libdir=${ARG#--libdir=} ;;
74 "--libexecdir="*) LIBEXECDIR=${ARG#--libexecdir=} ;; 92 "--libexecdir="*) libexecdir=${ARG#--libexecdir=} ;;
75 "--datadir="*) DATADIR=${ARG#--datadir=} ;; 93 "--datarootdir="*) datarootdir=${ARG#--datarootdir=} ;;
76 "--sysconfdir="*) SYSCONFDIR=${ARG#--sysconfdir=} ;; 94 "--datadir="*) datadir=${ARG#--datadir=} ;;
77 "--sharedstatedir="*) SHAREDSTATEDIR=${ARG#--sharedstatedir=} ;; 95 "--sysconfdir="*) sysconfdir=${ARG#--sysconfdir=} ;;
78 "--localstatedir="*) LOCALSTATEDIR=${ARG#--localstatedir=} ;; 96 "--sharedstatedir="*) sharedstatedir=${ARG#--sharedstatedir=} ;;
79 "--includedir="*) INCLUDEDIR=${ARG#--includedir=} ;; 97 "--localstatedir="*) localstatedir=${ARG#--localstatedir=} ;;
80 "--infodir="*) INFODIR=${ARG#--infodir=} ;; 98 "--includedir="*) includedir=${ARG#--includedir=} ;;
81 "--mandir"*) MANDIR=${ARG#--mandir} ;; 99 "--infodir="*) infodir=${ARG#--infodir=} ;;
82 "--help"*) printhelp; exit 1 ;; 100 "--mandir"*) mandir=${ARG#--mandir} ;;
83 "--toolkit="*) OPT_TOOLKIT=${ARG#--toolkit=} ;; 101 "--localedir"*) localedir=${ARG#--localedir} ;;
84 "-"*) echo "unknown option: $ARG"; exit 1 ;; 102 "--help"*) printhelp; abort_configure ;;
85 esac 103 "--debug") BUILD_TYPE="debug" ;;
104 "--release") BUILD_TYPE="release" ;;
105 "--toolkit="*) OPT_TOOLKIT=${ARG#--toolkit=} ;;
106 "-"*) echo "unknown option: $ARG"; abort_configure ;;
107 esac
86 done 108 done
87 109
88 # set dir variables 110
89 if [ -z "$BINDIR" ]; then 111
90 BINDIR=$EPREFIX/bin 112 # set defaults for dir variables
91 fi 113 : ${exec_prefix:="$prefix"}
92 if [ -z "$SBINDIR" ]; then 114 : ${bindir:='${exec_prefix}/bin'}
93 SBINDIR=$EPREFIX/sbin 115 : ${sbindir:='${exec_prefix}/sbin'}
94 fi 116 : ${libdir:='${exec_prefix}/lib'}
95 if [ -z "$LIBDIR" ]; then 117 : ${libexecdir:='${exec_prefix}/libexec'}
96 LIBDIR=$EPREFIX/lib 118 : ${datarootdir:='${prefix}/share'}
97 fi 119 : ${datadir:='${datarootdir}'}
98 if [ -z "$LIBEXEC" ]; then 120 : ${sysconfdir:='${prefix}/etc'}
99 LIBEXECDIR=$EPREFIX/libexec 121 : ${sharedstatedir:='${prefix}/com'}
100 fi 122 : ${localstatedir:='${prefix}/var'}
101 if [ -z "$DATADIR" ]; then 123 : ${runstatedir:='${localstatedir}/run'}
102 DATADIR=$PREFIX/share 124 : ${includedir:='${prefix}/include'}
103 fi 125 : ${infodir:='${datarootdir}/info'}
104 if [ -z "$SYSCONFDIR" ]; then 126 : ${mandir:='${datarootdir}/man'}
105 SYSCONFDIR=$PREFIX/etc 127 : ${localedir:='${datarootdir}/locale'}
106 fi 128
107 if [ -z "$SHAREDSTATEDIR" ]; then 129 # check if a config.site exists and load it
108 SHAREDSTATEDIR=$PREFIX/com 130 if [ -n "$CONFIG_SITE" ]; then
109 fi 131 # CONFIG_SITE may contain space separated file names
110 if [ -z "$LOCALSTATEDIR" ]; then 132 for cs in $CONFIG_SITE; do
111 LOCALSTATEDIR=$PREFIX/var 133 printf "loading defaults from $cs... "
112 fi 134 . "$cs"
113 if [ -z "$INCLUDEDIR" ]; then 135 echo ok
114 INCLUDEDIR=$PREFIX/include 136 done
115 fi 137 elif [ -f "$prefix/share/config.site" ]; then
116 if [ -z "$INFODIR" ]; then 138 printf "loading site defaults... "
117 INFODIR=$PREFIX/info 139 . "$prefix/share/config.site"
118 fi 140 echo ok
119 if [ -z "$MANDIR" ]; then 141 elif [ -f "$prefix/etc/config.site" ]; then
120 MANDIR=$PREFIX/man 142 printf "loading site defaults... "
121 fi 143 . "$prefix/etc/config.site"
122 144 echo ok
123 which pkg-config > /dev/null 145 fi
124 if [ $? -eq 0 ]; then 146
125 PKG_CONFIG=pkg-config 147 # Test for availability of pkg-config
126 else 148 PKG_CONFIG=`command -v pkg-config`
127 PKG_CONFIG=false 149 : ${PKG_CONFIG:="false"}
128 fi
129 150
130 # Simple uname based platform detection 151 # Simple uname based platform detection
131 # $PLATFORM is used for platform dependent dependency selection 152 # $PLATFORM is used for platform dependent dependency selection
153 OS=`uname -s`
154 OS_VERSION=`uname -r`
132 printf "detect platform... " 155 printf "detect platform... "
133 if [ $OS = SunOS ]; then 156 if [ "$OS" = "SunOS" ]; then
134 PLATFORM="solaris sunos unix svr4" 157 PLATFORM="solaris sunos unix svr4"
135 fi 158 elif [ "$OS" = "Linux" ]; then
136 if [ $OS = Linux ]; then
137 PLATFORM="linux unix" 159 PLATFORM="linux unix"
138 fi 160 elif [ "$OS" = "FreeBSD" ]; then
139 if [ $OS = FreeBSD ]; then
140 PLATFORM="freebsd bsd unix" 161 PLATFORM="freebsd bsd unix"
141 fi 162 elif [ "$OS" = "OpenBSD" ]; then
142 if [ $OS = Darwin ]; then 163 PLATFORM="openbsd bsd unix"
164 elif [ "$OS" = "NetBSD" ]; then
165 PLATFORM="netbsd bsd unix"
166 elif [ "$OS" = "Darwin" ]; then
143 PLATFORM="macos osx bsd unix" 167 PLATFORM="macos osx bsd unix"
144 fi 168 elif echo "$OS" | grep -i "MINGW" > /dev/null; then
145 echo $OS | grep "MINGW" > /dev/null
146 if [ $? -eq 0 ]; then
147 PLATFORM="windows mingw" 169 PLATFORM="windows mingw"
148 fi 170 fi
149 171 : ${PLATFORM:="unix"}
150 if [ -z "$PLATFORM" ]; then 172
151 PLATFORM="unix" 173 PLATFORM_NAME=`echo "$PLATFORM" | cut -f1 -d' ' -`
152 fi 174 echo "$PLATFORM_NAME"
153
154 for p in $PLATFORM
155 do
156 PLATFORM_NAME=$p
157 break
158 done
159 echo $PLATFORM_NAME
160 175
161 isplatform() 176 isplatform()
162 { 177 {
163 for p in $PLATFORM 178 for p in $PLATFORM
164 do 179 do
165 if [ $p = $1 ]; then 180 if [ "$p" = "$1" ]; then
166 return 0 181 return 0
167 fi 182 fi
168 done 183 done
169 return 1 184 return 1
170 } 185 }
171 isnotplatform() 186 notisplatform()
172 { 187 {
173 for p in $PLATFORM 188 for p in $PLATFORM
174 do 189 do
175 if [ $p = $1 ]; then 190 if [ "$p" = "$1" ]; then
176 return 1 191 return 1
177 fi 192 fi
178 done 193 done
179 return 0 194 return 0
180 } 195 }
181 196 istoolchain()
182 # generate config.mk and config.h 197 {
183 cat > $TEMP_DIR/config.mk << __EOF__ 198 for t in $TOOLCHAIN
184 # 199 do
185 # config.mk generated by configure 200 if [ "$t" = "$1" ]; then
186 # 201 return 0
187 202 fi
188 # general vars 203 done
189 204 return 1
190 PREFIX=$PREFIX 205 }
191 EPREFIX=$EPREFIX 206 notistoolchain()
192 207 {
193 BINDIR=$BINDIR 208 for t in $TOOLCHAIN
194 SBINDIR=$SBINDIR 209 do
195 LIBDIR=$LIBDIR 210 if [ "$t" = "$1" ]; then
196 LIBEXECDIR=$LIBEXECDIR 211 return 1
197 DATADIR=$DATADIR 212 fi
198 SYSCONFDIR=$SYSCONFDIR 213 done
199 SHAREDSTATEDIR=$SHAREDSTATEDIR 214 return 0
200 LOCALSTATEDIR=$LOCALSTATEDIR 215 }
201 INCLUDEDIR=$INCLUDEDIR 216
202 INFODIR=$INFODIR 217
203 MANDIR=$MANDIR 218 # generate vars.mk
204 219 cat > "$TEMP_DIR/vars.mk" << __EOF__
205 __EOF__ 220 prefix=$prefix
206 221 exec_prefix=$exec_prefix
207 echo > $TEMP_DIR/make.mk 222 bindir=$bindir
208 223 sbindir=$sbindir
209 ENV_CFLAGS=$CFLAGS 224 libdir=$libdir
210 ENV_LDFLAGS=$LDFLAGS 225 libexecdir=$libexecdir
211 ENV_CXXFLAGS=$CXXFLAGS 226 datarootdir=$datarootdir
212 227 datadir=$datadir
213 # Toolchain detection 228 sysconfdir=$sysconfdir
214 # this will insert make vars to config.mk 229 sharedstatedir=$sharedstatedir
230 localstatedir=$localstatedir
231 runstatedir=$runstatedir
232 includedir=$includedir
233 infodir=$infodir
234 mandir=$mandir
235 localedir=$localedir
236 __EOF__
237
238 # toolchain detection utilities
215 . make/toolchain.sh 239 . make/toolchain.sh
216
217 # add user specified flags to config.mk
218 echo >> $TEMP_DIR/config.mk
219 if [ ! -z "${ENV_CFLAGS}" ]; then
220 echo "CFLAGS += $ENV_CFLAGS" >> $TEMP_DIR/config.mk
221 fi
222 if [ ! -z "${ENV_CXXFLAGS}" ]; then
223 echo "CXXFLAGS += $ENV_CXXFLAGS" >> $TEMP_DIR/config.mk
224 fi
225 if [ ! -z "${ENV_LDFLAGS}" ]; then
226 echo "LDFLAGS += $ENV_LDFLAGS" >> $TEMP_DIR/config.mk
227 fi
228 240
229 # 241 #
230 # DEPENDENCIES 242 # DEPENDENCIES
231 # 243 #
232 244
233 dependency_qt4() 245 # check languages
234 { 246 lang_c=
235 printf "checking for qt4... " 247 lang_cpp=
236 # dependency qt4 248 if detect_c_compiler ; then
237 while true 249 lang_c=1
238 do 250 fi
239 qmake-qt4 -o - /dev/null | grep DEFINES\ > /dev/null 251
240 if [ $? -eq 0 ]; then 252 # create buffer for make variables required by dependencies
241 CFLAGS="$CFLAGS `qmake-qt4 -o - /dev/null | grep DEFINES\ `" 253 echo > "$TEMP_DIR/make.mk"
242 else 254
243 break 255 test_pkg_config()
244 fi 256 {
245 qmake-qt4 -o - /dev/null | grep INCPATH\ > /dev/null 257 if "$PKG_CONFIG" --exists "$1" ; then :
246 if [ $? -eq 0 ]; then 258 else return 1 ; fi
247 CFLAGS="$CFLAGS `qmake-qt4 -o - /dev/null | grep INCPATH\ `" 259 if [ -z "$2" ] || "$PKG_CONFIG" --atleast-version="$2" "$1" ; then :
248 else 260 else return 1 ; fi
249 break 261 if [ -z "$3" ] || "$PKG_CONFIG" --exact-version="$3" "$1" ; then :
250 fi 262 else return 1 ; fi
251 > /dev/null 263 if [ -z "$4" ] || "$PKG_CONFIG" --max-version="$4" "$1" ; then :
252 if [ $? -eq 0 ]; then 264 else return 1 ; fi
253 LDFLAGS="$LDFLAGS ``" 265 return 0
254 else 266 }
255 break 267
256 fi 268 print_check_msg()
257 which qmake-qt4 > /dev/null 269 {
258 if [ $? -ne 0 ]; then 270 if [ -z "$1" ]; then
259 break 271 shift
260 fi 272 printf "$@"
261 echo yes 273 fi
262 return 0 274 }
263 done 275
264 276 dependency_error_gtk2legacy()
265 echo no 277 {
266 return 1 278 print_check_msg "$dep_checked_gtk2legacy" "checking for gtk2legacy... "
267 } 279 # dependency gtk2legacy
268 dependency_gtk2legacy()
269 {
270 printf "checking for gtk2legacy... "
271 # dependency gtk2legacy
272 while true 280 while true
273 do 281 do
274 if [ -z "$PKG_CONFIG" ]; then 282 if [ -z "$PKG_CONFIG" ]; then
275 break 283 break
276 fi 284 fi
277 $PKG_CONFIG gtk+-2.0 285 if test_pkg_config "gtk+-2.0" "" "" "" ; then
278 if [ $? -ne 0 ] ; then 286 TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags gtk+-2.0`"
279 break 287 TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs gtk+-2.0`"
280 fi 288 else
281 CFLAGS="$CFLAGS `$PKG_CONFIG --cflags gtk+-2.0`" 289 break
282 LDFLAGS="$LDFLAGS `$PKG_CONFIG --libs gtk+-2.0`" 290 fi
283 CFLAGS="$CFLAGS -DUI_GTK2 -DUI_GTK2LEGACY" 291 TEMP_CFLAGS="$TEMP_CFLAGS -DUI_GTK2 -DUI_GTK2LEGACY"
284 LDFLAGS="$LDFLAGS -lpthread" 292 TEMP_LDFLAGS="$TEMP_LDFLAGS -lpthread"
285 echo yes 293 print_check_msg "$dep_checked_gtk2legacy" "yes\n"
286 return 0 294 dep_checked_gtk2legacy=1
287 done 295 return 1
288 296 done
289 echo no 297
290 return 1 298 print_check_msg "$dep_checked_gtk2legacy" "no\n"
291 } 299 dep_checked_gtk2legacy=1
292 dependency_qt5() 300 return 0
293 { 301 }
294 printf "checking for qt5... " 302 dependency_error_curl()
295 # dependency qt5 303 {
296 while true 304 print_check_msg "$dep_checked_curl" "checking for curl... "
297 do 305 # dependency curl platform="macos"
298 qmake-qt5 -o - /dev/null | grep DEFINES\ > /dev/null 306 while true
299 if [ $? -eq 0 ]; then 307 do
300 CFLAGS="$CFLAGS `qmake-qt5 -o - /dev/null | grep DEFINES\ `" 308 if notisplatform "macos"; then
301 else 309 break
302 break 310 fi
303 fi 311 if tmp_flags=`curl-config --cflags` ; then
304 qmake-qt5 -o - /dev/null | grep INCPATH\ > /dev/null 312 TEMP_CFLAGS="$TEMP_CFLAGS $tmp_flags"
305 if [ $? -eq 0 ]; then 313 else
306 CFLAGS="$CFLAGS `qmake-qt5 -o - /dev/null | grep INCPATH\ `" 314 break
307 else 315 fi
308 break 316 if tmp_flags=`curl-config --ldflags` ; then
309 fi 317 TEMP_LDFLAGS="$TEMP_LDFLAGS $tmp_flags"
310 > /dev/null 318 else
311 if [ $? -eq 0 ]; then 319 break
312 LDFLAGS="$LDFLAGS ``" 320 fi
313 else 321 print_check_msg "$dep_checked_curl" "yes\n"
314 break 322 dep_checked_curl=1
315 fi 323 return 1
316 which qmake-qt5 > /dev/null 324 done
317 if [ $? -ne 0 ]; then 325
318 break 326 # dependency curl
319 fi
320 echo yes
321 return 0
322 done
323
324 echo no
325 return 1
326 }
327 dependency_gtk2()
328 {
329 printf "checking for gtk2... "
330 # dependency gtk2
331 while true 327 while true
332 do 328 do
333 if [ -z "$PKG_CONFIG" ]; then 329 if [ -z "$PKG_CONFIG" ]; then
334 break 330 break
335 fi 331 fi
336 $PKG_CONFIG gtk+-2.0 332 if test_pkg_config "libcurl" "" "" "" ; then
337 if [ $? -ne 0 ] ; then 333 TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags libcurl`"
338 break 334 TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs libcurl`"
339 fi 335 else
340 CFLAGS="$CFLAGS `$PKG_CONFIG --cflags gtk+-2.0`" 336 break
341 LDFLAGS="$LDFLAGS `$PKG_CONFIG --libs gtk+-2.0`" 337 fi
342 CFLAGS="$CFLAGS -DUI_GTK2" 338 print_check_msg "$dep_checked_curl" "yes\n"
343 LDFLAGS="$LDFLAGS -lpthread" 339 dep_checked_curl=1
344 pkg-config --atleast-version=2.20 gtk+-2.0 > /dev/null 340 return 1
345 if [ $? -ne 0 ]; then 341 done
346 break 342
347 fi 343 # dependency curl
348 echo yes 344 while true
349 return 0 345 do
350 done 346 if tmp_flags=`curl-config --cflags` ; then
351 347 TEMP_CFLAGS="$TEMP_CFLAGS $tmp_flags"
352 echo no 348 else
353 return 1 349 break
354 } 350 fi
355 dependency_gtk3() 351 if tmp_flags=`curl-config --libs` ; then
356 { 352 TEMP_LDFLAGS="$TEMP_LDFLAGS $tmp_flags"
357 printf "checking for gtk3... " 353 else
358 # dependency gtk3 354 break
355 fi
356 print_check_msg "$dep_checked_curl" "yes\n"
357 dep_checked_curl=1
358 return 1
359 done
360
361 print_check_msg "$dep_checked_curl" "no\n"
362 dep_checked_curl=1
363 return 0
364 }
365 dependency_error_gtk2()
366 {
367 print_check_msg "$dep_checked_gtk2" "checking for gtk2... "
368 # dependency gtk2
359 while true 369 while true
360 do 370 do
361 if [ -z "$PKG_CONFIG" ]; then 371 if [ -z "$PKG_CONFIG" ]; then
362 break 372 break
363 fi 373 fi
364 $PKG_CONFIG gtk+-3.0 374 if pkg-config --atleast-version=2.20 gtk+-2.0 > /dev/null ; then
365 if [ $? -ne 0 ] ; then 375 :
366 break 376 else
367 fi 377 break
368 CFLAGS="$CFLAGS `$PKG_CONFIG --cflags gtk+-3.0`" 378 fi
369 LDFLAGS="$LDFLAGS `$PKG_CONFIG --libs gtk+-3.0`" 379 if test_pkg_config "gtk+-2.0" "" "" "" ; then
370 CFLAGS="$CFLAGS -DUI_GTK3" 380 TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags gtk+-2.0`"
371 LDFLAGS="$LDFLAGS -lpthread" 381 TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs gtk+-2.0`"
372 echo yes 382 else
373 return 0 383 break
374 done 384 fi
375 385 TEMP_CFLAGS="$TEMP_CFLAGS -DUI_GTK2"
376 echo no 386 TEMP_LDFLAGS="$TEMP_LDFLAGS -lpthread"
377 return 1 387 print_check_msg "$dep_checked_gtk2" "yes\n"
378 } 388 dep_checked_gtk2=1
379 dependency_gtk4() 389 return 1
380 { 390 done
381 printf "checking for gtk4... " 391
382 # dependency gtk4 392 print_check_msg "$dep_checked_gtk2" "no\n"
393 dep_checked_gtk2=1
394 return 0
395 }
396 dependency_error_gtk3()
397 {
398 print_check_msg "$dep_checked_gtk3" "checking for gtk3... "
399 # dependency gtk3
383 while true 400 while true
384 do 401 do
385 if [ -z "$PKG_CONFIG" ]; then 402 if [ -z "$PKG_CONFIG" ]; then
386 break 403 break
387 fi 404 fi
388 $PKG_CONFIG gtk+-4.0 405 if test_pkg_config "gtk+-3.0" "" "" "" ; then
389 if [ $? -ne 0 ] ; then 406 TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags gtk+-3.0`"
390 break 407 TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs gtk+-3.0`"
391 fi 408 else
392 CFLAGS="$CFLAGS `$PKG_CONFIG --cflags gtk+-4.0`" 409 break
393 LDFLAGS="$LDFLAGS `$PKG_CONFIG --libs gtk+-4.0`" 410 fi
394 CFLAGS="$CFLAGS -DUI_GTK3" 411 TEMP_CFLAGS="$TEMP_CFLAGS -DUI_GTK3"
395 LDFLAGS="$LDFLAGS -lpthread" 412 TEMP_LDFLAGS="$TEMP_LDFLAGS -lpthread"
396 echo yes 413 print_check_msg "$dep_checked_gtk3" "yes\n"
397 return 0 414 dep_checked_gtk3=1
398 done 415 return 1
399 416 done
400 echo no 417
401 return 1 418 print_check_msg "$dep_checked_gtk3" "no\n"
402 } 419 dep_checked_gtk3=1
403 dependency_motif() 420 return 0
404 { 421 }
405 printf "checking for motif... " 422 dependency_error_gtk4()
423 {
424 print_check_msg "$dep_checked_gtk4" "checking for gtk4... "
425 # dependency gtk4
426 while true
427 do
428 if [ -z "$PKG_CONFIG" ]; then
429 break
430 fi
431 if test_pkg_config "gtk+-4.0" "" "" "" ; then
432 TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags gtk+-4.0`"
433 TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs gtk+-4.0`"
434 else
435 break
436 fi
437 TEMP_CFLAGS="$TEMP_CFLAGS -DUI_GTK3"
438 TEMP_LDFLAGS="$TEMP_LDFLAGS -lpthread"
439 print_check_msg "$dep_checked_gtk4" "yes\n"
440 dep_checked_gtk4=1
441 return 1
442 done
443
444 print_check_msg "$dep_checked_gtk4" "no\n"
445 dep_checked_gtk4=1
446 return 0
447 }
448 dependency_error_openssl()
449 {
450 print_check_msg "$dep_checked_openssl" "checking for openssl... "
451 # dependency openssl platform="windows"
452 while true
453 do
454 if notisplatform "windows"; then
455 break
456 fi
457 TEMP_LDFLAGS="$TEMP_LDFLAGS -lssl -lcrypto"
458 print_check_msg "$dep_checked_openssl" "yes\n"
459 dep_checked_openssl=1
460 return 1
461 done
462
463 # dependency openssl platform="macos"
464 while true
465 do
466 if notisplatform "macos"; then
467 break
468 fi
469 TEMP_LDFLAGS="$TEMP_LDFLAGS -framework CoreFoundation"
470 print_check_msg "$dep_checked_openssl" "yes\n"
471 dep_checked_openssl=1
472 return 1
473 done
474
475 # dependency openssl platform="bsd"
476 while true
477 do
478 if notisplatform "bsd"; then
479 break
480 fi
481 if isplatform "macos" || istoolchain "macos"; then
482 break
483 fi
484 TEMP_LDFLAGS="$TEMP_LDFLAGS -lssl -lcrypto"
485 print_check_msg "$dep_checked_openssl" "yes\n"
486 dep_checked_openssl=1
487 return 1
488 done
489
490 # dependency openssl
491 while true
492 do
493 if [ -z "$PKG_CONFIG" ]; then
494 break
495 fi
496 if test_pkg_config "openssl" "" "" "" ; then
497 TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags openssl`"
498 TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs openssl`"
499 else
500 break
501 fi
502 print_check_msg "$dep_checked_openssl" "yes\n"
503 dep_checked_openssl=1
504 return 1
505 done
506
507 print_check_msg "$dep_checked_openssl" "no\n"
508 dep_checked_openssl=1
509 return 0
510 }
511 dependency_error_motif()
512 {
513 print_check_msg "$dep_checked_motif" "checking for motif... "
406 # dependency motif platform="bsd" 514 # dependency motif platform="bsd"
407 while true 515 while true
408 do 516 do
409 if isnotplatform "bsd"; then 517 if notisplatform "bsd"; then
410 break 518 break
411 fi 519 fi
412 CFLAGS="$CFLAGS -DUI_MOTIF -I/usr/local/include/X11" 520 TEMP_CFLAGS="$TEMP_CFLAGS -DUI_MOTIF -I/usr/local/include/X11"
413 LDFLAGS="$LDFLAGS -lXm -lXt -lX11 -lpthread" 521 TEMP_LDFLAGS="$TEMP_LDFLAGS -lXm -lXt -lX11 -lpthread"
414 echo yes 522 print_check_msg "$dep_checked_motif" "yes\n"
415 return 0 523 dep_checked_motif=1
416 done 524 return 1
417 525 done
418 # dependency motif 526
419 while true 527 # dependency motif
420 do 528 while true
421 CFLAGS="$CFLAGS -DUI_MOTIF" 529 do
422 LDFLAGS="$LDFLAGS -lXm -lXt -lX11 -lpthread" 530 TEMP_CFLAGS="$TEMP_CFLAGS -DUI_MOTIF"
423 echo yes 531 TEMP_LDFLAGS="$TEMP_LDFLAGS -lXm -lXt -lX11 -lpthread"
424 return 0 532 print_check_msg "$dep_checked_motif" "yes\n"
425 done 533 dep_checked_motif=1
426 534 return 1
427 echo no 535 done
428 return 1 536
429 } 537 print_check_msg "$dep_checked_motif" "no\n"
430 dependency_winui() 538 dep_checked_motif=1
431 { 539 return 0
432 printf "checking for winui... " 540 }
541 dependency_error_libxml2()
542 {
543 print_check_msg "$dep_checked_libxml2" "checking for libxml2... "
544 # dependency libxml2 platform="windows"
545 while true
546 do
547 if notisplatform "windows"; then
548 break
549 fi
550 if tmp_flags=`xml2-config --cflags` ; then
551 TEMP_CFLAGS="$TEMP_CFLAGS $tmp_flags"
552 else
553 break
554 fi
555 if tmp_flags=`xml2-config --libs` ; then
556 TEMP_LDFLAGS="$TEMP_LDFLAGS $tmp_flags"
557 else
558 break
559 fi
560 print_check_msg "$dep_checked_libxml2" "yes\n"
561 dep_checked_libxml2=1
562 return 1
563 done
564
565 # dependency libxml2 platform="macos"
566 while true
567 do
568 if notisplatform "macos"; then
569 break
570 fi
571 if tmp_flags=`xml2-config --cflags` ; then
572 TEMP_CFLAGS="$TEMP_CFLAGS $tmp_flags"
573 else
574 break
575 fi
576 if tmp_flags=`xml2-config --libs` ; then
577 TEMP_LDFLAGS="$TEMP_LDFLAGS $tmp_flags"
578 else
579 break
580 fi
581 print_check_msg "$dep_checked_libxml2" "yes\n"
582 dep_checked_libxml2=1
583 return 1
584 done
585
586 # dependency libxml2
587 while true
588 do
589 if [ -z "$PKG_CONFIG" ]; then
590 break
591 fi
592 if test_pkg_config "libxml-2.0" "" "" "" ; then
593 TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags libxml-2.0`"
594 TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs libxml-2.0`"
595 else
596 break
597 fi
598 print_check_msg "$dep_checked_libxml2" "yes\n"
599 dep_checked_libxml2=1
600 return 1
601 done
602
603 # dependency libxml2
604 while true
605 do
606 if tmp_flags=`xml2-config --cflags` ; then
607 TEMP_CFLAGS="$TEMP_CFLAGS $tmp_flags"
608 else
609 break
610 fi
611 if tmp_flags=`xml2-config --libs` ; then
612 TEMP_LDFLAGS="$TEMP_LDFLAGS $tmp_flags"
613 else
614 break
615 fi
616 print_check_msg "$dep_checked_libxml2" "yes\n"
617 dep_checked_libxml2=1
618 return 1
619 done
620
621 print_check_msg "$dep_checked_libxml2" "no\n"
622 dep_checked_libxml2=1
623 return 0
624 }
625 dependency_error_cocoa()
626 {
627 print_check_msg "$dep_checked_cocoa" "checking for cocoa... "
628 # dependency cocoa platform="macos"
629 while true
630 do
631 if notisplatform "macos"; then
632 break
633 fi
634 TEMP_CFLAGS="$TEMP_CFLAGS -DUI_COCOA"
635 TEMP_LDFLAGS="$TEMP_LDFLAGS -lobjc -framework Cocoa"
636 print_check_msg "$dep_checked_cocoa" "yes\n"
637 dep_checked_cocoa=1
638 return 1
639 done
640
641 print_check_msg "$dep_checked_cocoa" "no\n"
642 dep_checked_cocoa=1
643 return 0
644 }
645 dependency_error_winui()
646 {
647 print_check_msg "$dep_checked_winui" "checking for winui... "
433 # dependency winui platform="windows" 648 # dependency winui platform="windows"
434 while true 649 while true
435 do 650 do
436 if isnotplatform "windows"; then 651 if notisplatform "windows"; then
437 break 652 break
438 fi 653 fi
439 CFLAGS="$CFLAGS -DUI_WINUI" 654 TEMP_CFLAGS="$TEMP_CFLAGS -DUI_WINUI"
440 echo yes 655 print_check_msg "$dep_checked_winui" "yes\n"
441 return 0 656 dep_checked_winui=1
442 done 657 return 1
443 658 done
444 echo no 659
445 return 1 660 print_check_msg "$dep_checked_winui" "no\n"
446 } 661 dep_checked_winui=1
447 dependency_cocoa() 662 return 0
448 { 663 }
449 printf "checking for cocoa... " 664
450 # dependency cocoa platform="macos" 665 # start collecting dependency information
451 while true 666 echo > "$TEMP_DIR/flags.mk"
452 do
453 if isnotplatform "macos"; then
454 break
455 fi
456 CFLAGS="$CFLAGS -DUI_COCOA"
457 LDFLAGS="$LDFLAGS -lobjc -framework Cocoa"
458 echo yes
459 return 0
460 done
461
462 echo no
463 return 1
464 }
465 667
466 DEPENDENCIES_FAILED= 668 DEPENDENCIES_FAILED=
467 ERROR=0 669 ERROR=0
468 # general dependencies 670 # unnamed dependencies
469 CFLAGS= 671 TEMP_CFLAGS=
470 LDFLAGS= 672 TEMP_CXXFLAGS=
673 TEMP_LDFLAGS=
471 while true 674 while true
472 do 675 do
473 if isnotplatform "macos"; then 676 while true
677 do
678 if [ -z "$lang_c" ] ; then
679 ERROR=1
680 break
681 fi
682
474 break 683 break
475 fi 684 done
476 while true
477 do
478
479 cat >> $TEMP_DIR/make.mk << __EOF__
480 OBJ_EXT = .o
481 LIB_EXT = .a
482 PACKAGE_SCRIPT = package_osx.sh
483
484 __EOF__
485
486 break
487 done
488
489 break 685 break
490 done 686 done
491 while true 687 while true
492 do 688 do
493 if isnotplatform "unix"; then 689 if notisplatform "macos"; then
494 break 690 break
495 fi 691 fi
496 if isplatform "macos"; then 692 while true
693 do
694
695 cat >> "$TEMP_DIR/make.mk" << __EOF__
696 OBJ_EXT = o
697 LIB_EXT = .a
698 PACKAGE_SCRIPT = package_osx.sh
699 __EOF__
497 break 700 break
498 fi 701 done
499 while true
500 do
501
502 cat >> $TEMP_DIR/make.mk << __EOF__
503 OBJ_EXT = .o
504 LIB_EXT = .a
505 PACKAGE_SCRIPT = package_unix.sh
506
507 __EOF__
508
509 break
510 done
511
512 break 702 break
513 done 703 done
514 while true 704 while true
515 do 705 do
516 if isnotplatform "bsd"; then 706 if notisplatform "unix"; then
517 break 707 break
518 fi 708 fi
519 while true 709 if isplatform "macos" || istoolchain "macos"; then
520 do
521
522 CFLAGS="$CFLAGS -I/usr/local/include"
523 LDFLAGS="$LDFLAGS -L/usr/local/lib"
524
525 break 710 break
526 done 711 fi
527 712 while true
713 do
714
715 cat >> "$TEMP_DIR/make.mk" << __EOF__
716 OBJ_EXT = o
717 LIB_EXT = .a
718 PACKAGE_SCRIPT = package_unix.sh
719 __EOF__
720 break
721 done
528 break 722 break
529 done 723 done
530 724 while true
531 # add general dependency flags to config.mk 725 do
532 echo >> $TEMP_DIR/config.mk 726 if notisplatform "bsd"; then
533 if [ ! -z "${CFLAGS}" ]; then 727 break
534 echo "CFLAGS += $CFLAGS" >> $TEMP_DIR/config.mk 728 fi
535 fi 729 while true
536 if [ ! -z "${CXXFLAGS}" ]; then 730 do
537 echo "CXXFLAGS += $CXXFLAGS" >> $TEMP_DIR/config.mk 731
538 fi 732 TEMP_CFLAGS="$TEMP_CFLAGS -I/usr/local/include"
539 if [ ! -z "${LDFLAGS}" ]; then 733 TEMP_LDFLAGS="$TEMP_LDFLAGS -L/usr/local/lib"
540 echo "LDFLAGS += $LDFLAGS" >> $TEMP_DIR/config.mk 734 break
735 done
736 break
737 done
738
739 # add general dependency flags to flags.mk
740 echo "# general flags" >> "$TEMP_DIR/flags.mk"
741 if [ -n "${TEMP_CFLAGS}" ] && [ -n "$lang_c" ]; then
742 echo "CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk"
743 fi
744 if [ -n "${TEMP_CXXFLAGS}" ] && [ -n "$lang_cpp" ]; then
745 echo "CXXFLAGS += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk"
746 fi
747 if [ -n "${TEMP_LDFLAGS}" ]; then
748 echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk"
541 fi 749 fi
542 750
543 # 751 #
544 # OPTION VALUES 752 # OPTION VALUES
545 # 753 #
546 checkopt_toolkit_gtk4() 754 checkopt_toolkit_gtk4()
547 { 755 {
548 VERR=0 756 VERR=0
549 dependency_gtk4 757 if dependency_error_gtk4 ; then
550 if [ $? -ne 0 ]; then 758 VERR=1
551 VERR=1 759 fi
552 fi 760 if [ $VERR -ne 0 ]; then
553 if [ $VERR -ne 0 ]; then 761 return 1
554 return 1 762 fi
555 fi 763 cat >> "$TEMP_DIR/make.mk" << __EOF__
556 cat >> $TEMP_DIR/make.mk << __EOF__
557 TOOLKIT = gtk 764 TOOLKIT = gtk
558 GTKOBJ = draw_cairo.o 765 GTKOBJ = draw_cairo.o
559 766 __EOF__
560 __EOF__ 767 return 0
561 return 0
562 } 768 }
563 checkopt_toolkit_gtk3() 769 checkopt_toolkit_gtk3()
564 { 770 {
565 VERR=0 771 VERR=0
566 dependency_gtk3 772 if dependency_error_gtk3 ; then
567 if [ $? -ne 0 ]; then 773 VERR=1
568 VERR=1 774 fi
569 fi 775 if [ $VERR -ne 0 ]; then
570 if [ $VERR -ne 0 ]; then 776 return 1
571 return 1 777 fi
572 fi 778 cat >> "$TEMP_DIR/make.mk" << __EOF__
573 cat >> $TEMP_DIR/make.mk << __EOF__
574 TOOLKIT = gtk 779 TOOLKIT = gtk
575 GTKOBJ = draw_cairo.o 780 GTKOBJ = draw_cairo.o
576 781 __EOF__
577 __EOF__ 782 return 0
578 return 0
579 } 783 }
580 checkopt_toolkit_gtk2() 784 checkopt_toolkit_gtk2()
581 { 785 {
582 VERR=0 786 VERR=0
583 dependency_gtk2 787 if dependency_error_gtk2 ; then
584 if [ $? -ne 0 ]; then 788 VERR=1
585 VERR=1 789 fi
586 fi 790 if [ $VERR -ne 0 ]; then
587 if [ $VERR -ne 0 ]; then 791 return 1
588 return 1 792 fi
589 fi 793 cat >> "$TEMP_DIR/make.mk" << __EOF__
590 cat >> $TEMP_DIR/make.mk << __EOF__
591 TOOLKIT = gtk 794 TOOLKIT = gtk
592 GTKOBJ = draw_cairo.o 795 GTKOBJ = draw_cairo.o
593 796 __EOF__
594 __EOF__ 797 return 0
595 return 0
596 } 798 }
597 checkopt_toolkit_gtk2legacy() 799 checkopt_toolkit_gtk2legacy()
598 { 800 {
599 VERR=0 801 VERR=0
600 dependency_gtk2legacy 802 if dependency_error_gtk2legacy ; then
601 if [ $? -ne 0 ]; then 803 VERR=1
602 VERR=1 804 fi
603 fi 805 if [ $VERR -ne 0 ]; then
604 if [ $VERR -ne 0 ]; then 806 return 1
605 return 1 807 fi
606 fi 808 cat >> "$TEMP_DIR/make.mk" << __EOF__
607 cat >> $TEMP_DIR/make.mk << __EOF__
608 TOOLKIT = gtk 809 TOOLKIT = gtk
609 GTKOBJ = draw_gdk.o 810 GTKOBJ = draw_gdk.o
610 811 __EOF__
611 __EOF__ 812 return 0
612 return 0
613 } 813 }
614 checkopt_toolkit_qt5() 814 checkopt_toolkit_qt5()
615 { 815 {
616 VERR=0 816 VERR=0
617 dependency_qt5 817 if dependency_error_qt5 ; then
618 if [ $? -ne 0 ]; then 818 VERR=1
619 VERR=1 819 fi
620 fi 820 if [ $VERR -ne 0 ]; then
621 if [ $VERR -ne 0 ]; then 821 return 1
622 return 1 822 fi
623 fi 823 cat >> "$TEMP_DIR/make.mk" << __EOF__
624 cat >> $TEMP_DIR/make.mk << __EOF__
625 TOOLKIT = qt 824 TOOLKIT = qt
626 LD = $(CXX) 825 LD = $(CXX)
627 826 __EOF__
628 __EOF__ 827 return 0
629 return 0
630 } 828 }
631 checkopt_toolkit_qt4() 829 checkopt_toolkit_qt4()
632 { 830 {
633 VERR=0 831 VERR=0
634 dependency_qt4 832 if dependency_error_qt4 ; then
635 if [ $? -ne 0 ]; then 833 VERR=1
636 VERR=1 834 fi
637 fi 835 if [ $VERR -ne 0 ]; then
638 if [ $VERR -ne 0 ]; then 836 return 1
639 return 1 837 fi
640 fi 838 cat >> "$TEMP_DIR/make.mk" << __EOF__
641 cat >> $TEMP_DIR/make.mk << __EOF__
642 TOOLKIT = qt 839 TOOLKIT = qt
643 LD = $(CXX) 840 LD = $(CXX)
644 841 __EOF__
645 __EOF__ 842 return 0
646 return 0
647 } 843 }
648 checkopt_toolkit_motif() 844 checkopt_toolkit_motif()
649 { 845 {
650 VERR=0 846 VERR=0
651 dependency_motif 847 if dependency_error_motif ; then
652 if [ $? -ne 0 ]; then 848 VERR=1
653 VERR=1 849 fi
654 fi 850 if [ $VERR -ne 0 ]; then
655 if [ $VERR -ne 0 ]; then 851 return 1
656 return 1 852 fi
657 fi 853 cat >> "$TEMP_DIR/make.mk" << __EOF__
658 cat >> $TEMP_DIR/make.mk << __EOF__
659 TOOLKIT = motif 854 TOOLKIT = motif
660 855 __EOF__
661 __EOF__ 856 return 0
662 return 0
663 } 857 }
664 858
665 # 859 #
666 # TARGETS 860 # TARGETS
667 # 861 #
668 CFLAGS= 862
669 CXXFLAGS= 863 echo >> "$TEMP_DIR/flags.mk"
670 LDFLAGS= 864 echo "configuring target: dav"
671 865 echo "# flags for target dav" >> "$TEMP_DIR/flags.mk"
672 # Target: tk 866 TEMP_CFLAGS=
673 CFLAGS= 867 TEMP_CXXFLAGS=
674 LDFLAGS= 868 TEMP_LDFLAGS=
675 CXXFLAGS= 869
676 870 if dependency_error_curl; then
871 DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED curl "
872 ERROR=1
873 fi
874 if dependency_error_libxml2; then
875 DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED libxml2 "
876 ERROR=1
877 fi
878 if dependency_error_openssl; then
879 DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED openssl "
880 ERROR=1
881 fi
677 882
678 # Features 883 # Features
679 884
885
886 if [ -n "${TEMP_CFLAGS}" ] && [ -n "$lang_c" ]; then
887 echo "DAV_CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk"
888 fi
889 if [ -n "${TEMP_CXXFLAGS}" ] && [ -n "$lang_cpp" ]; then
890 echo "DAV_CXXFLAGS += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk"
891 fi
892 if [ "$BUILD_TYPE" = "debug" ]; then
893 if [ -n "$lang_c" ]; then
894 echo 'DAV_CFLAGS += ${DEBUG_CC_FLAGS}' >> "$TEMP_DIR/flags.mk"
895 fi
896 if [ -n "$lang_cpp" ]; then
897 echo 'DAV_CXXFLAGS += ${DEBUG_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk"
898 fi
899 fi
900 if [ "$BUILD_TYPE" = "release" ]; then
901 if [ -n "$lang_c" ]; then
902 echo 'DAV_CFLAGS += ${RELEASE_CC_FLAGS}' >> "$TEMP_DIR/flags.mk"
903 fi
904 if [ -n "$lang_cpp" ]; then
905 echo 'DAV_CXXFLAGS += ${RELEASE_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk"
906 fi
907 fi
908 if [ -n "${TEMP_LDFLAGS}" ]; then
909 echo "DAV_LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk"
910 fi
911
912 echo >> "$TEMP_DIR/flags.mk"
913 echo "configuring target: tk"
914 echo "# flags for target tk" >> "$TEMP_DIR/flags.mk"
915 TEMP_CFLAGS=
916 TEMP_CXXFLAGS=
917 TEMP_LDFLAGS=
918
919
920 # Features
921
680 # Option: --toolkit 922 # Option: --toolkit
681 if [ -z $OPT_TOOLKIT ]; then 923 if [ -z "$OPT_TOOLKIT" ]; then
682 SAVED_ERROR=$ERROR 924 echo "auto-detecting option 'toolkit'"
683 SAVED_DEPENDENCIES_FAILED=$DEPENDENCIES_FAILED 925 SAVED_ERROR="$ERROR"
684 ERROR=0 926 SAVED_DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED"
685 while true 927 ERROR=1
686 do 928 while true
687 if isplatform "windows"; then 929 do
688 checkopt_toolkit_winui 930 if isplatform "windows"; then
689 if [ $? -eq 0 ]; then 931 if checkopt_toolkit_winui ; then
690 echo " toolkit: winui" >> $TEMP_DIR/options 932 echo " toolkit: winui" >> "$TEMP_DIR/options"
691 ERROR=0 933 ERROR=0
692 break 934 break
693 fi 935 fi
694 fi 936 fi
695 if isplatform "macos"; then 937 if isplatform "macos"; then
696 checkopt_toolkit_cocoa 938 if checkopt_toolkit_cocoa ; then
697 if [ $? -eq 0 ]; then 939 echo " toolkit: cocoa" >> "$TEMP_DIR/options"
698 echo " toolkit: cocoa" >> $TEMP_DIR/options 940 ERROR=0
699 ERROR=0 941 break
700 break 942 fi
701 fi 943 fi
702 fi 944 if checkopt_toolkit_gtk3 ; then
703 checkopt_toolkit_gtk3 945 echo " toolkit: gtk3" >> "$TEMP_DIR/options"
704 if [ $? -eq 0 ]; then 946 ERROR=0
705 echo " toolkit: gtk3" >> $TEMP_DIR/options 947 break
706 ERROR=0 948 fi
707 break 949 if checkopt_toolkit_qt5 ; then
708 fi 950 echo " toolkit: qt5" >> "$TEMP_DIR/options"
709 checkopt_toolkit_qt5 951 ERROR=0
710 if [ $? -eq 0 ]; then 952 break
711 echo " toolkit: qt5" >> $TEMP_DIR/options 953 fi
712 ERROR=0 954 if checkopt_toolkit_gtk2 ; then
713 break 955 echo " toolkit: gtk2" >> "$TEMP_DIR/options"
714 fi 956 ERROR=0
715 checkopt_toolkit_gtk2 957 break
716 if [ $? -eq 0 ]; then 958 fi
717 echo " toolkit: gtk2" >> $TEMP_DIR/options 959 if checkopt_toolkit_qt4 ; then
718 ERROR=0 960 echo " toolkit: qt4" >> "$TEMP_DIR/options"
719 break 961 ERROR=0
720 fi 962 break
721 checkopt_toolkit_qt4 963 fi
722 if [ $? -eq 0 ]; then 964 if checkopt_toolkit_motif ; then
723 echo " toolkit: qt4" >> $TEMP_DIR/options 965 echo " toolkit: motif" >> "$TEMP_DIR/options"
724 ERROR=0 966 ERROR=0
725 break 967 break
726 fi 968 fi
727 checkopt_toolkit_motif 969 break
728 if [ $? -eq 0 ]; then 970 done
729 echo " toolkit: motif" >> $TEMP_DIR/options 971 if [ $ERROR -ne 0 ]; then
730 ERROR=0 972 SAVED_ERROR=1
731 break 973 SAVED_DEPENDENCIES_FAILED="option 'toolkit' $SAVED_DEPENDENCIES_FAILED"
732 fi 974 fi
733 break 975 ERROR="$SAVED_ERROR"
734 done 976 DEPENDENCIES_FAILED="$SAVED_DEPENDENCIES_FAILED"
735 if [ $ERROR -ne 0 ]; then
736 SAVED_ERROR=1
737 fi
738 ERROR=$SAVED_ERROR
739 DEPENDENCIES_FAILED=$SAVED_DEPENDENCIES_FAILED=
740 else 977 else
741 if false; then 978 echo "checking option toolkit = $OPT_TOOLKIT"
742 false 979 if false; then
743 elif [ $OPT_TOOLKIT = "gtk4" ]; then 980 false
744 echo " toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options 981 elif [ "$OPT_TOOLKIT" = "gtk4" ]; then
745 checkopt_toolkit_gtk4 982 echo " toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options
746 if [ $? -ne 0 ]; then 983 if checkopt_toolkit_gtk4 ; then
747 ERROR=1 984 :
748 fi 985 else
749 elif [ $OPT_TOOLKIT = "gtk3" ]; then 986 ERROR=1
750 echo " toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options 987 DEPENDENCIES_FAILED="option 'toolkit' $DEPENDENCIES_FAILED"
751 checkopt_toolkit_gtk3 988 fi
752 if [ $? -ne 0 ]; then 989 elif [ "$OPT_TOOLKIT" = "gtk3" ]; then
753 ERROR=1 990 echo " toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options
754 fi 991 if checkopt_toolkit_gtk3 ; then
755 elif [ $OPT_TOOLKIT = "gtk2" ]; then 992 :
756 echo " toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options 993 else
757 checkopt_toolkit_gtk2 994 ERROR=1
758 if [ $? -ne 0 ]; then 995 DEPENDENCIES_FAILED="option 'toolkit' $DEPENDENCIES_FAILED"
759 ERROR=1 996 fi
760 fi 997 elif [ "$OPT_TOOLKIT" = "gtk2" ]; then
761 elif [ $OPT_TOOLKIT = "gtk2legacy" ]; then 998 echo " toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options
762 echo " toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options 999 if checkopt_toolkit_gtk2 ; then
763 checkopt_toolkit_gtk2legacy 1000 :
764 if [ $? -ne 0 ]; then 1001 else
765 ERROR=1 1002 ERROR=1
766 fi 1003 DEPENDENCIES_FAILED="option 'toolkit' $DEPENDENCIES_FAILED"
767 elif [ $OPT_TOOLKIT = "qt5" ]; then 1004 fi
768 echo " toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options 1005 elif [ "$OPT_TOOLKIT" = "gtk2legacy" ]; then
769 checkopt_toolkit_qt5 1006 echo " toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options
770 if [ $? -ne 0 ]; then 1007 if checkopt_toolkit_gtk2legacy ; then
771 ERROR=1 1008 :
772 fi 1009 else
773 elif [ $OPT_TOOLKIT = "qt4" ]; then 1010 ERROR=1
774 echo " toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options 1011 DEPENDENCIES_FAILED="option 'toolkit' $DEPENDENCIES_FAILED"
775 checkopt_toolkit_qt4 1012 fi
776 if [ $? -ne 0 ]; then 1013 elif [ "$OPT_TOOLKIT" = "qt5" ]; then
777 ERROR=1 1014 echo " toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options
778 fi 1015 if checkopt_toolkit_qt5 ; then
779 elif [ $OPT_TOOLKIT = "motif" ]; then 1016 :
780 echo " toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options 1017 else
781 checkopt_toolkit_motif 1018 ERROR=1
782 if [ $? -ne 0 ]; then 1019 DEPENDENCIES_FAILED="option 'toolkit' $DEPENDENCIES_FAILED"
783 ERROR=1 1020 fi
784 fi 1021 elif [ "$OPT_TOOLKIT" = "qt4" ]; then
785 fi 1022 echo " toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options
786 fi 1023 if checkopt_toolkit_qt4 ; then
787 1024 :
788 echo >> $TEMP_DIR/config.mk 1025 else
789 if [ ! -z "${CFLAGS}" ]; then 1026 ERROR=1
790 echo "TK_CFLAGS += $CFLAGS" >> $TEMP_DIR/config.mk 1027 DEPENDENCIES_FAILED="option 'toolkit' $DEPENDENCIES_FAILED"
791 fi 1028 fi
792 if [ ! -z "${CXXFLAGS}" ]; then 1029 elif [ "$OPT_TOOLKIT" = "motif" ]; then
793 echo "TK_CXXFLAGS += $CXXFLAGS" >> $TEMP_DIR/config.mk 1030 echo " toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options
794 fi 1031 if checkopt_toolkit_motif ; then
795 if [ ! -z "${LDFLAGS}" ]; then 1032 :
796 echo "TK_LDFLAGS += $LDFLAGS" >> $TEMP_DIR/config.mk 1033 else
797 fi 1034 ERROR=1
798 1035 DEPENDENCIES_FAILED="option 'toolkit' $DEPENDENCIES_FAILED"
1036 fi
1037 fi
1038 fi
1039
1040 if [ -n "${TEMP_CFLAGS}" ] && [ -n "$lang_c" ]; then
1041 echo "TK_CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk"
1042 fi
1043 if [ -n "${TEMP_CXXFLAGS}" ] && [ -n "$lang_cpp" ]; then
1044 echo "TK_CXXFLAGS += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk"
1045 fi
1046 if [ "$BUILD_TYPE" = "debug" ]; then
1047 if [ -n "$lang_c" ]; then
1048 echo 'TK_CFLAGS += ${DEBUG_CC_FLAGS}' >> "$TEMP_DIR/flags.mk"
1049 fi
1050 if [ -n "$lang_cpp" ]; then
1051 echo 'TK_CXXFLAGS += ${DEBUG_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk"
1052 fi
1053 fi
1054 if [ "$BUILD_TYPE" = "release" ]; then
1055 if [ -n "$lang_c" ]; then
1056 echo 'TK_CFLAGS += ${RELEASE_CC_FLAGS}' >> "$TEMP_DIR/flags.mk"
1057 fi
1058 if [ -n "$lang_cpp" ]; then
1059 echo 'TK_CXXFLAGS += ${RELEASE_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk"
1060 fi
1061 fi
1062 if [ -n "${TEMP_LDFLAGS}" ]; then
1063 echo "TK_LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk"
1064 fi
1065
1066
1067 # final result
799 if [ $ERROR -ne 0 ]; then 1068 if [ $ERROR -ne 0 ]; then
800 echo 1069 echo
801 echo "Error: Unresolved dependencies" 1070 echo "Error: Unresolved dependencies"
802 echo $DEPENDENCIES_FAILED 1071 echo "$DEPENDENCIES_FAILED"
803 rm -Rf $TEMP_DIR 1072 abort_configure
804 exit 1
805 fi 1073 fi
806 1074
807 echo "configure finished" 1075 echo "configure finished"
808 echo 1076 echo
809 echo "Build Config:" 1077 echo "Build Config:"
810 echo " PREFIX: $PREFIX" 1078 echo " PREFIX: $prefix"
811 echo " TOOLCHAIN: $TOOLCHAIN_NAME" 1079 echo " TOOLCHAIN: $TOOLCHAIN_NAME"
812 echo "Options:" 1080 echo "Options:"
813 cat $TEMP_DIR/options 1081 cat "$TEMP_DIR/options"
814 echo 1082 echo
815 cat $TEMP_DIR/config.mk $TEMP_DIR/make.mk > config.mk 1083
816 rm -Rf $TEMP_DIR 1084 # generate the config.mk file
817 1085 cat > "$TEMP_DIR/config.mk" << __EOF__
818 1086 #
1087 # config.mk generated by configure
1088 #
1089
1090 __EOF__
1091 write_toolchain_defaults "$TEMP_DIR/toolchain.mk"
1092 cat "$TEMP_DIR/vars.mk" "$TEMP_DIR/toolchain.mk" "$TEMP_DIR/flags.mk" "$TEMP_DIR/make.mk" > config.mk
1093 rm -Rf "$TEMP_DIR"

mercurial