comparison libdlna-0.2.3/configure @ 129:4f6d9621ee00

add multi session streaming & add depending librarys. - libupnp-1.6.6 - libdlna-0.2.3
author Naoya OYAMA <naoya.oyama@gmail.com>
date Sun, 10 Oct 2010 15:33:18 +0900
parents
children
comparison
equal deleted inserted replaced
128:3a7d8d2f0585 129:4f6d9621ee00
1 #!/bin/sh
2 #
3 # libdlna configure script - (c) 2007 Benjamin Zores
4 #
5 # (fully inspirated from ffmpeg configure script, thanks to Fabrice Bellard)
6 #
7
8 # make sure we are running under a compatible shell
9 unset foo
10 (: ${foo%%bar}) 2>/dev/null && ! (: ${foo?}) 2>/dev/null
11 if test "$?" != 0; then
12 if test "x$OMC_CONFIGURE_EXEC" = x; then
13 OMC_CONFIGURE_EXEC=1
14 export OMC_CONFIGURE_EXEC
15 exec bash "$0" "$@"
16 exec ksh "$0" "$@"
17 exec /usr/xpg4/bin/sh "$0" "$@"
18 fi
19 echo "No compatible shell script interpreter found."
20 exit 1
21 fi
22
23 show_help(){
24 echo "Usage: configure [options]"
25 echo "Options: [defaults in brackets after descriptions]"
26 echo
27 echo "Standard options:"
28 echo " --help print this message"
29 echo " --log[=FILE|yes|no] log tests and output to FILE [config.log]"
30 echo " --prefix=PREFIX install in PREFIX [$PREFIX]"
31 echo " --libdir=DIR install libs in DIR [PREFIX/lib]"
32 echo " --includedir=DIR install includes in DIR [PREFIX/include]"
33 echo " --enable-static build static libraries [default=yes]"
34 echo " --disable-static do not build static libraries [default=no]
35 "
36 echo " --enable-shared build shared libraries [default=yes]"
37 echo " --disable-shared do not build shared libraries [default=no]"
38 echo " --with-ffmpeg-dir=DIR check for ffmpeg installed in DIR"
39 echo ""
40 echo "Advanced options (experts only):"
41 echo " --enable-debug enable debugging symbols"
42 echo " --disable-debug disable debugging symbols"
43 echo " --disable-strip disable stripping of executables at installation"
44 echo " --disable-optimize disable compiler optimization"
45 echo " --cross-prefix=PREFIX use PREFIX for compilation tools [$cross_prefix]"
46 echo " --cross-compile assume a cross-compiler is used"
47 exit 1
48 }
49
50 log(){
51 echo "$@" >>$logfile
52 }
53
54 log_file(){
55 log BEGIN $1
56 cat -n $1 >>$logfile
57 log END $1
58 }
59
60 echolog(){
61 log "$@"
62 echo "$@"
63 }
64
65 clean(){
66 rm -f $TMPC $TMPO $TMPE $TMPS
67 }
68
69 die(){
70 echolog "$@"
71 if enabled logging; then
72 echo "See file \"$logfile\" produced by configure for more details."
73 else
74 echo "Rerun configure with logging enabled (do not use --log=no) for more details."
75 fi
76 clean
77 exit 1
78 }
79
80 enabled(){
81 eval test "x\$$1" = "xyes"
82 }
83
84 flags_saved(){
85 (: ${SAVE_CFLAGS?}) 2>/dev/null
86 }
87
88 save_flags(){
89 flags_saved && return
90 SAVE_CFLAGS="$CFLAGS"
91 SAVE_LDFLAGS="$LDFLAGS"
92 SAVE_extralibs="$extralibs"
93 }
94
95 restore_flags(){
96 CFLAGS="$SAVE_CFLAGS"
97 LDFLAGS="$SAVE_LDFLAGS"
98 extralibs="$SAVE_extralibs"
99 unset SAVE_CFLAGS
100 unset SAVE_LDFLAGS
101 unset SAVE_extralibs
102 }
103
104 temp_cflags(){
105 temp_append CFLAGS "$@"
106 }
107
108 temp_ldflags(){
109 temp_append LDFLAGS "$@"
110 }
111
112 temp_extralibs(){
113 temp_append extralibs "$@"
114 }
115
116 temp_append(){
117 local var
118 var=$1
119 shift
120 save_flags
121 append_var "$var" "$@"
122 }
123
124 append_var(){
125 local var f
126 var=$1
127 shift
128 for f in $@; do
129 if eval echo \$$var | grep -qv -e "$f"; then
130 eval "$var=\"\$$var $f\""
131 fi
132 done
133 }
134
135 append(){
136 local var
137 var=$1
138 shift
139 flags_saved && append_var "SAVE_$var" "$@"
140 append_var "$var" "$@"
141 }
142
143 add_cflags(){
144 append CFLAGS "$@"
145 }
146
147 add_ldflags(){
148 append LDFLAGS "$@"
149 }
150
151 add_extralibs(){
152 append extralibs "$@"
153 }
154
155 check_cmd(){
156 log "$@"
157 "$@" >>$logfile 2>&1
158 }
159
160 check_cc(){
161 log check_cc "$@"
162 cat >$TMPC
163 log_file $TMPC
164 check_cmd $cc $CFLAGS "$@" -c -o $TMPO $TMPC
165 }
166
167 check_cpp(){
168 log check_cpp "$@"
169 cat >$TMPC
170 log_file $TMPC
171 check_cmd $cc $CFLAGS "$@" -E -o $TMPO $TMPC
172 }
173
174 check_ld(){
175 log check_ld "$@"
176 check_cc || return
177 check_cmd $cc $LDFLAGS "$@" -o $TMPE $TMPO $extralibs
178 }
179
180 check_exec(){
181 check_ld "$@" && { enabled cross_compile || $TMPE >>$logfile 2>&1; }
182 }
183
184 check_cflags(){
185 log check_cflags "$@"
186 check_cc "$@" <<EOF && add_cflags "$@"
187 int x;
188 EOF
189 }
190
191 check_ldflags(){
192 log check_ldflags "$@"
193 check_ld "$@" <<EOF && add_ldflags "$@"
194 int main(){
195 return 0;
196 }
197 EOF
198 }
199
200 check_header(){
201 local header
202 log check_header "$@"
203 header=$1
204 shift
205 check_cpp "$@" <<EOF
206 #include <$header>
207 int x;
208 EOF
209 }
210
211 check_func(){
212 local func
213 log check_func "$@"
214 func=$1
215 shift
216 check_ld "$@" <<EOF
217 extern int $func();
218 int main(){
219 $func();
220 return 0;
221 }
222 EOF
223 }
224
225 check_lib(){
226 local header func err
227 log check_lib "$@"
228 header="$1"
229 func="$2"
230 shift 2
231 temp_extralibs "$@"
232 check_header $header && check_func $func && add_extralibs "$@"
233 err=$?
234 restore_flags
235 return $err
236 }
237
238 check_libconfig(){
239 local config func ccflags clibs err
240 log check_libconfig "$@"
241 config="$1"
242 func="$2"
243 ccflags="${3:---cflags}"
244 clibs="${4:---libs}"
245 err=1
246 if `which "$config" 1>/dev/null 2>&1`; then
247 cflags=`$config $ccflags`
248 [ -n "$cflags" ] && check_cflags "$cflags"
249 libs=`$config $clibs`
250 if [ -n "$libs" ]; then
251 temp_extralibs "$libs"
252 check_func $func && add_extralibs "$libs"
253 err=$?
254 restore_flags
255 fi
256 fi
257 return $err
258 }
259
260 append_config(){
261 echo "$@" >> $CONFIGFILE
262 }
263
264 pkgconfig_generate(){
265 name=$1
266 comment=$2
267 version=$3
268 libs=$4
269 requires=$5
270 cat <<EOF >$name.pc
271 prefix=$PREFIX
272 exec_prefix=\${prefix}
273 libdir=\${exec_prefix}/lib
274 includedir=\${prefix}/include
275
276 Name: $name
277 Description: $comment
278 Version: $version
279 Requires: $requires
280 Conflicts:
281 Libs: -L\${libdir} $libs
282 Cflags: -I\${includedir}
283 EOF
284 }
285
286
287 # set temporary file name
288 if test ! -z "$TMPDIR" ; then
289 TMPDIR1="${TMPDIR}"
290 elif test ! -z "$TEMPDIR" ; then
291 TMPDIR1="${TEMPDIR}"
292 else
293 TMPDIR1="/tmp"
294 fi
295
296 TMPC="${TMPDIR1}/libdlna-${RANDOM}-$$-${RANDOM}.c"
297 TMPO="${TMPDIR1}/libdlna-${RANDOM}-$$-${RANDOM}.o"
298 TMPE="${TMPDIR1}/libdlna-${RANDOM}-$$-${RANDOM}"
299 TMPS="${TMPDIR1}/libdlna-${RANDOM}-$$-${RANDOM}.S"
300
301 CONFIGFILE="config.mak"
302
303 #################################################
304 # set default parameters
305 #################################################
306 logging="yes"
307 logfile="config.log"
308 PREFIX="/usr/local"
309 libdir='$(PREFIX)/lib'
310 includedir='$(PREFIX)/include'
311 static="yes"
312 shared="yes"
313 cc="gcc"
314 ar="ar"
315 ranlib="ranlib"
316 make="make"
317 strip="strip"
318 cpu=`uname -m`
319 optimize="yes"
320 debug="no"
321 dostrip="yes"
322 extralibs=""
323 installstrip="-s"
324 cross_compile="no"
325 INSTALL="/usr/bin/install -c"
326 VERSION=""
327
328 #################################################
329 # set cpu variable and specific cpu flags
330 #################################################
331 case "$cpu" in
332 i386|i486|i586|i686|i86pc|BePC)
333 cpu="x86"
334 ;;
335 x86_64|amd64)
336 cpu="x86"
337 canon_arch="`$cc -dumpmachine | sed -e 's,\([^-]*\)-.*,\1,'`"
338 if [ x"$canon_arch" = x"x86_64" -o x"$canon_arch" = x"amd64" ]; then
339 if [ -z "`echo $CFLAGS | grep -- -m32`" ]; then
340 cpu="x86_64"
341 fi
342 fi
343 ;;
344 # armv4l is a subset of armv5tel
345 arm|armv4l|armv5tel)
346 cpu="armv4l"
347 ;;
348 alpha)
349 cpu="alpha"
350 ;;
351 "Power Macintosh"|ppc|ppc64|powerpc)
352 cpu="powerpc"
353 ;;
354 mips|mipsel|IP*)
355 cpu="mips"
356 ;;
357 sun4u|sparc64)
358 cpu="sparc64"
359 ;;
360 sparc)
361 cpu="sparc"
362 ;;
363 sh4)
364 cpu="sh4"
365 ;;
366 parisc|parisc64)
367 cpu="parisc"
368 ;;
369 s390|s390x)
370 cpu="s390"
371 ;;
372 m68k)
373 cpu="m68k"
374 ;;
375 ia64)
376 cpu="ia64"
377 ;;
378 bfin)
379 cpu="bfin"
380 ;;
381 *)
382 cpu="unknown"
383 ;;
384 esac
385
386
387 #################################################
388 # check options
389 #################################################
390 for opt do
391 optval="${opt#*=}"
392 case "$opt" in
393 --log)
394 ;;
395 --log=*) logging="$optval"
396 ;;
397 --prefix=*) PREFIX="$optval"; force_prefix=yes
398 ;;
399 --libdir=*) libdir="$optval"; force_libdir=yes
400 ;;
401 --includedir=*) includedir="$optval"
402 ;;
403 --enable-static) static="yes"
404 ;;
405 --disable-static) static="no"
406 ;;
407 --enable-shared) shared="yes"
408 ;;
409 --disable-shared) shared="no"
410 ;;
411 --enable-debug) debug="yes"
412 ;;
413 --disable-debug) debug="no"
414 ;;
415 --disable-strip) dostrip="no"
416 ;;
417 --disable-optimize) optimize="no"
418 ;;
419 --cross-prefix=*) cross_prefix="$optval"
420 ;;
421 --cross-compile) cross_compile="yes"
422 ;;
423 --with-ffmpeg-dir=*) ffmpegdir="$optval";
424 ;;
425 --help) show_help
426 ;;
427 *)
428 echo "Unknown option \"$opt\"."
429 echo "See $0 --help for available options."
430 exit 1
431 ;;
432 esac
433 done
434
435 # Check for conflictual build options
436 if [ "$shared" = no -a "$static" = no ]; then
437 echo "At least one library type must be built."
438 echo "Specify --enable-static to build the static libraries or"
439 echo "--enable-shared to build the shared libraries as well."
440 exit 1
441 fi
442
443 if [ -n "$cross_prefix" ]; then
444 cross_compile="yes"
445 cc="${cross_prefix}${cc}"
446 ar="${cross_prefix}${ar}"
447 ranlib="${cross_prefix}${ranlib}"
448 strip="${cross_prefix}${strip}"
449 else
450 [ -n "$CC" ] && cc="$CC"
451 [ -n "$AR" ] && ar="$AR"
452 [ -n "$RANLIB" ] && ranlib="$RANLIB"
453 [ -n "$STRIP" ] && strip="$STRIP"
454 fi
455 [ -n "$MAKE" ] && make="$MAKE"
456
457 #################################################
458 # create logging file
459 #################################################
460 if test "$logging" != no; then
461 enabled logging || logfile="$logging"
462 echo "# $0 $@" >$logfile
463 set >>$logfile
464 else
465 logfile=/dev/null
466 fi
467
468 #################################################
469 # compiler sanity check
470 #################################################
471 echolog "Checking for compiler available..."
472 check_exec <<EOF
473 int main(){
474 return 0;
475 }
476 EOF
477 if test "$?" != 0; then
478 echo "$cc is unable to create an executable file."
479 if test -z "$cross_prefix" -a "$cross_compile" = no; then
480 echo "If $cc is a cross-compiler, use the --cross-compile option."
481 fi
482 die "C compiler test failed."
483 fi
484
485 #################################################
486 # check for target specific flags
487 #################################################
488 # check for SIMD availability
489
490 # AltiVec flags: The FSF version of GCC differs from the Apple version
491 if test $cpu = "powerpc"; then
492 if test $altivec = "yes"; then
493 if test -n "`$cc -v 2>&1 | grep version | grep Apple`"; then
494 add_cflags "-faltivec"
495 else
496 add_cflags "-maltivec -mabi=altivec"
497 fi
498 fi
499 fi
500
501 check_header altivec.h && _altivec_h=yes || _altivec_h=no
502
503 # check if our compiler supports Motorola AltiVec C API
504 if enabled altivec; then
505 if enabled _altivec_h; then
506 inc_altivec_h="#include <altivec.h>"
507 else
508 inc_altivec_h=
509 fi
510 check_cc <<EOF || altivec=no
511 $inc_altivec_h
512 int main(void) {
513 vector signed int v1, v2, v3;
514 v1 = vec_add(v2,v3);
515 return 0;
516 }
517 EOF
518 fi
519
520 # mmi only available on mips
521 if [ "$mmi" = "default" ]; then
522 if [ "$cpu" = "mips" ]; then
523 mmi="yes"
524 else
525 mmi="no"
526 fi
527 fi
528
529 # check if our compiler supports mmi
530 enabled mmi && check_cc <<EOF || mmi="no"
531 int main(void) {
532 __asm__ ("lq \$2, 0(\$2)");
533 return 0;
534 }
535 EOF
536
537 # test gcc version to see if vector builtins can be used
538 # currently only used on i386 for MMX builtins
539 check_cc -msse <<EOF && builtin_vector=yes || builtin_vector=no
540 #include <xmmintrin.h>
541 int main(void) {
542 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2)
543 return 0;
544 #else
545 #error no vector builtins
546 #endif
547 }
548 EOF
549
550 # test for mm3dnow.h
551 test "$cpu" = "x86_64" && march=k8 || march=athlon
552 check_cc -march=$march <<EOF && mm3dnow=yes || mm3dnow=no
553 #include <mm3dnow.h>
554 int main(void) {
555 __m64 b1;
556 b1 = _m_pswapd(b1);
557 _m_femms();
558 return 0;
559 }
560 EOF
561
562 # ---
563 # big/little-endian test
564 if test "$cross_compile" = "no"; then
565 check_ld <<EOF || die "endian test failed" && $TMPE && bigendian="yes"
566 #include <inttypes.h>
567 int main(int argc, char ** argv){
568 volatile uint32_t i=0x01234567;
569 return (*((uint8_t*)(&i))) == 0x67;
570 }
571 EOF
572 else
573 # programs cannot be launched if cross compiling, so make a static guess
574 if test "$cpu" = "powerpc" -o "$cpu" = "mips" ; then
575 bigendian="yes"
576 fi
577 fi
578
579 # add some useful compiler flags if supported
580 check_cflags -W
581 check_cflags -Wall
582 check_cflags -D_LARGEFILE_SOURCE
583 check_cflags -D_FILE_OFFSET_BITS=64
584 check_cflags -D_REENTRANT
585
586 #################################################
587 # check for debug symbols
588 #################################################
589 if enabled debug; then
590 add_cflags -g3
591 add_cflags -DHAVE_DEBUG
592 dostrip=no
593 fi
594
595 if enabled optimize; then
596 if test -n "`$cc -v 2>&1 | grep xlc`"; then
597 add_cflags "-O5"
598 add_ldflags "-O5"
599 else
600 add_cflags "-O3"
601 fi
602 fi
603
604 #################################################
605 # check for ffmpeg libavformat/libavcodec
606 #################################################
607 if [ -n "$ffmpegdir" ]; then
608 check_cflags -I$ffmpegdir
609 check_ldflags -L$ffmpegdir
610 fi
611
612 echolog "Checking for libavformat ..."
613 check_lib ffmpeg/avformat.h av_register_all -lavformat || die "Error, can't find libavformat !"
614 echolog "Checking for libavcodec ..."
615 check_lib ffmpeg/avcodec.h avcodec_register_all -lavcodec || die "Error, can't find libavcodec !"
616
617 #################################################
618 # version
619 #################################################
620 temp_cflags "-Isrc"
621 check_ld <<EOF
622 #include <stdio.h>
623 #include <dlna.h>
624 int main(){
625 printf(DLNA_STRINGIFY(LIBDLNA_VERSION));
626 printf("\n");
627 return 0;
628 }
629 EOF
630 VERSION=`$TMPE`
631 restore_flags
632
633
634 #################################################
635 # logging result
636 #################################################
637 echolog ""
638 echolog "libdlna: configure is OK"
639 echolog " version $VERSION"
640 echolog "configuration:"
641 echolog " install prefix $PREFIX"
642 echolog " C compiler $cc"
643 echolog " AR $ar"
644 echolog " RANLIB $ranlib"
645 echolog " STRIP $strip"
646 echolog " make $make"
647 echolog " CPU $cpu ($tune)"
648 echolog " debug symbols $debug"
649 echolog " strip symbols $dostrip"
650 echolog " optimize $optimize"
651 echolog " static ${static}"
652 echolog " shared ${shared}"
653 echolog ""
654 echolog " CFLAGS $CFLAGS"
655 echolog " LDFLAGS $LDFLAGS"
656 echolog " extralibs $extralibs"
657 echolog ""
658
659 #################################################
660 # save configs attributes
661 #################################################
662 echolog "Creating config.mak ..."
663
664 echo "# Automatically generated by configure - do not modify!" > $CONFIGFILE
665
666 append_config "VERSION=$VERSION"
667
668 append_config "PREFIX=$PREFIX"
669 append_config "prefix=\$(DESTDIR)\$(PREFIX)"
670 append_config "libdir=\$(DESTDIR)$libdir"
671 append_config "includedir=\$(DESTDIR)$includedir"
672
673 append_config "MAKE=$make"
674 append_config "CC=$cc"
675 append_config "AR=$ar"
676 append_config "RANLIB=$ranlib"
677
678 append_config "BUILD_STATIC=$static"
679 append_config "BUILD_SHARED=$shared"
680
681 append_config "LN=ln"
682 if enabled dostrip; then
683 append_config "STRIP=$strip"
684 append_config "INSTALLSTRIP=$installstrip"
685 else
686 append_config "STRIP=echo ignoring strip"
687 append_config "INSTALLSTRIP="
688 fi
689 append_config "EXTRALIBS=$extralibs"
690
691 append_config "OPTFLAGS=$CFLAGS"
692 append_config "LDFLAGS=$LDFLAGS"
693 append_config "INSTALL=$INSTALL"
694
695 append_config "DEBUG=$debug"
696
697 #################################################
698 # make pkg-config files
699 #################################################
700 pkgconfig_generate libdlna "DLNA (Digital Living Network Alliance) library" "$VERSION" "-ldlna $extralibs" "libavformat libavcodec"
701
702 clean
703 exit 0