source: roaraudio/configure @ 696:07dc9f9b3b2e

Last change on this file since 696:07dc9f9b3b2e was 696:07dc9f9b3b2e, checked in by phi, 16 years ago

added --no-*

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