source: roaraudio/configure @ 743:63c72d2a996d

Last change on this file since 743:63c72d2a996d was 730:b43149bb9cb3, checked in by phi, 16 years ago

introdused $(SHARED_CF)

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