source: roaraudio/configure @ 863:b7ef1e1038fd

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

added $PREFIX* to configure/Makefile.conf

  • Property exe set to *
File size: 9.8 KB
Line 
1#!/bin/sh
2
3# check for bash...
4
5if [ "$(echo -n)" = '-n' ]
6then
7 SHELL=$(which bash sh 2> /dev/null | grep ^/ | head -n 1)
8 exec $SHELL $0 "$@"
9fi
10
11
12#set -x
13
14TF_C=testit.c
15TF_E=./testit
16LDPATH=''
17INCPATH=''
18
19SYSNAME='unknown'
20SHARED='-shared'
21SHARED_CF=''
22PKG_CONFIG=false
23RUNTIME_DETECT=false
24
25PREFIX='/usr/local'
26PREFIX_BIN=''
27PREFIX_LIB=''
28PREFIX_INC=''
29PREFIX_MAN=''
30
31CDROM="none"
32PROC_NET_DECNET="/proc/net/decnet"
33
34echo -n "checking for C compiler... "
35CC=$(which gcc cc 2> /dev/null | grep ^/ | head -n 1)
36if [ "$CC" = '' ]
37then
38 echo 'none'
39 exit 1;
40fi
41echo $CC
42
43echo -n "checking for pkg-config... "
44PKG_CONFIG=$(which pkg-config false 2> /dev/null | grep ^/ | head -n 1)
45if $PKG_CONFIG --help > /dev/null 2> /dev/null
46then
47 echo $PKG_CONFIG
48else
49 echo no
50fi
51
52#Makefile.conf not yet open, write it later
53
54echo -n "checking for sysname... "
55SYSNAME=$(uname -s)
56echo "$SYSNAME"
57
58while [ "$1" != '' ]
59do
60 case "$1" in
61  '--help')
62   echo '--help                      - This Help'
63   echo '--ldpath DIR                - Add DIR to (compile time) search list for libs'
64   echo '--incpath DIR               - Add DIR to search list for headers'
65   echo '--addpath DIR               - Add DIR/lib to lib, DIR/include to header search list'
66   echo '--cdrom DEV                 - Set default CDRum device'
67   echo '--proc-net-decnet FILE      - Set DECnet file for DECnet support auto detecting'
68   echo '                              (ignore this on non-Linux)'
69   echo '--no-LIB                    - disable LIB'
70   echo '--runtime-detect            - do as much as posible auto detecting on runtime (for distributors)'
71   exit 0;
72  ;;
73  '--ldpath')
74   LDPATH="$LDPATH -L$2"
75   shift;
76  ;;
77  '--incpath')
78   INCPATH="$INCPATH -I$2"
79   shift;
80  ;;
81  '--addpath')
82   LDPATH="$LDPATH -L$2/lib/"
83   INCPATH="$INCPATH -I$2/include/"
84   shift;
85  ;;
86  '--cdrom')
87   CDROM="$2"
88   shift;
89  ;;
90  '--no-'*)
91   lib=$(echo "$1" | sed 's/^--no-//')
92   eval no_lib_$lib=true
93  ;;
94  '--runtime-detect')
95  RUNTIME_DETECT=true
96  ;;
97 esac;
98
99 shift;
100done
101
102
103CCTF="false"
104
105test_lib () {
106 echo > $TF_C
107
108 echo -n "checking for $1... "
109 shift;
110
111 LIBS=''
112
113 while [ "$1" != '--' ]
114 do
115  LIBS="$LIBS -l$1"
116  shift;
117 done
118
119 shift;
120
121 LIBS=$(echo "$LIBS" | sed 's/-l-l/-l/g; s/-l-L/-L/g;')
122
123 while [ "$1" != '' ]
124 do
125  echo "#include <$1>" >> $TF_C
126  shift;
127 done
128
129 echo 'int main (void) { return 0; }' >> $TF_C
130
131 $CCTF $LIBS 2> /dev/null;
132
133 R=$?
134
135 if [ "$R" = '0' ]
136 then
137  echo 'yes'
138 else
139  echo 'no'
140 fi
141
142 return $R
143}
144
145test_lib_defmake () {
146 def="$1"
147 subdir="$2"
148 shift
149 shift
150 name="$1"
151 lib="$2"
152 shift
153
154 [ "$subdir" = '%' ] && subdir=''
155
156 if [ "$lib" != '--' ]
157 then
158  eval _no="\$no_lib_$lib";
159
160  if [ "$_no" != '' ]
161  then
162    echo "checking for $1... disabled by user"
163   [ "$subdir" != '' ] && \
164    echo "subdir_$subdir=" >&4
165   echo "lib_$lib=" >&4
166   return;
167  fi
168 fi
169
170 LIBS=$($PKG_CONFIG --silence-errors --libs $lib)
171 if [ "$?" != '0' ]
172 then
173  LIBS="-l$lib"
174 fi
175
176 if test_lib "$name" $LIBS "$@"
177 then
178  echo "#define $def"            >&3
179  [ "$subdir" != '' ] && \
180   echo "subdir_$subdir=$subdir" >&4
181  echo "lib_$lib=$LIBS" >&4
182 else
183  [ "$subdir" != '' ] && \
184   echo "subdir_$subdir=" >&4
185  echo "lib_$lib=" >&4
186 fi
187}
188
189test_tool_defmake () {
190 DEF="$1"
191 NAME="$2"
192 shift;
193 shift;
194 echo -n "checking for $NAME... "
195
196 if $RUNTIME_DETECT
197 then
198  echo "$1 (runtime detect)"
199 echo "#define $DEF "\""$1"\" >&3
200 else
201
202  LIST=$(which "$@" 2> /dev/null | grep ^/ | head -n 1)
203
204  if [ "$LIST" = '' ]
205  then
206   echo 'no'
207  else
208   echo $LIST
209   echo "#define $DEF "\""$LIST"\" >&3
210  fi
211 fi
212}
213
214exec 3> config.h 4> Makefile.conf
215
216if [ "$SYSNAME" = 'Darwin' ]
217then
218 echo "Adding $SYSNAME shared lib arguments..."
219 SHARED="$SHARED -fno-common -dynamiclib -compatibility_version 0.1 -current_version 0.1.0"
220 SHARED_CF="$SHARED_CF -fno-common"
221elif [ "$SYSNAME" = 'NetBSD' ]
222then
223 echo "Adding $SYSNAME libpath arguments..."
224 LDPATH="$LDPATH -L/usr/local/lib/"
225fi
226
227[ "$PREFIX_BIN" = '' ] && PREFIX_BIN="$PREFIX/bin/"
228[ "$PREFIX_LIB" = '' ] && PREFIX_LIB="$PREFIX/lib/"
229[ "$PREFIX_INC" = '' ] && PREFIX_INC="$PREFIX/include/"
230[ "$PREFIX_MAN" = '' ] && PREFIX_MAN="$PREFIX/share/man/"
231
232# now write the cc name to Makefile.conf
233{
234 echo "SHARED=$SHARED"
235 echo "SHARED_CF=$SHARED_CF"
236 echo "CC=$CC"
237 echo "LDPATH=$LDPATH"
238 echo "INCPATH=$INCPATH"
239 echo "PREFIX=$PREFIX"
240 echo "PREFIX_BIN=$PREFIX_BIN"
241 echo "PREFIX_LIB=$PREFIX_LIB"
242 echo "PREFIX_INC=$PREFIX_INC"
243 echo "PREFIX_MAN=$PREFIX_MAN"
244} >&4
245
246CCTF="$CC $LDPATH $INCPATH -o $TF_E $TF_C"
247
248cat >&3 << EOF
249//config.h:
250
251#ifndef _ROARAUDIO_CONFIG_H_
252#define _ROARAUDIO_CONFIG_H_
253
254EOF
255
256{
257 echo '/* uname: ' $(uname -a) '*/'
258 echo '/* Date : ' $(date)  '*/'
259 echo
260} >&3
261
262#                 #define                  name         cmds...
263test_tool_defmake ROAR_HAVE_BIN_OGG123     ogg123       ogg123
264test_tool_defmake ROAR_HAVE_BIN_FLAC       flac         flac
265test_tool_defmake ROAR_HAVE_BIN_TIMIDITY   TiMidity++   timidity
266test_tool_defmake ROAR_HAVE_BIN_CDPARANOIA cdparanoia   cdparanoia
267test_tool_defmake ROAR_HAVE_BIN_WGET       Wget         wget
268
269echo >&3
270
271test_lib 'Math Library' m          -- math.h                         && echo '#define ROAR_HAVE_LIBM' >&3
272if test_lib 'realtime Library' rt -- sys/mman.h mqueue.h semaphore.h
273then
274 {
275  echo '#define ROAR_HAVE_LIBRT'
276  echo '#define ROAR_NEED_LIBRT'
277 } >&3
278fi
279
280echo >&3
281
282#                #define                 subdir       name          -lxxx      -- header
283test_lib_defmake ROAR_HAVE_ESD           libroaresd   EsounD        esd        -- esd.h
284test_lib_defmake ROAR_HAVE_LIBAO         %            libao         ao         -- ao/ao.h ao/plugin.h
285test_lib_defmake ROAR_HAVE_LIBVORBIS     %            libvorbis     vorbis     -- vorbis/codec.h
286test_lib_defmake ROAR_HAVE_LIBVORBISFILE %            libvorbisfile vorbisfile -- vorbis/vorbisfile.h
287test_lib_defmake ROAR_HAVE_LIBVORBISENC  %            libvorbisenc  vorbisenc  -- vorbis/vorbisenc.h
288test_lib_defmake ROAR_HAVE_LIBSPEEX      %            libspeex      speex      -- speex/speex.h speex/speex_stereo.h
289test_lib_defmake ROAR_HAVE_LIBCELT       %            libcelt       celt       -- celt/celt.h celt/celt_header.h
290test_lib_defmake ROAR_HAVE_LIBOGGZ       %            liboggz       oggz       -- oggz/oggz.h
291test_lib_defmake ROAR_HAVE_LIBSNDFILE    %            libsndfile    sndfile    -- sndfile.h
292test_lib_defmake ROAR_HAVE_LIBFISHSOUND  roarfish     libfishsound  fishsound  -- fishsound/fishsound.h
293test_lib_defmake ROAR_HAVE_LIBSHOUT      %            libshout      shout      -- shout/shout.h
294test_lib_defmake ROAR_HAVE_LIBPULSE      libroarpulse libpulse      pulse      -- pulse/pulseaudio.h pulse/simple.h
295test_lib_defmake ROAR_HAVE_LIBY2         libroaryiff  libyiff       Y2         -- Y2/Y.h Y2/Ylib.h
296test_lib_defmake ROAR_HAVE_LIBARTSC      libroararts  libartsc      artsc      -- kde/artsc/artsc.h
297test_lib_defmake ROAR_HAVE_LIBDNET       %            libdnet       dnet       -- sys/socket.h netdnet/dn.h netdnet/dnetdb.h
298test_lib_defmake ROAR_HAVE_IPX           %            IPX           c          -- netipx/ipx.h
299
300# add a better test here
301test_lib 'linux sendfile()'       -- sys/sendfile.h && echo '#define ROAR_HAVE_LINUX_SENDFILE' >&3
302
303
304echo -n 'checking for mlock()... '
305
306echo '#include <sys/mman.h>' > $TF_C
307echo 'int main (void) { mlock((void*)0, 0); return 0; }' >> $TF_C
308
309if $CCTF 2> /dev/null;
310then
311 echo '#define ROAR_HAVE_MLOCK' >&3
312 echo yes
313else
314 echo no
315fi
316
317echo -n 'checking for inline funcs... '
318
319echo 'inline int test (void) { return 0; }' > $TF_C
320echo 'int main (void) { return test(); }'  >> $TF_C
321
322if $CCTF 2> /dev/null;
323then
324 echo '#define ROAR_HAVE_INLINE' >&3
325 echo yes
326else
327 echo no
328fi
329
330echo -n 'checking for safe 32 bit integer overflow... '
331
332cat > $TF_C << EOF
333#include <stdio.h>
334#include <stdint.h>
335#define TYPE uint32_t
336#define MAX  ((TYPE)4294967295U)
337
338int main (void) {
339 TYPE a = MAX;
340
341 a += 2;
342
343 if ( a == 1 ) {
344  printf("#define ROAR_HAVE_SAFE_OVERFLOW\n");
345  return 0;
346 }
347
348 return 1;
349}
350EOF
351
352if $CCTF 2> /dev/null;
353then
354 $TF_E >&3
355 if [ "$?" = '0' ]
356 then
357  echo yes
358 else
359  echo no
360 fi
361else
362 echo 'no (can not compile!, no stdint.h?)'
363fi
364
365echo -n 'checking for __LP64__... '
366cat > $TF_C << EOF
367#include <stdio.h>
368
369int main (void) {
370#ifdef __LP64__
371 fprintf(stderr, "set by compiler\n");
372#else
373 if ( sizeof(int) == sizeof(void*) ) {
374  fprintf(stderr, "no need to set\n");
375 } else {
376  fprintf(stderr, "need to set\n");
377  printf("\n#ifndef __LP64__\n#define __LP64__\n#endif\n\n");
378 }
379#endif
380 return 0;
381}
382EOF
383if $CCTF 2> /dev/null;
384then
385 $TF_E >&3
386else
387 echo 'error, can not compile'
388 exit 1
389fi
390
391echo -n 'checking for 64 bit types... '
392cat > $TF_C << EOF
393#include <stdio.h>
394#include <stdint.h>
395
396int main (void) {
397 char * i64 = NULL, * ui64 = NULL;
398
399 if ( sizeof(int) == 8 ) {
400  i64 = "int"; ui64 = "unsigned int";
401 } else if ( sizeof(long int) == 8 ) {
402  i64 = "long int"; ui64 = "unsigned long int";
403 } else if ( sizeof(long long int) == 8 ) {
404  i64 = "long long int"; ui64 = "unsigned long long int";
405 } else if ( sizeof(int64_t) == 8 ) {
406  i64 = "int64_t"; ui64 = "uint64_t";
407 } else {
408  fprintf(stderr, "none\n");
409  return 0;
410 }
411
412 fprintf(stderr, "%s, %s\n", i64, ui64);
413 printf("#define ROAR_NATIVE_INT64 %s\n#define ROAR_NATIVE_UINT64 %s\n", i64, ui64);
414
415 return 0;
416}
417EOF
418if $CCTF 2> /dev/null;
419then
420 $TF_E >&3
421else
422 echo 'error, can not compile'
423 exit 1
424fi
425
426
427echo -n 'checking if cp supports -v... '
428if cp -v --help > /dev/null 2> /dev/null
429then
430 echo "cp_v=-v" >&4
431 echo yes
432else
433 echo "cp_v=" >&4
434 echo no
435fi
436
437echo -n 'checking for cdrom device... '
438if [ -e "$CDROM" ]
439then
440 echo "$CDROM"
441else
442 CDROM=$(ls /dev/cdrom /dev/rcd0c 2> /dev/null | head -n 1);
443 if [ -e "$CDROM" ]
444 then
445  echo "$CDROM"
446  echo '#define ROAR_DEFAULT_CDROM "'"$CDROM"'"' >&3
447 else
448  echo 'none'
449 fi
450fi
451
452echo 'checking for decnet status file... '"$PROC_NET_DECNET"
453echo '#define ROAR_PROC_NET_DECNET "'"$PROC_NET_DECNET"'"' >&3
454
455cat >&3 << EOF
456
457#endif
458
459//ll
460EOF
461
462rm -f $TF_C $TF_E
463
464mv config.h include/roaraudio/
465echo 'config.h created and moved into include/roaraudio/'
466
467#ll
Note: See TracBrowser for help on using the repository browser.