source: roaraudio/configure @ 604:6a80ea4e71bf

Last change on this file since 604:6a80ea4e71bf was 604:6a80ea4e71bf, checked in by phi, 16 years ago

added entry for libshout

  • Property exe set to *
File size: 4.8 KB
Line 
1#!/bin/sh
2
3#set -x
4
5TF_C=testit.c
6TF_E=./testit
7LDPATH=''
8INCPATH=''
9
10echo -n "checking for C compiler... "
11CC=$(which gcc cc 2> /dev/null | head -n 1)
12if [ "$CC" = '' ]
13then
14 echo 'none'
15 exit 1;
16fi
17echo $CC
18
19#Makefile.conf not yet open, write it later
20
21
22while [ "$1" != '' ]
23do
24 case "$1" in
25  '--help')
26   echo '--help'
27   echo '--ldpath DIR'
28   echo '--incpath DIR'
29   echo '--addpath DIR'
30   exit 0;
31  ;;
32  '--ldpath')
33   LDPATH="$LDPATH -L$2"
34   shift;
35  ;;
36  '--incpath')
37   INCPATH="$INCPATH -I$2"
38   shift;
39  ;;
40  '--addpath')
41   LDPATH="$LDPATH -L$2/lib/"
42   INCPATH="$INCPATH -I$2/include/"
43   shift;
44  ;;
45 esac;
46
47 shift;
48done
49
50
51CCTF="$CC $LDPATH $INCPATH -o $TF_E $TF_C"
52
53test_lib () {
54 echo > $TF_C
55
56 echo -n "checking for $1... "
57 shift;
58
59 LIBS=''
60
61 while [ "$1" != '--' ]
62 do
63  LIBS="$LIBS -l$1"
64  shift;
65 done
66
67 shift;
68
69 while [ "$1" != '' ]
70 do
71  echo "#include <$1>" >> $TF_C
72  shift;
73 done
74
75 echo 'int main (void) { return 0; }' >> $TF_C
76
77 $CCTF $LIBS 2> /dev/null;
78
79 R=$?
80
81 if [ "$R" = '0' ]
82 then
83  echo 'yes'
84 else
85  echo 'no'
86 fi
87
88 return $R
89}
90
91test_lib_defmake () {
92 def="$1"
93 subdir="$2"
94 shift
95 shift
96 lib="$2"
97
98 [ "$subdir" = '%' ] && subdir=''
99
100 if test_lib $@
101 then
102  echo "#define $def"            >&3
103  [ "$subdir" != '' ] && \
104   echo "subdir_$subdir=$subdir" >&4
105  echo "lib_$lib=-l$lib" >&4
106 else
107  [ "$subdir" != '' ] && \
108   echo "subdir_$subdir=" >&4
109  echo "lib_$lib=" >&4
110 fi
111}
112
113exec 3> config.h 4> Makefile.conf
114
115# now write the cc name to Makefile.conf
116echo "CC=$CC" >&4
117echo "LDPATH=$LDPATH" >&4
118echo "INCPATH=$INCPATH" >&4
119
120cat >&3 << EOF
121//config.h:
122
123#ifndef _ROARAUDIO_CONFIG_H_
124#define _ROARAUDIO_CONFIG_H_
125
126EOF
127
128{
129 echo '/* uname: ' $(uname -a) '*/'
130 echo '/* Date : ' $(date)  '*/'
131 echo
132} >&3
133
134test_lib 'Math Library' m          -- math.h                         && echo '#define ROAR_HAVE_LIBM' >&3
135if test_lib 'realtime Library' rt -- sys/mman.h mqueue.h semaphore.h
136then
137 {
138  echo '#define ROAR_HAVE_LIBRT'
139  echo '#define ROAR_NEED_LIBRT'
140 } >&3
141fi
142
143echo >&3
144
145#                #define                 subdir       name          -lxxx      -- header
146test_lib_defmake ROAR_HAVE_ESD           libroaresd   EsounD        esd        -- esd.h
147test_lib_defmake ROAR_HAVE_LIBAO         %            libao         ao         -- ao/ao.h ao/plugin.h
148test_lib_defmake ROAR_HAVE_LIBVORBIS     %            libvorbis     vorbis     -- vorbis/codec.h
149test_lib_defmake ROAR_HAVE_LIBVORBISFILE %            libvorbisfile vorbisfile -- vorbis/vorbisfile.h
150test_lib_defmake ROAR_HAVE_LIBVORBISENC  %            libvorbisenc  vorbisenc  -- vorbis/vorbisenc.h
151test_lib_defmake ROAR_HAVE_LIBSPEEX      %            libspeex      speex      -- speex/speex.h speex/speex_stereo.h
152test_lib_defmake ROAR_HAVE_LIBCELT       %            libcelt       celt       -- celt/celt.h celt/celt_header.h
153test_lib_defmake ROAR_HAVE_LIBOGGZ       %            liboggz       oggz       -- oggz/oggz.h
154test_lib_defmake ROAR_HAVE_LIBSNDFILE    %            libsndfile    sndfile    -- sndfile.h
155test_lib_defmake ROAR_HAVE_LIBFISHSOUND  roarfish     libfishsound  fishsound  -- fishsound/fishsound.h
156test_lib_defmake ROAR_HAVE_LIBSHOUT      %            libshout      shout      -- shout/shout.h
157test_lib_defmake ROAR_HAVE_LIBPULSE      libroarpulse libpulse      pulse      -- pulse/pulseaudio.h pulse/simple.h
158test_lib_defmake ROAR_HAVE_LIBY2         libroaryiff  libyiff       Y2         -- Y2/Y.h Y2/Ylib.h
159test_lib_defmake ROAR_HAVE_LIBARTSC      libroararts  libartsc      artsc      -- kde/artsc/artsc.h
160test_lib_defmake ROAR_HAVE_LIBDNET       %            libdnet       dnet       -- sys/socket.h netdnet/dn.h netdnet/dnetdb.h
161test_lib_defmake ROAR_HAVE_IPX           %            IPX                      -- netipx/ipx.h
162
163# add a better test here
164test_lib 'linux sendfile()'       -- sys/sendfile.h && echo '#define ROAR_HAVE_LINUX_SENDFILE' >&3
165
166
167echo -n 'checking for mlock()... '
168
169echo '#include <sys/mman.h>' > $TF_C
170echo 'int main (void) { mlock((void*)0, 0); return 0; }' >> $TF_C
171
172if $CCTF 2> /dev/null;
173then
174 echo '#define ROAR_HAVE_MLOCK' >&3
175 echo yes
176else
177 echo no
178fi
179
180echo -n 'checking for safe 32 bit integer overflow... '
181
182cat > $TF_C << EOF
183#include <stdio.h>
184#include <stdint.h>
185#define TYPE uint32_t
186#define MAX  ((TYPE)4294967295U)
187
188int main (void) {
189 TYPE a = MAX;
190
191 a += 2;
192
193 if ( a == 1 ) {
194  printf("#define ROAR_HAVE_SAFE_OVERFLOW\n");
195  return 0;
196 }
197
198 return 1;
199}
200EOF
201
202if $CCTF 2> /dev/null;
203then
204 $TF_E >&3
205 if [ "$?" = '0' ]
206 then
207  echo yes
208 else
209  echo no
210 fi
211else
212 echo 'no (can not compile!, no stdint.h?)'
213fi
214
215echo -n 'checking if cp supports -v... '
216if cp -v --help > /dev/null 2> /dev/null
217then
218 echo "cp_v=-v" >&4
219 echo yes
220else
221 echo "cp_v=" >&4
222 echo no
223fi
224
225
226cat >&3 << EOF
227
228#endif
229
230//ll
231EOF
232
233rm -f $TF_C $TF_E
234
235mv config.h include/roaraudio/
236echo 'config.h created and moved into include/roaraudio/'
237
238#ll
Note: See TracBrowser for help on using the repository browser.