source: roaraudio/configure @ 806:01208d682d8e

Last change on this file since 806:01208d682d8e was 804:7e498a6977b9, checked in by phi, 16 years ago

search for cdrom device

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