source: roaraudio/build-system/configure.lib @ 5808:03a414d5afc4

Last change on this file since 5808:03a414d5afc4 was 5808:03a414d5afc4, checked in by phi, 9 years ago

added function error_missing()

File size: 10.1 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-lib DIR            - Set prefix for libraries (default: $PREFIX/libs)'
64 echo '--prefix-inc DIR            - Set prefix for include files (default: $PREFIX/include)'
65 echo '--prefix-man DIR            - Set prefix for manpages (default: $PREFIX/man)'
66 echo '--prefix-pc DIR             - Set prefix for pkg-config (default: $PREFIX_LIB/pkgconfig)'
67 echo
68 echo '--without-beta              - Disable beta code'
69 echo '--without-experimental      - Disable experimental code'
70 echo
71 echo '--distribution-version-string STRING'
72 echo '                            - Sets distribution part of version string'
73 echo
74 echo '--mmcu MMCU                 - Sets -mmcu compiler/linker option'
75 echo '--target-win32              - Disable everything useful'
76 echo '--exec-helper HELPER        - Exec all test programms using this command (HELPER $cmd $args)'
77 echo '                              use '\''--exec-helper wine'\'' when building win32 binaries'
78 echo
79}
80
81parse_option() {
82 # Options are given via $n.
83 # we can not shift used ones so we tell the caller
84 # how many to shift: shift $SHIFT_COUNT
85 SHIFT_COUNT=0
86 # we also tell if the option was handelt.
87 HANDLED=true # will be reset if not.
88
89 case "$1" in
90  '--ldpath')
91   LDPATH="$LDPATH -L$2"
92   SHIFT_COUNT=1
93  ;;
94  '--incpath')
95   INCPATH="$INCPATH -I$2"
96   SHIFT_COUNT=1
97  ;;
98  '--addpath')
99   LDPATH="$LDPATH -L$2/lib/"
100   INCPATH="$INCPATH -I$2/include/"
101   SHIFT_COUNT=1
102  ;;
103  '--root')
104   LDPATH="$LDPATH -L$2/lib/"
105   INCPATH="$INCPATH -I$2/include/"
106   PREFIX="$2"
107   SHIFT_COUNT=1
108  ;;
109  '--cflags')
110   CFLAGS="$2"
111   SHIFT_COUNT=1
112  ;;
113  '--ldflags')
114   LDFLAGS="$2"
115   SHIFT_COUNT=1
116  ;;
117  '--opti')
118   OPTI_O="$2"
119   SHIFT_COUNT=1
120  ;;
121  '--link-deps')
122   LINK_DEPS="$2"
123   SHIFT_COUNT=1
124  ;;
125  '--cc')
126   CC="$2"
127   SHIFT_COUNT=1
128  ;;
129  '--ranlib')
130   RANLIB="$2"
131   SHIFT_COUNT=1
132  ;;
133  '--root-uid')
134   ROOT_UID="$2"
135   SHIFT_COUNT=1
136  ;;
137  '--no-'*)
138   lib=$(echo "$1" | sed 's/^--no-//' | to_escaped)
139   eval no_lib_$lib=true
140  ;;
141  '--maybe-'*)
142   lib=$(echo "$1" | sed 's/^--maybe-//' | to_escaped)
143   eval unset no_lib_$lib
144  ;;
145  '--distribution-version-string')
146   DISTRIBUTION_VERSION_STRING="$2"
147   SHIFT_COUNT=1
148  ;;
149  '--without-beta')
150   BETA=false
151   EXPERIMENTAL=false
152  ;;
153  '--without-experimental')
154   EXPERIMENTAL=false
155  ;;
156  '--prefix')
157   PREFIX="$2"
158   SHIFT_COUNT=1
159  ;;
160  '--prefix-bin')
161   PREFIX_BIN="$2"
162   SHIFT_COUNT=1
163  ;;
164  '--prefix-lib')
165   PREFIX_LIB="$2"
166   SHIFT_COUNT=1
167  ;;
168  '--prefix-inc')
169   PREFIX_INC="$2"
170   SHIFT_COUNT=1
171  ;;
172  '--prefix-man')
173   PREFIX_MAN="$2"
174   SHIFT_COUNT=1
175  ;;
176  '--prefix-pc')
177   PREFIX_PC="$2"
178   SHIFT_COUNT=1
179  ;;
180  '--prefix-ckport')
181   PREFIX_CKPORT="$2"
182   SHIFT_COUNT=1
183  ;;
184####################################
185# autof* options block:
186  '--prefix='*)
187   PREFIX=$(echo "$1" | cut -d= -f2)
188  ;;
189  '--prefix-bin='*)
190   PREFIX_BIN=$(echo "$1" | cut -d= -f2)
191  ;;
192  '--prefix-lib='*)
193   PREFIX_LIB=$(echo "$1" | cut -d= -f2)
194  ;;
195  '--prefix-inc='*)
196   PREFIX_INC=$(echo "$1" | cut -d= -f2)
197  ;;
198  '--prefix-man='*)
199   PREFIX_MAN=$(echo "$1" | cut -d= -f2)
200  ;;
201  '--prefix-pc='*)
202   PREFIX_PC=$(echo "$1" | cut -d= -f2)
203  ;;
204  '--prefix-ckport='*)
205   PREFIX_CKPORT=$(echo "$1" | cut -d= -f2)
206  ;;
207####################################
208  '--mmcu')
209   MMCU="$2"
210   SHIFT_COUNT=1
211  ;;
212  '--exec-helper')
213   EXEC_HELPER="$2"
214   SHIFT_COUNT=1
215  ;;
216  '--target-win32')
217   TARGET_WIN32=true
218  ;;
219  *)
220   HANDLED=false
221  ;;
222 esac;
223
224 if $HANDLED
225 then
226  SHIFT_COUNT=`expr $SHIFT_COUNT + 1`
227 fi
228}
229
230open_configure_files() {
231 exec 3> config.h 4> Makefile.conf 5> config.log
232}
233
234update_target() {
235 TARGET_CYGWIN=`echo "$SYSNAME" | if grep CYGWIN  > /dev/null; then echo true; else echo false; fi`
236 TARGET_WIN32=`echo  "$SYSNAME" | if grep MINGW32 > /dev/null; then echo true; else echo $TARGET_WIN32; fi`
237
238 if [ "$SYSNAME" = 'Darwin' ]
239 then
240  echo "Adding common $SYSNAME shared lib arguments..."
241  SHARED="$SHARED -fno-common -dynamiclib -compatibility_version 0.1 -current_version 0.1.0"
242  SHARED_CF="$SHARED_CF -fno-common"
243 elif [ "$SYSNAME" = 'NetBSD' ]
244 then
245  echo "Adding common $SYSNAME libpath arguments..."
246  LDPATH="$LDPATH -L/usr/local/lib/"
247 elif [ "$SYSNAME" = 'OpenBSD' ]
248 then
249  echo "Adding common $SYSNAME search path arguments..."
250  LDPATH="$LDPATH -L/usr/local/lib/"
251  INCPATH="$INCPATH -I/usr/local/include/"
252 # echo "Adding $SYSNAME build arguments..."
253 # SNDIO_EMUL=false
254 elif [ "$SYSNAME" = 'FreeBSD' ]
255 then
256  echo "Adding common $SYSNAME search path arguments..."
257  LDPATH="$LDPATH -L/usr/local/lib/"
258  INCPATH="$INCPATH -I/usr/local/include/"
259 elif $TARGET_WIN32
260 then
261  echo "Adding common win32 build arguments..."
262  rdynamic=false
263  fPIC=false
264  SHARED_SUFFIX='.dll'
265  TF_E="$TF_E.exe"
266 elif $TARGET_CYGWIN
267 then
268  echo "Adding common cygwin build arguments..."
269  rdynamic=false
270  fPIC=false
271  SHARED_SUFFIX='.dll'
272  TF_E="$TF_E.exe"
273 fi
274}
275
276update_prefixes() {
277 [ "$PREFIX_BIN"    = '' ] && PREFIX_BIN="$PREFIX/bin/"
278 [ "$PREFIX_LIB"    = '' ] && PREFIX_LIB="$PREFIX/lib/"
279 [ "$PREFIX_INC"    = '' ] && PREFIX_INC="$PREFIX/include/"
280 [ "$PREFIX_MAN"    = '' ] && PREFIX_MAN="$PREFIX/share/man/"
281 [ "$PREFIX_PC"     = '' ] && PREFIX_PC="$PREFIX_LIB/pkgconfig/"
282 [ "$PREFIX_CKPORT" = '' ] && PREFIX_CKPORT="$PREFIX_LIB/ckport/db/"
283}
284
285update_ccft() {
286 CCTF="$CC $CFLAGS $LDFLAGS $LDPATH $INCPATH -Iinclude/ -o $TF_E $TF_C"
287}
288
289cleanup_ccft() {
290 rm -f $TF_C $TF_E
291 if [ "$TARGET_CYGWIN" = 'true' -o "$TARGET_WIN32" = 'true' ]
292 then
293  echo "Deleting win32 specific temp files: $TF_E.exe"
294  rm -f $TF_E.exe
295 fi
296}
297
298update_cc() {
299 if [ "$MMCU" != '' ]
300 then
301  CC="$CC -mmcu=$MMCU"
302 fi
303}
304
305write_header_makefileconf() {
306 {
307  echo "VERSION=$VERSION"
308  echo "DISTRIBUTION_VERSION_STRING=$DISTRIBUTION_VERSION_STRING"
309  echo
310  echo "SHARED=$SHARED"
311  echo "SHARED_CF=$SHARED_CF"
312  echo "SHARED_SUFFIX=$SHARED_SUFFIX"
313  $rdynamic && echo 'rdynamic=-rdynamic'
314  $fPIC     && echo 'fPIC=-fPIC'
315  $Wextra   && echo 'Wextra=-Wextra'
316  echo
317  echo "CC=$CC"
318  echo "RANLIB=$RANLIB"
319  echo "LDPATH=$LDPATH"
320  echo "INCPATH=$INCPATH"
321  echo "ROAR_BUILDSYSTEM_DIR=$ROAR_BUILDSYSTEM_DIR"
322  echo
323  echo "OPTI_O=-O$OPTI_O"
324  echo
325  [ "$CFLAGS"  != '' ] && echo "CFLAGS  += $CFLAGS"
326  [ "$LDFLAGS" != '' ] && echo "LDFLAGS += $LDFLAGS"
327  echo
328  echo "EXEC_HELPER=$EXEC_HELPER"
329  echo "CROSS_COMPILE=$CROSS_COMPILE"
330  echo
331  echo "PREFIX=$PREFIX"
332  echo "PREFIX_BIN=$PREFIX_BIN"
333  echo "PREFIX_LIB=$PREFIX_LIB"
334  echo "PREFIX_INC=$PREFIX_INC"
335  echo "PREFIX_MAN=$PREFIX_MAN"
336  echo "PREFIX_PC=$PREFIX_PC"
337  echo "PREFIX_CKPORT=$PREFIX_CKPORT"
338  echo
339 } >&4
340}
341
342write_footer_makefileconf() {
343 {
344  echo
345  echo '#ll'
346 } >&4
347}
348
349write_header_configlog() {
350 {
351  cat <<'EOF'
352//config.log:
353
354/*
355 * Logfile for configure script $Revision$ of RoarAudio
356 */
357
358EOF
359  echo '/* uname: ' $(uname -a) '*/'
360  echo '/* Date : ' $(date)  '*/'
361  echo
362
363  echo
364  echo
365
366  echo "ARGS(): $_CARGS"
367
368  for i in PATH SHELL CC RANLIB PKG_CONFIG SYSNAME \
369           TARGET_CYGWIN TARGET_WIN32 TARGET_MICROCONTROLLER CROSS_COMPILE \
370           MINIMAL EXEC_HELPER \
371           "$@"
372  do
373   eval echo "BASICCONF\($i\): \$$i";
374  done
375
376  echo
377  echo
378 } >&5
379}
380
381write_footer_configlog() {
382 {
383  echo
384  echo '//ll'
385 } >&5
386}
387
388write_header_configh() {
389 {
390  echo '//config.h:'
391  echo
392  echo "#ifndef $1"
393  echo "#define $1"
394  echo
395  echo '/* uname: ' $(uname -a) '*/'
396  echo '/* Date : ' $(date)  '*/'
397  echo
398 } >&3
399}
400
401write_footer_configh() {
402 {
403  echo
404  echo '#endif'
405  echo
406  echo '//ll'
407 } >&3
408}
409
410write_vars_configh_string() {
411 {
412  for f in "$@"
413  do
414   eval val=\"\$$f\"
415   echo "#define $f \"$val\""
416  done
417 } >&3
418}
419
420write_vars_configh_literal() {
421 {
422  for f in "$@"
423  do
424   eval val=\"\$$f\"
425   echo "#define $f $val"
426  done
427 } >&3
428}
429
430write_header() {
431 write_header_makefileconf
432 write_header_configlog
433 write_header_configh "$@"
434}
435
436write_footer() {
437 write_footer_makefileconf
438 write_footer_configlog
439 write_footer_configh
440}
441
442#ll
Note: See TracBrowser for help on using the repository browser.