acinclude.m4 142 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056
  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. AC_PROG_CC
  1286. AS_IF([test -n "$CC"],[
  1287. CS_EMIT_BUILD_PROPERTY([CMD.CC], [$CC])
  1288. CS_EMIT_BUILD_PROPERTY([COMPILER.CFLAGS], [$CPPFLAGS $CFLAGS], [+])
  1289. # Check if compiler recognizes -pipe directive.
  1290. CS_EMIT_BUILD_FLAGS([if $CC accepts -pipe], [cs_cv_prog_cc_pipe],
  1291. [CS_CREATE_TUPLE([-pipe])], [C], [COMPILER.CFLAGS], [+])
  1292. ])
  1293. ])
  1294. AC_DEFUN([CS_PROG_CXX],[
  1295. CXXFLAGS="$CXXFLAGS" # Filter undesired flags
  1296. AC_PROG_CXX
  1297. AS_IF([test -n "$CXX"],[
  1298. CS_EMIT_BUILD_PROPERTY([CMD.C++], [$CXX])
  1299. CS_EMIT_BUILD_PROPERTY([COMPILER.C++FLAGS], [$CPPFLAGS $CXXFLAGS], [+])
  1300. # Check if compiler can be instructed to produce position-independent-code
  1301. # (PIC). This feature is required by some platforms when building plugin
  1302. # modules and shared libraries.
  1303. CS_COMPILER_PIC([C++], [cs_cv_prog_cxx_pic],
  1304. [CS_EMIT_BUILD_PROPERTY([COMPILER.C++FLAGS.PIC],
  1305. [$cs_cv_prog_cxx_pic])])
  1306. ])
  1307. ])
  1308. AC_DEFUN([CS_PROG_LINK],[
  1309. AC_REQUIRE([CS_PROG_CXX])
  1310. AS_IF([test -n "$CXX"],
  1311. [CS_EMIT_BUILD_PROPERTY([CMD.LINK], [AS_ESCAPE([$(CMD.C++)])])],
  1312. [CS_EMIT_BUILD_PROPERTY([CMD.LINK], [AS_ESCAPE([$(CMD.CC)])])])
  1313. CS_EMIT_BUILD_PROPERTY([COMPILER.LFLAGS], [$LDFLAGS], [+])
  1314. # Check if compiler/linker recognizes -shared directive which is needed for
  1315. # linking plugin modules. Unfortunately, the Apple compiler (and possibly
  1316. # others) requires extra effort. Even though the compiler does not recognize
  1317. # the -shared option, it nevertheless returns a "success" result after emitting
  1318. # the warning "unrecognized option `-shared'". Worse, even -Werror fails to
  1319. # promote the warning to an error, so we must instead scan the compiler's
  1320. # output for an appropriate diagnostic.
  1321. CS_CHECK_BUILD_FLAGS([if -shared is accepted], [cs_cv_prog_link_shared],
  1322. [CS_CREATE_TUPLE([-shared $cs_cv_prog_cxx_pic])], [C++],
  1323. [CS_EMIT_BUILD_PROPERTY([PLUGIN.LFLAGS], [-shared], [+])], [],
  1324. [], [], [], [shared])
  1325. # Check if linker recognizes -soname which is used to assign a name internally
  1326. # to plugin modules.
  1327. CS_CHECK_BUILD([if -soname is accepted], [cs_cv_prog_link_soname], [],
  1328. [CS_CREATE_TUPLE([-Wl,-soname,foobar])], [C++],
  1329. [CS_EMIT_BUILD_PROPERTY([PLUGIN.LFLAGS.USE_SONAME], [yes])])
  1330. ])
  1331. #------------------------------------------------------------------------------
  1332. # Determine host platform. Recognized families: Unix, Windows, MacOS/X.
  1333. # Orginial Macros Copyright (C)2003 Eric Sunshine <[email protected]>
  1334. #
  1335. # This library is free software; you can redistribute it and/or modify it
  1336. # under the terms of the GNU Library General Public License as published by
  1337. # the Free Software Foundation; either version 2 of the License, or (at your
  1338. # option) any later version.
  1339. #
  1340. # This library is distributed in the hope that it will be useful, but
  1341. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  1342. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
  1343. # License for more details.
  1344. #
  1345. # You should have received a copy of the GNU Library General Public License
  1346. # along with this library; if not, write to the Free Software Foundation,
  1347. # Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1348. #
  1349. #------------------------------------------------------------------------------
  1350. #------------------------------------------------------------------------------
  1351. # Determine host CPU.
  1352. #
  1353. # CS_CHECK_HOST_CPU
  1354. # Set the shell variable cs_host_cpu to a normalized form of the CPU name
  1355. # returned by config.guess/config.sub. Typically, Crystal Space's
  1356. # conception of CPU name is the same as that returned by
  1357. # config.guess/config.sub, but there may be exceptions as seen in the
  1358. # `case' statement. Also takes the normalized name, uppercases it to
  1359. # form a name suitable for the C preprocessor. Additionally sets the
  1360. # TARGET.PROCESSOR Jamconfig property.
  1361. #------------------------------------------------------------------------------
  1362. AC_DEFUN([CS_CHECK_HOST_CPU],
  1363. [AC_REQUIRE([AC_CANONICAL_HOST])
  1364. case $host_cpu in
  1365. [[Ii][3-9]86*|[Xx]86*]) cs_host_cpu=x86 ;;
  1366. *) cs_host_cpu=$host_cpu ;;
  1367. esac
  1368. cs_host_cpu_normalized="AS_TR_CPP([$cs_host_cpu])"
  1369. CS_JAMCONFIG_PROPERTY([TARGET.PROCESSOR], [$cs_host_cpu_normalized])
  1370. ])
  1371. #------------------------------------------------------------------------------
  1372. # CS_CHECK_HOST
  1373. # Sets the shell variables cs_host_target cs_host_family,
  1374. # cs_host_os_normalized, and cs_host_os_normalized_uc. Emits appropriate
  1375. # CS_PLATFORM_UNIX, CS_PLATFORM_WIN32, CS_PLATFORM_MACOSX via
  1376. # AC_DEFINE(), and TARGET.OS and TARGET.OS.NORMALIZED to Jamconfig.
  1377. #------------------------------------------------------------------------------
  1378. AC_DEFUN([CS_CHECK_HOST],
  1379. [AC_REQUIRE([AC_CANONICAL_HOST])
  1380. CS_CHECK_HOST_CPU
  1381. cs_host_os_normalized=''
  1382. case $host_os in
  1383. mingw*|cygwin*)
  1384. cs_host_target=win32gcc
  1385. cs_host_family=windows
  1386. ;;
  1387. darwin*)
  1388. _CS_CHECK_HOST_DARWIN
  1389. ;;
  1390. *)
  1391. # Everything else is assumed to be Unix or Unix-like.
  1392. cs_host_target=unix
  1393. cs_host_family=unix
  1394. ;;
  1395. esac
  1396. case $cs_host_family in
  1397. windows)
  1398. AC_DEFINE([CS_PLATFORM_WIN32], [],
  1399. [Define when compiling for Win32])
  1400. AS_IF([test -z "$cs_host_os_normalized"],
  1401. [cs_host_os_normalized='Win32'])
  1402. ;;
  1403. unix)
  1404. AC_DEFINE([CS_PLATFORM_UNIX], [],
  1405. [Define when compiling for Unix and Unix-like (i.e. MacOS/X)])
  1406. AS_IF([test -z "$cs_host_os_normalized"],
  1407. [cs_host_os_normalized='Unix'])
  1408. ;;
  1409. esac
  1410. cs_host_os_normalized_uc="AS_TR_CPP([$cs_host_os_normalized])"
  1411. CS_JAMCONFIG_PROPERTY([TARGET.OS], [$cs_host_os_normalized_uc])
  1412. CS_JAMCONFIG_PROPERTY([TARGET.OS.NORMALIZED], [$cs_host_os_normalized])
  1413. ])
  1414. AC_DEFUN([_CS_CHECK_HOST_DARWIN],
  1415. [AC_REQUIRE([CS_PROG_CC])
  1416. AC_REQUIRE([CS_PROG_CXX])
  1417. # Both MacOS/X and Darwin are identified via $host_os as "darwin". We need
  1418. # a way to distinguish between the two. If Carbon.h is present, then
  1419. # assume MacOX/S; if not, assume Darwin. If --with-x=yes was invoked, and
  1420. # Carbon.h is present, then assume that user wants to cross-build for
  1421. # Darwin even though build host is MacOS/X.
  1422. # IMPLEMENTATION NOTE *1*
  1423. # The QuickTime 7.0 installer removes <CarbonSound/CarbonSound.h>, which
  1424. # causes #include <Carbon/Carbon.h> to fail unconditionally. Re-installing
  1425. # the QuickTime SDK should restore the header, however not all developers
  1426. # know to do this, so we work around the problem of the missing
  1427. # CarbonSound.h by #defining __CARBONSOUND__ in the test in order to
  1428. # prevent Carbon.h from attempting to #include the missing header.
  1429. # IMPLEMENTATION NOTE *2*
  1430. # At least one MacOS/X user switches between gcc 2.95 and gcc 3.3 with a
  1431. # script which toggles the values of CC, CXX, and CPP. Unfortunately, CPP
  1432. # was being set to run the preprocessor directly ("cpp", for instance)
  1433. # rather than running it via the compiler ("gcc -E", for instance). The
  1434. # problem with running the preprocessor directly is that __APPLE__ and
  1435. # __GNUC__ are not defined, which causes the Carbon.h check to fail. We
  1436. # avoid this problem by supplying a non-empty fourth argument to
  1437. # AC_CHECK_HEADER(), which causes it to test compile the header only (which
  1438. # is a more robust test), rather than also testing it via the preprocessor.
  1439. AC_DEFINE([__CARBONSOUND__], [],
  1440. [Avoid problem caused by missing <Carbon/CarbonSound.h>])
  1441. AC_CHECK_HEADER([Carbon/Carbon.h],
  1442. [cs_host_macosx=yes], [cs_host_macosx=no], [/* force compile */])
  1443. AS_IF([test $cs_host_macosx = yes],
  1444. [AC_MSG_CHECKING([for --with-x])
  1445. AS_IF([test "${with_x+set}" = set && test "$with_x" = "yes"],
  1446. [AC_MSG_RESULT([yes (assume Darwin)])
  1447. cs_host_macosx=no],
  1448. [AC_MSG_RESULT([no])])])
  1449. AS_IF([test $cs_host_macosx = yes],
  1450. [cs_host_target=macosx
  1451. cs_host_family=unix
  1452. cs_host_os_normalized='MacOS/X'
  1453. AC_DEFINE([CS_PLATFORM_MACOSX], [],
  1454. [Define when compiling for MacOS/X])
  1455. AC_CACHE_CHECK([for Objective-C compiler], [cs_cv_prog_objc],
  1456. [cs_cv_prog_objc="$CC"])
  1457. CS_JAMCONFIG_PROPERTY([CMD.OBJC], [$cs_cv_prog_objc])
  1458. AC_CACHE_CHECK([for Objective-C++ compiler], [cs_cv_prog_objcxx],
  1459. [cs_cv_prog_objcxx="$CXX"])
  1460. CS_JAMCONFIG_PROPERTY([CMD.OBJC++], [$cs_cv_prog_objcxx])],
  1461. [cs_host_target=unix
  1462. cs_host_family=unix])])
  1463. # diagnose.m4 -*- Autoconf -*-
  1464. #==============================================================================
  1465. # Copyright (C)2003 by Eric Sunshine <[email protected]>
  1466. #
  1467. # This library is free software; you can redistribute it and/or modify it
  1468. # under the terms of the GNU Library General Public License as published by
  1469. # the Free Software Foundation; either version 2 of the License, or (at your
  1470. # option) any later version.
  1471. #
  1472. # This library is distributed in the hope that it will be useful, but
  1473. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  1474. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
  1475. # License for more details.
  1476. #
  1477. # You should have received a copy of the GNU Library General Public License
  1478. # along with this library; if not, write to the Free Software Foundation,
  1479. # Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1480. #
  1481. #==============================================================================
  1482. AC_PREREQ([2.56])
  1483. #------------------------------------------------------------------------------
  1484. # CS_MSG_ERROR(ERROR-DESCRIPTION, [EXIT-STATUS])
  1485. # A convenience wrapper for AC_MSG_ERROR() which invokes AC_CACHE_SAVE()
  1486. # before aborting the script. Saving the cache should make subsequent
  1487. # re-invocations of the configure script faster once the user has
  1488. # corrected the problem(s) which caused the failure.
  1489. #------------------------------------------------------------------------------
  1490. AC_DEFUN([CS_MSG_ERROR],
  1491. [AC_CACHE_SAVE
  1492. AC_MSG_ERROR([$1], [$2])])
  1493. # embed.m4 -*- Autoconf -*-
  1494. #==============================================================================
  1495. # Copyright (C)2003,2005 by Eric Sunshine <[email protected]>
  1496. #
  1497. # This library is free software; you can redistribute it and/or modify it
  1498. # under the terms of the GNU Library General Public License as published by
  1499. # the Free Software Foundation; either version 2 of the License, or (at your
  1500. # option) any later version.
  1501. #
  1502. # This library is distributed in the hope that it will be useful, but
  1503. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  1504. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
  1505. # License for more details.
  1506. #
  1507. # You should have received a copy of the GNU Library General Public License
  1508. # along with this library; if not, write to the Free Software Foundation,
  1509. # Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1510. #
  1511. #==============================================================================
  1512. AC_PREREQ([2.56])
  1513. #------------------------------------------------------------------------------
  1514. # CS_META_INFO_EMBED([EMITTER], [GPL-OKAY])
  1515. # Determine if plugin meta-information should be embedded or if it should
  1516. # exist in a stand-alone .csplugin file, and check if necessary tools and
  1517. # libraries are present. Sets the shell variable
  1518. # enable_meta_info_embedding to "yes" if the user requested embedding or
  1519. # if it was enabled by default; otherwise sets it to "no".
  1520. #
  1521. # If EMITTER is provided, then a subset of the following variables
  1522. # (depending upon platform and availability) are recorded by invoking
  1523. # CS_EMIT_BUILD_PROPERTY() with EMITTER. As a convenience, if EMITTER is
  1524. # the literal value "emit" or "yes", then CS_EMIT_BUILD_RESULT()'s
  1525. # default emitter will be used.
  1526. #
  1527. # EMBED_META := yes or no
  1528. # EMBED_META.CFLAGS := compiler flags
  1529. # EMBED_META.LFLAGS := linker flags
  1530. # CMD.WINDRES := windres.exe
  1531. # OBJCOPY.AVAILABLE := yes or no
  1532. # CMD.OBJCOPY := objcopy.exe
  1533. # LIBBFD.AVAILABLE := yes or no
  1534. # LIBBFD.CFLAGS := libbfd compiler flags
  1535. # LIBBFD.LFLAGS := libbfd linker flags
  1536. # ELF.AVAILABLE := yes or no
  1537. #
  1538. # In general, clients need only concern themselves with the various
  1539. # EMBED_META-related variables. For building plugin modules, utilize
  1540. # EMBED_META.CFLAGS when compiling, and EMBED_META.LFLAGS when linking.
  1541. #
  1542. # On Unix, when CS' own ELF metadata reader can't be used (because the
  1543. # necessary header file elf.h was not found) embedding is accomplished
  1544. # via libbfd, which carries a GPL license. Projects which carry licenses
  1545. # not compatible with GPL should consider carefully before enabling
  1546. # embedding on Unix. If your project is GPL-compatible, then set GPL-OKAY
  1547. # to "yes". This will indicate that it is safe to use libbfd if the ELF
  1548. # reader can not be used. If your project is not GPL-compatible, then
  1549. # set it to "no" in order to disable embedding on Unix if the ELF reader
  1550. # is not usable. (The user can still manually override the setting via
  1551. # the --enable-meta-info-embedding option.)
  1552. #
  1553. # IMPLEMENTATION NOTES
  1554. #
  1555. # Recent versions of Mingw supply libbfd and libiberty. Since Crystal
  1556. # Space uses native Win32 API for meta-information embedding on Windows,
  1557. # we do not require these libraries on Windows. More importantly, users
  1558. # do not want to see these GPL-licensed libraries appear in the link
  1559. # statement for plugin modules, thus we explicitly disable the libbfd
  1560. # test on Windows.
  1561. #------------------------------------------------------------------------------
  1562. AC_DEFUN([CS_META_INFO_EMBED],
  1563. [AC_REQUIRE([AC_CANONICAL_HOST])
  1564. _CS_META_INFO_EMBED_ENABLE([$1], [$2])
  1565. AS_IF([test $enable_meta_info_embedding = yes],
  1566. [_CS_META_INFO_EMBED_TOOLS([$1])
  1567. AS_IF([test $cs_header_elf_h = yes],
  1568. [CS_EMIT_BUILD_PROPERTY([ELF.AVAILABLE], [yes], [], [],
  1569. CS_EMITTER_OPTIONAL([$1]))],
  1570. [case $host_os in
  1571. mingw*|cygwin*) ;;
  1572. *)
  1573. CS_CHECK_LIBBFD([$1],
  1574. [CS_EMIT_BUILD_PROPERTY([EMBED_META.CFLAGS],
  1575. [$cs_cv_libbfd_ok_cflags], [+], [],
  1576. CS_EMITTER_OPTIONAL([$1]))
  1577. CS_EMIT_BUILD_PROPERTY([EMBED_META.LFLAGS],
  1578. [$cs_cv_libbfd_ok_lflags $cs_cv_libbfd_ok_libs],
  1579. [+], [], CS_EMITTER_OPTIONAL([$1]))])
  1580. ;;
  1581. esac])])])
  1582. #------------------------------------------------------------------------------
  1583. # _CS_META_INFO_EMBED_ENABLE([EMITTER], [GPL-OKAY])
  1584. # Helper for CS_META_INFO_EMBED which adds an
  1585. # --enable-meta-info-embedding option to the configure script allowing
  1586. # the user to control embedding. Sets the shell variable
  1587. # enable_meta_info_embedding to yes or no.
  1588. #
  1589. # IMPLEMENTATION NOTES
  1590. #
  1591. # On Unix, embedding is enabled by default if elf.h is found and disabled
  1592. # by default unless overridden via GPL-OKAY because libbfd carries a GPL
  1593. # license which may be incompatible with a project's own license (such as
  1594. # LGPL).
  1595. #------------------------------------------------------------------------------
  1596. AC_DEFUN([_CS_META_INFO_EMBED_ENABLE],
  1597. [AC_REQUIRE([CS_CHECK_HOST])
  1598. AC_CHECK_HEADERS([elf.h], [cs_header_elf_h=yes], [cs_header_elf_h=no])
  1599. AC_MSG_CHECKING([whether to embed plugin meta-information])
  1600. case $cs_host_target in
  1601. unix) AS_IF([test $cs_header_elf_h = yes],
  1602. [cs_embed_meta_info_default=yes],
  1603. [cs_embed_meta_info_default=m4_ifval([$2],[$2],[no])]) ;;
  1604. *) cs_embed_meta_info_default=yes ;;
  1605. esac
  1606. AC_ARG_ENABLE([meta-info-embedding],
  1607. [AC_HELP_STRING([--enable-meta-info-embedding],
  1608. [store plugin meta-information directly inside plugin modules if
  1609. supported by platform; if disabled, meta-information is stored in
  1610. stand-alone .csplugin files; this option is enabled by default for
  1611. non-Unix platforms and on Unix platforms with ELF-format object
  1612. files; it is disabled by default on Unix platforms if ELF is not
  1613. available and the project uses a non-GPL-compatible license (such
  1614. as LGPL) since the non-ELF Unix embedding technology requires the
  1615. GPL-licensed libbfd library; if ELF is not available, enable this
  1616. option on Unix only if you are certain you want a GPL-licensed
  1617. library infecting your project])],
  1618. [], [enable_meta_info_embedding=$cs_embed_meta_info_default])
  1619. AC_MSG_RESULT([$enable_meta_info_embedding])
  1620. CS_EMIT_BUILD_PROPERTY([EMBED_META], [$enable_meta_info_embedding],
  1621. [], [], CS_EMITTER_OPTIONAL([$1]))])
  1622. #------------------------------------------------------------------------------
  1623. # _CS_META_INFO_EMBED_TOOLS([EMITTER])
  1624. # Helper for CS_META_INFO_EMBED() which searches for tools required for
  1625. # plugin meta-info embedding.
  1626. #------------------------------------------------------------------------------
  1627. AC_DEFUN([_CS_META_INFO_EMBED_TOOLS],
  1628. [CS_CHECK_TOOLS([WINDRES], [windres])
  1629. CS_EMIT_BUILD_PROPERTY([CMD.WINDRES], [$WINDRES], [], [],
  1630. CS_EMITTER_OPTIONAL([$1]))
  1631. CS_CHECK_TOOLS([OBJCOPY], [objcopy])
  1632. AS_IF([test -n "$OBJCOPY"],
  1633. [CS_EMIT_BUILD_PROPERTY([OBJCOPY.AVAILABLE], [yes], [], [],
  1634. CS_EMITTER_OPTIONAL([$1]))
  1635. CS_EMIT_BUILD_PROPERTY([CMD.OBJCOPY], [$OBJCOPY], [], [],
  1636. CS_EMITTER_OPTIONAL([$1]))])])
  1637. #------------------------------------------------------------------------------
  1638. # CS_CHECK_LIBBFD([EMITTER], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
  1639. # Exhaustive check for a usable GPL-licensed libbfd, the Binary File
  1640. # Descriptor library, a component of binutils, which allows low-level
  1641. # manipulation of executable and object files. If EMITTER is provided,
  1642. # then the following variables are recorded by invoking
  1643. # CS_EMIT_BUILD_PROPERTY() with EMITTER. As a convenience, if EMITTER is
  1644. # the literal value "emit" or "yes", then CS_EMIT_BUILD_RESULT()'s
  1645. # default emitter will be used.
  1646. #
  1647. # LIBBFD.AVAILABLE := yes or no
  1648. # LIBBFD.CFLAGS := libbfd compiler flags
  1649. # LIBBFD.LFLAGS := libbfd linker flags
  1650. #
  1651. # The shell variable cs_cv_libbfd_ok is set to yes if a usable libbfd was
  1652. # discovered, else no. If found, the additional shell variables
  1653. # cs_cv_libbfd_ok_cflags, cs_cv_libbfd_ok_lflags, and
  1654. # cs_cv_libbfd_ok_libs are also set.
  1655. #
  1656. # WARNING
  1657. #
  1658. # libbfd carries a GPL license which is incompatible with the LGPL
  1659. # license of Crystal Space. Do not use this library with projects under
  1660. # less restrictive licenses, such as LGPL.
  1661. #
  1662. # IMPLEMENTATION NOTES
  1663. #
  1664. # It seems that some platforms have two version of libiberty installed:
  1665. # one from binutils and one from gcc. The binutils version resides in
  1666. # /usr/lib, whereas the gcc version resides in the gcc installation
  1667. # directory. The gcc version, by default, takes precedence at link time
  1668. # over the binutils version. Unfortunately, in broken cases, the gcc
  1669. # version of libiberty is missing htab_create_alloc() which is required
  1670. # by some libbfd functions. The extensive secondary check of libbfd
  1671. # catches this anomalous case of broken gcc libiberty. It turns out that
  1672. # it is possible to make the linker prefer the binutils version by
  1673. # specifying -L/usr/lib, thus the extensive test attempts to do so in an
  1674. # effort to resolve this unfortunate issue.
  1675. #------------------------------------------------------------------------------
  1676. AC_DEFUN([CS_CHECK_LIBBFD],
  1677. [CS_CHECK_LIB_WITH([bfd],
  1678. [AC_LANG_PROGRAM([[#include <bfd.h>]], [bfd_init();])],
  1679. [], [], [], [], [], [], [-liberty])
  1680. AS_IF([test $cs_cv_libbfd = yes],
  1681. [CS_CHECK_BUILD([if libbfd is usable], [cs_cv_libbfd_ok],
  1682. [AC_LANG_PROGRAM([[#include <bfd.h>]],
  1683. [bfd* p;
  1684. asection* s;
  1685. bfd_init();
  1686. p = bfd_openr(0,0);
  1687. bfd_check_format(p,bfd_object);
  1688. bfd_get_section_by_name(p,0);
  1689. bfd_section_size(p,s);
  1690. bfd_get_section_contents(p,s,0,0,0);
  1691. bfd_close(p);])],
  1692. [CS_CREATE_TUPLE() CS_CREATE_TUPLE([],[-L/usr/lib],[])],
  1693. [], [], [], [],
  1694. [$cs_cv_libbfd_cflags],
  1695. [$cs_cv_libbfd_lflags],
  1696. [$cs_cv_libbfd_libs])],
  1697. [cs_cv_libbfd_ok=no])
  1698. AS_IF([test $cs_cv_libbfd_ok = yes],
  1699. [CS_EMIT_BUILD_RESULT([cs_cv_libbfd_ok], [LIBBFD],
  1700. CS_EMITTER_OPTIONAL([$1]))
  1701. $2],
  1702. [$3])])
  1703. # emit.m4 -*- Autoconf -*-
  1704. #==============================================================================
  1705. # Copyright (C)2003-2005 by Eric Sunshine <[email protected]>
  1706. #
  1707. # This library is free software; you can redistribute it and/or modify it
  1708. # under the terms of the GNU Library General Public License as published by
  1709. # the Free Software Foundation; either version 2 of the License, or (at your
  1710. # option) any later version.
  1711. #
  1712. # This library is distributed in the hope that it will be useful, but
  1713. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  1714. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
  1715. # License for more details.
  1716. #
  1717. # You should have received a copy of the GNU Library General Public License
  1718. # along with this library; if not, write to the Free Software Foundation,
  1719. # Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1720. #
  1721. #==============================================================================
  1722. AC_PREREQ([2.56])
  1723. #------------------------------------------------------------------------------
  1724. # CS_EMIT_BUILD_PROPERTY(KEY, VALUE, [APPEND], [EMPTY-OKAY], [EMITTER],
  1725. # [UNCONDITIONAL])
  1726. # A utility function which invokes an emitter to record the KEY/VALUE
  1727. # tuple if VALUE is not the empty string (after leading and trailing
  1728. # whitespace is stripped). If EMPTY-OKAY is not an empty string, then the
  1729. # property is emitted even if VALUE is empty; that is, it is emitted
  1730. # unconditionally. If APPEND is the empty string, then the emitter sets
  1731. # the key's value directly (though it may be overridden by the
  1732. # environment), otherwise the emitter appends VALUE to the existing value
  1733. # of the key. EMITTER is a macro name, such as CS_JAMCONFIG_PROPERTY or
  1734. # CS_MAKEFILE_PROPERTY, which performs the actual task of emitting the
  1735. # KEY/VALUE tuple; it should also accept APPEND as an optional third
  1736. # argument. If EMITTER is omitted, CS_JAMCONFIG_PROPERTY is used. Some
  1737. # emitters accept an optional fourth argument, UNCONDITIONAL, which
  1738. # instructs it to set KEY's value unconditionally, even if KEY already
  1739. # had been assigned a value via some other mechanism (such as imported
  1740. # from the environment, or from Jambase, in the case of
  1741. # CS_JAMCONFIG_PROPERTY).
  1742. #------------------------------------------------------------------------------
  1743. AC_DEFUN([CS_EMIT_BUILD_PROPERTY],
  1744. [cs_build_prop_val="$2"
  1745. cs_build_prop_val=CS_TRIM([$cs_build_prop_val])
  1746. m4_ifval([$4],
  1747. [CS_JAMCONFIG_PROPERTY([$1], [$cs_build_prop_val], [$3])],
  1748. AS_IF([test -n "$cs_build_prop_val"],
  1749. [m4_default([$5],[CS_JAMCONFIG_PROPERTY])(
  1750. [$1], [$cs_build_prop_val], [$3], [$6])]))])
  1751. #------------------------------------------------------------------------------
  1752. # CS_EMIT_BUILD_RESULT(CACHE-VAR, PREFIX, [EMITTER])
  1753. # Record the results of CS_CHECK_BUILD() or CS_CHECK_LIB_WITH() via some
  1754. # emitter. If CACHE-VAR indicates that the build succeeded, then the
  1755. # following properties are emitted:
  1756. #
  1757. # PREFIX.AVAILABLE = yes
  1758. # PREFIX.CFLAGS = $CACHE-VAR_cflags
  1759. # PREFIX.LFLAGS = $CACHE-VAR_lflags $CACHE-VAR_libs
  1760. #
  1761. # EMITTER is a macro name, such as CS_JAMCONFIG_PROPERTY or
  1762. # CS_MAKEFILE_PROPERTY, which performs the actual task of emitting the
  1763. # KEY/VALUE tuple. If EMITTER is omitted, CS_JAMCONFIG_PROPERTY is used.
  1764. #------------------------------------------------------------------------------
  1765. AC_DEFUN([CS_EMIT_BUILD_RESULT],
  1766. [AS_IF([test "$$1" = yes],
  1767. [CS_EMIT_BUILD_PROPERTY([$2.AVAILABLE], [yes], [], [], [$3])
  1768. CS_EMIT_BUILD_PROPERTY([$2.CFLAGS], [$$1_cflags], [], [], [$3])
  1769. CS_EMIT_BUILD_PROPERTY([$2.LFLAGS], [$$1_lflags $$1_libs],
  1770. [], [], [$3])])])
  1771. #------------------------------------------------------------------------------
  1772. # CS_EMIT_BUILD_FLAGS(MESSAGE, CACHE-VAR, FLAGS, [LANGUAGE], EMITTER-KEY,
  1773. # [APPEND], [ACTION-IF-RECOGNIZED],
  1774. # [ACTION-IF-NOT-RECOGNIZED], [EMITTER])
  1775. # A convenience wrapper for CS_CHECK_BUILD_FLAGS() which also records the
  1776. # results via CS_EMIT_BUILD_PROPERTY(). Checks if the compiler or linker
  1777. # recognizes a command-line option. MESSAGE is the "checking" message.
  1778. # CACHE-VAR is the shell cache variable which receives the flag
  1779. # recognized by the compiler or linker, or "no" if the flag was not
  1780. # recognized. FLAGS is a whitespace- delimited list of build tuples
  1781. # created with CS_CREATE_TUPLE(). Each tuple from FLAGS is attempted in
  1782. # order until one is found which is recognized by the compiler. After
  1783. # that, no further flags are checked. LANGUAGE is typically either C or
  1784. # C++ and specifies which compiler to use for the test. If LANGUAGE is
  1785. # omitted, C is used. EMITTER-KEY is the name to pass as the emitter's
  1786. # "key" argument if a usable flag is encountered. If APPEND is not the
  1787. # empty string, then the discovered flag is appended to the existing
  1788. # value of the EMITTER-KEY. If the command-line option was recognized,
  1789. # then ACTION-IF-RECOGNIZED is invoked, otherwise
  1790. # ACTION-IF-NOT-RECOGNIZED is invoked. EMITTER is a macro name, such as
  1791. # CS_JAMCONFIG_PROPERTY or CS_MAKEFILE_PROPERTY, which performs the
  1792. # actual task of emitting the KEY/VALUE tuple; it should also accept
  1793. # APPEND as an optional third argument. If EMITTER is omitted,
  1794. # CS_JAMCONFIG_PROPERTY is used.
  1795. #------------------------------------------------------------------------------
  1796. AC_DEFUN([CS_EMIT_BUILD_FLAGS],
  1797. [CS_CHECK_BUILD_FLAGS([$1], [$2], [$3], [$4],
  1798. [CS_EMIT_BUILD_PROPERTY([$5], [$$2], [$6], [], [$9])
  1799. $7],
  1800. [$8])])
  1801. #------------------------------------------------------------------------------
  1802. # CS_EMITTER_OPTIONAL([EMITTER])
  1803. # The CS_EMIT_FOO() macros optionally accept an emitter. If no emitter is
  1804. # supplied to those macros, then a default emitter is chosen. Other
  1805. # macros, however, which perform testing and optionally emit the results
  1806. # may wish to interpret an omitted EMITTER as a request not to emit the
  1807. # results. CS_EMITTER_OPTIONAL() is a convenience macro to help in these
  1808. # cases. It should be passed to one of the CS_EMIT_FOO() macros in place
  1809. # of the literal EMITTER argument. It functions by re-interpretating
  1810. # EMITTER as follows:
  1811. #
  1812. # - If EMITTER is omitted, then CS_NULL_EMITTER is returned, effectively
  1813. # disabling output by the CS_EMIT_FOO() macro.
  1814. # - If EMITTER is the literal string "emit" or "yes", then it returns an
  1815. # empty string, which signals to the CS_EMIT_FOO() macro that is should
  1816. # use its default emitter.
  1817. # - Any other value for EMITTER is passed along as-is to the
  1818. # CS_EMIT_FOO() macro.
  1819. #------------------------------------------------------------------------------
  1820. AC_DEFUN([CS_EMITTER_OPTIONAL],
  1821. [m4_case([$1],
  1822. [], [[CS_NULL_EMITTER]],
  1823. [emit], [],
  1824. [yes], [],
  1825. [[$1]])])
  1826. #------------------------------------------------------------------------------
  1827. # CS_NULL_EMITTER(KEY, VALUE, [APPEND])
  1828. # A do-nothing emitter suitable for use as the EMITTER argument of one of
  1829. # the CS_EMIT_FOO() macros.
  1830. #------------------------------------------------------------------------------
  1831. AC_DEFUN([CS_NULL_EMITTER], [:
  1832. ])
  1833. #------------------------------------------------------------------------------
  1834. # CS_SUBST_EMITTER(KEY, VALUE, [APPEND])
  1835. # An emitter wrapped around AC_SUBST(). Invokes
  1836. # AC_SUBST(AS_TR_SH(KEY),VALUE). The APPEND argument is ignored.
  1837. # Suitable for use as the EMITTER argument of one of the CS_EMIT_FOO()
  1838. # macros. The call to AS_TR_SH() ensures that KEY is transformed into a
  1839. # valid shell variable. For instance, if a macro attempts to emit
  1840. # MYLIB.CFLAGS and MYLIB.LFLAGS via CS_SUBST_EMITTER(), then the names
  1841. # will be transformed to MYLIB_CFLAGS and MYLIB_LFLAGS, respectively, for
  1842. # the invocation of AC_SUBST().
  1843. #------------------------------------------------------------------------------
  1844. AC_DEFUN([CS_SUBST_EMITTER], [AC_SUBST(AS_TR_SH([$1]),[$2])])
  1845. #------------------------------------------------------------------------------
  1846. # CS_DEFINE_EMITTER(KEY, VALUE, [APPEND])
  1847. # An emitter wrapped around AC_DEFINE_UNQUOTED(). Invokes
  1848. # AC_DEFINE_UNQUOTED(AS_TR_CPP(KEY),VALUE). The APPEND argument is
  1849. # ignored. Suitable for use as the EMITTER argument of one of the
  1850. # CS_EMIT_FOO() macros. The call to AS_TR_CPP() ensures that KEY is a
  1851. # well-formed token for the C-preprocessor.
  1852. #------------------------------------------------------------------------------
  1853. AC_DEFUN([CS_DEFINE_EMITTER],
  1854. [AC_DEFINE_UNQUOTED(AS_TR_CPP([$1]),[$2],
  1855. [Define when feature is available])])
  1856. # headercache.m4 -*- Autoconf -*-
  1857. #==============================================================================
  1858. # Copyright (C)2003 by Eric Sunshine <[email protected]>
  1859. #
  1860. # This library is free software; you can redistribute it and/or modify it
  1861. # under the terms of the GNU Library General Public License as published by
  1862. # the Free Software Foundation; either version 2 of the License, or (at your
  1863. # option) any later version.
  1864. #
  1865. # This library is distributed in the hope that it will be useful, but
  1866. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  1867. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
  1868. # License for more details.
  1869. #
  1870. # You should have received a copy of the GNU Library General Public License
  1871. # along with this library; if not, write to the Free Software Foundation,
  1872. # Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1873. #
  1874. #==============================================================================
  1875. AC_PREREQ([2.56])
  1876. #------------------------------------------------------------------------------
  1877. # Text cache facility for C-style #define properties. The cache is stored in
  1878. # the shell variable cs_header_text.
  1879. #
  1880. # CS_HEADER_APPEND(TEXT)
  1881. # Append text to the C header text cache. This is a cover for
  1882. # CS_TEXT_CACHE_APPEND().
  1883. #
  1884. # CS_HEADER_PREPEND(TEXT)
  1885. # Prepend text to the C header text cache. This is a cover for
  1886. # CS_TEXT_CACHE_PREPEND().
  1887. #
  1888. # CS_HEADER_PROPERTY(KEY, [VALUE])
  1889. # Append a line of the form "#define KEY VALUE" to the C header text
  1890. # cache. If the VALUE argument is omitted, then the appended line has
  1891. # the simplified form "#define KEY".
  1892. #
  1893. # CS_HEADER_OUTPUT(FILENAME)
  1894. # Instruct config.status to write the C header text cache to the given
  1895. # filename. This is a cover for CS_TEXT_CACHE_OUTPUT().
  1896. #------------------------------------------------------------------------------
  1897. AC_DEFUN([CS_HEADER_APPEND], [CS_TEXT_CACHE_APPEND([cs_header_text], [$1])])
  1898. AC_DEFUN([CS_HEADER_PREPEND], [CS_TEXT_CACHE_PREPEND([cs_header_text], [$1])])
  1899. AC_DEFUN([CS_HEADER_PROPERTY],
  1900. [CS_HEADER_APPEND([@%:@define $1[]m4_ifval([$2], [ $2], [])
  1901. ])])
  1902. AC_DEFUN([CS_HEADER_OUTPUT], [CS_TEXT_CACHE_OUTPUT([cs_header_text], [$1])])
  1903. #-----------------------------------------------------------------------------
  1904. # installdirs.m4 (c) Matze Braun <[email protected]>
  1905. # Macro for emitting the installation paths gathered by Autoconf.
  1906. #
  1907. # This library is free software; you can redistribute it and/or modify it
  1908. # under the terms of the GNU Library General Public License as published by
  1909. # the Free Software Foundation; either version 2 of the License, or (at your
  1910. # option) any later version.
  1911. #
  1912. # This library is distributed in the hope that it will be useful, but
  1913. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  1914. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
  1915. # License for more details.
  1916. #
  1917. # You should have received a copy of the GNU Library General Public License
  1918. # along with this library; if not, write to the Free Software Foundation,
  1919. # Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1920. #
  1921. #-----------------------------------------------------------------------------
  1922. #-----------------------------------------------------------------------------
  1923. # CS_OUTPUT_INSTALLDIRS([EMITTER], [RAW-BACKSLASHES])
  1924. # Emit installation directories collected by Autoconf. EMITTER is a macro
  1925. # name, such as CS_JAMCONFIG_PROPERTY or CS_MAKEFILE_PROPERTY, which performs
  1926. # the actual task of emitting the KEY/VALUE tuple. If EMITTER is omitted,
  1927. # CS_JAMCONFIG_PROPERTY is used. If RAW-BACKSLASHES is not provided, then
  1928. # backslashes in emitted values are each escaped with an additional
  1929. # backslash. If RAW-BACKSLASHES is not the null value, then backslashes are
  1930. # emitted raw. The following properties are emitted:
  1931. #
  1932. # prefix
  1933. # exec_prefix
  1934. # bindir
  1935. # sbindir
  1936. # libexecdir
  1937. # datadir
  1938. # sysconfdir
  1939. # sharedstatedir
  1940. # localstatedir
  1941. # libdir
  1942. # includedir
  1943. # oldincludedir
  1944. # infodir
  1945. # mandir
  1946. #-----------------------------------------------------------------------------
  1947. AC_DEFUN([CS_OUTPUT_INSTALLDIRS],[
  1948. # Handle the case when no prefix is given, and the special case when a path
  1949. # contains more than 2 slashes, these paths seem to be correct but Jam fails
  1950. # on them.
  1951. AS_IF([test $prefix = NONE],
  1952. [cs_install_prefix="$ac_default_prefix"],
  1953. [cs_install_prefix=`echo "$prefix" | sed -e 's:///*:/:g'`])
  1954. AS_IF([test $exec_prefix = NONE],
  1955. [cs_install_exec_prefix="AS_ESCAPE([$(prefix)])"],
  1956. [cs_install_exec_prefix=`echo "$exec_prefix" | sed -e 's:///*:/:g'`])
  1957. _CS_OUTPUT_INSTALL_DIRS([$1], [prefix],
  1958. [CS_PREPARE_INSTALLPATH([$cs_install_prefix], [$2])])
  1959. _CS_OUTPUT_INSTALL_DIRS([$1], [exec_prefix],
  1960. [CS_PREPARE_INSTALLPATH([$cs_install_exec_prefix], [$2])])
  1961. _CS_OUTPUT_INSTALL_DIRS([$1], [bindir],
  1962. [CS_PREPARE_INSTALLPATH([$bindir], [$2])])
  1963. _CS_OUTPUT_INSTALL_DIRS([$1], [sbindir],
  1964. [CS_PREPARE_INSTALLPATH([$sbindir], [$2])])
  1965. _CS_OUTPUT_INSTALL_DIRS([$1], [libexecdir],
  1966. [CS_PREPARE_INSTALLPATH([$libexecdir], [$2])])
  1967. _CS_OUTPUT_INSTALL_DIRS([$1], [datadir],
  1968. [CS_PREPARE_INSTALLPATH([$datadir], [$2])])
  1969. _CS_OUTPUT_INSTALL_DIRS([$1], [sysconfdir],
  1970. [CS_PREPARE_INSTALLPATH([$sysconfdir], [$2])])
  1971. _CS_OUTPUT_INSTALL_DIRS([$1], [sharedstatedir],
  1972. [CS_PREPARE_INSTALLPATH([$sharedstatedir], [$2])])
  1973. _CS_OUTPUT_INSTALL_DIRS([$1], [localstatedir],
  1974. [CS_PREPARE_INSTALLPATH([$localstatedir], [$2])])
  1975. _CS_OUTPUT_INSTALL_DIRS([$1], [libdir],
  1976. [CS_PREPARE_INSTALLPATH([$libdir], [$2])])
  1977. _CS_OUTPUT_INSTALL_DIRS([$1], [includedir],
  1978. [CS_PREPARE_INSTALLPATH([$includedir], [$2])])
  1979. _CS_OUTPUT_INSTALL_DIRS([$1], [oldincludedir],
  1980. [CS_PREPARE_INSTALLPATH([$oldincludedir], [$2])])
  1981. _CS_OUTPUT_INSTALL_DIRS([$1], [infodir],
  1982. [CS_PREPARE_INSTALLPATH([$infodir], [$2])])
  1983. _CS_OUTPUT_INSTALL_DIRS([$1], [mandir],
  1984. [CS_PREPARE_INSTALLPATH([$mandir], [$2])])
  1985. ])
  1986. AC_DEFUN([_CS_OUTPUT_INSTALL_DIRS],
  1987. [m4_default([$1], [CS_JAMCONFIG_PROPERTY])([$2], [$3])])
  1988. #-----------------------------------------------------------------------------
  1989. # CS_PREPARE_INSTALLPATH(VALUE, [RAW-BACKSLASHES])
  1990. # Transform variable references of the form ${bla} to $(bla) in VALUE and
  1991. # correctly quotes backslashes. This is needed if you need to emit some of
  1992. # the paths from Autoconf. RAW-BACKSLASHES has the same meaning as in
  1993. # CS_OUTPUT_INSTALLDIRS.
  1994. #-----------------------------------------------------------------------------
  1995. AC_DEFUN([CS_PREPARE_INSTALLPATH],
  1996. [`echo "$1" | sed 's/\${\([[a-zA-Z_][a-zA-Z_]]*\)}/$(\1)/g;m4_ifval([$2],
  1997. [s/\\/\\\\/g], [s/\\\\/\\\\\\\\/g])'`])
  1998. # jamcache.m4 -*- Autoconf -*-
  1999. #==============================================================================
  2000. # Copyright (C)2003 by Eric Sunshine <[email protected]>
  2001. #
  2002. # This library is free software; you can redistribute it and/or modify it
  2003. # under the terms of the GNU Library General Public License as published by
  2004. # the Free Software Foundation; either version 2 of the License, or (at your
  2005. # option) any later version.
  2006. #
  2007. # This library is distributed in the hope that it will be useful, but
  2008. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  2009. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
  2010. # License for more details.
  2011. #
  2012. # You should have received a copy of the GNU Library General Public License
  2013. # along with this library; if not, write to the Free Software Foundation,
  2014. # Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  2015. #
  2016. #==============================================================================
  2017. AC_PREREQ([2.56])
  2018. #------------------------------------------------------------------------------
  2019. # Text cache facility for Jam-style properties. The cache is stored in
  2020. # the shell variable cs_jamfile_text.
  2021. #
  2022. # CS_JAMCONFIG_APPEND(TEXT)
  2023. # Append text to the Jam text cache. This is a cover for
  2024. # CS_TEXT_CACHE_APPEND().
  2025. #
  2026. # CS_JAMCONFIG_PREPEND(TEXT)
  2027. # Prepend text to the Jam text cache. This is a cover for
  2028. # CS_TEXT_CACHE_PREPEND().
  2029. #
  2030. # CS_JAMCONFIG_PROPERTY(KEY, VALUE, [APPEND], [UNCONDITIONAL])
  2031. # Append a line of the form "KEY ?= VALUE" to the Jam text cache. If the
  2032. # APPEND argument is not the empty string, then VALUE is appended to the
  2033. # existing value of KEY using the form "KEY += VALUE". If the
  2034. # UNCONDITIONAL argument is not empty, then the value of KEY is set
  2035. # unconditionally "KEY = VALUE", rather than via "KEY ?= VALUE". APPEND
  2036. # takes precedence over UNCONDITIONAL. Note that if VALUE references
  2037. # other Jam variables, for example $(OBJS), then be sure to protect the
  2038. # value with AS_ESCAPE(). For example:
  2039. # CS_JAMCONFIG_PROPERTY([ALLOBJS], [AS_ESCAPE([$(OBJS) $(LIBOBJS)])])
  2040. #
  2041. # CS_JAMCONFIG_OUTPUT(FILENAME)
  2042. # Instruct config.status to write the Jam text cache to the given
  2043. # filename. This is a cover for CS_TEXT_CACHE_OUTPUT().
  2044. #------------------------------------------------------------------------------
  2045. AC_DEFUN([CS_JAMCONFIG_APPEND],
  2046. [CS_TEXT_CACHE_APPEND([cs_jamconfig_text], [$1])])
  2047. AC_DEFUN([CS_JAMCONFIG_PREPEND],
  2048. [CS_TEXT_CACHE_PREPEND([cs_jamconfig_text], [$1])])
  2049. AC_DEFUN([CS_JAMCONFIG_PROPERTY],
  2050. [CS_JAMCONFIG_APPEND(
  2051. [$1 m4_ifval([$3], [+=], m4_ifval([$4], [=], [?=])) \"$2\" ;
  2052. ])])
  2053. AC_DEFUN([CS_JAMCONFIG_OUTPUT],
  2054. [CS_TEXT_CACHE_OUTPUT([cs_jamconfig_text], [$1])])
  2055. # makecache.m4 -*- Autoconf -*-
  2056. #==============================================================================
  2057. # Copyright (C)2003 by Eric Sunshine <[email protected]>
  2058. #
  2059. # This library is free software; you can redistribute it and/or modify it
  2060. # under the terms of the GNU Library General Public License as published by
  2061. # the Free Software Foundation; either version 2 of the License, or (at your
  2062. # option) any later version.
  2063. #
  2064. # This library is distributed in the hope that it will be useful, but
  2065. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  2066. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
  2067. # License for more details.
  2068. #
  2069. # You should have received a copy of the GNU Library General Public License
  2070. # along with this library; if not, write to the Free Software Foundation,
  2071. # Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  2072. #
  2073. #==============================================================================
  2074. AC_PREREQ([2.56])
  2075. #------------------------------------------------------------------------------
  2076. # Text cache facility for makefile-style properties. The cache is stored in
  2077. # the shell variable cs_makefile_text.
  2078. #
  2079. # CS_MAKEFILE_APPEND(TEXT)
  2080. # Append text to the makefile text cache. This is a cover for
  2081. # CS_TEXT_CACHE_APPEND().
  2082. #
  2083. # CS_MAKEFILE_PREPEND(TEXT)
  2084. # Prepend text to the makefile text cache. This is a cover for
  2085. # CS_TEXT_CACHE_PREPEND().
  2086. #
  2087. # CS_MAKEFILE_PROPERTY(KEY, VALUE, [APPEND])
  2088. # Append a line of the form "KEY = VALUE" to the makefile text cache. If
  2089. # the APPEND argument is not the empty string, then VALUE is appended to
  2090. # the existing value of KEY using the form "KEY += VALUE". Note that if
  2091. # VALUE references other makefile variables, for example $(OBJS), then be
  2092. # sure to protect the value with AS_ESCAPE(). For example:
  2093. # CS_MAKEFILE_PROPERTY([ALLOBJS], [AS_ESCAPE([$(OBJS) $(LIBOBJS)])])
  2094. #
  2095. # CS_MAKEFILE_OUTPUT(FILENAME)
  2096. # Instruct config.status to write the makefile text cache to the given
  2097. # filename. This is a cover for CS_TEXT_CACHE_OUTPUT().
  2098. #------------------------------------------------------------------------------
  2099. AC_DEFUN([CS_MAKEFILE_APPEND],
  2100. [CS_TEXT_CACHE_APPEND([cs_makefile_text], [$1])])
  2101. AC_DEFUN([CS_MAKEFILE_PREPEND],
  2102. [CS_TEXT_CACHE_PREPEND([cs_makefile_text], [$1])])
  2103. AC_DEFUN([CS_MAKEFILE_PROPERTY],
  2104. [CS_MAKEFILE_APPEND([$1 m4_ifval([$3], [+=], [=]) $2
  2105. ])])
  2106. AC_DEFUN([CS_MAKEFILE_OUTPUT],[CS_TEXT_CACHE_OUTPUT([cs_makefile_text], [$1])])
  2107. # mkdir.m4 -*- Autoconf -*-
  2108. #==============================================================================
  2109. # Copyright (C)2003 by Eric Sunshine <[email protected]>
  2110. #
  2111. # This library is free software; you can redistribute it and/or modify it
  2112. # under the terms of the GNU Library General Public License as published by
  2113. # the Free Software Foundation; either version 2 of the License, or (at your
  2114. # option) any later version.
  2115. #
  2116. # This library is distributed in the hope that it will be useful, but
  2117. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  2118. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
  2119. # License for more details.
  2120. #
  2121. # You should have received a copy of the GNU Library General Public License
  2122. # along with this library; if not, write to the Free Software Foundation,
  2123. # Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  2124. #
  2125. #==============================================================================
  2126. AC_PREREQ([2.56])
  2127. #------------------------------------------------------------------------------
  2128. # CS_CHECK_MKDIR
  2129. # Determine how to create a directory and a directory tree. Sets the
  2130. # shell variable MKDIR to the command which creates a directory, and
  2131. # MKDIRS to the command which creates a directory tree. Invokes
  2132. # AC_SUBST() for MKDIR and MKDIRS.
  2133. #
  2134. # IMPLEMENTATION NOTES
  2135. # We need to know the exact commands, so that we can emit them, thus the
  2136. # AS_MKDIR_P function is not what we want to use here since it does not
  2137. # provide access to the commands (and might not even discover suitable
  2138. # commands). First try "mkdir -p", then try the older "mkdirs".
  2139. # Finally, if the mkdir command failed to recognize -p, then it might
  2140. # have created a directory named "-p", so clean up that bogus directory.
  2141. #------------------------------------------------------------------------------
  2142. AC_DEFUN([CS_CHECK_MKDIR],
  2143. [AC_CACHE_CHECK([how to create a directory], [cs_cv_shell_mkdir],
  2144. [cs_cv_shell_mkdir='mkdir'])
  2145. AC_SUBST([MKDIR], [$cs_cv_shell_mkdir])
  2146. AC_CACHE_CHECK([how to create a directory tree], [cs_cv_shell_mkdir_p],
  2147. [if $cs_cv_shell_mkdir -p . 2>/dev/null; then
  2148. cs_cv_shell_mkdir_p='mkdir -p'
  2149. elif mkdirs . 2>/dev/null; then
  2150. cs_cv_shell_mkdir_p='mkdirs'
  2151. fi
  2152. test -d ./-p && rmdir ./-p])
  2153. AS_VAR_SET_IF([cs_cv_shell_mkdir_p],
  2154. [AC_SUBST([MKDIRS], [$cs_cv_shell_mkdir_p])],
  2155. [CS_MSG_ERROR([do not know how to create a directory tree])])])
  2156. #------------------------------------------------------------------------------
  2157. # Replacement for AS_MKDIR_P() from m4sugar/m4sh.m4 which fixes two problems
  2158. # which are present in Autoconf 2.57 and probably all earlier 2.5x versions.
  2159. # This bug, along with a patch, was submitted to the Autoconf GNATS database by
  2160. # Eric Sunshine as #227 on 17-Dec-2002. The bogus "-p" directory bug was fixed
  2161. # for Autoconf 2.58 on 26-Sep-2003. The "mkdirs" optimization was not accepted
  2162. # (since it is unnecessary; it's only an optimization).
  2163. #
  2164. # 1) Removes bogus "-p" directory which the stock AS_MKDIR_P() leaves laying
  2165. # around in the working directory if the mkdir command does not recognize
  2166. # the -p option.
  2167. # 2) Takes advantage of the older "mkdirs" program if it exists and if "mkdir
  2168. # -p" does not work.
  2169. #------------------------------------------------------------------------------
  2170. m4_defun([_AS_MKDIR_P_PREPARE],
  2171. [if mkdir -p . 2>/dev/null; then
  2172. as_mkdir_p='mkdir -p'
  2173. elif mkdirs . 2>/dev/null; then
  2174. as_mkdir_p='mkdirs'
  2175. else
  2176. as_mkdir_p=''
  2177. fi
  2178. test -d ./-p && rmdir ./-p
  2179. ])# _AS_MKDIR_P_PREPARE
  2180. m4_define([AS_MKDIR_P],
  2181. [AS_REQUIRE([_$0_PREPARE])dnl
  2182. { if test -n "$as_mkdir_p"; then
  2183. $as_mkdir_p $1
  2184. else
  2185. as_dir=$1
  2186. as_dirs=
  2187. while test ! -d "$as_dir"; do
  2188. as_dirs="$as_dir $as_dirs"
  2189. as_dir=`AS_DIRNAME("$as_dir")`
  2190. done
  2191. test ! -n "$as_dirs" || mkdir $as_dirs
  2192. fi || AS_ERROR([cannot create directory $1]); }
  2193. ])# AS_MKDIR_P
  2194. #==============================================================================
  2195. # packageinfo.m4
  2196. # Macros for setting general info on the package, such as name and version
  2197. # numbers and propagate them to the generated make and Jam property files.
  2198. #
  2199. # Copyright (C)2003 by Matthias Braun <[email protected]>
  2200. # Copyright (C)2003,2004 by Eric Sunshine <[email protected]>
  2201. #
  2202. # This library is free software; you can redistribute it and/or modify it
  2203. # under the terms of the GNU Library General Public License as published by
  2204. # the Free Software Foundation; either version 2 of the License, or (at your
  2205. # option) any later version.
  2206. #
  2207. # This library is distributed in the hope that it will be useful, but
  2208. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  2209. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
  2210. # License for more details.
  2211. #
  2212. # You should have received a copy of the GNU Library General Public License
  2213. # along with this library; if not, write to the Free Software Foundation,
  2214. # Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  2215. #
  2216. #==============================================================================
  2217. #------------------------------------------------------------------------------
  2218. # CS_PACKAGEINFO([LONGNAME], [COPYRIGHT, [HOMEPAGE])
  2219. # Set additional information for the package. Note that the version
  2220. # number of your application should only contain numbers, because on
  2221. # Windows you can only set numerical values in some of the file
  2222. # properties (such as versioninfo .rc files).
  2223. #------------------------------------------------------------------------------
  2224. AC_DEFUN([CS_PACKAGEINFO],
  2225. [PACKAGE_LONGNAME="[$1]"
  2226. PACKAGE_COPYRIGHT="[$2]"
  2227. PACKAGE_HOMEPAGE="[$3]"
  2228. ])
  2229. #------------------------------------------------------------------------------
  2230. # CS_EMIT_PACKAGEINFO([EMITTER])
  2231. # Emit extended package information using the provided EMITTER. EMITTER
  2232. # is a macro name, such as CS_JAMCONFIG_PROPERTY or CS_MAKEFILE_PROPERTY,
  2233. # which performs the actual task of emitting the KEY/VALUE tuple. If
  2234. # EMITTER is omitted, CS_JAMCONFIG_PROPERTY is used. For backward
  2235. # compatibility, if EMITTER is the literal value "jam", then
  2236. # CS_JAMCONFIG_PROPERTY is used; if it is "make", then
  2237. # CS_MAKEFILE_PROPERTY is used; however use of these literal names is
  2238. # highly discouraged.
  2239. #------------------------------------------------------------------------------
  2240. AC_DEFUN([CS_EMIT_PACKAGEINFO],
  2241. [_CS_EMIT_PACKAGEINFO([$1], [PACKAGE_NAME], [$PACKAGE_NAME])
  2242. _CS_EMIT_PACKAGEINFO([$1], [PACKAGE_VERSION], [$PACKAGE_VERSION])
  2243. _CS_EMIT_PACKAGEINFO([$1], [PACKAGE_STRING], [$PACKAGE_STRING])
  2244. _CS_EMIT_PACKAGEINFO([$1], [PACKAGE_BUGREPORT], [$PACKAGE_BUGREPORT])
  2245. _CS_EMIT_PACKAGEINFO([$1], [PACKAGE_LONGNAME], [$PACKAGE_LONGNAME])
  2246. _CS_EMIT_PACKAGEINFO([$1], [PACKAGE_HOMEPAGE], [$PACKAGE_HOMEPAGE])
  2247. _CS_EMIT_PACKAGEINFO([$1], [PACKAGE_COPYRIGHT], [$PACKAGE_COPYRIGHT])
  2248. for cs_veritem in m4_translit(AC_PACKAGE_VERSION, [.], [ ]); do
  2249. _CS_EMIT_PACKAGEINFO([$1], [PACKAGE_VERSION_LIST], [$cs_veritem], [+])
  2250. done
  2251. ])
  2252. AC_DEFUN([_CS_EMIT_PACKAGEINFO],
  2253. [m4_case([$1],
  2254. [make], [CS_MAKEFILE_PROPERTY([$2], [$3], [$4])],
  2255. [jam], [CS_JAMCONFIG_PROPERTY([$2], [$3], [$4])],
  2256. [], [CS_JAMCONFIG_PROPERTY([$2], [$3], [$4])],
  2257. [$1([$2], [$3], [$4])])])
  2258. # path.m4 -*- Autoconf -*-
  2259. #==============================================================================
  2260. # Copyright (C)2004 by Eric Sunshine <[email protected]>
  2261. #
  2262. # This library is free software; you can redistribute it and/or modify it
  2263. # under the terms of the GNU Library General Public License as published by
  2264. # the Free Software Foundation; either version 2 of the License, or (at your
  2265. # option) any later version.
  2266. #
  2267. # This library is distributed in the hope that it will be useful, but
  2268. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  2269. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
  2270. # License for more details.
  2271. #
  2272. # You should have received a copy of the GNU Library General Public License
  2273. # along with this library; if not, write to the Free Software Foundation,
  2274. # Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  2275. #
  2276. #==============================================================================
  2277. AC_PREREQ([2.56])
  2278. #------------------------------------------------------------------------------
  2279. # CS_PATH_NORMALIZE(STRING)
  2280. # Normalize a pathname at run-time by transliterating Windows/DOS
  2281. # backslashes to forward slashes. Also collapses whitespace.
  2282. #------------------------------------------------------------------------------
  2283. AC_DEFUN([CS_PATH_NORMALIZE],
  2284. [`echo "x$1" | tr '\\\\' '/' | sed 's/^x//;s/ */ /g;s/^ //;s/ $//'`])
  2285. #------------------------------------------------------------------------------
  2286. # CS_RUN_PATH_NORMALIZE(COMMAND)
  2287. # Normalize the pathname emitted by COMMAND by transliterating
  2288. # Windows/DOS backslashes to forward slashes. Also collapses whitespace.
  2289. #------------------------------------------------------------------------------
  2290. AC_DEFUN([CS_RUN_PATH_NORMALIZE],
  2291. [`AC_RUN_LOG([$1]) | tr '\\\\' '/' | sed 's/^x//;s/ */ /g;s/^ //;s/ $//'`])
  2292. ###############################################################################
  2293. # progver.m4
  2294. # Written by Norman Kramer <[email protected]>
  2295. #
  2296. # This library is free software; you can redistribute it and/or modify it
  2297. # under the terms of the GNU Library General Public License as published by
  2298. # the Free Software Foundation; either version 2 of the License, or (at your
  2299. # option) any later version.
  2300. #
  2301. # This library is distributed in the hope that it will be useful, but
  2302. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  2303. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
  2304. # License for more details.
  2305. #
  2306. # You should have received a copy of the GNU Library General Public License
  2307. # along with this library; if not, write to the Free Software Foundation,
  2308. # Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  2309. #
  2310. ###############################################################################
  2311. #
  2312. # From the input pattern we create regular expressions we send through sed
  2313. # to extract the version information from the standard input to sed.
  2314. # Then we extract from the resulting version string subparts.
  2315. # The same happens with the supplied version string. It too is split into its
  2316. # subparts according to the pattern.
  2317. # Then the subparts from the gathered version string and the supplied one are
  2318. # compared.
  2319. #
  2320. # How does the pattern look like ?
  2321. # It is a sequence of 9s and _s and separators.
  2322. # 9 denotes a non empty sequence of digits.
  2323. # _ denotes a non empty sequence of characters from the class [a-zA-Z].
  2324. # | everything behind is optional
  2325. # Everything else is treated as a separator.
  2326. # Consecutive 9s and _s are compressed to contain only one of each type.
  2327. # For instance "99_.9.__abc9_" will become "9_.9._abc9_".
  2328. #
  2329. # How we find the parts we compare ?
  2330. # From this transformed string we yield the parts we will later compare.
  2331. # We break up the string as follows:
  2332. # Any sequence of separators represent one breakup. Additional breakups are
  2333. # placed behind every 9 and _ .
  2334. # So the example from above will give:
  2335. #
  2336. # "99_.9.__abc9_" ===compress==> "9_.9._abc9_" ===breakup==> "9" "_" "9" "_" "9" "_"
  2337. #
  2338. # How we create the regular expressions ?
  2339. # We take the compressed pattern and quote every separator.
  2340. # The we replace the 9s with [0-9][0-9]*
  2341. # and the _s with [a-zA-Z][a-zA-Z]* .
  2342. # The above example will become:
  2343. #
  2344. # "99_.9.__abc9_" ===compress==> "9_.9._abc9_" ===rexify==>
  2345. # [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]*
  2346. #
  2347. # Voila.
  2348. #
  2349. # To yield the subparts from the string we additionally enclose the
  2350. # 9s and _s with \( and \).
  2351. #
  2352. ###############################################################################
  2353. # ****************************************************************
  2354. # ** helper definitions **
  2355. # ****************************************************************
  2356. m4_define([CS_VCHK_RUNTH], [m4_pushdef([i], [$1])m4_if($1,0,,[CS_VCHK_RUNTH(m4_decr($1), [$2])][$2])m4_popdef([i])])
  2357. m4_define([CS_VCHK_PREFIX], [])
  2358. m4_define([CS_VCHK_SUFFIX], [])
  2359. m4_define([CS_VCHK_GROUPPREFIX], [\(])
  2360. m4_define([CS_VCHK_GROUPSUFFIX], [\)])
  2361. m4_define([CS_VCHK_CHAR], [[[[a-zA-Z]]]])
  2362. m4_define([CS_VCHK_DIGIT], [[[0-9]]])
  2363. m4_define([CS_VCHK_SEQUENCE], [CS_VCHK_PREFIX[]CS_VCHK_SINGLE[]CS_VCHK_SINGLE[]*CS_VCHK_SUFFIX[]])
  2364. m4_define([CS_VCHK_OPTSEQUENCE], [CS_VCHK_PREFIX[]CS_VCHK_SINGLE[]*CS_VCHK_SUFFIX[]])
  2365. m4_define([CS_VCHK_REXSEQ], [m4_bpatsubst($1, [$2], [[]CS_VCHK_SEQUENCE[]])])
  2366. m4_define([CS_VCHK_GROUPINGON], [m4_pushdef([CS_VCHK_PREFIX], [CS_VCHK_GROUPPREFIX])m4_pushdef([CS_VCHK_SUFFIX], [CS_VCHK_GROUPSUFFIX])])
  2367. m4_define([CS_VCHK_GROUPINGOFF], [m4_popdef([CS_VCHK_SUFFIX])m4_popdef([CS_VCHK_PREFIX])])
  2368. m4_define([CS_VCHK_OPTON], [m4_pushdef([CS_VCHK_SEQUENCE], [CS_VCHK_OPTSEQUENCE])])
  2369. m4_define([CS_VCHK_OPTOFF], [m4_popdef([CS_VCHK_SEQUENCE])])
  2370. m4_define([CS_VCHK_RMOPT], [CS_VCHK_RMCHAR([$1], m4_index([$1], [|]))])
  2371. m4_define([CS_VCHK_RMCHAR], [m4_if($2,-1,[$1],m4_substr([$1], 0, $2)[]m4_substr([$1], m4_incr($2)))])
  2372. m4_define([CS_VCHK_RMALL], [m4_translit([$1], [|], [])])
  2373. m4_define([CS_VCHK_CUTOFF], [m4_if(m4_index($1,[|]),-1, [$1], [m4_substr($1, 0, m4_index($1,[|]))])])
  2374. m4_define([CS_VCHK_CYCLEOPT], [
  2375. 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])])
  2376. ])
  2377. m4_define([CS_VCHK_TAIL], [m4_if(m4_index($1,[|]),-1, [], [m4_substr($1, m4_incr(m4_index($1,[|])))])])
  2378. m4_define([CS_VCHK_DUMMY_COMPRESS], [m4_bpatsubst(m4_bpatsubst([$1], [__*], [A]), [99*], [0])])
  2379. m4_define([CS_VCHK_DUMMY_TAIL], [CS_VCHK_DUMMY_COMPRESS(m4_translit(CS_VCHK_TAIL([$1]), [|], []))])
  2380. # ****************************************************************
  2381. # ** FlagsOn / FlagsOff **
  2382. # ****************************************************************
  2383. m4_define([CS_VCHK_FLAGSON],
  2384. [m4_if($#, 0, [],
  2385. $1, [], [],
  2386. [$1], [group], [CS_VCHK_GROUPINGON[]],
  2387. [$1], [opt], [CS_VCHK_OPTON[]])dnl
  2388. m4_if($#, 0, [], $1, [], [], [CS_VCHK_FLAGSON(m4_shift($@))])])
  2389. m4_define([CS_VCHK_FLAGSOFF],
  2390. [m4_if($#, 0, [],
  2391. $1, [], [],
  2392. $1, [group], [CS_VCHK_GROUPINGOFF[]],
  2393. [$1], [opt], [CS_VCHK_OPTOFF[]])dnl
  2394. m4_if($#, 0, [], $1, [], [], [CS_VCHK_FLAGSOFF(m4_shift($@))])])
  2395. # ****************************************************************
  2396. # ** rexify / sedify **
  2397. # ****************************************************************
  2398. m4_define([CS_VCHK_REXIFY],
  2399. [m4_pushdef([CS_VCHK_SINGLE], [$1])dnl
  2400. CS_VCHK_FLAGSON(m4_shift(m4_shift(m4_shift($@))))dnl
  2401. CS_VCHK_REXSEQ([$3], [$2])dnl
  2402. CS_VCHK_FLAGSOFF(m4_shift(m4_shift(m4_shift($@))))dnl
  2403. m4_popdef([CS_VCHK_SINGLE])])
  2404. m4_define([CS_VCHK_QUOTESEP], [m4_bpatsubst($1, [[^9_]], [\\\&])])
  2405. m4_define([CS_VCHK_REXCHAR], [CS_VCHK_REXIFY([CS_VCHK_CHAR], [__*], $@)])
  2406. m4_define([CS_VCHK_REXDIGIT], [CS_VCHK_REXIFY([CS_VCHK_DIGIT], [99*], $@)])
  2407. m4_define([CS_VCHK_SEDIFY], [CS_VCHK_REXDIGIT([CS_VCHK_REXCHAR([CS_VCHK_QUOTESEP([$1])], m4_shift($@))], m4_shift($@))])
  2408. m4_define([CS_VCHK_SEDEXPRALL], [/CS_VCHK_SEDIFY([$1])/!d;s/.*\(CS_VCHK_SEDIFY([$1])\).*/\1/;q])
  2409. m4_define([CS_VCHK_SEDEXPRNTH], [/CS_VCHK_SEDIFY([$1])/!d;s/.*CS_VCHK_SEDIFY([$1],[group]).*/\$2/])
  2410. # ****************************************************************
  2411. # ** Pattern splitting **
  2412. # ****************************************************************
  2413. m4_define([CS_VCHK_SPLITSEP], [CS_VCHK_REXIFY([s], [[^9_][^9_]*], $@)])
  2414. m4_define([CS_VCHK_SPLITDIGIT], [CS_VCHK_REXIFY([d], [99*], $@)])
  2415. m4_define([CS_VCHK_SPLITCHAR], [CS_VCHK_REXIFY([c], [__*], $@)])
  2416. # ****************************************************************
  2417. # ** return a list of 's' 'd' 'c' 'e' chars denoting the kind **
  2418. # ** pattern parts: separator, digit, char, end **
  2419. # ****************************************************************
  2420. m4_define([CS_VCHK_PATTERNLIST], [m4_pushdef([CS_VCHK_SEQUENCE], [CS_VCHK_SINGLE ])dnl
  2421. m4_translit(CS_VCHK_SPLITDIGIT([CS_VCHK_SPLITCHAR([CS_VCHK_SPLITSEP([$1])])]), [ ], m4_if([$2],[],[ ],[$2]))e[]dnl
  2422. m4_popdef([CS_VCHK_SEQUENCE])])
  2423. # ****************************************************************
  2424. # ** Build the shell commands we emit to the configure script. **
  2425. # ****************************************************************
  2426. m4_define([CS_VCHK_PATCOUNT], [m4_len(m4_bpatsubst(CS_VCHK_PATTERNLIST([$1]), [[^dc]]))])
  2427. # ****************************************************************************************
  2428. # ** CS_VCHK_EXTRACTVERSION(EXTRACT_CALL, MIN_VERSION, PATTERN, PRGPREFIX, COMPARISION) **
  2429. # ****************************************************************************************
  2430. m4_define([CS_VCHK_EXTRACTVERSION],
  2431. [cs_prog_$4_is_version=
  2432. cs_prog_$4_min_version=
  2433. cs_prog_$4_is_suffix=
  2434. cs_prog_$4_min_suffix=
  2435. cs_prog_$4_is_suffix_done=
  2436. cs_prog_$4_min_suffix_done=
  2437. CS_VCHK_CYCLEOPT([$3], [],
  2438. [test -z $cs_prog_$4_is_version && cs_prog_$4_is_version=`$1 | sed 'CS_VCHK_SEDEXPRALL([i])'`
  2439. 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 ; }
  2440. ])
  2441. CS_VCHK_CYCLEOPT([$3], ,
  2442. [test -z $cs_prog_$4_min_version && cs_prog_$4_min_version=`echo $2 | sed 'CS_VCHK_SEDEXPRALL([i])'`
  2443. 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 ; }
  2444. ])
  2445. CS_VCHK_RUNTH([CS_VCHK_PATCOUNT([$3])],
  2446. [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])'`
  2447. ])
  2448. CS_VCHK_RUNTH([CS_VCHK_PATCOUNT([$3])],
  2449. [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])'`
  2450. ])
  2451. cs_cv_prog_$4_version_ok=''
  2452. CS_VCHK_RUNTH([CS_VCHK_PATCOUNT([$3])],
  2453. [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 ; }
  2454. 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 ; }
  2455. ])
  2456. AS_IF([test -z "$cs_cv_prog_$4_version_ok"], [cs_cv_prog_$4_version_ok=yes])
  2457. cs_cv_prog_$4_version_ok_annotated="$cs_cv_prog_$4_version_ok"
  2458. AS_IF([test -n "$cs_prog_$4_is_version"],
  2459. [cs_cv_prog_$4_version_ok_annotated="$cs_cv_prog_$4_version_ok_annotated (version $cs_prog_$4_is_version)"])
  2460. ])
  2461. ##############################################################################
  2462. # CS_CHECK_PROG_VERSION(PROG, EXTRACT_CALL, VERSION, PATTERN,
  2463. # [ACTION-IF-OKAY], [ACTION-IF-NOT-OKAY], [CMP])
  2464. # Check the version of a program PROG.
  2465. # Version information is emitted by EXTRACT_CALL (for instance "bison -V").
  2466. # The discovered program version is compared against VERSION.
  2467. # The pattern of the version string matches PATTERN
  2468. # The extracted version and the supplied version are compared with the CMP
  2469. # operator. i.e. EXTRACTED_VERSION CMP SUPPLIED_VERSION
  2470. # CMP defaults to >= if not specified.
  2471. # ACTION-IF-OKAY is invoked if comparision yields true, otherwise
  2472. # ACTION-IF-NOT-OKAY is invoked.
  2473. #
  2474. # PATTERN literals: 9 .. marks a non empty sequence of digits
  2475. # _ .. marks a non empty sequence of characters from [a-zA-Z]
  2476. # | .. everything behind is optional
  2477. # .. everything else is taken as separator - it is better
  2478. # to not try stuff like space, slash or comma.
  2479. #
  2480. # The test results in cs_cv_prog_PROG_version_ok being either yes or no.
  2481. ##############################################################################
  2482. AC_DEFUN([CS_CHECK_PROG_VERSION],
  2483. [AC_CACHE_CHECK([if $1 version m4_default([$7],[>=]) $3],
  2484. [AS_TR_SH([cs_cv_prog_$1_version_ok_annotated])],
  2485. [CS_VCHK_EXTRACTVERSION([$2], [$3], [$4], AS_TR_SH([$1]),
  2486. m4_default([$7],[>=]))])
  2487. AS_IF([test "$AS_TR_SH([cs_cv_prog_$1_version_ok])" = yes], [$5], [$6])])
  2488. # qualify.m4 -*- Autoconf -*-
  2489. #==============================================================================
  2490. # Copyright (C)2005 by Eric Sunshine <[email protected]>
  2491. #
  2492. # This library is free software; you can redistribute it and/or modify it
  2493. # under the terms of the GNU Library General Public License as published by
  2494. # the Free Software Foundation; either version 2 of the License, or (at your
  2495. # option) any later version.
  2496. #
  2497. # This library is distributed in the hope that it will be useful, but
  2498. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  2499. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
  2500. # License for more details.
  2501. #
  2502. # You should have received a copy of the GNU Library General Public License
  2503. # along with this library; if not, write to the Free Software Foundation,
  2504. # Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  2505. #
  2506. #==============================================================================
  2507. AC_PREREQ([2.56])
  2508. #------------------------------------------------------------------------------
  2509. # CS_SYMBOL_QUALIFIER(MESSAGE, CACHE-VAR, QUALIFIERS, [SYMBOL], [LANG],
  2510. # [ACTION-IF-ACCEPTED], [ACTION-IF-NOT-ACCEPTED])
  2511. # Test if a symbol can be qualified by one of the elements of the
  2512. # comma-separated list of QUALIFIERS. Examples of qualifiers include
  2513. # __attribute__((deprecated)), __declspec(dllimport), etc. MESSAGE is the
  2514. # "checking" message. CACHE-VAR is the variable which receives the
  2515. # qualifier which succeeded, or the the literal "no" if none were
  2516. # accepted. SYMBOL is the symbol to which the qualifier should be
  2517. # applied. If omitted, then SYMBOL defaults to "void f();". LANG is the
  2518. # language of the test, typically "C" or "C++". It defaults to "C" if
  2519. # omitted. ACTION-IF-ACCEPTED is invoked after CACHE-VAR is set if one of
  2520. # the qualifiers is accepted, else ACTION-IF-NOT-ACCEPTED is invoked.
  2521. #------------------------------------------------------------------------------
  2522. AC_DEFUN([CS_SYMBOL_QUALIFIER],
  2523. [AC_CACHE_CHECK([$1], [$2],
  2524. [$2='no'
  2525. m4_foreach([cs_symbol_qualifier], [$3],
  2526. [AS_IF([test "$$2" = no],
  2527. [CS_BUILD_IFELSE(
  2528. [AC_LANG_PROGRAM(
  2529. [cs_symbol_qualifier m4_default([$4],[void f()]);],
  2530. [])],
  2531. [], [$5], [$2='cs_symbol_qualifier'], [$2='no'])])])])
  2532. AS_IF([test $$2 != no], [$6], [$7])])
  2533. # split.m4 -*- Autoconf -*-
  2534. #==============================================================================
  2535. # Copyright (C)2003 by Eric Sunshine <[email protected]>
  2536. #
  2537. # This library is free software; you can redistribute it and/or modify it
  2538. # under the terms of the GNU Library General Public License as published by
  2539. # the Free Software Foundation; either version 2 of the License, or (at your
  2540. # option) any later version.
  2541. #
  2542. # This library is distributed in the hope that it will be useful, but
  2543. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  2544. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
  2545. # License for more details.
  2546. #
  2547. # You should have received a copy of the GNU Library General Public License
  2548. # along with this library; if not, write to the Free Software Foundation,
  2549. # Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  2550. #
  2551. #==============================================================================
  2552. AC_PREREQ([2.56])
  2553. #------------------------------------------------------------------------------
  2554. # CS_SPLIT(LINE, [OUTPUT-VARIABLES], [DELIMITER], [FILLER])
  2555. # Split LINE into individual tokens. Tokens are delimited by DELIMITER,
  2556. # which is the space character if omitted. OUTPUT-VARIABLES is a
  2557. # comma-delimited list of shell variables which should receive the
  2558. # extracted tokens. If there are too few tokens to fill the output
  2559. # variables, then the excess variables will be assigned the empty string.
  2560. # If there are too few output variables, then the excess tokens will be
  2561. # ignored. If OUTPUT-VARIABLES is omitted, then the split tokens will be
  2562. # assigned to the shell meta-variables $1, $2, $3, etc. When
  2563. # OUTPUT-VARIABLES is omitted, FILLER is assigned to meta-variables in
  2564. # cases where DELIMITER delimits a zero-length token. FILLER defaults
  2565. # to "filler". For example, if DELIMITER is "+" and OUTPUT-VARIABLES is
  2566. # omitted, given the line "one++three", $1 will be "one", $2 will be
  2567. # "filler", and $3 will be "three".
  2568. #------------------------------------------------------------------------------
  2569. AC_DEFUN([CS_SPLIT],
  2570. [m4_define([cs_split_filler], m4_default([$4],[filler]))
  2571. set cs_split_filler `echo "$1" | awk 'BEGIN { FS="m4_default([$3],[ ])" }
  2572. { for (i=1; i <= NF; ++i)
  2573. { if ($i == "") print "cs_split_filler"; else print $i } }'`
  2574. shift
  2575. m4_map([_CS_SPLIT], [$2])])
  2576. AC_DEFUN([_CS_SPLIT],
  2577. [AS_IF([test $[@%:@] -eq 0], [$1=''],
  2578. [AS_IF([test "$[1]" = cs_split_filler], [$1=''], [$1=$[1]])
  2579. shift])])
  2580. # textcache.m4 -*- Autoconf -*-
  2581. #==============================================================================
  2582. # Copyright (C)2003 by Eric Sunshine <[email protected]>
  2583. #
  2584. # This library is free software; you can redistribute it and/or modify it
  2585. # under the terms of the GNU Library General Public License as published by
  2586. # the Free Software Foundation; either version 2 of the License, or (at your
  2587. # option) any later version.
  2588. #
  2589. # This library is distributed in the hope that it will be useful, but
  2590. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  2591. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
  2592. # License for more details.
  2593. #
  2594. # You should have received a copy of the GNU Library General Public License
  2595. # along with this library; if not, write to the Free Software Foundation,
  2596. # Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  2597. #
  2598. #==============================================================================
  2599. AC_PREREQ([2.56])
  2600. #------------------------------------------------------------------------------
  2601. # Text cache facility. These macros provide a way to incrementally store
  2602. # arbitrary text in a shell variable, and to write the saved text to a file.
  2603. #
  2604. # CS_TEXT_CACHE_APPEND(VARIABLE, TEXT)
  2605. # Append text to the contents of the named shell variable. If the text
  2606. # contains references to shell variables (such as $foo), then those
  2607. # references will be expanded. If expansion is not desired, then protect
  2608. # the text with AS_ESCAPE().
  2609. #
  2610. # CS_TEXT_CACHE_PREPEND(VARIABLE, TEXT)
  2611. # Prepend text to the contents of the named shell variable. If the text
  2612. # contains references to shell variables (such as $foo), then those
  2613. # references will be expanded. If expansion is not desired, then protect
  2614. # the text with AS_ESCAPE().
  2615. #
  2616. # CS_TEXT_CACHE_OUTPUT(VARIABLE, FILENAME)
  2617. # Instruct config.status to write the contents of the named shell
  2618. # variable to the given filename. If the file resides in a directory,
  2619. # the directory will be created, if necessary. If the output file
  2620. # already exists, and if the cached text is identical to the contents of
  2621. # the existing file, then the existing file is left alone, thus its time
  2622. # stamp remains unmolested. This heuristic may help to minimize rebuilds
  2623. # when the file is listed as a dependency in a makefile.
  2624. #
  2625. # *NOTE*
  2626. # There is a bug in Autoconf 2.57 and probably all earlier 2.5x versions
  2627. # which results in errors if AC_CONFIG_COMMANDS is invoked for a `tag'
  2628. # which represents a file in a directory which does not yet exist.
  2629. # Unfortunately, even invoking AS_MKDIR_P in the `cmd' portion of
  2630. # AC_CONFIG_COMMANDS does not solve the problem because the generated
  2631. # configure script attempts to access information about the directory
  2632. # before AS_MKDIR_P has a chance to create it. This forces us to invoke
  2633. # AS_MKDIR_P in the third argument to AC_CONFIG_COMMANDS (the
  2634. # `init-cmds') rather than the second (the `cmds'). This is undesirable
  2635. # because it means that the directory will be created anytime
  2636. # config.status is invoked (even for a simple --help), rather than being
  2637. # created only when requested to output the text cache. This bug was
  2638. # submitted to the Autoconf GNATS database by Eric Sunshine as #228 on
  2639. # 27-Dec-2002. It was fixed for Autoconf 2.58 on 26-Sep-2003. The
  2640. # official fix makes the assumption that `tag' always represents a file
  2641. # (as opposed to some generic target), and creates the file's directory
  2642. # is not present.
  2643. #------------------------------------------------------------------------------
  2644. AC_DEFUN([CS_TEXT_CACHE_APPEND], [$1="${$1}$2"])
  2645. AC_DEFUN([CS_TEXT_CACHE_PREPEND], [$1="$2${$1}"])
  2646. AC_DEFUN([CS_TEXT_CACHE_OUTPUT],
  2647. [AC_CONFIG_COMMANDS([$2],
  2648. [echo $ECHO_N "$$1$ECHO_C" > $tmp/tcache
  2649. AS_IF([diff $2 $tmp/tcache >/dev/null 2>&1],
  2650. [AC_MSG_NOTICE([$2 is unchanged])],
  2651. [rm -f $2
  2652. cp $tmp/tcache $2])
  2653. rm -f $tmp/tcache],
  2654. [$1='$$1'
  2655. cs_dir=`AS_DIRNAME([$2])`
  2656. AS_ESCAPE(AS_MKDIR_P([$cs_dir]), [$`\])])])
  2657. # trim.m4 -*- Autoconf -*-
  2658. #==============================================================================
  2659. # Copyright (C)2003 by Eric Sunshine <[email protected]>
  2660. #
  2661. # This library is free software; you can redistribute it and/or modify it
  2662. # under the terms of the GNU Library General Public License as published by
  2663. # the Free Software Foundation; either version 2 of the License, or (at your
  2664. # option) any later version.
  2665. #
  2666. # This library is distributed in the hope that it will be useful, but
  2667. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  2668. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
  2669. # License for more details.
  2670. #
  2671. # You should have received a copy of the GNU Library General Public License
  2672. # along with this library; if not, write to the Free Software Foundation,
  2673. # Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  2674. #
  2675. #==============================================================================
  2676. AC_PREREQ([2.56])
  2677. #------------------------------------------------------------------------------
  2678. # CS_TRIM(STRING)
  2679. # Strip leading and trailing spaces from STRING and collapse internal
  2680. # runs of multiple spaces to a single space.
  2681. #------------------------------------------------------------------------------
  2682. AC_DEFUN([CS_TRIM], [`echo x$1 | sed 's/^x//;s/ */ /g;s/^ //;s/ $//'`])
  2683. # warnings.m4 -*- Autoconf -*-
  2684. #==============================================================================
  2685. # Copyright (C)2005 by Eric Sunshine <[email protected]>
  2686. #
  2687. # This library is free software; you can redistribute it and/or modify it
  2688. # under the terms of the GNU Library General Public License as published by
  2689. # the Free Software Foundation; either version 2 of the License, or (at your
  2690. # option) any later version.
  2691. #
  2692. # This library is distributed in the hope that it will be useful, but
  2693. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  2694. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
  2695. # License for more details.
  2696. #
  2697. # You should have received a copy of the GNU Library General Public License
  2698. # along with this library; if not, write to the Free Software Foundation,
  2699. # Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  2700. #
  2701. #==============================================================================
  2702. AC_PREREQ([2.56])
  2703. #------------------------------------------------------------------------------
  2704. # CS_COMPILER_WARNINGS([LANGUAGE], [CACHE-VAR], [ACTION-IF-FOUND],
  2705. # [ACTION-IF-NOT-FOUND])
  2706. # Check how to enable compilation warnings. If LANGUAGE is not provided,
  2707. # then `C' is assumed (other options include `C++'). If CACHE-VAR is not
  2708. # provided, then it defaults to the name
  2709. # "cs_cv_prog_compiler_enable_warnings". If an option for enabling
  2710. # warnings (such as `-Wall') is discovered, then it is assigned to
  2711. # CACHE-VAR and ACTION-IF-FOUND is invoked; otherwise the empty string is
  2712. # assigned to CACHE-VAR and ACTION-IF-NOT-FOUND is invoked.
  2713. #
  2714. # IMPLEMENTATION NOTES
  2715. #
  2716. # On some platforms, it is more appropriate to use -Wmost rather than
  2717. # -Wall even if the compiler understands both, thus we attempt -Wmost
  2718. # before -Wall.
  2719. #------------------------------------------------------------------------------
  2720. AC_DEFUN([CS_COMPILER_WARNINGS],
  2721. [CS_CHECK_BUILD_FLAGS(
  2722. [how to enable m4_default([$1],[C]) compilation warnings],
  2723. [m4_default([$2],[cs_cv_prog_compiler_enable_warnings])],
  2724. [CS_CREATE_TUPLE([-Wmost]) CS_CREATE_TUPLE([-Wall])],
  2725. [$1], [$3], [$4])])
  2726. #------------------------------------------------------------------------------
  2727. # CS_COMPILER_ERRORS([LANGUAGE], [CACHE-VAR], [ACTION-IF-FOUND],
  2728. # [ACTION-IF-NOT-FOUND])
  2729. # Check how to promote compilation diganostics from warning to error
  2730. # status. If LANGUAGE is not provided, then `C' is assumed (other options
  2731. # include `C++'). If CACHE-VAR is not provided, then it defaults to the
  2732. # name "cs_cv_prog_compiler_enable_errors". If an option for performing
  2733. # this promotion (such as `-Werror') is discovered, then it is assigned
  2734. # to CACHE-VAR and ACTION-IF-FOUND is invoked; otherwise the empty string
  2735. # is assigned to CACHE-VAR and ACTION-IF-NOT-FOUND is invoked.
  2736. #------------------------------------------------------------------------------
  2737. AC_DEFUN([CS_COMPILER_ERRORS],
  2738. [CS_CHECK_BUILD_FLAGS(
  2739. [how to treat m4_default([$1],[C]) warnings as errors],
  2740. [m4_default([$2],[cs_cv_prog_compiler_enable_errors])],
  2741. [CS_CREATE_TUPLE([-Werror])], [$1], [$3], [$4])])
  2742. #------------------------------------------------------------------------------
  2743. # CS_COMPILER_IGNORE_UNUSED([LANGUAGE], [CACHE-VAR], [ACTION-IF-FOUND],
  2744. # [ACTION-IF-NOT-FOUND])
  2745. # Check how to instruct compiler to ignore unused variables and
  2746. # arguments. This option may be useful for code generated by tools, such
  2747. # as Swig, Bison, and Flex, over which the client has no control, yet
  2748. # wishes to compile without excessive diagnostic spew. If LANGUAGE is
  2749. # not provided, then `C' is assumed (other options include `C++'). If
  2750. # CACHE-VAR is not provided, then it defaults to the name
  2751. # "cs_cv_prog_compiler_ignore_unused". If an option (such as
  2752. # `-Wno-unused') is discovered, then it is assigned to CACHE-VAR and
  2753. # ACTION-IF-FOUND is invoked; otherwise the empty string is assigned to
  2754. # CACHE-VAR and ACTION-IF-NOT-FOUND is invoked.
  2755. #------------------------------------------------------------------------------
  2756. AC_DEFUN([CS_COMPILER_IGNORE_UNUSED],
  2757. [CS_CHECK_BUILD_FLAGS(
  2758. [how to suppress m4_default([$1],[C]) unused variable warnings],
  2759. [m4_default([$2],[cs_cv_prog_compiler_ignore_unused])],
  2760. [CS_CREATE_TUPLE([-Wno-unused])], [$1], [$3], [$4])])
  2761. #------------------------------------------------------------------------------
  2762. # CS_COMPILER_IGNORE_UNINITIALIZED([LANGUAGE], [CACHE-VAR], [ACTION-IF-FOUND],
  2763. # [ACTION-IF-NOT-FOUND])
  2764. # Check how to instruct compiler to ignore uninitialized variables. This
  2765. # option may be useful for code generated by tools, such as Swig, Bison,
  2766. # and Flex, over which the client has no control, yet wishes to compile
  2767. # without excessive diagnostic spew. If LANGUAGE is not provided, then
  2768. # `C' is assumed (other options include `C++'). If CACHE-VAR is not
  2769. # provided, then it defaults to the name
  2770. # "cs_cv_prog_compiler_ignore_uninitialized". If an option (such as
  2771. # `-Wno-uninitialized') is discovered, then it is assigned to CACHE-VAR
  2772. # and ACTION-IF-FOUND is invoked; otherwise the empty string is assigned
  2773. # to CACHE-VAR and ACTION-IF-NOT-FOUND is invoked.
  2774. #------------------------------------------------------------------------------
  2775. AC_DEFUN([CS_COMPILER_IGNORE_UNINITIALIZED],
  2776. [CS_CHECK_BUILD_FLAGS(
  2777. [how to suppress m4_default([$1],[C]) uninitialized warnings],
  2778. [m4_default([$2],
  2779. [cs_cv_prog_compiler_ignore_uninitialized_variables])],
  2780. [CS_CREATE_TUPLE([-Wno-uninitialized])], [$1], [$3], [$4])])
  2781. #------------------------------------------------------------------------------
  2782. # CS_COMPILER_IGNORE_PRAGMAS([LANGUAGE], [CACHE-VAR], [ACTION-IF-FOUND],
  2783. # [ACTION-IF-NOT-FOUND])
  2784. # Check how to instruct compiler to ignore unrecognized #pragma
  2785. # directives. This option may be useful for code which contains
  2786. # unprotected #pragmas which are not understood by all compilers. If
  2787. # LANGUAGE is not provided, then `C' is assumed (other options include
  2788. # `C++'). If CACHE-VAR is not provided, then it defaults to the name
  2789. # "cs_cv_prog_compiler_ignore_unknown_pragmas". If an option (such as
  2790. # `-Wno-unknown-pragmas') is discovered, then it is assigned to CACHE-VAR
  2791. # and ACTION-IF-FOUND is invoked; otherwise the empty string is assigned
  2792. # to CACHE-VAR and ACTION-IF-NOT-FOUND is invoked.
  2793. #------------------------------------------------------------------------------
  2794. AC_DEFUN([CS_COMPILER_IGNORE_PRAGMAS],
  2795. [CS_CHECK_BUILD_FLAGS(
  2796. [how to suppress m4_default([$1],[C]) unknown [#pragma] warnings],
  2797. [m4_default([$2],[cs_cv_prog_compiler_ignore_unknown_pragmas])],
  2798. [CS_CREATE_TUPLE([-Wno-unknown-pragmas])], [$1], [$3], [$4])])
  2799. #------------------------------------------------------------------------------
  2800. # CS_COMPILER_IGNORE_LONG_DOUBLE([LANGUAGE], [CACHE-VAR], [ACTION-IF-FOUND],
  2801. # [ACTION-IF-NOT-FOUND])
  2802. # Check how to instruct compiler to suppress warnings about `long double'
  2803. # usage. This option may be useful for code generated by tools, such as
  2804. # Swig, Bison, and Flex, over which the client has no control, yet wishes
  2805. # to compile without excessive diagnostic spew. If LANGUAGE is not
  2806. # provided, then `C' is assumed (other options include `C++'). If
  2807. # CACHE-VAR is not provided, then it defaults to the name
  2808. # "cs_cv_prog_compiler_ignore_long_double". If an option (such as
  2809. # `-Wno-long-double') is discovered, then it is assigned to CACHE-VAR and
  2810. # ACTION-IF-FOUND is invoked; otherwise the empty string is assigned to
  2811. # CACHE-VAR and ACTION-IF-NOT-FOUND is invoked.
  2812. #------------------------------------------------------------------------------
  2813. AC_DEFUN([CS_COMPILER_IGNORE_LONG_DOUBLE],
  2814. [CS_CHECK_BUILD_FLAGS(
  2815. [how to suppress m4_default([$1],[C]) `long double' warnings],
  2816. [m4_default([$2],[cs_cv_prog_compiler_ignore_long_double])],
  2817. [CS_CREATE_TUPLE([-Wno-long-double])], [$1], [$3], [$4])])