OSDN Git Service

Make <vptype.h> header effectively self-contained.
[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-2018, 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 before it can be used!
66  ac_exeext=".xyz"dnl arbitrarily pre-empt link before EXEEXT is known
67 ])
68
69 # MINGW_AC_PROG_CC_COMPILE_ONLY
70 # -----------------------------
71 # A wrapper for AC_PROG_CC, ensuring that it will not succumb to
72 # the failure mode described above, while still running the checks
73 # provided by the original _AC_COMPILER_EXEEXT macro, when the
74 # circumstances of failure do not prevail.
75 #
76 AC_DEFUN_ONCE([MINGW_AC_PROG_CC_COMPILE_ONLY],
77 [AC_REQUIRE([MINGW_AC_NO_EXECUTABLES])dnl no need for linking
78  AC_LINK_IFELSE([AC_LANG_PROGRAM],dnl minimal 'int main(){return 0;}'
79  [_MINGW_AC_COMPILER_EXEEXT],dnl can create executables anyway!
80  [_MINGW_AC_COMPILER_NO_EXECUTABLES])dnl
81 ])
82
83 # _MINGW_AC_COMPILER_NO_EXECUTABLES
84 # ---------------------------------
85 # Package specific diagnostics for the case where the compiler
86 # really does succumb to the _AC_COMPILER_EXEEXT failure mode; in
87 # this case, we allow the build to proceed, but we disallow the
88 # building of executables and shared libraries by default.
89 #
90 AC_DEFUN([_MINGW_AC_COMPILER_NO_EXECUTABLES],
91 [AC_MSG_CHECKING([whether the C compiler can create executables])
92  AC_MSG_RESULT([${may_enable_stage_2=no}])
93  AC_MSG_WARN([$CC compiler cannot create executables!])
94  AC_MSG_WARN([build will proceed to completion of stage-1 only;])
95  AC_MSG_WARN([no executables or shared libraries will be built.])
96 ])
97
98 # MINGW_AC_DISABLE_STAGE_2
99 # ------------------------
100 # Implement the '--disable-stage-2' configure option, such that
101 # it activates the non-failing _AC_COMPILER_EXEEXT behaviour, as
102 # described above; default is to proceed with the stage-2 build,
103 # provided the compiler is determined to be able to support it.
104 #
105 AC_DEFUN_ONCE([MINGW_AC_DISABLE_STAGE_2],
106 [AC_ARG_ENABLE([stage-2],
107  [AS_HELP_STRING([--disable-stage-2],
108   [disable building of DLL components which require a fully installed compiler;
109    this option may be used during the compiler build process, to permit building
110    of the libraries required before commencing stage-2 of the compiler build.
111   ])dnl
112  ],[],dnl
113  [enable_stage_2=auto])dnl let compiler capability govern
114 ])
115
116 # MINGW_AC_MAKE_COMMAND_GOALS
117 # ---------------------------
118 # Resolve choice of whether stage-2 should be built or not, in
119 # favour of user's preference, if supported by the compiler; by
120 # default prefer to build, if possible.  Propagate the resolved
121 # choice as a default make command goal, by assignment to the
122 # AC_SUBST variable, DEFAULT_MAKECMDGOALS.
123 #
124 AC_DEFUN_ONCE([MINGW_AC_MAKE_COMMAND_GOALS],
125 [AC_REQUIRE([MINGW_AC_DISABLE_STAGE_2])dnl
126  AC_REQUIRE([MINGW_AC_PROG_CC_COMPILE_ONLY])dnl
127  AC_MSG_CHECKING([whether to complete stage-2 build])
128  ac_val="user's choice"
129  AS_CASE([$enable_stage_2],dnl
130  [auto],[enable_stage_2=${may_enable_stage_2-yes};dnl
131   test x$enable_stage_2 = xyes && ac_val="default choice" dnl
132   || ac_val="compiler override"],dnl
133  [yes],[enable_stage_2=${may_enable_stage_2-yes};dnl
134   test x$enable_stage_2 = xyes || ac_val="compiler override"dnl
135  ])
136  AC_MSG_RESULT([$enable_stage_2 ($ac_val)])
137  test "x$enable_stage_2" = xno dnl
138   && DEFAULT_MAKECMDGOALS=all-stage-1-only dnl
139   || DEFAULT_MAKECMDGOALS=all-stage-1-and-2
140  AC_SUBST([DEFAULT_MAKECMDGOALS])
141 ])
142
143 # MINGW_AC_PROG_COMPILE_SX
144 # ------------------------
145 # Determine how to invoke GCC to compile *.sx asssembly language
146 # files, and provide a suitable derivative of GNU make's COMPILE.S
147 # rule in AC_SUBST variable 'COMPILE_SX'.  Note that GCC itself has
148 # supported direct compilation of such files from version 4.3 onward,
149 # (earlier versions require the '-x assembler-with-cpp' hint), but
150 # GNU make does not provide a complementary built-in rule.
151 #
152 AC_DEFUN([MINGW_AC_PROG_COMPILE_SX],
153 [AC_REQUIRE([AC_PROG_CC])dnl
154  AC_MSG_CHECKING([for $CC option to compile .sx files])
155  rm -f conftest.sx conftest.$OBJEXT; : > conftest.sx
156  ac_compile_sx='$CC -c $ASFLAGS $CPPFLAGS $ac_val conftest.sx >&5'
157  for ac_val in "" "-x assembler-with-cpp"; do
158    (eval $ac_compile_sx) 2>&5 && test -f conftest.$OBJEXT && break
159  done
160  AC_SUBST([COMPILE_SX],[`echo '$(COMPILE.S)' $ac_val`])
161  test "x$ac_val" = x && ac_val="none needed"
162  test -f conftest.$OBJEXT || ac_val="not supported"
163  AC_MSG_RESULT([$ac_val])
164  rm -f conftest.sx conftest.$OBJEXT
165  test "x$ac_val" = "xnot supported" && {
166   AC_MSG_FAILURE([$CC cannot compile .sx files])
167   }dnl
168 ])
169
170 # MINGW_AC_SET_DLLVERSION( TAG, IMPLIB, DLLVERSION )
171 # --------------------------------------------------
172 # Create a configuration time substitution for MAP_[TAG]_A_DLLVERSION,
173 # such that it will define a target specific makefile variable assignment
174 # for target IMPLIB, with specified value assigned to DLLVERSION.
175 #
176 AC_DEFUN([MINGW_AC_SET_DLLVERSION],dnl
177 [AC_SUBST([MAP_][$1][_A_DLLVERSION],['$2: DLLVERSION = "$3"'])dnl
178 ])
179
180 # $RCSfile$: end of file