File: configure

package info (click to toggle)
muroard 0.1.14-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 420 kB
  • ctags: 424
  • sloc: ansic: 3,645; sh: 505; makefile: 113
file content (420 lines) | stat: -rwxr-xr-x 8,595 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
#!/bin/sh

# IDs officaly assigned
DEV_VENDOR=0
DEV_VENDOR_NAME='RoarAudio'
#--------

TF_C=testit.c
TF_E=./testit
LDPATH=''
INCPATH=''

PREFIX='/usr/local'
PREFIX_BIN=''
PREFIX_LIB=''
PREFIX_INC=''
PREFIX_MAN=''

SHARED='-shared'
SHARED_CF=''
SHARED_SUFFIX='.so'
fPIC=true
Wextra=false

BUILD_SHARED=true

TARGET_WIN32=false
TARGET_MICROCONTROLLER=false

DRIVER=''
DRIVER_LIBS=''

echo -n "checking for version of this package... "
VERSION=`head -n 1 ChangeLog | cut -d' ' -f2`
echo "$VERSION"

echo -n "checking for C compiler... "
if [ "$CC" != '' ]
then
 echo $CC
else
 CC=$(which gcc cc 2> /dev/null | grep ^/ | head -n 1)
 if [ "$CC" = '' ]
 then
  echo 'none'
  exit 1;
 fi
 echo $CC
fi

echo -n "checking for ranlib... "
if [ "$RANLIB" != '' ]
then
 echo $RANLIB
else
 _guess=`echo $CC | sed 's/[gp]*cc\(-.*\)*//'`
 RANLIB=$(which ${_guess}ranlib ranlib 2> /dev/null | grep ^/ | head -n 1)
 if [ "$RANLIB" = '' ]
 then
  echo 'none'
 fi
 echo $RANLIB
fi

echo -n "checking for sysname... "
SYSNAME=$(uname -s)
echo "$SYSNAME"

while [ "$1" != '' ]
do
 case "$1" in
  '--help'|'-h')
   echo '--help                      - This Help'
   echo
   echo '--ldpath DIR                - Add DIR to (compile time) search list for libs'
   echo '--incpath DIR               - Add DIR to search list for headers'
   echo '--addpath DIR               - Add DIR/lib to lib, DIR/include to header search list'
   echo
   echo '--cc CC                     - Set name of C compiler (CC) to CC'
   echo
   echo '--prefix DIR                - Set general prefix (default: '"$PREFIX"')'
   echo '--prefix-bin DIR            - Set prefix for binarys (default: $PREFIX/bin)'
   echo '--prefix-lib DIR            - Set prefix for librarys (default: $PREFIX/lib)'
   echo '--prefix-inc DIR            - Set prefix for include files (default: $PREFIX/include)'
   echo '--prefix-man DIR            - Set prefix for manpages (default: $PREFIX/share/man)'
   echo
   echo '--distribution-version-string STRING'
   echo '                            - Sets distribution part of version string'
   echo
   echo '--driver DRIVER             - Set the driver to use'
   echo
   echo '--target-win32              - Compile for win32'
   echo '--target-microcontroller    - Set Options for mircocontrollers without a OS'
   exit 0;
  ;;
  '--ldpath')
   LDPATH="$LDPATH -L$2"
   shift;
  ;;
  '--incpath')
   INCPATH="$INCPATH -I$2"
   shift;
  ;;
  '--addpath')
   LDPATH="$LDPATH -L$2/lib/"
   INCPATH="$INCPATH -I$2/include/"
   shift;
  ;;
  '--cc')
   CC="$2"
   shift;
  ;;
  '--prefix')
   PREFIX="$2"
   shift;
  ;;
  '--prefix-bin')
   PREFIX_BIN="$2"
   shift;
  ;;
  '--prefix-lib')
   PREFIX_LIB="$2"
   shift;
  ;;
  '--prefix-inc')
   PREFIX_INC="$2"
   shift;
  ;;
  '--prefix-man')
   PREFIX_MAN="$2"
   shift;
  ;;
####################################
# autof* options block:
  '--prefix=*')
   PREFIX=$(echo "$1" | cut -d= -f2)
  ;;
  '--prefix-bin=*')
   PREFIX_BIN=$(echo "$1" | cut -d= -f2)
  ;;
  '--prefix-lib=*')
   PREFIX_LIB=$(echo "$1" | cut -d= -f2)
  ;;
  '--prefix-inc=*')
   PREFIX_INC=$(echo "$1" | cut -d= -f2)
  ;;
  '--prefix-man=*')
   PREFIX_MAN=$(echo "$1" | cut -d= -f2)
  ;;
