source: roaraudio/configure @ 748:cd6aeea28945

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

added support to check for addition tools

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