OSDN Git Service

Provide default definition for _WIN32_IE feature test macro.
[mingw/mingw-org-wsl.git] / aclocal.m4
1 ## aclocal.m4 -*- Autoconf -*- vim: filetype=config
2 ##
3 ## Autoconf macros for MinGW.org Runtime Library Package
4 ##
5 ## $Id$
6 ##
7 ## Written by Keith Marshall <keithmarshall@users.sourceforge.net>
8 ## Copyright (C) 2014, 2016, 2017, MinGW.org Project
9 ##
10 ##
11 m4_include([VERSION.m4])
12 m4_define([__BUG_REPORT_URL__],[http://mingw.org/Reporting_Bugs])
13 ##
14 ##
15 ## Permission is hereby granted, free of charge, to any person obtaining a
16 ## copy of this software and associated documentation files (the "Software"),
17 ## to deal in the Software without restriction, including without limitation
18 ## the rights to use, copy, modify, merge, publish, distribute, sublicense,
19 ## and/or sell copies of the Software, and to permit persons to whom the
20 ## Software is furnished to do so, subject to the following conditions:
21 ##
22 ## The above copyright notice and this permission notice (including the next
23 ## paragraph) shall be included in all copies or substantial portions of the
24 ## Software.
25 ##
26 ## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
27 ## OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28 ## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29 ## AUTHORS OR THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30 ## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
31 ## FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
32 ## DEALINGS IN THE SOFTWARE.
33 ##
34
35 # MINGW_AC_CONFIG_EXTRA_SRCDIR( PACKAGE, WITNESS_FILE )
36 # -----------------------------------------------------
37 # Identify the top source directory for a sibling PACKAGE, which
38 # provides WITNESS_FILE, and set AC_SUBST variable PACKAGE_srcdir
39 # to its path relative to the build directory.  Prefers a sibling
40 # directory of ${srcdir} named exactly PACKAGE, but falls back to
41 # PACKAGE*, and then to *PACKAGE*, if necessary.
42 #
43 AC_DEFUN_ONCE([MINGW_AC_CONFIG_EXTRA_SRCDIR],
44 [AC_MSG_CHECKING([location of $1 source files])
45  for ac_dir in ${srcdir}/../$1 ${srcdir}/../$1* ${srcdir}/../*$1*
46    do test -f $ac_dir/$2 && { $1_srcdir=$ac_dir; break; }; done
47  AC_MSG_RESULT([$$1_srcdir])
48  AC_SUBST([$1_srcdir])dnl
49 ])
50
51 # MINGW_AC_NO_EXECUTABLES
52 # -----------------------
53 # When building the runtime and W32 API libraries with only
54 # a partially installed compiler, as we will be required to do
55 # between the stage-1 and stage-2 phases of building GCC itself,
56 # autoconf's _AC_COMPILER_EXEEXT may choke because the runtime
57 # library itself is not yet available; here, we have provided
58 # a redefined "do-nothing" version, which will avoid this mode
59 # of failure, while retaining the original test for subsequent
60 # use, after verifying that it should not fail.
61 #
62 AC_DEFUN_ONCE([MINGW_AC_NO_EXECUTABLES],
63 [AC_BEFORE([$0],[AC_PROG_CC])dnl cannot let this use...
64  m4_rename([_AC_COMPILER_EXEEXT],[_MINGW_AC_COMPILER_EXEEXT])dnl so...
65  m4_define([_AC_COMPILER_EXEEXT])dnl move it away quickly!
66 ])
67
68 # MINGW_AC_PROG_CC_COMPILE_ONLY
69 # -----------------------------
70 # A wrapper for AC_PROG_CC, ensuring that it will not succumb to
71 # the failure mode described above, while still running the checks
72 # provided by the original _AC_COMPILER_EXEEXT macro, when the
73 # circumstances of failure do not prevail.
74 #
75 AC_DEFUN_ONCE([MINGW_AC_PROG_CC_COMPILE_ONLY],
76 [AC_REQUIRE([MINGW_AC_NO_EXECUTABLES])dnl no need for linking
77  AC_LINK_IFELSE([AC_LANG_PROGRAM],dnl minimal 'int main(){return 0;}'
78  [_MINGW_AC_COMPILER_EXEEXT],dnl can create executables anyway!
79  [_MINGW_AC_COMPILER_NO_EXECUTABLES])dnl
80 ])
81
82 # _MINGW_AC_COMPILER_NO_EXECUTABLES
83 # ---------------------------------
84 # Package specific diagnostics for the case where the compiler
85 # really does succumb to the _AC_COMPILER_EXEEXT failure mode; in
86 # this case, we allow the build to proceed, but we disallow the
87 # building of executables and shared libraries by default.
88 #
89 AC_DEFUN([_MINGW_AC_COMPILER_NO_EXECUTABLES],
90 [AC_MSG_CHECKING([whether the C compiler can create executables])
91  AC_MSG_RESULT([${may_enable_stage_2=no}])
92  AC_MSG_WARN([$CC compiler cannot create executables!])
93  AC_MSG_WARN([build will proceed to completion of stage-1 only;])
94  AC_MSG_WARN([no executables or shared libraries will be built.])
95 ])
96
97 # MINGW_AC_DISABLE_STAGE_2
98 # ------------------------
99 # Implement the '--disable-stage-2' configure option, such that
100 # it activates the non-failing _AC_COMPILER_EXEEXT behaviour, as
101 # described above; default is to proceed with the stage-2 build,
102 # provided the compiler is determined to be able to support it.
103 #
104 AC_DEFUN_ONCE([MINGW_AC_DISABLE_STAGE_2],
105 [AC_ARG_ENABLE([stage-2],
106  [AS_HELP_STRING([--disable-stage-2],
107   [disable building of DLL components which require a fully installed compiler;
108    this option may be used during the compiler build process, to permit building
109    of the libraries required before commencing stage-2 of the compiler build.
110   ])dnl
111  ],[],dnl
112  [enable_stage_2=auto])dnl let compiler capability govern
113 ])
114
115 # MINGW_AC_MAKE_COMMAND_GOALS
116 # ---------------------------
117 # Resolve choice of whether stage-2 should be built or not, in
118 # favour of user's preference, if supported by the compiler; by
119 # default prefer to build, if possible.  Propagate the resolved
120 # choice as a default make command goal, by assignment to the
121 # AC_SUBST variable, DEFAULT_MAKECMDGOALS.
122 #
123 AC_DEFUN_ONCE([MINGW_AC_MAKE_COMMAND_GOALS],
124 [AC_REQUIRE([MINGW_AC_DISABLE_STAGE_2])dnl
125  AC_REQUIRE([MINGW_AC_PROG_CC_COMPILE_ONLY])dnl
126  AC_MSG_CHECKING([whether to complete stage-2 build])
127  ac_val="user's choice"
128  AS_CASE([$enable_stage_2],dnl
129  [auto],[enable_stage_2=${may_enable_stage_2-yes};dnl
130   test x$enable_stage_2 = xyes && ac_val="default choice" dnl
131   || ac_val="compiler override"],dnl
132  [yes],[enable_stage_2=${may_enable_stage_2-yes};dnl
133   test x$enable_stage_2 = xyes || ac_val="compiler override"dnl
134  ])
135  AC_MSG_RESULT([$enable_stage_2 ($ac_val)])
136  test "x$enable_stage_2" = xno dnl
137   && DEFAULT_MAKECMDGOALS=all-stage-1-only dnl
138   || DEFAULT_MAKECMDGOALS=all-stage-1-and-2
139  AC_SUBST([DEFAULT_MAKECMDGOALS])
140 ])
141
142 # MINGW_AC_PROG_COMPILE_SX
143 # ------------------------
144 # Determine how to invoke GCC to compile *.sx asssembly language
145 # files, and provide a suitable derivative of GNU make's COMPILE.S
146 # rule in AC_SUBST variable 'COMPILE_SX'.  Note that GCC itself has
147 # supported direct compilation of such files from version 4.3 onward,
148 # (earlier versions require the '-x assembler-with-cpp' hint), but
149 # GNU make does not provide a complementary built-in rule.
150 #
151 AC_DEFUN([MINGW_AC_PROG_COMPILE_SX],
152 [AC_REQUIRE([AC_PROG_CC])dnl
153  AC_MSG_CHECKING([for $CC option to compile .sx files])
154  rm -f conftest.sx conftest.$OBJEXT; : > conftest.sx
155  ac_compile_sx='$CC -c $ASFLAGS $CPPFLAGS $ac_val conftest.sx >&5'
156  for ac_val in "" "-x assembler-with-cpp"; do
157    (eval $ac_compile_sx) 2>&5 && test -f conftest.$OBJEXT && break
158  done
159  AC_SUBST([COMPILE_SX],[`echo '$(COMPILE.S)' $ac_val`])
160  test "x$ac_val" = x && ac_val="none needed"
161  test -f conftest.$OBJEXT || ac_val="not supported"
162  AC_MSG_RESULT([$ac_val])
163  rm -f conftest.sx conftest.$OBJEXT
164  test "x$ac_val" = "xnot supported" && {
165   AC_MSG_FAILURE([$CC cannot compile .sx files])
166   }dnl
167 ])
168
169 # MINGW_AC_SET_DLLVERSION( TAG, IMPLIB, DLLVERSION )
170 # --------------------------------------------------
171 # Create a configuration time substitution for MAP_[TAG]_A_DLLVERSION,
172 # such that it will define a target specific makefile variable assignment
173 # for target IMPLIB, with specified value assigned to DLLVERSION.
174 #
175 AC_DEFUN([MINGW_AC_SET_DLLVERSION],dnl
176 [AC_SUBST([MAP_][$1][_A_DLLVERSION],['$2: DLLVERSION = "$3"'])dnl
177 ])
178
179 # $RCSfile$: end of file