####################################
  '--distribution-version-string')
   DISTRIBUTION_VERSION_STRING="$2"
   shift;
  ;;
  '--driver')
   DRIVER="$2"
   shift;
  ;;
  '--target-win32')
   TARGET_WIN32=true
  ;;
  '--target-microcontroller')
   TARGET_MICROCONTROLLER=true
  ;;
  *)
   echo "Error: unknown option: $1" >&2;
   echo "Try: $0 --help" >&2;
   exit 1;
  ;;
 esac;

 shift;
done

exec 4> Makefile.conf 5> config.log

TARGET_WIN32=`echo  "$SYSNAME" | if grep MINGW32 > /dev/null; then echo true; else echo $TARGET_WIN32; fi`

if $TARGET_WIN32
then
 echo "Adding win32 build arguments..."
 fPIC=false
 SHARED_SUFFIX='.dll'
 BUILD_SHARED=false
 [ "$DRIVER" = '' ] && DRIVER='WMM'
elif [ "`uname -s`" = 'OpenBSD' ]
then
 echo "Adding OpenBSD build arguments..."
 [ "$DRIVER" = '' ] && DRIVER='OSS'
fi

if $TARGET_MICROCONTROLLER
then
 echo "Adding microcontroller build arguments..."
 BUILD_SHARED=false
fi

DRIVER=`echo "$DRIVER" | tr a-z A-Z`
case "$DRIVER" in
 'MUROAR')
  DRIVER_LIBS='$(lib_muroar)'
 ;;
 'ESD')
  DRIVER_LIBS='-lesd'
 ;;
 'LIBAO')
  DRIVER_LIBS='$(lib_ao)'
 ;;
 'OSS')
  : # no need to do anything
  # NOTE: some systems need -lossaudio or simular.
  #       users need to pass it in this case DRIVER_LIBS=-lossaudio make ...
  DRIVER_LIBS='$(lib_ossaudio)'
 ;;
 'WMM')
  DRIVER_LIBS='$(lib_winmm)'
 ;;
 'SNDIO')
  DRIVER_LIBS='-lsndio'
 ;;
 'TINYALSA')
  DRIVER_LIBS='-ltinyalsa'
 ;;
esac


CCTF="$CC $CFLAGS $LDFLAGS $LDPATH $INCPATH -o $TF_E $TF_C"

# Check for -Wextra
#Wextra
echo -n "checking if compiler supports -Wextra... "
echo 'int main (void) { return 0; }' > $TF_C
if $CCTF -Wextra 2> /dev/null;
then
 echo yes
 Wextra=true
else
 echo no
 Wextra=false
fi

[ "$PREFIX_BIN"  = '' ] && PREFIX_BIN="$PREFIX/bin/"
[ "$PREFIX_LIB"  = '' ] && PREFIX_LIB="$PREFIX/lib/"
[ "$PREFIX_INC"  = '' ] && PREFIX_INC="$PREFIX/include/"
[ "$PREFIX_MAN"  = '' ] && PREFIX_MAN="$PREFIX/share/man/"

{
 echo "EMPTY="
 echo "VERSION=$VERSION"
 echo "DEV_VENDOR=$DEV_VENDOR"
 echo "DEV_VENDOR_NAME=$DEV_VENDOR_NAME"
 echo "DEV_VENDOR_STRING=$DEV_VENDOR/$DEV_VENDOR_NAME"
 if [ "$DISTRIBUTION_VERSION_STRING" = '' ]
 then
  echo "DISTRIBUTION_VERSION_STRING="
 else
  echo "DISTRIBUTION_VERSION_STRING=\$(EMPTY) ($DISTRIBUTION_VERSION_STRING)"
 fi
 if [ "$DRIVER" = '' ]
 then
  echo "DRIVER_def="
 else
  echo "DRIVER_def=-DMUROARD_FEATURE_DRIVER=MUROARD_DRIVER_$DRIVER"
 fi
 echo "DRIVER_LIBS+=$DRIVER_LIBS"
 echo
 echo "SHARED=$SHARED"
 echo "SHARED_CF=$SHARED_CF"
 echo "SHARED_SUFFIX=$SHARED_SUFFIX"
 $fPIC && echo 'fPIC=-fPIC'
 $Wextra && echo 'Wextra=-Wextra'
 echo "BUILD_SHARED=$BUILD_SHARED"
 echo
 echo "CC=$CC"
 echo "RANLIB=$RANLIB"
 echo "LDPATH=$LDPATH"
 echo "INCPATH=$INCPATH"
 echo
 echo "CFLAGS=$CFLAGS"
 echo "LDPATH=$LDPATH"
 echo
 echo "PREFIX=$PREFIX"
 echo "PREFIX_BIN=$PREFIX_BIN"
 echo "PREFIX_LIB=$PREFIX_LIB"
 echo "PREFIX_INC=$PREFIX_INC"
 echo "PREFIX_MAN=$PREFIX_MAN"
 echo
 $TARGET_MICROCONTROLLER && echo "TARGET_MICROCONTROLLER=-DTARGET_MICROCONTROLLER"
} >&4

