xorg-macros.m4 69 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894
  1. dnl xorg-macros.m4. Generated from xorg-macros.m4.in xorgversion.m4 by configure.
  2. dnl
  3. dnl Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
  4. dnl
  5. dnl Permission is hereby granted, free of charge, to any person obtaining a
  6. dnl copy of this software and associated documentation files (the "Software"),
  7. dnl to deal in the Software without restriction, including without limitation
  8. dnl the rights to use, copy, modify, merge, publish, distribute, sublicense,
  9. dnl and/or sell copies of the Software, and to permit persons to whom the
  10. dnl Software is furnished to do so, subject to the following conditions:
  11. dnl
  12. dnl The above copyright notice and this permission notice (including the next
  13. dnl paragraph) shall be included in all copies or substantial portions of the
  14. dnl Software.
  15. dnl
  16. dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. dnl IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. dnl FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  19. dnl THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. dnl LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  21. dnl FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  22. dnl DEALINGS IN THE SOFTWARE.
  23. # XORG_MACROS_VERSION(required-version)
  24. # -------------------------------------
  25. # Minimum version: 1.1.0
  26. #
  27. # If you're using a macro added in Version 1.1 or newer, include this in
  28. # your configure.ac with the minimum required version, such as:
  29. # XORG_MACROS_VERSION(1.1)
  30. #
  31. # To ensure that this macro is defined, also add:
  32. # m4_ifndef([XORG_MACROS_VERSION],
  33. # [m4_fatal([must install xorg-macros 1.1 or later before running autoconf/autogen])])
  34. #
  35. #
  36. # See the "minimum version" comment for each macro you use to see what
  37. # version you require.
  38. m4_defun([XORG_MACROS_VERSION],[
  39. m4_define([vers_have], [1.19.0])
  40. m4_define([maj_have], m4_substr(vers_have, 0, m4_index(vers_have, [.])))
  41. m4_define([maj_needed], m4_substr([$1], 0, m4_index([$1], [.])))
  42. m4_if(m4_cmp(maj_have, maj_needed), 0,,
  43. [m4_fatal([xorg-macros major version ]maj_needed[ is required but ]vers_have[ found])])
  44. m4_if(m4_version_compare(vers_have, [$1]), -1,
  45. [m4_fatal([xorg-macros version $1 or higher is required but ]vers_have[ found])])
  46. m4_undefine([vers_have])
  47. m4_undefine([maj_have])
  48. m4_undefine([maj_needed])
  49. ]) # XORG_MACROS_VERSION
  50. # XORG_PROG_RAWCPP()
  51. # ------------------
  52. # Minimum version: 1.0.0
  53. #
  54. # Find cpp program and necessary flags for use in pre-processing text files
  55. # such as man pages and config files
  56. AC_DEFUN([XORG_PROG_RAWCPP],[
  57. AC_REQUIRE([AC_PROG_CPP])
  58. AC_PATH_PROGS(RAWCPP, [cpp], [${CPP}],
  59. [$PATH:/bin:/usr/bin:/usr/lib:/usr/libexec:/usr/ccs/lib:/usr/ccs/lbin:/lib])
  60. # Check for flag to avoid builtin definitions - assumes unix is predefined,
  61. # which is not the best choice for supporting other OS'es, but covers most
  62. # of the ones we need for now.
  63. AC_MSG_CHECKING([if $RAWCPP requires -undef])
  64. AC_LANG_CONFTEST([AC_LANG_SOURCE([[Does cpp redefine unix ?]])])
  65. if test `${RAWCPP} < conftest.$ac_ext | grep -c 'unix'` -eq 1 ; then
  66. AC_MSG_RESULT([no])
  67. else
  68. if test `${RAWCPP} -undef < conftest.$ac_ext | grep -c 'unix'` -eq 1 ; then
  69. RAWCPPFLAGS=-undef
  70. AC_MSG_RESULT([yes])
  71. # under Cygwin unix is still defined even with -undef
  72. elif test `${RAWCPP} -undef -ansi < conftest.$ac_ext | grep -c 'unix'` -eq 1 ; then
  73. RAWCPPFLAGS="-undef -ansi"
  74. AC_MSG_RESULT([yes, with -ansi])
  75. else
  76. AC_MSG_ERROR([${RAWCPP} defines unix with or without -undef. I don't know what to do.])
  77. fi
  78. fi
  79. rm -f conftest.$ac_ext
  80. AC_MSG_CHECKING([if $RAWCPP requires -traditional])
  81. AC_LANG_CONFTEST([AC_LANG_SOURCE([[Does cpp preserve "whitespace"?]])])
  82. if test `${RAWCPP} < conftest.$ac_ext | grep -c 'preserve \"'` -eq 1 ; then
  83. AC_MSG_RESULT([no])
  84. else
  85. if test `${RAWCPP} -traditional < conftest.$ac_ext | grep -c 'preserve \"'` -eq 1 ; then
  86. TRADITIONALCPPFLAGS="-traditional"
  87. RAWCPPFLAGS="${RAWCPPFLAGS} -traditional"
  88. AC_MSG_RESULT([yes])
  89. else
  90. AC_MSG_ERROR([${RAWCPP} does not preserve whitespace with or without -traditional. I don't know what to do.])
  91. fi
  92. fi
  93. rm -f conftest.$ac_ext
  94. AC_SUBST(RAWCPPFLAGS)
  95. AC_SUBST(TRADITIONALCPPFLAGS)
  96. ]) # XORG_PROG_RAWCPP
  97. # XORG_MANPAGE_SECTIONS()
  98. # -----------------------
  99. # Minimum version: 1.0.0
  100. #
  101. # Determine which sections man pages go in for the different man page types
  102. # on this OS - replaces *ManSuffix settings in old Imake *.cf per-os files.
  103. # Not sure if there's any better way than just hardcoding by OS name.
  104. # Override default settings by setting environment variables
  105. # Added MAN_SUBSTS in version 1.8
  106. # Added AC_PROG_SED in version 1.8
  107. AC_DEFUN([XORG_MANPAGE_SECTIONS],[
  108. AC_REQUIRE([AC_CANONICAL_HOST])
  109. AC_REQUIRE([AC_PROG_SED])
  110. if test x$APP_MAN_SUFFIX = x ; then
  111. APP_MAN_SUFFIX=1
  112. fi
  113. if test x$APP_MAN_DIR = x ; then
  114. APP_MAN_DIR='$(mandir)/man$(APP_MAN_SUFFIX)'
  115. fi
  116. if test x$LIB_MAN_SUFFIX = x ; then
  117. LIB_MAN_SUFFIX=3
  118. fi
  119. if test x$LIB_MAN_DIR = x ; then
  120. LIB_MAN_DIR='$(mandir)/man$(LIB_MAN_SUFFIX)'
  121. fi
  122. if test x$FILE_MAN_SUFFIX = x ; then
  123. case $host_os in
  124. solaris*) FILE_MAN_SUFFIX=4 ;;
  125. *) FILE_MAN_SUFFIX=5 ;;
  126. esac
  127. fi
  128. if test x$FILE_MAN_DIR = x ; then
  129. FILE_MAN_DIR='$(mandir)/man$(FILE_MAN_SUFFIX)'
  130. fi
  131. if test x$MISC_MAN_SUFFIX = x ; then
  132. case $host_os in
  133. solaris*) MISC_MAN_SUFFIX=5 ;;
  134. *) MISC_MAN_SUFFIX=7 ;;
  135. esac
  136. fi
  137. if test x$MISC_MAN_DIR = x ; then
  138. MISC_MAN_DIR='$(mandir)/man$(MISC_MAN_SUFFIX)'
  139. fi
  140. if test x$DRIVER_MAN_SUFFIX = x ; then
  141. case $host_os in
  142. solaris*) DRIVER_MAN_SUFFIX=7 ;;
  143. *) DRIVER_MAN_SUFFIX=4 ;;
  144. esac
  145. fi
  146. if test x$DRIVER_MAN_DIR = x ; then
  147. DRIVER_MAN_DIR='$(mandir)/man$(DRIVER_MAN_SUFFIX)'
  148. fi
  149. if test x$ADMIN_MAN_SUFFIX = x ; then
  150. case $host_os in
  151. solaris*) ADMIN_MAN_SUFFIX=1m ;;
  152. *) ADMIN_MAN_SUFFIX=8 ;;
  153. esac
  154. fi
  155. if test x$ADMIN_MAN_DIR = x ; then
  156. ADMIN_MAN_DIR='$(mandir)/man$(ADMIN_MAN_SUFFIX)'
  157. fi
  158. AC_SUBST([APP_MAN_SUFFIX])
  159. AC_SUBST([LIB_MAN_SUFFIX])
  160. AC_SUBST([FILE_MAN_SUFFIX])
  161. AC_SUBST([MISC_MAN_SUFFIX])
  162. AC_SUBST([DRIVER_MAN_SUFFIX])
  163. AC_SUBST([ADMIN_MAN_SUFFIX])
  164. AC_SUBST([APP_MAN_DIR])
  165. AC_SUBST([LIB_MAN_DIR])
  166. AC_SUBST([FILE_MAN_DIR])
  167. AC_SUBST([MISC_MAN_DIR])
  168. AC_SUBST([DRIVER_MAN_DIR])
  169. AC_SUBST([ADMIN_MAN_DIR])
  170. XORG_MAN_PAGE="X Version 11"
  171. AC_SUBST([XORG_MAN_PAGE])
  172. MAN_SUBSTS="\
  173. -e 's|__vendorversion__|\"\$(PACKAGE_STRING)\" \"\$(XORG_MAN_PAGE)\"|' \
  174. -e 's|__xorgversion__|\"\$(PACKAGE_STRING)\" \"\$(XORG_MAN_PAGE)\"|' \
  175. -e 's|__xservername__|Xorg|g' \
  176. -e 's|__xconfigfile__|xorg.conf|g' \
  177. -e 's|__projectroot__|\$(prefix)|g' \
  178. -e 's|__apploaddir__|\$(appdefaultdir)|g' \
  179. -e 's|__appmansuffix__|\$(APP_MAN_SUFFIX)|g' \
  180. -e 's|__drivermansuffix__|\$(DRIVER_MAN_SUFFIX)|g' \
  181. -e 's|__adminmansuffix__|\$(ADMIN_MAN_SUFFIX)|g' \
  182. -e 's|__libmansuffix__|\$(LIB_MAN_SUFFIX)|g' \
  183. -e 's|__miscmansuffix__|\$(MISC_MAN_SUFFIX)|g' \
  184. -e 's|__filemansuffix__|\$(FILE_MAN_SUFFIX)|g'"
  185. AC_SUBST([MAN_SUBSTS])
  186. ]) # XORG_MANPAGE_SECTIONS
  187. # XORG_CHECK_SGML_DOCTOOLS([MIN-VERSION])
  188. # ------------------------
  189. # Minimum version: 1.7.0
  190. #
  191. # Defines the variable XORG_SGML_PATH containing the location of X11/defs.ent
  192. # provided by xorg-sgml-doctools, if installed.
  193. AC_DEFUN([XORG_CHECK_SGML_DOCTOOLS],[
  194. AC_MSG_CHECKING([for X.Org SGML entities m4_ifval([$1],[>= $1])])
  195. XORG_SGML_PATH=
  196. PKG_CHECK_EXISTS([xorg-sgml-doctools m4_ifval([$1],[>= $1])],
  197. [XORG_SGML_PATH=`$PKG_CONFIG --variable=sgmlrootdir xorg-sgml-doctools`],
  198. [m4_ifval([$1],[:],
  199. [if test x"$cross_compiling" != x"yes" ; then
  200. AC_CHECK_FILE([$prefix/share/sgml/X11/defs.ent],
  201. [XORG_SGML_PATH=$prefix/share/sgml])
  202. fi])
  203. ])
  204. # Define variables STYLESHEET_SRCDIR and XSL_STYLESHEET containing
  205. # the path and the name of the doc stylesheet
  206. if test "x$XORG_SGML_PATH" != "x" ; then
  207. AC_MSG_RESULT([$XORG_SGML_PATH])
  208. STYLESHEET_SRCDIR=$XORG_SGML_PATH/X11
  209. XSL_STYLESHEET=$STYLESHEET_SRCDIR/xorg.xsl
  210. else
  211. AC_MSG_RESULT([no])
  212. fi
  213. AC_SUBST(XORG_SGML_PATH)
  214. AC_SUBST(STYLESHEET_SRCDIR)
  215. AC_SUBST(XSL_STYLESHEET)
  216. AM_CONDITIONAL([HAVE_STYLESHEETS], [test "x$XSL_STYLESHEET" != "x"])
  217. ]) # XORG_CHECK_SGML_DOCTOOLS
  218. # XORG_CHECK_LINUXDOC
  219. # -------------------
  220. # Minimum version: 1.0.0
  221. #
  222. # Defines the variable MAKE_TEXT if the necessary tools and
  223. # files are found. $(MAKE_TEXT) blah.sgml will then produce blah.txt.
  224. # Whether or not the necessary tools and files are found can be checked
  225. # with the AM_CONDITIONAL "BUILD_LINUXDOC"
  226. AC_DEFUN([XORG_CHECK_LINUXDOC],[
  227. AC_REQUIRE([XORG_CHECK_SGML_DOCTOOLS])
  228. AC_REQUIRE([XORG_WITH_PS2PDF])
  229. AC_PATH_PROG(LINUXDOC, linuxdoc)
  230. AC_MSG_CHECKING([whether to build documentation])
  231. if test x$XORG_SGML_PATH != x && test x$LINUXDOC != x ; then
  232. BUILDDOC=yes
  233. else
  234. BUILDDOC=no
  235. fi
  236. AM_CONDITIONAL(BUILD_LINUXDOC, [test x$BUILDDOC = xyes])
  237. AC_MSG_RESULT([$BUILDDOC])
  238. AC_MSG_CHECKING([whether to build pdf documentation])
  239. if test x$have_ps2pdf != xno && test x$BUILD_PDFDOC != xno; then
  240. BUILDPDFDOC=yes
  241. else
  242. BUILDPDFDOC=no
  243. fi
  244. AM_CONDITIONAL(BUILD_PDFDOC, [test x$BUILDPDFDOC = xyes])
  245. AC_MSG_RESULT([$BUILDPDFDOC])
  246. MAKE_TEXT="SGML_SEARCH_PATH=$XORG_SGML_PATH GROFF_NO_SGR=y $LINUXDOC -B txt -f"
  247. MAKE_PS="SGML_SEARCH_PATH=$XORG_SGML_PATH $LINUXDOC -B latex --papersize=letter --output=ps"
  248. MAKE_PDF="$PS2PDF"
  249. MAKE_HTML="SGML_SEARCH_PATH=$XORG_SGML_PATH $LINUXDOC -B html --split=0"
  250. AC_SUBST(MAKE_TEXT)
  251. AC_SUBST(MAKE_PS)
  252. AC_SUBST(MAKE_PDF)
  253. AC_SUBST(MAKE_HTML)
  254. ]) # XORG_CHECK_LINUXDOC
  255. # XORG_CHECK_DOCBOOK
  256. # -------------------
  257. # Minimum version: 1.0.0
  258. #
  259. # Checks for the ability to build output formats from SGML DocBook source.
  260. # For XXX in {TXT, PDF, PS, HTML}, the AM_CONDITIONAL "BUILD_XXXDOC"
  261. # indicates whether the necessary tools and files are found and, if set,
  262. # $(MAKE_XXX) blah.sgml will produce blah.xxx.
  263. AC_DEFUN([XORG_CHECK_DOCBOOK],[
  264. AC_REQUIRE([XORG_CHECK_SGML_DOCTOOLS])
  265. BUILDTXTDOC=no
  266. BUILDPDFDOC=no
  267. BUILDPSDOC=no
  268. BUILDHTMLDOC=no
  269. AC_PATH_PROG(DOCBOOKPS, docbook2ps)
  270. AC_PATH_PROG(DOCBOOKPDF, docbook2pdf)
  271. AC_PATH_PROG(DOCBOOKHTML, docbook2html)
  272. AC_PATH_PROG(DOCBOOKTXT, docbook2txt)
  273. AC_MSG_CHECKING([whether to build text documentation])
  274. if test x$XORG_SGML_PATH != x && test x$DOCBOOKTXT != x &&
  275. test x$BUILD_TXTDOC != xno; then
  276. BUILDTXTDOC=yes
  277. fi
  278. AM_CONDITIONAL(BUILD_TXTDOC, [test x$BUILDTXTDOC = xyes])
  279. AC_MSG_RESULT([$BUILDTXTDOC])
  280. AC_MSG_CHECKING([whether to build PDF documentation])
  281. if test x$XORG_SGML_PATH != x && test x$DOCBOOKPDF != x &&
  282. test x$BUILD_PDFDOC != xno; then
  283. BUILDPDFDOC=yes
  284. fi
  285. AM_CONDITIONAL(BUILD_PDFDOC, [test x$BUILDPDFDOC = xyes])
  286. AC_MSG_RESULT([$BUILDPDFDOC])
  287. AC_MSG_CHECKING([whether to build PostScript documentation])
  288. if test x$XORG_SGML_PATH != x && test x$DOCBOOKPS != x &&
  289. test x$BUILD_PSDOC != xno; then
  290. BUILDPSDOC=yes
  291. fi
  292. AM_CONDITIONAL(BUILD_PSDOC, [test x$BUILDPSDOC = xyes])
  293. AC_MSG_RESULT([$BUILDPSDOC])
  294. AC_MSG_CHECKING([whether to build HTML documentation])
  295. if test x$XORG_SGML_PATH != x && test x$DOCBOOKHTML != x &&
  296. test x$BUILD_HTMLDOC != xno; then
  297. BUILDHTMLDOC=yes
  298. fi
  299. AM_CONDITIONAL(BUILD_HTMLDOC, [test x$BUILDHTMLDOC = xyes])
  300. AC_MSG_RESULT([$BUILDHTMLDOC])
  301. MAKE_TEXT="SGML_SEARCH_PATH=$XORG_SGML_PATH $DOCBOOKTXT"
  302. MAKE_PS="SGML_SEARCH_PATH=$XORG_SGML_PATH $DOCBOOKPS"
  303. MAKE_PDF="SGML_SEARCH_PATH=$XORG_SGML_PATH $DOCBOOKPDF"
  304. MAKE_HTML="SGML_SEARCH_PATH=$XORG_SGML_PATH $DOCBOOKHTML"
  305. AC_SUBST(MAKE_TEXT)
  306. AC_SUBST(MAKE_PS)
  307. AC_SUBST(MAKE_PDF)
  308. AC_SUBST(MAKE_HTML)
  309. ]) # XORG_CHECK_DOCBOOK
  310. # XORG_WITH_XMLTO([MIN-VERSION], [DEFAULT])
  311. # ----------------
  312. # Minimum version: 1.5.0
  313. # Minimum version for optional DEFAULT argument: 1.11.0
  314. #
  315. # Documentation tools are not always available on all platforms and sometimes
  316. # not at the appropriate level. This macro enables a module to test for the
  317. # presence of the tool and obtain it's path in separate variables. Coupled with
  318. # the --with-xmlto option, it allows maximum flexibilty in making decisions
  319. # as whether or not to use the xmlto package. When DEFAULT is not specified,
  320. # --with-xmlto assumes 'auto'.
  321. #
  322. # Interface to module:
  323. # HAVE_XMLTO: used in makefiles to conditionally generate documentation
  324. # XMLTO: returns the path of the xmlto program found
  325. # returns the path set by the user in the environment
  326. # --with-xmlto: 'yes' user instructs the module to use xmlto
  327. # 'no' user instructs the module not to use xmlto
  328. #
  329. # Added in version 1.10.0
  330. # HAVE_XMLTO_TEXT: used in makefiles to conditionally generate text documentation
  331. # xmlto for text output requires either lynx, links, or w3m browsers
  332. #
  333. # If the user sets the value of XMLTO, AC_PATH_PROG skips testing the path.
  334. #
  335. AC_DEFUN([XORG_WITH_XMLTO],[
  336. AC_ARG_VAR([XMLTO], [Path to xmlto command])
  337. m4_define([_defopt], m4_default([$2], [auto]))
  338. AC_ARG_WITH(xmlto,
  339. AS_HELP_STRING([--with-xmlto],
  340. [Use xmlto to regenerate documentation (default: ]_defopt[)]),
  341. [use_xmlto=$withval], [use_xmlto=]_defopt)
  342. m4_undefine([_defopt])
  343. if test "x$use_xmlto" = x"auto"; then
  344. AC_PATH_PROG([XMLTO], [xmlto])
  345. if test "x$XMLTO" = "x"; then
  346. AC_MSG_WARN([xmlto not found - documentation targets will be skipped])
  347. have_xmlto=no
  348. else
  349. have_xmlto=yes
  350. fi
  351. elif test "x$use_xmlto" = x"yes" ; then
  352. AC_PATH_PROG([XMLTO], [xmlto])
  353. if test "x$XMLTO" = "x"; then
  354. AC_MSG_ERROR([--with-xmlto=yes specified but xmlto not found in PATH])
  355. fi
  356. have_xmlto=yes
  357. elif test "x$use_xmlto" = x"no" ; then
  358. if test "x$XMLTO" != "x"; then
  359. AC_MSG_WARN([ignoring XMLTO environment variable since --with-xmlto=no was specified])
  360. fi
  361. have_xmlto=no
  362. else
  363. AC_MSG_ERROR([--with-xmlto expects 'yes' or 'no'])
  364. fi
  365. # Test for a minimum version of xmlto, if provided.
  366. m4_ifval([$1],
  367. [if test "$have_xmlto" = yes; then
  368. # scrape the xmlto version
  369. AC_MSG_CHECKING([the xmlto version])
  370. xmlto_version=`$XMLTO --version 2>/dev/null | cut -d' ' -f3`
  371. AC_MSG_RESULT([$xmlto_version])
  372. AS_VERSION_COMPARE([$xmlto_version], [$1],
  373. [if test "x$use_xmlto" = xauto; then
  374. AC_MSG_WARN([xmlto version $xmlto_version found, but $1 needed])
  375. have_xmlto=no
  376. else
  377. AC_MSG_ERROR([xmlto version $xmlto_version found, but $1 needed])
  378. fi])
  379. fi])
  380. # Test for the ability of xmlto to generate a text target
  381. have_xmlto_text=no
  382. cat > conftest.xml << "EOF"
  383. EOF
  384. AS_IF([test "$have_xmlto" = yes],
  385. [AS_IF([$XMLTO --skip-validation txt conftest.xml >/dev/null 2>&1],
  386. [have_xmlto_text=yes],
  387. [AC_MSG_WARN([xmlto cannot generate text format, this format skipped])])])
  388. rm -f conftest.xml
  389. AM_CONDITIONAL([HAVE_XMLTO_TEXT], [test $have_xmlto_text = yes])
  390. AM_CONDITIONAL([HAVE_XMLTO], [test "$have_xmlto" = yes])
  391. ]) # XORG_WITH_XMLTO
  392. # XORG_WITH_XSLTPROC([MIN-VERSION], [DEFAULT])
  393. # --------------------------------------------
  394. # Minimum version: 1.12.0
  395. # Minimum version for optional DEFAULT argument: 1.12.0
  396. #
  397. # XSLT (Extensible Stylesheet Language Transformations) is a declarative,
  398. # XML-based language used for the transformation of XML documents.
  399. # The xsltproc command line tool is for applying XSLT stylesheets to XML documents.
  400. # It is used under the cover by xmlto to generate html files from DocBook/XML.
  401. # The XSLT processor is often used as a standalone tool for transformations.
  402. # It should not be assumed that this tool is used only to work with documnetation.
  403. # When DEFAULT is not specified, --with-xsltproc assumes 'auto'.
  404. #
  405. # Interface to module:
  406. # HAVE_XSLTPROC: used in makefiles to conditionally generate documentation
  407. # XSLTPROC: returns the path of the xsltproc program found
  408. # returns the path set by the user in the environment
  409. # --with-xsltproc: 'yes' user instructs the module to use xsltproc
  410. # 'no' user instructs the module not to use xsltproc
  411. # have_xsltproc: returns yes if xsltproc found in PATH or no
  412. #
  413. # If the user sets the value of XSLTPROC, AC_PATH_PROG skips testing the path.
  414. #
  415. AC_DEFUN([XORG_WITH_XSLTPROC],[
  416. AC_ARG_VAR([XSLTPROC], [Path to xsltproc command])
  417. # Preserves the interface, should it be implemented later
  418. m4_ifval([$1], [m4_warn([syntax], [Checking for xsltproc MIN-VERSION is not implemented])])
  419. m4_define([_defopt], m4_default([$2], [auto]))
  420. AC_ARG_WITH(xsltproc,
  421. AS_HELP_STRING([--with-xsltproc],
  422. [Use xsltproc for the transformation of XML documents (default: ]_defopt[)]),
  423. [use_xsltproc=$withval], [use_xsltproc=]_defopt)
  424. m4_undefine([_defopt])
  425. if test "x$use_xsltproc" = x"auto"; then
  426. AC_PATH_PROG([XSLTPROC], [xsltproc])
  427. if test "x$XSLTPROC" = "x"; then
  428. AC_MSG_WARN([xsltproc not found - cannot transform XML documents])
  429. have_xsltproc=no
  430. else
  431. have_xsltproc=yes
  432. fi
  433. elif test "x$use_xsltproc" = x"yes" ; then
  434. AC_PATH_PROG([XSLTPROC], [xsltproc])
  435. if test "x$XSLTPROC" = "x"; then
  436. AC_MSG_ERROR([--with-xsltproc=yes specified but xsltproc not found in PATH])
  437. fi
  438. have_xsltproc=yes
  439. elif test "x$use_xsltproc" = x"no" ; then
  440. if test "x$XSLTPROC" != "x"; then
  441. AC_MSG_WARN([ignoring XSLTPROC environment variable since --with-xsltproc=no was specified])
  442. fi
  443. have_xsltproc=no
  444. else
  445. AC_MSG_ERROR([--with-xsltproc expects 'yes' or 'no'])
  446. fi
  447. AM_CONDITIONAL([HAVE_XSLTPROC], [test "$have_xsltproc" = yes])
  448. ]) # XORG_WITH_XSLTPROC
  449. # XORG_WITH_PERL([MIN-VERSION], [DEFAULT])
  450. # ----------------------------------------
  451. # Minimum version: 1.15.0
  452. #
  453. # PERL (Practical Extraction and Report Language) is a language optimized for
  454. # scanning arbitrary text files, extracting information from those text files,
  455. # and printing reports based on that information.
  456. #
  457. # When DEFAULT is not specified, --with-perl assumes 'auto'.
  458. #
  459. # Interface to module:
  460. # HAVE_PERL: used in makefiles to conditionally scan text files
  461. # PERL: returns the path of the perl program found
  462. # returns the path set by the user in the environment
  463. # --with-perl: 'yes' user instructs the module to use perl
  464. # 'no' user instructs the module not to use perl
  465. # have_perl: returns yes if perl found in PATH or no
  466. #
  467. # If the user sets the value of PERL, AC_PATH_PROG skips testing the path.
  468. #
  469. AC_DEFUN([XORG_WITH_PERL],[
  470. AC_ARG_VAR([PERL], [Path to perl command])
  471. # Preserves the interface, should it be implemented later
  472. m4_ifval([$1], [m4_warn([syntax], [Checking for perl MIN-VERSION is not implemented])])
  473. m4_define([_defopt], m4_default([$2], [auto]))
  474. AC_ARG_WITH(perl,
  475. AS_HELP_STRING([--with-perl],
  476. [Use perl for extracting information from files (default: ]_defopt[)]),
  477. [use_perl=$withval], [use_perl=]_defopt)
  478. m4_undefine([_defopt])
  479. if test "x$use_perl" = x"auto"; then
  480. AC_PATH_PROG([PERL], [perl])
  481. if test "x$PERL" = "x"; then
  482. AC_MSG_WARN([perl not found - cannot extract information and report])
  483. have_perl=no
  484. else
  485. have_perl=yes
  486. fi
  487. elif test "x$use_perl" = x"yes" ; then
  488. AC_PATH_PROG([PERL], [perl])
  489. if test "x$PERL" = "x"; then
  490. AC_MSG_ERROR([--with-perl=yes specified but perl not found in PATH])
  491. fi
  492. have_perl=yes
  493. elif test "x$use_perl" = x"no" ; then
  494. if test "x$PERL" != "x"; then
  495. AC_MSG_WARN([ignoring PERL environment variable since --with-perl=no was specified])
  496. fi
  497. have_perl=no
  498. else
  499. AC_MSG_ERROR([--with-perl expects 'yes' or 'no'])
  500. fi
  501. AM_CONDITIONAL([HAVE_PERL], [test "$have_perl" = yes])
  502. ]) # XORG_WITH_PERL
  503. # XORG_WITH_ASCIIDOC([MIN-VERSION], [DEFAULT])
  504. # ----------------
  505. # Minimum version: 1.5.0
  506. # Minimum version for optional DEFAULT argument: 1.11.0
  507. #
  508. # Documentation tools are not always available on all platforms and sometimes
  509. # not at the appropriate level. This macro enables a module to test for the
  510. # presence of the tool and obtain it's path in separate variables. Coupled with
  511. # the --with-asciidoc option, it allows maximum flexibilty in making decisions
  512. # as whether or not to use the asciidoc package. When DEFAULT is not specified,
  513. # --with-asciidoc assumes 'auto'.
  514. #
  515. # Interface to module:
  516. # HAVE_ASCIIDOC: used in makefiles to conditionally generate documentation
  517. # ASCIIDOC: returns the path of the asciidoc program found
  518. # returns the path set by the user in the environment
  519. # --with-asciidoc: 'yes' user instructs the module to use asciidoc
  520. # 'no' user instructs the module not to use asciidoc
  521. #
  522. # If the user sets the value of ASCIIDOC, AC_PATH_PROG skips testing the path.
  523. #
  524. AC_DEFUN([XORG_WITH_ASCIIDOC],[
  525. AC_ARG_VAR([ASCIIDOC], [Path to asciidoc command])
  526. m4_define([_defopt], m4_default([$2], [auto]))
  527. AC_ARG_WITH(asciidoc,
  528. AS_HELP_STRING([--with-asciidoc],
  529. [Use asciidoc to regenerate documentation (default: ]_defopt[)]),
  530. [use_asciidoc=$withval], [use_asciidoc=]_defopt)
  531. m4_undefine([_defopt])
  532. if test "x$use_asciidoc" = x"auto"; then
  533. AC_PATH_PROG([ASCIIDOC], [asciidoc])
  534. if test "x$ASCIIDOC" = "x"; then
  535. AC_MSG_WARN([asciidoc not found - documentation targets will be skipped])
  536. have_asciidoc=no
  537. else
  538. have_asciidoc=yes
  539. fi
  540. elif test "x$use_asciidoc" = x"yes" ; then
  541. AC_PATH_PROG([ASCIIDOC], [asciidoc])
  542. if test "x$ASCIIDOC" = "x"; then
  543. AC_MSG_ERROR([--with-asciidoc=yes specified but asciidoc not found in PATH])
  544. fi
  545. have_asciidoc=yes
  546. elif test "x$use_asciidoc" = x"no" ; then
  547. if test "x$ASCIIDOC" != "x"; then
  548. AC_MSG_WARN([ignoring ASCIIDOC environment variable since --with-asciidoc=no was specified])
  549. fi
  550. have_asciidoc=no
  551. else
  552. AC_MSG_ERROR([--with-asciidoc expects 'yes' or 'no'])
  553. fi
  554. m4_ifval([$1],
  555. [if test "$have_asciidoc" = yes; then
  556. # scrape the asciidoc version
  557. AC_MSG_CHECKING([the asciidoc version])
  558. asciidoc_version=`$ASCIIDOC --version 2>/dev/null | cut -d' ' -f2`
  559. AC_MSG_RESULT([$asciidoc_version])
  560. AS_VERSION_COMPARE([$asciidoc_version], [$1],
  561. [if test "x$use_asciidoc" = xauto; then
  562. AC_MSG_WARN([asciidoc version $asciidoc_version found, but $1 needed])
  563. have_asciidoc=no
  564. else
  565. AC_MSG_ERROR([asciidoc version $asciidoc_version found, but $1 needed])
  566. fi])
  567. fi])
  568. AM_CONDITIONAL([HAVE_ASCIIDOC], [test "$have_asciidoc" = yes])
  569. ]) # XORG_WITH_ASCIIDOC
  570. # XORG_WITH_DOXYGEN([MIN-VERSION], [DEFAULT])
  571. # -------------------------------------------
  572. # Minimum version: 1.5.0
  573. # Minimum version for optional DEFAULT argument: 1.11.0
  574. # Minimum version for optional DOT checking: 1.18.0
  575. #
  576. # Documentation tools are not always available on all platforms and sometimes
  577. # not at the appropriate level. This macro enables a module to test for the
  578. # presence of the tool and obtain it's path in separate variables. Coupled with
  579. # the --with-doxygen option, it allows maximum flexibilty in making decisions
  580. # as whether or not to use the doxygen package. When DEFAULT is not specified,
  581. # --with-doxygen assumes 'auto'.
  582. #
  583. # Interface to module:
  584. # HAVE_DOXYGEN: used in makefiles to conditionally generate documentation
  585. # DOXYGEN: returns the path of the doxygen program found
  586. # returns the path set by the user in the environment
  587. # --with-doxygen: 'yes' user instructs the module to use doxygen
  588. # 'no' user instructs the module not to use doxygen
  589. #
  590. # If the user sets the value of DOXYGEN, AC_PATH_PROG skips testing the path.
  591. #
  592. AC_DEFUN([XORG_WITH_DOXYGEN],[
  593. AC_ARG_VAR([DOXYGEN], [Path to doxygen command])
  594. AC_ARG_VAR([DOT], [Path to the dot graphics utility])
  595. m4_define([_defopt], m4_default([$2], [auto]))
  596. AC_ARG_WITH(doxygen,
  597. AS_HELP_STRING([--with-doxygen],
  598. [Use doxygen to regenerate documentation (default: ]_defopt[)]),
  599. [use_doxygen=$withval], [use_doxygen=]_defopt)
  600. m4_undefine([_defopt])
  601. if test "x$use_doxygen" = x"auto"; then
  602. AC_PATH_PROG([DOXYGEN], [doxygen])
  603. if test "x$DOXYGEN" = "x"; then
  604. AC_MSG_WARN([doxygen not found - documentation targets will be skipped])
  605. have_doxygen=no
  606. else
  607. have_doxygen=yes
  608. fi
  609. elif test "x$use_doxygen" = x"yes" ; then
  610. AC_PATH_PROG([DOXYGEN], [doxygen])
  611. if test "x$DOXYGEN" = "x"; then
  612. AC_MSG_ERROR([--with-doxygen=yes specified but doxygen not found in PATH])
  613. fi
  614. have_doxygen=yes
  615. elif test "x$use_doxygen" = x"no" ; then
  616. if test "x$DOXYGEN" != "x"; then
  617. AC_MSG_WARN([ignoring DOXYGEN environment variable since --with-doxygen=no was specified])
  618. fi
  619. have_doxygen=no
  620. else
  621. AC_MSG_ERROR([--with-doxygen expects 'yes' or 'no'])
  622. fi
  623. m4_ifval([$1],
  624. [if test "$have_doxygen" = yes; then
  625. # scrape the doxygen version
  626. AC_MSG_CHECKING([the doxygen version])
  627. doxygen_version=`$DOXYGEN --version 2>/dev/null`
  628. AC_MSG_RESULT([$doxygen_version])
  629. AS_VERSION_COMPARE([$doxygen_version], [$1],
  630. [if test "x$use_doxygen" = xauto; then
  631. AC_MSG_WARN([doxygen version $doxygen_version found, but $1 needed])
  632. have_doxygen=no
  633. else
  634. AC_MSG_ERROR([doxygen version $doxygen_version found, but $1 needed])
  635. fi])
  636. fi])
  637. dnl Check for DOT if we have doxygen. The caller decides if it is mandatory
  638. dnl HAVE_DOT is a variable that can be used in your doxygen.in config file:
  639. dnl HAVE_DOT = @HAVE_DOT@
  640. HAVE_DOT=no
  641. if test "x$have_doxygen" = "xyes"; then
  642. AC_PATH_PROG([DOT], [dot])
  643. if test "x$DOT" != "x"; then
  644. HAVE_DOT=yes
  645. fi
  646. fi
  647. AC_SUBST([HAVE_DOT])
  648. AM_CONDITIONAL([HAVE_DOT], [test "$HAVE_DOT" = "yes"])
  649. AM_CONDITIONAL([HAVE_DOXYGEN], [test "$have_doxygen" = yes])
  650. ]) # XORG_WITH_DOXYGEN
  651. # XORG_WITH_GROFF([DEFAULT])
  652. # ----------------
  653. # Minimum version: 1.6.0
  654. # Minimum version for optional DEFAULT argument: 1.11.0
  655. #
  656. # Documentation tools are not always available on all platforms and sometimes
  657. # not at the appropriate level. This macro enables a module to test for the
  658. # presence of the tool and obtain it's path in separate variables. Coupled with
  659. # the --with-groff option, it allows maximum flexibilty in making decisions
  660. # as whether or not to use the groff package. When DEFAULT is not specified,
  661. # --with-groff assumes 'auto'.
  662. #
  663. # Interface to module:
  664. # HAVE_GROFF: used in makefiles to conditionally generate documentation
  665. # HAVE_GROFF_MM: the memorandum macros (-mm) package
  666. # HAVE_GROFF_MS: the -ms macros package
  667. # GROFF: returns the path of the groff program found
  668. # returns the path set by the user in the environment
  669. # --with-groff: 'yes' user instructs the module to use groff
  670. # 'no' user instructs the module not to use groff
  671. #
  672. # Added in version 1.9.0:
  673. # HAVE_GROFF_HTML: groff has dependencies to output HTML format:
  674. # pnmcut pnmcrop pnmtopng pnmtops from the netpbm package.
  675. # psselect from the psutils package.
  676. # the ghostcript package. Refer to the grohtml man pages
  677. #
  678. # If the user sets the value of GROFF, AC_PATH_PROG skips testing the path.
  679. #
  680. # OS and distros often splits groff in a basic and full package, the former
  681. # having the groff program and the later having devices, fonts and macros
  682. # Checking for the groff executable is not enough.
  683. #
  684. # If macros are missing, we cannot assume that groff is useless, so we don't
  685. # unset HAVE_GROFF or GROFF env variables.
  686. # HAVE_GROFF_?? can never be true while HAVE_GROFF is false.
  687. #
  688. AC_DEFUN([XORG_WITH_GROFF],[
  689. AC_ARG_VAR([GROFF], [Path to groff command])
  690. m4_define([_defopt], m4_default([$1], [auto]))
  691. AC_ARG_WITH(groff,
  692. AS_HELP_STRING([--with-groff],
  693. [Use groff to regenerate documentation (default: ]_defopt[)]),
  694. [use_groff=$withval], [use_groff=]_defopt)
  695. m4_undefine([_defopt])
  696. if test "x$use_groff" = x"auto"; then
  697. AC_PATH_PROG([GROFF], [groff])
  698. if test "x$GROFF" = "x"; then
  699. AC_MSG_WARN([groff not found - documentation targets will be skipped])
  700. have_groff=no
  701. else
  702. have_groff=yes
  703. fi
  704. elif test "x$use_groff" = x"yes" ; then
  705. AC_PATH_PROG([GROFF], [groff])
  706. if test "x$GROFF" = "x"; then
  707. AC_MSG_ERROR([--with-groff=yes specified but groff not found in PATH])
  708. fi
  709. have_groff=yes
  710. elif test "x$use_groff" = x"no" ; then
  711. if test "x$GROFF" != "x"; then
  712. AC_MSG_WARN([ignoring GROFF environment variable since --with-groff=no was specified])
  713. fi
  714. have_groff=no
  715. else
  716. AC_MSG_ERROR([--with-groff expects 'yes' or 'no'])
  717. fi
  718. # We have groff, test for the presence of the macro packages
  719. if test "x$have_groff" = x"yes"; then
  720. AC_MSG_CHECKING([for ${GROFF} -ms macros])
  721. if ${GROFF} -ms -I. /dev/null >/dev/null 2>&1 ; then
  722. groff_ms_works=yes
  723. else
  724. groff_ms_works=no
  725. fi
  726. AC_MSG_RESULT([$groff_ms_works])
  727. AC_MSG_CHECKING([for ${GROFF} -mm macros])
  728. if ${GROFF} -mm -I. /dev/null >/dev/null 2>&1 ; then
  729. groff_mm_works=yes
  730. else
  731. groff_mm_works=no
  732. fi
  733. AC_MSG_RESULT([$groff_mm_works])
  734. fi
  735. # We have groff, test for HTML dependencies, one command per package
  736. if test "x$have_groff" = x"yes"; then
  737. AC_PATH_PROGS(GS_PATH, [gs gswin32c])
  738. AC_PATH_PROG(PNMTOPNG_PATH, [pnmtopng])
  739. AC_PATH_PROG(PSSELECT_PATH, [psselect])
  740. if test "x$GS_PATH" != "x" -a "x$PNMTOPNG_PATH" != "x" -a "x$PSSELECT_PATH" != "x"; then
  741. have_groff_html=yes
  742. else
  743. have_groff_html=no
  744. AC_MSG_WARN([grohtml dependencies not found - HTML Documentation skipped. Refer to grohtml man pages])
  745. fi
  746. fi
  747. # Set Automake conditionals for Makefiles
  748. AM_CONDITIONAL([HAVE_GROFF], [test "$have_groff" = yes])
  749. AM_CONDITIONAL([HAVE_GROFF_MS], [test "$groff_ms_works" = yes])
  750. AM_CONDITIONAL([HAVE_GROFF_MM], [test "$groff_mm_works" = yes])
  751. AM_CONDITIONAL([HAVE_GROFF_HTML], [test "$have_groff_html" = yes])
  752. ]) # XORG_WITH_GROFF
  753. # XORG_WITH_FOP([MIN-VERSION], [DEFAULT])
  754. # ---------------------------------------
  755. # Minimum version: 1.6.0
  756. # Minimum version for optional DEFAULT argument: 1.11.0
  757. # Minimum version for optional MIN-VERSION argument: 1.15.0
  758. #
  759. # Documentation tools are not always available on all platforms and sometimes
  760. # not at the appropriate level. This macro enables a module to test for the
  761. # presence of the tool and obtain it's path in separate variables. Coupled with
  762. # the --with-fop option, it allows maximum flexibilty in making decisions
  763. # as whether or not to use the fop package. When DEFAULT is not specified,
  764. # --with-fop assumes 'auto'.
  765. #
  766. # Interface to module:
  767. # HAVE_FOP: used in makefiles to conditionally generate documentation
  768. # FOP: returns the path of the fop program found
  769. # returns the path set by the user in the environment
  770. # --with-fop: 'yes' user instructs the module to use fop
  771. # 'no' user instructs the module not to use fop
  772. #
  773. # If the user sets the value of FOP, AC_PATH_PROG skips testing the path.
  774. #
  775. AC_DEFUN([XORG_WITH_FOP],[
  776. AC_ARG_VAR([FOP], [Path to fop command])
  777. m4_define([_defopt], m4_default([$2], [auto]))
  778. AC_ARG_WITH(fop,
  779. AS_HELP_STRING([--with-fop],
  780. [Use fop to regenerate documentation (default: ]_defopt[)]),
  781. [use_fop=$withval], [use_fop=]_defopt)
  782. m4_undefine([_defopt])
  783. if test "x$use_fop" = x"auto"; then
  784. AC_PATH_PROG([FOP], [fop])
  785. if test "x$FOP" = "x"; then
  786. AC_MSG_WARN([fop not found - documentation targets will be skipped])
  787. have_fop=no
  788. else
  789. have_fop=yes
  790. fi
  791. elif test "x$use_fop" = x"yes" ; then
  792. AC_PATH_PROG([FOP], [fop])
  793. if test "x$FOP" = "x"; then
  794. AC_MSG_ERROR([--with-fop=yes specified but fop not found in PATH])
  795. fi
  796. have_fop=yes
  797. elif test "x$use_fop" = x"no" ; then
  798. if test "x$FOP" != "x"; then
  799. AC_MSG_WARN([ignoring FOP environment variable since --with-fop=no was specified])
  800. fi
  801. have_fop=no
  802. else
  803. AC_MSG_ERROR([--with-fop expects 'yes' or 'no'])
  804. fi
  805. # Test for a minimum version of fop, if provided.
  806. m4_ifval([$1],
  807. [if test "$have_fop" = yes; then
  808. # scrape the fop version
  809. AC_MSG_CHECKING([for fop minimum version])
  810. fop_version=`$FOP -version 2>/dev/null | cut -d' ' -f3`
  811. AC_MSG_RESULT([$fop_version])
  812. AS_VERSION_COMPARE([$fop_version], [$1],
  813. [if test "x$use_fop" = xauto; then
  814. AC_MSG_WARN([fop version $fop_version found, but $1 needed])
  815. have_fop=no
  816. else
  817. AC_MSG_ERROR([fop version $fop_version found, but $1 needed])
  818. fi])
  819. fi])
  820. AM_CONDITIONAL([HAVE_FOP], [test "$have_fop" = yes])
  821. ]) # XORG_WITH_FOP
  822. # XORG_WITH_M4([MIN-VERSION])
  823. # ---------------------------
  824. # Minimum version: 1.19.0
  825. #
  826. # This macro attempts to locate an m4 macro processor which supports
  827. # -I option and is only useful for modules relying on M4 in order to
  828. # expand macros in source code files.
  829. #
  830. # Interface to module:
  831. # M4: returns the path of the m4 program found
  832. # returns the path set by the user in the environment
  833. #
  834. AC_DEFUN([XORG_WITH_M4], [
  835. AC_CACHE_CHECK([for m4 that supports -I option], [ac_cv_path_M4],
  836. [AC_PATH_PROGS_FEATURE_CHECK([M4], [m4 gm4],
  837. [[$ac_path_M4 -I. /dev/null > /dev/null 2>&1 && \
  838. ac_cv_path_M4=$ac_path_M4 ac_path_M4_found=:]],
  839. [AC_MSG_ERROR([could not find m4 that supports -I option])],
  840. [$PATH:/usr/gnu/bin])])
  841. AC_SUBST([M4], [$ac_cv_path_M4])
  842. ]) # XORG_WITH_M4
  843. # XORG_WITH_PS2PDF([DEFAULT])
  844. # ----------------
  845. # Minimum version: 1.6.0
  846. # Minimum version for optional DEFAULT argument: 1.11.0
  847. #
  848. # Documentation tools are not always available on all platforms and sometimes
  849. # not at the appropriate level. This macro enables a module to test for the
  850. # presence of the tool and obtain it's path in separate variables. Coupled with
  851. # the --with-ps2pdf option, it allows maximum flexibilty in making decisions
  852. # as whether or not to use the ps2pdf package. When DEFAULT is not specified,
  853. # --with-ps2pdf assumes 'auto'.
  854. #
  855. # Interface to module:
  856. # HAVE_PS2PDF: used in makefiles to conditionally generate documentation
  857. # PS2PDF: returns the path of the ps2pdf program found
  858. # returns the path set by the user in the environment
  859. # --with-ps2pdf: 'yes' user instructs the module to use ps2pdf
  860. # 'no' user instructs the module not to use ps2pdf
  861. #
  862. # If the user sets the value of PS2PDF, AC_PATH_PROG skips testing the path.
  863. #
  864. AC_DEFUN([XORG_WITH_PS2PDF],[
  865. AC_ARG_VAR([PS2PDF], [Path to ps2pdf command])
  866. m4_define([_defopt], m4_default([$1], [auto]))
  867. AC_ARG_WITH(ps2pdf,
  868. AS_HELP_STRING([--with-ps2pdf],
  869. [Use ps2pdf to regenerate documentation (default: ]_defopt[)]),
  870. [use_ps2pdf=$withval], [use_ps2pdf=]_defopt)
  871. m4_undefine([_defopt])
  872. if test "x$use_ps2pdf" = x"auto"; then
  873. AC_PATH_PROG([PS2PDF], [ps2pdf])
  874. if test "x$PS2PDF" = "x"; then
  875. AC_MSG_WARN([ps2pdf not found - documentation targets will be skipped])
  876. have_ps2pdf=no
  877. else
  878. have_ps2pdf=yes
  879. fi
  880. elif test "x$use_ps2pdf" = x"yes" ; then
  881. AC_PATH_PROG([PS2PDF], [ps2pdf])
  882. if test "x$PS2PDF" = "x"; then
  883. AC_MSG_ERROR([--with-ps2pdf=yes specified but ps2pdf not found in PATH])
  884. fi
  885. have_ps2pdf=yes
  886. elif test "x$use_ps2pdf" = x"no" ; then
  887. if test "x$PS2PDF" != "x"; then
  888. AC_MSG_WARN([ignoring PS2PDF environment variable since --with-ps2pdf=no was specified])
  889. fi
  890. have_ps2pdf=no
  891. else
  892. AC_MSG_ERROR([--with-ps2pdf expects 'yes' or 'no'])
  893. fi
  894. AM_CONDITIONAL([HAVE_PS2PDF], [test "$have_ps2pdf" = yes])
  895. ]) # XORG_WITH_PS2PDF
  896. # XORG_ENABLE_DOCS (enable_docs=yes)
  897. # ----------------
  898. # Minimum version: 1.6.0
  899. #
  900. # Documentation tools are not always available on all platforms and sometimes
  901. # not at the appropriate level. This macro enables a builder to skip all
  902. # documentation targets except traditional man pages.
  903. # Combined with the specific tool checking macros XORG_WITH_*, it provides
  904. # maximum flexibilty in controlling documentation building.
  905. # Refer to:
  906. # XORG_WITH_XMLTO --with-xmlto
  907. # XORG_WITH_ASCIIDOC --with-asciidoc
  908. # XORG_WITH_DOXYGEN --with-doxygen
  909. # XORG_WITH_FOP --with-fop
  910. # XORG_WITH_GROFF --with-groff
  911. # XORG_WITH_PS2PDF --with-ps2pdf
  912. #
  913. # Interface to module:
  914. # ENABLE_DOCS: used in makefiles to conditionally generate documentation
  915. # --enable-docs: 'yes' user instructs the module to generate docs
  916. # 'no' user instructs the module not to generate docs
  917. # parm1: specify the default value, yes or no.
  918. #
  919. AC_DEFUN([XORG_ENABLE_DOCS],[
  920. m4_define([docs_default], m4_default([$1], [yes]))
  921. AC_ARG_ENABLE(docs,
  922. AS_HELP_STRING([--enable-docs],
  923. [Enable building the documentation (default: ]docs_default[)]),
  924. [build_docs=$enableval], [build_docs=]docs_default)
  925. m4_undefine([docs_default])
  926. AM_CONDITIONAL(ENABLE_DOCS, [test x$build_docs = xyes])
  927. AC_MSG_CHECKING([whether to build documentation])
  928. AC_MSG_RESULT([$build_docs])
  929. ]) # XORG_ENABLE_DOCS
  930. # XORG_ENABLE_DEVEL_DOCS (enable_devel_docs=yes)
  931. # ----------------
  932. # Minimum version: 1.6.0
  933. #
  934. # This macro enables a builder to skip all developer documentation.
  935. # Combined with the specific tool checking macros XORG_WITH_*, it provides
  936. # maximum flexibilty in controlling documentation building.
  937. # Refer to:
  938. # XORG_WITH_XMLTO --with-xmlto
  939. # XORG_WITH_ASCIIDOC --with-asciidoc
  940. # XORG_WITH_DOXYGEN --with-doxygen
  941. # XORG_WITH_FOP --with-fop
  942. # XORG_WITH_GROFF --with-groff
  943. # XORG_WITH_PS2PDF --with-ps2pdf
  944. #
  945. # Interface to module:
  946. # ENABLE_DEVEL_DOCS: used in makefiles to conditionally generate developer docs
  947. # --enable-devel-docs: 'yes' user instructs the module to generate developer docs
  948. # 'no' user instructs the module not to generate developer docs
  949. # parm1: specify the default value, yes or no.
  950. #
  951. AC_DEFUN([XORG_ENABLE_DEVEL_DOCS],[
  952. m4_define([devel_default], m4_default([$1], [yes]))
  953. AC_ARG_ENABLE(devel-docs,
  954. AS_HELP_STRING([--enable-devel-docs],
  955. [Enable building the developer documentation (default: ]devel_default[)]),
  956. [build_devel_docs=$enableval], [build_devel_docs=]devel_default)
  957. m4_undefine([devel_default])
  958. AM_CONDITIONAL(ENABLE_DEVEL_DOCS, [test x$build_devel_docs = xyes])
  959. AC_MSG_CHECKING([whether to build developer documentation])
  960. AC_MSG_RESULT([$build_devel_docs])
  961. ]) # XORG_ENABLE_DEVEL_DOCS
  962. # XORG_ENABLE_SPECS (enable_specs=yes)
  963. # ----------------
  964. # Minimum version: 1.6.0
  965. #
  966. # This macro enables a builder to skip all functional specification targets.
  967. # Combined with the specific tool checking macros XORG_WITH_*, it provides
  968. # maximum flexibilty in controlling documentation building.
  969. # Refer to:
  970. # XORG_WITH_XMLTO --with-xmlto
  971. # XORG_WITH_ASCIIDOC --with-asciidoc
  972. # XORG_WITH_DOXYGEN --with-doxygen
  973. # XORG_WITH_FOP --with-fop
  974. # XORG_WITH_GROFF --with-groff
  975. # XORG_WITH_PS2PDF --with-ps2pdf
  976. #
  977. # Interface to module:
  978. # ENABLE_SPECS: used in makefiles to conditionally generate specs
  979. # --enable-specs: 'yes' user instructs the module to generate specs
  980. # 'no' user instructs the module not to generate specs
  981. # parm1: specify the default value, yes or no.
  982. #
  983. AC_DEFUN([XORG_ENABLE_SPECS],[
  984. m4_define([spec_default], m4_default([$1], [yes]))
  985. AC_ARG_ENABLE(specs,
  986. AS_HELP_STRING([--enable-specs],
  987. [Enable building the specs (default: ]spec_default[)]),
  988. [build_specs=$enableval], [build_specs=]spec_default)
  989. m4_undefine([spec_default])
  990. AM_CONDITIONAL(ENABLE_SPECS, [test x$build_specs = xyes])
  991. AC_MSG_CHECKING([whether to build functional specifications])
  992. AC_MSG_RESULT([$build_specs])
  993. ]) # XORG_ENABLE_SPECS
  994. # XORG_ENABLE_UNIT_TESTS (enable_unit_tests=auto)
  995. # ----------------------------------------------
  996. # Minimum version: 1.13.0
  997. #
  998. # This macro enables a builder to enable/disable unit testing
  999. # It makes no assumption about the test cases implementation
  1000. # Test cases may or may not use Automake "Support for test suites"
  1001. # They may or may not use the software utility library GLib
  1002. #
  1003. # When used in conjunction with XORG_WITH_GLIB, use both AM_CONDITIONAL
  1004. # ENABLE_UNIT_TESTS and HAVE_GLIB. Not all unit tests may use glib.
  1005. # The variable enable_unit_tests is used by other macros in this file.
  1006. #
  1007. # Interface to module:
  1008. # ENABLE_UNIT_TESTS: used in makefiles to conditionally build tests
  1009. # enable_unit_tests: used in configure.ac for additional configuration
  1010. # --enable-unit-tests: 'yes' user instructs the module to build tests
  1011. # 'no' user instructs the module not to build tests
  1012. # parm1: specify the default value, yes or no.
  1013. #
  1014. AC_DEFUN([XORG_ENABLE_UNIT_TESTS],[
  1015. AC_BEFORE([$0], [XORG_WITH_GLIB])
  1016. AC_BEFORE([$0], [XORG_LD_WRAP])
  1017. AC_REQUIRE([XORG_MEMORY_CHECK_FLAGS])
  1018. m4_define([_defopt], m4_default([$1], [auto]))
  1019. AC_ARG_ENABLE(unit-tests, AS_HELP_STRING([--enable-unit-tests],
  1020. [Enable building unit test cases (default: ]_defopt[)]),
  1021. [enable_unit_tests=$enableval], [enable_unit_tests=]_defopt)
  1022. m4_undefine([_defopt])
  1023. AM_CONDITIONAL(ENABLE_UNIT_TESTS, [test "x$enable_unit_tests" != xno])
  1024. AC_MSG_CHECKING([whether to build unit test cases])
  1025. AC_MSG_RESULT([$enable_unit_tests])
  1026. ]) # XORG_ENABLE_UNIT_TESTS
  1027. # XORG_ENABLE_INTEGRATION_TESTS (enable_unit_tests=auto)
  1028. # ------------------------------------------------------
  1029. # Minimum version: 1.17.0
  1030. #
  1031. # This macro enables a builder to enable/disable integration testing
  1032. # It makes no assumption about the test cases' implementation
  1033. # Test cases may or may not use Automake "Support for test suites"
  1034. #
  1035. # Please see XORG_ENABLE_UNIT_TESTS for unit test support. Unit test support
  1036. # usually requires less dependencies and may be built and run under less
  1037. # stringent environments than integration tests.
  1038. #
  1039. # Interface to module:
  1040. # ENABLE_INTEGRATION_TESTS: used in makefiles to conditionally build tests
  1041. # enable_integration_tests: used in configure.ac for additional configuration
  1042. # --enable-integration-tests: 'yes' user instructs the module to build tests
  1043. # 'no' user instructs the module not to build tests
  1044. # parm1: specify the default value, yes or no.
  1045. #
  1046. AC_DEFUN([XORG_ENABLE_INTEGRATION_TESTS],[
  1047. AC_REQUIRE([XORG_MEMORY_CHECK_FLAGS])
  1048. m4_define([_defopt], m4_default([$1], [auto]))
  1049. AC_ARG_ENABLE(integration-tests, AS_HELP_STRING([--enable-integration-tests],
  1050. [Enable building integration test cases (default: ]_defopt[)]),
  1051. [enable_integration_tests=$enableval],
  1052. [enable_integration_tests=]_defopt)
  1053. m4_undefine([_defopt])
  1054. AM_CONDITIONAL([ENABLE_INTEGRATION_TESTS],
  1055. [test "x$enable_integration_tests" != xno])
  1056. AC_MSG_CHECKING([whether to build unit test cases])
  1057. AC_MSG_RESULT([$enable_integration_tests])
  1058. ]) # XORG_ENABLE_INTEGRATION_TESTS
  1059. # XORG_WITH_GLIB([MIN-VERSION], [DEFAULT])
  1060. # ----------------------------------------
  1061. # Minimum version: 1.13.0
  1062. #
  1063. # GLib is a library which provides advanced data structures and functions.
  1064. # This macro enables a module to test for the presence of Glib.
  1065. #
  1066. # When used with ENABLE_UNIT_TESTS, it is assumed GLib is used for unit testing.
  1067. # Otherwise the value of $enable_unit_tests is blank.
  1068. #
  1069. # Please see XORG_ENABLE_INTEGRATION_TESTS for integration test support. Unit
  1070. # test support usually requires less dependencies and may be built and run under
  1071. # less stringent environments than integration tests.
  1072. #
  1073. # Interface to module:
  1074. # HAVE_GLIB: used in makefiles to conditionally build targets
  1075. # with_glib: used in configure.ac to know if GLib has been found
  1076. # --with-glib: 'yes' user instructs the module to use glib
  1077. # 'no' user instructs the module not to use glib
  1078. #
  1079. AC_DEFUN([XORG_WITH_GLIB],[
  1080. AC_REQUIRE([PKG_PROG_PKG_CONFIG])
  1081. m4_define([_defopt], m4_default([$2], [auto]))
  1082. AC_ARG_WITH(glib, AS_HELP_STRING([--with-glib],
  1083. [Use GLib library for unit testing (default: ]_defopt[)]),
  1084. [with_glib=$withval], [with_glib=]_defopt)
  1085. m4_undefine([_defopt])
  1086. have_glib=no
  1087. # Do not probe GLib if user explicitly disabled unit testing
  1088. if test "x$enable_unit_tests" != x"no"; then
  1089. # Do not probe GLib if user explicitly disabled it
  1090. if test "x$with_glib" != x"no"; then
  1091. m4_ifval(
  1092. [$1],
  1093. [PKG_CHECK_MODULES([GLIB], [glib-2.0 >= $1], [have_glib=yes], [have_glib=no])],
  1094. [PKG_CHECK_MODULES([GLIB], [glib-2.0], [have_glib=yes], [have_glib=no])]
  1095. )
  1096. fi
  1097. fi
  1098. # Not having GLib when unit testing has been explicitly requested is an error
  1099. if test "x$enable_unit_tests" = x"yes"; then
  1100. if test "x$have_glib" = x"no"; then
  1101. AC_MSG_ERROR([--enable-unit-tests=yes specified but glib-2.0 not found])
  1102. fi
  1103. fi
  1104. # Having unit testing disabled when GLib has been explicitly requested is an error
  1105. if test "x$enable_unit_tests" = x"no"; then
  1106. if test "x$with_glib" = x"yes"; then
  1107. AC_MSG_ERROR([--enable-unit-tests=yes specified but glib-2.0 not found])
  1108. fi
  1109. fi
  1110. # Not having GLib when it has been explicitly requested is an error
  1111. if test "x$with_glib" = x"yes"; then
  1112. if test "x$have_glib" = x"no"; then
  1113. AC_MSG_ERROR([--with-glib=yes specified but glib-2.0 not found])
  1114. fi
  1115. fi
  1116. AM_CONDITIONAL([HAVE_GLIB], [test "$have_glib" = yes])
  1117. ]) # XORG_WITH_GLIB
  1118. # XORG_LD_WRAP([required|optional])
  1119. # ---------------------------------
  1120. # Minimum version: 1.13.0
  1121. #
  1122. # Check if linker supports -wrap, passed via compiler flags
  1123. #
  1124. # When used with ENABLE_UNIT_TESTS, it is assumed -wrap is used for unit testing.
  1125. # Otherwise the value of $enable_unit_tests is blank.
  1126. #
  1127. # Argument added in 1.16.0 - default is "required", to match existing behavior
  1128. # of returning an error if enable_unit_tests is yes, and ld -wrap is not
  1129. # available, an argument of "optional" allows use when some unit tests require
  1130. # ld -wrap and others do not.
  1131. #
  1132. AC_DEFUN([XORG_LD_WRAP],[
  1133. XORG_CHECK_LINKER_FLAGS([-Wl,-wrap,exit],[have_ld_wrap=yes],[have_ld_wrap=no],
  1134. [AC_LANG_PROGRAM([#include <stdlib.h>
  1135. void __wrap_exit(int status) { return; }],
  1136. [exit(0);])])
  1137. # Not having ld wrap when unit testing has been explicitly requested is an error
  1138. if test "x$enable_unit_tests" = x"yes" -a "x$1" != "xoptional"; then
  1139. if test "x$have_ld_wrap" = x"no"; then
  1140. AC_MSG_ERROR([--enable-unit-tests=yes specified but ld -wrap support is not available])
  1141. fi
  1142. fi
  1143. AM_CONDITIONAL([HAVE_LD_WRAP], [test "$have_ld_wrap" = yes])
  1144. #
  1145. ]) # XORG_LD_WRAP
  1146. # XORG_CHECK_LINKER_FLAGS
  1147. # -----------------------
  1148. # SYNOPSIS
  1149. #
  1150. # XORG_CHECK_LINKER_FLAGS(FLAGS, [ACTION-SUCCESS], [ACTION-FAILURE], [PROGRAM-SOURCE])
  1151. #
  1152. # DESCRIPTION
  1153. #
  1154. # Check whether the given linker FLAGS work with the current language's
  1155. # linker, or whether they give an error.
  1156. #
  1157. # ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
  1158. # success/failure.
  1159. #
  1160. # PROGRAM-SOURCE is the program source to link with, if needed
  1161. #
  1162. # NOTE: Based on AX_CHECK_COMPILER_FLAGS.
  1163. #
  1164. # LICENSE
  1165. #
  1166. # Copyright (c) 2009 Mike Frysinger <vapier@gentoo.org>
  1167. # Copyright (c) 2009 Steven G. Johnson <stevenj@alum.mit.edu>
  1168. # Copyright (c) 2009 Matteo Frigo
  1169. #
  1170. # This program is free software: you can redistribute it and/or modify it
  1171. # under the terms of the GNU General Public License as published by the
  1172. # Free Software Foundation, either version 3 of the License, or (at your
  1173. # option) any later version.
  1174. #
  1175. # This program is distributed in the hope that it will be useful, but
  1176. # WITHOUT ANY WARRANTY; without even the implied warranty of
  1177. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
  1178. # Public License for more details.
  1179. #
  1180. # You should have received a copy of the GNU General Public License along
  1181. # with this program. If not, see <http://www.gnu.org/licenses/>.
  1182. #
  1183. # As a special exception, the respective Autoconf Macro's copyright owner
  1184. # gives unlimited permission to copy, distribute and modify the configure
  1185. # scripts that are the output of Autoconf when processing the Macro. You
  1186. # need not follow the terms of the GNU General Public License when using
  1187. # or distributing such scripts, even though portions of the text of the
  1188. # Macro appear in them. The GNU General Public License (GPL) does govern
  1189. # all other use of the material that constitutes the Autoconf Macro.
  1190. #
  1191. # This special exception to the GPL applies to versions of the Autoconf
  1192. # Macro released by the Autoconf Archive. When you make and distribute a
  1193. # modified version of the Autoconf Macro, you may extend this special
  1194. # exception to the GPL to apply to your modified version as well.#
  1195. AC_DEFUN([XORG_CHECK_LINKER_FLAGS],
  1196. [AC_MSG_CHECKING([whether the linker accepts $1])
  1197. dnl Some hackery here since AC_CACHE_VAL can't handle a non-literal varname:
  1198. AS_LITERAL_IF([$1],
  1199. [AC_CACHE_VAL(AS_TR_SH(xorg_cv_linker_flags_[$1]), [
  1200. ax_save_FLAGS=$LDFLAGS
  1201. LDFLAGS="$1"
  1202. AC_LINK_IFELSE([m4_default([$4],[AC_LANG_PROGRAM()])],
  1203. AS_TR_SH(xorg_cv_linker_flags_[$1])=yes,
  1204. AS_TR_SH(xorg_cv_linker_flags_[$1])=no)
  1205. LDFLAGS=$ax_save_FLAGS])],
  1206. [ax_save_FLAGS=$LDFLAGS
  1207. LDFLAGS="$1"
  1208. AC_LINK_IFELSE([AC_LANG_PROGRAM()],
  1209. eval AS_TR_SH(xorg_cv_linker_flags_[$1])=yes,
  1210. eval AS_TR_SH(xorg_cv_linker_flags_[$1])=no)
  1211. LDFLAGS=$ax_save_FLAGS])
  1212. eval xorg_check_linker_flags=$AS_TR_SH(xorg_cv_linker_flags_[$1])
  1213. AC_MSG_RESULT($xorg_check_linker_flags)
  1214. if test "x$xorg_check_linker_flags" = xyes; then
  1215. m4_default([$2], :)
  1216. else
  1217. m4_default([$3], :)
  1218. fi
  1219. ]) # XORG_CHECK_LINKER_FLAGS
  1220. # XORG_MEMORY_CHECK_FLAGS
  1221. # -----------------------
  1222. # Minimum version: 1.16.0
  1223. #
  1224. # This macro attempts to find appropriate memory checking functionality
  1225. # for various platforms which unit testing code may use to catch various
  1226. # forms of memory allocation and access errors in testing.
  1227. #
  1228. # Interface to module:
  1229. # XORG_MALLOC_DEBUG_ENV - environment variables to set to enable debugging
  1230. # Usually added to TESTS_ENVIRONMENT in Makefile.am
  1231. #
  1232. # If the user sets the value of XORG_MALLOC_DEBUG_ENV, it is used verbatim.
  1233. #
  1234. AC_DEFUN([XORG_MEMORY_CHECK_FLAGS],[
  1235. AC_REQUIRE([AC_CANONICAL_HOST])
  1236. AC_ARG_VAR([XORG_MALLOC_DEBUG_ENV],
  1237. [Environment variables to enable memory checking in tests])
  1238. # Check for different types of support on different platforms
  1239. case $host_os in
  1240. solaris*)
  1241. AC_CHECK_LIB([umem], [umem_alloc],
  1242. [malloc_debug_env='LD_PRELOAD=libumem.so UMEM_DEBUG=default'])
  1243. ;;
  1244. *-gnu*) # GNU libc - Value is used as a single byte bit pattern,
  1245. # both directly and inverted, so should not be 0 or 255.
  1246. malloc_debug_env='MALLOC_PERTURB_=15'
  1247. ;;
  1248. darwin*)
  1249. malloc_debug_env='MallocPreScribble=1 MallocScribble=1 DYLD_INSERT_LIBRARIES=/usr/lib/libgmalloc.dylib'
  1250. ;;
  1251. *bsd*)
  1252. malloc_debug_env='MallocPreScribble=1 MallocScribble=1'
  1253. ;;
  1254. esac
  1255. # User supplied flags override default flags
  1256. if test "x$XORG_MALLOC_DEBUG_ENV" != "x"; then
  1257. malloc_debug_env="$XORG_MALLOC_DEBUG_ENV"
  1258. fi
  1259. AC_SUBST([XORG_MALLOC_DEBUG_ENV],[$malloc_debug_env])
  1260. ]) # XORG_WITH_LINT
  1261. # XORG_CHECK_MALLOC_ZERO
  1262. # ----------------------
  1263. # Minimum version: 1.0.0
  1264. #
  1265. # Defines {MALLOC,XMALLOC,XTMALLOC}_ZERO_CFLAGS appropriately if
  1266. # malloc(0) returns NULL. Packages should add one of these cflags to
  1267. # their AM_CFLAGS (or other appropriate *_CFLAGS) to use them.
  1268. AC_DEFUN([XORG_CHECK_MALLOC_ZERO],[
  1269. AC_ARG_ENABLE(malloc0returnsnull,
  1270. AS_HELP_STRING([--enable-malloc0returnsnull],
  1271. [malloc(0) returns NULL (default: auto)]),
  1272. [MALLOC_ZERO_RETURNS_NULL=$enableval],
  1273. [MALLOC_ZERO_RETURNS_NULL=auto])
  1274. AC_MSG_CHECKING([whether malloc(0) returns NULL])
  1275. if test "x$MALLOC_ZERO_RETURNS_NULL" = xauto; then
  1276. AC_CACHE_VAL([xorg_cv_malloc0_returns_null],
  1277. [AC_RUN_IFELSE([AC_LANG_PROGRAM([
  1278. #include <stdlib.h>
  1279. ],[
  1280. char *m0, *r0, *c0, *p;
  1281. m0 = malloc(0);
  1282. p = malloc(10);
  1283. r0 = realloc(p,0);
  1284. c0 = calloc(0,10);
  1285. exit((m0 == 0 || r0 == 0 || c0 == 0) ? 0 : 1);
  1286. ])],
  1287. [xorg_cv_malloc0_returns_null=yes],
  1288. [xorg_cv_malloc0_returns_null=no])])
  1289. MALLOC_ZERO_RETURNS_NULL=$xorg_cv_malloc0_returns_null
  1290. fi
  1291. AC_MSG_RESULT([$MALLOC_ZERO_RETURNS_NULL])
  1292. if test "x$MALLOC_ZERO_RETURNS_NULL" = xyes; then
  1293. MALLOC_ZERO_CFLAGS="-DMALLOC_0_RETURNS_NULL"
  1294. XMALLOC_ZERO_CFLAGS=$MALLOC_ZERO_CFLAGS
  1295. XTMALLOC_ZERO_CFLAGS="$MALLOC_ZERO_CFLAGS -DXTMALLOC_BC"
  1296. else
  1297. MALLOC_ZERO_CFLAGS=""
  1298. XMALLOC_ZERO_CFLAGS=""
  1299. XTMALLOC_ZERO_CFLAGS=""
  1300. fi
  1301. AC_SUBST([MALLOC_ZERO_CFLAGS])
  1302. AC_SUBST([XMALLOC_ZERO_CFLAGS])
  1303. AC_SUBST([XTMALLOC_ZERO_CFLAGS])
  1304. ]) # XORG_CHECK_MALLOC_ZERO
  1305. # XORG_WITH_LINT()
  1306. # ----------------
  1307. # Minimum version: 1.1.0
  1308. #
  1309. # This macro enables the use of a tool that flags some suspicious and
  1310. # non-portable constructs (likely to be bugs) in C language source code.
  1311. # It will attempt to locate the tool and use appropriate options.
  1312. # There are various lint type tools on different platforms.
  1313. #
  1314. # Interface to module:
  1315. # LINT: returns the path to the tool found on the platform
  1316. # or the value set to LINT on the configure cmd line
  1317. # also an Automake conditional
  1318. # LINT_FLAGS: an Automake variable with appropriate flags
  1319. #
  1320. # --with-lint: 'yes' user instructs the module to use lint
  1321. # 'no' user instructs the module not to use lint (default)
  1322. #
  1323. # If the user sets the value of LINT, AC_PATH_PROG skips testing the path.
  1324. # If the user sets the value of LINT_FLAGS, they are used verbatim.
  1325. #
  1326. AC_DEFUN([XORG_WITH_LINT],[
  1327. AC_ARG_VAR([LINT], [Path to a lint-style command])
  1328. AC_ARG_VAR([LINT_FLAGS], [Flags for the lint-style command])
  1329. AC_ARG_WITH(lint, [AS_HELP_STRING([--with-lint],
  1330. [Use a lint-style source code checker (default: disabled)])],
  1331. [use_lint=$withval], [use_lint=no])
  1332. # Obtain platform specific info like program name and options
  1333. # The lint program on FreeBSD and NetBSD is different from the one on Solaris
  1334. case $host_os in
  1335. *linux* | *openbsd* | kfreebsd*-gnu | darwin* | cygwin*)
  1336. lint_name=splint
  1337. lint_options="-badflag"
  1338. ;;
  1339. *freebsd* | *netbsd*)
  1340. lint_name=lint
  1341. lint_options="-u -b"
  1342. ;;
  1343. *solaris*)
  1344. lint_name=lint
  1345. lint_options="-u -b -h -erroff=E_INDISTING_FROM_TRUNC2"
  1346. ;;
  1347. esac
  1348. # Test for the presence of the program (either guessed by the code or spelled out by the user)
  1349. if test "x$use_lint" = x"yes" ; then
  1350. AC_PATH_PROG([LINT], [$lint_name])
  1351. if test "x$LINT" = "x"; then
  1352. AC_MSG_ERROR([--with-lint=yes specified but lint-style tool not found in PATH])
  1353. fi
  1354. elif test "x$use_lint" = x"no" ; then
  1355. if test "x$LINT" != "x"; then
  1356. AC_MSG_WARN([ignoring LINT environment variable since --with-lint=no was specified])
  1357. fi
  1358. else
  1359. AC_MSG_ERROR([--with-lint expects 'yes' or 'no'. Use LINT variable to specify path.])
  1360. fi
  1361. # User supplied flags override default flags
  1362. if test "x$LINT_FLAGS" != "x"; then
  1363. lint_options=$LINT_FLAGS
  1364. fi
  1365. AC_SUBST([LINT_FLAGS],[$lint_options])
  1366. AM_CONDITIONAL(LINT, [test "x$LINT" != x])
  1367. ]) # XORG_WITH_LINT
  1368. # XORG_LINT_LIBRARY(LIBNAME)
  1369. # --------------------------
  1370. # Minimum version: 1.1.0
  1371. #
  1372. # Sets up flags for building lint libraries for checking programs that call
  1373. # functions in the library.
  1374. #
  1375. # Interface to module:
  1376. # LINTLIB - Automake variable with the name of lint library file to make
  1377. # MAKE_LINT_LIB - Automake conditional
  1378. #
  1379. # --enable-lint-library: - 'yes' user instructs the module to created a lint library
  1380. # - 'no' user instructs the module not to create a lint library (default)
  1381. AC_DEFUN([XORG_LINT_LIBRARY],[
  1382. AC_REQUIRE([XORG_WITH_LINT])
  1383. AC_ARG_ENABLE(lint-library, [AS_HELP_STRING([--enable-lint-library],
  1384. [Create lint library (default: disabled)])],
  1385. [make_lint_lib=$enableval], [make_lint_lib=no])
  1386. if test "x$make_lint_lib" = x"yes" ; then
  1387. LINTLIB=llib-l$1.ln
  1388. if test "x$LINT" = "x"; then
  1389. AC_MSG_ERROR([Cannot make lint library without --with-lint])
  1390. fi
  1391. elif test "x$make_lint_lib" != x"no" ; then
  1392. AC_MSG_ERROR([--enable-lint-library expects 'yes' or 'no'.])
  1393. fi
  1394. AC_SUBST(LINTLIB)
  1395. AM_CONDITIONAL(MAKE_LINT_LIB, [test x$make_lint_lib != xno])
  1396. ]) # XORG_LINT_LIBRARY
  1397. # XORG_COMPILER_BRAND
  1398. # -------------------
  1399. # Minimum version: 1.14.0
  1400. #
  1401. # Checks for various brands of compilers and sets flags as appropriate:
  1402. # GNU gcc - relies on AC_PROG_CC (via AC_PROG_CC_C99) to set GCC to "yes"
  1403. # GNU g++ - relies on AC_PROG_CXX to set GXX to "yes"
  1404. # clang compiler - sets CLANGCC to "yes"
  1405. # Intel compiler - sets INTELCC to "yes"
  1406. # Sun/Oracle Solaris Studio cc - sets SUNCC to "yes"
  1407. #
  1408. AC_DEFUN([XORG_COMPILER_BRAND], [
  1409. AC_LANG_CASE(
  1410. [C], [
  1411. AC_REQUIRE([AC_PROG_CC_C99])
  1412. ],
  1413. [C++], [
  1414. AC_REQUIRE([AC_PROG_CXX])
  1415. ]
  1416. )
  1417. AC_CHECK_DECL([__clang__], [CLANGCC="yes"], [CLANGCC="no"])
  1418. AC_CHECK_DECL([__INTEL_COMPILER], [INTELCC="yes"], [INTELCC="no"])
  1419. AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
  1420. ]) # XORG_COMPILER_BRAND
  1421. # XORG_TESTSET_CFLAG(<variable>, <flag>, [<alternative flag>, ...])
  1422. # ---------------
  1423. # Minimum version: 1.16.0
  1424. #
  1425. # Test if the compiler works when passed the given flag as a command line argument.
  1426. # If it succeeds, the flag is appeneded to the given variable. If not, it tries the
  1427. # next flag in the list until there are no more options.
  1428. #
  1429. # Note that this does not guarantee that the compiler supports the flag as some
  1430. # compilers will simply ignore arguments that they do not understand, but we do
  1431. # attempt to weed out false positives by using -Werror=unknown-warning-option and
  1432. # -Werror=unused-command-line-argument
  1433. #
  1434. AC_DEFUN([XORG_TESTSET_CFLAG], [
  1435. m4_if([$#], 0, [m4_fatal([XORG_TESTSET_CFLAG was given with an unsupported number of arguments])])
  1436. m4_if([$#], 1, [m4_fatal([XORG_TESTSET_CFLAG was given with an unsupported number of arguments])])
  1437. AC_LANG_COMPILER_REQUIRE
  1438. AC_LANG_CASE(
  1439. [C], [
  1440. AC_REQUIRE([AC_PROG_CC_C99])
  1441. define([PREFIX], [C])
  1442. define([CACHE_PREFIX], [cc])
  1443. define([COMPILER], [$CC])
  1444. ],
  1445. [C++], [
  1446. define([PREFIX], [CXX])
  1447. define([CACHE_PREFIX], [cxx])
  1448. define([COMPILER], [$CXX])
  1449. ]
  1450. )
  1451. [xorg_testset_save_]PREFIX[FLAGS]="$PREFIX[FLAGS]"
  1452. if test "x$[xorg_testset_]CACHE_PREFIX[_unknown_warning_option]" = "x" ; then
  1453. PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unknown-warning-option"
  1454. AC_CACHE_CHECK([if ]COMPILER[ supports -Werror=unknown-warning-option],
  1455. [xorg_cv_]CACHE_PREFIX[_flag_unknown_warning_option],
  1456. AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])],
  1457. [xorg_cv_]CACHE_PREFIX[_flag_unknown_warning_option=yes],
  1458. [xorg_cv_]CACHE_PREFIX[_flag_unknown_warning_option=no]))
  1459. [xorg_testset_]CACHE_PREFIX[_unknown_warning_option]=$[xorg_cv_]CACHE_PREFIX[_flag_unknown_warning_option]
  1460. PREFIX[FLAGS]="$[xorg_testset_save_]PREFIX[FLAGS]"
  1461. fi
  1462. if test "x$[xorg_testset_]CACHE_PREFIX[_unused_command_line_argument]" = "x" ; then
  1463. if test "x$[xorg_testset_]CACHE_PREFIX[_unknown_warning_option]" = "xyes" ; then
  1464. PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unknown-warning-option"
  1465. fi
  1466. PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unused-command-line-argument"
  1467. AC_CACHE_CHECK([if ]COMPILER[ supports -Werror=unused-command-line-argument],
  1468. [xorg_cv_]CACHE_PREFIX[_flag_unused_command_line_argument],
  1469. AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])],
  1470. [xorg_cv_]CACHE_PREFIX[_flag_unused_command_line_argument=yes],
  1471. [xorg_cv_]CACHE_PREFIX[_flag_unused_command_line_argument=no]))
  1472. [xorg_testset_]CACHE_PREFIX[_unused_command_line_argument]=$[xorg_cv_]CACHE_PREFIX[_flag_unused_command_line_argument]
  1473. PREFIX[FLAGS]="$[xorg_testset_save_]PREFIX[FLAGS]"
  1474. fi
  1475. found="no"
  1476. m4_foreach([flag], m4_cdr($@), [
  1477. if test $found = "no" ; then
  1478. if test "x$xorg_testset_]CACHE_PREFIX[_unknown_warning_option" = "xyes" ; then
  1479. PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unknown-warning-option"
  1480. fi
  1481. if test "x$xorg_testset_]CACHE_PREFIX[_unused_command_line_argument" = "xyes" ; then
  1482. PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unused-command-line-argument"
  1483. fi
  1484. PREFIX[FLAGS]="$PREFIX[FLAGS] ]flag["
  1485. dnl Some hackery here since AC_CACHE_VAL can't handle a non-literal varname
  1486. AC_MSG_CHECKING([if ]COMPILER[ supports ]flag[])
  1487. cacheid=AS_TR_SH([xorg_cv_]CACHE_PREFIX[_flag_]flag[])
  1488. AC_CACHE_VAL($cacheid,
  1489. [AC_LINK_IFELSE([AC_LANG_PROGRAM([int i;])],
  1490. [eval $cacheid=yes],
  1491. [eval $cacheid=no])])
  1492. PREFIX[FLAGS]="$[xorg_testset_save_]PREFIX[FLAGS]"
  1493. eval supported=\$$cacheid
  1494. AC_MSG_RESULT([$supported])
  1495. if test "$supported" = "yes" ; then
  1496. $1="$$1 ]flag["
  1497. found="yes"
  1498. fi
  1499. fi
  1500. ])
  1501. ]) # XORG_TESTSET_CFLAG
  1502. # XORG_COMPILER_FLAGS
  1503. # ---------------
  1504. # Minimum version: 1.16.0
  1505. #
  1506. # Defines BASE_CFLAGS or BASE_CXXFLAGS to contain a set of command line
  1507. # arguments supported by the selected compiler which do NOT alter the generated
  1508. # code. These arguments will cause the compiler to print various warnings
  1509. # during compilation AND turn a conservative set of warnings into errors.
  1510. #
  1511. # The set of flags supported by BASE_CFLAGS and BASE_CXXFLAGS will grow in
  1512. # future versions of util-macros as options are added to new compilers.
  1513. #
  1514. AC_DEFUN([XORG_COMPILER_FLAGS], [
  1515. AC_REQUIRE([XORG_COMPILER_BRAND])
  1516. AC_ARG_ENABLE(selective-werror,
  1517. AS_HELP_STRING([--disable-selective-werror],
  1518. [Turn off selective compiler errors. (default: enabled)]),
  1519. [SELECTIVE_WERROR=$enableval],
  1520. [SELECTIVE_WERROR=yes])
  1521. AC_LANG_CASE(
  1522. [C], [
  1523. define([PREFIX], [C])
  1524. ],
  1525. [C++], [
  1526. define([PREFIX], [CXX])
  1527. ]
  1528. )
  1529. # -v is too short to test reliably with XORG_TESTSET_CFLAG
  1530. if test "x$SUNCC" = "xyes"; then
  1531. [BASE_]PREFIX[FLAGS]="-v"
  1532. else
  1533. [BASE_]PREFIX[FLAGS]=""
  1534. fi
  1535. # This chunk of warnings were those that existed in the legacy CWARNFLAGS
  1536. XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wall])
  1537. XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wpointer-arith])
  1538. XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-declarations])
  1539. XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wformat=2], [-Wformat])
  1540. AC_LANG_CASE(
  1541. [C], [
  1542. XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wstrict-prototypes])
  1543. XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-prototypes])
  1544. XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wnested-externs])
  1545. XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wbad-function-cast])
  1546. XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wold-style-definition], [-fd])
  1547. XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wdeclaration-after-statement])
  1548. ]
  1549. )
  1550. # This chunk adds additional warnings that could catch undesired effects.
  1551. XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wunused])
  1552. XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wuninitialized])
  1553. XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wshadow])
  1554. XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-noreturn])
  1555. XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-format-attribute])
  1556. XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wredundant-decls])
  1557. XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wlogical-op])
  1558. # These are currently disabled because they are noisy. They will be enabled
  1559. # in the future once the codebase is sufficiently modernized to silence
  1560. # them. For now, I don't want them to drown out the other warnings.
  1561. # XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wparentheses])
  1562. # XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wcast-align])
  1563. # XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wcast-qual])
  1564. # Turn some warnings into errors, so we don't accidently get successful builds
  1565. # when there are problems that should be fixed.
  1566. if test "x$SELECTIVE_WERROR" = "xyes" ; then
  1567. XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=implicit], [-errwarn=E_NO_EXPLICIT_TYPE_GIVEN -errwarn=E_NO_IMPLICIT_DECL_ALLOWED])
  1568. XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=nonnull])
  1569. XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=init-self])
  1570. XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=main])
  1571. XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=missing-braces])
  1572. XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=sequence-point])
  1573. XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=return-type], [-errwarn=E_FUNC_HAS_NO_RETURN_STMT])
  1574. XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=trigraphs])
  1575. XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=array-bounds])
  1576. XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=write-strings])
  1577. XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=address])
  1578. XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=int-to-pointer-cast], [-errwarn=E_BAD_PTR_INT_COMBINATION])
  1579. XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=pointer-to-int-cast]) # Also -errwarn=E_BAD_PTR_INT_COMBINATION
  1580. else
  1581. AC_MSG_WARN([You have chosen not to turn some select compiler warnings into errors. This should not be necessary. Please report why you needed to do so in a bug report at $PACKAGE_BUGREPORT])
  1582. XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wimplicit])
  1583. XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wnonnull])
  1584. XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Winit-self])
  1585. XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmain])
  1586. XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-braces])
  1587. XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wsequence-point])
  1588. XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wreturn-type])
  1589. XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wtrigraphs])
  1590. XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Warray-bounds])
  1591. XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wwrite-strings])
  1592. XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Waddress])
  1593. XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wint-to-pointer-cast])
  1594. XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wpointer-to-int-cast])
  1595. fi
  1596. AC_SUBST([BASE_]PREFIX[FLAGS])
  1597. ]) # XORG_COMPILER_FLAGS
  1598. # XORG_CWARNFLAGS
  1599. # ---------------
  1600. # Minimum version: 1.2.0
  1601. # Deprecated since: 1.16.0 (Use XORG_COMPILER_FLAGS instead)
  1602. #
  1603. # Defines CWARNFLAGS to enable C compiler warnings.
  1604. #
  1605. # This function is deprecated because it defines -fno-strict-aliasing
  1606. # which alters the code generated by the compiler. If -fno-strict-aliasing
  1607. # is needed, then it should be added explicitly in the module when
  1608. # it is updated to use BASE_CFLAGS.
  1609. #
  1610. AC_DEFUN([XORG_CWARNFLAGS], [
  1611. AC_REQUIRE([XORG_COMPILER_FLAGS])
  1612. AC_REQUIRE([XORG_COMPILER_BRAND])
  1613. AC_LANG_CASE(
  1614. [C], [
  1615. CWARNFLAGS="$BASE_CFLAGS"
  1616. if test "x$GCC" = xyes ; then
  1617. CWARNFLAGS="$CWARNFLAGS -fno-strict-aliasing"
  1618. fi
  1619. AC_SUBST(CWARNFLAGS)
  1620. ]
  1621. )
  1622. ]) # XORG_CWARNFLAGS
  1623. # XORG_STRICT_OPTION
  1624. # -----------------------
  1625. # Minimum version: 1.3.0
  1626. #
  1627. # Add configure option to enable strict compilation flags, such as treating
  1628. # warnings as fatal errors.
  1629. # If --enable-strict-compilation is passed to configure, adds strict flags to
  1630. # $BASE_CFLAGS or $BASE_CXXFLAGS and the deprecated $CWARNFLAGS.
  1631. #
  1632. # Starting in 1.14.0 also exports $STRICT_CFLAGS for use in other tests or
  1633. # when strict compilation is unconditionally desired.
  1634. AC_DEFUN([XORG_STRICT_OPTION], [
  1635. AC_REQUIRE([XORG_CWARNFLAGS])
  1636. AC_REQUIRE([XORG_COMPILER_FLAGS])
  1637. AC_ARG_ENABLE(strict-compilation,
  1638. AS_HELP_STRING([--enable-strict-compilation],
  1639. [Enable all warnings from compiler and make them errors (default: disabled)]),
  1640. [STRICT_COMPILE=$enableval], [STRICT_COMPILE=no])
  1641. AC_LANG_CASE(
  1642. [C], [
  1643. define([PREFIX], [C])
  1644. ],
  1645. [C++], [
  1646. define([PREFIX], [CXX])
  1647. ]
  1648. )
  1649. [STRICT_]PREFIX[FLAGS]=""
  1650. XORG_TESTSET_CFLAG([[STRICT_]PREFIX[FLAGS]], [-pedantic])
  1651. XORG_TESTSET_CFLAG([[STRICT_]PREFIX[FLAGS]], [-Werror], [-errwarn])
  1652. # Earlier versions of gcc (eg: 4.2) support -Werror=attributes, but do not
  1653. # activate it with -Werror, so we add it here explicitly.
  1654. XORG_TESTSET_CFLAG([[STRICT_]PREFIX[FLAGS]], [-Werror=attributes])
  1655. if test "x$STRICT_COMPILE" = "xyes"; then
  1656. [BASE_]PREFIX[FLAGS]="$[BASE_]PREFIX[FLAGS] $[STRICT_]PREFIX[FLAGS]"
  1657. AC_LANG_CASE([C], [CWARNFLAGS="$CWARNFLAGS $STRICT_CFLAGS"])
  1658. fi
  1659. AC_SUBST([STRICT_]PREFIX[FLAGS])
  1660. AC_SUBST([BASE_]PREFIX[FLAGS])
  1661. AC_LANG_CASE([C], AC_SUBST([CWARNFLAGS]))
  1662. ]) # XORG_STRICT_OPTION
  1663. # XORG_DEFAULT_OPTIONS
  1664. # --------------------
  1665. # Minimum version: 1.3.0
  1666. #
  1667. # Defines default options for X.Org modules.
  1668. #
  1669. AC_DEFUN([XORG_DEFAULT_OPTIONS], [
  1670. AC_REQUIRE([AC_PROG_INSTALL])
  1671. XORG_COMPILER_FLAGS
  1672. XORG_CWARNFLAGS
  1673. XORG_STRICT_OPTION
  1674. XORG_RELEASE_VERSION
  1675. XORG_CHANGELOG
  1676. XORG_INSTALL
  1677. XORG_MANPAGE_SECTIONS
  1678. m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])],
  1679. [AC_SUBST([AM_DEFAULT_VERBOSITY], [1])])
  1680. ]) # XORG_DEFAULT_OPTIONS
  1681. # XORG_INSTALL()
  1682. # ----------------
  1683. # Minimum version: 1.4.0
  1684. #
  1685. # Defines the variable INSTALL_CMD as the command to copy
  1686. # INSTALL from $prefix/share/util-macros.
  1687. #
  1688. AC_DEFUN([XORG_INSTALL], [
  1689. AC_REQUIRE([PKG_PROG_PKG_CONFIG])
  1690. macros_datadir=`$PKG_CONFIG --print-errors --variable=pkgdatadir xorg-macros`
  1691. INSTALL_CMD="(cp -f "$macros_datadir/INSTALL" \$(top_srcdir)/.INSTALL.tmp && \
  1692. mv \$(top_srcdir)/.INSTALL.tmp \$(top_srcdir)/INSTALL) \
  1693. || (rm -f \$(top_srcdir)/.INSTALL.tmp; touch \$(top_srcdir)/INSTALL; \
  1694. echo 'util-macros \"pkgdatadir\" from xorg-macros.pc not found: installing possibly empty INSTALL.' >&2)"
  1695. AC_SUBST([INSTALL_CMD])
  1696. ]) # XORG_INSTALL
  1697. dnl Copyright 2005 Red Hat, Inc
  1698. dnl
  1699. dnl Permission to use, copy, modify, distribute, and sell this software and its
  1700. dnl documentation for any purpose is hereby granted without fee, provided that
  1701. dnl the above copyright notice appear in all copies and that both that
  1702. dnl copyright notice and this permission notice appear in supporting
  1703. dnl documentation.
  1704. dnl
  1705. dnl The above copyright notice and this permission notice shall be included
  1706. dnl in all copies or substantial portions of the Software.
  1707. dnl
  1708. dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  1709. dnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  1710. dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  1711. dnl IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
  1712. dnl OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  1713. dnl ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  1714. dnl OTHER DEALINGS IN THE SOFTWARE.
  1715. dnl
  1716. dnl Except as contained in this notice, the name of the copyright holders shall
  1717. dnl not be used in advertising or otherwise to promote the sale, use or
  1718. dnl other dealings in this Software without prior written authorization
  1719. dnl from the copyright holders.
  1720. dnl
  1721. # XORG_RELEASE_VERSION
  1722. # --------------------
  1723. # Defines PACKAGE_VERSION_{MAJOR,MINOR,PATCHLEVEL} for modules to use.
  1724. AC_DEFUN([XORG_RELEASE_VERSION],[
  1725. AC_DEFINE_UNQUOTED([PACKAGE_VERSION_MAJOR],
  1726. [`echo $PACKAGE_VERSION | cut -d . -f 1`],
  1727. [Major version of this package])
  1728. PVM=`echo $PACKAGE_VERSION | cut -d . -f 2 | cut -d - -f 1`
  1729. if test "x$PVM" = "x"; then
  1730. PVM="0"
  1731. fi
  1732. AC_DEFINE_UNQUOTED([PACKAGE_VERSION_MINOR],
  1733. [$PVM],
  1734. [Minor version of this package])
  1735. PVP=`echo $PACKAGE_VERSION | cut -d . -f 3 | cut -d - -f 1`
  1736. if test "x$PVP" = "x"; then
  1737. PVP="0"
  1738. fi
  1739. AC_DEFINE_UNQUOTED([PACKAGE_VERSION_PATCHLEVEL],
  1740. [$PVP],
  1741. [Patch version of this package])
  1742. ])
  1743. # XORG_CHANGELOG()
  1744. # ----------------
  1745. # Minimum version: 1.2.0
  1746. #
  1747. # Defines the variable CHANGELOG_CMD as the command to generate
  1748. # ChangeLog from git.
  1749. #
  1750. #
  1751. AC_DEFUN([XORG_CHANGELOG], [
  1752. CHANGELOG_CMD="(GIT_DIR=\$(top_srcdir)/.git git log > \$(top_srcdir)/.changelog.tmp && \
  1753. mv \$(top_srcdir)/.changelog.tmp \$(top_srcdir)/ChangeLog) \
  1754. || (rm -f \$(top_srcdir)/.changelog.tmp; touch \$(top_srcdir)/ChangeLog; \
  1755. echo 'git directory not found: installing possibly empty changelog.' >&2)"
  1756. AC_SUBST([CHANGELOG_CMD])
  1757. ]) # XORG_CHANGELOG