source: roaraudio/configure @ 706:6627e0732b98

Last change on this file since 706:6627e0732b98 was 698:eed06bd91e11, checked in by phi, 16 years ago

got lib=-- working for and not do a false positive for --no-*

  • Property exe set to *
File size: 5.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 | 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="$CC $LDPATH $INCPATH -o $TF_E $TF_C"
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
149# now write the cc name to Makefile.conf
150echo "CC=$CC" >&4
151echo "LDPATH=$LDPATH" >&4
152echo "INCPATH=$INCPATH" >&4
153
154if [ "$SYSNAME" = 'Darwin' ]
155then
156 echo "Adding $SYSNAME shared lib arguments..."
157 SHARED="$SHARED -fno-common -dynamiclib -compatibility_version 0.1 -current_version 0.1.0"
158 INCPATH="$INCPATH -fno-common"
159fi
160
161echo "SHARED=$SHARED" >&4
162
163cat >&3 << EOF
164//config.h:
165
166#ifndef _ROARAUDIO_CONFIG_H_
167#define _ROARAUDIO_CONFIG_H_
168
169EOF
170
171{
172 echo '/* uname: ' $(uname -a) '*/'
173 echo '/* Date : ' $(date)  '*/'
174 echo
175} >&3
176
177test_lib 'Math Library' m          -- math.h                         && echo '#define ROAR_HAVE_LIBM' >&3
178if test_lib 'realtime Library' rt -- sys/mman.h mqueue.h semaphore.h
179then
180 {
181  echo '#define ROAR_HAVE_LIBRT'
182  echo '#define ROAR_NEED_LIBRT'
183 } >&3
184fi
185
186echo >&3
187
188#                #define                 subdir       name          -lxxx      -- header
189test_lib_defmake ROAR_HAVE_ESD           libroaresd   EsounD        esd        -- esd.h
190test_lib_defmake ROAR_HAVE_LIBAO         %            libao         ao         -- ao/ao.h ao/plugin.h
191test_lib_defmake ROAR_HAVE_LIBVORBIS     %            libvorbis     vorbis     -- vorbis/codec.h
192test_lib_defmake ROAR_HAVE_LIBVORBISFILE %            libvorbisfile vorbisfile -- vorbis/vorbisfile.h
193test_lib_defmake ROAR_HAVE_LIBVORBISENC  %            libvorbisenc  vorbisenc  -- vorbis/vorbisenc.h
194test_lib_defmake ROAR_HAVE_LIBSPEEX      %            libspeex      speex      -- speex/speex.h speex/speex_stereo.h
195test_lib_defmake ROAR_HAVE_LIBCELT       %            libcelt       celt       -- celt/celt.h celt/celt_header.h
196test_lib_defmake ROAR_HAVE_LIBOGGZ       %            liboggz       oggz       -- oggz/oggz.h
197test_lib_defmake ROAR_HAVE_LIBSNDFILE    %            libsndfile    sndfile    -- sndfile.h
198test_lib_defmake ROAR_HAVE_LIBFISHSOUND  roarfish     libfishsound  fishsound  -- fishsound/fishsound.h
199test_lib_defmake ROAR_HAVE_LIBSHOUT      %            libshout      shout      -- shout/shout.h
200test_lib_defmake ROAR_HAVE_LIBPULSE      libroarpulse libpulse      pulse      -- pulse/pulseaudio.h pulse/simple.h
201test_lib_defmake ROAR_HAVE_LIBY2         libroaryiff  libyiff       Y2         -- Y2/Y.h Y2/Ylib.h
202test_lib_defmake ROAR_HAVE_LIBARTSC      libroararts  libartsc      artsc      -- kde/artsc/artsc.h
203test_lib_defmake ROAR_HAVE_LIBDNET       %            libdnet       dnet       -- sys/socket.h netdnet/dn.h netdnet/dnetdb.h
204test_lib_defmake ROAR_HAVE_IPX           %            IPX                      -- netipx/ipx.h
205
206# add a better test here
207test_lib 'linux sendfile()'       -- sys/sendfile.h && echo '#define ROAR_HAVE_LINUX_SENDFILE' >&3
208
209
210echo -n 'checking for mlock()... '
211
212echo '#include <sys/mman.h>' > $TF_C
213echo 'int main (void) { mlock((void*)0, 0); return 0; }' >> $TF_C
214
215if $CCTF 2> /dev/null;
216then
217 echo '#define ROAR_HAVE_MLOCK' >&3
218 echo yes
219else
220 echo no
221fi
222
223echo -n 'checking for inline funcs... '
224
225echo 'inline int test (void) { return 0; }' > $TF_C
226echo 'int main (void) { return test(); }'  >> $TF_C
227
228if $CCTF 2> /dev/null;
229then
230 echo '#define ROAR_HAVE_INLINE' >&3
231 echo yes
232else
233 echo no
234fi
235
236echo -n 'checking for safe 32 bit integer overflow... '
237
238cat > $TF_C << EOF
239#include <stdio.h>
240#include <stdint.h>
241#define TYPE uint32_t
242#define MAX  ((TYPE)4294967295U)
243
244int main (void) {
245 TYPE a = MAX;
246
247 a += 2;
248
249 if ( a == 1 ) {
250  printf("#define ROAR_HAVE_SAFE_OVERFLOW\n");
251  return 0;
252 }
253
254 return 1;
255}
256EOF
257
258if $CCTF 2> /dev/null;
259then
260 $TF_E >&3
261 if [ "$?" = '0' ]
262 then
263  echo yes
264 else
265  echo no
266 fi
267else
268 echo 'no (can not compile!, no stdint.h?)'
269fi
270
271echo -n 'checking if cp supports -v... '
272if cp -v --help > /dev/null 2> /dev/null
273then
274 echo "cp_v=-v" >&4
275 echo yes
276else
277 echo "cp_v=" >&4
278 echo no
279fi
280
281
282cat >&3 << EOF
283
284#endif
285
286//ll
287EOF
288
289rm -f $TF_C $TF_E
290
291mv config.h include/roaraudio/
292echo 'config.h created and moved into include/roaraudio/'
293
294#ll
Note: See TracBrowser for help on using the repository browser.