source: roaraudio/configure @ 860:c78eff1ca926

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

check for wget

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