1
0

configure 18 KB

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