source: roaraudio/configure @ 475:c5c9b2f8b848

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

use cp -v only if cp accepts -v

  • Property exe set to *
File size: 3.6 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 lib="$2"
55
56 [ "$subdir" = '%' ] && subdir=''
57
58 if test_lib $@
59 then
60  echo "#define $def"            >&3
61  [ "$subdir" != '' ] && \
62   echo "subdir_$subdir=$subdir" >&4
63  echo "lib_$lib=-l$lib" >&4
64 else
65  [ "$subdir" != '' ] && \
66   echo "subdir_$subdir=" >&4
67  echo "lib_$lib=" >&4
68 fi
69}
70
71exec 3> config.h 4> Makefile.conf
72
73cat >&3 << EOF
74//config.h:
75
76#ifndef _ROARAUDIO_CONFIG_H_
77#define _ROARAUDIO_CONFIG_H_
78
79EOF
80
81{
82 echo '/* uname: ' $(uname -a) '*/'
83 echo '/* Date : ' $(date)  '*/'
84 echo
85} >&3
86
87test_lib 'Math Library' m          -- math.h                         && echo '#define ROAR_HAVE_LIBM' >&3
88if test_lib 'realtime Library' rt -- sys/mman.h mqueue.h semaphore.h
89then
90 {
91  echo '#define ROAR_HAVE_LIBRT'
92  echo '#define ROAR_NEED_LIBRT'
93 } >&3
94fi
95
96echo >&3
97
98test_lib_defmake ROAR_HAVE_ESD           libroaresd   EsounD         esd        -- esd.h
99test_lib_defmake ROAR_HAVE_LIBAO         %            libao          ao         -- ao/ao.h ao/plugin.h
100test_lib_defmake ROAR_HAVE_LIBVORBIS     %            libvorbis      vorbis     -- vorbis/codec.h
101test_lib_defmake ROAR_HAVE_LIBVORBISFILE %           libvorbisfile  vorbisfile -- vorbis/vorbisfile.h
102test_lib_defmake ROAR_HAVE_LIBSPEEX      %            libspeex       speex      -- speex/speex.h speex/speex_stereo.h
103test_lib_defmake ROAR_HAVE_LIBCELT       %            libcelt        celt       -- celt/celt.h celt/celt_header.h
104test_lib_defmake ROAR_HAVE_LIBOGGZ       %            liboggz        oggz       -- oggz/oggz.h
105test_lib_defmake ROAR_HAVE_LIBSNDFILE    %            libsndfile     sndfile    -- sndfile.h
106test_lib_defmake ROAR_HAVE_LIBFISHSOUND  roarfish     libfishsound   fishsound  -- fishsound/fishsound.h
107test_lib_defmake ROAR_HAVE_LIBPULSE      libroarpulse libpulse       pulse      -- pulse/pulseaudio.h pulse/simple.h
108test_lib_defmake ROAR_HAVE_LIBY2         libroaryiff  libyiff        Y2         -- Y2/Y.h Y2/Ylib.h
109test_lib_defmake ROAR_HAVE_LIBARTSC      libroararts  libartsc       artsc      -- kde/artsc/artsc.h
110
111# add a better test here
112test_lib 'linux sendfile()'       -- sys/sendfile.h && echo '#define ROAR_HAVE_LINUX_SENDFILE' >&3
113
114
115echo -n 'checking for mlock()... '
116
117echo '#include <sys/mman.h>' > $TF_C
118echo 'int main (void) { mlock((void*)0, 0); return 0; }' >> $TF_C
119
120if $CCTF 2> /dev/null;
121then
122 echo '#define ROAR_HAVE_MLOCK' >&3
123 echo yes
124else
125 echo no
126fi
127
128echo -n 'checking for safe 32 bit integer overflow... '
129
130cat > $TF_C << EOF
131#include <stdio.h>
132#include <stdint.h>
133#define TYPE uint32_t
134#define MAX  ((TYPE)4294967295U)
135
136int main (void) {
137 TYPE a = MAX;
138
139 a += 2;
140
141 if ( a == 1 ) {
142  printf("#define ROAR_HAVE_SAFE_OVERFLOW\n");
143  return 0;
144 }
145
146 return 1;
147}
148EOF
149
150if $CCTF 2> /dev/null;
151then
152 $TF_E >&3
153 if [ "$?" = '0' ]
154 then
155  echo yes
156 else
157  echo no
158 fi
159else
160 echo 'no (can not compile!, no stdint.h?)'
161fi
162
163echo -n 'checking if cp supports -v... '
164if cp -v --help > /dev/null 2> /dev/null
165then
166 echo "cp_v=-v" >&4
167 echo yes
168else
169 echo "cp_v=" >&4
170 echo no
171fi
172
173
174cat >&3 << EOF
175
176#endif
177
178//ll
179EOF
180
181rm -f $TF_C $TF_E
182
183mv config.h include/roaraudio/
184echo 'config.h created and moved into include/roaraudio/'
185
186#ll
Note: See TracBrowser for help on using the repository browser.