source: roaraudio/configure @ 500:9646e437f5a1

Last change on this file since 500:9646e437f5a1 was 500:9646e437f5a1, checked in by phi, 16 years ago

rearranched spaces a bit and added header for table

  • Property exe set to *
File size: 4.2 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
132#                #define                 subdir       name          -lxxx      -- header
133test_lib_defmake ROAR_HAVE_ESD           libroaresd   EsounD        esd        -- esd.h
134test_lib_defmake ROAR_HAVE_LIBAO         %            libao         ao         -- ao/ao.h ao/plugin.h
135test_lib_defmake ROAR_HAVE_LIBVORBIS     %            libvorbis     vorbis     -- vorbis/codec.h
136test_lib_defmake ROAR_HAVE_LIBVORBISFILE %            libvorbisfile vorbisfile -- vorbis/vorbisfile.h
137test_lib_defmake ROAR_HAVE_LIBSPEEX      %            libspeex      speex      -- speex/speex.h speex/speex_stereo.h
138test_lib_defmake ROAR_HAVE_LIBCELT       %            libcelt       celt       -- celt/celt.h celt/celt_header.h
139test_lib_defmake ROAR_HAVE_LIBOGGZ       %            liboggz       oggz       -- oggz/oggz.h
140test_lib_defmake ROAR_HAVE_LIBSNDFILE    %            libsndfile    sndfile    -- sndfile.h
141test_lib_defmake ROAR_HAVE_LIBFISHSOUND  roarfish     libfishsound  fishsound  -- fishsound/fishsound.h
142test_lib_defmake ROAR_HAVE_LIBPULSE      libroarpulse libpulse      pulse      -- pulse/pulseaudio.h pulse/simple.h
143test_lib_defmake ROAR_HAVE_LIBY2         libroaryiff  libyiff       Y2         -- Y2/Y.h Y2/Ylib.h
144test_lib_defmake ROAR_HAVE_LIBARTSC      libroararts  libartsc      artsc      -- kde/artsc/artsc.h
145test_lib_defmake ROAR_HAVE_LIBDNET       %            libdnet       dnet       -- sys/socket.h netdnet/dn.h netdnet/dnetdb.h
146
147# add a better test here
148test_lib 'linux sendfile()'       -- sys/sendfile.h && echo '#define ROAR_HAVE_LINUX_SENDFILE' >&3
149
150
151echo -n 'checking for mlock()... '
152
153echo '#include <sys/mman.h>' > $TF_C
154echo 'int main (void) { mlock((void*)0, 0); return 0; }' >> $TF_C
155
156if $CCTF 2> /dev/null;
157then
158 echo '#define ROAR_HAVE_MLOCK' >&3
159 echo yes
160else
161 echo no
162fi
163
164echo -n 'checking for safe 32 bit integer overflow... '
165
166cat > $TF_C << EOF
167#include <stdio.h>
168#include <stdint.h>
169#define TYPE uint32_t
170#define MAX  ((TYPE)4294967295U)
171
172int main (void) {
173 TYPE a = MAX;
174
175 a += 2;
176
177 if ( a == 1 ) {
178  printf("#define ROAR_HAVE_SAFE_OVERFLOW\n");
179  return 0;
180 }
181
182 return 1;
183}
184EOF
185
186if $CCTF 2> /dev/null;
187then
188 $TF_E >&3
189 if [ "$?" = '0' ]
190 then
191  echo yes
192 else
193  echo no
194 fi
195else
196 echo 'no (can not compile!, no stdint.h?)'
197fi
198
199echo -n 'checking if cp supports -v... '
200if cp -v --help > /dev/null 2> /dev/null
201then
202 echo "cp_v=-v" >&4
203 echo yes
204else
205 echo "cp_v=" >&4
206 echo no
207fi
208
209
210cat >&3 << EOF
211
212#endif
213
214//ll
215EOF
216
217rm -f $TF_C $TF_E
218
219mv config.h include/roaraudio/
220echo 'config.h created and moved into include/roaraudio/'
221
222#ll
Note: See TracBrowser for help on using the repository browser.