Debian Codegraph @

util-macros/xorg-macros.m4.in

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