• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#                                               -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3# Use AM_MAINTANER_MODE somewhere in this file once reconfigurations settle down.
4
5AC_PREREQ([2.69])
6AC_INIT([mingw-w64-runtime],[4.0b],[mingw-w64-public@lists.sourceforge.net])
7AC_CONFIG_AUX_DIR([build-aux])
8AC_CONFIG_SRCDIR([ChangeLog])
9AC_CONFIG_HEADER([config.h])
10
11AM_INIT_AUTOMAKE([1.14 foreign subdir-objects])
12AM_MAINTAINER_MODE
13
14AC_CANONICAL_HOST
15
16AC_MSG_CHECKING([for sysroot])
17AC_ARG_WITH([sysroot],
18  [AS_HELP_STRING([--with-sysroot=DIR],
19    [Search for headers within DIR/include (default: prefix)])],
20  [],
21  [AS_VAR_SET([with_sysroot],[yes])])
22AS_CASE([$with_sysroot],
23  [no],[],
24  [yes],[AS_VAR_SET([with_sysroot],[$prefix])],
25  [])
26AC_MSG_RESULT([$with_sysroot])
27AS_VAR_IF([with_sysroot],[no],[],[AS_VAR_SET([TARGET_SYSTEM_ROOT],[$with_sysroot])])
28AC_SUBST([TARGET_SYSTEM_ROOT])
29AM_CONDITIONAL([WITHSYSROOT],[AS_VAR_TEST_SET([TARGET_SYSTEM_ROOT])])
30
31
32# Checks for programs.
33# Checks for headers, libs, etc need to utilize the sysroot... no idea how
34AC_NO_EXECUTABLES
35AC_PROG_SED
36AC_PROG_AWK
37AC_PROG_CC
38AC_PROG_CXX
39AC_PROG_CPP
40AC_PROG_INSTALL
41AC_PROG_RANLIB
42AC_CHECK_TOOL([DLLTOOL], [dlltool], [:])
43AM_PROG_AR
44AM_PROG_AS
45dnl Remove this once automake fixes the bug where AS is not defined according to $host
46AC_CHECK_TOOL([AS], [as], [:])
47dnl ---
48AM_PROG_CC_C_O
49
50AC_MSG_CHECKING([whether to build a w32api package for Cygwin])
51AC_ARG_ENABLE([w32api],
52  [AS_HELP_STRING([--enable-w32api],
53    [Enable building a w32api package for Cygwin])],
54  [],
55  [AS_VAR_SET([enable_w32api],[no])])
56AC_MSG_RESULT([$enable_w32api])
57AS_CASE([$enable_w32api],
58  [no],[],
59  [yes],[AS_VAR_SET([W32API])
60	 AS_VAR_SET([includedir],[${prefix}/include/w32api])],
61  [AC_MSG_ERROR([invalid argument.  Must be either yes or no.])])
62AM_CONDITIONAL([W32API], [AS_VAR_TEST_SET([W32API])])
63
64AC_MSG_CHECKING([whether to build the Win32 libraries])
65AC_ARG_ENABLE([lib32],
66  [AS_HELP_STRING([--enable-lib32],
67    [Build the Win32 libraries])],
68  [],
69  [
70    _save_CFLAGS="$CFLAGS"
71    CFLAGS="$CFLAGS -m32"
72    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[const char test[(sizeof(void*)==4)?0:-1];]],[])],
73      [enable_lib32=yes],
74      [enable_lib32=no])
75    CFLAGS="$_save_CFLAGS"])
76AC_MSG_RESULT([$enable_lib32])
77AS_CASE([$enable_lib32],
78  [no],[],
79  [yes],[AS_VAR_SET([LIB32])],
80  [AC_MSG_ERROR([invalid argument.  Must be either yes or no.])])
81AM_CONDITIONAL([LIB32], [AS_VAR_TEST_SET([LIB32])])
82
83AC_MSG_CHECKING([whether to build the Win64 libraries])
84AC_ARG_ENABLE([lib64],
85  [AS_HELP_STRING([--enable-lib64],
86    [Build the Win64 libraries])],
87  [],
88  [
89    _save_CFLAGS="$CFLAGS"
90    CFLAGS="$CFLAGS -m64"
91    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[const char test[(sizeof(void*)==8)?0:-1];]],[])],
92      [enable_lib64=yes],
93      [enable_lib64=no])
94    CFLAGS="$_save_CFLAGS"])
95AC_MSG_RESULT([$enable_lib64])
96AS_CASE([$enable_lib64],
97  [no],[],
98  [yes],[AS_VAR_SET([LIB64])],
99  [AC_MSG_ERROR([invalid argument.  Must be either yes or no.])])
100AM_CONDITIONAL([LIB64], [AS_VAR_TEST_SET([LIB64])])
101
102AC_MSG_CHECKING([whether to build the WinARM32 libraries])
103AC_ARG_ENABLE([libarm32],
104  [AS_HELP_STRING([--enable-libarm32],
105    [Build the WinARM32 libraries])],
106  [],
107  [AS_CASE([$host_cpu],
108    [armv7*],[enable_libarm32=yes],
109    [*],[enable_libarm32=no])
110  ])
111AC_MSG_RESULT([$enable_libarm32])
112AS_CASE([$enable_libarm32],
113  [no],[],
114  [yes],[AS_VAR_SET([LIBARM32])],
115  [AC_MSG_ERROR([invalid argument.  Must be either yes or no.])])
116AM_CONDITIONAL([LIBARM32], [AS_VAR_TEST_SET([LIBARM32])])
117
118AS_VAR_IF([enable_libarm32],[yes],[
119  AS_IF([AS_VAR_TEST_SET([LIB32]) || AS_VAR_TEST_SET([LIB64])],
120    [AC_MSG_WARN([Building the runtime to use libarm32 with lib32 or lib64 is unsupported.])])])
121
122AC_MSG_CHECKING([whether to build the WinARM64 libraries])
123AC_ARG_ENABLE([libarm64],
124  [AS_HELP_STRING([--enable-libarm64],
125    [Build the WinARM64 libraries])],
126  [],
127  [AS_CASE([$host_cpu],
128    [aarch64*],[enable_libarm64=yes],
129    [*],[enable_libarm64=no])
130  ])
131AC_MSG_RESULT([$enable_libarm64])
132AS_CASE([$enable_libarm64],
133  [no],[],
134  [yes],[AS_VAR_SET([LIBARM64])],
135  [AC_MSG_ERROR([invalid argument.  Must be either yes or no.])])
136AM_CONDITIONAL([LIBARM64], [AS_VAR_TEST_SET([LIBARM64])])
137
138AS_VAR_IF([enable_libarm64],[yes],[
139  AS_IF([AS_VAR_TEST_SET([LIB32]) || AS_VAR_TEST_SET([LIB64]) || AS_VAR_TEST_SET([LIBARM32])],
140    [AC_MSG_WARN([Building the runtime to use libarm64 with lib32, lib64 or libarm32 is unsupported.])])])
141
142AS_CASE([$host_cpu],
143  [x86_64],[
144    libx8664suffx=lib
145    libx8632suffx=lib32
146    libarm64suffx=libarm64
147    libarm32suffx=libarm32],
148  [i*86],[
149    libx8664suffx=lib64
150    libx8632suffx=lib
151    libarm64suffx=libarm64
152    libarm32suffx=libarm32],
153  [aarch64*],[
154    libx8664suffx=libx8664
155    libx8632suffx=libx8632
156    libarm64suffx=lib
157    libarm32suffx=lib32],
158  [armv7*],[
159    libx8664suffx=libx8664
160    libx8632suffx=libx8632
161    libarm64suffx=lib64
162    libarm32suffx=lib],
163  [
164    libx8664suffx=libx8664
165    libx8632suffx=libx8632
166    libarm64suffx=libarm64
167    libarm32suffx=libarm32]
168)
169
170AS_VAR_IF([enable_w32api],[yes],[
171  libx8664suffx=$libx8664suffx/w32api
172  libx8632suffx=$libx8632suffx/w32api
173  libarm64suffx=$libarm64suffx/w32api
174  libarm32suffx=$libarm32suffx/w32api
175])
176
177AC_SUBST([LIBX8664SUFFIXDIR],[$libx8664suffx])
178AC_SUBST([LIBX8632SUFFIXDIR],[$libx8632suffx])
179AC_SUBST([LIBARM64SUFFIXDIR],[$libarm64suffx])
180AC_SUBST([LIBARM32SUFFIXDIR],[$libarm32suffx])
181
182# Checks for features.
183
184AC_MSG_CHECKING([whether to use genlib])
185AC_ARG_WITH([genlib],
186  [AS_HELP_STRING([--with-genlib=PATH],
187    [Whether to build import libraries via the genlib tool (default: no)])],
188  [],
189  [with_genlib=no])
190AS_CASE([$with_genlib],
191  [yes],[AC_CHECK_TOOL([GENLIB], [genlib], [:])],
192  [no],[],
193  [AS_VAR_SET([GENLIB], [$with_genlib])])
194AM_CONDITIONAL([WITH_GENLIB], [AS_VAR_TEST_SET([GENLIB])])
195AC_MSG_RESULT([$with_genlib])
196
197AC_MSG_CHECKING([whether to enable globbing])
198AC_ARG_ENABLE([wildcard],
199  [AS_HELP_STRING([--enable-wildcard],
200    [Enable command line globbing])],
201  [],
202  [enable_wildcard=no])
203AS_CASE([$enable_wildcard],
204  [yes],[enable_wildcard_value=-1],
205  [no],[enable_wildcard_value=0],
206  [AC_MSG_ERROR([Please only use --enable-wildcard or --disable-wildcard, without any additional arguments.])])
207AC_DEFINE_UNQUOTED([__ENABLE_GLOBBING],[$enable_wildcard_value],[Define as -1 to enable command line globbing or 0 to disable it.])
208AC_MSG_RESULT([$enable_wildcard])
209
210AC_MSG_CHECKING([whether to enable private exports])
211AC_ARG_ENABLE([private-exports],
212  [AS_HELP_STRING([--enable-private-exports],
213    [Enable exporting private internal functions])],
214  [],
215  [enable_private_exports=no])
216AS_CASE([$enable_private_exports],
217  [yes],[],
218  [no],[],
219  [AC_MSG_ERROR([Please only use --enable-private-exports  or --disable-private-exports, without any additional arguments.])])
220AM_CONDITIONAL([PRIVATE_EXPORTS],[test $enable_private_exports = yes])
221AC_MSG_RESULT([$enable_private_exports])
222
223AC_MSG_CHECKING([whether to enable delay import libs])
224AC_ARG_ENABLE([delay-import-libs],
225  [AS_HELP_STRING([--enable-delay-import-libs],
226    [Enable creation of delay-import libraries])],
227  [],
228  [enable_delay_import_libs=no])
229AS_CASE([$enable_delay_import_libs],
230  [yes],[],
231  [no],[],
232  [AC_MSG_ERROR([Please only use --enable-delay-import-libs  or --disable-delay-import-libs, without any additional arguments.])])
233AM_CONDITIONAL([DELAY_IMPORT_LIBS],[test $enable_delay_import_libs = yes])
234AC_MSG_RESULT([$enable_delay_import_libs])
235
236AC_MSG_CHECKING([what to provide as libmsvcrt.a])
237AC_ARG_WITH([default-msvcrt],
238  [AS_HELP_STRING([--with-default-msvcrt=LIB],
239    [Lib to provide as libmsvcrt.a (default: msvcrt-os)])],
240  [],
241  [with_default_msvcrt=msvcrt-os])
242if test "$with_default_msvcrt" = "msvcrt"; then
243  with_default_msvcrt=msvcrt-os
244fi
245AC_MSG_RESULT([$with_default_msvcrt])
246AS_VAR_SET([MSVCRT_LIB],[lib${with_default_msvcrt}.a])
247AC_SUBST([MSVCRT_LIB])
248
249AC_MSG_CHECKING([whether to enable experimental features])
250AC_ARG_ENABLE([experimental],
251  [AS_HELP_STRING([--enable-experimental],
252    [Enable experimental features, valid options are comma separated combination of all, dfp, printf128, registeredprintf, softmath.])],
253    [experimental_features=$enable_experimental],
254    [experimental_features="no"])
255
256enable_dfp=no
257enable_printf128=no
258enable_registeredprintf=no
259enable_softmath=no
260experiment_list=$($AWK 'BEGIN{OFS=" "; len = split(ARGV@<:@1@:>@,str,","); for(; len != 0; len--) print str@<:@len@:>@ }' "$experimental_features")
261
262for arg in $experiment_list
263do
264AS_CASE([$arg],
265  [dfp],[enable_dfp=yes],
266  [printf128],[enable_printf128=yes],
267  [registeredprintf],[enable_registeredprintf=yes],
268  [softmath],[enable_softmath=yes],
269  [all], [enable_dfp=yes; enable_printf128=yes; enable_registeredprintf=yes; enable_softmath=yes; ],
270  [yes], [enable_dfp=yes; enable_printf128=yes; enable_registeredprintf=yes; enable_softmath=yes; ],
271  [no],  [enable_dfp=no; enable_printf128=no; enable_registeredprintf=no; enable_softmath=no; ],
272  [AC_MSG_ERROR([Unknown option \"$experiment\"])]
273)
274done
275
276AC_MSG_RESULT([$experimental_features])
277AM_CONDITIONAL([ENABLE_DFP],[ test "$enable_dfp" = "yes" ])
278AM_CONDITIONAL([ENABLE_PRINTF128],[ test "$enable_printf128" = "yes" ])
279AM_CONDITIONAL([ENABLE_REGISTEREDPRINTF],[ test "$enable_registeredprintf" = "yes" ])
280AM_CONDITIONAL([ENABLE_SOFTMATH],[ test "$enable_softmath" = "yes" ])
281AM_COND_IF([ENABLE_DFP],[AC_DEFINE([__ENABLE_DFP],[1],[Build DFP support])])
282AM_COND_IF([ENABLE_PRINTF128],[AC_DEFINE([__ENABLE_PRINTF128],[1],[Build DFP support])])
283AM_COND_IF([ENABLE_REGISTEREDPRINTF],[AC_DEFINE([__ENABLE_REGISTEREDPRINTF],[1],[Build DFP support])])
284AM_COND_IF([ENABLE_SOFTMATH],[AC_DEFINE([__ENABLE_SOFTMATH],[1],[Build softmath routines])])
285
286AC_MSG_CHECKING([whether the compiler supports -municode])
287AC_ARG_ENABLE([tests-unicode],
288  [AS_HELP_STRING([--enable-tests-unicode],
289    [Enable the unicode testsuite without testing the compiler for support.])],
290  [],[
291    saved_CFLAGS="$CFLAGS"
292    CFLAGS="$CFLAGS -municode"
293    AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
294#ifndef UNICODE
295# error UNICODE not defined with -municode
296#endif
297    ]])],
298    [enable_tests_unicode=yes],
299    [enable_tests_unicode=no])
300    CFLAGS="$saved_CFLAGS"])
301AM_CONDITIONAL([ENABLE_TESTS_UNICODE],[test x$enable_tests_unicode = xyes])
302AC_MSG_RESULT([$enable_tests_unicode])
303
304AC_MSG_CHECKING([whether the linker provides __CTOR_LIST__])
305saved_LDFLAGS="$LDFLAGS"
306saved_ac_no_link="$ac_no_link"
307LDFLAGS="$LDFLAGS -nostdlib"
308# Note that binutils 2.30 is broken with respect to __CTOR_LIST__ (the change
309# was reverted for 2.31); it does provide __CTOR_LIST__ automatically only if
310# necessary. But as long as there's no other definition of it, a fallback
311# __CTOR_LIST__ gets pulled in from libgcc, and this fallback is only a dummy
312# to prevent linker errors (in general) and isn't assigned to the right
313# sections. Therefore, it'd be better to test whether we can/should provide
314# our own __CTOR_LIST__.
315
316# But we can't test whether we can provide our own __CTOR_LIST__ with binutils
317# ld either; even if our test provides its own symbol __CTOR_LIST__, ld will
318# include it but silently use its own provided __CTOR_LIST__ instead, and
319# won't error out. For actual real use, that'd mean a stray broken pointer in
320# the .ctors section.
321
322# This test uses both mainCRTStartup and main functions, to let lld deduce
323# entry point and subsystem automatically without having to manually specify,
324# anything. And as long as main() is provided, we need to implicitly provide
325# __main as well, since the compiler injects a call to it.
326
327# Run this test manually instead of wrapping it in AC_LINK_IFELSE; when
328# bootstrapping an environment, an earlier linking test will have failed,
329# which both causes autoconf to refuse to run any linker test at all,
330# and even if $ac_no_link is overridden, the linker test iteslf will explicitly
331# check that the linker actually produced output in the given output file.
332# If $ac_exeext is empty, as it is when the earlier linker test failed, gcc
333# will behave differently depending on version. If run with "gcc conftest.c
334# -o conftest", old versions will produce explicitly a file named "conftest",
335# while modern GCC versions will produce "conftest.exe". AC_LINK_IFELSE will
336# explicitly look for the output file named "conftest$ac_exeext", which isn't
337# found, and the test fails even though linking succeeded.
338#
339# Therefore, just do a manual test; run the linking command and check the return
340# code whether it was successful or not.
341cat <<_ACEOF >conftest.$ac_ext
342#include <stdint.h>
343extern const void * __CTOR_LIST__;
344void __main(void) {
345}
346int main(void) {
347  return (int)(intptr_t)__CTOR_LIST__;
348}
349int mainCRTStartup(void) {
350  return main();
351}
352_ACEOF
353
354echo "$as_me:$LINENO: $CC conftest.$ac_ext $LDFLAGS -o conftest$ac_exeext" >&AS_MESSAGE_LOG_FD
355if $CC conftest.$ac_ext $LDFLAGS -o conftest$ac_exeext >&AS_MESSAGE_LOG_FD 2>&1; then
356  AC_DEFINE([HAVE_CTOR_LIST],[1],[Whether the linker provides __CTOR_LIST__])
357  AC_MSG_RESULT(yes)
358else
359  AC_MSG_RESULT(no)
360fi
361LDFLAGS="$saved_LDFLAGS"
362
363# Checks for libraries.
364
365# Checks for header files.
366#AC_HEADER_DIRENT
367#AC_HEADER_STDC
368#AC_CHECK_HEADERS([fcntl.h fenv.h float.h inttypes.h limits.h locale.h malloc.h stddef.h stdint.h stdlib.h string.h sys/ioctl.h sys/time.h sys/timeb.h termios.h unistd.h wchar.h wctype.h])
369
370# Checks for typedefs, structures, and compiler characteristics.
371#AC_C_INLINE
372#AC_HEADER_TIME
373#AC_C_VOLATILE
374#AC_CHECK_TYPES([ptrdiff_t])
375
376# Checks for library functions.
377#AC_FUNC_MALLOC
378#AC_FUNC_MBRTOWC
379#AC_FUNC_REALLOC
380#AC_FUNC_STRTOD
381#AC_FUNC_VPRINTF
382#AC_CHECK_FUNCS([alarm atexit btowc fesetround floor ftruncate gettimeofday isascii localeconv mbrlen memmove memset pow rint setlocale sqrt strcasecmp strchr strncasecmp strtoull strtoumax])
383
384AC_CHECK_HEADER([_mingw_mac.h], [], [AC_MSG_ERROR([Please check if the mingw-w64 header set and the build/host option are set properly.])])
385
386#Warnings and errors, default level is 3
387AC_MSG_CHECKING([for warning levels])
388AC_ARG_ENABLE([warnings],
389  [AS_HELP_STRING([[--enable-warnings[=0-5]]],
390    [Enable compile time warnings @<:@default=3@:>@])],
391  [AS_CASE([$enableval],
392    [yes], [warning_level=3],
393    [no],  [warning_level=0],
394    [[[0-5]]], [warning_level="$enableval"],
395    [warning_level=3])],
396  [warning_level=3])
397AC_MSG_RESULT([Level $warning_level])
398
399#Add warning flags as appropriate. Level 4 and above are only for testing purpose.
400AS_CASE([$warning_level],
401  [0],[ADD_C_CXX_WARNING_FLAGS="-Wall"],
402  [1],[
403    ADD_C_CXX_WARNING_FLAGS="-Wall -Wextra"
404    ADD_C_ONLY_WARNING_FLAGS="-Wimplicit-function-declaration"],
405  [2],[
406    ADD_C_CXX_WARNING_FLAGS="-Wall -Wextra -Wformat -Wstrict-aliasing -Wshadow -Wpacked -Winline"
407    ADD_C_ONLY_WARNING_FLAGS="-Wimplicit-function-declaration"],
408  [3],[
409    ADD_C_CXX_WARNING_FLAGS="-Wall -Wextra -Wformat -Wstrict-aliasing -Wshadow -Wpacked -Winline"
410    ADD_C_ONLY_WARNING_FLAGS="-Wimplicit-function-declaration -Wmissing-noreturn -Wmissing-prototypes"],
411  [4],[
412    ADD_C_CXX_WARNING_FLAGS="-Wall -Wextra -Wformat -Wstrict-aliasing=2 -Wsystem-headers -Wshadow -Wmissing-declarations -Wpacked -Winline -Werror -pedantic"
413    ADD_C_ONLY_WARNING_FLAGS="-Wimplicit-function-declaration -Wmissing-noreturn -Wmissing-prototypes"],
414  [5],[
415    ADD_C_CXX_WARNING_FLAGS="-Wall -Wextra -Wformat -Wstrict-aliasing=2 -Wsystem-headers -Wshadow -Wmissing-declarations -Wpacked -Wredundant-decls -Winline -Werror -Wfatal-errors -pedantic -pedantic-errors"
416    ADD_C_ONLY_WARNING_FLAGS="-Wimplicit-function-declaration -Wmissing-noreturn -Wmissing-prototypes"]
417   )
418
419AC_SUBST(ADD_C_ONLY_WARNING_FLAGS)
420AC_SUBST(ADD_C_CXX_WARNING_FLAGS)
421AC_SUBST(ADD_CXX_ONLY_WARNING_FLAGS)
422
423AC_CONFIG_FILES([Makefile])
424AC_OUTPUT
425
426AC_MSG_NOTICE([])
427AC_MSG_NOTICE([])
428AC_MSG_NOTICE([])
429AC_MSG_NOTICE([------------------------------------------------------------------------])
430AC_MSG_NOTICE([$PACKAGE $VERSION])
431AC_MSG_NOTICE([------------------------------------------------------------------------])
432AC_MSG_NOTICE([])
433AC_MSG_NOTICE([])
434AC_MSG_NOTICE([Configuration Options Summary:])
435AC_MSG_NOTICE([])
436AC_MSG_NOTICE([  WinARM32 runtime.....: $enable_libarm32])
437AC_MSG_NOTICE([  WinARM64 runtime.....: $enable_libarm64])
438AC_MSG_NOTICE([  Win32 runtime........: $enable_lib32])
439AC_MSG_NOTICE([  Win64 runtime........: $enable_lib64])
440AC_MSG_NOTICE([  C Warning Flags......: $ADD_C_ONLY_WARNING_FLAGS])
441AC_MSG_NOTICE([  C++ Warning Flags....: $ADD_CXX_ONLY_WARNING_FLAGS])
442AC_MSG_NOTICE([  Common Warning Flags.: $ADD_C_CXX_WARNING_FLAGS])
443AC_MSG_NOTICE([  Default msvcrt.......: $with_default_msvcrt])
444AC_MSG_NOTICE([])
445AC_MSG_NOTICE([  DFP printf...........: $enable_dfp])
446AC_MSG_NOTICE([  128-bit printf.......: $enable_printf128])
447AC_MSG_NOTICE([  Custom printf........: $enable_registeredprintf])
448AC_MSG_NOTICE([  Softhmath............: $enable_softmath])
449AC_MSG_NOTICE([])
450
451
452