c.m4 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737
  1. # This file is part of Autoconf. -*- Autoconf -*-
  2. # Programming languages support.
  3. # Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Free Software
  4. # Foundation, Inc.
  5. #
  6. # This program is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation; either version 2, or (at your option)
  9. # any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program; if not, write to the Free Software
  18. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  19. # 02110-1301, USA.
  20. #
  21. # As a special exception, the Free Software Foundation gives unlimited
  22. # permission to copy, distribute and modify the configure scripts that
  23. # are the output of Autoconf. You need not follow the terms of the GNU
  24. # General Public License when using or distributing such scripts, even
  25. # though portions of the text of Autoconf appear in them. The GNU
  26. # General Public License (GPL) does govern all other use of the material
  27. # that constitutes the Autoconf program.
  28. #
  29. # Certain portions of the Autoconf source text are designed to be copied
  30. # (in certain cases, depending on the input) into the output of
  31. # Autoconf. We call these the "data" portions. The rest of the Autoconf
  32. # source text consists of comments plus executable code that decides which
  33. # of the data portions to output in any given case. We call these
  34. # comments and executable code the "non-data" portions. Autoconf never
  35. # copies any of the non-data portions into its output.
  36. #
  37. # This special exception to the GPL applies to versions of Autoconf
  38. # released by the Free Software Foundation. When you make and
  39. # distribute a modified version of Autoconf, you may extend this special
  40. # exception to the GPL to apply to your modified version as well, *unless*
  41. # your modified version has the potential to copy into its output some
  42. # of the text that was the non-data portion of the version that you started
  43. # with. (In other words, unless your change moves or copies text from
  44. # the non-data portions to the data portions.) If your modification has
  45. # such potential, you must delete any notice of this special exception
  46. # to the GPL from your modified version.
  47. #
  48. # Written by David MacKenzie, with help from
  49. # Akim Demaille, Paul Eggert,
  50. # Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
  51. # Roland McGrath, Noah Friedman, david d zuhn, and many others.
  52. # -------------------- #
  53. # 1b. The C language. #
  54. # -------------------- #
  55. # AC_LANG(C)
  56. # ----------
  57. # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
  58. m4_define([AC_LANG(C)],
  59. [ac_ext=c
  60. ac_cpp='$CPP $CPPFLAGS'
  61. ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
  62. ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD'
  63. ac_compiler_gnu=$ac_cv_c_compiler_gnu
  64. ])
  65. # AC_LANG_C
  66. # ---------
  67. AU_DEFUN([AC_LANG_C], [AC_LANG(C)])
  68. # _AC_LANG_ABBREV(C)
  69. # ------------------
  70. m4_define([_AC_LANG_ABBREV(C)], [c])
  71. # _AC_LANG_PREFIX(C)
  72. # ------------------
  73. m4_define([_AC_LANG_PREFIX(C)], [C])
  74. # ---------------------- #
  75. # 1c. The C++ language. #
  76. # ---------------------- #
  77. # AC_LANG(C++)
  78. # ------------
  79. # CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
  80. m4_define([AC_LANG(C++)],
  81. [ac_ext=cpp
  82. ac_cpp='$CXXCPP $CPPFLAGS'
  83. ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
  84. ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD'
  85. ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
  86. ])
  87. # AC_LANG_CPLUSPLUS
  88. # -----------------
  89. AU_DEFUN([AC_LANG_CPLUSPLUS], [AC_LANG(C++)])
  90. # _AC_LANG_ABBREV(C++)
  91. # --------------------
  92. m4_define([_AC_LANG_ABBREV(C++)], [cxx])
  93. # _AC_LANG_PREFIX(C++)
  94. # --------------------
  95. m4_define([_AC_LANG_PREFIX(C++)], [CXX])
  96. # ------------------------------ #
  97. # 1d. The Objective C language. #
  98. # ------------------------------ #
  99. # AC_LANG(Objective C)
  100. # --------------------
  101. m4_define([AC_LANG(Objective C)],
  102. [ac_ext=m
  103. ac_cpp='$OBJCPP $CPPFLAGS'
  104. ac_compile='$OBJC -c $OBJCFLAGS $CPPFLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
  105. ac_link='$OBJC -o conftest$ac_exeext $OBJCFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD'
  106. ac_compiler_gnu=$ac_cv_objc_compiler_gnu
  107. ])
  108. # AC_LANG_OBJC
  109. # ------------
  110. AU_DEFUN([AC_LANG_OBJC], [AC_LANG(Objective C)])
  111. # _AC_LANG_ABBREV(Objective C)
  112. # ----------------------------
  113. m4_define([_AC_LANG_ABBREV(Objective C)], [objc])
  114. # _AC_LANG_PREFIX(Objective C)
  115. # ----------------------------
  116. m4_define([_AC_LANG_PREFIX(Objective C)], [OBJC])
  117. ## ---------------------- ##
  118. ## 2.Producing programs. ##
  119. ## ---------------------- ##
  120. # --------------- #
  121. # 2b. C sources. #
  122. # --------------- #
  123. # AC_LANG_SOURCE(C)(BODY)
  124. # -----------------------
  125. # We can't use '#line $LINENO "configure"' here, since
  126. # Sun c89 (Sun WorkShop 6 update 2 C 5.3 Patch 111679-08 2002/05/09)
  127. # rejects $LINENO greater than 32767, and some configure scripts
  128. # are longer than 32767 lines.
  129. m4_define([AC_LANG_SOURCE(C)],
  130. [/* confdefs.h. */
  131. _ACEOF
  132. cat confdefs.h >>conftest.$ac_ext
  133. cat >>conftest.$ac_ext <<_ACEOF
  134. /* end confdefs.h. */
  135. $1])
  136. # AC_LANG_PROGRAM(C)([PROLOGUE], [BODY])
  137. # --------------------------------------
  138. m4_define([AC_LANG_PROGRAM(C)],
  139. [$1
  140. m4_ifdef([_AC_LANG_PROGRAM_C_F77_HOOKS], [_AC_LANG_PROGRAM_C_F77_HOOKS])[]dnl
  141. m4_ifdef([_AC_LANG_PROGRAM_C_FC_HOOKS], [_AC_LANG_PROGRAM_C_FC_HOOKS])[]dnl
  142. int
  143. main ()
  144. {
  145. dnl Do *not* indent the following line: there may be CPP directives.
  146. dnl Don't move the `;' right after for the same reason.
  147. $2
  148. ;
  149. return 0;
  150. }])
  151. # AC_LANG_CALL(C)(PROLOGUE, FUNCTION)
  152. # -----------------------------------
  153. # Avoid conflicting decl of main.
  154. m4_define([AC_LANG_CALL(C)],
  155. [AC_LANG_PROGRAM([$1
  156. m4_if([$2], [main], ,
  157. [/* Override any GCC internal prototype to avoid an error.
  158. Use char because int might match the return type of a GCC
  159. builtin and then its argument prototype would still apply. */
  160. #ifdef __cplusplus
  161. extern "C"
  162. #endif
  163. char $2 ();])], [return $2 ();])])
  164. # AC_LANG_FUNC_LINK_TRY(C)(FUNCTION)
  165. # ----------------------------------
  166. # Don't include <ctype.h> because on OSF/1 3.0 it includes
  167. # <sys/types.h> which includes <sys/select.h> which contains a
  168. # prototype for select. Similarly for bzero.
  169. #
  170. # This test used to merely assign f=$1 in main(), but that was
  171. # optimized away by HP unbundled cc A.05.36 for ia64 under +O3,
  172. # presumably on the basis that there's no need to do that store if the
  173. # program is about to exit. Conversely, the AIX linker optimizes an
  174. # unused external declaration that initializes f=$1. So this test
  175. # program has both an external initialization of f, and a use of f in
  176. # main that affects the exit status.
  177. #
  178. m4_define([AC_LANG_FUNC_LINK_TRY(C)],
  179. [AC_LANG_PROGRAM(
  180. [/* Define $1 to an innocuous variant, in case <limits.h> declares $1.
  181. For example, HP-UX 11i <limits.h> declares gettimeofday. */
  182. #define $1 innocuous_$1
  183. /* System header to define __stub macros and hopefully few prototypes,
  184. which can conflict with char $1 (); below.
  185. Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
  186. <limits.h> exists even on freestanding compilers. */
  187. #ifdef __STDC__
  188. # include <limits.h>
  189. #else
  190. # include <assert.h>
  191. #endif
  192. #undef $1
  193. /* Override any GCC internal prototype to avoid an error.
  194. Use char because int might match the return type of a GCC
  195. builtin and then its argument prototype would still apply. */
  196. #ifdef __cplusplus
  197. extern "C"
  198. #endif
  199. char $1 ();
  200. /* The GNU C library defines this for functions which it implements
  201. to always fail with ENOSYS. Some functions are actually named
  202. something starting with __ and the normal name is an alias. */
  203. #if defined __stub_$1 || defined __stub___$1
  204. choke me
  205. #endif
  206. ], [return $1 ();])])
  207. # AC_LANG_BOOL_COMPILE_TRY(C)(PROLOGUE, EXPRESSION)
  208. # -------------------------------------------------
  209. # Return a program that is valid if EXPRESSION is nonzero.
  210. # EXPRESSION must be an integer constant expression.
  211. # Be sure to use this array to avoid `unused' warnings, which are even
  212. # errors with `-W error'.
  213. m4_define([AC_LANG_BOOL_COMPILE_TRY(C)],
  214. [AC_LANG_PROGRAM([$1], [static int test_array @<:@1 - 2 * !($2)@:>@;
  215. test_array @<:@0@:>@ = 0
  216. ])])
  217. # AC_LANG_INT_SAVE(C)(PROLOGUE, EXPRESSION)
  218. # -----------------------------------------
  219. # We need `stdio.h' to open a `FILE' and `stdlib.h' for `exit'.
  220. # But we include them only after the EXPRESSION has been evaluated.
  221. m4_define([AC_LANG_INT_SAVE(C)],
  222. [AC_LANG_PROGRAM([$1
  223. static long int longval () { return $2; }
  224. static unsigned long int ulongval () { return $2; }
  225. @%:@include <stdio.h>
  226. @%:@include <stdlib.h>],
  227. [
  228. FILE *f = fopen ("conftest.val", "w");
  229. if (! f)
  230. return 1;
  231. if (($2) < 0)
  232. {
  233. long int i = longval ();
  234. if (i != ($2))
  235. return 1;
  236. fprintf (f, "%ld\n", i);
  237. }
  238. else
  239. {
  240. unsigned long int i = ulongval ();
  241. if (i != ($2))
  242. return 1;
  243. fprintf (f, "%lu\n", i);
  244. }
  245. return ferror (f) || fclose (f) != 0;
  246. ])])
  247. # ----------------- #
  248. # 2c. C++ sources. #
  249. # ----------------- #
  250. # AC_LANG_SOURCE(C++)(BODY)
  251. # -------------------------
  252. m4_copy([AC_LANG_SOURCE(C)], [AC_LANG_SOURCE(C++)])
  253. # AC_LANG_PROGRAM(C++)([PROLOGUE], [BODY])
  254. # ----------------------------------------
  255. m4_copy([AC_LANG_PROGRAM(C)], [AC_LANG_PROGRAM(C++)])
  256. # AC_LANG_CALL(C++)(PROLOGUE, FUNCTION)
  257. # -------------------------------------
  258. m4_copy([AC_LANG_CALL(C)], [AC_LANG_CALL(C++)])
  259. # AC_LANG_FUNC_LINK_TRY(C++)(FUNCTION)
  260. # ------------------------------------
  261. m4_copy([AC_LANG_FUNC_LINK_TRY(C)], [AC_LANG_FUNC_LINK_TRY(C++)])
  262. # AC_LANG_BOOL_COMPILE_TRY(C++)(PROLOGUE, EXPRESSION)
  263. # ---------------------------------------------------
  264. m4_copy([AC_LANG_BOOL_COMPILE_TRY(C)], [AC_LANG_BOOL_COMPILE_TRY(C++)])
  265. # AC_LANG_INT_SAVE(C++)(PROLOGUE, EXPRESSION)
  266. # -------------------------------------------
  267. m4_copy([AC_LANG_INT_SAVE(C)], [AC_LANG_INT_SAVE(C++)])
  268. # ------------------------- #
  269. # 2d. Objective C sources. #
  270. # ------------------------- #
  271. # AC_LANG_SOURCE(Objective C)(BODY)
  272. # ---------------------------------
  273. m4_copy([AC_LANG_SOURCE(C)], [AC_LANG_SOURCE(Objective C)])
  274. # AC_LANG_PROGRAM(Objective C)([PROLOGUE], [BODY])
  275. # ------------------------------------------------
  276. m4_copy([AC_LANG_PROGRAM(C)], [AC_LANG_PROGRAM(Objective C)])
  277. # AC_LANG_CALL(Objective C)(PROLOGUE, FUNCTION)
  278. # ---------------------------------------------
  279. m4_copy([AC_LANG_CALL(C)], [AC_LANG_CALL(Objective C)])
  280. # AC_LANG_FUNC_LINK_TRY(Objective C)(FUNCTION)
  281. # --------------------------------------------
  282. m4_copy([AC_LANG_FUNC_LINK_TRY(C)], [AC_LANG_FUNC_LINK_TRY(Objective C)])
  283. # AC_LANG_BOOL_COMPILE_TRY(Objective C)(PROLOGUE, EXPRESSION)
  284. # -----------------------------------------------------------
  285. m4_copy([AC_LANG_BOOL_COMPILE_TRY(C)], [AC_LANG_BOOL_COMPILE_TRY(Objective C)])
  286. # AC_LANG_INT_SAVE(Objective C)(PROLOGUE, EXPRESSION)
  287. # ---------------------------------------------------
  288. m4_copy([AC_LANG_INT_SAVE(C)], [AC_LANG_INT_SAVE(Objective C)])
  289. ## -------------------------------------------- ##
  290. ## 3. Looking for Compilers and Preprocessors. ##
  291. ## -------------------------------------------- ##
  292. # -------------------- #
  293. # 3b. The C compiler. #
  294. # -------------------- #
  295. # _AC_ARG_VAR_CPPFLAGS
  296. # --------------------
  297. # Document and register CPPFLAGS, which is used by
  298. # AC_PROG_{CC, CPP, CXX, CXXCPP, OBJC, OBJCPP}.
  299. AC_DEFUN([_AC_ARG_VAR_CPPFLAGS],
  300. [AC_ARG_VAR([CPPFLAGS],
  301. [C/C++/Objective C preprocessor flags, e.g. -I<include dir>
  302. if you have headers in a nonstandard directory <include dir>])])
  303. # _AC_ARG_VAR_LDFLAGS
  304. # -------------------
  305. # Document and register LDFLAGS, which is used by
  306. # AC_PROG_{CC, CXX, F77, FC, OBJC}.
  307. AC_DEFUN([_AC_ARG_VAR_LDFLAGS],
  308. [AC_ARG_VAR([LDFLAGS],
  309. [linker flags, e.g. -L<lib dir> if you have libraries in a
  310. nonstandard directory <lib dir>])])
  311. # _AC_ARG_VAR_LIBS
  312. # ----------------
  313. # Document and register LIBS, which is used by
  314. # AC_PROG_{CC, CXX, F77, FC, OBJS}.
  315. AC_DEFUN([_AC_ARG_VAR_LIBS],
  316. [AC_ARG_VAR([LIBS],
  317. [libraries to pass to the linker, e.g. -l<library>])])
  318. # AC_LANG_PREPROC(C)
  319. # -------------------
  320. # Find the C preprocessor. Must be AC_DEFUN'd to be AC_REQUIRE'able.
  321. AC_DEFUN([AC_LANG_PREPROC(C)],
  322. [AC_REQUIRE([AC_PROG_CPP])])
  323. # _AC_PROG_PREPROC_WORKS_IFELSE(IF-WORKS, IF-NOT)
  324. # -----------------------------------------------
  325. # Check if $ac_cpp is a working preprocessor that can flag absent
  326. # includes either by the exit status or by warnings.
  327. # This macro is for all languages, not only C.
  328. AC_DEFUN([_AC_PROG_PREPROC_WORKS_IFELSE],
  329. [ac_preproc_ok=false
  330. for ac_[]_AC_LANG_ABBREV[]_preproc_warn_flag in '' yes
  331. do
  332. # Use a header file that comes with gcc, so configuring glibc
  333. # with a fresh cross-compiler works.
  334. # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
  335. # <limits.h> exists even on freestanding compilers.
  336. # On the NeXT, cc -E runs the code through the compiler's parser,
  337. # not just through cpp. "Syntax error" is here to catch this case.
  338. _AC_PREPROC_IFELSE([AC_LANG_SOURCE([[@%:@ifdef __STDC__
  339. @%:@ include <limits.h>
  340. @%:@else
  341. @%:@ include <assert.h>
  342. @%:@endif
  343. Syntax error]])],
  344. [],
  345. [# Broken: fails on valid input.
  346. continue])
  347. # OK, works on sane cases. Now check whether nonexistent headers
  348. # can be detected and how.
  349. _AC_PREPROC_IFELSE([AC_LANG_SOURCE([[@%:@include <ac_nonexistent.h>]])],
  350. [# Broken: success on invalid input.
  351. continue],
  352. [# Passes both tests.
  353. ac_preproc_ok=:
  354. break])
  355. done
  356. # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
  357. rm -f conftest.err conftest.$ac_ext
  358. AS_IF([$ac_preproc_ok], [$1], [$2])])# _AC_PROG_PREPROC_WORKS_IFELSE
  359. # AC_PROG_CPP
  360. # -----------
  361. # Find a working C preprocessor.
  362. # We shouldn't have to require AC_PROG_CC, but this is due to the concurrency
  363. # between the AC_LANG_COMPILER_REQUIRE family and that of AC_PROG_CC.
  364. AN_MAKEVAR([CPP], [AC_PROG_CPP])
  365. AN_PROGRAM([cpp], [AC_PROG_CPP])
  366. AC_DEFUN([AC_PROG_CPP],
  367. [AC_REQUIRE([AC_PROG_CC])dnl
  368. AC_ARG_VAR([CPP], [C preprocessor])dnl
  369. _AC_ARG_VAR_CPPFLAGS()dnl
  370. AC_LANG_PUSH(C)dnl
  371. AC_MSG_CHECKING([how to run the C preprocessor])
  372. # On Suns, sometimes $CPP names a directory.
  373. if test -n "$CPP" && test -d "$CPP"; then
  374. CPP=
  375. fi
  376. if test -z "$CPP"; then
  377. AC_CACHE_VAL([ac_cv_prog_CPP],
  378. [dnl
  379. # Double quotes because CPP needs to be expanded
  380. for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
  381. do
  382. _AC_PROG_PREPROC_WORKS_IFELSE([break])
  383. done
  384. ac_cv_prog_CPP=$CPP
  385. ])dnl
  386. CPP=$ac_cv_prog_CPP
  387. else
  388. ac_cv_prog_CPP=$CPP
  389. fi
  390. AC_MSG_RESULT([$CPP])
  391. _AC_PROG_PREPROC_WORKS_IFELSE([],
  392. [AC_MSG_FAILURE([C preprocessor "$CPP" fails sanity check])])
  393. AC_SUBST(CPP)dnl
  394. AC_LANG_POP(C)dnl
  395. ])# AC_PROG_CPP
  396. # AC_PROG_CPP_WERROR
  397. # ------------------
  398. # Treat warnings from the preprocessor as errors.
  399. AC_DEFUN([AC_PROG_CPP_WERROR],
  400. [AC_REQUIRE([AC_PROG_CPP])dnl
  401. ac_c_preproc_warn_flag=yes])# AC_PROG_CPP_WERROR
  402. # AC_LANG_COMPILER(C)
  403. # -------------------
  404. # Find the C compiler. Must be AC_DEFUN'd to be AC_REQUIRE'able.
  405. AC_DEFUN([AC_LANG_COMPILER(C)],
  406. [AC_REQUIRE([AC_PROG_CC])])
  407. # ac_cv_prog_gcc
  408. # --------------
  409. # We used to name the cache variable this way.
  410. AU_DEFUN([ac_cv_prog_gcc],
  411. [ac_cv_c_compiler_gnu])
  412. # AC_PROG_CC([COMPILER ...])
  413. # --------------------------
  414. # COMPILER ... is a space separated list of C compilers to search for.
  415. # This just gives the user an opportunity to specify an alternative
  416. # search list for the C compiler.
  417. AN_MAKEVAR([CC], [AC_PROG_CC])
  418. AN_PROGRAM([cc], [AC_PROG_CC])
  419. AN_PROGRAM([gcc], [AC_PROG_CC])
  420. AC_DEFUN([AC_PROG_CC],
  421. [AC_LANG_PUSH(C)dnl
  422. AC_ARG_VAR([CC], [C compiler command])dnl
  423. AC_ARG_VAR([CFLAGS], [C compiler flags])dnl
  424. _AC_ARG_VAR_LDFLAGS()dnl
  425. _AC_ARG_VAR_LIBS()dnl
  426. _AC_ARG_VAR_CPPFLAGS()dnl
  427. m4_ifval([$1],
  428. [AC_CHECK_TOOLS(CC, [$1])],
  429. [AC_CHECK_TOOL(CC, gcc)
  430. if test -z "$CC"; then
  431. dnl Here we want:
  432. dnl AC_CHECK_TOOL(CC, cc)
  433. dnl but without the check for a tool without the prefix.
  434. dnl Until the check is removed from there, copy the code:
  435. if test -n "$ac_tool_prefix"; then
  436. AC_CHECK_PROG(CC, [${ac_tool_prefix}cc], [${ac_tool_prefix}cc])
  437. fi
  438. fi
  439. if test -z "$CC"; then
  440. AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc)
  441. fi
  442. if test -z "$CC"; then
  443. AC_CHECK_TOOLS(CC, cl.exe)
  444. fi
  445. ])
  446. test -z "$CC" && AC_MSG_FAILURE([no acceptable C compiler found in \$PATH])
  447. # Provide some information about the compiler.
  448. _AS_ECHO_LOG([checking for _AC_LANG compiler version])
  449. ac_compiler=`set X $ac_compile; echo $[2]`
  450. _AC_DO([$ac_compiler --version >&AS_MESSAGE_LOG_FD])
  451. _AC_DO([$ac_compiler -v >&AS_MESSAGE_LOG_FD])
  452. _AC_DO([$ac_compiler -V >&AS_MESSAGE_LOG_FD])
  453. m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
  454. m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
  455. _AC_LANG_COMPILER_GNU
  456. GCC=`test $ac_compiler_gnu = yes && echo yes`
  457. _AC_PROG_CC_G
  458. _AC_PROG_CC_C89
  459. AC_LANG_POP(C)dnl
  460. ])# AC_PROG_CC
  461. # _AC_PROG_CC_G
  462. # -------------
  463. # Check whether -g works, even if CFLAGS is set, in case the package
  464. # plays around with CFLAGS (such as to build both debugging and normal
  465. # versions of a library), tasteless as that idea is.
  466. # Don't consider -g to work if it generates warnings when plain compiles don't.
  467. m4_define([_AC_PROG_CC_G],
  468. [ac_test_CFLAGS=${CFLAGS+set}
  469. ac_save_CFLAGS=$CFLAGS
  470. AC_CACHE_CHECK(whether $CC accepts -g, ac_cv_prog_cc_g,
  471. [ac_save_c_werror_flag=$ac_c_werror_flag
  472. ac_c_werror_flag=yes
  473. ac_cv_prog_cc_g=no
  474. CFLAGS="-g"
  475. _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
  476. [ac_cv_prog_cc_g=yes],
  477. [CFLAGS=""
  478. _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
  479. [],
  480. [ac_c_werror_flag=$ac_save_c_werror_flag
  481. CFLAGS="-g"
  482. _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
  483. [ac_cv_prog_cc_g=yes])])])
  484. ac_c_werror_flag=$ac_save_c_werror_flag])
  485. if test "$ac_test_CFLAGS" = set; then
  486. CFLAGS=$ac_save_CFLAGS
  487. elif test $ac_cv_prog_cc_g = yes; then
  488. if test "$GCC" = yes; then
  489. CFLAGS="-g -O2"
  490. else
  491. CFLAGS="-g"
  492. fi
  493. else
  494. if test "$GCC" = yes; then
  495. CFLAGS="-O2"
  496. else
  497. CFLAGS=
  498. fi
  499. fi[]dnl
  500. ])# _AC_PROG_CC_G
  501. # AC_PROG_GCC_TRADITIONAL
  502. # -----------------------
  503. AN_FUNCTION([ioctl], [AC_PROG_GCC_TRADITIONAL])
  504. AC_DEFUN([AC_PROG_GCC_TRADITIONAL],
  505. [AC_REQUIRE([AC_PROG_CC])dnl
  506. if test $ac_cv_c_compiler_gnu = yes; then
  507. AC_CACHE_CHECK(whether $CC needs -traditional,
  508. ac_cv_prog_gcc_traditional,
  509. [ ac_pattern="Autoconf.*'x'"
  510. AC_EGREP_CPP($ac_pattern, [#include <sgtty.h>
  511. Autoconf TIOCGETP],
  512. ac_cv_prog_gcc_traditional=yes, ac_cv_prog_gcc_traditional=no)
  513. if test $ac_cv_prog_gcc_traditional = no; then
  514. AC_EGREP_CPP($ac_pattern, [#include <termio.h>
  515. Autoconf TCGETA],
  516. ac_cv_prog_gcc_traditional=yes)
  517. fi])
  518. if test $ac_cv_prog_gcc_traditional = yes; then
  519. CC="$CC -traditional"
  520. fi
  521. fi
  522. ])# AC_PROG_GCC_TRADITIONAL
  523. # AC_PROG_CC_C_O
  524. # --------------
  525. AC_DEFUN([AC_PROG_CC_C_O],
  526. [AC_REQUIRE([AC_PROG_CC])dnl
  527. if test "x$CC" != xcc; then
  528. AC_MSG_CHECKING([whether $CC and cc understand -c and -o together])
  529. else
  530. AC_MSG_CHECKING([whether cc understands -c and -o together])
  531. fi
  532. set dummy $CC; ac_cc=`echo $[2] |
  533. sed 's/[[^a-zA-Z0-9_]]/_/g;s/^[[0-9]]/_/'`
  534. AC_CACHE_VAL(ac_cv_prog_cc_${ac_cc}_c_o,
  535. [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])
  536. # Make sure it works both with $CC and with simple cc.
  537. # We do the test twice because some compilers refuse to overwrite an
  538. # existing .o file with -o, though they will create one.
  539. ac_try='$CC -c conftest.$ac_ext -o conftest2.$ac_objext >&AS_MESSAGE_LOG_FD'
  540. rm -f conftest2.*
  541. if _AC_DO_VAR(ac_try) &&
  542. test -f conftest2.$ac_objext && _AC_DO_VAR(ac_try);
  543. then
  544. eval ac_cv_prog_cc_${ac_cc}_c_o=yes
  545. if test "x$CC" != xcc; then
  546. # Test first that cc exists at all.
  547. if _AC_DO_TOKENS(cc -c conftest.$ac_ext >&AS_MESSAGE_LOG_FD); then
  548. ac_try='cc -c conftest.$ac_ext -o conftest2.$ac_objext >&AS_MESSAGE_LOG_FD'
  549. rm -f conftest2.*
  550. if _AC_DO_VAR(ac_try) &&
  551. test -f conftest2.$ac_objext && _AC_DO_VAR(ac_try);
  552. then
  553. # cc works too.
  554. :
  555. else
  556. # cc exists but doesn't like -o.
  557. eval ac_cv_prog_cc_${ac_cc}_c_o=no
  558. fi
  559. fi
  560. fi
  561. else
  562. eval ac_cv_prog_cc_${ac_cc}_c_o=no
  563. fi
  564. rm -f core conftest*
  565. ])dnl
  566. if eval test \$ac_cv_prog_cc_${ac_cc}_c_o = yes; then
  567. AC_MSG_RESULT([yes])
  568. else
  569. AC_MSG_RESULT([no])
  570. AC_DEFINE(NO_MINUS_C_MINUS_O, 1,
  571. [Define to 1 if your C compiler doesn't accept -c and -o together.])
  572. fi
  573. ])# AC_PROG_CC_C_O
  574. # ---------------------- #
  575. # 3c. The C++ compiler. #
  576. # ---------------------- #
  577. # AC_LANG_PREPROC(C++)
  578. # ---------------------
  579. # Find the C++ preprocessor. Must be AC_DEFUN'd to be AC_REQUIRE'able.
  580. AC_DEFUN([AC_LANG_PREPROC(C++)],
  581. [AC_REQUIRE([AC_PROG_CXXCPP])])
  582. # AC_PROG_CXXCPP
  583. # --------------
  584. # Find a working C++ preprocessor.
  585. # We shouldn't have to require AC_PROG_CC, but this is due to the concurrency
  586. # between the AC_LANG_COMPILER_REQUIRE family and that of AC_PROG_CXX.
  587. AC_DEFUN([AC_PROG_CXXCPP],
  588. [AC_REQUIRE([AC_PROG_CXX])dnl
  589. AC_ARG_VAR([CXXCPP], [C++ preprocessor])dnl
  590. _AC_ARG_VAR_CPPFLAGS()dnl
  591. AC_LANG_PUSH(C++)dnl
  592. AC_MSG_CHECKING([how to run the C++ preprocessor])
  593. if test -z "$CXXCPP"; then
  594. AC_CACHE_VAL(ac_cv_prog_CXXCPP,
  595. [dnl
  596. # Double quotes because CXXCPP needs to be expanded
  597. for CXXCPP in "$CXX -E" "/lib/cpp"
  598. do
  599. _AC_PROG_PREPROC_WORKS_IFELSE([break])
  600. done
  601. ac_cv_prog_CXXCPP=$CXXCPP
  602. ])dnl
  603. CXXCPP=$ac_cv_prog_CXXCPP
  604. else
  605. ac_cv_prog_CXXCPP=$CXXCPP
  606. fi
  607. AC_MSG_RESULT([$CXXCPP])
  608. _AC_PROG_PREPROC_WORKS_IFELSE([],
  609. [AC_MSG_FAILURE([C++ preprocessor "$CXXCPP" fails sanity check])])
  610. AC_SUBST(CXXCPP)dnl
  611. AC_LANG_POP(C++)dnl
  612. ])# AC_PROG_CXXCPP
  613. # AC_LANG_COMPILER(C++)
  614. # ---------------------
  615. # Find the C++ compiler. Must be AC_DEFUN'd to be AC_REQUIRE'able.
  616. AC_DEFUN([AC_LANG_COMPILER(C++)],
  617. [AC_REQUIRE([AC_PROG_CXX])])
  618. # ac_cv_prog_gxx
  619. # --------------
  620. # We used to name the cache variable this way.
  621. AU_DEFUN([ac_cv_prog_gxx],
  622. [ac_cv_cxx_compiler_gnu])
  623. # AC_PROG_CXX([LIST-OF-COMPILERS])
  624. # --------------------------------
  625. # LIST-OF-COMPILERS is a space separated list of C++ compilers to search
  626. # for (if not specified, a default list is used). This just gives the
  627. # user an opportunity to specify an alternative search list for the C++
  628. # compiler.
  629. # aCC HP-UX C++ compiler much better than `CC', so test before.
  630. # FCC Fujitsu C++ compiler
  631. # KCC KAI C++ compiler
  632. # RCC Rational C++
  633. # xlC_r AIX C Set++ (with support for reentrant code)
  634. # xlC AIX C Set++
  635. AN_MAKEVAR([CXX], [AC_PROG_CXX])
  636. AN_PROGRAM([CC], [AC_PROG_CXX])
  637. AN_PROGRAM([c++], [AC_PROG_CXX])
  638. AN_PROGRAM([g++], [AC_PROG_CXX])
  639. AC_DEFUN([AC_PROG_CXX],
  640. [AC_LANG_PUSH(C++)dnl
  641. AC_ARG_VAR([CXX], [C++ compiler command])dnl
  642. AC_ARG_VAR([CXXFLAGS], [C++ compiler flags])dnl
  643. _AC_ARG_VAR_LDFLAGS()dnl
  644. _AC_ARG_VAR_LIBS()dnl
  645. _AC_ARG_VAR_CPPFLAGS()dnl
  646. _AC_ARG_VAR_PRECIOUS([CCC])dnl
  647. if test -z "$CXX"; then
  648. if test -n "$CCC"; then
  649. CXX=$CCC
  650. else
  651. AC_CHECK_TOOLS(CXX,
  652. [m4_default([$1],
  653. [g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC])],
  654. g++)
  655. fi
  656. fi
  657. # Provide some information about the compiler.
  658. _AS_ECHO_LOG([checking for _AC_LANG compiler version])
  659. ac_compiler=`set X $ac_compile; echo $[2]`
  660. _AC_DO([$ac_compiler --version >&AS_MESSAGE_LOG_FD])
  661. _AC_DO([$ac_compiler -v >&AS_MESSAGE_LOG_FD])
  662. _AC_DO([$ac_compiler -V >&AS_MESSAGE_LOG_FD])
  663. m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
  664. m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
  665. _AC_LANG_COMPILER_GNU
  666. GXX=`test $ac_compiler_gnu = yes && echo yes`
  667. _AC_PROG_CXX_G
  668. AC_LANG_POP(C++)dnl
  669. ])# AC_PROG_CXX
  670. # _AC_PROG_CXX_G
  671. # --------------
  672. # Check whether -g works, even if CXXFLAGS is set, in case the package
  673. # plays around with CXXFLAGS (such as to build both debugging and
  674. # normal versions of a library), tasteless as that idea is.
  675. # Don't consider -g to work if it generates warnings when plain compiles don't.
  676. m4_define([_AC_PROG_CXX_G],
  677. [ac_test_CXXFLAGS=${CXXFLAGS+set}
  678. ac_save_CXXFLAGS=$CXXFLAGS
  679. AC_CACHE_CHECK(whether $CXX accepts -g, ac_cv_prog_cxx_g,
  680. [ac_save_cxx_werror_flag=$ac_cxx_werror_flag
  681. ac_cxx_werror_flag=yes
  682. ac_cv_prog_cxx_g=no
  683. CXXFLAGS="-g"
  684. _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
  685. [ac_cv_prog_cxx_g=yes],
  686. [CXXFLAGS=""
  687. _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
  688. [],
  689. [ac_cxx_werror_flag=$ac_save_cxx_werror_flag
  690. CXXFLAGS="-g"
  691. _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
  692. [ac_cv_prog_cxx_g=yes])])])
  693. ac_cxx_werror_flag=$ac_save_cxx_werror_flag])
  694. if test "$ac_test_CXXFLAGS" = set; then
  695. CXXFLAGS=$ac_save_CXXFLAGS
  696. elif test $ac_cv_prog_cxx_g = yes; then
  697. if test "$GXX" = yes; then
  698. CXXFLAGS="-g -O2"
  699. else
  700. CXXFLAGS="-g"
  701. fi
  702. else
  703. if test "$GXX" = yes; then
  704. CXXFLAGS="-O2"
  705. else
  706. CXXFLAGS=
  707. fi
  708. fi[]dnl
  709. ])# _AC_PROG_CXX_G
  710. # AC_PROG_CXX_C_O
  711. # ---------------
  712. # Test if the C++ compiler accepts the options `-c' and `-o'
  713. # simultaneously, and define `CXX_NO_MINUS_C_MINUS_O' if it does not.
  714. AC_DEFUN([AC_PROG_CXX_C_O],
  715. [AC_REQUIRE([AC_PROG_CXX])dnl
  716. AC_LANG_PUSH([C++])dnl
  717. AC_CACHE_CHECK([whether $CXX understands -c and -o together],
  718. [ac_cv_prog_cxx_c_o],
  719. [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])
  720. # We test twice because some compilers refuse to overwrite an existing
  721. # `.o' file with `-o', although they will create one.
  722. ac_try='$CXX $CXXFLAGS -c conftest.$ac_ext -o conftest2.$ac_objext >&AS_MESSAGE_LOG_FD'
  723. rm -f conftest2.*
  724. if _AC_DO_VAR(ac_try) &&
  725. test -f conftest2.$ac_objext &&
  726. _AC_DO_VAR(ac_try); then
  727. ac_cv_prog_cxx_c_o=yes
  728. else
  729. ac_cv_prog_cxx_c_o=no
  730. fi
  731. rm -f conftest*])
  732. if test $ac_cv_prog_cxx_c_o = no; then
  733. AC_DEFINE(CXX_NO_MINUS_C_MINUS_O, 1,
  734. [Define to 1 if your C++ compiler doesn't accept
  735. -c and -o together.])
  736. fi
  737. AC_LANG_POP([C++])dnl
  738. ])# AC_PROG_CXX_C_O
  739. # ------------------------------ #
  740. # 3d. The Objective C compiler. #
  741. # ------------------------------ #
  742. # AC_LANG_PREPROC(Objective C)
  743. # ----------------------------
  744. # Find the Objective C preprocessor. Must be AC_DEFUN'd to be AC_REQUIRE'able.
  745. AC_DEFUN([AC_LANG_PREPROC(Objective C)],
  746. [AC_REQUIRE([AC_PROG_OBJCPP])])
  747. # AC_PROG_OBJCPP
  748. # --------------
  749. # Find a working Objective C preprocessor.
  750. AC_DEFUN([AC_PROG_OBJCPP],
  751. [AC_REQUIRE([AC_PROG_OBJC])dnl
  752. AC_ARG_VAR([OBJCPP], [Objective C preprocessor])dnl
  753. _AC_ARG_VAR_CPPFLAGS()dnl
  754. AC_LANG_PUSH(Objective C)dnl
  755. AC_MSG_CHECKING([how to run the Objective C preprocessor])
  756. if test -z "$OBJCPP"; then
  757. AC_CACHE_VAL(ac_cv_prog_OBJCPP,
  758. [dnl
  759. # Double quotes because OBJCPP needs to be expanded
  760. for OBJCPP in "$OBJC -E" "/lib/cpp"
  761. do
  762. _AC_PROG_PREPROC_WORKS_IFELSE([break])
  763. done
  764. ac_cv_prog_OBJCPP=$OBJCPP
  765. ])dnl
  766. OBJCPP=$ac_cv_prog_OBJCPP
  767. else
  768. ac_cv_prog_OBJCPP=$OBJCPP
  769. fi
  770. AC_MSG_RESULT([$OBJCPP])
  771. _AC_PROG_PREPROC_WORKS_IFELSE([],
  772. [AC_MSG_FAILURE([Objective C preprocessor "$OBJCPP" fails sanity check])])
  773. AC_SUBST(OBJCPP)dnl
  774. AC_LANG_POP(Objective C)dnl
  775. ])# AC_PROG_OBJCPP
  776. # AC_LANG_COMPILER(Objective C)
  777. # -----------------------------
  778. # Find the Objective C compiler. Must be AC_DEFUN'd to be AC_REQUIRE'able.
  779. AC_DEFUN([AC_LANG_COMPILER(Objective C)],
  780. [AC_REQUIRE([AC_PROG_OBJC])])
  781. # AC_PROG_OBJC([LIST-OF-COMPILERS])
  782. # ---------------------------------
  783. # LIST-OF-COMPILERS is a space separated list of Objective C compilers to
  784. # search for (if not specified, a default list is used). This just gives
  785. # the user an opportunity to specify an alternative search list for the
  786. # Objective C compiler.
  787. # objcc StepStone Objective-C compiler (also "standard" name for OBJC)
  788. # objc David Stes' POC. If you installed this, you likely want it.
  789. # cc Native C compiler (for instance, Apple).
  790. # CC You never know.
  791. AN_MAKEVAR([OBJC], [AC_PROG_OBJC])
  792. AN_PROGRAM([objcc], [AC_PROG_OBJC])
  793. AN_PROGRAM([objc], [AC_PROG_OBJC])
  794. AC_DEFUN([AC_PROG_OBJC],
  795. [AC_LANG_PUSH(Objective C)dnl
  796. AC_ARG_VAR([OBJC], [Objective C compiler command])dnl
  797. AC_ARG_VAR([OBJCFLAGS], [Objective C compiler flags])dnl
  798. _AC_ARG_VAR_LDFLAGS()dnl
  799. _AC_ARG_VAR_LIBS()dnl
  800. _AC_ARG_VAR_CPPFLAGS()dnl
  801. _AC_ARG_VAR_PRECIOUS([OBJC])dnl
  802. AC_CHECK_TOOLS(OBJC,
  803. [m4_default([$1], [gcc objcc objc cc CC])],
  804. gcc)
  805. # Provide some information about the compiler.
  806. _AS_ECHO_LOG([checking for _AC_LANG compiler version])
  807. ac_compiler=`set X $ac_compile; echo $[2]`
  808. _AC_DO([$ac_compiler --version >&AS_MESSAGE_LOG_FD])
  809. _AC_DO([$ac_compiler -v >&AS_MESSAGE_LOG_FD])
  810. _AC_DO([$ac_compiler -V >&AS_MESSAGE_LOG_FD])
  811. m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
  812. m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
  813. _AC_LANG_COMPILER_GNU
  814. GOBJC=`test $ac_compiler_gnu = yes && echo yes`
  815. _AC_PROG_OBJC_G
  816. AC_LANG_POP(Objective C)dnl
  817. ])# AC_PROG_OBJC
  818. # _AC_PROG_OBJC_G
  819. # ---------------
  820. # Check whether -g works, even if OBJCFLAGS is set, in case the package
  821. # plays around with OBJCFLAGS (such as to build both debugging and
  822. # normal versions of a library), tasteless as that idea is.
  823. # Don't consider -g to work if it generates warnings when plain compiles don't.
  824. m4_define([_AC_PROG_OBJC_G],
  825. [ac_test_OBJCFLAGS=${OBJCFLAGS+set}
  826. ac_save_OBJCFLAGS=$OBJCFLAGS
  827. AC_CACHE_CHECK(whether $OBJC accepts -g, ac_cv_prog_objc_g,
  828. [ac_save_objc_werror_flag=$ac_objc_werror_flag
  829. ac_objc_werror_flag=yes
  830. ac_cv_prog_objc_g=no
  831. OBJCFLAGS="-g"
  832. _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
  833. [ac_cv_prog_objc_g=yes],
  834. [OBJCFLAGS=""
  835. _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
  836. [],
  837. [ac_objc_werror_flag=$ac_save_objc_werror_flag
  838. OBJCFLAGS="-g"
  839. _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
  840. [ac_cv_prog_objc_g=yes])])])
  841. ac_objc_werror_flag=$ac_save_objc_werror_flag])
  842. if test "$ac_test_OBJCFLAGS" = set; then
  843. OBJCFLAGS=$ac_save_OBJCFLAGS
  844. elif test $ac_cv_prog_objc_g = yes; then
  845. if test "$GOBJC" = yes; then
  846. OBJCFLAGS="-g -O2"
  847. else
  848. OBJCFLAGS="-g"
  849. fi
  850. else
  851. if test "$GOBJC" = yes; then
  852. OBJCFLAGS="-O2"
  853. else
  854. OBJCFLAGS=
  855. fi
  856. fi[]dnl
  857. ])# _AC_PROG_OBJC_G
  858. ## ------------------------------- ##
  859. ## 4. Compilers' characteristics. ##
  860. ## ------------------------------- ##
  861. # -------------------------------- #
  862. # 4b. C compiler characteristics. #
  863. # -------------------------------- #
  864. # _AC_PROG_CC_C89 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE])
  865. # ----------------------------------------------------------------
  866. # If the C compiler is not in ANSI C89 (ISO C90) mode by default, try
  867. # to add an option to output variable CC to make it so. This macro
  868. # tries various options that select ANSI C89 on some system or
  869. # another. It considers the compiler to be in ANSI C89 mode if it
  870. # handles function prototypes correctly.
  871. AC_DEFUN([_AC_PROG_CC_C89],
  872. [_AC_C_STD_TRY([c89],
  873. [[#include <stdarg.h>
  874. #include <stdio.h>
  875. #include <sys/types.h>
  876. #include <sys/stat.h>
  877. /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
  878. struct buf { int x; };
  879. FILE * (*rcsopen) (struct buf *, struct stat *, int);
  880. static char *e (p, i)
  881. char **p;
  882. int i;
  883. {
  884. return p[i];
  885. }
  886. static char *f (char * (*g) (char **, int), char **p, ...)
  887. {
  888. char *s;
  889. va_list v;
  890. va_start (v,p);
  891. s = g (p, va_arg (v,int));
  892. va_end (v);
  893. return s;
  894. }
  895. /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
  896. function prototypes and stuff, but not '\xHH' hex character constants.
  897. These don't provoke an error unfortunately, instead are silently treated
  898. as 'x'. The following induces an error, until -std is added to get
  899. proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an
  900. array size at least. It's necessary to write '\x00'==0 to get something
  901. that's true only with -std. */
  902. int osf4_cc_array ['\x00' == 0 ? 1 : -1];
  903. /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
  904. inside strings and character constants. */
  905. #define FOO(x) 'x'
  906. int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
  907. int test (int i, double x);
  908. struct s1 {int (*f) (int a);};
  909. struct s2 {int (*f) (double a);};
  910. int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
  911. int argc;
  912. char **argv;]],
  913. [[return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];]],
  914. dnl Don't try gcc -ansi; that turns off useful extensions and
  915. dnl breaks some systems' header files.
  916. dnl AIX circa 2003 -qlanglvl=extc89
  917. dnl old AIX -qlanglvl=ansi
  918. dnl Ultrix, OSF/1, Tru64 -std
  919. dnl HP-UX 10.20 and later -Ae
  920. dnl HP-UX older versions -Aa -D_HPUX_SOURCE
  921. dnl SVR4 -Xc -D__EXTENSIONS__
  922. [-qlanglvl=extc89 -qlanglvl=ansi -std \
  923. -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"], [$1], [$2])[]dnl
  924. ])# _AC_PROG_CC_C89
  925. # _AC_C_STD_TRY(STANDARD, TEST-PROLOGUE, TEST-BODY, OPTION-LIST,
  926. # ACTION-IF-AVAILABLE, ACTION-IF-UNAVAILABLE)
  927. # --------------------------------------------------------------
  928. # Check whether the C compiler accepts features of STANDARD (e.g `c89', `c99')
  929. # by trying to compile a program of TEST-PROLOGUE and TEST-BODY. If this fails,
  930. # try again with each compiler option in the space-separated OPTION-LIST; if one
  931. # helps, append it to CC. If eventually successful, run ACTION-IF-AVAILABLE,
  932. # else ACTION-IF-UNAVAILABLE.
  933. AC_DEFUN([_AC_C_STD_TRY],
  934. [AC_MSG_CHECKING([for $CC option to accept ISO ]m4_translit($1, [c], [C]))
  935. AC_CACHE_VAL(ac_cv_prog_cc_$1,
  936. [ac_cv_prog_cc_$1=no
  937. ac_save_CC=$CC
  938. AC_LANG_CONFTEST([AC_LANG_PROGRAM([$2], [$3])])
  939. for ac_arg in '' $4
  940. do
  941. CC="$ac_save_CC $ac_arg"
  942. _AC_COMPILE_IFELSE([], [ac_cv_prog_cc_$1=$ac_arg])
  943. test "x$ac_cv_prog_cc_$1" != "xno" && break
  944. done
  945. rm -f conftest.$ac_ext
  946. CC=$ac_save_CC
  947. ])# AC_CACHE_VAL
  948. case "x$ac_cv_prog_cc_$1" in
  949. x)
  950. AC_MSG_RESULT([none needed]) ;;
  951. xno)
  952. AC_MSG_RESULT([unsupported]) ;;
  953. *)
  954. CC="$CC $ac_cv_prog_cc_$1"
  955. AC_MSG_RESULT([$ac_cv_prog_cc_$1]) ;;
  956. esac
  957. AS_IF([test "x$ac_cv_prog_cc_$1" != xno], [$5], [$6])
  958. ])# _AC_C_STD_TRY
  959. # _AC_PROG_CC_C99 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE])
  960. # ----------------------------------------------------------------
  961. # If the C compiler is not in ISO C99 mode by default, try to add an
  962. # option to output variable CC to make it so. This macro tries
  963. # various options that select ISO C99 on some system or another. It
  964. # considers the compiler to be in ISO C99 mode if it handles _Bool,
  965. # // comments, flexible array members, inline, long long int, mixed
  966. # code and declarations, named initialization of structs, restrict,
  967. # va_copy, varargs macros, variable declarations in for loops and
  968. # variable length arrays.
  969. AC_DEFUN([_AC_PROG_CC_C99],
  970. [_AC_C_STD_TRY([c99],
  971. [[#include <stdarg.h>
  972. #include <stdbool.h>
  973. #include <stdlib.h>
  974. #include <wchar.h>
  975. #include <stdio.h>
  976. // Check varargs macros. These examples are taken from C99 6.10.3.5.
  977. #define debug(...) fprintf (stderr, __VA_ARGS__)
  978. #define showlist(...) puts (#__VA_ARGS__)
  979. #define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__))
  980. static void
  981. test_varargs_macros (void)
  982. {
  983. int x = 1234;
  984. int y = 5678;
  985. debug ("Flag");
  986. debug ("X = %d\n", x);
  987. showlist (The first, second, and third items.);
  988. report (x>y, "x is %d but y is %d", x, y);
  989. }
  990. // Check long long types.
  991. #define BIG64 18446744073709551615ull
  992. #define BIG32 4294967295ul
  993. #define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0)
  994. #if !BIG_OK
  995. your preprocessor is broken;
  996. #endif
  997. #if BIG_OK
  998. #else
  999. your preprocessor is broken;
  1000. #endif
  1001. static long long int bignum = -9223372036854775807LL;
  1002. static unsigned long long int ubignum = BIG64;
  1003. struct incomplete_array
  1004. {
  1005. int datasize;
  1006. double data[];
  1007. };
  1008. struct named_init {
  1009. int number;
  1010. const wchar_t *name;
  1011. double average;
  1012. };
  1013. typedef const char *ccp;
  1014. static inline int
  1015. test_restrict (ccp restrict text)
  1016. {
  1017. // See if C++-style comments work.
  1018. // Iterate through items via the restricted pointer.
  1019. // Also check for declarations in for loops.
  1020. for (unsigned int i = 0; *(text+i) != '\0'; ++i)
  1021. continue;
  1022. return 0;
  1023. }
  1024. // Check varargs and va_copy.
  1025. static void
  1026. test_varargs (const char *format, ...)
  1027. {
  1028. va_list args;
  1029. va_start (args, format);
  1030. va_list args_copy;
  1031. va_copy (args_copy, args);
  1032. const char *str;
  1033. int number;
  1034. float fnumber;
  1035. while (*format)
  1036. {
  1037. switch (*format++)
  1038. {
  1039. case 's': // string
  1040. str = va_arg (args_copy, const char *);
  1041. break;
  1042. case 'd': // int
  1043. number = va_arg (args_copy, int);
  1044. break;
  1045. case 'f': // float
  1046. fnumber = va_arg (args_copy, double);
  1047. break;
  1048. default:
  1049. break;
  1050. }
  1051. }
  1052. va_end (args_copy);
  1053. va_end (args);
  1054. }
  1055. ]],
  1056. [[
  1057. // Check bool.
  1058. _Bool success = false;
  1059. // Check restrict.
  1060. if (test_restrict ("String literal") == 0)
  1061. success = true;
  1062. char *restrict newvar = "Another string";
  1063. // Check varargs.
  1064. test_varargs ("s, d' f .", "string", 65, 34.234);
  1065. test_varargs_macros ();
  1066. // Check flexible array members.
  1067. struct incomplete_array *ia =
  1068. malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10));
  1069. ia->datasize = 10;
  1070. for (int i = 0; i < ia->datasize; ++i)
  1071. ia->data[i] = i * 1.234;
  1072. // Check named initializers.
  1073. struct named_init ni = {
  1074. .number = 34,
  1075. .name = L"Test wide string",
  1076. .average = 543.34343,
  1077. };
  1078. ni.number = 58;
  1079. int dynamic_array[ni.number];
  1080. dynamic_array[ni.number - 1] = 543;
  1081. // work around unused variable warnings
  1082. return (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x'
  1083. || dynamic_array[ni.number - 1] != 543);
  1084. ]],
  1085. dnl Try
  1086. dnl GCC -std=gnu99 (unused restrictive modes: -std=c99 -std=iso9899:1999)
  1087. dnl AIX -qlanglvl=extc99 (unused restrictive mode: -qlanglvl=stdc99)
  1088. dnl Intel ICC -c99
  1089. dnl IRIX -c99
  1090. dnl Solaris (unused because it causes the compiler to assume C99 semantics for
  1091. dnl library functions, and this is invalid before Solaris 10: -xc99)
  1092. dnl Tru64 -c99
  1093. dnl with extended modes being tried first.
  1094. [[-std=gnu99 -c99 -qlanglvl=extc99]], [$1], [$2])[]dnl
  1095. ])# _AC_PROG_CC_C99
  1096. # AC_PROG_CC_C89
  1097. # --------------
  1098. AC_DEFUN([AC_PROG_CC_C89],
  1099. [ AC_REQUIRE([AC_PROG_CC])dnl
  1100. _AC_PROG_CC_C89
  1101. ])
  1102. # AC_PROG_CC_C99
  1103. # --------------
  1104. AC_DEFUN([AC_PROG_CC_C99],
  1105. [ AC_REQUIRE([AC_PROG_CC])dnl
  1106. _AC_PROG_CC_C99
  1107. ])
  1108. # AC_PROG_CC_STDC
  1109. # ---------------
  1110. AC_DEFUN([AC_PROG_CC_STDC],
  1111. [ AC_REQUIRE([AC_PROG_CC])dnl
  1112. AS_CASE([$ac_cv_prog_cc_stdc],
  1113. [no], [ac_cv_prog_cc_c99=no; ac_cv_prog_cc_c89=no],
  1114. [_AC_PROG_CC_C99([ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99],
  1115. [_AC_PROG_CC_C89([ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89],
  1116. [ac_cv_prog_cc_stdc=no])])])dnl
  1117. AC_MSG_CHECKING([for $CC option to accept ISO Standard C])
  1118. AC_CACHE_VAL([ac_cv_prog_cc_stdc], [])
  1119. AS_CASE([$ac_cv_prog_cc_stdc],
  1120. [no], [AC_MSG_RESULT([unsupported])],
  1121. [''], [AC_MSG_RESULT([none needed])],
  1122. [AC_MSG_RESULT([$ac_cv_prog_cc_stdc])])
  1123. ])
  1124. # AC_C_BACKSLASH_A
  1125. # ----------------
  1126. AC_DEFUN([AC_C_BACKSLASH_A],
  1127. [
  1128. AC_CACHE_CHECK([whether backslash-a works in strings], ac_cv_c_backslash_a,
  1129. [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
  1130. [[
  1131. #if '\a' == 'a'
  1132. syntax error;
  1133. #endif
  1134. char buf['\a' == 'a' ? -1 : 1];
  1135. buf[0] = '\a';
  1136. return buf[0] != "\a"[0];
  1137. ]])],
  1138. [ac_cv_c_backslash_a=yes],
  1139. [ac_cv_c_backslash_a=no])])
  1140. if test $ac_cv_c_backslash_a = yes; then
  1141. AC_DEFINE(HAVE_C_BACKSLASH_A, 1,
  1142. [Define if backslash-a works in C strings.])
  1143. fi
  1144. ])
  1145. # AC_C_CROSS
  1146. # ----------
  1147. # Has been merged into AC_PROG_CC.
  1148. AU_DEFUN([AC_C_CROSS], [])
  1149. # AC_C_CHAR_UNSIGNED
  1150. # ------------------
  1151. AC_DEFUN([AC_C_CHAR_UNSIGNED],
  1152. [AH_VERBATIM([__CHAR_UNSIGNED__],
  1153. [/* Define to 1 if type `char' is unsigned and you are not using gcc. */
  1154. #ifndef __CHAR_UNSIGNED__
  1155. # undef __CHAR_UNSIGNED__
  1156. #endif])dnl
  1157. AC_CACHE_CHECK(whether char is unsigned, ac_cv_c_char_unsigned,
  1158. [AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([AC_INCLUDES_DEFAULT([])],
  1159. [((char) -1) < 0])],
  1160. ac_cv_c_char_unsigned=no, ac_cv_c_char_unsigned=yes)])
  1161. if test $ac_cv_c_char_unsigned = yes && test "$GCC" != yes; then
  1162. AC_DEFINE(__CHAR_UNSIGNED__)
  1163. fi
  1164. ])# AC_C_CHAR_UNSIGNED
  1165. # AC_C_BIGENDIAN ([ACTION-IF-TRUE], [ACTION-IF-FALSE], [ACTION-IF-UNKNOWN])
  1166. # -------------------------------------------------------------------------
  1167. AC_DEFUN([AC_C_BIGENDIAN],
  1168. [AC_CACHE_CHECK(whether byte ordering is bigendian, ac_cv_c_bigendian,
  1169. [# See if sys/param.h defines the BYTE_ORDER macro.
  1170. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
  1171. #include <sys/param.h>
  1172. ],
  1173. [#if ! (defined BYTE_ORDER && defined BIG_ENDIAN && defined LITTLE_ENDIAN \
  1174. && BYTE_ORDER && BIG_ENDIAN && LITTLE_ENDIAN)
  1175. bogus endian macros
  1176. #endif
  1177. ])],
  1178. [# It does; now see whether it defined to BIG_ENDIAN or not.
  1179. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
  1180. #include <sys/param.h>
  1181. ], [#if BYTE_ORDER != BIG_ENDIAN
  1182. not big endian
  1183. #endif
  1184. ])], [ac_cv_c_bigendian=yes], [ac_cv_c_bigendian=no])],
  1185. [# It does not; compile a test program.
  1186. AC_RUN_IFELSE(
  1187. [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [[
  1188. /* Are we little or big endian? From Harbison&Steele. */
  1189. union
  1190. {
  1191. long int l;
  1192. char c[sizeof (long int)];
  1193. } u;
  1194. u.l = 1;
  1195. return u.c[sizeof (long int) - 1] == 1;
  1196. ]])],
  1197. [ac_cv_c_bigendian=no],
  1198. [ac_cv_c_bigendian=yes],
  1199. [# try to guess the endianness by grepping values into an object file
  1200. ac_cv_c_bigendian=unknown
  1201. AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
  1202. [[short int ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 };
  1203. short int ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 };
  1204. void _ascii () { char *s = (char *) ascii_mm; s = (char *) ascii_ii; }
  1205. short int ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 };
  1206. short int ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 };
  1207. void _ebcdic () { char *s = (char *) ebcdic_mm; s = (char *) ebcdic_ii; }]],
  1208. [[ _ascii (); _ebcdic (); ]])],
  1209. [if grep BIGenDianSyS conftest.$ac_objext >/dev/null ; then
  1210. ac_cv_c_bigendian=yes
  1211. fi
  1212. if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then
  1213. if test "$ac_cv_c_bigendian" = unknown; then
  1214. ac_cv_c_bigendian=no
  1215. else
  1216. # finding both strings is unlikely to happen, but who knows?
  1217. ac_cv_c_bigendian=unknown
  1218. fi
  1219. fi])])])])
  1220. case $ac_cv_c_bigendian in
  1221. yes)
  1222. m4_default([$1],
  1223. [AC_DEFINE([WORDS_BIGENDIAN], 1,
  1224. [Define to 1 if your processor stores words with the most significant
  1225. byte first (like Motorola and SPARC, unlike Intel and VAX).])]) ;;
  1226. no)
  1227. $2 ;;
  1228. *)
  1229. m4_default([$3],
  1230. [AC_MSG_ERROR([unknown endianness
  1231. presetting ac_cv_c_bigendian=no (or yes) will help])]) ;;
  1232. esac
  1233. ])# AC_C_BIGENDIAN
  1234. # AC_C_INLINE
  1235. # -----------
  1236. # Do nothing if the compiler accepts the inline keyword.
  1237. # Otherwise define inline to __inline__ or __inline if one of those work,
  1238. # otherwise define inline to be empty.
  1239. #
  1240. # HP C version B.11.11.04 doesn't allow a typedef as the return value for an
  1241. # inline function, only builtin types.
  1242. #
  1243. AN_IDENTIFIER([inline], [AC_C_INLINE])
  1244. AC_DEFUN([AC_C_INLINE],
  1245. [AC_CACHE_CHECK([for inline], ac_cv_c_inline,
  1246. [ac_cv_c_inline=no
  1247. for ac_kw in inline __inline__ __inline; do
  1248. AC_COMPILE_IFELSE([AC_LANG_SOURCE(
  1249. [#ifndef __cplusplus
  1250. typedef int foo_t;
  1251. static $ac_kw foo_t static_foo () {return 0; }
  1252. $ac_kw foo_t foo () {return 0; }
  1253. #endif
  1254. ])],
  1255. [ac_cv_c_inline=$ac_kw])
  1256. test "$ac_cv_c_inline" != no && break
  1257. done
  1258. ])
  1259. AH_VERBATIM([inline],
  1260. [/* Define to `__inline__' or `__inline' if that's what the C compiler
  1261. calls it, or to nothing if 'inline' is not supported under any name. */
  1262. #ifndef __cplusplus
  1263. #undef inline
  1264. #endif])
  1265. case $ac_cv_c_inline in
  1266. inline | yes) ;;
  1267. *)
  1268. case $ac_cv_c_inline in
  1269. no) ac_val=;;
  1270. *) ac_val=$ac_cv_c_inline;;
  1271. esac
  1272. cat >>confdefs.h <<_ACEOF
  1273. #ifndef __cplusplus
  1274. #define inline $ac_val
  1275. #endif
  1276. _ACEOF
  1277. ;;
  1278. esac
  1279. ])# AC_C_INLINE
  1280. # AC_C_CONST
  1281. # ----------
  1282. AN_IDENTIFIER([const], [AC_C_CONST])
  1283. AC_DEFUN([AC_C_CONST],
  1284. [AC_CACHE_CHECK([for an ANSI C-conforming const], ac_cv_c_const,
  1285. [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
  1286. [[/* FIXME: Include the comments suggested by Paul. */
  1287. #ifndef __cplusplus
  1288. /* Ultrix mips cc rejects this. */
  1289. typedef int charset[2];
  1290. const charset cs;
  1291. /* SunOS 4.1.1 cc rejects this. */
  1292. char const *const *pcpcc;
  1293. char **ppc;
  1294. /* NEC SVR4.0.2 mips cc rejects this. */
  1295. struct point {int x, y;};
  1296. static struct point const zero = {0,0};
  1297. /* AIX XL C 1.02.0.0 rejects this.
  1298. It does not let you subtract one const X* pointer from another in
  1299. an arm of an if-expression whose if-part is not a constant
  1300. expression */
  1301. const char *g = "string";
  1302. pcpcc = &g + (g ? g-g : 0);
  1303. /* HPUX 7.0 cc rejects these. */
  1304. ++pcpcc;
  1305. ppc = (char**) pcpcc;
  1306. pcpcc = (char const *const *) ppc;
  1307. { /* SCO 3.2v4 cc rejects this. */
  1308. char *t;
  1309. char const *s = 0 ? (char *) 0 : (char const *) 0;
  1310. *t++ = 0;
  1311. if (s) return 0;
  1312. }
  1313. { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */
  1314. int x[] = {25, 17};
  1315. const int *foo = &x[0];
  1316. ++foo;
  1317. }
  1318. { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
  1319. typedef const int *iptr;
  1320. iptr p = 0;
  1321. ++p;
  1322. }
  1323. { /* AIX XL C 1.02.0.0 rejects this saying
  1324. "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
  1325. struct s { int j; const int *ap[3]; };
  1326. struct s *b; b->j = 5;
  1327. }
  1328. { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
  1329. const int foo = 10;
  1330. if (!foo) return 0;
  1331. }
  1332. return !cs[0] && !zero.x;
  1333. #endif
  1334. ]])],
  1335. [ac_cv_c_const=yes],
  1336. [ac_cv_c_const=no])])
  1337. if test $ac_cv_c_const = no; then
  1338. AC_DEFINE(const,,
  1339. [Define to empty if `const' does not conform to ANSI C.])
  1340. fi
  1341. ])# AC_C_CONST
  1342. # AC_C_RESTRICT
  1343. # -------------
  1344. # based on acx_restrict.m4, from the GNU Autoconf Macro Archive at:
  1345. # http://autoconf-archive.cryp.to/acx_restrict.html
  1346. #
  1347. # Determine whether the C/C++ compiler supports the "restrict" keyword
  1348. # introduced in ANSI C99, or an equivalent. Do nothing if the compiler
  1349. # accepts it. Otherwise, if the compiler supports an equivalent,
  1350. # define "restrict" to be that. Here are some variants:
  1351. # - GCC supports both __restrict and __restrict__
  1352. # - older DEC Alpha C compilers support only __restrict
  1353. # - _Restrict is the only spelling accepted by Sun WorkShop 6 update 2 C
  1354. # Otherwise, define "restrict" to be empty.
  1355. AN_IDENTIFIER([restrict], [AC_C_RESTRICT])
  1356. AC_DEFUN([AC_C_RESTRICT],
  1357. [AC_CACHE_CHECK([for C/C++ restrict keyword], ac_cv_c_restrict,
  1358. [ac_cv_c_restrict=no
  1359. # Try the official restrict keyword, then gcc's __restrict, and
  1360. # the less common variants.
  1361. for ac_kw in restrict __restrict __restrict__ _Restrict; do
  1362. AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
  1363. [[typedef int * int_ptr;
  1364. int foo (int_ptr $ac_kw ip) {
  1365. return ip[0];
  1366. }]],
  1367. [[int s[1];
  1368. int * $ac_kw t = s;
  1369. t[0] = 0;
  1370. return foo(t)]])],
  1371. [ac_cv_c_restrict=$ac_kw])
  1372. test "$ac_cv_c_restrict" != no && break
  1373. done
  1374. ])
  1375. case $ac_cv_c_restrict in
  1376. restrict) ;;
  1377. no) AC_DEFINE(restrict,,
  1378. [Define to equivalent of C99 restrict keyword, or to nothing if this
  1379. is not supported. Do not define if restrict is supported directly.]) ;;
  1380. *) AC_DEFINE_UNQUOTED(restrict, $ac_cv_c_restrict) ;;
  1381. esac
  1382. ])# AC_C_RESTRICT
  1383. # AC_C_VOLATILE
  1384. # -------------
  1385. # Note that, unlike const, #defining volatile to be the empty string can
  1386. # actually turn a correct program into an incorrect one, since removing
  1387. # uses of volatile actually grants the compiler permission to perform
  1388. # optimizations that could break the user's code. So, do not #define
  1389. # volatile away unless it is really necessary to allow the user's code
  1390. # to compile cleanly. Benign compiler failures should be tolerated.
  1391. AN_IDENTIFIER([volatile], [AC_C_VOLATILE])
  1392. AC_DEFUN([AC_C_VOLATILE],
  1393. [AC_CACHE_CHECK([for working volatile], ac_cv_c_volatile,
  1394. [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
  1395. volatile int x;
  1396. int * volatile y = (int *) 0;
  1397. return !x && !y;])],
  1398. [ac_cv_c_volatile=yes],
  1399. [ac_cv_c_volatile=no])])
  1400. if test $ac_cv_c_volatile = no; then
  1401. AC_DEFINE(volatile,,
  1402. [Define to empty if the keyword `volatile' does not work.
  1403. Warning: valid code using `volatile' can become incorrect
  1404. without. Disable with care.])
  1405. fi
  1406. ])# AC_C_VOLATILE
  1407. # AC_C_STRINGIZE
  1408. # --------------
  1409. # Checks if `#' can be used to glue strings together at the CPP level.
  1410. # Defines HAVE_STRINGIZE if positive.
  1411. AC_DEFUN([AC_C_STRINGIZE],
  1412. [AC_CACHE_CHECK([for preprocessor stringizing operator],
  1413. [ac_cv_c_stringize],
  1414. [AC_EGREP_CPP([@%:@teststring],
  1415. [@%:@define x(y) #y
  1416. char *s = x(teststring);],
  1417. [ac_cv_c_stringize=no],
  1418. [ac_cv_c_stringize=yes])])
  1419. if test $ac_cv_c_stringize = yes; then
  1420. AC_DEFINE(HAVE_STRINGIZE, 1,
  1421. [Define to 1 if cpp supports the ANSI @%:@ stringizing operator.])
  1422. fi
  1423. ])# AC_C_STRINGIZE
  1424. # AC_C_PROTOTYPES
  1425. # ---------------
  1426. # Check if the C compiler supports prototypes, included if it needs
  1427. # options.
  1428. AC_DEFUN([AC_C_PROTOTYPES],
  1429. [AC_REQUIRE([AC_PROG_CC])dnl
  1430. AC_MSG_CHECKING([for function prototypes])
  1431. if test "$ac_cv_prog_cc_c89" != no; then
  1432. AC_MSG_RESULT([yes])
  1433. AC_DEFINE(PROTOTYPES, 1,
  1434. [Define to 1 if the C compiler supports function prototypes.])
  1435. AC_DEFINE(__PROTOTYPES, 1,
  1436. [Define like PROTOTYPES; this can be used by system headers.])
  1437. else
  1438. AC_MSG_RESULT([no])
  1439. fi
  1440. ])# AC_C_PROTOTYPES
  1441. # AC_C_FLEXIBLE_ARRAY_MEMBER
  1442. # --------------------------
  1443. # Check whether the C compiler supports flexible array members.
  1444. AC_DEFUN([AC_C_FLEXIBLE_ARRAY_MEMBER],
  1445. [
  1446. AC_CACHE_CHECK([for flexible array members],
  1447. ac_cv_c_flexmember,
  1448. [AC_COMPILE_IFELSE(
  1449. [AC_LANG_PROGRAM(
  1450. [[#include <stdlib.h>
  1451. #include <stdio.h>
  1452. #include <stddef.h>
  1453. struct s { int n; double d[]; };]],
  1454. [[int m = getchar ();
  1455. struct s *p = malloc (offsetof (struct s, d)
  1456. + m * sizeof (double));
  1457. p->d[0] = 0.0;
  1458. return p->d != (double *) NULL;]])],
  1459. [ac_cv_c_flexmember=yes],
  1460. [ac_cv_c_flexmember=no])])
  1461. if test $ac_cv_c_flexmember = yes; then
  1462. AC_DEFINE([FLEXIBLE_ARRAY_MEMBER], [],
  1463. [Define to nothing if C supports flexible array members, and to
  1464. 1 if it does not. That way, with a declaration like `struct s
  1465. { int n; double d@<:@FLEXIBLE_ARRAY_MEMBER@:>@; };', the struct hack
  1466. can be used with pre-C99 compilers.
  1467. When computing the size of such an object, don't use 'sizeof (struct s)'
  1468. as it overestimates the size. Use 'offsetof (struct s, d)' instead.
  1469. Don't use 'offsetof (struct s, d@<:@0@:>@)', as this doesn't work with
  1470. MSVC and with C++ compilers.])
  1471. else
  1472. AC_DEFINE([FLEXIBLE_ARRAY_MEMBER], 1)
  1473. fi
  1474. ])
  1475. # AC_C_VARARRAYS
  1476. # --------------
  1477. # Check whether the C compiler supports variable-length arrays.
  1478. AC_DEFUN([AC_C_VARARRAYS],
  1479. [
  1480. AC_CACHE_CHECK([for variable-length arrays],
  1481. ac_cv_c_vararrays,
  1482. [AC_COMPILE_IFELSE(
  1483. [AC_LANG_PROGRAM([],
  1484. [[static int x; char a[++x]; a[sizeof a - 1] = 0; return a[0];]])],
  1485. [ac_cv_c_vararrays=yes],
  1486. [ac_cv_c_vararrays=no])])
  1487. if test $ac_cv_c_vararrays = yes; then
  1488. AC_DEFINE([HAVE_C_VARARRAYS], 1,
  1489. [Define to 1 if C supports variable-length arrays.])
  1490. fi
  1491. ])
  1492. # AC_C_TYPEOF
  1493. # -----------
  1494. # Check if the C compiler supports GCC's typeof syntax.
  1495. # The test case provokes incompatibilities in the Sun C compilers
  1496. # (both Solaris 8 and Solaris 10).
  1497. AC_DEFUN([AC_C_TYPEOF],
  1498. [
  1499. AC_CACHE_CHECK([for typeof syntax and keyword spelling], ac_cv_c_typeof,
  1500. [ac_cv_c_typeof=no
  1501. for ac_kw in typeof __typeof__ no; do
  1502. test $ac_kw = no && break
  1503. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
  1504. [[
  1505. int value;
  1506. typedef struct {
  1507. char a [1
  1508. + ! (($ac_kw (value))
  1509. (($ac_kw (value)) 0 < ($ac_kw (value)) -1
  1510. ? ($ac_kw (value)) - 1
  1511. : ~ (~ ($ac_kw (value)) 0
  1512. << sizeof ($ac_kw (value)))))]; }
  1513. ac__typeof_type_;
  1514. return
  1515. (! ((void) ((ac__typeof_type_ *) 0), 0));
  1516. ]])],
  1517. [ac_cv_c_typeof=$ac_kw])
  1518. test $ac_cv_c_typeof != no && break
  1519. done])
  1520. if test $ac_cv_c_typeof != no; then
  1521. AC_DEFINE([HAVE_TYPEOF], 1,
  1522. [Define to 1 if typeof works with your compiler.])
  1523. if test $ac_cv_c_typeof != typeof; then
  1524. AC_DEFINE_UNQUOTED([typeof], [$ac_cv_c_typeof],
  1525. [Define to __typeof__ if your compiler spells it that way.])
  1526. fi
  1527. fi
  1528. ])