source: roaraudio/configure @ 499:4b162c373ea8

Last change on this file since 499:4b162c373ea8 was 499:4b162c373ea8, checked in by phi, 16 years ago

added libdnet to configure

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