source: roaraudio/configure @ 750:cd3a83df2083

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

added --runtime-detect

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