{
 cat <<'EOF'
//config.log:

/*
 * Logfile for configure script $Revision: 1.19 $ of ┬ÁRoarD
 */

EOF
 echo '/* uname: ' $(uname -a) '*/'
 echo '/* Date : ' $(date)  '*/'
 echo

 echo
 echo

 echo "ARGS(): $_CARGS"

 for i in PATH SHELL CC RANLIB PKG_CONFIG SYSNAME \
          TARGET_WIN32 TARGET_MICROCONTROLLER
 do
  eval echo "BASICCONF\($i\): \$$i";
 done

 echo
 echo
} >&5


test_lib () {
 echo > $TF_C

 name="$1"
 echo -n "checking for $name... "
 echo "TEST LIB: $name" >&5
 shift;

 lib="$1"

 LIBS=''

 while [ "$1" != '--' ]
 do
  case "$1" in
   'c'|'-lc')
    :; # no need to do anything
   ;;
   '-'*)
    LIBS="$LIBS $1"
   ;;
   *)
    LIBS="$LIBS -l$1"
   ;;
  esac
  shift;
 done

 shift;

 echo "LIB($name) IS TESTED USING LIBS: $LIBS" >&5

 while [ "$1" != '' ]
 do
  echo "#include <$1>" >> $TF_C
  shift;
 done

 echo 'int main (void) { return 0; }' >> $TF_C

 echo "LIB($name) IS TESTED USING TEST CODE:" >&5
 echo "--- BEGIN OF CODE BLOCK ---" >&5
 cat $TF_C >&5
 echo "--- END OF CODE BLOCK ---" >&5

 echo "LIB($name) HAS COMPILER/LINKER OUTPUT:" >&5
 echo "--- BEGIN OF CHILD OUTPUT BLOCK ---" >&5
 $CCTF $LIBS >&5 2>&5;
 R=$?
 echo "--- END OF CHILD OUTPUT BLOCK ---" >&5

 if [ "$R" = '0' ]
 then
  echo 'yes'
  echo "LIB($name) WAS FOUND" >&5
  if [ "$lib" != 'c' ]
  then
   echo "lib_$lib=$LIBS" >&4
   echo "def_$lib=-DHAVE_LIB_"`echo "$lib" | tr a-z A-Z` >&4
  fi
 else
  echo 'no'
  echo "LIB($name) NOT FOUND" >&5
 fi

 return $R
}


test_lib         DECnet        dnet             -- sys/socket.h netdnet/dn.h netdnet/dnetdb.h
test_lib         DECnetDaemon  dnet_daemon dnet -- sys/socket.h netdnet/dn.h netdnet/dnetdb.h
test_lib         WinSockP0     wsock32          -- winsock2.h
test_lib         WinSockP1     ws2_32           -- winsock2.h
test_lib         libao         ao               -- ao/ao.h
test_lib         BSDOSS        ossaudio         -- sys/ioctl.h
test_lib         libwinmm      winmm            -- windows.h mmsystem.h
test_lib         libvorbisfile vorbisfile       -- vorbis/vorbisfile.h
test_lib         muRoar        muroar           -- muroar.h
if [ "$?" != '0' ]
then
 echo "Error: can not find libmuroar" >&2
 exit 1
fi


echo -n 'checking if cp supports -v... '
if cp -v --help > /dev/null 2> /dev/null
then
 echo "cp_v=-v" >&4
 echo yes
else
 echo "cp_v=" >&4
 echo no
fi

echo >&5
echo '//ll' >&5

rm -f $TF_C $TF_E

#ll