have configure check/add linker options to reduce size lost to padding
[musl] / configure
1 #!/bin/sh
2
3 usage () {
4 cat <<EOF
5 Usage: $0 [OPTION]... [VAR=VALUE]... [TARGET]
6
7 To assign environment variables (e.g., CC, CFLAGS...), specify them as
8 VAR=VALUE.  See below for descriptions of some of the useful variables.
9
10 Defaults for the options are specified in brackets.
11
12 Installation directories:
13   --prefix=PREFIX         main installation prefix [/usr/local/musl]
14   --exec-prefix=EPREFIX   installation prefix for executable files [PREFIX]
15
16 Fine tuning of the installation directories:
17   --bindir=DIR            user executables [EPREFIX/bin]
18   --libdir=DIR            library files for the linker [PREFIX/lib]
19   --includedir=DIR        include files for the C compiler [PREFIX/include]
20   --syslibdir=DIR         location for the dynamic linker [/lib]
21
22 System types:
23   --target=TARGET         configure to run on target TARGET [detected]
24   --host=HOST             same as --target
25
26 Optional features:
27   --enable-optimize=...   optimize listed components for speed over size [auto]
28   --enable-debug          build with debugging information [disabled]
29   --enable-warnings       build with recommended warnings flags [disabled]
30   --enable-visibility     use global visibility options to optimize PIC [auto]
31   --enable-wrapper=...    build given musl toolchain wrapper [auto]
32   --disable-shared        inhibit building shared library [enabled]
33   --disable-static        inhibit building static library [enabled]
34
35 Some influential environment variables:
36   CC                      C compiler command [detected]
37   CFLAGS                  C compiler flags [-Os -pipe ...]
38   CROSS_COMPILE           prefix for cross compiler and tools [none]
39   LIBCC                   compiler runtime library [detected]
40
41 Use these variables to override the choices made by configure.
42
43 EOF
44 exit 0
45 }
46
47 # Helper functions
48
49 quote () {
50 tr '\n' ' ' <<EOF | grep '^[-[:alnum:]_=,./:]* $' >/dev/null 2>&1 && { echo "$1" ; return 0 ; }
51 $1
52 EOF
53 printf %s\\n "$1" | sed -e "s/'/'\\\\''/g" -e "1s/^/'/" -e "\$s/\$/'/" -e "s#^'\([-[:alnum:]_,./:]*\)=\(.*\)\$#\1='\2#"
54 }
55 echo () { printf "%s\n" "$*" ; }
56 fail () { echo "$*" ; exit 1 ; }
57 fnmatch () { eval "case \"\$2\" in $1) return 0 ;; *) return 1 ;; esac" ; }
58 cmdexists () { type "$1" >/dev/null 2>&1 ; }
59 trycc () { test -z "$CC" && cmdexists "$1" && CC=$1 ; }
60
61 stripdir () {
62 while eval "fnmatch '*/' \"\${$1}\"" ; do eval "$1=\${$1%/}" ; done
63 }
64
65 trycppif () {
66 printf "checking preprocessor condition %s... " "$1"
67 echo "typedef int x;" > "$tmpc"
68 echo "#if $1" >> "$tmpc"
69 echo "#error yes" >> "$tmpc"
70 echo "#endif" >> "$tmpc"
71 if $CC $2 -c -o /dev/null "$tmpc" >/dev/null 2>&1 ; then
72 printf "false\n"
73 return 1
74 else
75 printf "true\n"
76 return 0
77 fi
78 }
79
80 tryflag () {
81 printf "checking whether compiler accepts %s... " "$2"
82 echo "typedef int x;" > "$tmpc"
83 if $CC $CFLAGS_TRY $2 -c -o /dev/null "$tmpc" >/dev/null 2>&1 ; then
84 printf "yes\n"
85 eval "$1=\"\${$1} \$2\""
86 eval "$1=\${$1# }"
87 return 0
88 else
89 printf "no\n"
90 return 1
91 fi
92 }
93
94 tryldflag () {
95 printf "checking whether linker accepts %s... " "$2"
96 echo "typedef int x;" > "$tmpc"
97 if $CC $LDFLAGS_TRY -nostdlib -shared "$2" -o /dev/null "$tmpc" >/dev/null 2>&1 ; then
98 printf "yes\n"
99 eval "$1=\"\${$1} \$2\""
100 eval "$1=\${$1# }"
101 return 0
102 else
103 printf "no\n"
104 return 1
105 fi
106 }
107
108
109
110 # Beginning of actual script
111
112 CFLAGS_C99FSE=
113 CFLAGS_AUTO=
114 CFLAGS_MEMOPS=
115 CFLAGS_NOSSP=
116 CFLAGS_TRY=
117 LDFLAGS_AUTO=
118 LDFLAGS_TRY=
119 OPTIMIZE_GLOBS=
120 prefix=/usr/local/musl
121 exec_prefix='$(prefix)'
122 bindir='$(exec_prefix)/bin'
123 libdir='$(prefix)/lib'
124 includedir='$(prefix)/include'
125 syslibdir='/lib'
126 tools=
127 tool_libs=
128 target=
129 optimize=auto
130 debug=no
131 warnings=no
132 visibility=auto
133 shared=auto
134 static=yes
135 wrapper=auto
136 gcc_wrapper=no
137 clang_wrapper=no
138
139 for arg ; do
140 case "$arg" in
141 --help) usage ;;
142 --prefix=*) prefix=${arg#*=} ;;
143 --exec-prefix=*) exec_prefix=${arg#*=} ;;
144 --bindir=*) bindir=${arg#*=} ;;
145 --libdir=*) libdir=${arg#*=} ;;
146 --includedir=*) includedir=${arg#*=} ;;
147 --syslibdir=*) syslibdir=${arg#*=} ;;
148 --enable-shared|--enable-shared=yes) shared=yes ;;
149 --disable-shared|--enable-shared=no) shared=no ;;
150 --enable-static|--enable-static=yes) static=yes ;;
151 --disable-static|--enable-static=no) static=no ;;
152 --enable-optimize) optimize=yes ;;
153 --enable-optimize=*) optimize=${arg#*=} ;;
154 --disable-optimize) optimize=no ;;
155 --enable-debug|--enable-debug=yes) debug=yes ;;
156 --disable-debug|--enable-debug=no) debug=no ;;
157 --enable-warnings|--enable-warnings=yes) warnings=yes ;;
158 --disable-warnings|--enable-warnings=no) warnings=no ;;
159 --enable-visibility|--enable-visibility=yes) visibility=yes ;;
160 --disable-visibility|--enable-visibility=no) visibility=no ;;
161 --enable-wrapper|--enable-wrapper=yes) wrapper=detect ;;
162 --enable-wrapper=all) wrapper=yes ; gcc_wrapper=yes ; clang_wrapper=yes ;;
163 --enable-wrapper=gcc) wrapper=yes ; gcc_wrapper=yes ;;
164 --enable-wrapper=clang) wrapper=yes ; clang_wrapper=yes ;;
165 --disable-wrapper|--enable-wrapper=no) wrapper=no ;;
166 --enable-gcc-wrapper|--enable-gcc-wrapper=yes) wrapper=yes ; gcc_wrapper=yes ;;
167 --disable-gcc-wrapper|--enable-gcc-wrapper=no) wrapper=no ;;
168 --enable-*|--disable-*|--with-*|--without-*|--*dir=*|--build=*) ;;
169 --host=*|--target=*) target=${arg#*=} ;;
170 -* ) echo "$0: unknown option $arg" ;;
171 CC=*) CC=${arg#*=} ;;
172 CFLAGS=*) CFLAGS=${arg#*=} ;;
173 CPPFLAGS=*) CPPFLAGS=${arg#*=} ;;
174 LDFLAGS=*) LDFLAGS=${arg#*=} ;;
175 CROSS_COMPILE=*) CROSS_COMPILE=${arg#*=} ;;
176 LIBCC=*) LIBCC=${arg#*=} ;;
177 *=*) ;;
178 *) target=$arg ;;
179 esac
180 done
181
182 for i in prefix exec_prefix bindir libdir includedir syslibdir ; do
183 stripdir $i
184 done
185
186 #
187 # Get a temp filename we can use
188 #
189 i=0
190 set -C
191 while : ; do i=$(($i+1))
192 tmpc="./conf$$-$PPID-$i.c"
193 2>|/dev/null > "$tmpc" && break
194 test "$i" -gt 50 && fail "$0: cannot create temporary file $tmpc"
195 done
196 set +C
197 trap 'rm "$tmpc"' EXIT INT QUIT TERM HUP
198
199 #
200 # Find a C compiler to use
201 #
202 printf "checking for C compiler... "
203 trycc ${CROSS_COMPILE}gcc
204 trycc ${CROSS_COMPILE}c99
205 trycc ${CROSS_COMPILE}cc
206 printf "%s\n" "$CC"
207 test -n "$CC" || { echo "$0: cannot find a C compiler" ; exit 1 ; }
208
209 printf "checking whether C compiler works... "
210 echo "typedef int x;" > "$tmpc"
211 if output=$($CC $CPPFLAGS $CFLAGS -c -o /dev/null "$tmpc" 2>&1) ; then
212 printf "yes\n"
213 else
214 printf "no; compiler output follows:\n%s\n" "$output"
215 exit 1
216 fi
217
218 #
219 # Figure out options to force errors on unknown flags.
220 #
221 tryflag   CFLAGS_TRY  -Werror=unknown-warning-option
222 tryflag   CFLAGS_TRY  -Werror=unused-command-line-argument
223 tryldflag LDFLAGS_TRY -Werror=unknown-warning-option
224 tryldflag LDFLAGS_TRY -Werror=unused-command-line-argument
225
226 #
227 # Need to know if the compiler is gcc or clang to decide which toolchain
228 # wrappers to build.
229 #
230 printf "checking for C compiler family... "
231 cc_ver="$(LC_ALL=C $CC -v 2>&1)"
232 cc_family=unknown
233 if fnmatch '*gcc\ version*' "$cc_ver" ; then
234 cc_family=gcc
235 elif fnmatch '*clang\ version*' "$cc_ver" ; then
236 cc_family=clang
237 fi
238 echo "$cc_family"
239
240 #
241 # Figure out toolchain wrapper to build
242 #
243 if test "$wrapper" = auto -o "$wrapper" = detect ; then
244 echo "#include <stdlib.h>" > "$tmpc"
245 echo "#if ! __GLIBC__" >> "$tmpc"
246 echo "#error no" >> "$tmpc"
247 echo "#endif" >> "$tmpc"
248 printf "checking for toolchain wrapper to build... "
249 if test "$wrapper" = auto && ! $CC -c -o /dev/null "$tmpc" >/dev/null 2>&1 ; then
250 echo "none"
251 elif test "$cc_family" = gcc ; then
252 gcc_wrapper=yes
253 echo "gcc"
254 elif test "$cc_family" = clang ; then
255 clang_wrapper=yes
256 echo "clang"
257 else
258 echo "none"
259 if test "$wrapper" = detect ; then
260 fail "$0: could not find an appropriate toolchain wrapper"
261 fi
262 fi
263 fi
264
265 if test "$gcc_wrapper" = yes ; then
266 tools="$tools tools/musl-gcc"
267 tool_libs="$tool_libs lib/musl-gcc.specs"
268 fi
269 if test "$clang_wrapper" = yes ; then
270 tools="$tools tools/musl-clang tools/ld.musl-clang"
271 fi
272
273 #
274 # Find the target architecture
275 #
276 printf "checking target system type... "
277 test -n "$target" || target=$($CC -dumpmachine 2>/dev/null) || target=unknown
278 printf "%s\n" "$target"
279
280 #
281 # Convert to just ARCH
282 #
283 case "$target" in
284 # Catch these early to simplify matching for 32-bit archs
285 mips64*|powerpc64*) fail "$0: unsupported target \"$target\"" ;;
286 arm*) ARCH=arm ;;
287 aarch64*) ARCH=aarch64 ;;
288 i?86*) ARCH=i386 ;;
289 x86_64-x32*|x32*|x86_64*x32) ARCH=x32 ;;
290 x86_64*) ARCH=x86_64 ;;
291 mips*) ARCH=mips ;;
292 microblaze*) ARCH=microblaze ;;
293 or1k*) ARCH=or1k ;;
294 powerpc*) ARCH=powerpc ;;
295 sh[1-9bel-]*|sh|superh*) ARCH=sh ;;
296 unknown) fail "$0: unable to detect target arch; try $0 --target=..." ;;
297 *) fail "$0: unknown or unsupported target \"$target\"" ;;
298 esac
299
300 #
301 # Try to get a conforming C99 freestanding environment
302 #
303 tryflag CFLAGS_C99FSE -std=c99
304 tryflag CFLAGS_C99FSE -nostdinc
305 tryflag CFLAGS_C99FSE -ffreestanding \
306 || tryflag CFLAGS_C99FSE -fno-builtin
307 tryflag CFLAGS_C99FSE -fexcess-precision=standard \
308 || { test "$ARCH" = i386 && tryflag CFLAGS_C99FSE -ffloat-store ; }
309 tryflag CFLAGS_C99FSE -frounding-math
310
311 #
312 # We may use the may_alias attribute if __GNUC__ is defined, so
313 # if the compiler defines __GNUC__ but does not provide it,
314 # it must be defined away as part of the CFLAGS.
315 #
316 printf "checking whether compiler needs attribute((may_alias)) suppression... "
317 cat > "$tmpc" <<EOF
318 typedef int
319 #ifdef __GNUC__
320 __attribute__((__may_alias__))
321 #endif
322 x;
323 EOF
324 if $CC $CFLAGS_C99FSE -I./arch/$ARCH -I./include $CPPFLAGS $CFLAGS \
325   -c -o /dev/null "$tmpc" >/dev/null 2>&1 ; then
326 printf "no\n"
327 else
328 printf "yes\n"
329 CFLAGS_C99FSE="$CFLAGS_C99FSE -D__may_alias__="
330 fi
331
332 #
333 # The GNU toolchain defaults to assuming unmarked files need an
334 # executable stack, potentially exposing vulnerabilities in programs
335 # linked with such object files. Fix this.
336 #
337 tryflag CFLAGS_C99FSE -Wa,--noexecstack
338
339 #
340 # Check for options to disable stack protector, which needs to be
341 # disabled for a few early-bootstrap translation units. If not found,
342 # this is not an error; we assume the toolchain does not do ssp.
343 #
344 tryflag CFLAGS_NOSSP -fno-stack-protector
345
346 #
347 # Check for options that may be needed to prevent the compiler from
348 # generating self-referential versions of memcpy,, memmove, memcmp,
349 # and memset. Really, we should add a check to determine if this
350 # option is sufficient, and if not, add a macro to cripple these
351 # functions with volatile...
352 #
353 tryflag CFLAGS_MEMOPS -fno-tree-loop-distribute-patterns
354
355 #
356 # Enable debugging if requessted.
357 #
358 test "$debug" = yes && CFLAGS_AUTO=-g
359
360 #
361 # Preprocess asm files to add extra debugging information if debug is
362 # enabled, our assembler supports the needed directives, and the
363 # preprocessing script has been written for our architecture.
364 #
365 printf "checking whether we should preprocess assembly to add debugging information... "
366 if fnmatch '-g*|*\ -g*' "$CFLAGS_AUTO $CFLAGS" &&
367    test -f "tools/add-cfi.$ARCH.awk" &&
368    printf ".file 1 \"srcfile.s\"\n.line 1\n.cfi_startproc\n.cfi_endproc" | $CC -g -x assembler -c -o /dev/null 2>/dev/null -
369 then
370   ADD_CFI=yes
371 else
372   ADD_CFI=no
373 fi
374 printf "%s\n" "$ADD_CFI"
375
376 #
377 # Possibly add a -O option to CFLAGS and select modules to optimize with
378 # -O3 based on the status of --enable-optimize and provided CFLAGS.
379 #
380 printf "checking for optimization settings... "
381 case "x$optimize" in
382 xauto)
383 if fnmatch '-O*|*\ -O*' "$CFLAGS_AUTO $CFLAGS" ; then
384 printf "using provided CFLAGS\n" ;optimize=no
385 else
386 printf "using defaults\n" ; optimize=yes
387 fi
388 ;;
389 xsize|xnone) printf "minimize size\n" ; optimize=size ;;
390 xno|x) printf "disabled\n" ; optimize=no ;;
391 *) printf "custom\n" ;;
392 esac
393
394 test "$optimize" = no || tryflag CFLAGS_AUTO -Os || tryflag CFLAGS_AUTO -O2
395 test "$optimize" = yes && optimize="internal,malloc,string"
396
397 if fnmatch 'no|size' "$optimize" ; then :
398 else
399 printf "components to be optimized for speed:"
400 while test "$optimize" ; do
401 case "$optimize" in
402 *,*) this=${optimize%%,*} optimize=${optimize#*,} ;;
403 *) this=$optimize optimize=
404 esac
405 printf " $this"
406 case "$this" in
407 */*.c) ;;
408 */*) this=$this*.c ;;
409 *) this=$this/*.c ;;
410 esac
411 OPTIMIZE_GLOBS="$OPTIMIZE_GLOBS $this"
412 done
413 OPTIMIZE_GLOBS=${OPTIMIZE_GLOBS# }
414 printf "\n"
415 fi
416
417 # Always try -pipe
418 tryflag CFLAGS_AUTO -pipe
419
420 #
421 # If debugging is disabled, omit frame pointer. Modern GCC does this
422 # anyway on most archs even when debugging is enabled since the frame
423 # pointer is no longer needed for debugging.
424 #
425 if fnmatch '-g*|*\ -g*' "$CFLAGS_AUTO $CFLAGS" ; then :
426 else 
427 tryflag CFLAGS_AUTO -fomit-frame-pointer
428 fi
429
430 #
431 # Modern GCC wants to put DWARF tables (used for debugging and
432 # unwinding) in the loaded part of the program where they are
433 # unstrippable. These options force them back to debug sections (and
434 # cause them not to get generated at all if debugging is off).
435 #
436 tryflag CFLAGS_AUTO -fno-unwind-tables
437 tryflag CFLAGS_AUTO -fno-asynchronous-unwind-tables
438
439 #
440 # Attempt to put each function and each data object in its own
441 # section. This both allows additional size optimizations at link
442 # time and works around a dangerous class of compiler/assembler bugs
443 # whereby relative address expressions are constant-folded by the
444 # assembler even when one or more of the symbols involved is
445 # replaceable. See gas pr 18561 and gcc pr 66609, 68178, etc.
446 #
447 tryflag CFLAGS_AUTO -ffunction-sections
448 tryflag CFLAGS_AUTO -fdata-sections
449
450 #
451 # On x86, make sure we don't have incompatible instruction set
452 # extensions enabled by default. This is bad for making static binaries.
453 # We cheat and use i486 rather than i386 because i386 really does not
454 # work anyway (issues with atomic ops).
455 # Some build environments pass -march and -mtune options via CC, so
456 # check both CC and CFLAGS.
457 #
458 if test "$ARCH" = "i386" ; then
459 fnmatch '-march=*|*\ -march=*' "$CC $CFLAGS" || tryldflag CFLAGS_AUTO -march=i486
460 fnmatch '-mtune=*|*\ -mtune=*' "$CC $CFLAGS" || tryldflag CFLAGS_AUTO -mtune=generic
461 fi
462
463 #
464 # Even with -std=c99, gcc accepts some constructs which are constraint
465 # violations. We want to treat these as errors regardless of whether
466 # other purely stylistic warnings are enabled -- especially implicit
467 # function declarations, which are a dangerous programming error.
468 #
469 tryflag CFLAGS_AUTO -Werror=implicit-function-declaration
470 tryflag CFLAGS_AUTO -Werror=implicit-int
471 tryflag CFLAGS_AUTO -Werror=pointer-sign
472 tryflag CFLAGS_AUTO -Werror=pointer-arith
473
474 if test "x$warnings" = xyes ; then
475 tryflag CFLAGS_AUTO -Wall
476 tryflag CFLAGS_AUTO -Wno-parentheses
477 tryflag CFLAGS_AUTO -Wno-uninitialized
478 tryflag CFLAGS_AUTO -Wno-missing-braces
479 tryflag CFLAGS_AUTO -Wno-unused-value
480 tryflag CFLAGS_AUTO -Wno-unused-but-set-variable
481 tryflag CFLAGS_AUTO -Wno-unknown-pragmas
482 tryflag CFLAGS_AUTO -Wno-pointer-to-int-cast
483 fi
484
485 if test "x$visibility" = xauto ; then
486 # This test checks toolchain support for several things:
487 # - the -include option
488 # - the attributes/pragmas used in vis.h
489 # - linking code that takes the address of protected symbols
490 # - gcc 3.x bug that wrongly claims declarations mismatch
491 printf "checking whether global visibility preinclude works... "
492 cat > "$tmpc" <<EOF
493 __attribute__((__visibility__("default")))
494 extern struct a *const x;
495 typedef struct a b;
496 extern b *const x;
497 b *const x;
498 int (*fp)(void);
499 int foo(void) { }
500 int bar(void) { fp = foo; return foo(); }
501 EOF
502 if $CC $CFLAGS_C99FSE $CPPFLAGS $CFLAGS \
503   -DSHARED -fPIC -I./src/internal -include vis.h \
504   -nostdlib -shared -Wl,-Bsymbolic-functions \
505   -o /dev/null "$tmpc" >/dev/null 2>&1 ; then
506 visibility=yes
507 else
508 visibility=no
509 fi
510 printf "%s\n" "$visibility"
511 fi
512
513 if test "x$visibility" = xyes ; then
514 CFLAGS_AUTO="$CFLAGS_AUTO -include vis.h"
515 CFLAGS_AUTO="${CFLAGS_AUTO# }"
516 fi
517
518 # Reduce space lost to padding for alignment purposes by sorting data
519 # objects according to their alignment reqirements. This approximates
520 # optimal packing.
521 tryldflag LDFLAGS_AUTO -Wl,--sort-section,alignment
522 tryldflag LDFLAGS_AUTO -Wl,--sort-common
523
524 # Some patched GCC builds have these defaults messed up...
525 tryldflag LDFLAGS_AUTO -Wl,--hash-style=both
526
527 # Prevent linking if there are undefined symbols; if any exist,
528 # libc.so will crash at runtime during relocation processing.
529 # The common way this can happen is failure to link the compiler
530 # runtime library; implementation error is also a possibility.
531 tryldflag LDFLAGS_AUTO -Wl,--no-undefined
532
533 test "$shared" = "no" || {
534 # Disable dynamic linking if ld is broken and can't do -Bsymbolic-functions
535 LDFLAGS_DUMMY=
536 tryldflag LDFLAGS_DUMMY -Wl,-Bsymbolic-functions || {
537 test "$shared" = "yes" && fail "$0: error: linker cannot build shared library"
538 printf "warning: disabling dynamic linking support\n"
539 shared=no
540 }
541 }
542
543 # Find compiler runtime library
544 test -z "$LIBCC" && tryldflag LIBCC -lgcc && tryldflag LIBCC -lgcc_eh
545 test -z "$LIBCC" && tryldflag LIBCC -lcompiler_rt
546 test -z "$LIBCC" && try_libcc=`$CC -print-file-name=libpcc.a 2>/dev/null` \
547                  && tryldflag LIBCC "$try_libcc"
548 printf "using compiler runtime libraries: %s\n" "$LIBCC"
549
550 # Figure out arch variants for archs with variants
551 SUBARCH=
552 t="$CFLAGS_C99FSE $CPPFLAGS $CFLAGS"
553
554 if test "$ARCH" = "x86_64" ; then
555 trycppif __ILP32__ "$t" && ARCH=x32
556 fi
557
558 if test "$ARCH" = "arm" ; then
559 trycppif __ARMEB__ "$t" && SUBARCH=${SUBARCH}eb
560 trycppif __ARM_PCS_VFP "$t" && SUBARCH=${SUBARCH}hf
561 fi
562
563 if test "$ARCH" = "aarch64" ; then
564 trycppif __AARCH64EB__ "$t" && SUBARCH=${SUBARCH}_be
565 fi
566
567 if test "$ARCH" = "mips" ; then
568 trycppif "_MIPSEL || __MIPSEL || __MIPSEL__" "$t" && SUBARCH=${SUBARCH}el
569 trycppif __mips_soft_float "$t" && SUBARCH=${SUBARCH}-sf
570 fi
571
572 test "$ARCH" = "microblaze" && trycppif __MICROBLAZEEL__ "$t" \
573 && SUBARCH=${SUBARCH}el
574
575 if test "$ARCH" = "sh" ; then
576 tryflag CFLAGS_AUTO -Wa,--isa=any
577 trycppif __BIG_ENDIAN__ "$t" && SUBARCH=${SUBARCH}eb
578 if trycppif "__SH_FPU_ANY__ || __SH4__" "$t" ; then
579 # Some sh configurations are broken and replace double with float
580 # rather than using softfloat when the fpu is present but only
581 # supports single precision. Reject them.
582 printf "checking whether compiler's double type is IEEE double... "
583 echo 'typedef char dblcheck[(int)sizeof(double)-5];' > "$tmpc"
584 if $CC $CFLAGS_C99FSE $CPPFLAGS $CFLAGS -c -o /dev/null "$tmpc" >/dev/null 2>&1 ; then
585 printf "yes\n"
586 else
587 printf "no\n"
588 fail "$0: error: compiler's floating point configuration is unsupported"
589 fi
590 else
591 SUBARCH=${SUBARCH}-nofpu
592 fi
593 if trycppif __SH_FDPIC__ "$t" ; then
594 SUBARCH=${SUBARCH}-fdpic
595 fi
596 fi
597
598 test "$SUBARCH" \
599 && printf "configured for %s variant: %s\n" "$ARCH" "$ARCH$SUBARCH"
600
601 case "$ARCH$SUBARCH" in
602 arm) ASMSUBARCH=el ;;
603 *) ASMSUBARCH=$SUBARCH ;;
604 esac
605
606 #
607 # Some archs (powerpc) have different possible long double formats
608 # that the compiler can be configured for. The logic for whether this
609 # is supported is in bits/float.h; in general, it is not. We need to
610 # check for mismatches here or code in printf, strotd, and scanf will
611 # be dangerously incorrect because it depends on (1) the macros being
612 # correct, and (2) IEEE semantics.
613 #
614 printf "checking whether compiler's long double definition matches float.h... "
615 echo '#include <float.h>' > "$tmpc"
616 echo '#if LDBL_MANT_DIG == 53' >> "$tmpc"
617 echo 'typedef char ldcheck[9-(int)sizeof(long double)];' >> "$tmpc"
618 echo '#endif' >> "$tmpc"
619 if $CC $CFLAGS_C99FSE -I./arch/$ARCH -I./include $CPPFLAGS $CFLAGS \
620   -c -o /dev/null "$tmpc" >/dev/null 2>&1 ; then
621 printf "yes\n"
622 else
623 printf "no\n"
624 fail "$0: error: unsupported long double type"
625 fi
626
627 printf "creating config.mak... "
628
629 cmdline=$(quote "$0")
630 for i ; do cmdline="$cmdline $(quote "$i")" ; done
631
632 exec 3>&1 1>config.mak
633
634
635 cat << EOF
636 # This version of config.mak was generated by:
637 # $cmdline
638 # Any changes made here will be lost if configure is re-run
639 ARCH = $ARCH
640 SUBARCH = $SUBARCH
641 ASMSUBARCH = $ASMSUBARCH
642 prefix = $prefix
643 exec_prefix = $exec_prefix
644 bindir = $bindir
645 libdir = $libdir
646 includedir = $includedir
647 syslibdir = $syslibdir
648 CC = $CC
649 CFLAGS = $CFLAGS
650 CFLAGS_AUTO = $CFLAGS_AUTO
651 CFLAGS_C99FSE = $CFLAGS_C99FSE
652 CFLAGS_MEMOPS = $CFLAGS_MEMOPS
653 CFLAGS_NOSSP = $CFLAGS_NOSSP
654 CPPFLAGS = $CPPFLAGS
655 LDFLAGS = $LDFLAGS
656 LDFLAGS_AUTO = $LDFLAGS_AUTO
657 CROSS_COMPILE = $CROSS_COMPILE
658 LIBCC = $LIBCC
659 OPTIMIZE_GLOBS = $OPTIMIZE_GLOBS
660 ALL_TOOLS = $tools
661 TOOL_LIBS = $tool_libs
662 ADD_CFI = $ADD_CFI
663 EOF
664 test "x$static" = xno && echo "STATIC_LIBS ="
665 test "x$shared" = xno && echo "SHARED_LIBS ="
666 test "x$cc_family" = xgcc && echo 'WRAPCC_GCC = $(CC)'
667 test "x$cc_family" = xclang && echo 'WRAPCC_CLANG = $(CC)'
668 exec 1>&3 3>&-
669
670 printf "done\n"