source: roaraudio/configure @ 691:f2bf0e2577c9

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

some trys to get thinks working under MAC OS X

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