source: roaraudio/build-system/configure.lib @ 5810:d44ff4605fa5

Last change on this file since 5810:d44ff4605fa5 was 5810:d44ff4605fa5, checked in by phi, 9 years ago

added a lot paths to our path config (roar_libroar_get_path())

File size: 14.2 KB
Line 
1#!/bin/false
2# vim:ft=sh
3
4#     Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2012
5#
6# This file is part of roard a part of RoarAudio,
7# a cross-platform sound system for both, home and professional use.
8# See README for details.
9#
10# This file is free software; you can redistribute it and/or modify
11# it under the terms of the GNU General Public License version 3
12# as published by the Free Software Foundation.
13#
14# RoarAudio is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this software; see the file COPYING.  If not, write to
21# the Free Software Foundation, 51 Franklin Street, Fifth Floor,
22# Boston, MA 02110-1301, USA.
23
24# some very basic string functions:
25to_upper() {
26 tr 'a-z' 'A-Z'
27}
28
29to_escaped() {
30 tr 'A-Z/.+-' 'a-z____'
31}
32
33error_missing() {
34 _object="$1"
35 [ "$_object" = '' ] && _object="$last_tested_object"
36 echo "Error: $_object is missing but required."
37 exit 1
38}
39
40write_help() {
41 echo 'COMMON OPTIONS:'
42 echo
43 echo '--ldpath DIR                - Add DIR to (compile time) search list for libs'
44 echo '--incpath DIR               - Add DIR to search list for headers'
45 echo '--addpath DIR               - Add DIR/lib to lib, DIR/include to header search list'
46 echo '--root DIR                  - The same as "--addpath DIR --prefix DIR"'
47 echo
48 echo '--cflags FLAGS              - Sets additional compiler flags (default: '"$CFLAGS"')'
49 echo '--ldflags FLAGS             - Sets additional linker flags (default: '"$LDFLAGS"')'
50 echo '--opti LEVEL                - Sets optimizer level (default: '"$OPTI_O"')'
51 echo '--link-deps MODE            - Model for linking dependencies: auto, full or indirect'
52 echo
53 echo '--cc CC                     - Set name of C compiler (CC) to CC'
54 echo '--ranlib RANLIB             - Set name of ranlib (RANLIB) to RANLIB'
55 echo
56 echo '--root-uid UID              - Sets User ID (UID) of the root user/superuser'
57 echo
58 echo '--no-LIB                    - disable library LIB'
59 echo '--maybe-LIB                 - autodetect library LIB (default)'
60 echo
61 echo '--prefix DIR                - Set general prefix (default: '"$PREFIX"')'
62 echo '--prefix-bin DIR            - Set prefix for binaries (default: $PREFIX/bin)'
63 echo '--prefix-sbin DIR           - Set prefix for system binaries (default: $PREFIX/sbin)'
64 echo '--prefix-lib DIR            - Set prefix for libraries (default: $PREFIX/libs)'
65 echo '--prefix-inc DIR            - Set prefix for include files (default: $PREFIX/include)'
66 echo '--prefix-man DIR            - Set prefix for manpages (default: $PREFIX/share/man)'
67 echo '--prefix-pc DIR             - Set prefix for pkg-config (default: $PREFIX_LIB/pkgconfig)'
68 echo '--prefix-sysconf DIR        - Set prefix for system configuration (default: $PREFIX/etc)'
69 echo '--prefix-dev DIR            - Set prefix for devices (default: $PREFIX/dev)'
70 echo '--prefix-doc DIR            - Set prefix for documentation (default: $PREFIX/share/doc)'
71 echo '--prefix-tmp DIR            - Set prefix for temporary files (default: $PREFIX/tmp)'
72 echo '--prefix-var DIR            - Set prefix for variable files (default: $PREFIX/var)'
73 echo '--prefix-cache DIR          - Set prefix for application caches (default: $PREFIX_VAR/cache)'
74 echo '--prefix-data DIR           - Set prefix for variable application data (default: $PREFIX_VAR/lib)'
75 echo '--prefix-lock DIR           - Set prefix for lock files (locked resources) (default: $PREFIX_VAR/lock)'
76 echo '--prefix-log DIR            - Set prefix for log files (default: $PREFIX_VAR/log)'
77 echo '--prefix-mail DIR           - Set prefix for user'\''s mailboxes (default: $PREFIX_VAR/mail)'
78 echo '--prefix-run DIR            - Set prefix for information about the running system (default: $PREFIX_VAR/run)'
79 echo '--prefix-spool DIR          - Set prefix for spools (queued jobs) (default: $PREFIX_VAR/spool)'
80 echo
81 echo '--without-beta              - Disable beta code'
82 echo '--without-experimental      - Disable experimental code'
83 echo
84 echo '--distribution-version-string STRING'
85 echo '                            - Sets distribution part of version string'
86 echo
87 echo '--mmcu MMCU                 - Sets -mmcu compiler/linker option'
88 echo '--target-win32              - Disable everything useful'
89 echo '--exec-helper HELPER        - Exec all test programms using this command (HELPER $cmd $args)'
90 echo '                              use '\''--exec-helper wine'\'' when building win32 binaries'
91 echo
92}
93
94parse_option() {
95 # Options are given via $n.
96 # we can not shift used ones so we tell the caller
97 # how many to shift: shift $SHIFT_COUNT
98 SHIFT_COUNT=0
99 # we also tell if the option was handelt.
100 HANDLED=true # will be reset if not.
101
102 case "$1" in
103  '--ldpath')
104   LDPATH="$LDPATH -L$2"
105   SHIFT_COUNT=1
106  ;;
107  '--incpath')
108   INCPATH="$INCPATH -I$2"
109   SHIFT_COUNT=1
110  ;;
111  '--addpath')
112   LDPATH="$LDPATH -L$2/lib/"
113   INCPATH="$INCPATH -I$2/include/"
114   SHIFT_COUNT=1
115  ;;
116  '--root')
117   LDPATH="$LDPATH -L$2/lib/"
118   INCPATH="$INCPATH -I$2/include/"
119   PREFIX="$2"
120   SHIFT_COUNT=1
121  ;;
122  '--cflags')
123   CFLAGS="$2"
124   SHIFT_COUNT=1
125  ;;
126  '--ldflags')
127   LDFLAGS="$2"
128   SHIFT_COUNT=1
129  ;;
130  '--opti')
131   OPTI_O="$2"
132   SHIFT_COUNT=1
133  ;;
134  '--link-deps')
135   LINK_DEPS="$2"
136   SHIFT_COUNT=1
137  ;;
138  '--cc')
139   CC="$2"
140   SHIFT_COUNT=1
141  ;;
142  '--ranlib')
143   RANLIB="$2"
144   SHIFT_COUNT=1
145  ;;
146  '--root-uid')
147   ROOT_UID="$2"
148   SHIFT_COUNT=1
149  ;;
150  '--no-'*)
151   lib=$(echo "$1" | sed 's/^--no-//' | to_escaped)
152   eval no_lib_$lib=true
153  ;;
154  '--maybe-'*)
155   lib=$(echo "$1" | sed 's/^--maybe-//' | to_escaped)
156   eval unset no_lib_$lib
157  ;;
158  '--distribution-version-string')
159   DISTRIBUTION_VERSION_STRING="$2"
160   SHIFT_COUNT=1
161  ;;
162  '--without-beta')
163   BETA=false
164   EXPERIMENTAL=false
165  ;;
166  '--without-experimental')
167   EXPERIMENTAL=false
168  ;;
169  '--prefix')
170   PREFIX="$2"
171   SHIFT_COUNT=1
172  ;;
173  '--prefix-bin')
174   PREFIX_BIN="$2"
175   SHIFT_COUNT=1
176  ;;
177  '--prefix-sbin')
178   PREFIX_SBIN="$2"
179   SHIFT_COUNT=1
180  ;;
181  '--prefix-lib')
182   PREFIX_LIB="$2"
183   SHIFT_COUNT=1
184  ;;
185  '--prefix-inc')
186   PREFIX_INC="$2"
187   SHIFT_COUNT=1
188  ;;
189  '--prefix-man')
190   PREFIX_MAN="$2"
191   SHIFT_COUNT=1
192  ;;
193  '--prefix-pc')
194   PREFIX_PC="$2"
195   SHIFT_COUNT=1
196  ;;
197  '--prefix-ckport')
198   PREFIX_CKPORT="$2"
199   SHIFT_COUNT=1
200  ;;
201  '--prefix-sysconf')
202   PREFIX_SYSCONF="$2"
203   SHIFT_COUNT=1
204  ;;
205  '--prefix-dev')
206   PREFIX_DEV="$2"
207   SHIFT_COUNT=1
208  ;;
209  '--prefix-doc')
210   PREFIX_DOC="$2"
211   SHIFT_COUNT=1
212  ;;
213  '--prefix-tmp')
214   PREFIX_TMP="$2"
215   SHIFT_COUNT=1
216  ;;
217  '--prefix-var')
218   PREFIX_VAR="$2"
219   SHIFT_COUNT=1
220  ;;
221  '--prefix-cache')
222   PREFIX_CACHE="$2"
223   SHIFT_COUNT=1
224  ;;
225  '--prefix-data')
226   PREFIX_DATA="$2"
227   SHIFT_COUNT=1
228  ;;
229  '--prefix-lock')
230   PREFIX_LOCK="$2"
231   SHIFT_COUNT=1
232  ;;
233  '--prefix-log')
234   PREFIX_LOG="$2"
235   SHIFT_COUNT=1
236  ;;
237  '--prefix-mail')
238   PREFIX_MAIL="$2"
239   SHIFT_COUNT=1
240  ;;
241  '--prefix-run')
242   PREFIX_RUN="$2"
243   SHIFT_COUNT=1
244  ;;
245  '--prefix-spool')
246   PREFIX_SPOOL="$2"
247   SHIFT_COUNT=1
248  ;;
249####################################
250# autof* options block:
251  '--prefix='*)
252   PREFIX=$(echo "$1" | cut -d= -f2)
253  ;;
254  '--prefix-bin='*)
255   PREFIX_BIN=$(echo "$1" | cut -d= -f2)
256  ;;
257  '--prefix-sbin='*)
258   PREFIX_SBIN=$(echo "$1" | cut -d= -f2)
259  ;;
260  '--prefix-lib='*)
261   PREFIX_LIB=$(echo "$1" | cut -d= -f2)
262  ;;
263  '--prefix-inc='*)
264   PREFIX_INC=$(echo "$1" | cut -d= -f2)
265  ;;
266  '--prefix-man='*)
267   PREFIX_MAN=$(echo "$1" | cut -d= -f2)
268  ;;
269  '--prefix-pc='*)
270   PREFIX_PC=$(echo "$1" | cut -d= -f2)
271  ;;
272  '--prefix-ckport='*)
273   PREFIX_CKPORT=$(echo "$1" | cut -d= -f2)
274  ;;
275  '--prefix-sysconf='*)
276   PREFIX_SYSCONF=$(echo "$1" | cut -d= -f2)
277  ;;
278  '--prefix-dev='*)
279   PREFIX_DEV=$(echo "$1" | cut -d= -f2)
280  ;;
281  '--prefix-doc='*)
282   PREFIX_DOC=$(echo "$1" | cut -d= -f2)
283  ;;
284  '--prefix-tmp='*)
285   PREFIX_TMP=$(echo "$1" | cut -d= -f2)
286  ;;
287  '--prefix-var='*)
288   PREFIX_VAR=$(echo "$1" | cut -d= -f2)
289  ;;
290  '--prefix-cache='*)
291   PREFIX_CACHE=$(echo "$1" | cut -d= -f2)
292  ;;
293  '--prefix-data='*)
294   PREFIX_DATA=$(echo "$1" | cut -d= -f2)
295  ;;
296  '--prefix-lock='*)
297   PREFIX_LOCK=$(echo "$1" | cut -d= -f2)
298  ;;
299  '--prefix-log='*)
300   PREFIX_LOG=$(echo "$1" | cut -d= -f2)
301  ;;
302  '--prefix-mail='*)
303   PREFIX_MAIL=$(echo "$1" | cut -d= -f2)
304  ;;
305  '--prefix-run='*)
306   PREFIX_RUN=$(echo "$1" | cut -d= -f2)
307  ;;
308  '--prefix-spool='*)
309   PREFIX_SPOOL=$(echo "$1" | cut -d= -f2)
310  ;;
311####################################
312  '--mmcu')
313   MMCU="$2"
314   SHIFT_COUNT=1
315  ;;
316  '--exec-helper')
317   EXEC_HELPER="$2"
318   SHIFT_COUNT=1
319  ;;
320  '--target-win32')
321   TARGET_WIN32=true
322  ;;
323  *)
324   HANDLED=false
325  ;;
326 esac;
327
328 if $HANDLED
329 then
330  SHIFT_COUNT=`expr $SHIFT_COUNT + 1`
331 fi
332}
333
334open_configure_files() {
335 exec 3> config.h 4> Makefile.conf 5> config.log
336}
337
338update_target() {
339 TARGET_CYGWIN=`echo "$SYSNAME" | if grep CYGWIN  > /dev/null; then echo true; else echo false; fi`
340 TARGET_WIN32=`echo  "$SYSNAME" | if grep MINGW32 > /dev/null; then echo true; else echo $TARGET_WIN32; fi`
341
342 if [ "$SYSNAME" = 'Darwin' ]
343 then
344  echo "Adding common $SYSNAME shared lib arguments..."
345  SHARED="$SHARED -fno-common -dynamiclib -compatibility_version 0.1 -current_version 0.1.0"
346  SHARED_CF="$SHARED_CF -fno-common"
347 elif [ "$SYSNAME" = 'NetBSD' ]
348 then
349  echo "Adding common $SYSNAME libpath arguments..."
350  LDPATH="$LDPATH -L/usr/local/lib/"
351 elif [ "$SYSNAME" = 'OpenBSD' ]
352 then
353  echo "Adding common $SYSNAME search path arguments..."
354  LDPATH="$LDPATH -L/usr/local/lib/"
355  INCPATH="$INCPATH -I/usr/local/include/"
356 # echo "Adding $SYSNAME build arguments..."
357 # SNDIO_EMUL=false
358 elif [ "$SYSNAME" = 'FreeBSD' ]
359 then
360  echo "Adding common $SYSNAME search path arguments..."
361  LDPATH="$LDPATH -L/usr/local/lib/"
362  INCPATH="$INCPATH -I/usr/local/include/"
363 elif $TARGET_WIN32
364 then
365  echo "Adding common win32 build arguments..."
366  rdynamic=false
367  fPIC=false
368  SHARED_SUFFIX='.dll'
369  TF_E="$TF_E.exe"
370 elif $TARGET_CYGWIN
371 then
372  echo "Adding common cygwin build arguments..."
373  rdynamic=false
374  fPIC=false
375  SHARED_SUFFIX='.dll'
376  TF_E="$TF_E.exe"
377 fi
378}
379
380update_prefixes() {
381 [ "$PREFIX_BIN"    = '' ] && PREFIX_BIN="$PREFIX/bin/"
382 [ "$PREFIX_SBIN"   = '' ] && PREFIX_SBIN="$PREFIX/sbin/"
383 [ "$PREFIX_LIB"    = '' ] && PREFIX_LIB="$PREFIX/lib/"
384 [ "$PREFIX_INC"    = '' ] && PREFIX_INC="$PREFIX/include/"
385 [ "$PREFIX_MAN"    = '' ] && PREFIX_MAN="$PREFIX/share/man/"
386 [ "$PREFIX_PC"     = '' ] && PREFIX_PC="$PREFIX_LIB/pkgconfig/"
387 [ "$PREFIX_CKPORT" = '' ] && PREFIX_CKPORT="$PREFIX_LIB/ckport/db/"
388 [ "$PREFIX_SYSCONF" = '' ] && PREFIX_SYSCONF="$PREFIX/etc/"
389 [ "$PREFIX_DEV"    = '' ] && PREFIX_DEV="$PREFIX/dev/"
390 [ "$PREFIX_DOC"    = '' ] && PREFIX_DOC="$PREFIX/share/doc/"
391 [ "$PREFIX_TMP"    = '' ] && PREFIX_TMP="$PREFIX/tmp/"
392 [ "$PREFIX_VAR"    = '' ] && PREFIX_VAR="$PREFIX/var/"
393 [ "$PREFIX_CACHE"  = '' ] && PREFIX_CACHE="$PREFIX_VAR/cache/"
394 [ "$PREFIX_DATA"   = '' ] && PREFIX_DATA="$PREFIX_VAR/lib/"
395 [ "$PREFIX_LOCK"   = '' ] && PREFIX_LOCK="$PREFIX_VAR/lock/"
396 [ "$PREFIX_LOG"    = '' ] && PREFIX_LOG="$PREFIX_VAR/log/"
397 [ "$PREFIX_MAIL"   = '' ] && PREFIX_MAIL="$PREFIX_VAR/mail/"
398 [ "$PREFIX_RUN"    = '' ] && PREFIX_RUN="$PREFIX_VAR/run/"
399 [ "$PREFIX_SPOOL"  = '' ] && PREFIX_SPOOL="$PREFIX_VAR/spool/"
400}
401
402update_ccft() {
403 CCTF="$CC $CFLAGS $LDFLAGS $LDPATH $INCPATH -Iinclude/ -o $TF_E $TF_C"
404}
405
406cleanup_ccft() {
407 rm -f $TF_C $TF_E
408 if [ "$TARGET_CYGWIN" = 'true' -o "$TARGET_WIN32" = 'true' ]
409 then
410  echo "Deleting win32 specific temp files: $TF_E.exe"
411  rm -f $TF_E.exe
412 fi
413}
414
415update_cc() {
416 if [ "$MMCU" != '' ]
417 then
418  CC="$CC -mmcu=$MMCU"
419 fi
420}
421
422write_header_makefileconf() {
423 {
424  echo "VERSION=$VERSION"
425  echo "DISTRIBUTION_VERSION_STRING=$DISTRIBUTION_VERSION_STRING"
426  echo
427  echo "SHARED=$SHARED"
428  echo "SHARED_CF=$SHARED_CF"
429  echo "SHARED_SUFFIX=$SHARED_SUFFIX"
430  $rdynamic && echo 'rdynamic=-rdynamic'
431  $fPIC     && echo 'fPIC=-fPIC'
432  $Wextra   && echo 'Wextra=-Wextra'
433  echo
434  echo "CC=$CC"
435  echo "RANLIB=$RANLIB"
436  echo "LDPATH=$LDPATH"
437  echo "INCPATH=$INCPATH"
438  echo "ROAR_BUILDSYSTEM_DIR=$ROAR_BUILDSYSTEM_DIR"
439  echo
440  echo "OPTI_O=-O$OPTI_O"
441  echo
442  [ "$CFLAGS"  != '' ] && echo "CFLAGS  += $CFLAGS"
443  [ "$LDFLAGS" != '' ] && echo "LDFLAGS += $LDFLAGS"
444  echo
445  echo "EXEC_HELPER=$EXEC_HELPER"
446  echo "CROSS_COMPILE=$CROSS_COMPILE"
447  echo
448  echo "PREFIX=$PREFIX"
449  echo "PREFIX_BIN=$PREFIX_BIN"
450  echo "PREFIX_SBIN=$PREFIX_SBIN"
451  echo "PREFIX_LIB=$PREFIX_LIB"
452  echo "PREFIX_INC=$PREFIX_INC"
453  echo "PREFIX_MAN=$PREFIX_MAN"
454  echo "PREFIX_PC=$PREFIX_PC"
455  echo "PREFIX_CKPORT=$PREFIX_CKPORT"
456  echo "PREFIX_SYSCONF=$PREFIX_SYSCONF"
457  echo "PREFIX_DEV=$PREFIX_DEV"
458  echo "PREFIX_DOC=$PREFIX_DOC"
459  echo "PREFIX_TMP=$PREFIX_TMP"
460  echo "PREFIX_VAR=$PREFIX_VAR"
461  echo "PREFIX_CACHE=$PREFIX_CACHE"
462  echo "PREFIX_DATA=$PREFIX_DATA"
463  echo "PREFIX_LOCK=$PREFIX_LOCK"
464  echo "PREFIX_LOG=$PREFIX_LOG"
465  echo "PREFIX_MAIL=$PREFIX_MAIL"
466  echo "PREFIX_RUN=$PREFIX_RUN"
467  echo "PREFIX_SPOOL=$PREFIX_SPOOL"
468  echo
469 } >&4
470}
471
472write_footer_makefileconf() {
473 {
474  echo
475  echo '#ll'
476 } >&4
477}
478
479write_header_configlog() {
480 {
481  cat <<'EOF'
482//config.log:
483
484/*
485 * Logfile for configure script $Revision$ of RoarAudio
486 */
487
488EOF
489  echo '/* uname: ' $(uname -a) '*/'
490  echo '/* Date : ' $(date)  '*/'
491  echo
492
493  echo
494  echo
495
496  echo "ARGS(): $_CARGS"
497
498  for i in PATH SHELL CC RANLIB PKG_CONFIG SYSNAME \
499           TARGET_CYGWIN TARGET_WIN32 TARGET_MICROCONTROLLER CROSS_COMPILE \
500           MINIMAL EXEC_HELPER \
501           "$@"
502  do
503   eval echo "BASICCONF\($i\): \$$i";
504  done
505
506  echo
507  echo
508 } >&5
509}
510
511write_footer_configlog() {
512 {
513  echo
514  echo '//ll'
515 } >&5
516}
517
518write_header_configh() {
519 {
520  echo '//config.h:'
521  echo
522  echo "#ifndef $1"
523  echo "#define $1"
524  echo
525  echo '/* uname: ' $(uname -a) '*/'
526  echo '/* Date : ' $(date)  '*/'
527  echo
528 } >&3
529}
530
531write_footer_configh() {
532 {
533  echo
534  echo '#endif'
535  echo
536  echo '//ll'
537 } >&3
538}
539
540write_vars_configh_string() {
541 {
542  for f in "$@"
543  do
544   eval val=\"\$$f\"
545   echo "#define $f \"$val\""
546  done
547 } >&3
548}
549
550write_vars_configh_literal() {
551 {
552  for f in "$@"
553  do
554   eval val=\"\$$f\"
555   echo "#define $f $val"
556  done
557 } >&3
558}
559
560write_header() {
561 write_header_makefileconf
562 write_header_configlog
563 write_header_configh "$@"
564}
565
566write_footer() {
567 write_footer_makefileconf
568 write_footer_configlog
569 write_footer_configh
570}
571
572#ll
Note: See TracBrowser for help on using the repository browser.