source: roaraudio/configure @ 890:c3559be0bc00

Last change on this file since 890:c3559be0bc00 was 890:c3559be0bc00, checked in by phi, 15 years ago

added check for IPv6

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