Debian Codegraph @

configure

raw
1 #!/bin/sh
2 #
3 # Flake configure script
4 #
5 # based on ffmpeg configure script (c) 2000, 2001, 2002 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$FLAKE_CONFIGURE_EXEC" = x; then
13 FLAKE_CONFIGURE_EXEC=1
14 export FLAKE_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.err]"
30 echo " --prefix=PREFIX install in PREFIX [$PREFIX]"
31 echo " --libdir=DIR install libs in DIR [PREFIX/lib]"
32 echo " --incdir=DIR install includes in DIR [PREFIX/include/ffmpeg]"
33 echo " --enable-mingw32 enable MinGW native/cross Windows compile"
34 echo " --enable-mingwce enable MinGW native/cross WinCE compile"
35 echo ""
36 echo "Advanced options (experts only):"
37 echo " --source-path=PATH path to source code [$source_path]"
38 echo " --cross-prefix=PREFIX use PREFIX for compilation tools [$cross_prefix]"
39 echo " --cross-compile assume a cross-compiler is used"
40 echo " --cc=CC use C compiler CC [$cc]"
41 echo " --make=MAKE use specified make [$make]"
42 echo " --ar=AR use specified ar [$ar]"
43 echo " --ranlib=RANLIB use specified ranlib [$ranlib]"
44 echo " --strip=STRIP use specified ranlib [$strip]"
45 echo " --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]"
46 echo " --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]"
47 echo " --extra-libs=ELIBS add ELIBS [$ELIBS]"
48 echo " --build-suffix=SUFFIX suffix for application specific build []"
49 echo " --cpu=CPU force cpu to CPU [$cpu]"
50 echo " --tune=CPU tune code for a particular CPU"
51 echo " (may fail or perform badly on other CPUs)"
52 echo " --disable-altivec disable AltiVec usage"
53 echo " --enable-gprof enable profiling with gprof [$gprof]"
54 echo " --disable-debug disable debugging symbols"
55 echo " --disable-opts disable compiler optimizations"
56 echo " --enable-small optimize for size instead of speed"
57 echo " --disable-strip disable stripping of executables"
58 echo ""
59 echo "NOTE: Object files are built at the place where configure is launched."
60 exit 1
61 }
62
63 log(){
64 echo "$@" >>$logfile
65 }
66
67 log_file(){
68 log BEGIN $1
69 cat -n $1 >>$logfile
70 log END $1
71 }
72
73 echolog(){
74 log "$@"
75 echo "$@"
76 }
77
78 die(){
79 echolog "$@"
80 cat <<EOF
81 If you think configure made a mistake, make sure you are using the latest
82 version from SVN. If the latest version fails, report the problem to
83 [email protected].
84 EOF
85 if enabled logging; then
86 cat <<EOF
87 Include the log file "$logfile" produced by configure as this will help
88 solving the problem.
89 EOF
90 else
91 cat <<EOF
92 Rerun configure with logging enabled (do not use --log=no), and include the
93 log this produces with your report.
94 EOF
95 fi
96 rm -f $TMPC $TMPO $TMPE $TMPS $TMPH
97 exit 1
98 }
99
100 enabled(){
101 eval test "\$$1" = "yes"
102 }
103
104 flags_saved(){
105 (: ${SAVE_CFLAGS?}) 2>/dev/null
106 }
107
108 save_flags(){
109 flags_saved && return
110 SAVE_CFLAGS="$CFLAGS"
111 SAVE_LDFLAGS="$LDFLAGS"
112 SAVE_extralibs="$extralibs"
113 }
114
115 restore_flags(){
116 CFLAGS="$SAVE_CFLAGS"
117 LDFLAGS="$SAVE_LDFLAGS"
118 extralibs="$SAVE_extralibs"
119 unset SAVE_CFLAGS
120 unset SAVE_LDFLAGS
121 unset SAVE_extralibs
122 }
123
124 append(){
125 var=$1
126 shift
127 flags_saved && eval "SAVE_$var=\"\$SAVE_$var $*\""
128 eval "$var=\"\$$var $*\""
129 }
130
131 add_cflags(){
132 append CFLAGS "$@"
133 }
134
135 add_ldflags(){
136 append LDFLAGS "$@"
137 }
138
139 add_extralibs(){
140 append extralibs "$@"
141 }
142
143 check_cmd(){
144 log "$@"
145 "$@" >>$logfile 2>&1
146 }
147
148 check_cc(){
149 log check_cc "$@"
150 cat >$TMPC
151 log_file $TMPC
152 check_cmd $cc $CFLAGS "$@" -c -o $TMPO $TMPC
153 }
154
155 check_cpp(){
156 log check_cpp "$@"
157 cat >$TMPC
158 log_file $TMPC
159 check_cmd $cc $CFLAGS "$@" -E -o $TMPO $TMPC
160 }
161
162 check_ld(){
163 log check_ld "$@"
164 check_cc || return
165 check_cmd $cc $LDFLAGS "$@" -o $TMPE $TMPO $extralibs
166 }
167
168 check_cflags(){
169 log check_cflags "$@"
170 check_cc "$@" <<EOF && add_cflags "$@"
171 int x;
172 EOF
173 }
174
175 check_ldflags(){
176 log check_ldflags "$@"
177 check_ld "$@" <<EOF && add_ldflags "$@"
178 int main(){
179 return 0;
180 }
181 EOF
182 }
183
184 check_header(){
185 log check_header "$@"
186 header=$1
187 shift
188 check_cpp "$@" <<EOF
189 #include <$header>
190 int x;
191 EOF
192 }
193
194 check_exec(){
195 check_ld "$@" && { test "$cross_compile" = yes || $TMPE >>$logfile 2>&1; }
196 }
197
198 # set temporary file name
199 if test ! -z "$TMPDIR" ; then
200 TMPDIR1="${TMPDIR}"
201 elif test ! -z "$TEMPDIR" ; then
202 TMPDIR1="${TEMPDIR}"
203 elif test ! -z "$TEMP" ; then
204 TMPDIR1="${TEMP}"
205 else
206 TMPDIR1="/tmp"
207 fi
208
209 TMPC="${TMPDIR1}/flake-conf-${RANDOM}-$$-${RANDOM}.c"
210 TMPO="${TMPDIR1}/flake-conf-${RANDOM}-$$-${RANDOM}.o"
211 TMPE="${TMPDIR1}/flake-conf-${RANDOM}-$$-${RANDOM}"
212 TMPS="${TMPDIR1}/flake-conf-${RANDOM}-$$-${RANDOM}.S"
213 TMPH="${TMPDIR1}/flake-conf-${RANDOM}-$$-${RANDOM}.h"
214
215 # default parameters
216 logging="yes"
217 logfile="config.err"
218 PREFIX="/usr/local"
219 libdir='${PREFIX}/lib'
220 incdir='${PREFIX}/include'
221 bindir='${PREFIX}/bin'
222 cross_prefix=""
223 cross_compile="no"
224 cc="gcc"
225 ar="ar"
226 ranlib="ranlib"
227 make="make"
228 strip="strip"
229 cpu=`uname -m`
230 tune="generic"
231 altivec="default"
232 case "$cpu" in
233 i386|i486|i586|i686|i86pc|BePC)
234 cpu="x86"
235 ;;
236 x86_64|amd64)
237 cpu="x86"
238 canon_arch="`$cc -dumpmachine | sed -e 's,\([^-]*\)-.*,\1,'`"
239 if [ x"$canon_arch" = x"x86_64" -o x"$canon_arch" = x"amd64" ]; then
240 if [ -z "`echo $CFLAGS | grep -- -m32`" ]; then
241 cpu="x86_64"
242 fi
243 fi
244 ;;
245 # armv4l is a subset of armv5tel
246 armv4l|armv5tel)
247 cpu="armv4l"
248 ;;
249 alpha)
250 cpu="alpha"
251 ;;
252 "Power Macintosh"|ppc|ppc64|powerpc)
253 cpu="powerpc"
254 ;;
255 mips|mipsel|IP*)
256 cpu="mips"
257 ;;
258 sun4u|sparc64)
259 cpu="sparc64"
260 ;;
261 sparc)
262 cpu="sparc"
263 ;;
264 sh4)
265 cpu="sh4"
266 ;;
267 parisc|parisc64)
268 cpu="parisc"
269 ;;
270 s390|s390x)
271 cpu="s390"
272 ;;
273 m68k)
274 cpu="m68k"
275 ;;
276 ia64)
277 cpu="ia64"
278 ;;
279 bfin)
280 cpu="bfin"
281 ;;
282 *)
283 cpu="unknown"
284 ;;
285 esac
286 gprof="no"
287 mingw32="no"
288 mingwce="no"
289 os2="no"
290 optimize="yes"
291 debug="yes"
292 dostrip="yes"
293 installstrip="-s"
294 extralibs="-lm"
295 bigendian="no"
296 inttypes="yes"
297 LIBOBJFLAGS=""
298 PROJLDFLAGS=-Wl,--warn-common
299 LDCONFIG="ldconfig"
300 LIBPREF="lib"
301 LIBSUF=".a"
302 LIB='$(LIBPREF)$(NAME)$(LIBSUF)'
303 EXESUF=""
304 BUILDSUF=""
305 LIB_INSTALL_EXTRA_CMD='$(RANLIB) "$(libdir)/$(LIB)"'
306
307 # OS specific
308 targetos=`uname -s`
309 case $targetos in
310 BeOS)
311 PREFIX="/boot/home/config"
312 add_cflags "-DPIC -fomit-frame-pointer"
313 # 3 gcc releases known for BeOS, each with ugly bugs
314 gcc_version="`$cc -v 2>&1 | grep version | cut -d ' ' -f3-`"
315 case "$gcc_version" in
316 2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
317 ;;
318 *20010315*) echo "BeBits gcc"
319 add_cflags "-fno-expensive-optimizations"
320 ;;
321 esac
322 ;;
323 SunOS)
324 make="gmake"
325 PROJLDFLAGS=""
326 ;;
327 NetBSD)
328 make="gmake"
329 ;;
330 OpenBSD)
331 make="gmake"
332 LIBOBJFLAGS="\$(PIC)"
333 ;;
334 FreeBSD)
335 make="gmake"
336 add_cflags "-pthread"
337 ;;
338 GNU/kFreeBSD)
339 add_cflags "-pthread"
340 ;;
341 BSD/OS)
342 extralibs="-lpoll -lgnugetopt -lm"
343 make="gmake"
344 strip="strip -d"
345 installstrip=""
346 ;;
347 Darwin)
348 cc="cc"
349 extralibs=""
350 strip="strip -x"
351 installstrip=""
352 PROJLDFLAGS="-Wl,-dynamic,-search_paths_first"
353 LIB_INSTALL_EXTRA_CMD='$(RANLIB) "$(libdir)/$(LIB)"'
354 ;;
355 MINGW32*)
356 # Note: the rest of the mingw32 config is done afterwards as mingw32
357 # can be forced on the command line for Linux cross compilation.
358 mingw32="yes"
359 ;;
360 CYGWIN*)
361 targetos=CYGWIN
362 extralibs=""
363 EXESUF=".exe"
364 ;;
365 Linux)
366 ;;
367 IRIX*)
368 targetos=IRIX
369 ranlib="echo ignoring ranlib"
370 make="gmake"
371 ;;
372 OS/2)
373 TMPE=$TMPE".exe"
374 ar="emxomfar -p128"
375 ranlib="echo ignoring ranlib"
376 strip="echo ignoring strip"
377 add_cflags "-Zomf"
378 PROJLDFLAGS="-Zomf -Zstack 16384 -s"
379 LIBPREF=""
380 LIBSUF=".lib"
381 EXESUF=".exe"
382 extralibs=""
383 os2="yes"
384
385 ;;
386 *)
387 targetos="${targetos}-UNKNOWN"
388 ;;
389 esac
390
391 # find source path
392 source_path="`dirname $0`"
393 source_path_used="yes"
394 if test -z "$source_path" -o "$source_path" = "." ; then
395 source_path=`pwd`
396 source_path_used="no"
397 else
398 source_path="`cd \"$source_path\"; pwd`"
399 fi
400
401 if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
402 show_help
403 fi
404
405 FLAKE_CONFIGURATION=" "
406 for opt do
407 FLAKE_CONFIGURATION="$FLAKE_CONFIGURATION""$opt "
408 done
409
410 for opt do
411 optval="${opt#*=}"
412 case "$opt" in
413 --log)
414 ;;
415 --log=*) logging="$optval"
416 ;;
417 --prefix=*) PREFIX="$optval"; force_prefix=yes
418 ;;
419 --libdir=*) libdir="$optval"; force_libdir=yes
420 ;;
421 --incdir=*) incdir="$optval"
422 ;;
423 --source-path=*) source_path="$optval"
424 ;;
425 --cross-prefix=*) cross_prefix="$optval"
426 ;;
427 --cross-compile) cross_compile=yes
428 ;;
429 --cc=*) cc="$optval"
430 ;;
431 --make=*) make="$optval"
432 ;;
433 --ar=*) ar="$optval"
434 ;;
435 --ranlib=*) ranlib="$optval"
436 ;;
437 --strip=*) strip="$optval"
438 ;;
439 --extra-cflags=*) add_cflags "$optval"
440 ;;
441 --extra-ldflags=*) EXTRALDFLAGS="$optval"
442 ;;
443 --extra-libs=*) extralibs="$optval"
444 ;;
445 --build-suffix=*) BUILDSUF="$optval"
446 ;;
447 --cpu=*) cpu="$optval"
448 ;;
449 --tune=*) tune="$optval"
450 ;;
451 --disable-altivec) altivec="no"
452 ;;
453 --enable-gprof) gprof="yes"
454 ;;
455 --enable-mingw32) mingw32="yes"
456 ;;
457 --enable-mingwce) mingwce="yes"
458 ;;
459 --disable-debug) debug="no"
460 ;;
461 --disable-opts) optimize="no"
462 ;;
463 --enable-small) optimize="small"
464 ;;
465 --disable-strip) dostrip="no"
466 ;;
467 --help) show_help
468 ;;
469 *)
470 echo "Unknown option \"$opt\"."
471 echo "See $0 --help for available options."
472 exit 1
473 ;;
474 esac
475 done
476
477 if test "$logging" != no; then
478 test "$logging" = yes || logfile="$logging"
479 echo "# $0 $@" >$logfile
480 set >>$logfile
481 else
482 logfile=/dev/null
483 fi
484
485 if test "$mingw32" = "yes" -o "$mingwce" = "yes"; then
486 EXESUF=".exe"
487 if test "$force_prefix" != yes; then PREFIX="$PROGRAMFILES/Flake"; fi
488 if test "$force_libdir" != yes; then bindir='${PREFIX}'; fi
489 fi
490
491 # Combine PROFLDFLAGS, EXTRALDFLAGS and the LDFLAGS environment variable.
492 LDFLAGS="$PROJLDFLAGS $EXTRALDFLAGS $LDFLAGS"
493
494 test -n "$cross_prefix" && cross_compile=yes
495 cc="${cross_prefix}${cc}"
496 ar="${cross_prefix}${ar}"
497 ranlib="${cross_prefix}${ranlib}"
498 strip="${cross_prefix}${strip}"
499
500 #Darwin CC versions
501 needmdynamicnopic="no"
502 if test $targetos = Darwin; then
503 if test -n "`$cc -v 2>&1 | grep xlc`"; then
504 add_cflags "-qpdf2 -qlanglvl=extc99 -qmaxmem=-1 -qarch=auto -qtune=auto"
505 else
506 gcc_version="`$cc -v 2>&1 | grep version | cut -d ' ' -f3-`"
507 case "$gcc_version" in
508 *2.95*)
509 add_cflags "-no-cpp-precomp -pipe"
510 ;;
511 *[34].*)
512 add_cflags "-no-cpp-precomp -pipe -force_cpusubtype_ALL -Wno-sign-compare"
513 needmdynamicnopic="yes"
514 ;;
515 *)
516 add_cflags "-no-cpp-precomp -pipe"
517 needmdynamicnopic="yes"
518 ;;
519 esac
520 fi
521 if test $optimize != "no"; then
522 add_cflags "-fomit-frame-pointer"
523 fi
524 fi
525
526 # Can only do AltiVec on PowerPC
527 if test $altivec = "default"; then
528 if test $cpu = "powerpc"; then
529 altivec="yes"
530 else
531 altivec="no"
532 fi
533 fi
534
535 # Add processor-specific flags
536 TUNECPU="generic"
537 POWERPCMODE="32bits"
538 if test $tune != "generic"; then
539 case $tune in
540 601|ppc601|PowerPC601)
541 add_cflags "-mcpu=601"
542 if test $altivec = "yes"; then
543 echo "WARNING: Tuning for PPC601 but AltiVec enabled!";
544 fi
545 TUNECPU=ppc601
546 ;;
547 603*|ppc603*|PowerPC603*)
548 add_cflags "-mcpu=603"
549 if test $altivec = "yes"; then
550 echo "WARNING: Tuning for PPC603 but AltiVec enabled!";
551 fi
552 TUNECPU=ppc603
553 ;;
554 604*|ppc604*|PowerPC604*)
555 add_cflags "-mcpu=604"
556 if test $altivec = "yes"; then
557 echo "WARNING: Tuning for PPC604 but AltiVec enabled!";
558 fi
559 TUNECPU=ppc604
560 ;;
561 G3|g3|75*|ppc75*|PowerPC75*)
562 add_cflags "-mcpu=750 -mtune=750 -mpowerpc-gfxopt"
563 if test $altivec = "yes"; then
564 echo "WARNING: Tuning for PPC75x but AltiVec enabled!";
565 fi
566 TUNECPU=ppc750
567 ;;
568 G4|g4|745*|ppc745*|PowerPC745*)
569 add_cflags "-mcpu=7450 -mtune=7450 -mpowerpc-gfxopt"
570 if test $altivec = "no"; then
571 echo "WARNING: Tuning for PPC745x but AltiVec disabled!";
572 fi
573 TUNECPU=ppc7450
574 ;;
575 74*|ppc74*|PowerPC74*)
576 add_cflags "-mcpu=7400 -mtune=7400 -mpowerpc-gfxopt"
577 if test $altivec = "no"; then
578 echo "WARNING: Tuning for PPC74xx but AltiVec disabled!";
579 fi
580 TUNECPU=ppc7400
581 ;;
582 G5|g5|970|ppc970|PowerPC970|power4*|Power4*)
583 add_cflags "-mcpu=970 -mtune=970 -mpowerpc-gfxopt -mpowerpc64"
584 if test $altivec = "no"; then
585 echo "WARNING: Tuning for PPC970 but AltiVec disabled!";
586 fi
587 TUNECPU=ppc970
588 POWERPCMODE="64bits"
589 ;;
590 power5*|Power5*)
591 add_cflags "-mcpu=power5 -mtune=power5 -mpowerpc-gfxopt -mpowerpc64"
592 if test $altivec = "no"; then
593 echo "WARNING: Tuning for POWER5 but AltiVec disabled!";
594 fi
595 TUNECPU=power5
596 POWERPCMODE="64bits"
597 ;;
598 i[3456]86|pentium|pentiumpro|pentium-mmx|pentium[234]|prescott|k6|k6-[23]|athlon|athlon-tbird|athlon-4|athlon-[mx]p|winchip-c6|winchip2|c3|nocona|athlon64|k8|opteron|athlon-fx)
599 add_cflags "-march=$tune"
600 ;;
601 ev4|ev45|ev5|ev56|ev6|ev67|21064|21164|21164a|21164pc|21164PC|21264|21264a)
602 add_cflags "-mcpu=$tune"
603 ;;
604 sparc64)
605 add_cflags "-mcpu=v9 -mtune=v9"
606 ;;
607 *)
608 echo "WARNING: Unknown CPU \"$tune\", ignored."
609 ;;
610 esac
611 fi
612
613 # compiler sanity check
614 check_exec <<EOF
615 int main(){
616 return 0;
617 }
618 EOF
619 if test "$?" != 0; then
620 echo "$cc is unable to create an executable file."
621 if test -z "$cross_prefix" -a "$cross_compile" = no; then
622 echo "If $cc is a cross-compiler, use the --cross-compile option."
623 fi
624 die "C compiler test failed."
625 fi
626
627 # AltiVec flags: The FSF version of GCC differs from the Apple version
628 if test $cpu = "powerpc"; then
629 if test $altivec = "yes"; then
630 if test -n "`$cc -v 2>&1 | grep version | grep Apple`"; then
631 add_cflags "-faltivec"
632 else
633 add_cflags "-maltivec -mabi=altivec"
634 fi
635 fi
636 fi
637
638 # ---
639 # big/little-endian test
640 if test "$cross_compile" = "no"; then
641 check_ld <<EOF || die "endian test failed" && $TMPE && bigendian="yes"
642 #include <inttypes.h>
643 int main(int argc, char ** argv){
644 volatile uint32_t i=0x01234567;
645 return (*((uint8_t*)(&i))) == 0x67;
646 }
647 EOF
648 else
649 # programs cannot be launched if cross compiling, so make a static guess
650 if test "$cpu" = "powerpc" -o "$cpu" = "mips" ; then
651 bigendian="yes"
652 fi
653 fi
654
655 # ---
656 # *inttypes.h* test
657 check_header inttypes.h || inttypes=no
658
659 # test for lrintf in math.h
660 check_exec <<EOF && have_lrintf=yes || have_lrintf=no
661 #define _ISOC9X_SOURCE 1
662 #include <math.h>
663 int main( void ) { return (lrintf(3.999f) > 0)?0:1; }
664 EOF
665
666 # test for strnlen in string.h
667 check_exec <<EOF && have_strnlen=yes || have_strnlen=no
668 #define _ISOC9X_SOURCE 1
669 #include <string.h>
670 int main( void ) { return (strnlen("help", 6) == 4)?0:1; }
671 EOF
672
673 if enabled debug; then
674 add_cflags -g
675 else
676 add_cflags -DNDEBUG
677 fi
678
679 # add some useful compiler flags if supported
680 check_cflags -Wdeclaration-after-statement
681 check_cflags -Wall
682 check_cflags -Wno-switch
683 check_cflags -Wdisabled-optimization
684 check_cflags -Wpointer-arith
685 check_cflags -Wredundant-decls
686 check_cflags -Winline
687
688 # not all compilers support -Os
689 test "$optimize" = "small" && check_cflags -Os
690
691 if enabled optimize; then
692 if test -n "`$cc -v 2>&1 | grep xlc`"; then
693 add_cflags "-O5"
694 add_ldflags "-O5"
695 else
696 add_cflags "-O3"
697 fi
698 fi
699
700 if test "$gprof" = "yes" ; then
701 add_cflags "-p"
702 add_ldflags "-p"
703 fi
704
705 echo "install prefix $PREFIX"
706 echo "source path $source_path"
707 echo "C compiler $cc"
708 echo "make $make"
709 echo "CPU $cpu ($tune)"
710 if test "$BUILDSUF" != ""; then
711 echo "build suffix $BUILDSUF"
712 fi
713 echo "big-endian $bigendian"
714 echo "inttypes.h $inttypes"
715 echo "lrintf() $have_lrintf"
716 echo "strnlen() $have_strnlen"
717 if test $cpu = "powerpc"; then
718 echo "AltiVec enabled $altivec"
719 fi
720 echo "gprof enabled $gprof"
721 echo "debug symbols $debug"
722 echo "strip symbols $dostrip"
723 echo "optimize $optimize"
724
725 echo "Creating config.mak and config.h..."
726
727 date >> config.log
728 echo " $0 $FLAKE_CONFIGURATION" >> config.log
729 echo "# Automatically generated by configure - do not modify!" > config.mak
730 echo "/* Automatically generated by configure - do not modify! */" > $TMPH
731 echo "#define FLAKE_CONFIGURATION "'"'"$FLAKE_CONFIGURATION"'"' >> $TMPH
732
733 echo "PREFIX=$PREFIX" >> config.mak
734 echo "prefix=\$(DESTDIR)\${PREFIX}" >> config.mak
735 echo "libdir=\$(DESTDIR)$libdir" >> config.mak
736 echo "incdir=\$(DESTDIR)$incdir" >> config.mak
737 echo "bindir=\$(DESTDIR)$bindir" >> config.mak
738 echo "MAKE=$make" >> config.mak
739 echo "CC=$cc" >> config.mak
740 echo "AR=$ar" >> config.mak
741 echo "RANLIB=$ranlib" >> config.mak
742 if test "$dostrip" = "yes" ; then
743 echo "STRIP=$strip" >> config.mak
744 echo "INSTALLSTRIP=$installstrip" >> config.mak
745 else
746 echo "STRIP=echo ignoring strip" >> config.mak
747 echo "INSTALLSTRIP=" >> config.mak
748 fi
749
750 test "$needmdynamicnopic" = yes && add_cflags -mdynamic-no-pic
751
752 echo "OPTFLAGS=$CFLAGS" >> config.mak
753 echo "LDFLAGS=$LDFLAGS" >> config.mak
754 echo "LDCONFIG=$LDCONFIG" >> config.mak
755 echo "LIBOBJFLAGS=$LIBOBJFLAGS" >> config.mak
756 echo "BUILDSUF=$BUILDSUF" >> config.mak
757 echo "LIBPREF=$LIBPREF" >> config.mak
758 echo "LIBSUF=\${BUILDSUF}$LIBSUF" >> config.mak
759 echo "LIB=$LIB" >> config.mak
760 echo "EXESUF=\${BUILDSUF}$EXESUF" >> config.mak
761
762 echo "#define TUNECPU $TUNECPU" >> $TMPH
763 if test "$bigendian" = "yes" ; then
764 echo "WORDS_BIGENDIAN=yes" >> config.mak
765 echo "#define WORDS_BIGENDIAN 1" >> $TMPH
766 fi
767 if test "$inttypes" != "yes" ; then
768 echo "#define EMULATE_INTTYPES 1" >> $TMPH
769 fi
770 if test "$have_lrintf" = "yes" ; then
771 echo "#define HAVE_LRINTF 1" >> $TMPH
772 fi
773 if test "$have_strnlen" = "yes" ; then
774 echo "#define HAVE_STRNLEN 1" >> $TMPH
775 fi
776
777 libflake_version=`grep '#define FLAKE_VERSION ' "$source_path/libflake/flake.h" | sed 's/[^0-9\.]//g'`
778
779 echo "LIB_INSTALL_EXTRA_CMD=${LIB_INSTALL_EXTRA_CMD}" >> config.mak
780 echo "EXTRALIBS=$extralibs" >> config.mak
781
782 if test "$mingw32" = "yes" ; then
783 echo "#ifndef __MINGW32__" >> $TMPH
784 echo "#define __MINGW32__ 1" >> $TMPH
785 echo "#endif" >> $TMPH
786 fi
787
788 if test "$mingwce" = "yes" ; then
789 echo "#define CONFIG_WINCE 1" >> $TMPH
790 echo "#ifndef __MINGW32__" >> $TMPH
791 echo "#define __MINGW32__ 1" >> $TMPH
792 echo "#endif" >> $TMPH
793 fi
794
795 if test "$os2" = "yes" ; then
796 echo "#define CONFIG_OS2 1" >> $TMPH
797 fi
798
799 if test "$targetos" = "SunOS" ; then
800 echo "#define CONFIG_SUNOS 1" >> $TMPH
801 fi
802
803 if test "$targetos" = "Darwin"; then
804 echo "#define CONFIG_DARWIN 1" >> $TMPH
805 fi
806
807 # build tree in object directory if source path is different from current one
808 if test "$source_path_used" = "yes" ; then
809 DIRS="\
810 libflake \
811 flake \
812 util \
813 "
814 FILES="\
815 Makefile \
816 libflake/Makefile \
817 flake/Makefile \
818 util/Makefile \
819 "
820 for dir in $DIRS ; do
821 mkdir -p $dir
822 done
823 for f in $FILES ; do
824 ln -sf "$source_path/$f" $f
825 done
826 fi
827 echo "SRC_PATH=$source_path" >> config.mak
828 echo "BUILD_ROOT=$PWD" >> config.mak
829
830 # Do not overwrite config.h if unchanged to avoid superfluous rebuilds.
831 diff $TMPH config.h >/dev/null 2>&1
832 if test "$?" != "0" ; then
833 mv -f $TMPH config.h
834 else
835 echo "config.h is unchanged"
836 fi
837
838 rm -f $TMPO $TMPC $TMPE $TMPS $TMPH