source: roaraudio/configure @ 484:f5f98f005601

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

updated configure script to search for cc and add a way to add -Ls to ld

  • Property exe set to *
File size: 4.0 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
144
145# add a better test here
146test_lib 'linux sendfile()'       -- sys/sendfile.h && echo '#define ROAR_HAVE_LINUX_SENDFILE' >&3
147
148
149echo -n 'checking for mlock()... '
150
151echo '#include <sys/mman.h>' > $TF_C
152echo 'int main (void) { mlock((void*)0, 0); return 0; }' >> $TF_C
153
154if $CCTF 2> /dev/null;
155then
156 echo '#define ROAR_HAVE_MLOCK' >&3
157 echo yes
158else
159 echo no
160fi
161
162echo -n 'checking for safe 32 bit integer overflow... '
163
164cat > $TF_C << EOF
165#include <stdio.h>
166#include <stdint.h>
167#define TYPE uint32_t
168#define MAX  ((TYPE)4294967295U)
169
170int main (void) {
171 TYPE a = MAX;
172
173 a += 2;
174
175 if ( a == 1 ) {
176  printf("#define ROAR_HAVE_SAFE_OVERFLOW\n");
177  return 0;
178 }
179
180 return 1;
181}
182EOF
183
184if $CCTF 2> /dev/null;
185then
186 $TF_E >&3
187 if [ "$?" = '0' ]
188 then
189  echo yes
190 else
191  echo no
192 fi
193else
194 echo 'no (can not compile!, no stdint.h?)'
195fi
196
197echo -n 'checking if cp supports -v... '
198if cp -v --help > /dev/null 2> /dev/null
199then
200 echo "cp_v=-v" >&4
201 echo yes
202else
203 echo "cp_v=" >&4
204 echo no
205fi
206
207
208cat >&3 << EOF
209
210#endif
211
212//ll
213EOF
214
215rm -f $TF_C $TF_E
216
217mv config.h include/roaraudio/
218echo 'config.h created and moved into include/roaraudio/'
219
220#ll
Note: See TracBrowser for help on using the repository browser.