lang.m4 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721
  1. # This file is part of Autoconf. -*- Autoconf -*-
  2. # Programming languages support.
  3. # Copyright (C) 2000-2002, 2004-2012 Free Software Foundation, Inc.
  4. # This file is part of Autoconf. This program is free
  5. # software; you can redistribute it and/or modify it under the
  6. # terms of the GNU General Public License as published by the
  7. # Free Software Foundation, either version 3 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # Under Section 7 of GPL version 3, you are granted additional
  16. # permissions described in the Autoconf Configure Script Exception,
  17. # version 3.0, as published by the Free Software Foundation.
  18. #
  19. # You should have received a copy of the GNU General Public License
  20. # and a copy of the Autoconf Configure Script Exception along with
  21. # this program; see the files COPYINGv3 and COPYING.EXCEPTION
  22. # respectively. If not, see <http://www.gnu.org/licenses/>.
  23. # Written by David MacKenzie, with help from
  24. # Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
  25. # Roland McGrath, Noah Friedman, david d zuhn, and many others.
  26. # Table of Contents:
  27. #
  28. # 1. Language selection
  29. # and routines to produce programs in a given language.
  30. #
  31. # 2. Producing programs in a given language.
  32. #
  33. # 3. Looking for a compiler
  34. # And possibly the associated preprocessor.
  35. #
  36. # 3a. Computing EXEEXT and OBJEXT.
  37. #
  38. # 4. Compilers' characteristics.
  39. ## ----------------------- ##
  40. ## 1. Language selection. ##
  41. ## ----------------------- ##
  42. # AC_LANG_CASE(LANG1, IF-LANG1, LANG2, IF-LANG2, ..., DEFAULT)
  43. # ------------------------------------------------------------
  44. # Expand into IF-LANG1 if the current language is LANG1 etc. else
  45. # into default.
  46. m4_define([AC_LANG_CASE],
  47. [m4_case(_AC_LANG, $@)])
  48. # _AC_LANG_DISPATCH(MACRO, LANG, ARGS)
  49. # ------------------------------------
  50. # Call the specialization of MACRO for LANG with ARGS. Complain if
  51. # unavailable.
  52. m4_define([_AC_LANG_DISPATCH],
  53. [m4_ifdef([$1($2)],
  54. [m4_indir([$1($2)], m4_shift2($@))],
  55. [m4_fatal([$1: unknown language: $2])])])
  56. # _AC_LANG_SET(OLD, NEW)
  57. # ----------------------
  58. # Output the shell code needed to switch from OLD language to NEW language.
  59. # Do not try to optimize like this:
  60. #
  61. # m4_defun([_AC_LANG_SET],
  62. # [m4_if([$1], [$2], [],
  63. # [_AC_LANG_DISPATCH([AC_LANG], [$2])])])
  64. #
  65. # as it can introduce differences between the sh-current language and the
  66. # m4-current-language when m4_require is used. Something more subtle
  67. # might be possible, but at least for the time being, play it safe.
  68. m4_defun([_AC_LANG_SET],
  69. [_AC_LANG_DISPATCH([AC_LANG], [$2])])
  70. # AC_LANG(LANG)
  71. # -------------
  72. # Set the current language to LANG.
  73. m4_defun([AC_LANG],
  74. [_AC_LANG_SET(m4_ifdef([_AC_LANG], [m4_defn([_AC_LANG])]),
  75. [$1])dnl
  76. m4_define([_AC_LANG], [$1])])
  77. # AC_LANG_PUSH(LANG)
  78. # ------------------
  79. # Save the current language, and use LANG.
  80. m4_defun([AC_LANG_PUSH],
  81. [_AC_LANG_SET(m4_ifdef([_AC_LANG], [m4_defn([_AC_LANG])]),
  82. [$1])dnl
  83. m4_pushdef([_AC_LANG], [$1])])
  84. # AC_LANG_POP([LANG])
  85. # -------------------
  86. # If given, check that the current language is LANG, and restore the
  87. # previous language.
  88. m4_defun([AC_LANG_POP],
  89. [m4_ifval([$1],
  90. [m4_if([$1], m4_defn([_AC_LANG]), [],
  91. [m4_fatal([$0($1): unexpected current language: ]m4_defn([_AC_LANG]))])])dnl
  92. m4_pushdef([$0 OLD], m4_defn([_AC_LANG]))dnl
  93. m4_popdef([_AC_LANG])dnl
  94. _AC_LANG_SET(m4_defn([$0 OLD]), m4_defn([_AC_LANG]))dnl
  95. m4_popdef([$0 OLD])dnl
  96. ])
  97. # AC_LANG_SAVE
  98. # ------------
  99. # Save the current language, but don't change language.
  100. AU_DEFUN([AC_LANG_SAVE],
  101. [[AC_LANG_SAVE]],
  102. [Instead of using `AC_LANG', `AC_LANG_SAVE', and `AC_LANG_RESTORE',
  103. you should use `AC_LANG_PUSH' and `AC_LANG_POP'.])
  104. AC_DEFUN([AC_LANG_SAVE],
  105. [m4_pushdef([_AC_LANG], _AC_LANG)dnl
  106. AC_DIAGNOSE([obsolete], [The macro `AC_LANG_SAVE' is obsolete.
  107. You should run autoupdate.])])
  108. # AC_LANG_RESTORE
  109. # ---------------
  110. # Restore the current language from the stack.
  111. AU_DEFUN([AC_LANG_RESTORE], [AC_LANG_POP($@)])
  112. # _AC_LANG_ABBREV
  113. # ---------------
  114. # Return a short signature of _AC_LANG which can be used in shell
  115. # variable names, or in M4 macro names.
  116. m4_defun([_AC_LANG_ABBREV],
  117. [_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
  118. # _AC_LANG_PREFIX
  119. # ---------------
  120. # Return a short (upper case) signature of _AC_LANG that is used to
  121. # prefix environment variables like FLAGS.
  122. m4_defun([_AC_LANG_PREFIX],
  123. [_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
  124. # AC_LANG_ASSERT(LANG)
  125. # --------------------
  126. # Current language must be LANG.
  127. m4_defun([AC_LANG_ASSERT],
  128. [m4_if(_AC_LANG, $1, [],
  129. [m4_fatal([$0: current language is not $1: ] _AC_LANG)])])
  130. # AC_LANG_DEFINE(NAME, ABBREV, PREFIX, COMPILER-VAR, COPY-FROM, SHELL-VARS)
  131. # -------------------------------------------------------------------------
  132. # Define a language referenced by AC_LANG(NAME), with cache variable prefix
  133. # ABBREV, Makefile variable prefix PREFIX and compiler variable COMPILER-VAR.
  134. # AC_LANG(NAME) is defined to SHELL-VARS, other macros are copied from language
  135. # COPY-FROM. Even if COPY-FROM is empty, a default definition is provided for
  136. # language-specific macros AC_LANG_SOURCE(NAME) and AC_LANG_CONFTEST(NAME).
  137. m4_define([AC_LANG_DEFINE],
  138. [m4_define([AC_LANG($1)], [$6])]
  139. [m4_define([_AC_LANG_ABBREV($1)], [$2])]
  140. [m4_define([_AC_LANG_PREFIX($1)], [$3])]
  141. [m4_define([_AC_CC($1)], [$4])]
  142. [m4_copy([AC_LANG_CONFTEST($5)], [AC_LANG_CONFTEST($1)])]
  143. [m4_copy([AC_LANG_SOURCE($5)], [AC_LANG_SOURCE($1)])]
  144. [m4_copy([_AC_LANG_NULL_PROGRAM($5)], [_AC_LANG_NULL_PROGRAM($1)])]
  145. [m4_ifval([$5],
  146. [m4_copy([AC_LANG_PROGRAM($5)], [AC_LANG_PROGRAM($1)])]
  147. [m4_copy([AC_LANG_CALL($5)], [AC_LANG_CALL($1)])]
  148. [m4_copy([AC_LANG_FUNC_LINK_TRY($5)], [AC_LANG_FUNC_LINK_TRY($1)])]
  149. [m4_copy([AC_LANG_BOOL_COMPILE_TRY($5)], [AC_LANG_BOOL_COMPILE_TRY($1)])]
  150. [m4_copy([AC_LANG_INT_SAVE($5)], [AC_LANG_INT_SAVE($1)])]
  151. [m4_copy([_AC_LANG_IO_PROGRAM($5)], [_AC_LANG_IO_PROGRAM($1)])])])
  152. ## ----------------------- ##
  153. ## 2. Producing programs. ##
  154. ## ----------------------- ##
  155. # AC_LANG_CONFTEST(BODY)
  156. # ----------------------
  157. # Save the BODY in `conftest.$ac_ext'. Add a trailing new line.
  158. AC_DEFUN([AC_LANG_CONFTEST],
  159. [m4_pushdef([_AC_LANG_DEFINES_PROVIDED],
  160. [m4_warn([syntax], [$0: no AC_LANG_SOURCE call detected in body])])]dnl
  161. [_AC_LANG_DISPATCH([$0], _AC_LANG, $@)]dnl
  162. [[]_AC_LANG_DEFINES_PROVIDED[]m4_popdef([_AC_LANG_DEFINES_PROVIDED])])
  163. # AC_LANG_CONFTEST()(BODY)
  164. # ------------------------
  165. # Default implementation of AC_LANG_CONFTEST.
  166. # This version assumes that you can't inline confdefs.h into your
  167. # language, and as such, it is safe to blindly call
  168. # AC_LANG_DEFINES_PROVIDED. Language-specific overrides should
  169. # remove this call if AC_LANG_SOURCE does inline confdefs.h.
  170. m4_define([AC_LANG_CONFTEST()],
  171. [cat > conftest.$ac_ext <<_ACEOF
  172. AC_LANG_DEFINES_PROVIDED[]$1
  173. _ACEOF])
  174. # AC_LANG_DEFINES_PROVIDED
  175. # ------------------------
  176. # Witness macro that all prior AC_DEFINE results have been output
  177. # into the current expansion, to silence warning from AC_LANG_CONFTEST.
  178. m4_define([AC_LANG_DEFINES_PROVIDED],
  179. [m4_define([_$0])])
  180. # AC_LANG_SOURCE(BODY)
  181. # --------------------
  182. # Produce a valid source for the current language, which includes the
  183. # BODY, and as much as possible `confdefs.h'.
  184. AC_DEFUN([AC_LANG_SOURCE],
  185. [AC_LANG_DEFINES_PROVIDED[]_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
  186. # AC_LANG_SOURCE()(BODY)
  187. # ----------------------
  188. # Default implementation of AC_LANG_SOURCE.
  189. m4_define([AC_LANG_SOURCE()],
  190. [$1])
  191. # AC_LANG_PROGRAM([PROLOGUE], [BODY])
  192. # -----------------------------------
  193. # Produce a valid source for the current language. Prepend the
  194. # PROLOGUE (typically CPP directives and/or declarations) to an
  195. # execution the BODY (typically glued inside the `main' function, or
  196. # equivalent).
  197. AC_DEFUN([AC_LANG_PROGRAM],
  198. [AC_LANG_SOURCE([_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])])
  199. # _AC_LANG_NULL_PROGRAM()()
  200. # -------------------------
  201. # Default implementation of AC_LANG_NULL_PROGRAM
  202. m4_define([_AC_LANG_NULL_PROGRAM()],
  203. [AC_LANG_PROGRAM([], [])])
  204. # _AC_LANG_NULL_PROGRAM
  205. # ---------------------
  206. # Produce valid source for the current language that does
  207. # nothing.
  208. AC_DEFUN([_AC_LANG_NULL_PROGRAM],
  209. [AC_LANG_SOURCE([_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])])
  210. # _AC_LANG_IO_PROGRAM
  211. # -------------------
  212. # Produce valid source for the current language that creates
  213. # a file. (This is used when detecting whether executables
  214. # work, e.g. to detect cross-compiling.)
  215. AC_DEFUN([_AC_LANG_IO_PROGRAM],
  216. [AC_LANG_SOURCE([_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])])
  217. # AC_LANG_CALL(PROLOGUE, FUNCTION)
  218. # --------------------------------
  219. # Call the FUNCTION.
  220. AC_DEFUN([AC_LANG_CALL],
  221. [m4_ifval([$2], [], [m4_warn([syntax], [$0: no function given])])dnl
  222. _AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
  223. # AC_LANG_FUNC_LINK_TRY(FUNCTION)
  224. # -------------------------------
  225. # Produce a source which links correctly iff the FUNCTION exists.
  226. AC_DEFUN([AC_LANG_FUNC_LINK_TRY],
  227. [m4_ifval([$1], [], [m4_warn([syntax], [$0: no function given])])dnl
  228. _AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
  229. # AC_LANG_BOOL_COMPILE_TRY(PROLOGUE, EXPRESSION)
  230. # ----------------------------------------------
  231. # Produce a program that compiles with success iff the boolean EXPRESSION
  232. # evaluates to true at compile time.
  233. AC_DEFUN([AC_LANG_BOOL_COMPILE_TRY],
  234. [_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
  235. # AC_LANG_INT_SAVE(PROLOGUE, EXPRESSION)
  236. # --------------------------------------
  237. # Produce a program that saves the runtime evaluation of the integer
  238. # EXPRESSION into `conftest.val'.
  239. AC_DEFUN([AC_LANG_INT_SAVE],
  240. [_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
  241. # _AC_CC
  242. # ------
  243. # The variable name of the compiler.
  244. m4_define([_AC_CC],
  245. [_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
  246. ## -------------------------------------------- ##
  247. ## 3. Looking for Compilers and Preprocessors. ##
  248. ## -------------------------------------------- ##
  249. # AC_LANG_COMPILER
  250. # ----------------
  251. # Find a compiler for the current LANG. Be sure to be run before
  252. # AC_LANG_PREPROC.
  253. #
  254. # Note that because we might AC_REQUIRE `AC_LANG_COMPILER(C)' for
  255. # instance, the latter must be AC_DEFUN'd, not just define'd.
  256. m4_define([AC_LANG_COMPILER],
  257. [AC_BEFORE([AC_LANG_COMPILER(]_AC_LANG[)],
  258. [AC_LANG_PREPROC(]_AC_LANG[)])dnl
  259. _AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
  260. # AC_LANG_COMPILER_REQUIRE
  261. # ------------------------
  262. # Ensure we have a compiler for the current LANG.
  263. AC_DEFUN([AC_LANG_COMPILER_REQUIRE],
  264. [m4_require([AC_LANG_COMPILER(]_AC_LANG[)],
  265. [AC_LANG_COMPILER])])
  266. # _AC_LANG_COMPILER_GNU
  267. # ---------------------
  268. # Check whether the compiler for the current language is GNU.
  269. #
  270. # It doesn't seem necessary right now to have a different source
  271. # according to the current language, since this works fine. Some day
  272. # it might be needed. Nevertheless, pay attention to the fact that
  273. # the position of `choke me' on the seventh column is meant: otherwise
  274. # some Fortran compilers (e.g., SGI) might consider it's a
  275. # continuation line, and warn instead of reporting an error.
  276. m4_define([_AC_LANG_COMPILER_GNU],
  277. [AC_CACHE_CHECK([whether we are using the GNU _AC_LANG compiler],
  278. [ac_cv_[]_AC_LANG_ABBREV[]_compiler_gnu],
  279. [_AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[#ifndef __GNUC__
  280. choke me
  281. #endif
  282. ]])],
  283. [ac_compiler_gnu=yes],
  284. [ac_compiler_gnu=no])
  285. ac_cv_[]_AC_LANG_ABBREV[]_compiler_gnu=$ac_compiler_gnu
  286. ])])# _AC_LANG_COMPILER_GNU
  287. # AC_LANG_PREPROC
  288. # ---------------
  289. # Find a preprocessor for the current language. Note that because we
  290. # might AC_REQUIRE `AC_LANG_PREPROC(C)' for instance, the latter must
  291. # be AC_DEFUN'd, not just define'd. Since the preprocessor depends
  292. # upon the compiler, look for the compiler.
  293. m4_define([AC_LANG_PREPROC],
  294. [AC_LANG_COMPILER_REQUIRE()dnl
  295. _AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
  296. # AC_LANG_PREPROC_REQUIRE
  297. # -----------------------
  298. # Ensure we have a preprocessor for the current language.
  299. AC_DEFUN([AC_LANG_PREPROC_REQUIRE],
  300. [m4_require([AC_LANG_PREPROC(]_AC_LANG[)],
  301. [AC_LANG_PREPROC])])
  302. # AC_REQUIRE_CPP
  303. # --------------
  304. # Require the preprocessor for the current language.
  305. # FIXME: AU_ALIAS once AC_LANG is officially documented (2.51?).
  306. AC_DEFUN([AC_REQUIRE_CPP],
  307. [AC_LANG_PREPROC_REQUIRE])
  308. # AC_NO_EXECUTABLES
  309. # -----------------
  310. # FIXME: The GCC team has specific needs which the current Autoconf
  311. # framework cannot solve elegantly. This macro implements a dirty
  312. # hack until Autoconf is able to provide the services its users
  313. # need.
  314. #
  315. # Several of the support libraries that are often built with GCC can't
  316. # assume the tool-chain is already capable of linking a program: the
  317. # compiler often expects to be able to link with some of such
  318. # libraries.
  319. #
  320. # In several of these libraries, workarounds have been introduced to
  321. # avoid the AC_PROG_CC_WORKS test, that would just abort their
  322. # configuration. The introduction of AC_EXEEXT, enabled either by
  323. # libtool or by CVS autoconf, have just made matters worse.
  324. #
  325. # Unlike an earlier version of this macro, using AC_NO_EXECUTABLES does
  326. # not disable link tests at autoconf time, but at configure time.
  327. # This allows AC_NO_EXECUTABLES to be invoked conditionally.
  328. AC_DEFUN_ONCE([AC_NO_EXECUTABLES],
  329. [m4_divert_push([KILL])
  330. m4_divert_text([DEFAULTS], [ac_no_link=no])
  331. AC_BEFORE([$0], [_AC_COMPILER_EXEEXT])
  332. AC_BEFORE([$0], [AC_LINK_IFELSE])
  333. m4_define([_AC_COMPILER_EXEEXT],
  334. [AC_LANG_CONFTEST([_AC_LANG_NULL_PROGRAM])
  335. if _AC_DO_VAR(ac_link); then
  336. ac_no_link=no
  337. ]m4_defn([_AC_COMPILER_EXEEXT])[
  338. else
  339. rm -f -r a.out a.exe b.out conftest.$ac_ext conftest.o conftest.obj conftest.dSYM
  340. ac_no_link=yes
  341. # Setting cross_compile will disable run tests; it will
  342. # also disable AC_CHECK_FILE but that's generally
  343. # correct if we can't link.
  344. cross_compiling=yes
  345. EXEEXT=
  346. _AC_COMPILER_EXEEXT_CROSS
  347. fi
  348. ])
  349. m4_define([AC_LINK_IFELSE],
  350. [if test x$ac_no_link = xyes; then
  351. AC_MSG_ERROR([link tests are not allowed after AC@&t@_NO_EXECUTABLES])
  352. fi
  353. ]m4_defn([AC_LINK_IFELSE]))
  354. m4_divert_pop()dnl
  355. ])# AC_NO_EXECUTABLES
  356. # --------------------------------- #
  357. # 3a. Computing EXEEXT and OBJEXT. #
  358. # --------------------------------- #
  359. # Files to ignore
  360. # ---------------
  361. # Ignore .d files produced by CFLAGS=-MD.
  362. #
  363. # On UWIN (which uses a cc wrapper for MSVC), the compiler also generates
  364. # a .pdb file
  365. #
  366. # When the w32 free Borland C++ command line compiler links a program
  367. # (conftest.exe), it also produces a file named `conftest.tds' in
  368. # addition to `conftest.obj'.
  369. #
  370. # - *.bb, *.bbg
  371. # Created per object by GCC when given -ftest-coverage.
  372. #
  373. # - *.xSYM
  374. # Created on BeOS. Seems to be per executable.
  375. #
  376. # - *.map, *.inf
  377. # Created by the Green Hills compiler.
  378. #
  379. # - *.dSYM
  380. # Directory created on Mac OS X Leopard.
  381. # _AC_COMPILER_OBJEXT_REJECT
  382. # --------------------------
  383. # Case/esac pattern matching the files to be ignored when looking for
  384. # compiled object files.
  385. m4_define([_AC_COMPILER_OBJEXT_REJECT],
  386. [*.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM])
  387. # _AC_COMPILER_EXEEXT_REJECT
  388. # --------------------------
  389. # Case/esac pattern matching the files to be ignored when looking for
  390. # compiled executables.
  391. m4_define([_AC_COMPILER_EXEEXT_REJECT],
  392. [_AC_COMPILER_OBJEXT_REJECT | *.o | *.obj])
  393. # We must not AU define them, because autoupdate would then remove
  394. # them, which is right, but Automake 1.4 would remove the support for
  395. # $(EXEEXT) etc.
  396. # FIXME: Remove this once Automake fixed.
  397. AC_DEFUN([AC_EXEEXT], [])
  398. AC_DEFUN([AC_OBJEXT], [])
  399. # _AC_COMPILER_EXEEXT_DEFAULT
  400. # ---------------------------
  401. # Check for the extension used for the default name for executables.
  402. #
  403. # We do this in order to find out what is the extension we must add for
  404. # creating executables (see _AC_COMPILER_EXEEXT's comments).
  405. #
  406. # On OpenVMS 7.1 system, the DEC C 5.5 compiler when called through a
  407. # GNV (gnv.sourceforge.net) cc wrapper, produces the output file named
  408. # `a_out.exe'.
  409. # b.out is created by i960 compilers.
  410. #
  411. # Start with the most likely output file names, but:
  412. # 1) Beware the clever `test -f' on Cygwin, try the DOS-like .exe names
  413. # before the counterparts without the extension.
  414. # 2) The algorithm is not robust to junk in `.', hence go to wildcards
  415. # (conftest.*) only as a last resort.
  416. # Beware of `expr' that may return `0' or `'. Since this macro is
  417. # the first one in touch with the compiler, it should also check that
  418. # it compiles properly.
  419. #
  420. # The IRIX 6 linker writes into existing files which may not be
  421. # executable, retaining their permissions. Remove them first so a
  422. # subsequent execution test works.
  423. #
  424. m4_define([_AC_COMPILER_EXEEXT_DEFAULT],
  425. [# Try to create an executable without -o first, disregard a.out.
  426. # It will help us diagnose broken compilers, and finding out an intuition
  427. # of exeext.
  428. AC_MSG_CHECKING([whether the _AC_LANG compiler works])
  429. ac_link_default=`AS_ECHO(["$ac_link"]) | sed ['s/ -o *conftest[^ ]*//']`
  430. # The possible output files:
  431. ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"
  432. ac_rmfiles=
  433. for ac_file in $ac_files
  434. do
  435. case $ac_file in
  436. _AC_COMPILER_EXEEXT_REJECT ) ;;
  437. * ) ac_rmfiles="$ac_rmfiles $ac_file";;
  438. esac
  439. done
  440. rm -f $ac_rmfiles
  441. AS_IF([_AC_DO_VAR(ac_link_default)],
  442. [# Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
  443. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
  444. # in a Makefile. We should not override ac_cv_exeext if it was cached,
  445. # so that the user can short-circuit this test for compilers unknown to
  446. # Autoconf.
  447. for ac_file in $ac_files ''
  448. do
  449. test -f "$ac_file" || continue
  450. case $ac_file in
  451. _AC_COMPILER_EXEEXT_REJECT )
  452. ;;
  453. [[ab]].out )
  454. # We found the default executable, but exeext='' is most
  455. # certainly right.
  456. break;;
  457. *.* )
  458. if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
  459. then :; else
  460. ac_cv_exeext=`expr "$ac_file" : ['[^.]*\(\..*\)']`
  461. fi
  462. # We set ac_cv_exeext here because the later test for it is not
  463. # safe: cross compilers may not add the suffix if given an `-o'
  464. # argument, so we may need to know it at that point already.
  465. # Even if this section looks crufty: it has the advantage of
  466. # actually working.
  467. break;;
  468. * )
  469. break;;
  470. esac
  471. done
  472. test "$ac_cv_exeext" = no && ac_cv_exeext=
  473. ],
  474. [ac_file=''])
  475. AS_IF([test -z "$ac_file"],
  476. [AC_MSG_RESULT([no])
  477. _AC_MSG_LOG_CONFTEST
  478. AC_MSG_FAILURE([_AC_LANG compiler cannot create executables], 77)],
  479. [AC_MSG_RESULT([yes])])
  480. AC_MSG_CHECKING([for _AC_LANG compiler default output file name])
  481. AC_MSG_RESULT([$ac_file])
  482. ac_exeext=$ac_cv_exeext
  483. ])# _AC_COMPILER_EXEEXT_DEFAULT
  484. # _AC_COMPILER_EXEEXT_CROSS
  485. # -------------------------
  486. # FIXME: These cross compiler hacks should be removed for Autoconf 3.0
  487. #
  488. # It is not sufficient to run a no-op program -- this succeeds and gives
  489. # a false negative when cross-compiling for the compute nodes on the
  490. # IBM Blue Gene/L. Instead, _AC_COMPILER_EXEEXT calls _AC_LANG_IO_PROGRAM
  491. # to create a program that writes to a file, which is sufficient to
  492. # detect cross-compiling on Blue Gene. Note also that AC_COMPUTE_INT
  493. # requires programs that create files when not cross-compiling, so it
  494. # is safe and not a bad idea to check for this capability in general.
  495. m4_define([_AC_COMPILER_EXEEXT_CROSS],
  496. [# Check that the compiler produces executables we can run. If not, either
  497. # the compiler is broken, or we cross compile.
  498. AC_MSG_CHECKING([whether we are cross compiling])
  499. if test "$cross_compiling" != yes; then
  500. _AC_DO_VAR(ac_link)
  501. if _AC_DO_TOKENS([./conftest$ac_cv_exeext]); then
  502. cross_compiling=no
  503. else
  504. if test "$cross_compiling" = maybe; then
  505. cross_compiling=yes
  506. else
  507. AC_MSG_FAILURE([cannot run _AC_LANG compiled programs.
  508. If you meant to cross compile, use `--host'.])
  509. fi
  510. fi
  511. fi
  512. AC_MSG_RESULT([$cross_compiling])
  513. ])# _AC_COMPILER_EXEEXT_CROSS
  514. # _AC_COMPILER_EXEEXT_O
  515. # ---------------------
  516. # Check for the extension used when `-o foo'. Try to see if ac_cv_exeext,
  517. # as computed by _AC_COMPILER_EXEEXT_DEFAULT is OK.
  518. m4_define([_AC_COMPILER_EXEEXT_O],
  519. [AC_MSG_CHECKING([for suffix of executables])
  520. AS_IF([_AC_DO_VAR(ac_link)],
  521. [# If both `conftest.exe' and `conftest' are `present' (well, observable)
  522. # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will
  523. # work properly (i.e., refer to `conftest.exe'), while it won't with
  524. # `rm'.
  525. for ac_file in conftest.exe conftest conftest.*; do
  526. test -f "$ac_file" || continue
  527. case $ac_file in
  528. _AC_COMPILER_EXEEXT_REJECT ) ;;
  529. *.* ) ac_cv_exeext=`expr "$ac_file" : ['[^.]*\(\..*\)']`
  530. break;;
  531. * ) break;;
  532. esac
  533. done],
  534. [AC_MSG_FAILURE([cannot compute suffix of executables: cannot compile and link])])
  535. rm -f conftest conftest$ac_cv_exeext
  536. AC_MSG_RESULT([$ac_cv_exeext])
  537. ])# _AC_COMPILER_EXEEXT_O
  538. # _AC_COMPILER_EXEEXT
  539. # -------------------
  540. # Check for the extension used for executables. It compiles a test
  541. # executable. If this is called, the executable extensions will be
  542. # automatically used by link commands run by the configure script.
  543. #
  544. # Note that some compilers (cross or not), strictly obey to `-o foo' while
  545. # the host requires `foo.exe', so we should not depend upon `-o' to
  546. # test EXEEXT. But then, be sure not to destroy user files.
  547. #
  548. # Must be run before _AC_COMPILER_OBJEXT because _AC_COMPILER_EXEEXT_DEFAULT
  549. # checks whether the compiler works.
  550. #
  551. # Do not rename this macro; Automake decides whether EXEEXT is used
  552. # by checking whether `_AC_COMPILER_EXEEXT' has been expanded.
  553. #
  554. # See _AC_COMPILER_EXEEXT_CROSS for why we need _AC_LANG_IO_PROGRAM.
  555. m4_define([_AC_COMPILER_EXEEXT],
  556. [AC_LANG_CONFTEST([_AC_LANG_NULL_PROGRAM])
  557. ac_clean_files_save=$ac_clean_files
  558. ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
  559. _AC_COMPILER_EXEEXT_DEFAULT
  560. rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
  561. ac_clean_files=$ac_clean_files_save
  562. _AC_COMPILER_EXEEXT_O
  563. rm -f conftest.$ac_ext
  564. AC_SUBST([EXEEXT], [$ac_cv_exeext])dnl
  565. ac_exeext=$EXEEXT
  566. AC_LANG_CONFTEST([_AC_LANG_IO_PROGRAM])
  567. ac_clean_files="$ac_clean_files conftest.out"
  568. _AC_COMPILER_EXEEXT_CROSS
  569. rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out
  570. ac_clean_files=$ac_clean_files_save
  571. ])# _AC_COMPILER_EXEEXT
  572. # _AC_COMPILER_OBJEXT
  573. # -------------------
  574. # Check the object extension used by the compiler: typically `.o' or
  575. # `.obj'. If this is called, some other behavior will change,
  576. # determined by ac_objext.
  577. #
  578. # This macro is called by AC_LANG_COMPILER, the latter being required
  579. # by the AC_COMPILE_IFELSE macros, so use _AC_COMPILE_IFELSE. And in fact,
  580. # don't, since _AC_COMPILE_IFELSE needs to know ac_objext for the `test -s'
  581. # it includes. So do it by hand.
  582. m4_define([_AC_COMPILER_OBJEXT],
  583. [AC_CACHE_CHECK([for suffix of object files], ac_cv_objext,
  584. [AC_LANG_CONFTEST([_AC_LANG_NULL_PROGRAM])
  585. rm -f conftest.o conftest.obj
  586. AS_IF([_AC_DO_VAR(ac_compile)],
  587. [for ac_file in conftest.o conftest.obj conftest.*; do
  588. test -f "$ac_file" || continue;
  589. case $ac_file in
  590. _AC_COMPILER_OBJEXT_REJECT ) ;;
  591. *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
  592. break;;
  593. esac
  594. done],
  595. [_AC_MSG_LOG_CONFTEST
  596. AC_MSG_FAILURE([cannot compute suffix of object files: cannot compile])])
  597. rm -f conftest.$ac_cv_objext conftest.$ac_ext])
  598. AC_SUBST([OBJEXT], [$ac_cv_objext])dnl
  599. ac_objext=$OBJEXT
  600. ])# _AC_COMPILER_OBJEXT
  601. ## ------------------------------- ##
  602. ## 4. Compilers' characteristics. ##
  603. ## ------------------------------- ##
  604. # AC_LANG_WERROR
  605. # --------------
  606. # Treat warnings from the current language's preprocessor, compiler, and
  607. # linker as fatal errors.
  608. AC_DEFUN([AC_LANG_WERROR],
  609. [m4_divert_text([DEFAULTS], [ac_[]_AC_LANG_ABBREV[]_werror_flag=])
  610. ac_[]_AC_LANG_ABBREV[]_werror_flag=yes])# AC_LANG_WERROR