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
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
[750]23RUNTIME_DETECT=false
[691]24
[863]25PREFIX='/usr/local'
26PREFIX_BIN=''
27PREFIX_LIB=''
28PREFIX_INC=''
29PREFIX_MAN=''
30
[804]31CDROM="none"
[827]32PROC_NET_DECNET="/proc/net/decnet"
[804]33
[484]34echo -n "checking for C compiler... "
[727]35CC=$(which gcc cc 2> /dev/null | grep ^/ | head -n 1)
[484]36if [ "$CC" = '' ]
37then
38 echo 'none'
39 exit 1;
40fi
41echo $CC
42
[725]43echo -n "checking for pkg-config... "
[727]44PKG_CONFIG=$(which pkg-config false 2> /dev/null | grep ^/ | head -n 1)
[725]45if $PKG_CONFIG --help > /dev/null 2> /dev/null
46then
47 echo $PKG_CONFIG
48else
49 echo no
50fi
51
[484]52#Makefile.conf not yet open, write it later
53
[691]54echo -n "checking for sysname... "
55SYSNAME=$(uname -s)
56echo "$SYSNAME"
[353]57
[484]58while [ "$1" != '' ]
59do
60 case "$1" in
61  '--help')
[862]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)'
[484]71   exit 0;
72  ;;
73  '--ldpath')
74   LDPATH="$LDPATH -L$2"
75   shift;
76  ;;
[553]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  ;;
[804]86  '--cdrom')
87   CDROM="$2"
88   shift;
89  ;;
[696]90  '--no-'*)
91   lib=$(echo "$1" | sed 's/^--no-//')
92   eval no_lib_$lib=true
93  ;;
[750]94  '--runtime-detect')
95  RUNTIME_DETECT=true
96  ;;
[484]97 esac;
98
99 shift;
100done
101
102
[714]103CCTF="false"
[353]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
[751]121 LIBS=$(echo "$LIBS" | sed 's/-l-l/-l/g; s/-l-L/-L/g;')
[725]122
[353]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
[426]145test_lib_defmake () {
146 def="$1"
147 subdir="$2"
148 shift
149 shift
[725]150 name="$1"
[428]151 lib="$2"
[725]152 shift
[426]153
[429]154 [ "$subdir" = '%' ] && subdir=''
155
[698]156 if [ "$lib" != '--' ]
[696]157 then
[698]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
[696]168 fi
169
[725]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 "$@"
[426]177 then
178  echo "#define $def"            >&3
179  [ "$subdir" != '' ] && \
180   echo "subdir_$subdir=$subdir" >&4
[725]181  echo "lib_$lib=$LIBS" >&4
[426]182 else
183  [ "$subdir" != '' ] && \
184   echo "subdir_$subdir=" >&4
[428]185  echo "lib_$lib=" >&4
[426]186 fi
187}
188
[748]189test_tool_defmake () {
190 DEF="$1"
191 NAME="$2"
192 shift;
193 shift;
194 echo -n "checking for $NAME... "
195
[750]196 if $RUNTIME_DETECT
[748]197 then
[750]198  echo "$1 (runtime detect)"
199 echo "#define $DEF "\""$1"\" >&3
[748]200 else
[750]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
[748]211 fi
212}
213
[426]214exec 3> config.h 4> Makefile.conf
[353]215
[691]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"
[730]220 SHARED_CF="$SHARED_CF -fno-common"
[713]221elif [ "$SYSNAME" = 'NetBSD' ]
222then
223 echo "Adding $SYSNAME libpath arguments..."
224 LDPATH="$LDPATH -L/usr/local/lib/"
[691]225fi
226
[863]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
[714]232# now write the cc name to Makefile.conf
[863]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
[714]245
246CCTF="$CC $LDPATH $INCPATH -o $TF_E $TF_C"
[691]247
[353]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
[803]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
[860]267test_tool_defmake ROAR_HAVE_BIN_WGET       Wget         wget
[748]268
269echo >&3
270
[360]271test_lib 'Math Library' m          -- math.h                         && echo '#define ROAR_HAVE_LIBM' >&3
[363]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
[500]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
[568]287test_lib_defmake ROAR_HAVE_LIBVORBISENC  %            libvorbisenc  vorbisenc  -- vorbis/vorbisenc.h
[500]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
[604]293test_lib_defmake ROAR_HAVE_LIBSHOUT      %            libshout      shout      -- shout/shout.h
[500]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
[725]298test_lib_defmake ROAR_HAVE_IPX           %            IPX           c          -- netipx/ipx.h
[353]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
[697]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
[420]330echo -n 'checking for safe 32 bit integer overflow... '
[354]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
[781]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
[853]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
[475]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
[804]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
[475]451
[843]452echo 'checking for decnet status file... '"$PROC_NET_DECNET"
[827]453echo '#define ROAR_PROC_NET_DECNET "'"$PROC_NET_DECNET"'"' >&3
454
[353]455cat >&3 << EOF
456
457#endif
458
459//ll
460EOF
461
[354]462rm -f $TF_C $TF_E
[353]463
[359]464mv config.h include/roaraudio/
465echo 'config.h created and moved into include/roaraudio/'
466
[353]467#ll
Note: See TracBrowser for help on using the repository browser.