source: roaraudio/configure @ 914:673bfebe2ee4

Last change on this file since 914:673bfebe2ee4 was 914:673bfebe2ee4, checked in by phi, 15 years ago

check for OSS support

  • Property exe set to *
File size: 11.5 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
345test_lib_defmake ROAR_HAVE_OSS           %            OSS           c          -- sys/ioctl.h sys/soundcard.h
346test_lib_defmake ROAR_HAVE_OSS_BSD       %            BSDOSS        c          -- sys/ioctl.h soundcard.h
347
348# add a better test here
349test_lib 'linux sendfile()'       -- sys/sendfile.h && echo '#define ROAR_HAVE_LINUX_SENDFILE' >&3
350
351
352echo -n 'checking for IPv6... '
353
354echo '#include <sys/socket.h>'  > $TF_C
355echo '#include <netinet/in.h>' >> $TF_C
356echo 'int main (void) { struct sockaddr_in6 in6; return 0; }' >> $TF_C
357
358if $CCTF 2> /dev/null;
359then
360 echo '#define ROAR_HAVE_IPV6' >&3
361 echo yes
362else
363 echo no
364fi
365
366
367echo -n 'checking for mlock()... '
368
369echo '#include <sys/mman.h>' > $TF_C
370echo 'int main (void) { mlock((void*)0, 0); return 0; }' >> $TF_C
371
372if $CCTF 2> /dev/null;
373then
374 echo '#define ROAR_HAVE_MLOCK' >&3
375 echo yes
376else
377 echo no
378fi
379
380echo -n 'checking for inline funcs... '
381
382echo 'inline int test (void) { return 0; }' > $TF_C
383echo 'int main (void) { return test(); }'  >> $TF_C
384
385if $CCTF 2> /dev/null;
386then
387 echo '#define ROAR_HAVE_INLINE' >&3
388 echo yes
389else
390 echo no
391fi
392
393echo -n 'checking for safe 32 bit integer overflow... '
394
395cat > $TF_C << EOF
396#include <stdio.h>
397#include <stdint.h>
398#define TYPE uint32_t
399#define MAX  ((TYPE)4294967295U)
400
401int main (void) {
402 TYPE a = MAX;
403
404 a += 2;
405
406 if ( a == 1 ) {
407  printf("#define ROAR_HAVE_SAFE_OVERFLOW\n");
408  return 0;
409 }
410
411 return 1;
412}
413EOF
414
415if $CCTF 2> /dev/null;
416then
417 $TF_E >&3
418 if [ "$?" = '0' ]
419 then
420  echo yes
421 else
422  echo no
423 fi
424else
425 echo 'no (can not compile!, no stdint.h?)'
426fi
427
428echo -n 'checking for __LP64__... '
429cat > $TF_C << EOF
430#include <stdio.h>
431
432int main (void) {
433#ifdef __LP64__
434 fprintf(stderr, "set by compiler\n");
435#else
436 if ( sizeof(int) == sizeof(void*) ) {
437  fprintf(stderr, "no need to set\n");
438 } else {
439  fprintf(stderr, "need to set\n");
440  printf("\n#ifndef __LP64__\n#define __LP64__\n#endif\n\n");
441 }
442#endif
443 return 0;
444}
445EOF
446if $CCTF 2> /dev/null;
447then
448 $TF_E >&3
449else
450 echo 'error, can not compile'
451 exit 1
452fi
453
454echo -n 'checking for 64 bit types... '
455cat > $TF_C << EOF
456#include <stdio.h>
457#include <stdint.h>
458
459int main (void) {
460 char * i64 = NULL, * ui64 = NULL;
461
462 if ( sizeof(int) == 8 ) {
463  i64 = "int"; ui64 = "unsigned int";
464 } else if ( sizeof(long int) == 8 ) {
465  i64 = "long int"; ui64 = "unsigned long int";
466 } else if ( sizeof(long long int) == 8 ) {
467  i64 = "long long int"; ui64 = "unsigned long long int";
468 } else if ( sizeof(int64_t) == 8 ) {
469  i64 = "int64_t"; ui64 = "uint64_t";
470 } else {
471  fprintf(stderr, "none\n");
472  return 0;
473 }
474
475 fprintf(stderr, "%s, %s\n", i64, ui64);
476 printf("#define ROAR_NATIVE_INT64 %s\n#define ROAR_NATIVE_UINT64 %s\n", i64, ui64);
477
478 return 0;
479}
480EOF
481if $CCTF 2> /dev/null;
482then
483 $TF_E >&3
484else
485 echo 'error, can not compile'
486 exit 1
487fi
488
489
490echo -n 'checking if cp supports -v... '
491if cp -v --help > /dev/null 2> /dev/null
492then
493 echo "cp_v=-v" >&4
494 echo yes
495else
496 echo "cp_v=" >&4
497 echo no
498fi
499
500echo -n 'checking for cdrom device... '
501if [ -e "$CDROM" ]
502then
503 echo "$CDROM"
504else
505 CDROM=$(ls /dev/cdrom /dev/rcd0c 2> /dev/null | head -n 1);
506 if [ -e "$CDROM" ]
507 then
508  echo "$CDROM"
509  echo '#define ROAR_DEFAULT_CDROM "'"$CDROM"'"' >&3
510 else
511  echo 'none'
512 fi
513fi
514
515echo -n 'checking for OSS device... '
516if [ -e "$OSS_DEV" ]
517then
518 echo "$OSS_DEV"
519else
520 OSS_DEV=$(ls /dev/dsp /dev/audio 2> /dev/null | head -n 1);
521 if [ -e "$OSS_DEV" ]
522 then
523  echo "$OSS_DEV"
524  echo '#define ROAR_DEFAULT_OSS_DEV "'"$OSS_DEV"'"' >&3
525 else
526  echo 'none'
527 fi
528fi
529
530echo 'checking for decnet status file... '"$PROC_NET_DECNET"
531echo '#define ROAR_PROC_NET_DECNET "'"$PROC_NET_DECNET"'"' >&3
532
533cat >&3 << EOF
534
535#endif
536
537//ll
538EOF
539
540echo 'running libao plugin configure...'
541 cd plugins/ao/
542if [ "$AO_INST_DIR" = '' ]
543then
544 ./configure
545else
546 ./configure --inst-dir "$AO_INST_DIR"
547fi
548cd ../..
549
550rm -f $TF_C $TF_E
551
552mv config.h include/roaraudio/
553echo 'config.h created and moved into include/roaraudio/'
554
555echo "$SYSNAME" | if grep CYGWIN > /dev/null
556then
557 echo 'patching Makefiles for cygwin...'
558 find . -name Makefile -print0 | xargs -0 sed 's/\.so/.dll'/g -i
559fi
560
561#ll
Note: See TracBrowser for help on using the repository browser.