acinclude.m4 142 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054
  1. # checkbuild.m4 -*- Autoconf -*-
  2. #==============================================================================
  3. # Copyright (C)2003 by Eric Sunshine <[email protected]>
  4. #
  5. # This library is free software; you can redistribute it and/or modify it
  6. # under the terms of the GNU Library General Public License as published by
  7. # the Free Software Foundation; either version 2 of the License, or (at your
  8. # option) any later version.
  9. #
  10. # This library is distributed in the hope that it will be useful, but
  11. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  12. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
  13. # License for more details.
  14. #
  15. # You should have received a copy of the GNU Library General Public License
  16. # along with this library; if not, write to the Free Software Foundation,
  17. # Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. #
  19. #==============================================================================
  20. AC_PREREQ([2.56])
  21. #------------------------------------------------------------------------------
  22. # CS_SPLIT_TUPLE(TUPLE, OUTPUT-VARIABLES)
  23. # Split a build-tuple into its component parts. A build tuple is
  24. # constructed by CS_CREATE_TUPLE() and is comprised of compiler flags,
  25. # linker flags, and library references. OUTPUT-VARIABLES is a
  26. # comma-delimited list of shell variables which should receive the
  27. # extracted compiler flags, linker flags, and library references,
  28. # respectively.
  29. #------------------------------------------------------------------------------
  30. AC_DEFUN([CS_SPLIT_TUPLE],
  31. [CS_SPLIT([$1], [cs_dummy,$2], [@])
  32. m4_map([_CS_SPLIT_TUPLE], [$2])])
  33. AC_DEFUN([_CS_SPLIT_TUPLE],
  34. [$1=`echo $$1 | sed 'y%@%:@% %'`
  35. ])
  36. #------------------------------------------------------------------------------
  37. # CS_CREATE_TUPLE([CFLAGS], [LFLAGS], [LIBS])
  38. # Construct a build-tuple which is comprised of compiler flags, linker
  39. # flags, and library references. Build tuples are encoded so as to
  40. # preserve whitespace in each component. This makes it possible for
  41. # macros (such as CS_BUILD_IFELSE) which employ build tuples to accept
  42. # whitespace-delimited lists of tuples, and for shell "for" statements to
  43. # iterate over tuple lists without compromising whitespace embedded
  44. # within individual flags or library references.
  45. #------------------------------------------------------------------------------
  46. AC_DEFUN([CS_CREATE_TUPLE], [`echo @$1@$2@$3 | sed 'y% %@%:@%'`])
  47. #------------------------------------------------------------------------------
  48. # CS_LANG_CFLAGS
  49. # Return the literal string CFLAGS if the current language is C. Return
  50. # the literal string CXXFLAGS if the current language is C++. Generic
  51. # compiler test macros which need to modify or save the compiler flags
  52. # can invoke this macro to get the name of the compiler flags environment
  53. # variable (either CFLAGS or CXXFLAGS) depending upon the current
  54. # language. For example:
  55. # CS_LANG_CFLAGS="$CS_LANG_CFLAGS -Wall"
  56. # With C, this expands to:
  57. # CFLAGS="$CFLAGS -Wall"
  58. # With C++, it expands to:
  59. # CXXFLAGS="$CXXFLAGS -Wall"
  60. #------------------------------------------------------------------------------
  61. AC_DEFUN([CS_LANG_CFLAGS], [AC_LANG_CASE([C], [CFLAGS], [C++], [CXXFLAGS])])
  62. #------------------------------------------------------------------------------
  63. # CS_BUILD_IFELSE([PROGRAM], [FLAGS], [LANGUAGE], [ACTION-IF-BUILT],
  64. # [ACTION-IF-NOT-BUILT], [OTHER-CFLAGS], [OTHER-LFLAGS],
  65. # [OTHER-LIBS], [INHIBIT-OTHER-FLAGS], [ERROR-REGEX])
  66. # Try building a program using the supplied compiler flags, linker flags,
  67. # and library references. PROGRAM is typically a program composed via
  68. # AC_LANG_PROGRAM(). PROGRAM may be omitted if you are interested only
  69. # in learning if the compiler or linker respects certain flags. LANGUAGE
  70. # is typically either C or C++ and specifies which compiler to use for
  71. # the test. If LANGUAGE is omitted, C is used. FLAGS is a whitespace
  72. # delimited list of build tuples. Tuples are created with
  73. # CS_CREATE_TUPLE() and are composed of up to three elements each. The
  74. # first element represents compiler flags, the second linker flags, and
  75. # the third libraries used when linking the program. Each tuple from
  76. # FLAGS is attempted in order. If you want a build attempted with no
  77. # special flags prior to builds with specialized flags, create an empty
  78. # tuple with CS_CREATE_TUPLE() at the start of the FLAGS list. If the
  79. # build is successful, then the shell variables cs_build_ok is set to
  80. # "yes", cs_build_cflags, cs_build_lflags, and cs_build_libs are set to
  81. # the tuple elements which resulted in the successful build, and
  82. # ACTION-IF-BUILT is invoked. Upon successful build, no further tuples
  83. # are consulted. If no tuple results in a successful build, then
  84. # cs_build_ok is set to "no" and ACTION-IF-NOT-BUILT is invoked.
  85. # OTHER-CFLAGS, OTHER-LFLAGS, and OTHER-LIBS specify additional compiler
  86. # flags, linker flags, and libraries which should be used with each tuple
  87. # build attempt. Upon successful build, these additional flags are also
  88. # reflected in the variables cs_build_cflags, cs_build_lflags, and
  89. # cs_build_libs unless INHIBIT-OTHER-FLAGS is a non-empty string. The
  90. # optional ERROR-REGEX places an additional constraint upon the build
  91. # check. If specified, ERROR-REGEX, which is a standard `grep' regular
  92. # expression, is applied to output captured from the compiler and linker.
  93. # If ERROR-REGEX matches, then the build is deemed a failure, and
  94. # cs_build_ok is set to "no". This facility is useful for broken build
  95. # tools which emit an error message yet still return success as a result.
  96. # In such cases, it should be possible to detect the failure by scanning
  97. # the tools' output.
  98. #
  99. # IMPLEMENTATION NOTES
  100. #
  101. # In Autoconf 2.57 and earlier, AC_LINK_IFELSE() invokes AC_TRY_EVAL(),
  102. # which does not provide access to the captured output. To work around
  103. # this limitation, we temporarily re-define AC_TRY_EVAL() as
  104. # _AC_EVAL_STDERR(), which leaves the captured output in conftest.err
  105. # (which we must also delete). In Autoconf 2.58, however,
  106. # AC_LINK_IFELSE() instead already invokes _AC_EVAL_STDERR() on our
  107. # behalf, however we must be careful to apply ERROR-REGEX within the
  108. # invocation AC_LINK_IFELSE(), since AC_LINK_IFELSE() deletes
  109. # conftest.err before it returns.
  110. #------------------------------------------------------------------------------
  111. AC_DEFUN([CS_BUILD_IFELSE],
  112. [AC_LANG_PUSH(m4_default([$3],[C]))
  113. cs_cflags_save="$CS_LANG_CFLAGS"
  114. cs_lflags_save="$LDFLAGS"
  115. cs_libs_save="$LIBS"
  116. cs_build_ok=no
  117. m4_ifval([$10], [m4_pushdef([AC_TRY_EVAL], [_AC_EVAL_STDERR]($$[1]))])
  118. for cs_build_item in m4_default([$2],[CS_CREATE_TUPLE()])
  119. do
  120. CS_SPLIT_TUPLE(
  121. [$cs_build_item],[cs_cflags_test,cs_lflags_test,cs_libs_test])
  122. CS_LANG_CFLAGS="$cs_cflags_test $6 $cs_cflags_save"
  123. LDFLAGS="$cs_lflags_test $7 $cs_lflags_save"
  124. LIBS="$cs_libs_test $8 $cs_libs_save"
  125. AC_LINK_IFELSE(m4_default([$1], [AC_LANG_PROGRAM([],[])]),
  126. [m4_ifval([$10],
  127. [AS_IF([AC_TRY_COMMAND(
  128. [grep "AS_ESCAPE([$10])" conftest.err >/dev/null 2>&1])],
  129. [cs_build_ok=no], [cs_build_ok=yes])],
  130. [cs_build_ok=yes])])
  131. AS_IF([test $cs_build_ok = yes], [break])
  132. done
  133. m4_ifval([$10], [m4_popdef([AC_TRY_EVAL]) rm -f conftest.err])
  134. CS_LANG_CFLAGS=$cs_cflags_save
  135. LDFLAGS=$cs_lflags_save
  136. LIBS=$cs_libs_save
  137. AC_LANG_POP(m4_default([$3],[C]))
  138. AS_IF([test $cs_build_ok = yes],
  139. [cs_build_cflags=CS_TRIM([$cs_cflags_test[]m4_ifval([$9],[],[ $6])])
  140. cs_build_lflags=CS_TRIM([$cs_lflags_test[]m4_ifval([$9],[],[ $7])])
  141. cs_build_libs=CS_TRIM([$cs_libs_test[]m4_ifval([$9],[],[ $8])])
  142. $4],
  143. [$5])])
  144. #------------------------------------------------------------------------------
  145. # CS_CHECK_BUILD(MESSAGE, CACHE-VAR, [PROGRAM], [FLAGS], [LANGUAGE],
  146. # [ACTION-IF-BUILT], [ACTION-IF-NOT-BUILT], [IGNORE-CACHE],
  147. # [OTHER-CFLAGS], [OTHER-LFLAGS], [OTHER-LIBS],
  148. # [INHIBIT-OTHER-FLAGS], [ERROR-REGEX])
  149. # Like CS_BUILD_IFELSE() but also prints "checking" and result messages,
  150. # and optionally respects the cache. Sets CACHE-VAR to "yes" upon
  151. # success, else "no" upon failure. Additionally, sets CACHE-VAR_cflags,
  152. # CACHE-VAR_lflags, and CACHE-VAR_libs to the values which resulted in a
  153. # successful build. If IGNORE-CACHE is "yes", then the cache variables
  154. # are ignored upon entry to this macro, however they are still set to
  155. # appropriate values upon exit.
  156. #------------------------------------------------------------------------------
  157. AC_DEFUN([CS_CHECK_BUILD],
  158. [AS_IF([test "$8" != yes],
  159. [AC_CACHE_CHECK([$1], [$2],
  160. [CS_BUILD_IFELSE([$3], [$4], [$5],
  161. [$2=yes
  162. $2_cflags=$cs_build_cflags
  163. $2_lflags=$cs_build_lflags
  164. $2_libs=$cs_build_libs],
  165. [$2=no], [$9], [$10], [$11], [$12], [$13])])],
  166. [AC_MSG_CHECKING([$1])
  167. CS_BUILD_IFELSE([$3], [$4], [$5],
  168. [$2=yes
  169. $2_cflags=$cs_build_cflags
  170. $2_lflags=$cs_build_lflags
  171. $2_libs=$cs_build_libs],
  172. [$2=no], [$9], [$10], [$11], [$12], [$13])
  173. AC_MSG_RESULT([$$2])])
  174. AS_IF([test $$2 = yes], [$6],
  175. [$2_cflags=''
  176. $2_lflags=''
  177. $2_libs=''
  178. $7])])
  179. #------------------------------------------------------------------------------
  180. # CS_CHECK_BUILD_FLAGS(MESSAGE, CACHE-VAR, FLAGS, [LANGUAGE],
  181. # [ACTION-IF-RECOGNIZED], [ACTION-IF-NOT-RECOGNIZED],
  182. # [OTHER-CFLAGS], [OTHER-LFLAGS], [OTHER-LIBS],
  183. # [ERROR-REGEX])
  184. # Like CS_CHECK_BUILD(), but checks only if the compiler or linker
  185. # recognizes a command-line option or options. MESSAGE is the "checking"
  186. # message. CACHE-VAR is the shell cache variable which receives the flag
  187. # or flags recognized by the compiler or linker. FLAGS is a
  188. # whitespace-delimited list of build tuples created with
  189. # CS_CREATE_TUPLE(). Each tuple from FLAGS is attempted in order until
  190. # one is found which is recognized by the compiler. After that, no
  191. # further flags are checked. LANGUAGE is typically either C or C++ and
  192. # specifies which compiler to use for the test. If LANGUAGE is omitted,
  193. # C is used. If a command-line option is recognized, then CACHE-VAR is
  194. # set to the composite value of $cs_build_cflags, $cs_build_lflags, and
  195. # $cs_build_libs of the FLAGS element which succeeded (not including the
  196. # "other" flags) and ACTION-IF-RECOGNIZED is invoked. If no options are
  197. # recognized, then CACHE-VAR is set to the empty string, and
  198. # ACTION-IF-NOT-RECOGNIZED is invoked. As a convenience, in case
  199. # comparing CACHE-VAR against the empty string to test for failure is
  200. # undesirable, a second variable named CACHE-VAR_ok is set to the literal
  201. # "no" upon failure, and to the same value as CACHE-VAR upon success.
  202. #------------------------------------------------------------------------------
  203. AC_DEFUN([CS_CHECK_BUILD_FLAGS],
  204. [AC_CACHE_CHECK([$1], [$2_ok],
  205. [CS_BUILD_IFELSE([], [$3], [$4],
  206. [$2=CS_TRIM([$cs_build_cflags $cs_build_lflags $cs_build_libs])
  207. $2_ok="$$2"],
  208. [$2=''
  209. $2_ok=no], [$7], [$8], [$9], [Y], [$10])])
  210. AS_IF([test "$$2_ok" != no], [$5], [$6])])
  211. #==============================================================================
  212. # Copyright (C)2003-2006 by Eric Sunshine <[email protected]>
  213. #
  214. # This library is free software; you can redistribute it and/or modify it
  215. # under the terms of the GNU Library General Public License as published by
  216. # the Free Software Foundation; either version 2 of the License, or (at your
  217. # option) any later version.
  218. #
  219. # This library is distributed in the hope that it will be useful, but
  220. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  221. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
  222. # License for more details.
  223. #
  224. # You should have received a copy of the GNU Library General Public License
  225. # along with this library; if not, write to the Free Software Foundation,
  226. # Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  227. #
  228. #==============================================================================
  229. AC_PREREQ([2.56])
  230. #------------------------------------------------------------------------------
  231. # CS_CHECK_COMMON_TOOLS_LINK
  232. # Checks for common tools related to linking.
  233. #------------------------------------------------------------------------------
  234. AC_DEFUN([CS_CHECK_COMMON_TOOLS_LINK],
  235. [
  236. # The default RANLIB in Jambase is wrong on some platforms, and is also
  237. # unsuitable during cross-compilation, so we set the value unconditionally
  238. # (sixth argument of CS_EMIT_BUILD_PROPERTY).
  239. AC_PROG_RANLIB
  240. CS_EMIT_BUILD_PROPERTY([RANLIB], [$RANLIB], [], [], [], [Y])
  241. CS_CHECK_TOOLS([DLLTOOL], [dlltool])
  242. CS_EMIT_BUILD_PROPERTY([CMD.DLLTOOL], [$DLLTOOL])
  243. CS_CHECK_TOOLS([DLLWRAP], [dllwrap])
  244. CS_EMIT_BUILD_PROPERTY([CMD.DLLWRAP], [$DLLWRAP])
  245. CS_CHECK_TOOLS([WINDRES], [windres])
  246. CS_EMIT_BUILD_PROPERTY([CMD.WINDRES], [$WINDRES])
  247. CS_CHECK_TOOLS([STRINGS], [strings])
  248. CS_EMIT_BUILD_PROPERTY([CMD.STRINGS], [$STRINGS])
  249. CS_CHECK_TOOLS([OBJCOPY], [objcopy])
  250. CS_EMIT_BUILD_PROPERTY([CMD.OBJCOPY], [$OBJCOPY])
  251. CS_CHECK_LIBTOOL
  252. CS_EMIT_BUILD_PROPERTY([LIBTOOL], [$LIBTOOL])
  253. CS_EMIT_BUILD_PROPERTY([APPLE_LIBTOOL], [$APPLE_LIBTOOL])
  254. ])
  255. #------------------------------------------------------------------------------
  256. # CS_CHECK_COMMON_TOOLS_BASIC
  257. # Checks for basic tools for building things.
  258. #------------------------------------------------------------------------------
  259. AC_DEFUN([CS_CHECK_COMMON_TOOLS_BASIC],
  260. [CS_CHECK_MKDIR
  261. CS_EMIT_BUILD_PROPERTY([CMD.MKDIR], [$MKDIR])
  262. CS_EMIT_BUILD_PROPERTY([CMD.MKDIRS], [$MKDIRS])
  263. CS_CHECK_PROGS([INSTALL], [install])
  264. CS_EMIT_BUILD_PROPERTY([INSTALL], [$INSTALL])])
  265. #------------------------------------------------------------------------------
  266. # CS_CHECK_COMMON_TOOLS_DOC_TEXINFO
  267. # Checks for tools to generate documentation from texinfo files.
  268. #------------------------------------------------------------------------------
  269. AC_DEFUN([CS_CHECK_COMMON_TOOLS_DOC_TEXINFO],
  270. [CS_CHECK_PROGS([TEXI2DVI], [texi2dvi])
  271. CS_EMIT_BUILD_PROPERTY([CMD.TEXI2DVI], [$TEXI2DVI])
  272. CS_CHECK_PROGS([TEXI2PDF], [texi2pdf])
  273. CS_EMIT_BUILD_PROPERTY([CMD.TEXI2PDF], [$TEXI2PDF])
  274. CS_CHECK_PROGS([DVIPS], [dvips])
  275. CS_EMIT_BUILD_PROPERTY([CMD.DVIPS], [$DVIPS])
  276. CS_CHECK_PROGS([DVIPDF], [dvipdf])
  277. CS_EMIT_BUILD_PROPERTY([CMD.DVIPDF], [$DVIPDF])
  278. CS_CHECK_PROGS([MAKEINFO], [makeinfo])
  279. CS_EMIT_BUILD_PROPERTY([CMD.MAKEINFO], [$MAKEINFO])])
  280. #------------------------------------------------------------------------------
  281. # CS_CHECK_COMMON_TOOLS_DOC_DOXYGEN
  282. # Checks for tools to generate source documentation via doxygen.
  283. #------------------------------------------------------------------------------
  284. AC_DEFUN([CS_CHECK_COMMON_TOOLS_DOC_DOXYGEN],
  285. [CS_CHECK_PROGS([DOXYGEN], [doxygen])
  286. CS_EMIT_BUILD_PROPERTY([CMD.DOXYGEN], [$DOXYGEN])
  287. CS_CHECK_TOOLS([DOT], [dot])
  288. CS_EMIT_BUILD_PROPERTY([CMD.DOT], [$DOT])])
  289. #------------------------------------------------------------------------------
  290. # CS_CHECK_COMMON_LIBS
  291. # Check for typical required libraries (libm, libmx, libdl, libnsl).
  292. #------------------------------------------------------------------------------
  293. AC_DEFUN([CS_CHECK_COMMON_LIBS],
  294. [AC_LANG_PUSH([C])
  295. AC_CHECK_LIB([m], [pow], [cs_cv_libm_libs=-lm], [cs_cv_libm_libs=])
  296. AC_CHECK_LIB([m], [cosf], [cs_cv_libm_libs=-lm])
  297. AC_CHECK_LIB([mx], [cosf])
  298. AC_CHECK_LIB([dl], [dlopen], [cs_cv_libdl_libs=-ldl], [cs_cv_libdl_libs=])
  299. AC_CHECK_LIB([nsl], [gethostbyname])
  300. AC_LANG_POP([C])])
  301. # checkcppunit.m4 -*- Autoconf -*-
  302. #==============================================================================
  303. # Copyright (C)2005 by Eric Sunshine <[email protected]>
  304. #
  305. # This library is free software; you can redistribute it and/or modify it
  306. # under the terms of the GNU Library General Public License as published by
  307. # the Free Software Foundation; either version 2 of the License, or (at your
  308. # option) any later version.
  309. #
  310. # This library is distributed in the hope that it will be useful, but
  311. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  312. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
  313. # License for more details.
  314. #
  315. # You should have received a copy of the GNU Library General Public License
  316. # along with this library; if not, write to the Free Software Foundation,
  317. # Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  318. #
  319. #==============================================================================
  320. AC_PREREQ([2.56])
  321. #------------------------------------------------------------------------------
  322. # CS_CHECK_CPPUNIT([EMITTER])
  323. # Check if CppUnit (http://cppunit.sourceforge.net/), the unit-testing
  324. # framework is available. The shell variable cs_cv_libcppunit is set to
  325. # "yes" if CppUnit is discovered, else "no". If available, then the
  326. # variables cs_cv_libcppunit_cflags, cs_cv_libcppunit_lflags, and
  327. # cs_cv_libcppunit_libs are set. If EMITTER is provided, then
  328. # CS_EMIT_BUILD_RESULT() is invoked with EMITTER in order to record the
  329. # results in an output file. As a convenience, if EMITTER is the literal
  330. # value "emit" or "yes", then CS_EMIT_BUILD_RESULT()'s default emitter
  331. # will be used.
  332. #------------------------------------------------------------------------------
  333. AC_DEFUN([CS_CHECK_CPPUNIT],
  334. [CS_CHECK_LIB_WITH([cppunit],
  335. [AC_LANG_PROGRAM([[#include <cppunit/ui/text/TestRunner.h>]],
  336. [CppUnit::TextUi::TestRunner r; r.run();])],
  337. [], [C++])
  338. AS_IF([test $cs_cv_libcppunit = yes],
  339. [CS_CHECK_BUILD([if cppunit is sufficiently recent],
  340. [cs_cv_libcppunit_recent],
  341. [AC_LANG_PROGRAM(
  342. [[#include <cppunit/BriefTestProgressListener.h>]],
  343. [CppUnit::BriefTestProgressListener b; b.startTest(0);])],
  344. [], [C++],
  345. [CS_EMIT_BUILD_RESULT([cs_cv_libcppunit], [CPPUNIT],
  346. CS_EMITTER_OPTIONAL([$1]))], [], [],
  347. [$cs_cv_libcppunit_cflags],
  348. [$cs_cv_libcppunit_lflags],
  349. [$cs_cv_libcppunit_libs])])])
  350. # checklib.m4 -*- Autoconf -*-
  351. #==============================================================================
  352. # Copyright (C)2003-2005 by Eric Sunshine <[email protected]>
  353. #
  354. # This library is free software; you can redistribute it and/or modify it
  355. # under the terms of the GNU Library General Public License as published by
  356. # the Free Software Foundation; either version 2 of the License, or (at your
  357. # option) any later version.
  358. #
  359. # This library is distributed in the hope that it will be useful, but
  360. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  361. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
  362. # License for more details.
  363. #
  364. # You should have received a copy of the GNU Library General Public License
  365. # along with this library; if not, write to the Free Software Foundation,
  366. # Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  367. #
  368. #==============================================================================
  369. AC_PREREQ([2.56])
  370. #------------------------------------------------------------------------------
  371. # cs_lib_paths_default
  372. # Whitespace delimited list of directory tuples in which to search, by
  373. # default, for external libraries. Each list item can specify an
  374. # include|library directory tuple (for example, "/usr/include|/usr/lib"),
  375. # or a single directory (for example, "/usr"). If the second form is
  376. # used, then "include" and "lib" subdirectories of the directory are
  377. # searched. If the library resources are not found, then the directory
  378. # itself is searched. Thus, "/proj" is shorthand for
  379. # "/proj/include|/proj/lib /proj|/proj".
  380. #
  381. # Present Cases:
  382. # /usr/local -- Not all compilers search here by default, so we specify
  383. # it manually.
  384. # /sw -- Fink, the MacOS/X manager of Unix packages, installs here by
  385. # default.
  386. # /opt/local -- DarwinPorts installs here by default.
  387. #------------------------------------------------------------------------------
  388. m4_define([cs_lib_paths_default],
  389. [/usr/local/include|/usr/local/lib \
  390. /sw/include|/sw/lib \
  391. /opt/local/include|/opt/local/lib \
  392. /opt/include|/opt/lib])
  393. #------------------------------------------------------------------------------
  394. # cs_pkg_paths_default
  395. # Comma delimited list of additional directories in which the
  396. # `pkg-config' command should search for its `.pc' files.
  397. #
  398. # Present Cases:
  399. # /usr/local/lib/pkgconfig -- Although a common location for .pc files
  400. # installed by "make install", many `pkg-config' commands neglect
  401. # to search here automatically.
  402. # /sw/lib/pkgconfig -- Fink, the MacOS/X manager of Unix packages,
  403. # installs .pc files here by default.
  404. # /opt/local/lib/pkgconfig -- DarwinPorts installs .pc files here by
  405. # default.
  406. #------------------------------------------------------------------------------
  407. m4_define([cs_pkg_paths_default],
  408. [/usr/local/lib/pkgconfig,
  409. /sw/lib/pkgconfig,
  410. /opt/local/lib/pkgconfig,
  411. /opt/lib/pkgconfig])
  412. #------------------------------------------------------------------------------
  413. # CS_CHECK_LIB_WITH(LIBRARY, PROGRAM, [SEARCH-LIST], [LANGUAGE],
  414. # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], [OTHER-CFLAGS],
  415. # [OTHER-LFLAGS], [OTHER-LIBS], [ALIASES])
  416. # Very roughly similar in concept to AC_CHECK_LIB(), but allows caller to
  417. # to provide list of directories in which to search for LIBRARY; allows
  418. # user to override library location via --with-LIBRARY=dir; and consults
  419. # `pkg-config' (if present) and `LIBRARY-config' (if present, i.e.
  420. # `sdl-config') in order to obtain compiler and linker flags. LIBRARY is
  421. # the name of the library or MacOS/X framework which is to be located
  422. # (for example, "readline" for `libreadline.a' or `readline.framework').
  423. # PROGRAM, which is typically composed with AC_LANG_PROGRAM(), is a
  424. # program which references at least one function or symbol in LIBRARY.
  425. # SEARCH-LIST is a whitespace-delimited list of paths in which to search
  426. # for the library and its header files, in addition to those searched by
  427. # the compiler and linker by default, and those referenced by the
  428. # cs_lib_paths_default macro. Each list item can specify an
  429. # `include|library' directory tuple (for example,
  430. # "/usr/include|/usr/lib"), or a single directory (for example, "/usr").
  431. # If the second form is used, then "include" and "lib" subdirectories of
  432. # the directory are searched. If the library resources are not found,
  433. # then the directory itself is searched. Thus, "/proj" is shorthand for
  434. # "/proj/include|/proj/lib /proj|/proj". Items in the search list can
  435. # include wildcards. SEARCH-LIST can be overridden by the user with the
  436. # --with-LIBRARY=dir option, in which case only "dir/include|dir/lib" and
  437. # "dir|dir" are searched. If SEARCH-LIST is omitted and the user did not
  438. # override the search list via --with-LIBRARY=dir, then only the
  439. # directories normally searched by the compiler and the directories
  440. # mentioned via cs_lib_paths_default are searched. LANGUAGE is typically
  441. # either C or C++ and specifies which compiler to use for the test. If
  442. # LANGUAGE is omitted, C is used. OTHER-CFLAGS, OTHER-LFLAGS, and
  443. # OTHER-LIBS can specify additional compiler flags, linker flags, and
  444. # libraries needed to successfully link with LIBRARY. The optional
  445. # ALIASES is a comma-delimited list of library names for which to search
  446. # in case LIBRARY is not located (for example "[sdl1.2, sdl12]" for
  447. # libsdl1.2.a, sdl1.2.framework, libsdl12.a, and sdl12.framework). If
  448. # the library or one of its aliases is found and can be successfully
  449. # linked into a program, then the shell cache variable cs_cv_libLIBRARY
  450. # is set to "yes"; cs_cv_libLIBRARY_cflags, cs_cv_libLIBRARY_lflags, and
  451. # cs_cv_libLIBRARY_libs are set, respectively, to the compiler flags
  452. # (including OTHER-CFLAGS), linker flags (including OTHER-LFLAGS), and
  453. # library references (including OTHER-LIBS) which resulted in a
  454. # successful build; and ACTION-IF-FOUND is invoked. If the library was
  455. # not found or was unlinkable, or if the user disabled the library via
  456. # --without-LIBRARY, then cs_cv_libLIBRARY is set to "no" and
  457. # ACTION-IF-NOT-FOUND is invoked. Note that the exported shell variable
  458. # names are always composed from LIBRARY regardless of whether the test
  459. # succeeded because the primary library was discovered or one of the
  460. # aliases.
  461. #------------------------------------------------------------------------------
  462. AC_DEFUN([CS_CHECK_LIB_WITH],
  463. [AC_ARG_WITH([$1], [AC_HELP_STRING([--with-$1=dir],
  464. [specify location of lib$1 if not detected automatically; searches
  465. dir/include, dir/lib, and dir])])
  466. # Backward compatibility: Recognize --with-lib$1 as alias for --with-$1.
  467. AS_IF([test -n "$with_lib$1" && test -z "$with_$1"],
  468. [with_$1="$with_lib$1"])
  469. AS_IF([test -z "$with_$1"], [with_$1=yes])
  470. AS_IF([test "$with_$1" != no],
  471. [# If --with-$1 value is same as cached value, then assume other
  472. # cached values are also valid; otherwise, ignore all cached values.
  473. AS_IF([test "$with_$1" != "$cs_cv_with_$1"],
  474. [cs_ignore_cache=yes], [cs_ignore_cache=no])
  475. cs_check_lib_flags=''
  476. AS_IF([test $with_$1 = yes],
  477. [m4_foreach([cs_check_lib_alias], [$1, $10],
  478. [_CS_CHECK_LIB_PKG_CONFIG_FLAGS([cs_check_lib_flags],
  479. cs_check_lib_alias)
  480. _CS_CHECK_LIB_CONFIG_FLAGS([cs_check_lib_flags],
  481. cs_check_lib_alias)
  482. ])])
  483. AS_IF([test $with_$1 != yes],
  484. [cs_check_lib_paths=$with_$1],
  485. [cs_check_lib_paths="| cs_lib_paths_default $3"])
  486. m4_foreach([cs_check_lib_alias], [$1, $10],
  487. [_CS_CHECK_LIB_CREATE_FLAGS([cs_check_lib_flags],
  488. cs_check_lib_alias, [$cs_check_lib_paths])
  489. ])
  490. CS_CHECK_BUILD([for lib$1], [cs_cv_lib$1], [$2], [$cs_check_lib_flags],
  491. [$4], [], [], [$cs_ignore_cache], [$7], [$8], [$9])],
  492. [cs_cv_lib$1=no])
  493. cs_cv_with_$1="$with_$1"
  494. AS_IF([test "$cs_cv_lib$1" = yes], [$5], [$6])])
  495. #------------------------------------------------------------------------------
  496. # CS_CHECK_PKG_CONFIG
  497. # Check if the `pkg-config' command is available and reasonably recent.
  498. # This program acts as a central repository of build flags for various
  499. # packages. For example, to determine the compiler flags for FreeType2
  500. # use, "pkg-config --cflags freetype2"; and "pkg-config --libs freetype2"
  501. # to determine the linker flags. If `pkg-config' is found and is
  502. # sufficiently recent, PKG_CONFIG is set and AC_SUBST() invoked.
  503. #------------------------------------------------------------------------------
  504. m4_define([CS_PKG_CONFIG_MIN], [0.9.0])
  505. AC_DEFUN([CS_CHECK_PKG_CONFIG],
  506. [AS_IF([test "$cs_prog_pkg_config_checked" != yes],
  507. [CS_CHECK_TOOLS([PKG_CONFIG], [pkg-config])
  508. _CS_CHECK_PKG_CONFIG_PREPARE_PATH
  509. cs_prog_pkg_config_checked=yes])
  510. AS_IF([test -z "$cs_cv_prog_pkg_config_ok"],
  511. [AS_IF([test -n "$PKG_CONFIG"],
  512. [AS_IF([$PKG_CONFIG --atleast-pkgconfig-version=CS_PKG_CONFIG_MIN],
  513. [cs_cv_prog_pkg_config_ok=yes],
  514. [cs_cv_prog_pkg_config_ok=no])],
  515. [cs_cv_prog_pkg_config_ok=no])])])
  516. AC_DEFUN([_CS_CHECK_PKG_CONFIG_PREPARE_PATH],
  517. [PKG_CONFIG_PATH="m4_foreach([cs_pkg_path], [cs_pkg_paths_default],
  518. [cs_pkg_path$PATH_SEPARATOR])$PKG_CONFIG_PATH"
  519. export PKG_CONFIG_PATH])
  520. #------------------------------------------------------------------------------
  521. # _CS_CHECK_LIB_PKG_CONFIG_FLAGS(VARIABLE, LIBRARY)
  522. # Helper macro for CS_CHECK_LIB_WITH(). Checks if `pkg-config' knows
  523. # about LIBRARY and, if so, appends a build tuple consisting of the
  524. # compiler and linker flags reported by `pkg-config' to the list of
  525. # tuples stored in the shell variable VARIABLE.
  526. #------------------------------------------------------------------------------
  527. AC_DEFUN([_CS_CHECK_LIB_PKG_CONFIG_FLAGS],
  528. [CS_CHECK_PKG_CONFIG
  529. AS_IF([test $cs_cv_prog_pkg_config_ok = yes],
  530. [AC_CACHE_CHECK([if $PKG_CONFIG recognizes $2], [_CS_CLPCF_CVAR([$2])],
  531. [AS_IF([$PKG_CONFIG --exists $2],
  532. [_CS_CLPCF_CVAR([$2])=yes], [_CS_CLPCF_CVAR([$2])=no])])
  533. AS_IF([test $_CS_CLPCF_CVAR([$2]) = yes],
  534. [_CS_CHECK_LIB_CONFIG_PROG_FLAGS([$1], [pkg_config_$2],
  535. [$PKG_CONFIG], [$2])])])])
  536. AC_DEFUN([_CS_CLPCF_CVAR], [AS_TR_SH([cs_cv_prog_pkg_config_$1])])
  537. #------------------------------------------------------------------------------
  538. # _CS_CHECK_LIB_CONFIG_FLAGS(VARIABLE, LIBRARY)
  539. # Helper macro for CS_CHECK_LIB_WITH(). Checks if `LIBRARY-config'
  540. # (i.e. `sdl-config') exists and, if so, appends a build tuple consisting
  541. # of the compiler and linker flags reported by `LIBRARY-config' to the
  542. # list of tuples stored in the shell variable VARIABLE.
  543. #------------------------------------------------------------------------------
  544. AC_DEFUN([_CS_CHECK_LIB_CONFIG_FLAGS],
  545. [CS_CHECK_TOOLS(_CS_CLCF_SHVAR([$2]), [$2-config])
  546. AS_IF([test -n "$_CS_CLCF_SHVAR([$2])"],
  547. [AS_IF([test -z "$_CS_CLCF_CVAR([$2])"],
  548. [AS_IF([$_CS_CLCF_SHVAR([$2]) --cflags --libs >/dev/null 2>&1],
  549. [_CS_CLCF_CVAR([$2])=yes], [_CS_CLCF_CVAR([$2])=no])])
  550. AS_IF([test $_CS_CLCF_CVAR([$2]) = yes],
  551. [_CS_CHECK_LIB_CONFIG_PROG_FLAGS([$1], [config_$2],
  552. [$_CS_CLCF_SHVAR([$2])])])])])
  553. AC_DEFUN([_CS_CLCF_CVAR], [AS_TR_SH([cs_cv_prog_config_$1_ok])])
  554. AC_DEFUN([_CS_CLCF_SHVAR], [m4_toupper(AS_TR_SH([CONFIG_$1]))])
  555. #------------------------------------------------------------------------------
  556. # _CS_CHECK_LIB_CONFIG_PROG_FLAGS(VARIABLE, TAG, CONFIG-PROGRAM, [ARGS])
  557. # Helper macro for _CS_CHECK_LIB_PKG_CONFIG_FLAGS() and
  558. # _CS_CHECK_LIB_CONFIG_FLAGS(). CONFIG-PROGRAM is a command which
  559. # responds to the --cflags and --libs options and returns suitable
  560. # compiler and linker flags for some package. ARGS, if supplied, is
  561. # passed to CONFIG-PROGRAM after the --cflags or --libs argument. The
  562. # results of the --cflags and --libs options are packed into a build
  563. # tuple and appended to the list of tuples stored in the shell variable
  564. # VARIABLE. TAG is used to compose the name of the cache variable. A good
  565. # choice for TAG is some unique combination of the library name and
  566. # configuration program.
  567. #------------------------------------------------------------------------------
  568. AC_DEFUN([_CS_CHECK_LIB_CONFIG_PROG_FLAGS],
  569. [AS_IF([test -z "$_CS_CLCPF_CVAR([$2])"],
  570. [cs_check_lib_cflag=CS_RUN_PATH_NORMALIZE([$3 --cflags $4])
  571. cs_check_lib_lflag=''
  572. cs_check_lib_libs=CS_RUN_PATH_NORMALIZE([$3 --libs $4])
  573. _CS_CLCPF_CVAR([$2])=CS_CREATE_TUPLE(
  574. [$cs_check_lib_cflag],
  575. [$cs_check_lib_lflag],
  576. [$cs_check_lib_libs])])
  577. $1="$$1 $_CS_CLCPF_CVAR([$2])"])
  578. AC_DEFUN([_CS_CLCPF_CVAR], [AS_TR_SH([cs_cv_prog_$1_flags])])
  579. #------------------------------------------------------------------------------
  580. # _CS_CHECK_LIB_CREATE_FLAGS(VARIABLE, LIBRARY, PATHS)
  581. # Helper macro for CS_CHECK_LIB_WITH(). Constructs a list of build
  582. # tuples suitable for CS_CHECK_BUILD() and appends the tuple list to the
  583. # shell variable VARIABLE. LIBRARY and PATHS have the same meanings as
  584. # the like-named arguments of CS_CHECK_LIB_WITH().
  585. #------------------------------------------------------------------------------
  586. AC_DEFUN([_CS_CHECK_LIB_CREATE_FLAGS],
  587. [for cs_lib_item in $3
  588. do
  589. case $cs_lib_item in
  590. *\|*) CS_SPLIT(
  591. [$cs_lib_item], [cs_check_incdir,cs_check_libdir], [|])
  592. _CS_CHECK_LIB_CREATE_FLAG([$1],
  593. [$cs_check_incdir], [$cs_check_libdir], [$2])
  594. ;;
  595. *) _CS_CHECK_LIB_CREATE_FLAG([$1],
  596. [$cs_lib_item/include], [$cs_lib_item/lib], [$2])
  597. _CS_CHECK_LIB_CREATE_FLAG(
  598. [$1], [$cs_lib_item], [$cs_lib_item], [$2])
  599. ;;
  600. esac
  601. done])
  602. #------------------------------------------------------------------------------
  603. # _CS_CHECK_LIB_CREATE_FLAG(VARIABLE, HEADER-DIR, LIBRARY-DIR, LIBRARY)
  604. # Helper macro for _CS_CHECK_LIB_CREATE_FLAGS(). Constructs build tuples
  605. # suitable for CS_CHECK_BUILD() for given header and library directories,
  606. # and appends the tuples to the shell variable VARIABLE. Synthesizes
  607. # tuples which check for LIBRARY as a MacOS/X framework, and a standard
  608. # link library.
  609. #------------------------------------------------------------------------------
  610. AC_DEFUN([_CS_CHECK_LIB_CREATE_FLAG],
  611. [AS_IF([test -n "$2"], [cs_check_lib_cflag="-I$2"], [cs_check_lib_cflag=''])
  612. AS_IF([test -n "$3"], [cs_check_lib_lflag="-L$3"], [cs_check_lib_lflag=''])
  613. AS_IF([test -n "$4"],
  614. [cs_check_lib_libs="-l$4"
  615. cs_check_lib_framework="-framework $4"],
  616. [cs_check_lib_libs=''
  617. cs_check_lib_framework=''])
  618. $1="$$1
  619. CS_CREATE_TUPLE(
  620. [$cs_check_lib_cflag],
  621. [$cs_check_lib_lflag],
  622. [$cs_check_lib_framework])
  623. CS_CREATE_TUPLE(
  624. [$cs_check_lib_cflag],
  625. [$cs_check_lib_lflag],
  626. [$cs_check_lib_libs])"])
  627. # checklibtool.m4 -*- Autoconf -*-
  628. #==============================================================================
  629. # Copyright (C)2004 by Eric Sunshine <[email protected]>
  630. #
  631. # This library is free software; you can redistribute it and/or modify it
  632. # under the terms of the GNU Library General Public License as published by
  633. # the Free Software Foundation; either version 2 of the License, or (at your
  634. # option) any later version.
  635. #
  636. # This library is distributed in the hope that it will be useful, but
  637. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  638. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
  639. # License for more details.
  640. #
  641. # You should have received a copy of the GNU Library General Public License
  642. # along with this library; if not, write to the Free Software Foundation,
  643. # Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  644. #
  645. #==============================================================================
  646. AC_PREREQ([2.56])
  647. #------------------------------------------------------------------------------
  648. # CS_CHECK_LIBTOOL
  649. # Find and identify the various implementations of libtool. In
  650. # particular, this macro is aware of GNU libtool and Apple's libtool
  651. # (which serves a completely different purpose). On MacOS/X, GNU libtool
  652. # is typically named glibtool, however a user might also use Fink to
  653. # install the unadorned libtool; and the Fink-installed version might
  654. # shadow Apple's own libtool if it appears in the PATH before the Apple
  655. # tool. This macro jumps through the necessary hoops to distinguish and
  656. # locate the various implementations. Sets the shell variable LIBTOOL to
  657. # the located GNU libtool (if any), and APPLE_LIBTOOL to the located
  658. # Apple libtool. Invokes AC_SUBST() for LIBTOOL and APPLE_LIBTOOL.
  659. #------------------------------------------------------------------------------
  660. AC_DEFUN([CS_CHECK_LIBTOOL],
  661. [# GNU: Search for libtool before glibtool since Fink version is likely newer.
  662. m4_define([cs_lt_path_gnu],
  663. [/sw/bin$PATH_SEPARATOR/usr/local/bin$PATH_SEPARATOR$PATH])
  664. AS_IF([test -z "$LIBTOOL"],
  665. [CS_CHECK_TOOLS([LIBTOOL_TEST], [libtool glibtool gnulibtool], [],
  666. [cs_lt_path_gnu])
  667. AS_IF([test -n "$LIBTOOL_TEST"],
  668. [CS_PATH_PROG([LIBTOOL_PATH], [$LIBTOOL_TEST], [], [cs_lt_path_gnu])
  669. CS_LIBTOOL_CLASSIFY([$LIBTOOL_PATH],
  670. [LIBTOOL="$LIBTOOL_PATH"],
  671. [AS_IF([test -z "$APPLE_LIBTOOL"], [APPLE_LIBTOOL="$LIBTOOL_PATH"])
  672. CS_CHECK_TOOLS([LIBTOOL], [glibtool gnulibtool])])])])
  673. AC_SUBST([LIBTOOL])
  674. # Apple: Ensure that Apple libtool will be found before GNU libtool from Fink.
  675. m4_define([cs_lt_path_apple],[/bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH])
  676. AS_IF([test -z "$APPLE_LIBTOOL"],
  677. [CS_PATH_PROG([CS_LT_APPLE], [libtool], [], [cs_lt_path_apple])
  678. CS_LIBTOOL_CLASSIFY([$CS_LT_APPLE], [],
  679. [APPLE_LIBTOOL="$CS_LT_APPLE"])])
  680. AC_SUBST([APPLE_LIBTOOL])])
  681. AC_DEFUN([CS_LIBTOOL_CLASSIFY],
  682. [AS_IF([test -n "$1"],
  683. [AC_MSG_CHECKING([classification of $1])
  684. CS_LIBTOOL_GNU_IFELSE([$1],
  685. [AC_MSG_RESULT([gnu])
  686. $2],
  687. [AC_MSG_RESULT([apple])
  688. $3])])])
  689. AC_DEFUN([CS_LIBTOOL_GNU_IFELSE],
  690. [AS_IF([AC_RUN_LOG([$1 --version 1>&2])], [$2], [$3])])
  691. #==============================================================================
  692. # Copyright (C)2003-2006 by Eric Sunshine <[email protected]>
  693. #
  694. # This library is free software; you can redistribute it and/or modify it
  695. # under the terms of the GNU Library General Public License as published by
  696. # the Free Software Foundation; either version 2 of the License, or (at your
  697. # option) any later version.
  698. #
  699. # This library is distributed in the hope that it will be useful, but
  700. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  701. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
  702. # License for more details.
  703. #
  704. # You should have received a copy of the GNU Library General Public License
  705. # along with this library; if not, write to the Free Software Foundation,
  706. # Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  707. #
  708. #==============================================================================
  709. AC_PREREQ([2.56])
  710. #------------------------------------------------------------------------------
  711. # CS_CHECK_OPENGL
  712. # Check for OpenGL.
  713. #
  714. # IMPLEMENTATION NOTES
  715. #
  716. # Some Mesa installations require pthread, so pthread flags are employed if
  717. # available.
  718. #
  719. # The check for opengl32 needs to precede other checks because Cygwin users
  720. # often have Mesa installed, and Mesa's OpenGL library is compiled without the
  721. # __stdcall flags which results in link errors, whereas Microsoft's native
  722. # opengl32 works fine. Conversely, some Unix implementations have Wine
  723. # installed (Windows emulation layer) which includes an opengl32.so library.
  724. # We need to avoid detection of this library on Unix since it would cause an
  725. # undesirable dependence upon Wine.
  726. #
  727. # Many OpenGL libraries on Unix already contain GLX, so there is no separate
  728. # GLX library, thus we first check for GLX using the discovered OpenGL library
  729. # before attempting to locate a separate GLX-specific library.
  730. #
  731. # On MacOS/X, some users have XFree86 installed which creates a link from
  732. # /usr/include/GL to /usr/X11R6/include/GL. We want to ignore this directory
  733. # and instead check for Apple's OpenGL.framework, if we are not cross-building
  734. # for Darwin. We accomplish this by placing the OpenGL.framework test ahead of
  735. # the other tests.
  736. #
  737. # At least one user (Jorrit) has a strange installation in which inclusion of
  738. # <windows.h> fails if an int32 is not present, thus we must take this into
  739. # account.
  740. #------------------------------------------------------------------------------
  741. m4_define([cs_define_int32],
  742. [[#if !HAVE_TYPE_INT32
  743. typedef long int32;
  744. #endif
  745. ]])
  746. # CS_GL_INCLUDE(CPP-MACRO,FALLBACK,HEADER)
  747. AC_DEFUN([CS_GL_INCLUDE],
  748. [[#if HAVE_WINDOWS_H
  749. #if !HAVE_TYPE_INT32
  750. typedef long int32;
  751. #endif
  752. #include <windows.h>
  753. #endif
  754. #ifndef CS_HEADER_GLOBAL
  755. #define CS_HEADER_GLOBAL(X,Y) CS_HEADER_GLOBAL_COMPOSE(X,Y)
  756. #define CS_HEADER_GLOBAL_COMPOSE(X,Y) <X/Y>
  757. #endif
  758. #ifdef $1
  759. #include CS_HEADER_GLOBAL($1,$3)
  760. #else
  761. #include <$2/$3>
  762. #endif]])
  763. AC_DEFUN([CS_CHECK_OPENGL],
  764. [AC_REQUIRE([CS_CHECK_HOST])
  765. AC_REQUIRE([CS_CHECK_COMMON_LIBS])
  766. AC_REQUIRE([CS_CHECK_PTHREAD])
  767. AC_REQUIRE([AC_PATH_X])
  768. AC_REQUIRE([AC_PATH_XTRA])
  769. AC_CHECK_TYPE([int32], [AC_DEFINE([HAVE_TYPE_INT32], [],
  770. [Whether the int32 type is available])], [])
  771. AC_CHECK_HEADERS([windows.h], [], [], [cs_define_int32])
  772. # Apply plaform-specific flags if necessary.
  773. cs_gl_plat_cflags=''
  774. cs_gl_plat_lflags=''
  775. cs_gl_plat_libs=''
  776. AS_IF([test -n "$cs_cv_libm_cflags$cs_cv_libm_lflags$cs_cv_libm_libs"],
  777. [cs_gl_plat_cflags="$cs_cv_libm_cflags $cs_gl_plat_cflags"
  778. cs_gl_plat_lflags="$cs_cv_libm_lflags $cs_gl_plat_lflags"
  779. cs_gl_plat_libs="$cs_cv_libm_libs $cs_gl_plat_libs"])
  780. AS_IF([test $cs_cv_sys_pthread = yes],
  781. [cs_gl_plat_cflags="$cs_cv_sys_pthread_cflags $cs_gl_plat_cflags"
  782. cs_gl_plat_lflags="$cs_cv_sys_pthread_lflags $cs_gl_plat_lflags"
  783. cs_gl_plat_libs="$cs_cv_sys_pthread_libs $cs_gl_plat_libs"])
  784. AS_IF([test "$no_x" != yes],
  785. [cs_gl_plat_cflags="$X_CFLAGS $cs_gl_plat_cflags"
  786. cs_gl_plat_lflags="$cs_gl_plat_lflags"
  787. cs_gl_plat_libs="
  788. $X_PRE_LIBS $X_LIBS -lX11 -lXext $X_EXTRA_LIBS $cs_gl_plat_libs"])
  789. # Mesa requested?
  790. AC_ARG_WITH([mesa], [AC_HELP_STRING([--with-mesa],
  791. [use Mesa OpenGL library if available (default YES)])],
  792. [], [with_mesa=yes])
  793. AS_IF([test $with_mesa != no],
  794. [cs_mesa_gl=CS_CREATE_TUPLE([],[],[-lMesaGL])])
  795. # MacOS/X or Darwin?
  796. AS_IF([test "x$cs_host_macosx" = "xyes"],
  797. [cs_osx_gl=CS_CREATE_TUPLE([-DCS_OPENGL_PATH=OpenGL],[],[-framework OpenGL])])
  798. AS_IF([test "x$cs_host_macosx" = "xyes"],
  799. [cs_gl_plat_lflags="$cs_plat_lflags -Wl,-dylib_file,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib"])
  800. # Windows?
  801. AS_IF([test $cs_host_family = windows],
  802. [cs_win32_gl=CS_CREATE_TUPLE([],[],[-lopengl32])])
  803. # Check for OpenGL.
  804. CS_CHECK_BUILD([for OpenGL], [cs_cv_libgl],
  805. [AC_LANG_PROGRAM([CS_GL_INCLUDE([CS_OPENGL_PATH],[GL],[gl.h])],[glEnd()])],
  806. [$cs_win32_gl \
  807. $cs_osx_gl \
  808. CS_CREATE_TUPLE([],[],[-lGL]) \
  809. CS_CREATE_TUPLE([],[],[-lgl]) \
  810. $cs_mesa_gl], [],
  811. [CS_EMIT_BUILD_RESULT([cs_cv_libgl], [GL])], [], [],
  812. [$cs_gl_plat_cflags], [$cs_gl_plat_lflags], [$cs_gl_plat_libs])])
  813. #------------------------------------------------------------------------------
  814. # CS_CHECK_GLU
  815. # Check for GLU.
  816. #------------------------------------------------------------------------------
  817. AC_DEFUN([CS_CHECK_GLU],
  818. [AC_REQUIRE([CS_CHECK_OPENGL])
  819. AS_IF([test $cs_cv_libgl = yes],
  820. [AS_IF([test $with_mesa != no],
  821. [cs_mesa_glu=CS_CREATE_TUPLE([],[],[-lMesaGLU])])
  822. # MacOS/X or Darwin?
  823. AS_IF([test "x$cs_host_macosx" = "xyes"],
  824. [cs_osx_glu=CS_CREATE_TUPLE([-DCS_GLU_PATH=OpenGL],[],[-framework OpenGL])])
  825. # Windows?
  826. AS_IF([test $cs_host_family = windows],
  827. [cs_win32_glu=CS_CREATE_TUPLE([],[],[-lglu32])])
  828. # Check for GLU.
  829. CS_CHECK_BUILD([for GLU], [cs_cv_libglu],
  830. [AC_LANG_PROGRAM(
  831. [CS_GL_INCLUDE([CS_GLU_PATH],[GL],[glu.h])], [gluNewQuadric()])],
  832. [$cs_osx_glu \
  833. CS_CREATE_TUPLE() \
  834. $cs_win32_glu \
  835. CS_CREATE_TUPLE([],[],[-lGLU]) \
  836. CS_CREATE_TUPLE([],[],[-lglu]) \
  837. $cs_mesa_glu], [],
  838. [CS_EMIT_BUILD_RESULT([cs_cv_libglu], [GLU])], [], [],
  839. [$cs_cv_libgl_cflags], [$cs_cv_libgl_lflags], [$cs_cv_libgl_libs])])])
  840. #------------------------------------------------------------------------------
  841. # CS_CHECK_GLX
  842. # Check for GLX.
  843. #------------------------------------------------------------------------------
  844. AC_DEFUN([CS_CHECK_GLX],
  845. [AC_REQUIRE([CS_CHECK_OPENGL])
  846. AS_IF([test $cs_cv_libgl = yes],
  847. [AS_IF([test $with_mesa != no],
  848. [cs_mesa_glx=CS_CREATE_TUPLE([],[],[-lMesaGLX])])
  849. # Check for GLX.
  850. AS_IF([test "$no_x" != yes],
  851. [CS_CHECK_BUILD([for GLX], [cs_cv_libglx],
  852. [AC_LANG_PROGRAM([[#include <GL/glx.h>]], [glXWaitGL()])],
  853. [CS_CREATE_TUPLE() \
  854. CS_CREATE_TUPLE([],[],[-lGLX]) \
  855. CS_CREATE_TUPLE([],[],[-lglx]) \
  856. $cs_mesa_glx], [],
  857. [CS_EMIT_BUILD_RESULT([cs_cv_libglx], [GLX])], [], [],
  858. [$cs_cv_libgl_cflags], [$cs_cv_libgl_lflags], [$cs_cv_libgl_libs])])])])
  859. #------------------------------------------------------------------------------
  860. # CS_CHECK_GLXEXT([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
  861. # Check for GLX extensions.
  862. #------------------------------------------------------------------------------
  863. AC_DEFUN([CS_CHECK_GLXEXT],
  864. [AC_REQUIRE([CS_CHECK_GLX])
  865. AS_IF([test x$cs_cv_libglx = "xyes"],
  866. [# Check for GLX extensions.
  867. CS_CHECK_BUILD([for GLX extensions], [cs_cv_libglx_extensions],
  868. [AC_LANG_PROGRAM(
  869. [[#define GLX_GLXEXT_PROTOTYPES
  870. #include <GL/glx.h>]],
  871. [glXGetProcAddressARB(0)])],
  872. [CS_CREATE_TUPLE(
  873. [$cs_cv_libglx_cflags],
  874. [$cs_cv_libglx_lflags],
  875. [$cs_cv_libglx_libs])],
  876. [], [$1], [$2])])])
  877. #------------------------------------------------------------------------------
  878. # CS_CHECK_GLUT
  879. # Check for GLUT.
  880. #------------------------------------------------------------------------------
  881. AC_DEFUN([CS_CHECK_GLUT],
  882. [AC_REQUIRE([CS_CHECK_GLU])
  883. AS_IF([test x$cs_cv_libglu = "xyes"],
  884. [# MacOS/X or Darwin?
  885. AS_IF([test "x$cs_host_macosx" = "xyes"],
  886. [cs_osx_glut=CS_CREATE_TUPLE([-DCS_GLUT_PATH=GLUT],[],[-framework GLUT])])
  887. # Windows?
  888. AS_IF([test $cs_host_family = windows],
  889. [cs_win32_glut=CS_CREATE_TUPLE([],[],[-lglut32])])
  890. # Check for GLUT.
  891. CS_CHECK_BUILD([for GLUT], [cs_cv_libglut],
  892. [AC_LANG_PROGRAM(
  893. [CS_GL_INCLUDE([CS_GLUT_PATH],[GL],[glut.h])], [glutSwapBuffers()])],
  894. [$cs_osx_glut \
  895. CS_CREATE_TUPLE() \
  896. $cs_win32_glut \
  897. CS_CREATE_TUPLE([],[],[-lGLUT]) \
  898. CS_CREATE_TUPLE([],[],[-lglut])], [],
  899. [CS_EMIT_BUILD_RESULT([cs_cv_libglut], [GLUT])], [], [],
  900. [$cs_cv_libgl_cflags $cs_cv_libglu_cflags],
  901. [$cs_cv_libgl_lflags $cs_cv_libglu_lflags],
  902. [$cs_cv_libgl_libs $cs_cv_libglu_libs])])])
  903. # checkpic.m4 -*- Autoconf -*-
  904. #==============================================================================
  905. # Copyright (C)2005 by Eric Sunshine <[email protected]>
  906. #
  907. # This library is free software; you can redistribute it and/or modify it
  908. # under the terms of the GNU Library General Public License as published by
  909. # the Free Software Foundation; either version 2 of the License, or (at your
  910. # option) any later version.
  911. #
  912. # This library is distributed in the hope that it will be useful, but
  913. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  914. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
  915. # License for more details.
  916. #
  917. # You should have received a copy of the GNU Library General Public License
  918. # along with this library; if not, write to the Free Software Foundation,
  919. # Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  920. #
  921. #==============================================================================
  922. AC_PREREQ([2.56])
  923. #------------------------------------------------------------------------------
  924. # CS_COMPILER_PIC([LANGUAGE], [CACHE-VAR], [ACTION-IF-FOUND],
  925. # [ACTION-IF-NOT-FOUND])
  926. # Check if compiler can be instructed to produce
  927. # position-independent-code (PIC). This feature is required by some
  928. # platforms when building plugin modules and shared libraries. If
  929. # LANGUAGE is not provided, then `C' is assumed (other options include
  930. # `C++'). If CACHE-VAR is not provided, then it defaults to the name
  931. # "cs_cv_prog_compiler_pic". If a PIC-enabling option (such as `-fPIC')
  932. # is discovered, then it is assigned to CACHE-VAR and ACTION-IF-FOUND is
  933. # invoked; otherwise the empty string is assigned to CACHE-VAR and
  934. # ACTION-IF-NOT-FOUND is invoked.
  935. #
  936. # IMPLEMENTATION NOTES
  937. #
  938. # On some platforms (such as Windows), the -fPIC option is superfluous
  939. # and emits a warning "-fPIC ignored for target (all code is position
  940. # independent)", despite the fact that the compiler accepts the option
  941. # and returns a success code. We want to re-interpret the warning as a
  942. # failure in order to avoid unnecessary compiler diagnostics in case the
  943. # client inserts the result of this check into CFLAGS, for instance. We
  944. # do so by attempting to promote warnings to errors using the result of
  945. # CS_COMPILER_ERRORS(). As an extra safe-guard, we also scan the compiler
  946. # output for an appropriate diagnostic because some gcc warnings fail to
  947. # promote to error status despite use of -Werror.
  948. #------------------------------------------------------------------------------
  949. AC_DEFUN([CS_COMPILER_PIC],
  950. [CS_COMPILER_ERRORS([$1],
  951. [m4_default([$2_werror],[cs_cv_prog_compiler_pic_werror])])
  952. CS_CHECK_BUILD_FLAGS(
  953. [how to enable m4_default([$1],[C]) PIC generation],
  954. [m4_default([$2],[cs_cv_prog_compiler_pic])],
  955. [CS_CREATE_TUPLE([-fPIC])], [$1], [$3], [$4],
  956. [m4_default([$$2_werror],[$cs_cv_prog_compiler_pic_werror])], [], [],
  957. [fPIC])])
  958. # Backward-compatiblity alias.
  959. AC_DEFUN([CS_CHECK_COMPILER_PIC], [CS_COMPILER_PIC([$1],[$2],[$3],[$4])])
  960. # checkprog.m4 -*- Autoconf -*-
  961. #==============================================================================
  962. # Copyright (C)2004 by Eric Sunshine <[email protected]>
  963. #
  964. # This library is free software; you can redistribute it and/or modify it
  965. # under the terms of the GNU Library General Public License as published by
  966. # the Free Software Foundation; either version 2 of the License, or (at your
  967. # option) any later version.
  968. #
  969. # This library is distributed in the hope that it will be useful, but
  970. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  971. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
  972. # License for more details.
  973. #
  974. # You should have received a copy of the GNU Library General Public License
  975. # along with this library; if not, write to the Free Software Foundation,
  976. # Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  977. #
  978. #==============================================================================
  979. AC_PREREQ([2.56])
  980. #------------------------------------------------------------------------------
  981. # cs_bin_paths_default
  982. # Comma delimited list of additional directories in which tools and
  983. # commands might be found.
  984. #
  985. # Present Cases:
  986. # /usr/local/bin -- Although a common location for executables, it is
  987. # now-and-then absent from the default PATH setting.
  988. # /sw/bin -- Fink, the MacOS/X manager of Unix packages, installs
  989. # executables here.
  990. #------------------------------------------------------------------------------
  991. m4_define([cs_bin_paths_default], [/usr/local/bin, /sw/bin])
  992. #------------------------------------------------------------------------------
  993. # CS_CHECK_PROG(VARIABLE, PROGRAM, VALUE-IF-FOUND, [VALUE-IF-NOT-FOUND],
  994. # [PATH], [REJECT])
  995. # Simple wrapper for AC_CHECK_PROG() which ensures that the search path
  996. # is augmented by the directories mentioned in cs_bin_paths_default.
  997. #------------------------------------------------------------------------------
  998. AC_DEFUN([CS_CHECK_PROG],
  999. [_CS_PROG_PATH_PREPARE
  1000. AC_CHECK_PROG([$1], [$2], [$3], [$4],
  1001. m4_ifval([$5], [_CS_PROG_CLIENT_PATH([$5])]), [$6])])
  1002. #------------------------------------------------------------------------------
  1003. # CS_CHECK_PROGS(VARIABLE, PROGRAMS, [VALUE-IF-NOT-FOUND], [PATH])
  1004. # Simple wrapper for AC_CHECK_PROGS() which ensures that the search path
  1005. # is augmented by the directories mentioned in cs_bin_paths_default.
  1006. #------------------------------------------------------------------------------
  1007. AC_DEFUN([CS_CHECK_PROGS],
  1008. [_CS_PROG_PATH_PREPARE
  1009. AC_CHECK_PROGS([$1], [$2], [$3],
  1010. m4_ifval([$4], [_CS_PROG_CLIENT_PATH([$4])]))])
  1011. #------------------------------------------------------------------------------
  1012. # CS_CHECK_TOOL(VARIABLE, TOOL, [VALUE-IF-NOT-FOUND], [PATH])
  1013. # Simple wrapper for AC_CHECK_TOOL() which ensures that the search path
  1014. # is augmented by the directories mentioned in cs_bin_paths_default.
  1015. #------------------------------------------------------------------------------
  1016. AC_DEFUN([CS_CHECK_TOOL],
  1017. [_CS_PROG_PATH_PREPARE
  1018. AC_CHECK_TOOL([$1], [$2], [$3],
  1019. m4_ifval([$4], [_CS_PROG_CLIENT_PATH([$4])]))])
  1020. #------------------------------------------------------------------------------
  1021. # CS_CHECK_TOOLS(VARIABLE, TOOLS, [VALUE-IF-NOT-FOUND], [PATH])
  1022. # Simple wrapper for AC_CHECK_TOOLS() which ensures that the search path
  1023. # is augmented by the directories mentioned in cs_bin_paths_default.
  1024. #------------------------------------------------------------------------------
  1025. AC_DEFUN([CS_CHECK_TOOLS],
  1026. [_CS_PROG_PATH_PREPARE
  1027. AC_CHECK_TOOLS([$1], [$2], [$3],
  1028. m4_ifval([$4], [_CS_PROG_CLIENT_PATH([$4])]))])
  1029. #------------------------------------------------------------------------------
  1030. # CS_PATH_PROG(VARIABLE, PROGRAM, [VALUE-IF-NOT-FOUND], [PATH])
  1031. # Simple wrapper for AC_PATH_PROG() which ensures that the search path
  1032. # is augmented by the directories mentioned in cs_bin_paths_default.
  1033. #------------------------------------------------------------------------------
  1034. AC_DEFUN([CS_PATH_PROG],
  1035. [_CS_PROG_PATH_PREPARE
  1036. AC_PATH_PROG([$1], [$2], [$3],
  1037. m4_ifval([$4], [_CS_PROG_CLIENT_PATH([$4])]))])
  1038. #------------------------------------------------------------------------------
  1039. # CS_PATH_PROGS(VARIABLE, PROGRAMS, [VALUE-IF-NOT-FOUND], [PATH])
  1040. # Simple wrapper for AC_PATH_PROGS() which ensures that the search path
  1041. # is augmented by the directories mentioned in cs_bin_paths_default.
  1042. #------------------------------------------------------------------------------
  1043. AC_DEFUN([CS_PATH_PROGS],
  1044. [_CS_PROG_PATH_PREPARE
  1045. AC_PATH_PROGS([$1], [$2], [$3],
  1046. m4_ifval([$4], [_CS_PROG_CLIENT_PATH([$4])]))])
  1047. #------------------------------------------------------------------------------
  1048. # CS_PATH_TOOL(VARIABLE, TOOL, [VALUE-IF-NOT-FOUND], [PATH])
  1049. # Simple wrapper for AC_PATH_TOOL() which ensures that the search path
  1050. # is augmented by the directories mentioned in cs_bin_paths_default.
  1051. #------------------------------------------------------------------------------
  1052. AC_DEFUN([CS_PATH_TOOL],
  1053. [_CS_PROG_PATH_PREPARE
  1054. AC_PATH_TOOL([$1], [$2], [$3],
  1055. m4_ifval([$4], [_CS_PROG_CLIENT_PATH([$4])]))])
  1056. #------------------------------------------------------------------------------
  1057. # _CS_PROG_PATH_PREPARE
  1058. # Ensure that the PATH environment variable mentions the set of
  1059. # directories listed in cs_bin_paths_default. These directories may not
  1060. # appear by default in the typical PATH, yet they might be common
  1061. # locations for tools and commands.
  1062. #------------------------------------------------------------------------------
  1063. AC_DEFUN([_CS_PROG_PATH_PREPARE],
  1064. [AS_REQUIRE([_AS_PATH_SEPARATOR_PREPARE])
  1065. AS_IF([test "$cs_prog_path_prepared" != yes],
  1066. [cs_prog_path_prepared=yes
  1067. PATH="$PATH[]m4_foreach([cs_bin_path], [cs_bin_paths_default],
  1068. [$PATH_SEPARATOR[]cs_bin_path])"
  1069. export PATH])])
  1070. #------------------------------------------------------------------------------
  1071. # _CS_PROG_CLIENT_PATH(CLIENT-PATH)
  1072. # Given a client-supplied replacement for PATH, augment the list by
  1073. # appending the locations mentioned in cs_bin_paths_default.
  1074. #------------------------------------------------------------------------------
  1075. AC_DEFUN([_CS_PROG_CLIENT_PATH],
  1076. [AS_REQUIRE([_AS_PATH_SEPARATOR_PREPARE])dnl
  1077. $1[]m4_foreach([cs_bin_path], [cs_bin_paths_default],
  1078. [$PATH_SEPARATOR[]cs_bin_path])])
  1079. # checkpthread.m4 -*- Autoconf -*-
  1080. #==============================================================================
  1081. # Copyright (C)2003-2005 by Eric Sunshine <[email protected]>
  1082. #
  1083. # This library is free software; you can redistribute it and/or modify it
  1084. # under the terms of the GNU Library General Public License as published by
  1085. # the Free Software Foundation; either version 2 of the License, or (at your
  1086. # option) any later version.
  1087. #
  1088. # This library is distributed in the hope that it will be useful, but
  1089. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  1090. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
  1091. # License for more details.
  1092. #
  1093. # You should have received a copy of the GNU Library General Public License
  1094. # along with this library; if not, write to the Free Software Foundation,
  1095. # Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1096. #
  1097. #==============================================================================
  1098. AC_PREREQ([2.56])
  1099. #------------------------------------------------------------------------------
  1100. # CS_CHECK_PTHREAD([REJECT-MASK])
  1101. # Check for pthread. Also check if the pthread implementation supports
  1102. # the recursive and timed mutex extensions. (Timed mutexes are needed for
  1103. # the NPTL: New Posix Thread Library on GNU/Linux if the mutex is going
  1104. # to be used with any of the timed condition-wait functions.) The shell
  1105. # variable cs_cv_sys_pthread is set to "yes" if pthread is available,
  1106. # else "no". If available, then the variables cs_cv_sys_pthread_cflags,
  1107. # cs_cv_sys_pthread_lflags, and cs_cv_sys_pthread_libs are set. (As a
  1108. # convenience, these variables can be emitted to an output file with
  1109. # CS_EMIT_BUILD_RESULT() by passing "cs_cv_sys_pthread" as its CACHE-VAR
  1110. # argument.) If the recursive mutex extension is supported, then
  1111. # cs_cv_sys_pthread_mutex_recursive will be set with the literal name of
  1112. # the constant which must be passed to pthread_mutexattr_settype() to
  1113. # enable this feature. The constant name will be typically
  1114. # PTHREAD_MUTEX_RECURSIVE or PTHREAD_MUTEX_RECURSIVE_NP. If the recursive
  1115. # mutex extension is not available, then
  1116. # cs_cv_sys_pthread_mutex_recursive will be set to "no". If the timed
  1117. # mutex extension is supported, then cs_cv_sys_pthread_mutex_timed will
  1118. # be set with the literal name of the constant which must be passed to
  1119. # pthread_mutexattr_settype() to enable this feature. The constant name
  1120. # will be typically PTHREAD_MUTEX_TIMED or PTHREAD_MUTEX_TIMED_NP. If the
  1121. # timed mutex extension is not available, then
  1122. # cs_cv_sys_pthread_mutex_timed will be set to "no". REJECT-MASK can be
  1123. # used to limit the platforms on which the pthread test is performed. It
  1124. # is compared against $host_os; matches are rejected. If omitted, then
  1125. # the test is performed on all platforms. Examples: To avoid testing on
  1126. # Cygwin, use "cygwin*"; to avoid testing on Cygwin and AIX, use
  1127. # "cygwin*|aix*".
  1128. #------------------------------------------------------------------------------
  1129. AC_DEFUN([CS_CHECK_PTHREAD],
  1130. [AC_REQUIRE([AC_CANONICAL_HOST])
  1131. case $host_os in
  1132. m4_ifval([$1],
  1133. [$1)
  1134. cs_cv_sys_pthread=no
  1135. ;;
  1136. ])
  1137. *)
  1138. CS_CHECK_BUILD([for pthread], [cs_cv_sys_pthread],
  1139. [AC_LANG_PROGRAM(
  1140. [[#include <pthread.h>
  1141. #include <semaphore.h>
  1142. void* worker(void* p) { (void)p; return p; }]],
  1143. [pthread_t tid;
  1144. sem_t sem;
  1145. pthread_create(&tid, 0, worker, 0);
  1146. sem_init(&sem, 0, 0);
  1147. sem_destroy(&sem);])],
  1148. [cs_pthread_flags])
  1149. ;;
  1150. esac
  1151. _CS_CHECK_MUTEX_FEATURE([PTHREAD_MUTEX_RECURSIVE],
  1152. [cs_cv_sys_pthread_mutex_recursive], [for pthread recursive mutexes])])
  1153. # _CS_CHECK_MUTEX_FEATURE(FEATURE, CACHE-VAR, MESSAGE)
  1154. AC_DEFUN([_CS_CHECK_MUTEX_FEATURE],
  1155. [AS_IF([test $cs_cv_sys_pthread = yes],
  1156. [AC_CACHE_CHECK([$3], [$2],
  1157. [CS_BUILD_IFELSE(
  1158. [AC_LANG_PROGRAM(
  1159. [[#include <pthread.h>]],
  1160. [pthread_mutexattr_t attr;
  1161. pthread_mutexattr_settype(&attr, CS_MUTEX_FEATURE);])],
  1162. [CS_CREATE_TUPLE([-DCS_MUTEX_FEATURE=$1]) \
  1163. CS_CREATE_TUPLE([-DCS_MUTEX_FEATURE=$1_NP])],
  1164. [],
  1165. [$2=`echo $cs_build_cflags | sed 's/.*\($1_*N*P*\).*/\1/'`],
  1166. [$2=no],
  1167. [$cs_cv_sys_pthread_cflags -D_GNU_SOURCE],
  1168. [$cs_cv_sys_pthread_lflags],
  1169. [$cs_cv_sys_pthread_libs])])],
  1170. [$2=no])])
  1171. #------------------------------------------------------------------------------
  1172. # CS_CHECK_PTHREAD_ATFORK(CACHE-VAR)
  1173. # Checks whether the pthread library contains pthread_atfork(). Sets
  1174. # CACHE-VAR to "yes" or "no", according to the test result.
  1175. #------------------------------------------------------------------------------
  1176. AC_DEFUN([CS_CHECK_PTHREAD_ATFORK],
  1177. [AS_IF([test $cs_cv_sys_pthread = yes],
  1178. [AC_CACHE_CHECK([for pthread_atfork support], [$1],
  1179. [CS_BUILD_IFELSE(
  1180. [AC_LANG_PROGRAM(
  1181. [[#include <pthread.h>]],
  1182. [pthread_atfork (0, 0, 0);])],
  1183. [], [],
  1184. [$1=yes], [$1=no],
  1185. [$cs_cv_sys_pthread_cflags -D_GNU_SOURCE],
  1186. [$cs_cv_sys_pthread_lflags],
  1187. [$cs_cv_sys_pthread_libs])])],
  1188. [$1=no])])
  1189. m4_define([cs_pthread_flags],
  1190. [CS_CREATE_TUPLE() \
  1191. CS_CREATE_TUPLE([], [], [-lpthread]) \
  1192. CS_CREATE_TUPLE([], [], [-lpthread -lrt]) \
  1193. CS_CREATE_TUPLE([-pthread], [-pthread], []) \
  1194. CS_CREATE_TUPLE([-pthread], [-pthread], [-lpthread]) \
  1195. CS_CREATE_TUPLE([-pthread], [-pthread], [-lc_r])])
  1196. # checktt2.m4 -*- Autoconf -*-
  1197. #==============================================================================
  1198. # Copyright (C)2004,2005 by Eric Sunshine <[email protected]>
  1199. #
  1200. # This library is free software; you can redistribute it and/or modify it
  1201. # under the terms of the GNU Library General Public License as published by
  1202. # the Free Software Foundation; either version 2 of the License, or (at your
  1203. # option) any later version.
  1204. #
  1205. # This library is distributed in the hope that it will be useful, but
  1206. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  1207. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
  1208. # License for more details.
  1209. #
  1210. # You should have received a copy of the GNU Library General Public License
  1211. # along with this library; if not, write to the Free Software Foundation,
  1212. # Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1213. #
  1214. #==============================================================================
  1215. AC_PREREQ([2.56])
  1216. #------------------------------------------------------------------------------
  1217. # CS_CHECK_TEMPLATE_TOOLKIT2([EMITTER])
  1218. # Check if Template Toolkit 2 (http://www.tt2.org/) is available. The
  1219. # shell variable cs_cv_perl_tt2 is set to "yes" if the package is
  1220. # discovered, else "no". Also sets the shell variable TTREE to the name
  1221. # path of the 'ttree' utility program and invokes AC_SUBST(). If EMITTER
  1222. # is provided and the package was discovered, then
  1223. # CS_EMIT_BUILD_PROPERTY() is invoked with EMITTER in order to record the
  1224. # value of the TTREE variable in an output file. As a convenience, if
  1225. # EMITTER is the literal value "emit" or "yes", then
  1226. # CS_EMIT_BUILD_RESULT()'s default emitter will be used.
  1227. #------------------------------------------------------------------------------
  1228. AC_DEFUN([CS_CHECK_TEMPLATE_TOOLKIT2],
  1229. [CS_CHECK_PROGS([PERL], [perl5 perl])
  1230. AS_IF([test -n "$PERL"],
  1231. [AC_CACHE_CHECK([for TemplateToolkit], [cs_cv_perl_tt2],
  1232. [AS_IF([AC_RUN_LOG(
  1233. [$PERL -M'Template 2.11' -MTemplate::Plugin -e 0 1>&2])],
  1234. [cs_cv_perl_tt2=yes],
  1235. [cs_cv_perl_tt2=no])])
  1236. CS_PATH_PROGS([TTREE], [ttree])
  1237. AS_IF([test $cs_cv_perl_tt2 = yes && test -n "$TTREE"],
  1238. [CS_EMIT_BUILD_PROPERTY([TTREE], [$TTREE], [], [],
  1239. CS_EMITTER_OPTIONAL([$1]))])])])
  1240. # compiler.m4 -*- Autoconf -*-
  1241. #=============================================================================
  1242. # Copyright (C)2003 by Matze Braun <[email protected]>
  1243. #
  1244. # This library is free software; you can redistribute it and/or modify it
  1245. # under the terms of the GNU Library General Public License as published by
  1246. # the Free Software Foundation; either version 2 of the License, or (at your
  1247. # option) any later version.
  1248. #
  1249. # This library is distributed in the hope that it will be useful, but
  1250. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  1251. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
  1252. # License for more details.
  1253. #
  1254. # You should have received a copy of the GNU Library General Public License
  1255. # along with this library; if not, write to the Free Software Foundation,
  1256. # Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1257. #
  1258. #=============================================================================
  1259. #-----------------------------------------------------------------------------
  1260. # Detection of C and C++ compilers and setting flags
  1261. #
  1262. # CS_PROG_CC
  1263. # Detects the C compiler. Also takes care of the CFLAGS, CPPFLAGS and CC
  1264. # environment variables. This will filter out all -g and -O from the
  1265. # CFLAGS variable because Autoconf's -g and -O defaults are not always
  1266. # desired. This will also set the CMD.CC and COMPILER.CFLAGS variables
  1267. # in Jamconfig
  1268. # CS_PROG_CXX
  1269. # Detects the C++ compiler. Also takes care of the CXXFLAGS, CPPFLAGS
  1270. # and CXX environment variables. This will filter out all -g and -O from
  1271. # the CXXFLAGS variable because Autoconf's -g and -O defaults are not
  1272. # always desired. This will also set the CMD.C++ and COMPILER.C++FLAGS
  1273. # variables in Jamconfig
  1274. # CS_PROG_LINK
  1275. # Tries to determine a linker. This is done by checking if a C++ or
  1276. # Objecctive-C++ compiler is available in which case it is used for
  1277. # linking; otherwise the C or Objective-C compiler is used. This also
  1278. # sets the CMD.LINK and COMPILER.LFLAGS variables in Jamconfig and
  1279. # respects the LDFLAGS environment variable. Finally, checks if linker
  1280. # recognizes -shared and sets PLUGIN.LFLAGS; and checks if linker
  1281. # recognizes -soname and sets PLUGIN.LFLAGS.USE_SONAME to "yes".
  1282. #-----------------------------------------------------------------------------
  1283. AC_DEFUN([CS_PROG_CC],[
  1284. CFLAGS="$CFLAGS" # Filter undesired flags
  1285. AS_IF([test -n "$CC"],[
  1286. CS_EMIT_BUILD_PROPERTY([CMD.CC], [$CC])
  1287. CS_EMIT_BUILD_PROPERTY([COMPILER.CFLAGS], [$CPPFLAGS $CFLAGS], [+])
  1288. # Check if compiler recognizes -pipe directive.
  1289. CS_EMIT_BUILD_FLAGS([if $CC accepts -pipe], [cs_cv_prog_cc_pipe],
  1290. [CS_CREATE_TUPLE([-pipe])], [C], [COMPILER.CFLAGS], [+])
  1291. ])
  1292. ])
  1293. AC_DEFUN([CS_PROG_CXX],[
  1294. CXXFLAGS="$CXXFLAGS" # Filter undesired flags
  1295. AS_IF([test -n "$CXX"],[
  1296. CS_EMIT_BUILD_PROPERTY([CMD.C++], [$CXX])
  1297. CS_EMIT_BUILD_PROPERTY([COMPILER.C++FLAGS], [$CPPFLAGS $CXXFLAGS], [+])
  1298. # Check if compiler can be instructed to produce position-independent-code
  1299. # (PIC). This feature is required by some platforms when building plugin
  1300. # modules and shared libraries.
  1301. CS_COMPILER_PIC([C++], [cs_cv_prog_cxx_pic],
  1302. [CS_EMIT_BUILD_PROPERTY([COMPILER.C++FLAGS.PIC],
  1303. [$cs_cv_prog_cxx_pic])])
  1304. ])
  1305. ])
  1306. AC_DEFUN([CS_PROG_LINK],[
  1307. AC_REQUIRE([CS_PROG_CXX])
  1308. AS_IF([test -n "$CXX"],
  1309. [CS_EMIT_BUILD_PROPERTY([CMD.LINK], [AS_ESCAPE([$(CMD.C++)])])],
  1310. [CS_EMIT_BUILD_PROPERTY([CMD.LINK], [AS_ESCAPE([$(CMD.CC)])])])
  1311. CS_EMIT_BUILD_PROPERTY([COMPILER.LFLAGS], [$LDFLAGS], [+])
  1312. # Check if compiler/linker recognizes -shared directive which is needed for
  1313. # linking plugin modules. Unfortunately, the Apple compiler (and possibly
  1314. # others) requires extra effort. Even though the compiler does not recognize
  1315. # the -shared option, it nevertheless returns a "success" result after emitting
  1316. # the warning "unrecognized option `-shared'". Worse, even -Werror fails to
  1317. # promote the warning to an error, so we must instead scan the compiler's
  1318. # output for an appropriate diagnostic.
  1319. CS_CHECK_BUILD_FLAGS([if -shared is accepted], [cs_cv_prog_link_shared],
  1320. [CS_CREATE_TUPLE([-shared $cs_cv_prog_cxx_pic])], [C++],
  1321. [CS_EMIT_BUILD_PROPERTY([PLUGIN.LFLAGS], [-shared], [+])], [],
  1322. [], [], [], [shared])
  1323. # Check if linker recognizes -soname which is used to assign a name internally
  1324. # to plugin modules.
  1325. CS_CHECK_BUILD([if -soname is accepted], [cs_cv_prog_link_soname], [],
  1326. [CS_CREATE_TUPLE([-Wl,-soname,foobar])], [C++],
  1327. [CS_EMIT_BUILD_PROPERTY([PLUGIN.LFLAGS.USE_SONAME], [yes])])
  1328. ])
  1329. #------------------------------------------------------------------------------
  1330. # Determine host platform. Recognized families: Unix, Windows, MacOS/X.
  1331. # Orginial Macros Copyright (C)2003 Eric Sunshine <[email protected]>
  1332. #
  1333. # This library is free software; you can redistribute it and/or modify it
  1334. # under the terms of the GNU Library General Public License as published by
  1335. # the Free Software Foundation; either version 2 of the License, or (at your
  1336. # option) any later version.
  1337. #
  1338. # This library is distributed in the hope that it will be useful, but
  1339. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  1340. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
  1341. # License for more details.
  1342. #
  1343. # You should have received a copy of the GNU Library General Public License
  1344. # along with this library; if not, write to the Free Software Foundation,
  1345. # Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1346. #
  1347. #------------------------------------------------------------------------------
  1348. #------------------------------------------------------------------------------
  1349. # Determine host CPU.
  1350. #
  1351. # CS_CHECK_HOST_CPU
  1352. # Set the shell variable cs_host_cpu to a normalized form of the CPU name
  1353. # returned by config.guess/config.sub. Typically, Crystal Space's
  1354. # conception of CPU name is the same as that returned by
  1355. # config.guess/config.sub, but there may be exceptions as seen in the
  1356. # `case' statement. Also takes the normalized name, uppercases it to
  1357. # form a name suitable for the C preprocessor. Additionally sets the
  1358. # TARGET.PROCESSOR Jamconfig property.
  1359. #------------------------------------------------------------------------------
  1360. AC_DEFUN([CS_CHECK_HOST_CPU],
  1361. [AC_REQUIRE([AC_CANONICAL_HOST])
  1362. case $host_cpu in
  1363. [[Ii][3-9]86*|[Xx]86*]) cs_host_cpu=x86 ;;
  1364. *) cs_host_cpu=$host_cpu ;;
  1365. esac
  1366. cs_host_cpu_normalized="AS_TR_CPP([$cs_host_cpu])"
  1367. CS_JAMCONFIG_PROPERTY([TARGET.PROCESSOR], [$cs_host_cpu_normalized])
  1368. ])
  1369. #------------------------------------------------------------------------------
  1370. # CS_CHECK_HOST
  1371. # Sets the shell variables cs_host_target cs_host_family,
  1372. # cs_host_os_normalized, and cs_host_os_normalized_uc. Emits appropriate
  1373. # CS_PLATFORM_UNIX, CS_PLATFORM_WIN32, CS_PLATFORM_MACOSX via
  1374. # AC_DEFINE(), and TARGET.OS and TARGET.OS.NORMALIZED to Jamconfig.
  1375. #------------------------------------------------------------------------------
  1376. AC_DEFUN([CS_CHECK_HOST],
  1377. [AC_REQUIRE([AC_CANONICAL_HOST])
  1378. CS_CHECK_HOST_CPU
  1379. cs_host_os_normalized=''
  1380. case $host_os in
  1381. mingw*|cygwin*)
  1382. cs_host_target=win32gcc
  1383. cs_host_family=windows
  1384. ;;
  1385. darwin*)
  1386. _CS_CHECK_HOST_DARWIN
  1387. ;;
  1388. *)
  1389. # Everything else is assumed to be Unix or Unix-like.
  1390. cs_host_target=unix
  1391. cs_host_family=unix
  1392. ;;
  1393. esac
  1394. case $cs_host_family in
  1395. windows)
  1396. AC_DEFINE([CS_PLATFORM_WIN32], [],
  1397. [Define when compiling for Win32])
  1398. AS_IF([test -z "$cs_host_os_normalized"],
  1399. [cs_host_os_normalized='Win32'])
  1400. ;;
  1401. unix)
  1402. AC_DEFINE([CS_PLATFORM_UNIX], [],
  1403. [Define when compiling for Unix and Unix-like (i.e. MacOS/X)])
  1404. AS_IF([test -z "$cs_host_os_normalized"],
  1405. [cs_host_os_normalized='Unix'])
  1406. ;;
  1407. esac
  1408. cs_host_os_normalized_uc="AS_TR_CPP([$cs_host_os_normalized])"
  1409. CS_JAMCONFIG_PROPERTY([TARGET.OS], [$cs_host_os_normalized_uc])
  1410. CS_JAMCONFIG_PROPERTY([TARGET.OS.NORMALIZED], [$cs_host_os_normalized])
  1411. ])
  1412. AC_DEFUN([_CS_CHECK_HOST_DARWIN],
  1413. [AC_REQUIRE([CS_PROG_CC])
  1414. AC_REQUIRE([CS_PROG_CXX])
  1415. # Both MacOS/X and Darwin are identified via $host_os as "darwin". We need
  1416. # a way to distinguish between the two. If Carbon.h is present, then
  1417. # assume MacOX/S; if not, assume Darwin. If --with-x=yes was invoked, and
  1418. # Carbon.h is present, then assume that user wants to cross-build for
  1419. # Darwin even though build host is MacOS/X.
  1420. # IMPLEMENTATION NOTE *1*
  1421. # The QuickTime 7.0 installer removes <CarbonSound/CarbonSound.h>, which
  1422. # causes #include <Carbon/Carbon.h> to fail unconditionally. Re-installing
  1423. # the QuickTime SDK should restore the header, however not all developers
  1424. # know to do this, so we work around the problem of the missing
  1425. # CarbonSound.h by #defining __CARBONSOUND__ in the test in order to
  1426. # prevent Carbon.h from attempting to #include the missing header.
  1427. # IMPLEMENTATION NOTE *2*
  1428. # At least one MacOS/X user switches between gcc 2.95 and gcc 3.3 with a
  1429. # script which toggles the values of CC, CXX, and CPP. Unfortunately, CPP
  1430. # was being set to run the preprocessor directly ("cpp", for instance)
  1431. # rather than running it via the compiler ("gcc -E", for instance). The
  1432. # problem with running the preprocessor directly is that __APPLE__ and
  1433. # __GNUC__ are not defined, which causes the Carbon.h check to fail. We
  1434. # avoid this problem by supplying a non-empty fourth argument to
  1435. # AC_CHECK_HEADER(), which causes it to test compile the header only (which
  1436. # is a more robust test), rather than also testing it via the preprocessor.
  1437. AC_DEFINE([__CARBONSOUND__], [],
  1438. [Avoid problem caused by missing <Carbon/CarbonSound.h>])
  1439. AC_CHECK_HEADER([Carbon/Carbon.h],
  1440. [cs_host_macosx=yes], [cs_host_macosx=no], [/* force compile */])
  1441. AS_IF([test $cs_host_macosx = yes],
  1442. [AC_MSG_CHECKING([for --with-x])
  1443. AS_IF([test "${with_x+set}" = set && test "$with_x" = "yes"],
  1444. [AC_MSG_RESULT([yes (assume Darwin)])
  1445. cs_host_macosx=no],
  1446. [AC_MSG_RESULT([no])])])
  1447. AS_IF([test $cs_host_macosx = yes],
  1448. [cs_host_target=macosx
  1449. cs_host_family=unix
  1450. cs_host_os_normalized='MacOS/X'
  1451. AC_DEFINE([CS_PLATFORM_MACOSX], [],
  1452. [Define when compiling for MacOS/X])
  1453. AC_CACHE_CHECK([for Objective-C compiler], [cs_cv_prog_objc],
  1454. [cs_cv_prog_objc="$CC"])
  1455. CS_JAMCONFIG_PROPERTY([CMD.OBJC], [$cs_cv_prog_objc])
  1456. AC_CACHE_CHECK([for Objective-C++ compiler], [cs_cv_prog_objcxx],
  1457. [cs_cv_prog_objcxx="$CXX"])
  1458. CS_JAMCONFIG_PROPERTY([CMD.OBJC++], [$cs_cv_prog_objcxx])],
  1459. [cs_host_target=unix
  1460. cs_host_family=unix])])
  1461. # diagnose.m4 -*- Autoconf -*-
  1462. #==============================================================================
  1463. # Copyright (C)2003 by Eric Sunshine <[email protected]>
  1464. #
  1465. # This library is free software; you can redistribute it and/or modify it
  1466. # under the terms of the GNU Library General Public License as published by
  1467. # the Free Software Foundation; either version 2 of the License, or (at your
  1468. # option) any later version.
  1469. #
  1470. # This library is distributed in the hope that it will be useful, but
  1471. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  1472. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
  1473. # License for more details.
  1474. #
  1475. # You should have received a copy of the GNU Library General Public License
  1476. # along with this library; if not, write to the Free Software Foundation,
  1477. # Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1478. #
  1479. #==============================================================================
  1480. AC_PREREQ([2.56])
  1481. #------------------------------------------------------------------------------
  1482. # CS_MSG_ERROR(ERROR-DESCRIPTION, [EXIT-STATUS])
  1483. # A convenience wrapper for AC_MSG_ERROR() which invokes AC_CACHE_SAVE()
  1484. # before aborting the script. Saving the cache should make subsequent
  1485. # re-invocations of the configure script faster once the user has
  1486. # corrected the problem(s) which caused the failure.
  1487. #------------------------------------------------------------------------------
  1488. AC_DEFUN([CS_MSG_ERROR],
  1489. [AC_CACHE_SAVE
  1490. AC_MSG_ERROR([$1], [$2])])
  1491. # embed.m4 -*- Autoconf -*-
  1492. #==============================================================================
  1493. # Copyright (C)2003,2005 by Eric Sunshine <[email protected]>
  1494. #
  1495. # This library is free software; you can redistribute it and/or modify it
  1496. # under the terms of the GNU Library General Public License as published by
  1497. # the Free Software Foundation; either version 2 of the License, or (at your
  1498. # option) any later version.
  1499. #
  1500. # This library is distributed in the hope that it will be useful, but
  1501. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  1502. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
  1503. # License for more details.
  1504. #
  1505. # You should have received a copy of the GNU Library General Public License
  1506. # along with this library; if not, write to the Free Software Foundation,
  1507. # Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1508. #
  1509. #==============================================================================
  1510. AC_PREREQ([2.56])
  1511. #------------------------------------------------------------------------------
  1512. # CS_META_INFO_EMBED([EMITTER], [GPL-OKAY])
  1513. # Determine if plugin meta-information should be embedded or if it should
  1514. # exist in a stand-alone .csplugin file, and check if necessary tools and
  1515. # libraries are present. Sets the shell variable
  1516. # enable_meta_info_embedding to "yes" if the user requested embedding or
  1517. # if it was enabled by default; otherwise sets it to "no".
  1518. #
  1519. # If EMITTER is provided, then a subset of the following variables
  1520. # (depending upon platform and availability) are recorded by invoking
  1521. # CS_EMIT_BUILD_PROPERTY() with EMITTER. As a convenience, if EMITTER is
  1522. # the literal value "emit" or "yes", then CS_EMIT_BUILD_RESULT()'s
  1523. # default emitter will be used.
  1524. #
  1525. # EMBED_META := yes or no
  1526. # EMBED_META.CFLAGS := compiler flags
  1527. # EMBED_META.LFLAGS := linker flags
  1528. # CMD.WINDRES := windres.exe
  1529. # OBJCOPY.AVAILABLE := yes or no
  1530. # CMD.OBJCOPY := objcopy.exe
  1531. # LIBBFD.AVAILABLE := yes or no
  1532. # LIBBFD.CFLAGS := libbfd compiler flags
  1533. # LIBBFD.LFLAGS := libbfd linker flags
  1534. # ELF.AVAILABLE := yes or no
  1535. #
  1536. # In general, clients need only concern themselves with the various
  1537. # EMBED_META-related variables. For building plugin modules, utilize
  1538. # EMBED_META.CFLAGS when compiling, and EMBED_META.LFLAGS when linking.
  1539. #
  1540. # On Unix, when CS' own ELF metadata reader can't be used (because the
  1541. # necessary header file elf.h was not found) embedding is accomplished
  1542. # via libbfd, which carries a GPL license. Projects which carry licenses
  1543. # not compatible with GPL should consider carefully before enabling
  1544. # embedding on Unix. If your project is GPL-compatible, then set GPL-OKAY
  1545. # to "yes". This will indicate that it is safe to use libbfd if the ELF
  1546. # reader can not be used. If your project is not GPL-compatible, then
  1547. # set it to "no" in order to disable embedding on Unix if the ELF reader
  1548. # is not usable. (The user can still manually override the setting via
  1549. # the --enable-meta-info-embedding option.)
  1550. #
  1551. # IMPLEMENTATION NOTES
  1552. #
  1553. # Recent versions of Mingw supply libbfd and libiberty. Since Crystal
  1554. # Space uses native Win32 API for meta-information embedding on Windows,
  1555. # we do not require these libraries on Windows. More importantly, users
  1556. # do not want to see these GPL-licensed libraries appear in the link
  1557. # statement for plugin modules, thus we explicitly disable the libbfd
  1558. # test on Windows.
  1559. #------------------------------------------------------------------------------
  1560. AC_DEFUN([CS_META_INFO_EMBED],
  1561. [AC_REQUIRE([AC_CANONICAL_HOST])
  1562. _CS_META_INFO_EMBED_ENABLE([$1], [$2])
  1563. AS_IF([test $enable_meta_info_embedding = yes],
  1564. [_CS_META_INFO_EMBED_TOOLS([$1])
  1565. AS_IF([test $cs_header_elf_h = yes],
  1566. [CS_EMIT_BUILD_PROPERTY([ELF.AVAILABLE], [yes], [], [],
  1567. CS_EMITTER_OPTIONAL([$1]))],
  1568. [case $host_os in
  1569. mingw*|cygwin*) ;;
  1570. *)
  1571. CS_CHECK_LIBBFD([$1],
  1572. [CS_EMIT_BUILD_PROPERTY([EMBED_META.CFLAGS],
  1573. [$cs_cv_libbfd_ok_cflags], [+], [],
  1574. CS_EMITTER_OPTIONAL([$1]))
  1575. CS_EMIT_BUILD_PROPERTY([EMBED_META.LFLAGS],
  1576. [$cs_cv_libbfd_ok_lflags $cs_cv_libbfd_ok_libs],
  1577. [+], [], CS_EMITTER_OPTIONAL([$1]))])
  1578. ;;
  1579. esac])])])
  1580. #------------------------------------------------------------------------------
  1581. # _CS_META_INFO_EMBED_ENABLE([EMITTER], [GPL-OKAY])
  1582. # Helper for CS_META_INFO_EMBED which adds an
  1583. # --enable-meta-info-embedding option to the configure script allowing
  1584. # the user to control embedding. Sets the shell variable
  1585. # enable_meta_info_embedding to yes or no.
  1586. #
  1587. # IMPLEMENTATION NOTES
  1588. #
  1589. # On Unix, embedding is enabled by default if elf.h is found and disabled
  1590. # by default unless overridden via GPL-OKAY because libbfd carries a GPL
  1591. # license which may be incompatible with a project's own license (such as
  1592. # LGPL).
  1593. #------------------------------------------------------------------------------
  1594. AC_DEFUN([_CS_META_INFO_EMBED_ENABLE],
  1595. [AC_REQUIRE([CS_CHECK_HOST])
  1596. AC_CHECK_HEADERS([elf.h], [cs_header_elf_h=yes], [cs_header_elf_h=no])
  1597. AC_MSG_CHECKING([whether to embed plugin meta-information])
  1598. case $cs_host_target in
  1599. unix) AS_IF([test $cs_header_elf_h = yes],
  1600. [cs_embed_meta_info_default=yes],
  1601. [cs_embed_meta_info_default=m4_ifval([$2],[$2],[no])]) ;;
  1602. *) cs_embed_meta_info_default=yes ;;
  1603. esac
  1604. AC_ARG_ENABLE([meta-info-embedding],
  1605. [AC_HELP_STRING([--enable-meta-info-embedding],
  1606. [store plugin meta-information directly inside plugin modules if
  1607. supported by platform; if disabled, meta-information is stored in
  1608. stand-alone .csplugin files; this option is enabled by default for
  1609. non-Unix platforms and on Unix platforms with ELF-format object
  1610. files; it is disabled by default on Unix platforms if ELF is not
  1611. available and the project uses a non-GPL-compatible license (such
  1612. as LGPL) since the non-ELF Unix embedding technology requires the
  1613. GPL-licensed libbfd library; if ELF is not available, enable this
  1614. option on Unix only if you are certain you want a GPL-licensed
  1615. library infecting your project])],
  1616. [], [enable_meta_info_embedding=$cs_embed_meta_info_default])
  1617. AC_MSG_RESULT([$enable_meta_info_embedding])
  1618. CS_EMIT_BUILD_PROPERTY([EMBED_META], [$enable_meta_info_embedding],
  1619. [], [], CS_EMITTER_OPTIONAL([$1]))])
  1620. #------------------------------------------------------------------------------
  1621. # _CS_META_INFO_EMBED_TOOLS([EMITTER])
  1622. # Helper for CS_META_INFO_EMBED() which searches for tools required for
  1623. # plugin meta-info embedding.
  1624. #------------------------------------------------------------------------------
  1625. AC_DEFUN([_CS_META_INFO_EMBED_TOOLS],
  1626. [CS_CHECK_TOOLS([WINDRES], [windres])
  1627. CS_EMIT_BUILD_PROPERTY([CMD.WINDRES], [$WINDRES], [], [],
  1628. CS_EMITTER_OPTIONAL([$1]))
  1629. CS_CHECK_TOOLS([OBJCOPY], [objcopy])
  1630. AS_IF([test -n "$OBJCOPY"],
  1631. [CS_EMIT_BUILD_PROPERTY([OBJCOPY.AVAILABLE], [yes], [], [],
  1632. CS_EMITTER_OPTIONAL([$1]))
  1633. CS_EMIT_BUILD_PROPERTY([CMD.OBJCOPY], [$OBJCOPY], [], [],
  1634. CS_EMITTER_OPTIONAL([$1]))])])
  1635. #------------------------------------------------------------------------------
  1636. # CS_CHECK_LIBBFD([EMITTER], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
  1637. # Exhaustive check for a usable GPL-licensed libbfd, the Binary File
  1638. # Descriptor library, a component of binutils, which allows low-level
  1639. # manipulation of executable and object files. If EMITTER is provided,
  1640. # then the following variables are recorded by invoking
  1641. # CS_EMIT_BUILD_PROPERTY() with EMITTER. As a convenience, if EMITTER is
  1642. # the literal value "emit" or "yes", then CS_EMIT_BUILD_RESULT()'s
  1643. # default emitter will be used.
  1644. #
  1645. # LIBBFD.AVAILABLE := yes or no
  1646. # LIBBFD.CFLAGS := libbfd compiler flags
  1647. # LIBBFD.LFLAGS := libbfd linker flags
  1648. #
  1649. # The shell variable cs_cv_libbfd_ok is set to yes if a usable libbfd was
  1650. # discovered, else no. If found, the additional shell variables
  1651. # cs_cv_libbfd_ok_cflags, cs_cv_libbfd_ok_lflags, and
  1652. # cs_cv_libbfd_ok_libs are also set.
  1653. #
  1654. # WARNING
  1655. #
  1656. # libbfd carries a GPL license which is incompatible with the LGPL
  1657. # license of Crystal Space. Do not use this library with projects under
  1658. # less restrictive licenses, such as LGPL.
  1659. #
  1660. # IMPLEMENTATION NOTES
  1661. #
  1662. # It seems that some platforms have two version of libiberty installed:
  1663. # one from binutils and one from gcc. The binutils version resides in
  1664. # /usr/lib, whereas the gcc version resides in the gcc installation
  1665. # directory. The gcc version, by default, takes precedence at link time
  1666. # over the binutils version. Unfortunately, in broken cases, the gcc
  1667. # version of libiberty is missing htab_create_alloc() which is required
  1668. # by some libbfd functions. The extensive secondary check of libbfd
  1669. # catches this anomalous case of broken gcc libiberty. It turns out that
  1670. # it is possible to make the linker prefer the binutils version by
  1671. # specifying -L/usr/lib, thus the extensive test attempts to do so in an
  1672. # effort to resolve this unfortunate issue.
  1673. #------------------------------------------------------------------------------
  1674. AC_DEFUN([CS_CHECK_LIBBFD],
  1675. [CS_CHECK_LIB_WITH([bfd],
  1676. [AC_LANG_PROGRAM([[#include <bfd.h>]], [bfd_init();])],
  1677. [], [], [], [], [], [], [-liberty])
  1678. AS_IF([test $cs_cv_libbfd = yes],
  1679. [CS_CHECK_BUILD([if libbfd is usable], [cs_cv_libbfd_ok],
  1680. [AC_LANG_PROGRAM([[#include <bfd.h>]],
  1681. [bfd* p;
  1682. asection* s;
  1683. bfd_init();
  1684. p = bfd_openr(0,0);
  1685. bfd_check_format(p,bfd_object);
  1686. bfd_get_section_by_name(p,0);
  1687. bfd_section_size(p,s);
  1688. bfd_get_section_contents(p,s,0,0,0);
  1689. bfd_close(p);])],
  1690. [CS_CREATE_TUPLE() CS_CREATE_TUPLE([],[-L/usr/lib],[])],
  1691. [], [], [], [],
  1692. [$cs_cv_libbfd_cflags],
  1693. [$cs_cv_libbfd_lflags],
  1694. [$cs_cv_libbfd_libs])],
  1695. [cs_cv_libbfd_ok=no])
  1696. AS_IF([test $cs_cv_libbfd_ok = yes],
  1697. [CS_EMIT_BUILD_RESULT([cs_cv_libbfd_ok], [LIBBFD],
  1698. CS_EMITTER_OPTIONAL([$1]))
  1699. $2],
  1700. [$3])])
  1701. # emit.m4 -*- Autoconf -*-
  1702. #==============================================================================
  1703. # Copyright (C)2003-2005 by Eric Sunshine <[email protected]>
  1704. #
  1705. # This library is free software; you can redistribute it and/or modify it
  1706. # under the terms of the GNU Library General Public License as published by
  1707. # the Free Software Foundation; either version 2 of the License, or (at your
  1708. # option) any later version.
  1709. #
  1710. # This library is distributed in the hope that it will be useful, but
  1711. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  1712. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
  1713. # License for more details.
  1714. #
  1715. # You should have received a copy of the GNU Library General Public License
  1716. # along with this library; if not, write to the Free Software Foundation,
  1717. # Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1718. #
  1719. #==============================================================================
  1720. AC_PREREQ([2.56])
  1721. #------------------------------------------------------------------------------
  1722. # CS_EMIT_BUILD_PROPERTY(KEY, VALUE, [APPEND], [EMPTY-OKAY], [EMITTER],
  1723. # [UNCONDITIONAL])
  1724. # A utility function which invokes an emitter to record the KEY/VALUE
  1725. # tuple if VALUE is not the empty string (after leading and trailing
  1726. # whitespace is stripped). If EMPTY-OKAY is not an empty string, then the
  1727. # property is emitted even if VALUE is empty; that is, it is emitted
  1728. # unconditionally. If APPEND is the empty string, then the emitter sets
  1729. # the key's value directly (though it may be overridden by the
  1730. # environment), otherwise the emitter appends VALUE to the existing value
  1731. # of the key. EMITTER is a macro name, such as CS_JAMCONFIG_PROPERTY or
  1732. # CS_MAKEFILE_PROPERTY, which performs the actual task of emitting the
  1733. # KEY/VALUE tuple; it should also accept APPEND as an optional third
  1734. # argument. If EMITTER is omitted, CS_JAMCONFIG_PROPERTY is used. Some
  1735. # emitters accept an optional fourth argument, UNCONDITIONAL, which
  1736. # instructs it to set KEY's value unconditionally, even if KEY already
  1737. # had been assigned a value via some other mechanism (such as imported
  1738. # from the environment, or from Jambase, in the case of
  1739. # CS_JAMCONFIG_PROPERTY).
  1740. #------------------------------------------------------------------------------
  1741. AC_DEFUN([CS_EMIT_BUILD_PROPERTY],
  1742. [cs_build_prop_val="$2"
  1743. cs_build_prop_val=CS_TRIM([$cs_build_prop_val])
  1744. m4_ifval([$4],
  1745. [CS_JAMCONFIG_PROPERTY([$1], [$cs_build_prop_val], [$3])],
  1746. AS_IF([test -n "$cs_build_prop_val"],
  1747. [m4_default([$5],[CS_JAMCONFIG_PROPERTY])(
  1748. [$1], [$cs_build_prop_val], [$3], [$6])]))])
  1749. #------------------------------------------------------------------------------
  1750. # CS_EMIT_BUILD_RESULT(CACHE-VAR, PREFIX, [EMITTER])
  1751. # Record the results of CS_CHECK_BUILD() or CS_CHECK_LIB_WITH() via some
  1752. # emitter. If CACHE-VAR indicates that the build succeeded, then the
  1753. # following properties are emitted:
  1754. #
  1755. # PREFIX.AVAILABLE = yes
  1756. # PREFIX.CFLAGS = $CACHE-VAR_cflags
  1757. # PREFIX.LFLAGS = $CACHE-VAR_lflags $CACHE-VAR_libs
  1758. #
  1759. # EMITTER is a macro name, such as CS_JAMCONFIG_PROPERTY or
  1760. # CS_MAKEFILE_PROPERTY, which performs the actual task of emitting the
  1761. # KEY/VALUE tuple. If EMITTER is omitted, CS_JAMCONFIG_PROPERTY is used.
  1762. #------------------------------------------------------------------------------
  1763. AC_DEFUN([CS_EMIT_BUILD_RESULT],
  1764. [AS_IF([test "$$1" = yes],
  1765. [CS_EMIT_BUILD_PROPERTY([$2.AVAILABLE], [yes], [], [], [$3])
  1766. CS_EMIT_BUILD_PROPERTY([$2.CFLAGS], [$$1_cflags], [], [], [$3])
  1767. CS_EMIT_BUILD_PROPERTY([$2.LFLAGS], [$$1_lflags $$1_libs],
  1768. [], [], [$3])])])
  1769. #------------------------------------------------------------------------------
  1770. # CS_EMIT_BUILD_FLAGS(MESSAGE, CACHE-VAR, FLAGS, [LANGUAGE], EMITTER-KEY,
  1771. # [APPEND], [ACTION-IF-RECOGNIZED],
  1772. # [ACTION-IF-NOT-RECOGNIZED], [EMITTER])
  1773. # A convenience wrapper for CS_CHECK_BUILD_FLAGS() which also records the
  1774. # results via CS_EMIT_BUILD_PROPERTY(). Checks if the compiler or linker
  1775. # recognizes a command-line option. MESSAGE is the "checking" message.
  1776. # CACHE-VAR is the shell cache variable which receives the flag
  1777. # recognized by the compiler or linker, or "no" if the flag was not
  1778. # recognized. FLAGS is a whitespace- delimited list of build tuples
  1779. # created with CS_CREATE_TUPLE(). Each tuple from FLAGS is attempted in
  1780. # order until one is found which is recognized by the compiler. After
  1781. # that, no further flags are checked. LANGUAGE is typically either C or
  1782. # C++ and specifies which compiler to use for the test. If LANGUAGE is
  1783. # omitted, C is used. EMITTER-KEY is the name to pass as the emitter's
  1784. # "key" argument if a usable flag is encountered. If APPEND is not the
  1785. # empty string, then the discovered flag is appended to the existing
  1786. # value of the EMITTER-KEY. If the command-line option was recognized,
  1787. # then ACTION-IF-RECOGNIZED is invoked, otherwise
  1788. # ACTION-IF-NOT-RECOGNIZED is invoked. EMITTER is a macro name, such as
  1789. # CS_JAMCONFIG_PROPERTY or CS_MAKEFILE_PROPERTY, which performs the
  1790. # actual task of emitting the KEY/VALUE tuple; it should also accept
  1791. # APPEND as an optional third argument. If EMITTER is omitted,
  1792. # CS_JAMCONFIG_PROPERTY is used.
  1793. #------------------------------------------------------------------------------
  1794. AC_DEFUN([CS_EMIT_BUILD_FLAGS],
  1795. [CS_CHECK_BUILD_FLAGS([$1], [$2], [$3], [$4],
  1796. [CS_EMIT_BUILD_PROPERTY([$5], [$$2], [$6], [], [$9])
  1797. $7],
  1798. [$8])])
  1799. #------------------------------------------------------------------------------
  1800. # CS_EMITTER_OPTIONAL([EMITTER])
  1801. # The CS_EMIT_FOO() macros optionally accept an emitter. If no emitter is
  1802. # supplied to those macros, then a default emitter is chosen. Other
  1803. # macros, however, which perform testing and optionally emit the results
  1804. # may wish to interpret an omitted EMITTER as a request not to emit the
  1805. # results. CS_EMITTER_OPTIONAL() is a convenience macro to help in these
  1806. # cases. It should be passed to one of the CS_EMIT_FOO() macros in place
  1807. # of the literal EMITTER argument. It functions by re-interpretating
  1808. # EMITTER as follows:
  1809. #
  1810. # - If EMITTER is omitted, then CS_NULL_EMITTER is returned, effectively
  1811. # disabling output by the CS_EMIT_FOO() macro.
  1812. # - If EMITTER is the literal string "emit" or "yes", then it returns an
  1813. # empty string, which signals to the CS_EMIT_FOO() macro that is should
  1814. # use its default emitter.
  1815. # - Any other value for EMITTER is passed along as-is to the
  1816. # CS_EMIT_FOO() macro.
  1817. #------------------------------------------------------------------------------
  1818. AC_DEFUN([CS_EMITTER_OPTIONAL],
  1819. [m4_case([$1],
  1820. [], [[CS_NULL_EMITTER]],
  1821. [emit], [],
  1822. [yes], [],
  1823. [[$1]])])
  1824. #------------------------------------------------------------------------------
  1825. # CS_NULL_EMITTER(KEY, VALUE, [APPEND])
  1826. # A do-nothing emitter suitable for use as the EMITTER argument of one of
  1827. # the CS_EMIT_FOO() macros.
  1828. #------------------------------------------------------------------------------
  1829. AC_DEFUN([CS_NULL_EMITTER], [:
  1830. ])
  1831. #------------------------------------------------------------------------------
  1832. # CS_SUBST_EMITTER(KEY, VALUE, [APPEND])
  1833. # An emitter wrapped around AC_SUBST(). Invokes
  1834. # AC_SUBST(AS_TR_SH(KEY),VALUE). The APPEND argument is ignored.
  1835. # Suitable for use as the EMITTER argument of one of the CS_EMIT_FOO()
  1836. # macros. The call to AS_TR_SH() ensures that KEY is transformed into a
  1837. # valid shell variable. For instance, if a macro attempts to emit
  1838. # MYLIB.CFLAGS and MYLIB.LFLAGS via CS_SUBST_EMITTER(), then the names
  1839. # will be transformed to MYLIB_CFLAGS and MYLIB_LFLAGS, respectively, for
  1840. # the invocation of AC_SUBST().
  1841. #------------------------------------------------------------------------------
  1842. AC_DEFUN([CS_SUBST_EMITTER], [AC_SUBST(AS_TR_SH([$1]),[$2])])
  1843. #------------------------------------------------------------------------------
  1844. # CS_DEFINE_EMITTER(KEY, VALUE, [APPEND])
  1845. # An emitter wrapped around AC_DEFINE_UNQUOTED(). Invokes
  1846. # AC_DEFINE_UNQUOTED(AS_TR_CPP(KEY),VALUE). The APPEND argument is
  1847. # ignored. Suitable for use as the EMITTER argument of one of the
  1848. # CS_EMIT_FOO() macros. The call to AS_TR_CPP() ensures that KEY is a
  1849. # well-formed token for the C-preprocessor.
  1850. #------------------------------------------------------------------------------
  1851. AC_DEFUN([CS_DEFINE_EMITTER],
  1852. [AC_DEFINE_UNQUOTED(AS_TR_CPP([$1]),[$2],
  1853. [Define when feature is available])])
  1854. # headercache.m4 -*- Autoconf -*-
  1855. #==============================================================================
  1856. # Copyright (C)2003 by Eric Sunshine <[email protected]>
  1857. #
  1858. # This library is free software; you can redistribute it and/or modify it
  1859. # under the terms of the GNU Library General Public License as published by
  1860. # the Free Software Foundation; either version 2 of the License, or (at your
  1861. # option) any later version.
  1862. #
  1863. # This library is distributed in the hope that it will be useful, but
  1864. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  1865. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
  1866. # License for more details.
  1867. #
  1868. # You should have received a copy of the GNU Library General Public License
  1869. # along with this library; if not, write to the Free Software Foundation,
  1870. # Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1871. #
  1872. #==============================================================================
  1873. AC_PREREQ([2.56])
  1874. #------------------------------------------------------------------------------
  1875. # Text cache facility for C-style #define properties. The cache is stored in
  1876. # the shell variable cs_header_text.
  1877. #
  1878. # CS_HEADER_APPEND(TEXT)
  1879. # Append text to the C header text cache. This is a cover for
  1880. # CS_TEXT_CACHE_APPEND().
  1881. #
  1882. # CS_HEADER_PREPEND(TEXT)
  1883. # Prepend text to the C header text cache. This is a cover for
  1884. # CS_TEXT_CACHE_PREPEND().
  1885. #
  1886. # CS_HEADER_PROPERTY(KEY, [VALUE])
  1887. # Append a line of the form "#define KEY VALUE" to the C header text
  1888. # cache. If the VALUE argument is omitted, then the appended line has
  1889. # the simplified form "#define KEY".
  1890. #
  1891. # CS_HEADER_OUTPUT(FILENAME)
  1892. # Instruct config.status to write the C header text cache to the given
  1893. # filename. This is a cover for CS_TEXT_CACHE_OUTPUT().
  1894. #------------------------------------------------------------------------------
  1895. AC_DEFUN([CS_HEADER_APPEND], [CS_TEXT_CACHE_APPEND([cs_header_text], [$1])])
  1896. AC_DEFUN([CS_HEADER_PREPEND], [CS_TEXT_CACHE_PREPEND([cs_header_text], [$1])])
  1897. AC_DEFUN([CS_HEADER_PROPERTY],
  1898. [CS_HEADER_APPEND([@%:@define $1[]m4_ifval([$2], [ $2], [])
  1899. ])])
  1900. AC_DEFUN([CS_HEADER_OUTPUT], [CS_TEXT_CACHE_OUTPUT([cs_header_text], [$1])])
  1901. #-----------------------------------------------------------------------------
  1902. # installdirs.m4 (c) Matze Braun <[email protected]>
  1903. # Macro for emitting the installation paths gathered by Autoconf.
  1904. #
  1905. # This library is free software; you can redistribute it and/or modify it
  1906. # under the terms of the GNU Library General Public License as published by
  1907. # the Free Software Foundation; either version 2 of the License, or (at your
  1908. # option) any later version.
  1909. #
  1910. # This library is distributed in the hope that it will be useful, but
  1911. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  1912. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
  1913. # License for more details.
  1914. #
  1915. # You should have received a copy of the GNU Library General Public License
  1916. # along with this library; if not, write to the Free Software Foundation,
  1917. # Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1918. #
  1919. #-----------------------------------------------------------------------------
  1920. #-----------------------------------------------------------------------------
  1921. # CS_OUTPUT_INSTALLDIRS([EMITTER], [RAW-BACKSLASHES])
  1922. # Emit installation directories collected by Autoconf. EMITTER is a macro
  1923. # name, such as CS_JAMCONFIG_PROPERTY or CS_MAKEFILE_PROPERTY, which performs
  1924. # the actual task of emitting the KEY/VALUE tuple. If EMITTER is omitted,
  1925. # CS_JAMCONFIG_PROPERTY is used. If RAW-BACKSLASHES is not provided, then
  1926. # backslashes in emitted values are each escaped with an additional
  1927. # backslash. If RAW-BACKSLASHES is not the null value, then backslashes are
  1928. # emitted raw. The following properties are emitted:
  1929. #
  1930. # prefix
  1931. # exec_prefix
  1932. # bindir
  1933. # sbindir
  1934. # libexecdir
  1935. # datadir
  1936. # sysconfdir
  1937. # sharedstatedir
  1938. # localstatedir
  1939. # libdir
  1940. # includedir
  1941. # oldincludedir
  1942. # infodir
  1943. # mandir
  1944. #-----------------------------------------------------------------------------
  1945. AC_DEFUN([CS_OUTPUT_INSTALLDIRS],[
  1946. # Handle the case when no prefix is given, and the special case when a path
  1947. # contains more than 2 slashes, these paths seem to be correct but Jam fails
  1948. # on them.
  1949. AS_IF([test $prefix = NONE],
  1950. [cs_install_prefix="$ac_default_prefix"],
  1951. [cs_install_prefix=`echo "$prefix" | sed -e 's:///*:/:g'`])
  1952. AS_IF([test $exec_prefix = NONE],
  1953. [cs_install_exec_prefix="AS_ESCAPE([$(prefix)])"],
  1954. [cs_install_exec_prefix=`echo "$exec_prefix" | sed -e 's:///*:/:g'`])
  1955. _CS_OUTPUT_INSTALL_DIRS([$1], [prefix],
  1956. [CS_PREPARE_INSTALLPATH([$cs_install_prefix], [$2])])
  1957. _CS_OUTPUT_INSTALL_DIRS([$1], [exec_prefix],
  1958. [CS_PREPARE_INSTALLPATH([$cs_install_exec_prefix], [$2])])
  1959. _CS_OUTPUT_INSTALL_DIRS([$1], [bindir],
  1960. [CS_PREPARE_INSTALLPATH([$bindir], [$2])])
  1961. _CS_OUTPUT_INSTALL_DIRS([$1], [sbindir],
  1962. [CS_PREPARE_INSTALLPATH([$sbindir], [$2])])
  1963. _CS_OUTPUT_INSTALL_DIRS([$1], [libexecdir],
  1964. [CS_PREPARE_INSTALLPATH([$libexecdir], [$2])])
  1965. _CS_OUTPUT_INSTALL_DIRS([$1], [datadir],
  1966. [CS_PREPARE_INSTALLPATH([$datadir], [$2])])
  1967. _CS_OUTPUT_INSTALL_DIRS([$1], [sysconfdir],
  1968. [CS_PREPARE_INSTALLPATH([$sysconfdir], [$2])])
  1969. _CS_OUTPUT_INSTALL_DIRS([$1], [sharedstatedir],
  1970. [CS_PREPARE_INSTALLPATH([$sharedstatedir], [$2])])
  1971. _CS_OUTPUT_INSTALL_DIRS([$1], [localstatedir],
  1972. [CS_PREPARE_INSTALLPATH([$localstatedir], [$2])])
  1973. _CS_OUTPUT_INSTALL_DIRS([$1], [libdir],
  1974. [CS_PREPARE_INSTALLPATH([$libdir], [$2])])
  1975. _CS_OUTPUT_INSTALL_DIRS([$1], [includedir],
  1976. [CS_PREPARE_INSTALLPATH([$includedir], [$2])])
  1977. _CS_OUTPUT_INSTALL_DIRS([$1], [oldincludedir],
  1978. [CS_PREPARE_INSTALLPATH([$oldincludedir], [$2])])
  1979. _CS_OUTPUT_INSTALL_DIRS([$1], [infodir],
  1980. [CS_PREPARE_INSTALLPATH([$infodir], [$2])])
  1981. _CS_OUTPUT_INSTALL_DIRS([$1], [mandir],
  1982. [CS_PREPARE_INSTALLPATH([$mandir], [$2])])
  1983. ])
  1984. AC_DEFUN([_CS_OUTPUT_INSTALL_DIRS],
  1985. [m4_default([$1], [CS_JAMCONFIG_PROPERTY])([$2], [$3])])
  1986. #-----------------------------------------------------------------------------
  1987. # CS_PREPARE_INSTALLPATH(VALUE, [RAW-BACKSLASHES])
  1988. # Transform variable references of the form ${bla} to $(bla) in VALUE and
  1989. # correctly quotes backslashes. This is needed if you need to emit some of
  1990. # the paths from Autoconf. RAW-BACKSLASHES has the same meaning as in
  1991. # CS_OUTPUT_INSTALLDIRS.
  1992. #-----------------------------------------------------------------------------
  1993. AC_DEFUN([CS_PREPARE_INSTALLPATH],
  1994. [`echo "$1" | sed 's/\${\([[a-zA-Z_][a-zA-Z_]]*\)}/$(\1)/g;m4_ifval([$2],
  1995. [s/\\/\\\\/g], [s/\\\\/\\\\\\\\/g])'`])
  1996. # jamcache.m4 -*- Autoconf -*-
  1997. #==============================================================================
  1998. # Copyright (C)2003 by Eric Sunshine <[email protected]>
  1999. #
  2000. # This library is free software; you can redistribute it and/or modify it
  2001. # under the terms of the GNU Library General Public License as published by
  2002. # the Free Software Foundation; either version 2 of the License, or (at your
  2003. # option) any later version.
  2004. #
  2005. # This library is distributed in the hope that it will be useful, but
  2006. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  2007. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
  2008. # License for more details.
  2009. #
  2010. # You should have received a copy of the GNU Library General Public License
  2011. # along with this library; if not, write to the Free Software Foundation,
  2012. # Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  2013. #
  2014. #==============================================================================
  2015. AC_PREREQ([2.56])
  2016. #------------------------------------------------------------------------------
  2017. # Text cache facility for Jam-style properties. The cache is stored in
  2018. # the shell variable cs_jamfile_text.
  2019. #
  2020. # CS_JAMCONFIG_APPEND(TEXT)
  2021. # Append text to the Jam text cache. This is a cover for
  2022. # CS_TEXT_CACHE_APPEND().
  2023. #
  2024. # CS_JAMCONFIG_PREPEND(TEXT)
  2025. # Prepend text to the Jam text cache. This is a cover for
  2026. # CS_TEXT_CACHE_PREPEND().
  2027. #
  2028. # CS_JAMCONFIG_PROPERTY(KEY, VALUE, [APPEND], [UNCONDITIONAL])
  2029. # Append a line of the form "KEY ?= VALUE" to the Jam text cache. If the
  2030. # APPEND argument is not the empty string, then VALUE is appended to the
  2031. # existing value of KEY using the form "KEY += VALUE". If the
  2032. # UNCONDITIONAL argument is not empty, then the value of KEY is set
  2033. # unconditionally "KEY = VALUE", rather than via "KEY ?= VALUE". APPEND
  2034. # takes precedence over UNCONDITIONAL. Note that if VALUE references
  2035. # other Jam variables, for example $(OBJS), then be sure to protect the
  2036. # value with AS_ESCAPE(). For example:
  2037. # CS_JAMCONFIG_PROPERTY([ALLOBJS], [AS_ESCAPE([$(OBJS) $(LIBOBJS)])])
  2038. #
  2039. # CS_JAMCONFIG_OUTPUT(FILENAME)
  2040. # Instruct config.status to write the Jam text cache to the given
  2041. # filename. This is a cover for CS_TEXT_CACHE_OUTPUT().
  2042. #------------------------------------------------------------------------------
  2043. AC_DEFUN([CS_JAMCONFIG_APPEND],
  2044. [CS_TEXT_CACHE_APPEND([cs_jamconfig_text], [$1])])
  2045. AC_DEFUN([CS_JAMCONFIG_PREPEND],
  2046. [CS_TEXT_CACHE_PREPEND([cs_jamconfig_text], [$1])])
  2047. AC_DEFUN([CS_JAMCONFIG_PROPERTY],
  2048. [CS_JAMCONFIG_APPEND(
  2049. [$1 m4_ifval([$3], [+=], m4_ifval([$4], [=], [?=])) \"$2\" ;
  2050. ])])
  2051. AC_DEFUN([CS_JAMCONFIG_OUTPUT],
  2052. [CS_TEXT_CACHE_OUTPUT([cs_jamconfig_text], [$1])])
  2053. # makecache.m4 -*- Autoconf -*-
  2054. #==============================================================================
  2055. # Copyright (C)2003 by Eric Sunshine <[email protected]>
  2056. #
  2057. # This library is free software; you can redistribute it and/or modify it
  2058. # under the terms of the GNU Library General Public License as published by
  2059. # the Free Software Foundation; either version 2 of the License, or (at your
  2060. # option) any later version.
  2061. #
  2062. # This library is distributed in the hope that it will be useful, but
  2063. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  2064. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
  2065. # License for more details.
  2066. #
  2067. # You should have received a copy of the GNU Library General Public License
  2068. # along with this library; if not, write to the Free Software Foundation,
  2069. # Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  2070. #
  2071. #==============================================================================
  2072. AC_PREREQ([2.56])
  2073. #------------------------------------------------------------------------------
  2074. # Text cache facility for makefile-style properties. The cache is stored in
  2075. # the shell variable cs_makefile_text.
  2076. #
  2077. # CS_MAKEFILE_APPEND(TEXT)
  2078. # Append text to the makefile text cache. This is a cover for
  2079. # CS_TEXT_CACHE_APPEND().
  2080. #
  2081. # CS_MAKEFILE_PREPEND(TEXT)
  2082. # Prepend text to the makefile text cache. This is a cover for
  2083. # CS_TEXT_CACHE_PREPEND().
  2084. #
  2085. # CS_MAKEFILE_PROPERTY(KEY, VALUE, [APPEND])
  2086. # Append a line of the form "KEY = VALUE" to the makefile text cache. If
  2087. # the APPEND argument is not the empty string, then VALUE is appended to
  2088. # the existing value of KEY using the form "KEY += VALUE". Note that if
  2089. # VALUE references other makefile variables, for example $(OBJS), then be
  2090. # sure to protect the value with AS_ESCAPE(). For example:
  2091. # CS_MAKEFILE_PROPERTY([ALLOBJS], [AS_ESCAPE([$(OBJS) $(LIBOBJS)])])
  2092. #
  2093. # CS_MAKEFILE_OUTPUT(FILENAME)
  2094. # Instruct config.status to write the makefile text cache to the given
  2095. # filename. This is a cover for CS_TEXT_CACHE_OUTPUT().
  2096. #------------------------------------------------------------------------------
  2097. AC_DEFUN([CS_MAKEFILE_APPEND],
  2098. [CS_TEXT_CACHE_APPEND([cs_makefile_text], [$1])])
  2099. AC_DEFUN([CS_MAKEFILE_PREPEND],
  2100. [CS_TEXT_CACHE_PREPEND([cs_makefile_text], [$1])])
  2101. AC_DEFUN([CS_MAKEFILE_PROPERTY],
  2102. [CS_MAKEFILE_APPEND([$1 m4_ifval([$3], [+=], [=]) $2
  2103. ])])
  2104. AC_DEFUN([CS_MAKEFILE_OUTPUT],[CS_TEXT_CACHE_OUTPUT([cs_makefile_text], [$1])])
  2105. # mkdir.m4 -*- Autoconf -*-
  2106. #==============================================================================
  2107. # Copyright (C)2003 by Eric Sunshine <[email protected]>
  2108. #
  2109. # This library is free software; you can redistribute it and/or modify it
  2110. # under the terms of the GNU Library General Public License as published by
  2111. # the Free Software Foundation; either version 2 of the License, or (at your
  2112. # option) any later version.
  2113. #
  2114. # This library is distributed in the hope that it will be useful, but
  2115. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  2116. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
  2117. # License for more details.
  2118. #
  2119. # You should have received a copy of the GNU Library General Public License
  2120. # along with this library; if not, write to the Free Software Foundation,
  2121. # Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  2122. #
  2123. #==============================================================================
  2124. AC_PREREQ([2.56])
  2125. #------------------------------------------------------------------------------
  2126. # CS_CHECK_MKDIR
  2127. # Determine how to create a directory and a directory tree. Sets the
  2128. # shell variable MKDIR to the command which creates a directory, and
  2129. # MKDIRS to the command which creates a directory tree. Invokes
  2130. # AC_SUBST() for MKDIR and MKDIRS.
  2131. #
  2132. # IMPLEMENTATION NOTES
  2133. # We need to know the exact commands, so that we can emit them, thus the
  2134. # AS_MKDIR_P function is not what we want to use here since it does not
  2135. # provide access to the commands (and might not even discover suitable
  2136. # commands). First try "mkdir -p", then try the older "mkdirs".
  2137. # Finally, if the mkdir command failed to recognize -p, then it might
  2138. # have created a directory named "-p", so clean up that bogus directory.
  2139. #------------------------------------------------------------------------------
  2140. AC_DEFUN([CS_CHECK_MKDIR],
  2141. [AC_CACHE_CHECK([how to create a directory], [cs_cv_shell_mkdir],
  2142. [cs_cv_shell_mkdir='mkdir'])
  2143. AC_SUBST([MKDIR], [$cs_cv_shell_mkdir])
  2144. AC_CACHE_CHECK([how to create a directory tree], [cs_cv_shell_mkdir_p],
  2145. [if $cs_cv_shell_mkdir -p . 2>/dev/null; then
  2146. cs_cv_shell_mkdir_p='mkdir -p'
  2147. elif mkdirs . 2>/dev/null; then
  2148. cs_cv_shell_mkdir_p='mkdirs'
  2149. fi
  2150. test -d ./-p && rmdir ./-p])
  2151. AS_VAR_SET_IF([cs_cv_shell_mkdir_p],
  2152. [AC_SUBST([MKDIRS], [$cs_cv_shell_mkdir_p])],
  2153. [CS_MSG_ERROR([do not know how to create a directory tree])])])
  2154. #------------------------------------------------------------------------------
  2155. # Replacement for AS_MKDIR_P() from m4sugar/m4sh.m4 which fixes two problems
  2156. # which are present in Autoconf 2.57 and probably all earlier 2.5x versions.
  2157. # This bug, along with a patch, was submitted to the Autoconf GNATS database by
  2158. # Eric Sunshine as #227 on 17-Dec-2002. The bogus "-p" directory bug was fixed
  2159. # for Autoconf 2.58 on 26-Sep-2003. The "mkdirs" optimization was not accepted
  2160. # (since it is unnecessary; it's only an optimization).
  2161. #
  2162. # 1) Removes bogus "-p" directory which the stock AS_MKDIR_P() leaves laying
  2163. # around in the working directory if the mkdir command does not recognize
  2164. # the -p option.
  2165. # 2) Takes advantage of the older "mkdirs" program if it exists and if "mkdir
  2166. # -p" does not work.
  2167. #------------------------------------------------------------------------------
  2168. m4_defun([_AS_MKDIR_P_PREPARE],
  2169. [if mkdir -p . 2>/dev/null; then
  2170. as_mkdir_p='mkdir -p'
  2171. elif mkdirs . 2>/dev/null; then
  2172. as_mkdir_p='mkdirs'
  2173. else
  2174. as_mkdir_p=''
  2175. fi
  2176. test -d ./-p && rmdir ./-p
  2177. ])# _AS_MKDIR_P_PREPARE
  2178. m4_define([AS_MKDIR_P],
  2179. [AS_REQUIRE([_$0_PREPARE])dnl
  2180. { if test -n "$as_mkdir_p"; then
  2181. $as_mkdir_p $1
  2182. else
  2183. as_dir=$1
  2184. as_dirs=
  2185. while test ! -d "$as_dir"; do
  2186. as_dirs="$as_dir $as_dirs"
  2187. as_dir=`AS_DIRNAME("$as_dir")`
  2188. done
  2189. test ! -n "$as_dirs" || mkdir $as_dirs
  2190. fi || AS_ERROR([cannot create directory $1]); }
  2191. ])# AS_MKDIR_P
  2192. #==============================================================================
  2193. # packageinfo.m4
  2194. # Macros for setting general info on the package, such as name and version
  2195. # numbers and propagate them to the generated make and Jam property files.
  2196. #
  2197. # Copyright (C)2003 by Matthias Braun <[email protected]>
  2198. # Copyright (C)2003,2004 by Eric Sunshine <[email protected]>
  2199. #
  2200. # This library is free software; you can redistribute it and/or modify it
  2201. # under the terms of the GNU Library General Public License as published by
  2202. # the Free Software Foundation; either version 2 of the License, or (at your
  2203. # option) any later version.
  2204. #
  2205. # This library is distributed in the hope that it will be useful, but
  2206. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  2207. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
  2208. # License for more details.
  2209. #
  2210. # You should have received a copy of the GNU Library General Public License
  2211. # along with this library; if not, write to the Free Software Foundation,
  2212. # Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  2213. #
  2214. #==============================================================================
  2215. #------------------------------------------------------------------------------
  2216. # CS_PACKAGEINFO([LONGNAME], [COPYRIGHT, [HOMEPAGE])
  2217. # Set additional information for the package. Note that the version
  2218. # number of your application should only contain numbers, because on
  2219. # Windows you can only set numerical values in some of the file
  2220. # properties (such as versioninfo .rc files).
  2221. #------------------------------------------------------------------------------
  2222. AC_DEFUN([CS_PACKAGEINFO],
  2223. [PACKAGE_LONGNAME="[$1]"
  2224. PACKAGE_COPYRIGHT="[$2]"
  2225. PACKAGE_HOMEPAGE="[$3]"
  2226. ])
  2227. #------------------------------------------------------------------------------
  2228. # CS_EMIT_PACKAGEINFO([EMITTER])
  2229. # Emit extended package information using the provided EMITTER. EMITTER
  2230. # is a macro name, such as CS_JAMCONFIG_PROPERTY or CS_MAKEFILE_PROPERTY,
  2231. # which performs the actual task of emitting the KEY/VALUE tuple. If
  2232. # EMITTER is omitted, CS_JAMCONFIG_PROPERTY is used. For backward
  2233. # compatibility, if EMITTER is the literal value "jam", then
  2234. # CS_JAMCONFIG_PROPERTY is used; if it is "make", then
  2235. # CS_MAKEFILE_PROPERTY is used; however use of these literal names is
  2236. # highly discouraged.
  2237. #------------------------------------------------------------------------------
  2238. AC_DEFUN([CS_EMIT_PACKAGEINFO],
  2239. [_CS_EMIT_PACKAGEINFO([$1], [PACKAGE_NAME], [$PACKAGE_NAME])
  2240. _CS_EMIT_PACKAGEINFO([$1], [PACKAGE_VERSION], [$PACKAGE_VERSION])
  2241. _CS_EMIT_PACKAGEINFO([$1], [PACKAGE_STRING], [$PACKAGE_STRING])
  2242. _CS_EMIT_PACKAGEINFO([$1], [PACKAGE_BUGREPORT], [$PACKAGE_BUGREPORT])
  2243. _CS_EMIT_PACKAGEINFO([$1], [PACKAGE_LONGNAME], [$PACKAGE_LONGNAME])
  2244. _CS_EMIT_PACKAGEINFO([$1], [PACKAGE_HOMEPAGE], [$PACKAGE_HOMEPAGE])
  2245. _CS_EMIT_PACKAGEINFO([$1], [PACKAGE_COPYRIGHT], [$PACKAGE_COPYRIGHT])
  2246. for cs_veritem in m4_translit(AC_PACKAGE_VERSION, [.], [ ]); do
  2247. _CS_EMIT_PACKAGEINFO([$1], [PACKAGE_VERSION_LIST], [$cs_veritem], [+])
  2248. done
  2249. ])
  2250. AC_DEFUN([_CS_EMIT_PACKAGEINFO],
  2251. [m4_case([$1],
  2252. [make], [CS_MAKEFILE_PROPERTY([$2], [$3], [$4])],
  2253. [jam], [CS_JAMCONFIG_PROPERTY([$2], [$3], [$4])],
  2254. [], [CS_JAMCONFIG_PROPERTY([$2], [$3], [$4])],
  2255. [$1([$2], [$3], [$4])])])
  2256. # path.m4 -*- Autoconf -*-
  2257. #==============================================================================
  2258. # Copyright (C)2004 by Eric Sunshine <[email protected]>
  2259. #
  2260. # This library is free software; you can redistribute it and/or modify it
  2261. # under the terms of the GNU Library General Public License as published by
  2262. # the Free Software Foundation; either version 2 of the License, or (at your
  2263. # option) any later version.
  2264. #
  2265. # This library is distributed in the hope that it will be useful, but
  2266. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  2267. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
  2268. # License for more details.
  2269. #
  2270. # You should have received a copy of the GNU Library General Public License
  2271. # along with this library; if not, write to the Free Software Foundation,
  2272. # Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  2273. #
  2274. #==============================================================================
  2275. AC_PREREQ([2.56])
  2276. #------------------------------------------------------------------------------
  2277. # CS_PATH_NORMALIZE(STRING)
  2278. # Normalize a pathname at run-time by transliterating Windows/DOS
  2279. # backslashes to forward slashes. Also collapses whitespace.
  2280. #------------------------------------------------------------------------------
  2281. AC_DEFUN([CS_PATH_NORMALIZE],
  2282. [`echo "x$1" | tr '\\\\' '/' | sed 's/^x//;s/ */ /g;s/^ //;s/ $//'`])
  2283. #------------------------------------------------------------------------------
  2284. # CS_RUN_PATH_NORMALIZE(COMMAND)
  2285. # Normalize the pathname emitted by COMMAND by transliterating
  2286. # Windows/DOS backslashes to forward slashes. Also collapses whitespace.
  2287. #------------------------------------------------------------------------------
  2288. AC_DEFUN([CS_RUN_PATH_NORMALIZE],
  2289. [`AC_RUN_LOG([$1]) | tr '\\\\' '/' | sed 's/^x//;s/ */ /g;s/^ //;s/ $//'`])
  2290. ###############################################################################
  2291. # progver.m4
  2292. # Written by Norman Kramer <[email protected]>
  2293. #
  2294. # This library is free software; you can redistribute it and/or modify it
  2295. # under the terms of the GNU Library General Public License as published by
  2296. # the Free Software Foundation; either version 2 of the License, or (at your
  2297. # option) any later version.
  2298. #
  2299. # This library is distributed in the hope that it will be useful, but
  2300. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  2301. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
  2302. # License for more details.
  2303. #
  2304. # You should have received a copy of the GNU Library General Public License
  2305. # along with this library; if not, write to the Free Software Foundation,
  2306. # Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  2307. #
  2308. ###############################################################################
  2309. #
  2310. # From the input pattern we create regular expressions we send through sed
  2311. # to extract the version information from the standard input to sed.
  2312. # Then we extract from the resulting version string subparts.
  2313. # The same happens with the supplied version string. It too is split into its
  2314. # subparts according to the pattern.
  2315. # Then the subparts from the gathered version string and the supplied one are
  2316. # compared.
  2317. #
  2318. # How does the pattern look like ?
  2319. # It is a sequence of 9s and _s and separators.
  2320. # 9 denotes a non empty sequence of digits.
  2321. # _ denotes a non empty sequence of characters from the class [a-zA-Z].
  2322. # | everything behind is optional
  2323. # Everything else is treated as a separator.
  2324. # Consecutive 9s and _s are compressed to contain only one of each type.
  2325. # For instance "99_.9.__abc9_" will become "9_.9._abc9_".
  2326. #
  2327. # How we find the parts we compare ?
  2328. # From this transformed string we yield the parts we will later compare.
  2329. # We break up the string as follows:
  2330. # Any sequence of separators represent one breakup. Additional breakups are
  2331. # placed behind every 9 and _ .
  2332. # So the example from above will give:
  2333. #
  2334. # "99_.9.__abc9_" ===compress==> "9_.9._abc9_" ===breakup==> "9" "_" "9" "_" "9" "_"
  2335. #
  2336. # How we create the regular expressions ?
  2337. # We take the compressed pattern and quote every separator.
  2338. # The we replace the 9s with [0-9][0-9]*
  2339. # and the _s with [a-zA-Z][a-zA-Z]* .
  2340. # The above example will become:
  2341. #
  2342. # "99_.9.__abc9_" ===compress==> "9_.9._abc9_" ===rexify==>
  2343. # [0-9][0-9]*[a-zA-Z][a-zA-Z]*\.[0-9][0-9]*\.[a-zA-Z][a-zA-Z]*\a\b\c[0-9][0-9]*[a-zA-Z][a-zA-Z]*
  2344. #
  2345. # Voila.
  2346. #
  2347. # To yield the subparts from the string we additionally enclose the
  2348. # 9s and _s with \( and \).
  2349. #
  2350. ###############################################################################
  2351. # ****************************************************************
  2352. # ** helper definitions **
  2353. # ****************************************************************
  2354. m4_define([CS_VCHK_RUNTH], [m4_pushdef([i], [$1])m4_if($1,0,,[CS_VCHK_RUNTH(m4_decr($1), [$2])][$2])m4_popdef([i])])
  2355. m4_define([CS_VCHK_PREFIX], [])
  2356. m4_define([CS_VCHK_SUFFIX], [])
  2357. m4_define([CS_VCHK_GROUPPREFIX], [\(])
  2358. m4_define([CS_VCHK_GROUPSUFFIX], [\)])
  2359. m4_define([CS_VCHK_CHAR], [[[[a-zA-Z]]]])
  2360. m4_define([CS_VCHK_DIGIT], [[[0-9]]])
  2361. m4_define([CS_VCHK_SEQUENCE], [CS_VCHK_PREFIX[]CS_VCHK_SINGLE[]CS_VCHK_SINGLE[]*CS_VCHK_SUFFIX[]])
  2362. m4_define([CS_VCHK_OPTSEQUENCE], [CS_VCHK_PREFIX[]CS_VCHK_SINGLE[]*CS_VCHK_SUFFIX[]])
  2363. m4_define([CS_VCHK_REXSEQ], [m4_bpatsubst($1, [$2], [[]CS_VCHK_SEQUENCE[]])])
  2364. m4_define([CS_VCHK_GROUPINGON], [m4_pushdef([CS_VCHK_PREFIX], [CS_VCHK_GROUPPREFIX])m4_pushdef([CS_VCHK_SUFFIX], [CS_VCHK_GROUPSUFFIX])])
  2365. m4_define([CS_VCHK_GROUPINGOFF], [m4_popdef([CS_VCHK_SUFFIX])m4_popdef([CS_VCHK_PREFIX])])
  2366. m4_define([CS_VCHK_OPTON], [m4_pushdef([CS_VCHK_SEQUENCE], [CS_VCHK_OPTSEQUENCE])])
  2367. m4_define([CS_VCHK_OPTOFF], [m4_popdef([CS_VCHK_SEQUENCE])])
  2368. m4_define([CS_VCHK_RMOPT], [CS_VCHK_RMCHAR([$1], m4_index([$1], [|]))])
  2369. m4_define([CS_VCHK_RMCHAR], [m4_if($2,-1,[$1],m4_substr([$1], 0, $2)[]m4_substr([$1], m4_incr($2)))])
  2370. m4_define([CS_VCHK_RMALL], [m4_translit([$1], [|], [])])
  2371. m4_define([CS_VCHK_CUTOFF], [m4_if(m4_index($1,[|]),-1, [$1], [m4_substr($1, 0, m4_index($1,[|]))])])
  2372. m4_define([CS_VCHK_CYCLEOPT], [
  2373. m4_if($2,-1,, [m4_pushdef([i], CS_VCHK_CUTOFF([$1])) m4_pushdef([j], CS_VCHK_DUMMY_TAIL([$1])) CS_VCHK_CYCLEOPT( CS_VCHK_RMOPT([$1]), m4_index($1, [|]), [$3])$3 m4_popdef([i]) m4_popdef([j])])
  2374. ])
  2375. m4_define([CS_VCHK_TAIL], [m4_if(m4_index($1,[|]),-1, [], [m4_substr($1, m4_incr(m4_index($1,[|])))])])
  2376. m4_define([CS_VCHK_DUMMY_COMPRESS], [m4_bpatsubst(m4_bpatsubst([$1], [__*], [A]), [99*], [0])])
  2377. m4_define([CS_VCHK_DUMMY_TAIL], [CS_VCHK_DUMMY_COMPRESS(m4_translit(CS_VCHK_TAIL([$1]), [|], []))])
  2378. # ****************************************************************
  2379. # ** FlagsOn / FlagsOff **
  2380. # ****************************************************************
  2381. m4_define([CS_VCHK_FLAGSON],
  2382. [m4_if($#, 0, [],
  2383. $1, [], [],
  2384. [$1], [group], [CS_VCHK_GROUPINGON[]],
  2385. [$1], [opt], [CS_VCHK_OPTON[]])dnl
  2386. m4_if($#, 0, [], $1, [], [], [CS_VCHK_FLAGSON(m4_shift($@))])])
  2387. m4_define([CS_VCHK_FLAGSOFF],
  2388. [m4_if($#, 0, [],
  2389. $1, [], [],
  2390. $1, [group], [CS_VCHK_GROUPINGOFF[]],
  2391. [$1], [opt], [CS_VCHK_OPTOFF[]])dnl
  2392. m4_if($#, 0, [], $1, [], [], [CS_VCHK_FLAGSOFF(m4_shift($@))])])
  2393. # ****************************************************************
  2394. # ** rexify / sedify **
  2395. # ****************************************************************
  2396. m4_define([CS_VCHK_REXIFY],
  2397. [m4_pushdef([CS_VCHK_SINGLE], [$1])dnl
  2398. CS_VCHK_FLAGSON(m4_shift(m4_shift(m4_shift($@))))dnl
  2399. CS_VCHK_REXSEQ([$3], [$2])dnl
  2400. CS_VCHK_FLAGSOFF(m4_shift(m4_shift(m4_shift($@))))dnl
  2401. m4_popdef([CS_VCHK_SINGLE])])
  2402. m4_define([CS_VCHK_QUOTESEP], [m4_bpatsubst($1, [[^9_]], [\\\&])])
  2403. m4_define([CS_VCHK_REXCHAR], [CS_VCHK_REXIFY([CS_VCHK_CHAR], [__*], $@)])
  2404. m4_define([CS_VCHK_REXDIGIT], [CS_VCHK_REXIFY([CS_VCHK_DIGIT], [99*], $@)])
  2405. m4_define([CS_VCHK_SEDIFY], [CS_VCHK_REXDIGIT([CS_VCHK_REXCHAR([CS_VCHK_QUOTESEP([$1])], m4_shift($@))], m4_shift($@))])
  2406. m4_define([CS_VCHK_SEDEXPRALL], [/CS_VCHK_SEDIFY([$1])/!d;s/.*\(CS_VCHK_SEDIFY([$1])\).*/\1/;q])
  2407. m4_define([CS_VCHK_SEDEXPRNTH], [/CS_VCHK_SEDIFY([$1])/!d;s/.*CS_VCHK_SEDIFY([$1],[group]).*/\$2/])
  2408. # ****************************************************************
  2409. # ** Pattern splitting **
  2410. # ****************************************************************
  2411. m4_define([CS_VCHK_SPLITSEP], [CS_VCHK_REXIFY([s], [[^9_][^9_]*], $@)])
  2412. m4_define([CS_VCHK_SPLITDIGIT], [CS_VCHK_REXIFY([d], [99*], $@)])
  2413. m4_define([CS_VCHK_SPLITCHAR], [CS_VCHK_REXIFY([c], [__*], $@)])
  2414. # ****************************************************************
  2415. # ** return a list of 's' 'd' 'c' 'e' chars denoting the kind **
  2416. # ** pattern parts: separator, digit, char, end **
  2417. # ****************************************************************
  2418. m4_define([CS_VCHK_PATTERNLIST], [m4_pushdef([CS_VCHK_SEQUENCE], [CS_VCHK_SINGLE ])dnl
  2419. m4_translit(CS_VCHK_SPLITDIGIT([CS_VCHK_SPLITCHAR([CS_VCHK_SPLITSEP([$1])])]), [ ], m4_if([$2],[],[ ],[$2]))e[]dnl
  2420. m4_popdef([CS_VCHK_SEQUENCE])])
  2421. # ****************************************************************
  2422. # ** Build the shell commands we emit to the configure script. **
  2423. # ****************************************************************
  2424. m4_define([CS_VCHK_PATCOUNT], [m4_len(m4_bpatsubst(CS_VCHK_PATTERNLIST([$1]), [[^dc]]))])
  2425. # ****************************************************************************************
  2426. # ** CS_VCHK_EXTRACTVERSION(EXTRACT_CALL, MIN_VERSION, PATTERN, PRGPREFIX, COMPARISION) **
  2427. # ****************************************************************************************
  2428. m4_define([CS_VCHK_EXTRACTVERSION],
  2429. [cs_prog_$4_is_version=
  2430. cs_prog_$4_min_version=
  2431. cs_prog_$4_is_suffix=
  2432. cs_prog_$4_min_suffix=
  2433. cs_prog_$4_is_suffix_done=
  2434. cs_prog_$4_min_suffix_done=
  2435. CS_VCHK_CYCLEOPT([$3], [],
  2436. [test -z $cs_prog_$4_is_version && cs_prog_$4_is_version=`$1 | sed 'CS_VCHK_SEDEXPRALL([i])'`
  2437. test -n "$cs_prog_$4_is_version" && test -z $cs_prog_$4_is_suffix_done && { cs_prog_$4_is_suffix_done=yes ; cs_prog_$4_is_suffix=j ; }
  2438. ])
  2439. CS_VCHK_CYCLEOPT([$3], ,
  2440. [test -z $cs_prog_$4_min_version && cs_prog_$4_min_version=`echo $2 | sed 'CS_VCHK_SEDEXPRALL([i])'`
  2441. test -n "$cs_prog_$4_min_version" && test -z $cs_prog_$4_min_suffix_done && { cs_prog_$4_min_suffix_done=yes ; cs_prog_$4_min_suffix=j ; }
  2442. ])
  2443. CS_VCHK_RUNTH([CS_VCHK_PATCOUNT([$3])],
  2444. [cs_prog_$4_is_ver_[]i=`echo ${cs_prog_$4_is_version}${cs_prog_$4_is_suffix} | sed 'CS_VCHK_SEDEXPRNTH([CS_VCHK_RMALL([$3])], [i])'`
  2445. ])
  2446. CS_VCHK_RUNTH([CS_VCHK_PATCOUNT([$3])],
  2447. [cs_prog_$4_min_ver_[]i=`echo $cs_prog_$4_min_version${cs_prog_$4_min_suffix} | sed 'CS_VCHK_SEDEXPRNTH([CS_VCHK_RMALL([$3])], [i])'`
  2448. ])
  2449. cs_cv_prog_$4_version_ok=''
  2450. CS_VCHK_RUNTH([CS_VCHK_PATCOUNT([$3])],
  2451. [test -z "$cs_cv_prog_$4_version_ok" && { expr "$cs_prog_$4_is_ver_[]i" "$5" "$cs_prog_$4_min_ver_[]i" >/dev/null || cs_cv_prog_$4_version_ok=no ; }
  2452. test -z "$cs_cv_prog_$4_version_ok" && { expr "$cs_prog_$4_min_ver_[]i" "$5" "$cs_prog_$4_is_ver_[]i" >/dev/null || cs_cv_prog_$4_version_ok=yes ; }
  2453. ])
  2454. AS_IF([test -z "$cs_cv_prog_$4_version_ok"], [cs_cv_prog_$4_version_ok=yes])
  2455. cs_cv_prog_$4_version_ok_annotated="$cs_cv_prog_$4_version_ok"
  2456. AS_IF([test -n "$cs_prog_$4_is_version"],
  2457. [cs_cv_prog_$4_version_ok_annotated="$cs_cv_prog_$4_version_ok_annotated (version $cs_prog_$4_is_version)"])
  2458. ])
  2459. ##############################################################################
  2460. # CS_CHECK_PROG_VERSION(PROG, EXTRACT_CALL, VERSION, PATTERN,
  2461. # [ACTION-IF-OKAY], [ACTION-IF-NOT-OKAY], [CMP])
  2462. # Check the version of a program PROG.
  2463. # Version information is emitted by EXTRACT_CALL (for instance "bison -V").
  2464. # The discovered program version is compared against VERSION.
  2465. # The pattern of the version string matches PATTERN
  2466. # The extracted version and the supplied version are compared with the CMP
  2467. # operator. i.e. EXTRACTED_VERSION CMP SUPPLIED_VERSION
  2468. # CMP defaults to >= if not specified.
  2469. # ACTION-IF-OKAY is invoked if comparision yields true, otherwise
  2470. # ACTION-IF-NOT-OKAY is invoked.
  2471. #
  2472. # PATTERN literals: 9 .. marks a non empty sequence of digits
  2473. # _ .. marks a non empty sequence of characters from [a-zA-Z]
  2474. # | .. everything behind is optional
  2475. # .. everything else is taken as separator - it is better
  2476. # to not try stuff like space, slash or comma.
  2477. #
  2478. # The test results in cs_cv_prog_PROG_version_ok being either yes or no.
  2479. ##############################################################################
  2480. AC_DEFUN([CS_CHECK_PROG_VERSION],
  2481. [AC_CACHE_CHECK([if $1 version m4_default([$7],[>=]) $3],
  2482. [AS_TR_SH([cs_cv_prog_$1_version_ok_annotated])],
  2483. [CS_VCHK_EXTRACTVERSION([$2], [$3], [$4], AS_TR_SH([$1]),
  2484. m4_default([$7],[>=]))])
  2485. AS_IF([test "$AS_TR_SH([cs_cv_prog_$1_version_ok])" = yes], [$5], [$6])])
  2486. # qualify.m4 -*- Autoconf -*-
  2487. #==============================================================================
  2488. # Copyright (C)2005 by Eric Sunshine <[email protected]>
  2489. #
  2490. # This library is free software; you can redistribute it and/or modify it
  2491. # under the terms of the GNU Library General Public License as published by
  2492. # the Free Software Foundation; either version 2 of the License, or (at your
  2493. # option) any later version.
  2494. #
  2495. # This library is distributed in the hope that it will be useful, but
  2496. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  2497. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
  2498. # License for more details.
  2499. #
  2500. # You should have received a copy of the GNU Library General Public License
  2501. # along with this library; if not, write to the Free Software Foundation,
  2502. # Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  2503. #
  2504. #==============================================================================
  2505. AC_PREREQ([2.56])
  2506. #------------------------------------------------------------------------------
  2507. # CS_SYMBOL_QUALIFIER(MESSAGE, CACHE-VAR, QUALIFIERS, [SYMBOL], [LANG],
  2508. # [ACTION-IF-ACCEPTED], [ACTION-IF-NOT-ACCEPTED])
  2509. # Test if a symbol can be qualified by one of the elements of the
  2510. # comma-separated list of QUALIFIERS. Examples of qualifiers include
  2511. # __attribute__((deprecated)), __declspec(dllimport), etc. MESSAGE is the
  2512. # "checking" message. CACHE-VAR is the variable which receives the
  2513. # qualifier which succeeded, or the the literal "no" if none were
  2514. # accepted. SYMBOL is the symbol to which the qualifier should be
  2515. # applied. If omitted, then SYMBOL defaults to "void f();". LANG is the
  2516. # language of the test, typically "C" or "C++". It defaults to "C" if
  2517. # omitted. ACTION-IF-ACCEPTED is invoked after CACHE-VAR is set if one of
  2518. # the qualifiers is accepted, else ACTION-IF-NOT-ACCEPTED is invoked.
  2519. #------------------------------------------------------------------------------
  2520. AC_DEFUN([CS_SYMBOL_QUALIFIER],
  2521. [AC_CACHE_CHECK([$1], [$2],
  2522. [$2='no'
  2523. m4_foreach([cs_symbol_qualifier], [$3],
  2524. [AS_IF([test "$$2" = no],
  2525. [CS_BUILD_IFELSE(
  2526. [AC_LANG_PROGRAM(
  2527. [cs_symbol_qualifier m4_default([$4],[void f()]);],
  2528. [])],
  2529. [], [$5], [$2='cs_symbol_qualifier'], [$2='no'])])])])
  2530. AS_IF([test $$2 != no], [$6], [$7])])
  2531. # split.m4 -*- Autoconf -*-
  2532. #==============================================================================
  2533. # Copyright (C)2003 by Eric Sunshine <[email protected]>
  2534. #
  2535. # This library is free software; you can redistribute it and/or modify it
  2536. # under the terms of the GNU Library General Public License as published by
  2537. # the Free Software Foundation; either version 2 of the License, or (at your
  2538. # option) any later version.
  2539. #
  2540. # This library is distributed in the hope that it will be useful, but
  2541. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  2542. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
  2543. # License for more details.
  2544. #
  2545. # You should have received a copy of the GNU Library General Public License
  2546. # along with this library; if not, write to the Free Software Foundation,
  2547. # Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  2548. #
  2549. #==============================================================================
  2550. AC_PREREQ([2.56])
  2551. #------------------------------------------------------------------------------
  2552. # CS_SPLIT(LINE, [OUTPUT-VARIABLES], [DELIMITER], [FILLER])
  2553. # Split LINE into individual tokens. Tokens are delimited by DELIMITER,
  2554. # which is the space character if omitted. OUTPUT-VARIABLES is a
  2555. # comma-delimited list of shell variables which should receive the
  2556. # extracted tokens. If there are too few tokens to fill the output
  2557. # variables, then the excess variables will be assigned the empty string.
  2558. # If there are too few output variables, then the excess tokens will be
  2559. # ignored. If OUTPUT-VARIABLES is omitted, then the split tokens will be
  2560. # assigned to the shell meta-variables $1, $2, $3, etc. When
  2561. # OUTPUT-VARIABLES is omitted, FILLER is assigned to meta-variables in
  2562. # cases where DELIMITER delimits a zero-length token. FILLER defaults
  2563. # to "filler". For example, if DELIMITER is "+" and OUTPUT-VARIABLES is
  2564. # omitted, given the line "one++three", $1 will be "one", $2 will be
  2565. # "filler", and $3 will be "three".
  2566. #------------------------------------------------------------------------------
  2567. AC_DEFUN([CS_SPLIT],
  2568. [m4_define([cs_split_filler], m4_default([$4],[filler]))
  2569. set cs_split_filler `echo "$1" | awk 'BEGIN { FS="m4_default([$3],[ ])" }
  2570. { for (i=1; i <= NF; ++i)
  2571. { if ($i == "") print "cs_split_filler"; else print $i } }'`
  2572. shift
  2573. m4_map([_CS_SPLIT], [$2])])
  2574. AC_DEFUN([_CS_SPLIT],
  2575. [AS_IF([test $[@%:@] -eq 0], [$1=''],
  2576. [AS_IF([test "$[1]" = cs_split_filler], [$1=''], [$1=$[1]])
  2577. shift])])
  2578. # textcache.m4 -*- Autoconf -*-
  2579. #==============================================================================
  2580. # Copyright (C)2003 by Eric Sunshine <[email protected]>
  2581. #
  2582. # This library is free software; you can redistribute it and/or modify it
  2583. # under the terms of the GNU Library General Public License as published by
  2584. # the Free Software Foundation; either version 2 of the License, or (at your
  2585. # option) any later version.
  2586. #
  2587. # This library is distributed in the hope that it will be useful, but
  2588. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  2589. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
  2590. # License for more details.
  2591. #
  2592. # You should have received a copy of the GNU Library General Public License
  2593. # along with this library; if not, write to the Free Software Foundation,
  2594. # Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  2595. #
  2596. #==============================================================================
  2597. AC_PREREQ([2.56])
  2598. #------------------------------------------------------------------------------
  2599. # Text cache facility. These macros provide a way to incrementally store
  2600. # arbitrary text in a shell variable, and to write the saved text to a file.
  2601. #
  2602. # CS_TEXT_CACHE_APPEND(VARIABLE, TEXT)
  2603. # Append text to the contents of the named shell variable. If the text
  2604. # contains references to shell variables (such as $foo), then those
  2605. # references will be expanded. If expansion is not desired, then protect
  2606. # the text with AS_ESCAPE().
  2607. #
  2608. # CS_TEXT_CACHE_PREPEND(VARIABLE, TEXT)
  2609. # Prepend text to the contents of the named shell variable. If the text
  2610. # contains references to shell variables (such as $foo), then those
  2611. # references will be expanded. If expansion is not desired, then protect
  2612. # the text with AS_ESCAPE().
  2613. #
  2614. # CS_TEXT_CACHE_OUTPUT(VARIABLE, FILENAME)
  2615. # Instruct config.status to write the contents of the named shell
  2616. # variable to the given filename. If the file resides in a directory,
  2617. # the directory will be created, if necessary. If the output file
  2618. # already exists, and if the cached text is identical to the contents of
  2619. # the existing file, then the existing file is left alone, thus its time
  2620. # stamp remains unmolested. This heuristic may help to minimize rebuilds
  2621. # when the file is listed as a dependency in a makefile.
  2622. #
  2623. # *NOTE*
  2624. # There is a bug in Autoconf 2.57 and probably all earlier 2.5x versions
  2625. # which results in errors if AC_CONFIG_COMMANDS is invoked for a `tag'
  2626. # which represents a file in a directory which does not yet exist.
  2627. # Unfortunately, even invoking AS_MKDIR_P in the `cmd' portion of
  2628. # AC_CONFIG_COMMANDS does not solve the problem because the generated
  2629. # configure script attempts to access information about the directory
  2630. # before AS_MKDIR_P has a chance to create it. This forces us to invoke
  2631. # AS_MKDIR_P in the third argument to AC_CONFIG_COMMANDS (the
  2632. # `init-cmds') rather than the second (the `cmds'). This is undesirable
  2633. # because it means that the directory will be created anytime
  2634. # config.status is invoked (even for a simple --help), rather than being
  2635. # created only when requested to output the text cache. This bug was
  2636. # submitted to the Autoconf GNATS database by Eric Sunshine as #228 on
  2637. # 27-Dec-2002. It was fixed for Autoconf 2.58 on 26-Sep-2003. The
  2638. # official fix makes the assumption that `tag' always represents a file
  2639. # (as opposed to some generic target), and creates the file's directory
  2640. # is not present.
  2641. #------------------------------------------------------------------------------
  2642. AC_DEFUN([CS_TEXT_CACHE_APPEND], [$1="${$1}$2"])
  2643. AC_DEFUN([CS_TEXT_CACHE_PREPEND], [$1="$2${$1}"])
  2644. AC_DEFUN([CS_TEXT_CACHE_OUTPUT],
  2645. [AC_CONFIG_COMMANDS([$2],
  2646. [echo $ECHO_N "$$1$ECHO_C" > $tmp/tcache
  2647. AS_IF([diff $2 $tmp/tcache >/dev/null 2>&1],
  2648. [AC_MSG_NOTICE([$2 is unchanged])],
  2649. [rm -f $2
  2650. cp $tmp/tcache $2])
  2651. rm -f $tmp/tcache],
  2652. [$1='$$1'
  2653. cs_dir=`AS_DIRNAME([$2])`
  2654. AS_ESCAPE(AS_MKDIR_P([$cs_dir]), [$`\])])])
  2655. # trim.m4 -*- Autoconf -*-
  2656. #==============================================================================
  2657. # Copyright (C)2003 by Eric Sunshine <[email protected]>
  2658. #
  2659. # This library is free software; you can redistribute it and/or modify it
  2660. # under the terms of the GNU Library General Public License as published by
  2661. # the Free Software Foundation; either version 2 of the License, or (at your
  2662. # option) any later version.
  2663. #
  2664. # This library is distributed in the hope that it will be useful, but
  2665. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  2666. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
  2667. # License for more details.
  2668. #
  2669. # You should have received a copy of the GNU Library General Public License
  2670. # along with this library; if not, write to the Free Software Foundation,
  2671. # Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  2672. #
  2673. #==============================================================================
  2674. AC_PREREQ([2.56])
  2675. #------------------------------------------------------------------------------
  2676. # CS_TRIM(STRING)
  2677. # Strip leading and trailing spaces from STRING and collapse internal
  2678. # runs of multiple spaces to a single space.
  2679. #------------------------------------------------------------------------------
  2680. AC_DEFUN([CS_TRIM], [`echo x$1 | sed 's/^x//;s/ */ /g;s/^ //;s/ $//'`])
  2681. # warnings.m4 -*- Autoconf -*-
  2682. #==============================================================================
  2683. # Copyright (C)2005 by Eric Sunshine <[email protected]>
  2684. #
  2685. # This library is free software; you can redistribute it and/or modify it
  2686. # under the terms of the GNU Library General Public License as published by
  2687. # the Free Software Foundation; either version 2 of the License, or (at your
  2688. # option) any later version.
  2689. #
  2690. # This library is distributed in the hope that it will be useful, but
  2691. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  2692. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
  2693. # License for more details.
  2694. #
  2695. # You should have received a copy of the GNU Library General Public License
  2696. # along with this library; if not, write to the Free Software Foundation,
  2697. # Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  2698. #
  2699. #==============================================================================
  2700. AC_PREREQ([2.56])
  2701. #------------------------------------------------------------------------------
  2702. # CS_COMPILER_WARNINGS([LANGUAGE], [CACHE-VAR], [ACTION-IF-FOUND],
  2703. # [ACTION-IF-NOT-FOUND])
  2704. # Check how to enable compilation warnings. If LANGUAGE is not provided,
  2705. # then `C' is assumed (other options include `C++'). If CACHE-VAR is not
  2706. # provided, then it defaults to the name
  2707. # "cs_cv_prog_compiler_enable_warnings". If an option for enabling
  2708. # warnings (such as `-Wall') is discovered, then it is assigned to
  2709. # CACHE-VAR and ACTION-IF-FOUND is invoked; otherwise the empty string is
  2710. # assigned to CACHE-VAR and ACTION-IF-NOT-FOUND is invoked.
  2711. #
  2712. # IMPLEMENTATION NOTES
  2713. #
  2714. # On some platforms, it is more appropriate to use -Wmost rather than
  2715. # -Wall even if the compiler understands both, thus we attempt -Wmost
  2716. # before -Wall.
  2717. #------------------------------------------------------------------------------
  2718. AC_DEFUN([CS_COMPILER_WARNINGS],
  2719. [CS_CHECK_BUILD_FLAGS(
  2720. [how to enable m4_default([$1],[C]) compilation warnings],
  2721. [m4_default([$2],[cs_cv_prog_compiler_enable_warnings])],
  2722. [CS_CREATE_TUPLE([-Wmost]) CS_CREATE_TUPLE([-Wall])],
  2723. [$1], [$3], [$4])])
  2724. #------------------------------------------------------------------------------
  2725. # CS_COMPILER_ERRORS([LANGUAGE], [CACHE-VAR], [ACTION-IF-FOUND],
  2726. # [ACTION-IF-NOT-FOUND])
  2727. # Check how to promote compilation diganostics from warning to error
  2728. # status. If LANGUAGE is not provided, then `C' is assumed (other options
  2729. # include `C++'). If CACHE-VAR is not provided, then it defaults to the
  2730. # name "cs_cv_prog_compiler_enable_errors". If an option for performing
  2731. # this promotion (such as `-Werror') is discovered, then it is assigned
  2732. # to CACHE-VAR and ACTION-IF-FOUND is invoked; otherwise the empty string
  2733. # is assigned to CACHE-VAR and ACTION-IF-NOT-FOUND is invoked.
  2734. #------------------------------------------------------------------------------
  2735. AC_DEFUN([CS_COMPILER_ERRORS],
  2736. [CS_CHECK_BUILD_FLAGS(
  2737. [how to treat m4_default([$1],[C]) warnings as errors],
  2738. [m4_default([$2],[cs_cv_prog_compiler_enable_errors])],
  2739. [CS_CREATE_TUPLE([-Werror])], [$1], [$3], [$4])])
  2740. #------------------------------------------------------------------------------
  2741. # CS_COMPILER_IGNORE_UNUSED([LANGUAGE], [CACHE-VAR], [ACTION-IF-FOUND],
  2742. # [ACTION-IF-NOT-FOUND])
  2743. # Check how to instruct compiler to ignore unused variables and
  2744. # arguments. This option may be useful for code generated by tools, such
  2745. # as Swig, Bison, and Flex, over which the client has no control, yet
  2746. # wishes to compile without excessive diagnostic spew. If LANGUAGE is
  2747. # not provided, then `C' is assumed (other options include `C++'). If
  2748. # CACHE-VAR is not provided, then it defaults to the name
  2749. # "cs_cv_prog_compiler_ignore_unused". If an option (such as
  2750. # `-Wno-unused') is discovered, then it is assigned to CACHE-VAR and
  2751. # ACTION-IF-FOUND is invoked; otherwise the empty string is assigned to
  2752. # CACHE-VAR and ACTION-IF-NOT-FOUND is invoked.
  2753. #------------------------------------------------------------------------------
  2754. AC_DEFUN([CS_COMPILER_IGNORE_UNUSED],
  2755. [CS_CHECK_BUILD_FLAGS(
  2756. [how to suppress m4_default([$1],[C]) unused variable warnings],
  2757. [m4_default([$2],[cs_cv_prog_compiler_ignore_unused])],
  2758. [CS_CREATE_TUPLE([-Wno-unused])], [$1], [$3], [$4])])
  2759. #------------------------------------------------------------------------------
  2760. # CS_COMPILER_IGNORE_UNINITIALIZED([LANGUAGE], [CACHE-VAR], [ACTION-IF-FOUND],
  2761. # [ACTION-IF-NOT-FOUND])
  2762. # Check how to instruct compiler to ignore uninitialized variables. This
  2763. # option may be useful for code generated by tools, such as Swig, Bison,
  2764. # and Flex, over which the client has no control, yet wishes to compile
  2765. # without excessive diagnostic spew. If LANGUAGE is not provided, then
  2766. # `C' is assumed (other options include `C++'). If CACHE-VAR is not
  2767. # provided, then it defaults to the name
  2768. # "cs_cv_prog_compiler_ignore_uninitialized". If an option (such as
  2769. # `-Wno-uninitialized') is discovered, then it is assigned to CACHE-VAR
  2770. # and ACTION-IF-FOUND is invoked; otherwise the empty string is assigned
  2771. # to CACHE-VAR and ACTION-IF-NOT-FOUND is invoked.
  2772. #------------------------------------------------------------------------------
  2773. AC_DEFUN([CS_COMPILER_IGNORE_UNINITIALIZED],
  2774. [CS_CHECK_BUILD_FLAGS(
  2775. [how to suppress m4_default([$1],[C]) uninitialized warnings],
  2776. [m4_default([$2],
  2777. [cs_cv_prog_compiler_ignore_uninitialized_variables])],
  2778. [CS_CREATE_TUPLE([-Wno-uninitialized])], [$1], [$3], [$4])])
  2779. #------------------------------------------------------------------------------
  2780. # CS_COMPILER_IGNORE_PRAGMAS([LANGUAGE], [CACHE-VAR], [ACTION-IF-FOUND],
  2781. # [ACTION-IF-NOT-FOUND])
  2782. # Check how to instruct compiler to ignore unrecognized #pragma
  2783. # directives. This option may be useful for code which contains
  2784. # unprotected #pragmas which are not understood by all compilers. If
  2785. # LANGUAGE is not provided, then `C' is assumed (other options include
  2786. # `C++'). If CACHE-VAR is not provided, then it defaults to the name
  2787. # "cs_cv_prog_compiler_ignore_unknown_pragmas". If an option (such as
  2788. # `-Wno-unknown-pragmas') is discovered, then it is assigned to CACHE-VAR
  2789. # and ACTION-IF-FOUND is invoked; otherwise the empty string is assigned
  2790. # to CACHE-VAR and ACTION-IF-NOT-FOUND is invoked.
  2791. #------------------------------------------------------------------------------
  2792. AC_DEFUN([CS_COMPILER_IGNORE_PRAGMAS],
  2793. [CS_CHECK_BUILD_FLAGS(
  2794. [how to suppress m4_default([$1],[C]) unknown [#pragma] warnings],
  2795. [m4_default([$2],[cs_cv_prog_compiler_ignore_unknown_pragmas])],
  2796. [CS_CREATE_TUPLE([-Wno-unknown-pragmas])], [$1], [$3], [$4])])
  2797. #------------------------------------------------------------------------------
  2798. # CS_COMPILER_IGNORE_LONG_DOUBLE([LANGUAGE], [CACHE-VAR], [ACTION-IF-FOUND],
  2799. # [ACTION-IF-NOT-FOUND])
  2800. # Check how to instruct compiler to suppress warnings about `long double'
  2801. # usage. This option may be useful for code generated by tools, such as
  2802. # Swig, Bison, and Flex, over which the client has no control, yet wishes
  2803. # to compile without excessive diagnostic spew. If LANGUAGE is not
  2804. # provided, then `C' is assumed (other options include `C++'). If
  2805. # CACHE-VAR is not provided, then it defaults to the name
  2806. # "cs_cv_prog_compiler_ignore_long_double". If an option (such as
  2807. # `-Wno-long-double') is discovered, then it is assigned to CACHE-VAR and
  2808. # ACTION-IF-FOUND is invoked; otherwise the empty string is assigned to
  2809. # CACHE-VAR and ACTION-IF-NOT-FOUND is invoked.
  2810. #------------------------------------------------------------------------------
  2811. AC_DEFUN([CS_COMPILER_IGNORE_LONG_DOUBLE],
  2812. [CS_CHECK_BUILD_FLAGS(
  2813. [how to suppress m4_default([$1],[C]) `long double' warnings],
  2814. [m4_default([$2],[cs_cv_prog_compiler_ignore_long_double])],
  2815. [CS_CREATE_TUPLE([-Wno-long-double])], [$1], [$3], [$4])])