source: roaraudio/configure @ 864:ce3de1d58b8d

Last change on this file since 864:ce3de1d58b8d was 864:ce3de1d58b8d, checked in by phi, 16 years ago

added options to set $PREFIX*

  • Property exe set to *
File size: 10.2 KB
Line 
1#!/bin/sh
2
3# check for bash...
4
5if [ "$(echo -n)" = '-n' ]
6then
7 SHELL=$(which bash sh 2> /dev/null | grep ^/ | head -n 1)
8 exec $SHELL $0 "$@"
9fi
10
11
12#set -x
13
14TF_C=testit.c
15TF_E=./testit
16LDPATH=''
17INCPATH=''
18
19SYSNAME='unknown'
20SHARED='-shared'
21SHARED_CF=''
22PKG_CONFIG=false
23RUNTIME_DETECT=false
24
25PREFIX='/usr/local'
26PREFIX_BIN=''
27PREFIX_LIB=''
28PREFIX_INC=''
29PREFIX_MAN=''
30
31CDROM="none"
32PROC_NET_DECNET="/proc/net/decnet"
33
34echo -n "checking for C compiler... "
35CC=$(which gcc cc 2> /dev/null | grep ^/ | head -n 1)
36if [ "$CC" = '' ]
37then
38 echo 'none'
39 exit 1;
40fi
41echo $CC
42
43echo -n "checking for pkg-config... "
44PKG_CONFIG=$(which pkg-config false 2> /dev/null | grep ^/ | head -n 1)
45if $PKG_CONFIG --help > /dev/null 2> /dev/null
46then
47 echo $PKG_CONFIG
48else
49 echo no
50fi
51
52#Makefile.conf not yet open, write it later
53
54echo -n "checking for sysname... "
55SYSNAME=$(uname -s)
56echo "$SYSNAME"
57
58while [ "$1" != '' ]
59do
60 case "$1" in
61  '--help')
62   echo '--help                      - This Help'
63   echo '--ldpath DIR                - Add DIR to (compile time) search list for libs'
64   echo '--incpath DIR               - Add DIR to search list for headers'
65   echo '--addpath DIR               - Add DIR/lib to lib, DIR/include to header search list'
66   echo '--cdrom DEV                 - Set default CDRum device'
67   echo '--proc-net-decnet FILE      - Set DECnet file for DECnet support auto detecting'
68   echo '                              (ignore this on non-Linux)'
69   echo '--no-LIB                    - disable LIB'
70   echo '--runtime-detect            - do as much as posible auto detecting on runtime (for distributors)'
71   echo '--prefix DIR'
72   echo '--prefix-bin DIR'
73   echo '--prefix-lib DIR'
74   echo '--prefix-inc DIR'
75   echo '--prefix-man DIR'
76   exit 0;
77  ;;
78  '--ldpath')
79   LDPATH="$LDPATH -L$2"
80   shift;
81  ;;
82  '--incpath')
83   INCPATH="$INCPATH -I$2"
84   shift;
85  ;;
86  '--addpath')
87   LDPATH="$LDPATH -L$2/lib/"
88   INCPATH="$INCPATH -I$2/include/"
89   shift;
90  ;;
91  '--cdrom')
92   CDROM="$2"
93   shift;
94  ;;
95  '--no-'*)
96   lib=$(echo "$1" | sed 's/^--no-//')
97   eval no_lib_$lib=true
98  ;;
99  '--runtime-detect')
100   RUNTIME_DETECT=true
101  ;;
102  '--prefix')
103   PREFIX="$2"
104   shift;
105  ;;
106  '--prefix-bin')
107   PREFIX_BIN="$2"
108   shift;
109  ;;
110  '--prefix-lib')
111   PREFIX_LIB="$2"
112   shift;
113  ;;
114  '--prefix-inc')
115   PREFIX_INC="$2"
116   shift;
117  ;;
118  '--prefix-man')
119   PREFIX_MAN="$2"
120   shift;
121  ;;
122 esac;
123
124 shift;
125done
126
127
128CCTF="false"
129
130test_lib () {
131 echo > $TF_C
132
133 echo -n "checking for $1... "
134 shift;
135
136 LIBS=''
137
138 while [ "$1" != '--' ]
139 do
140  LIBS="$LIBS -l$1"
141  shift;
142 done
143
144 shift;
145
146 LIBS=$(echo "$LIBS" | sed 's/-l-l/-l/g; s/-l-L/-L/g;')
147
148 while [ "$1" != '' ]
149 do
150  echo "#include <$1>" >> $TF_C
151  shift;
152 done
153
154 echo 'int main (void) { return 0; }' >> $TF_C
155
156 $CCTF $LIBS 2> /dev/null;
157
158 R=$?
159
160 if [ "$R" = '0' ]
161 then
162  echo 'yes'
163 else
164  echo 'no'
165 fi
166
167 return $R
168}
169
170test_lib_defmake () {
171 def="$1"
172 subdir="$2"
173 shift
174 shift
175 name="$1"
176 lib="$2"
177 shift
178
179 [ "$subdir" = '%' ] && subdir=''
180
181 if [ "$lib" != '--' ]
182 then
183  eval _no="\$no_lib_$lib";
184
185  if [ "$_no" != '' ]
186  then
187    echo "checking for $1... disabled by user"
188   [ "$subdir" != '' ] && \
189    echo "subdir_$subdir=" >&4
190   echo "lib_$lib=" >&4
191   return;
192  fi
193 fi
194
195 LIBS=$($PKG_CONFIG --silence-errors --libs $lib)
196 if [ "$?" != '0' ]
197 then
198  LIBS="-l$lib"
199 fi
200
201 if test_lib "$name" $LIBS "$@"
202 then
203  echo "#define $def"            >&3
204  [ "$subdir" != '' ] && \
205   echo "subdir_$subdir=$subdir" >&4
206  echo "lib_$lib=$LIBS" >&4
207 else
208  [ "$subdir" != '' ] && \
209   echo "subdir_$subdir=" >&4
210  echo "lib_$lib=" >&4
211 fi
212}
213
214test_tool_defmake () {
215 DEF="$1"
216 NAME="$2"
217 shift;
218 shift;
219 echo -n "checking for $NAME... "
220
221 if $RUNTIME_DETECT
222 then
223  echo "$1 (runtime detect)"
224 echo "#define $DEF "\""$1"\" >&3
225 else
226
227  LIST=$(which "$@" 2> /dev/null | grep ^/ | head -n 1)
228
229  if [ "$LIST" = '' ]
230  then
231   echo 'no'
232  else
233   echo $LIST
234   echo "#define $DEF "\""$LIST"\" >&3
235  fi
236 fi
237}
238
239exec 3> config.h 4> Makefile.conf
240
241if [ "$SYSNAME" = 'Darwin' ]
242then
243 echo "Adding $SYSNAME shared lib arguments..."
244 SHARED="$SHARED -fno-common -dynamiclib -compatibility_version 0.1 -current_version 0.1.0"
245 SHARED_CF="$SHARED_CF -fno-common"
246elif [ "$SYSNAME" = 'NetBSD' ]
247then
248 echo "Adding $SYSNAME libpath arguments..."
249 LDPATH="$LDPATH -L/usr/local/lib/"
250fi
251
252[ "$PREFIX_BIN" = '' ] && PREFIX_BIN="$PREFIX/bin/"
253[ "$PREFIX_LIB" = '' ] && PREFIX_LIB="$PREFIX/lib/"
254[ "$PREFIX_INC" = '' ] && PREFIX_INC="$PREFIX/include/"
255[ "$PREFIX_MAN" = '' ] && PREFIX_MAN="$PREFIX/share/man/"
256
257# now write the cc name to Makefile.conf
258{
259 echo "SHARED=$SHARED"
260 echo "SHARED_CF=$SHARED_CF"
261 echo "CC=$CC"
262 echo "LDPATH=$LDPATH"
263 echo "INCPATH=$INCPATH"
264 echo "PREFIX=$PREFIX"
265 echo "PREFIX_BIN=$PREFIX_BIN"
266 echo "PREFIX_LIB=$PREFIX_LIB"
267 echo "PREFIX_INC=$PREFIX_INC"
268 echo "PREFIX_MAN=$PREFIX_MAN"
269} >&4
270
271CCTF="$CC $LDPATH $INCPATH -o $TF_E $TF_C"
272
273cat >&3 << EOF
274//config.h:
275
276#ifndef _ROARAUDIO_CONFIG_H_
277#define _ROARAUDIO_CONFIG_H_
278
279EOF
280
281{
282 echo '/* uname: ' $(uname -a) '*/'
283 echo '/* Date : ' $(date)  '*/'
284 echo
285} >&3
286
287#                 #define                  name         cmds...
288test_tool_defmake ROAR_HAVE_BIN_OGG123     ogg123       ogg123
289test_tool_defmake ROAR_HAVE_BIN_FLAC       flac         flac
290test_tool_defmake ROAR_HAVE_BIN_TIMIDITY   TiMidity++   timidity
291test_tool_defmake ROAR_HAVE_BIN_CDPARANOIA cdparanoia   cdparanoia
292test_tool_defmake ROAR_HAVE_BIN_WGET       Wget         wget
293
294echo >&3
295
296test_lib 'Math Library' m          -- math.h                         && echo '#define ROAR_HAVE_LIBM' >&3
297if test_lib 'realtime Library' rt -- sys/mman.h mqueue.h semaphore.h
298then
299 {
300  echo '#define ROAR_HAVE_LIBRT'
301  echo '#define ROAR_NEED_LIBRT'
302 } >&3
303fi
304
305echo >&3
306
307#                #define                 subdir       name          -lxxx      -- header
308test_lib_defmake ROAR_HAVE_ESD           libroaresd   EsounD        esd        -- esd.h
309test_lib_defmake ROAR_HAVE_LIBAO         %            libao         ao         -- ao/ao.h ao/plugin.h
310test_lib_defmake ROAR_HAVE_LIBVORBIS     %            libvorbis     vorbis     -- vorbis/codec.h
311test_lib_defmake ROAR_HAVE_LIBVORBISFILE %            libvorbisfile vorbisfile -- vorbis/vorbisfile.h
312test_lib_defmake ROAR_HAVE_LIBVORBISENC  %            libvorbisenc  vorbisenc  -- vorbis/vorbisenc.h
313test_lib_defmake ROAR_HAVE_LIBSPEEX      %            libspeex      speex      -- speex/speex.h speex/speex_stereo.h
314test_lib_defmake ROAR_HAVE_LIBCELT       %            libcelt       celt       -- celt/celt.h celt/celt_header.h
315test_lib_defmake ROAR_HAVE_LIBOGGZ       %            liboggz       oggz       -- oggz/oggz.h
316test_lib_defmake ROAR_HAVE_LIBSNDFILE    %            libsndfile    sndfile    -- sndfile.h
317test_lib_defmake ROAR_HAVE_LIBFISHSOUND  roarfish     libfishsound  fishsound  -- fishsound/fishsound.h
318test_lib_defmake ROAR_HAVE_LIBSHOUT      %            libshout      shout      -- shout/shout.h
319test_lib_defmake ROAR_HAVE_LIBPULSE      libroarpulse libpulse      pulse      -- pulse/pulseaudio.h pulse/simple.h
320test_lib_defmake ROAR_HAVE_LIBY2         libroaryiff  libyiff       Y2         -- Y2/Y.h Y2/Ylib.h
321test_lib_defmake ROAR_HAVE_LIBARTSC      libroararts  libartsc      artsc      -- kde/artsc/artsc.h
322test_lib_defmake ROAR_HAVE_LIBDNET       %            libdnet       dnet       -- sys/socket.h netdnet/dn.h netdnet/dnetdb.h
323test_lib_defmake ROAR_HAVE_IPX           %            IPX           c          -- netipx/ipx.h
324
325# add a better test here
326test_lib 'linux sendfile()'       -- sys/sendfile.h && echo '#define ROAR_HAVE_LINUX_SENDFILE' >&3
327
328
329echo -n 'checking for mlock()... '
330
331echo '#include <sys/mman.h>' > $TF_C
332echo 'int main (void) { mlock((void*)0, 0); return 0; }' >> $TF_C
333
334if $CCTF 2> /dev/null;
335then
336 echo '#define ROAR_HAVE_MLOCK' >&3
337 echo yes
338else
339 echo no
340fi
341
342echo -n 'checking for inline funcs... '
343
344echo 'inline int test (void) { return 0; }' > $TF_C
345echo 'int main (void) { return test(); }'  >> $TF_C
346
347if $CCTF 2> /dev/null;
348then
349 echo '#define ROAR_HAVE_INLINE' >&3
350 echo yes
351else
352 echo no
353fi
354
355echo -n 'checking for safe 32 bit integer overflow... '
356
357cat > $TF_C << EOF
358#include <stdio.h>
359#include <stdint.h>
360#define TYPE uint32_t
361#define MAX  ((TYPE)4294967295U)
362
363int main (void) {
364 TYPE a = MAX;
365
366 a += 2;
367
368 if ( a == 1 ) {
369  printf("#define ROAR_HAVE_SAFE_OVERFLOW\n");
370  return 0;
371 }
372
373 return 1;
374}
375EOF
376
377if $CCTF 2> /dev/null;
378then
379 $TF_E >&3
380 if [ "$?" = '0' ]
381 then
382  echo yes
383 else
384  echo no
385 fi
386else
387 echo 'no (can not compile!, no stdint.h?)'
388fi
389
390echo -n 'checking for __LP64__... '
391cat > $TF_C << EOF
392#include <stdio.h>
393
394int main (void) {
395#ifdef __LP64__
396 fprintf(stderr, "set by compiler\n");
397#else
398 if ( sizeof(int) == sizeof(void*) ) {
399  fprintf(stderr, "no need to set\n");
400 } else {
401  fprintf(stderr, "need to set\n");
402  printf("\n#ifndef __LP64__\n#define __LP64__\n#endif\n\n");
403 }
404#endif
405 return 0;
406}
407EOF
408if $CCTF 2> /dev/null;
409then
410 $TF_E >&3
411else
412 echo 'error, can not compile'
413 exit 1
414fi
415
416echo -n 'checking for 64 bit types... '
417cat > $TF_C << EOF
418#include <stdio.h>
419#include <stdint.h>
420
421int main (void) {
422 char * i64 = NULL, * ui64 = NULL;
423
424 if ( sizeof(int) == 8 ) {
425  i64 = "int"; ui64 = "unsigned int";
426 } else if ( sizeof(long int) == 8 ) {
427  i64 = "long int"; ui64 = "unsigned long int";
428 } else if ( sizeof(long long int) == 8 ) {
429  i64 = "long long int"; ui64 = "unsigned long long int";
430 } else if ( sizeof(int64_t) == 8 ) {
431  i64 = "int64_t"; ui64 = "uint64_t";
432 } else {
433  fprintf(stderr, "none\n");
434  return 0;
435 }
436
437 fprintf(stderr, "%s, %s\n", i64, ui64);
438 printf("#define ROAR_NATIVE_INT64 %s\n#define ROAR_NATIVE_UINT64 %s\n", i64, ui64);
439
440 return 0;
441}
442EOF
443if $CCTF 2> /dev/null;
444then
445 $TF_E >&3
446else
447 echo 'error, can not compile'
448 exit 1
449fi
450
451
452echo -n 'checking if cp supports -v... '
453if cp -v --help > /dev/null 2> /dev/null
454then
455 echo "cp_v=-v" >&4
456 echo yes
457else
458 echo "cp_v=" >&4
459 echo no
460fi
461
462echo -n 'checking for cdrom device... '
463if [ -e "$CDROM" ]
464then
465 echo "$CDROM"
466else
467 CDROM=$(ls /dev/cdrom /dev/rcd0c 2> /dev/null | head -n 1);
468 if [ -e "$CDROM" ]
469 then
470  echo "$CDROM"
471  echo '#define ROAR_DEFAULT_CDROM "'"$CDROM"'"' >&3
472 else
473  echo 'none'
474 fi
475fi
476
477echo 'checking for decnet status file... '"$PROC_NET_DECNET"
478echo '#define ROAR_PROC_NET_DECNET "'"$PROC_NET_DECNET"'"' >&3
479
480cat >&3 << EOF
481
482#endif
483
484//ll
485EOF
486
487rm -f $TF_C $TF_E
488
489mv config.h include/roaraudio/
490echo 'config.h created and moved into include/roaraudio/'
491
492#ll
Note: See TracBrowser for help on using the repository browser.