source: roaraudio/configure @ 913:83f431ef590e

Last change on this file since 913:83f431ef590e was 913:83f431ef590e, checked in by phi, 15 years ago

search for default OSS device

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