5 Usage: $0 [OPTION]... [VAR=VALUE]... [BUILDTYPE]
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.
10 Defaults for the options are specified in brackets.
12 Installation directories:
13 --prefix=PREFIX main installation prefix [/usr/local/musl]
14 --exec-prefix=EPREFIX installation prefix for executable files [PREFIX]
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]
23 --target=TARGET configure to run on target TARGET [detected]
24 --build=BUILD same as --target
27 --enable-debug build with debugging information [disabled]
28 --enable-warnings build with recommended warnings flags [disabled]
29 --enable-gcc-wrapper build musl-gcc toolchain wrapper [auto]
30 --disable-shared inhibit building shared library [enabled]
31 --disable-static inhibit building static library [enabled]
33 Some influential environment variables:
34 CC C compiler command [detected]
35 CFLAGS C compiler flags [-Os -pipe ...]
37 Use these variables to override the choices made by configure.
45 echo () { printf "%s\n" "$*" ; }
46 fail () { echo "$*" ; exit 1 ; }
47 fnmatch () { eval "case \"\$2\" in $1) return 0 ;; *) return 1 ;; esac" ; }
48 cmdexists () { type "$1" >/dev/null 2>&1 ; }
49 trycc () { test -z "$CC" && cmdexists "$1" && CC=$1 ; }
52 if eval "test -z \"\${$1}\"" ; then eval "$1=\$2"
53 else eval "fnmatch '*/' \"\${$1}\"" && eval "$1=\${$1%/}" ; fi
57 printf "checking whether compiler accepts %s... " "$2"
58 echo "typedef int x;" > "$tmpc"
59 if "$CC" "$2" -c -o /dev/null "$tmpc" 2>/dev/null ; then
61 eval "$1=\"\${$1} \$2\""
72 # Beginning of actual script
89 --prefix=*) prefix=${arg#*=} ;;
90 --exec-prefix=*) exec_prefix=${arg#*=} ;;
91 --bindir=*) bindir=${arg#*=} ;;
92 --libdir=*) libdir=${arg#*=} ;;
93 --includedir=*) includedir=${arg#*=} ;;
94 --syslibdir=*) syslibdir=${arg#*=} ;;
95 --enable-shared|--enable-shared=yes) shared=yes ;;
96 --disable-shared|--enable-shared=no) shared=no ;;
97 --enable-static|--enable-static=yes) static=yes ;;
98 --disable-static|--enable-static=no) static=no ;;
99 --enable-debug|--enable-debug=yes) debug=yes ;;
100 --disable-debug|--enable-debug=no) debug=no ;;
101 --enable-warnings|--enable-warnings=yes) warnings=yes ;;
102 --disable-warnings|--enable-warnings=no) warnings=no ;;
103 --enable-gcc-wrapper|--enable-gcc-wrapper=yes) wrapper=yes ;;
104 --disable-gcc-wrapper|--enable-gcc-wrapper=no) wrapper=no ;;
105 --enable-*|--disable-*|--with-*|--without-*|--*dir=*|--host=*) ;;
106 --build=*|--target=*) build=${arg#*=} ;;
107 -* ) echo "$0: unknown option $arg" ;;
108 CC=*) CC=${arg#*=} ;;
109 CFLAGS=*) CFLAGS=${arg#*=} ;;
110 CPPFLAGS=*) CPPFLAGS=${arg#*=} ;;
111 LDFLAGS=*) LDFLAGS=${arg#*=} ;;
116 setdir prefix /usr/local/musl
117 setdir exec_prefix '$(prefix)'
118 setdir bindir '$(exec_prefix)/bin'
119 setdir libdir '$(prefix)/lib'
120 setdir includedir '$(prefix)/include'
121 setdir syslibdir '/lib'
124 # Get a temp filename we can use
128 while : ; do i=$(($i+1))
129 tmpc="./conf$$-$PPID-$i.c"
130 2>/dev/null > "$tmpc" && break
131 test "$i" -gt 50 && fail "$0: cannot create temporary file $tmpc"
134 trap 'rm "$tmpc"' EXIT INT QUIT TERM HUP
137 # Find a C compiler to use
139 printf "checking for C compiler... "
144 test -n "$CC" || { echo "$0: cannot find a C compiler" ; exit 1 ; }
147 # Only build musl-gcc wrapper if toolchain does not already target musl
149 if test -z "$wrapper" ; then
150 printf "checking whether compiler is gcc... "
151 if fnmatch 'gcc*|GCC*' "$("$CC" --version 2>/dev/null)" ; then
153 printf "checking whether to build musl-gcc wrapper... "
156 case "$line" in */ld-musl-*) wrapper=no ;; esac
169 # Find the build architecture
171 printf "checking build system type... "
172 test -n "$build" || build=$("$CC" -dumpmachine 2>/dev/null) || build=unknown
173 printf "%s\n" "$build"
176 # Convert to just ARCH
181 x86_64*) ARCH=x86_64 ;;
182 unknown) fail "$0: unable to detect built target; try $0 --build=..." ;;
183 *) fail "$0: unknown or unsupported build target \"$build\"" ;;
187 # Try to get a conforming C99 freestanding environment
189 tryflag CFLAGS_C99FSE -std=c99
190 tryflag CFLAGS_C99FSE -nostdinc
191 tryflag CFLAGS_C99FSE -ffreestanding \
192 || tryflag CFLAGS_C99FSE -fno-builtin
193 tryflag CFLAGS_C99FSE -fexcess-precision=standard \
194 || tryflag CFLAGS_C99FSE -ffloat-store
195 tryflag CFLAGS_C99FSE -frounding-math
198 # Setup basic default CFLAGS: debug, optimization, and -pipe
200 if fnmatch '-O*|*\ -O*' "$CFLAGS_AUTO $CFLAGS" ; then :
202 tryflag CFLAGS_AUTO -Os || tryflag CFLAGS_AUTO -O2
204 test "x$debug" = xyes && CFLAGS_AUTO="-g"
205 tryflag CFLAGS_AUTO -pipe
208 # If debugging is disabled, omit bloated DWARF2 unwind tables & frame ptr
210 if fnmatch '-g*|*\ -g*' "$CFLAGS_AUTO $CFLAGS" ; then :
212 tryflag CFLAGS_AUTO -fno-unwind-tables
213 tryflag CFLAGS_AUTO -fno-asynchronous-unwind-tables
214 tryflag CFLAGS_AUTO -fomit-frame-pointer
218 # Some optimization levels add bloated alignment that hurt performance
220 tryflag CFLAGS_AUTO -falign-functions=1
221 tryflag CFLAGS_AUTO -falign-labels=1
222 tryflag CFLAGS_AUTO -falign-loops=1
223 tryflag CFLAGS_AUTO -falign-jumps=1
226 # On x86, make sure we don't have incompatible instruction set
227 # extensions enabled by default. This is bad for making static binaries.
228 # We cheat and use i486 rather than i386 because i386 really does not
229 # work anyway (issues with atomic ops).
231 if test "$ARCH" = "i386" ; then
232 fnmatch '-march=*|*\ -march=*' "$CFLAGS" || tryflag CFLAGS_AUTO -march=i486
233 fnmatch '-mtune=*|*\ -mtune=*' "$CFLAGS" || tryflag CFLAGS_AUTO -mtune=generic
236 if test "x$warnings" = xyes ; then
237 tryflag CFLAGS_AUTO -Wall
238 tryflag CFLAGS_AUTO -Wpointer-arith
239 tryflag CFLAGS_AUTO -Wcast-align
240 tryflag CFLAGS_AUTO -Wno-parentheses
241 tryflag CFLAGS_AUTO -Wno-uninitialized
242 tryflag CFLAGS_AUTO -Wno-missing-braces
243 tryflag CFLAGS_AUTO -Wno-unused-value
244 tryflag CFLAGS_AUTO -Wno-unused-but-set-variable
245 tryflag CFLAGS_AUTO -Wno-unknown-pragmas
249 printf "creating config.mak... "
251 exec 3>&1 1>config.mak
255 # This version of config.mak was generated by configure
256 # Any changes made here will be lost if configure is re-run
259 exec_prefix = $exec_prefix
262 includedir = $includedir
263 syslibdir = $syslibdir
265 CFLAGS= $CFLAGS_AUTO $CFLAGS
266 CFLAGS_C99FSE = $CFLAGS_C99FSE
270 test "x$static" = xno && echo "STATIC_LIBS ="
271 test "x$shared" = xno && echo "SHARED_LIBS ="
272 test "x$wrapper" = xno && echo "ALL_TOOLS ="
273 test "x$wrapper" = xno && echo "TOOL_LIBS ="