source: roaraudio/configure @ 426:a032dfca46cf

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

build only subdirs we know we can build

  • Property exe set to *
File size: 3.3 KB
Line 
1#!/bin/sh
2
3#set -x
4
5TF_C=testit.c
6TF_E=./testit
7CC=cc
8
9CCTF="$CC -o $TF_E $TF_C"
10
11test_lib () {
12 echo > $TF_C
13
14 echo -n "checking for $1... "
15 shift;
16
17 LIBS=''
18
19 while [ "$1" != '--' ]
20 do
21  LIBS="$LIBS -l$1"
22  shift;
23 done
24
25 shift;
26
27 while [ "$1" != '' ]
28 do
29  echo "#include <$1>" >> $TF_C
30  shift;
31 done
32
33 echo 'int main (void) { return 0; }' >> $TF_C
34
35 $CCTF $LIBS 2> /dev/null;
36
37 R=$?
38
39 if [ "$R" = '0' ]
40 then
41  echo 'yes'
42 else
43  echo 'no'
44 fi
45
46 return $R
47}
48
49test_lib_defmake () {
50 def="$1"
51 subdir="$2"
52 shift
53 shift
54
55 if test_lib $@
56 then
57  echo "#define $def"            >&3
58  [ "$subdir" != '' ] && \
59   echo "subdir_$subdir=$subdir" >&4
60 else
61  [ "$subdir" != '' ] && \
62   echo "subdir_$subdir=" >&4
63 fi
64}
65
66exec 3> config.h 4> Makefile.conf
67
68cat >&3 << EOF
69//config.h:
70
71#ifndef _ROARAUDIO_CONFIG_H_
72#define _ROARAUDIO_CONFIG_H_
73
74EOF
75
76{
77 echo '/* uname: ' $(uname -a) '*/'
78 echo '/* Date : ' $(date)  '*/'
79 echo
80} >&3
81
82test_lib 'Math Library' m          -- math.h                         && echo '#define ROAR_HAVE_LIBM' >&3
83if test_lib 'realtime Library' rt -- sys/mman.h mqueue.h semaphore.h
84then
85 {
86  echo '#define ROAR_HAVE_LIBRT'
87  echo '#define ROAR_NEED_LIBRT'
88 } >&3
89fi
90
91echo >&3
92
93test_lib_defmake ROAR_HAVE_ESD          libroaresd   EsounD         esd        -- esd.h
94test_lib libao          ao         -- ao/ao.h ao/plugin.h                && echo '#define ROAR_HAVE_LIBAO' >&3
95test_lib libvorbis      vorbis     -- vorbis/codec.h                     && echo '#define ROAR_HAVE_LIBVORBIS' >&3
96test_lib libvorbisfile  vorbisfile -- vorbis/vorbisfile.h                && echo '#define ROAR_HAVE_LIBVORBISFILE' >&3
97test_lib libspeex       speex      -- speex/speex.h speex/speex_stereo.h && echo '#define ROAR_HAVE_LIBSPEEX' >&3
98test_lib libcelt        celt       -- celt/celt.h celt/celt_header.h     && echo '#define ROAR_HAVE_LIBCELT' >&3
99test_lib liboggz        oggz       -- oggz/oggz.h                        && echo '#define ROAR_HAVE_LIBOGGZ' >&3
100test_lib libsndfile     sndfile    -- sndfile.h                          && echo '#define ROAR_HAVE_LIBSNDFILE' >&3
101test_lib_defmake ROAR_HAVE_LIBFISHSOUND roarfish     libfishsound   fishsound  -- fishsound/fishsound.h
102test_lib_defmake ROAR_HAVE_LIBPULSE     libroarpulse libpulse       pulse      -- pulse/pulseaudio.h pulse/simple.h
103test_lib_defmake ROAR_HAVE_LIBY2        libroaryiff  libyiff        Y2         -- Y2/Y.h Y2/Ylib.h
104
105# add a better test here
106test_lib 'linux sendfile()'       -- sys/sendfile.h && echo '#define ROAR_HAVE_LINUX_SENDFILE' >&3
107
108
109echo -n 'checking for mlock()... '
110
111echo '#include <sys/mman.h>' > $TF_C
112echo 'int main (void) { mlock((void*)0, 0); return 0; }' >> $TF_C
113
114if $CCTF 2> /dev/null;
115then
116 echo '#define ROAR_HAVE_MLOCK' >&3
117 echo yes
118else
119 echo no
120fi
121
122echo -n 'checking for safe 32 bit integer overflow... '
123
124cat > $TF_C << EOF
125#include <stdio.h>
126#include <stdint.h>
127#define TYPE uint32_t
128#define MAX  ((TYPE)4294967295U)
129
130int main (void) {
131 TYPE a = MAX;
132
133 a += 2;
134
135 if ( a == 1 ) {
136  printf("#define ROAR_HAVE_SAFE_OVERFLOW\n");
137  return 0;
138 }
139
140 return 1;
141}
142EOF
143
144if $CCTF 2> /dev/null;
145then
146 $TF_E >&3
147 if [ "$?" = '0' ]
148 then
149  echo yes
150 else
151  echo no
152 fi
153else
154 echo 'no (can not compile!, no stdint.h?)'
155fi
156
157cat >&3 << EOF
158
159#endif
160
161//ll
162EOF
163
164rm -f $TF_C $TF_E
165
166mv config.h include/roaraudio/
167echo 'config.h created and moved into include/roaraudio/'
168
169#ll
Note: See TracBrowser for help on using the repository browser.