source: roaraudio/configure @ 727:7347928b02db

Last change on this file since 727:7347928b02db was 727:7347928b02db, checked in by phi, 16 years ago

which behaves diffrently on NetBSD... *grrr*

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