source: roaraudio/configure @ 693:3890159b8bf6

Last change on this file since 693:3890159b8bf6 was 693:3890159b8bf6, checked in by phi, 16 years ago

let the output of configure look correct on MAC OS X :)

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