OSDN Git Service

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