source: roaraudio/configure @ 714:d5e269760276

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

reorderd things to let sys specifc workarounds take effect while testing for libs

  • Property exe set to *
File size: 5.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 | 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'
21
22echo -n "checking for C compiler... "
23CC=$(which gcc cc 2> /dev/null | head -n 1)
24if [ "$CC" = '' ]
25then
26 echo 'none'
27 exit 1;
28fi
29echo $CC
30
31#Makefile.conf not yet open, write it later
32
33echo -n "checking for sysname... "
34SYSNAME=$(uname -s)
35echo "$SYSNAME"
36
37while [ "$1" != '' ]
38do
39 case "$1" in
40  '--help')
41   echo '--help'
42   echo '--ldpath DIR'
43   echo '--incpath DIR'
44   echo '--addpath DIR'
45   echo '--no-LIB'
46   exit 0;
47  ;;
48  '--ldpath')
49   LDPATH="$LDPATH -L$2"
50   shift;
51  ;;
52  '--incpath')
53   INCPATH="$INCPATH -I$2"
54   shift;
55  ;;
56  '--addpath')
57   LDPATH="$LDPATH -L$2/lib/"
58   INCPATH="$INCPATH -I$2/include/"
59   shift;
60  ;;
61  '--no-'*)
62   lib=$(echo "$1" | sed 's/^--no-//')
63   eval no_lib_$lib=true
64  ;;
65 esac;
66
67 shift;
68done
69
70
71CCTF="false"
72
73test_lib () {
74 echo > $TF_C
75
76 echo -n "checking for $1... "
77 shift;
78
79 LIBS=''
80
81 while [ "$1" != '--' ]
82 do
83  LIBS="$LIBS -l$1"
84  shift;
85 done
86
87 shift;
88
89 while [ "$1" != '' ]
90 do
91  echo "#include <$1>" >> $TF_C
92  shift;
93 done
94
95 echo 'int main (void) { return 0; }' >> $TF_C
96
97 $CCTF $LIBS 2> /dev/null;
98
99 R=$?
100
101 if [ "$R" = '0' ]
102 then
103  echo 'yes'
104 else
105  echo 'no'
106 fi
107
108 return $R
109}
110
111test_lib_defmake () {
112 def="$1"
113 subdir="$2"
114 shift
115 shift
116 lib="$2"
117
118 [ "$subdir" = '%' ] && subdir=''
119
120 if [ "$lib" != '--' ]
121 then
122  eval _no="\$no_lib_$lib";
123
124  if [ "$_no" != '' ]
125  then
126    echo "checking for $1... disabled by user"
127   [ "$subdir" != '' ] && \
128    echo "subdir_$subdir=" >&4
129   echo "lib_$lib=" >&4
130   return;
131  fi
132 fi
133
134 if test_lib $@
135 then
136  echo "#define $def"            >&3
137  [ "$subdir" != '' ] && \
138   echo "subdir_$subdir=$subdir" >&4
139  echo "lib_$lib=-l$lib" >&4
140 else
141  [ "$subdir" != '' ] && \
142   echo "subdir_$subdir=" >&4
143  echo "lib_$lib=" >&4
144 fi
145}
146
147exec 3> config.h 4> Makefile.conf
148
149if [ "$SYSNAME" = 'Darwin' ]
150then
151 echo "Adding $SYSNAME shared lib arguments..."
152 SHARED="$SHARED -fno-common -dynamiclib -compatibility_version 0.1 -current_version 0.1.0"
153 INCPATH="$INCPATH -fno-common"
154elif [ "$SYSNAME" = 'NetBSD' ]
155then
156 echo "Adding $SYSNAME libpath arguments..."
157 LDPATH="$LDPATH -L/usr/local/lib/"
158fi
159
160# now write the cc name to Makefile.conf
161echo "SHARED=$SHARED" >&4
162echo "CC=$CC" >&4
163echo "LDPATH=$LDPATH" >&4
164echo "INCPATH=$INCPATH" >&4
165
166CCTF="$CC $LDPATH $INCPATH -o $TF_E $TF_C"
167
168cat >&3 << EOF
169//config.h:
170
171#ifndef _ROARAUDIO_CONFIG_H_
172#define _ROARAUDIO_CONFIG_H_
173
174EOF
175
176{
177 echo '/* uname: ' $(uname -a) '*/'
178 echo '/* Date : ' $(date)  '*/'
179 echo
180} >&3
181
182test_lib 'Math Library' m          -- math.h                         && echo '#define ROAR_HAVE_LIBM' >&3
183if test_lib 'realtime Library' rt -- sys/mman.h mqueue.h semaphore.h
184then
185 {
186  echo '#define ROAR_HAVE_LIBRT'
187  echo '#define ROAR_NEED_LIBRT'
188 } >&3
189fi
190
191echo >&3
192
193#                #define                 subdir       name          -lxxx      -- header
194test_lib_defmake ROAR_HAVE_ESD           libroaresd   EsounD        esd        -- esd.h
195test_lib_defmake ROAR_HAVE_LIBAO         %            libao         ao         -- ao/ao.h ao/plugin.h
196test_lib_defmake ROAR_HAVE_LIBVORBIS     %            libvorbis     vorbis     -- vorbis/codec.h
197test_lib_defmake ROAR_HAVE_LIBVORBISFILE %            libvorbisfile vorbisfile -- vorbis/vorbisfile.h
198test_lib_defmake ROAR_HAVE_LIBVORBISENC  %            libvorbisenc  vorbisenc  -- vorbis/vorbisenc.h
199test_lib_defmake ROAR_HAVE_LIBSPEEX      %            libspeex      speex      -- speex/speex.h speex/speex_stereo.h
200test_lib_defmake ROAR_HAVE_LIBCELT       %            libcelt       celt       -- celt/celt.h celt/celt_header.h
201test_lib_defmake ROAR_HAVE_LIBOGGZ       %            liboggz       oggz       -- oggz/oggz.h
202test_lib_defmake ROAR_HAVE_LIBSNDFILE    %            libsndfile    sndfile    -- sndfile.h
203test_lib_defmake ROAR_HAVE_LIBFISHSOUND  roarfish     libfishsound  fishsound  -- fishsound/fishsound.h
204test_lib_defmake ROAR_HAVE_LIBSHOUT      %            libshout      shout      -- shout/shout.h
205test_lib_defmake ROAR_HAVE_LIBPULSE      libroarpulse libpulse      pulse      -- pulse/pulseaudio.h pulse/simple.h
206test_lib_defmake ROAR_HAVE_LIBY2         libroaryiff  libyiff       Y2         -- Y2/Y.h Y2/Ylib.h
207test_lib_defmake ROAR_HAVE_LIBARTSC      libroararts  libartsc      artsc      -- kde/artsc/artsc.h
208test_lib_defmake ROAR_HAVE_LIBDNET       %            libdnet       dnet       -- sys/socket.h netdnet/dn.h netdnet/dnetdb.h
209test_lib_defmake ROAR_HAVE_IPX           %            IPX                      -- netipx/ipx.h
210
211# add a better test here
212test_lib 'linux sendfile()'       -- sys/sendfile.h && echo '#define ROAR_HAVE_LINUX_SENDFILE' >&3
213
214
215echo -n 'checking for mlock()... '
216
217echo '#include <sys/mman.h>' > $TF_C
218echo 'int main (void) { mlock((void*)0, 0); return 0; }' >> $TF_C
219
220if $CCTF 2> /dev/null;
221then
222 echo '#define ROAR_HAVE_MLOCK' >&3
223 echo yes
224else
225 echo no
226fi
227
228echo -n 'checking for inline funcs... '
229
230echo 'inline int test (void) { return 0; }' > $TF_C
231echo 'int main (void) { return test(); }'  >> $TF_C
232
233if $CCTF 2> /dev/null;
234then
235 echo '#define ROAR_HAVE_INLINE' >&3
236 echo yes
237else
238 echo no
239fi
240
241echo -n 'checking for safe 32 bit integer overflow... '
242
243cat > $TF_C << EOF
244#include <stdio.h>
245#include <stdint.h>
246#define TYPE uint32_t
247#define MAX  ((TYPE)4294967295U)
248
249int main (void) {
250 TYPE a = MAX;
251
252 a += 2;
253
254 if ( a == 1 ) {
255  printf("#define ROAR_HAVE_SAFE_OVERFLOW\n");
256  return 0;
257 }
258
259 return 1;
260}
261EOF
262
263if $CCTF 2> /dev/null;
264then
265 $TF_E >&3
266 if [ "$?" = '0' ]
267 then
268  echo yes
269 else
270  echo no
271 fi
272else
273 echo 'no (can not compile!, no stdint.h?)'
274fi
275
276echo -n 'checking if cp supports -v... '
277if cp -v --help > /dev/null 2> /dev/null
278then
279 echo "cp_v=-v" >&4
280 echo yes
281else
282 echo "cp_v=" >&4
283 echo no
284fi
285
286
287cat >&3 << EOF
288
289#endif
290
291//ll
292EOF
293
294rm -f $TF_C $TF_E
295
296mv config.h include/roaraudio/
297echo 'config.h created and moved into include/roaraudio/'
298
299#ll
Note: See TracBrowser for help on using the repository browser.