Upload Tizen:Main source
[framework/uifw/xorg/util/xorg-x11-util-macros.git] / xorg-macros.m4.in
1 dnl @configure_input@
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
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_PROGS(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([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([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                 RAWCPPFLAGS="${RAWCPPFLAGS} -traditional"
91                 AC_MSG_RESULT([yes])
92         else
93                 AC_MSG_ERROR([${RAWCPP} does not preserve whitespace with or without -traditional.  I don't know what to do.])
94         fi
95 fi
96 rm -f conftest.$ac_ext
97 AC_SUBST(RAWCPPFLAGS)
98 ]) # XORG_PROG_RAWCPP
99
100 # XORG_MANPAGE_SECTIONS()
101 # -----------------------
102 # Minimum version: 1.0.0
103 #
104 # Determine which sections man pages go in for the different man page types
105 # on this OS - replaces *ManSuffix settings in old Imake *.cf per-os files.
106 # Not sure if there's any better way than just hardcoding by OS name.
107 # Override default settings by setting environment variables
108 # Added MAN_SUBSTS in version 1.8
109 # Added AC_PROG_SED in version 1.8
110
111 AC_DEFUN([XORG_MANPAGE_SECTIONS],[
112 AC_REQUIRE([AC_CANONICAL_HOST])
113 AC_REQUIRE([AC_PROG_SED])
114
115 if test x$APP_MAN_SUFFIX = x    ; then
116     APP_MAN_SUFFIX=1
117 fi
118 if test x$APP_MAN_DIR = x    ; then
119     APP_MAN_DIR='$(mandir)/man$(APP_MAN_SUFFIX)'
120 fi
121
122 if test x$LIB_MAN_SUFFIX = x    ; then
123     LIB_MAN_SUFFIX=3
124 fi
125 if test x$LIB_MAN_DIR = x    ; then
126     LIB_MAN_DIR='$(mandir)/man$(LIB_MAN_SUFFIX)'
127 fi
128
129 if test x$FILE_MAN_SUFFIX = x    ; then
130     case $host_os in
131         solaris*)       FILE_MAN_SUFFIX=4  ;;
132         *)              FILE_MAN_SUFFIX=5  ;;
133     esac
134 fi
135 if test x$FILE_MAN_DIR = x    ; then
136     FILE_MAN_DIR='$(mandir)/man$(FILE_MAN_SUFFIX)'
137 fi
138
139 if test x$MISC_MAN_SUFFIX = x    ; then
140     case $host_os in
141         solaris*)       MISC_MAN_SUFFIX=5  ;;
142         *)              MISC_MAN_SUFFIX=7  ;;
143     esac
144 fi
145 if test x$MISC_MAN_DIR = x    ; then
146     MISC_MAN_DIR='$(mandir)/man$(MISC_MAN_SUFFIX)'
147 fi
148
149 if test x$DRIVER_MAN_SUFFIX = x    ; then
150     case $host_os in
151         solaris*)       DRIVER_MAN_SUFFIX=7  ;;
152         *)              DRIVER_MAN_SUFFIX=4  ;;
153     esac
154 fi
155 if test x$DRIVER_MAN_DIR = x    ; then
156     DRIVER_MAN_DIR='$(mandir)/man$(DRIVER_MAN_SUFFIX)'
157 fi
158
159 if test x$ADMIN_MAN_SUFFIX = x    ; then
160     case $host_os in
161         solaris*)       ADMIN_MAN_SUFFIX=1m ;;
162         *)              ADMIN_MAN_SUFFIX=8  ;;
163     esac
164 fi
165 if test x$ADMIN_MAN_DIR = x    ; then
166     ADMIN_MAN_DIR='$(mandir)/man$(ADMIN_MAN_SUFFIX)'
167 fi
168
169
170 AC_SUBST([APP_MAN_SUFFIX])
171 AC_SUBST([LIB_MAN_SUFFIX])
172 AC_SUBST([FILE_MAN_SUFFIX])
173 AC_SUBST([MISC_MAN_SUFFIX])
174 AC_SUBST([DRIVER_MAN_SUFFIX])
175 AC_SUBST([ADMIN_MAN_SUFFIX])
176 AC_SUBST([APP_MAN_DIR])
177 AC_SUBST([LIB_MAN_DIR])
178 AC_SUBST([FILE_MAN_DIR])
179 AC_SUBST([MISC_MAN_DIR])
180 AC_SUBST([DRIVER_MAN_DIR])
181 AC_SUBST([ADMIN_MAN_DIR])
182
183 XORG_MAN_PAGE="X Version 11"
184 AC_SUBST([XORG_MAN_PAGE])
185 MAN_SUBSTS="\
186         -e 's|__vendorversion__|\"\$(PACKAGE_STRING)\" \"\$(XORG_MAN_PAGE)\"|' \
187         -e 's|__xorgversion__|\"\$(PACKAGE_STRING)\" \"\$(XORG_MAN_PAGE)\"|' \
188         -e 's|__xservername__|Xorg|g' \
189         -e 's|__xconfigfile__|xorg.conf|g' \
190         -e 's|__projectroot__|\$(prefix)|g' \
191         -e 's|__apploaddir__|\$(appdefaultdir)|g' \
192         -e 's|__appmansuffix__|\$(APP_MAN_SUFFIX)|g' \
193         -e 's|__drivermansuffix__|\$(DRIVER_MAN_SUFFIX)|g' \
194         -e 's|__adminmansuffix__|\$(ADMIN_MAN_SUFFIX)|g' \
195         -e 's|__libmansuffix__|\$(LIB_MAN_SUFFIX)|g' \
196         -e 's|__miscmansuffix__|\$(MISC_MAN_SUFFIX)|g' \
197         -e 's|__filemansuffix__|\$(FILE_MAN_SUFFIX)|g'"
198 AC_SUBST([MAN_SUBSTS])
199
200 ]) # XORG_MANPAGE_SECTIONS
201
202 # XORG_CHECK_SGML_DOCTOOLS([MIN-VERSION])
203 # ------------------------
204 # Minimum version: 1.7.0
205 #
206 # Defines the variable XORG_SGML_PATH containing the location of X11/defs.ent
207 # provided by xorg-sgml-doctools, if installed.
208 AC_DEFUN([XORG_CHECK_SGML_DOCTOOLS],[
209 AC_MSG_CHECKING([for X.Org SGML entities m4_ifval([$1],[>= $1])])
210 XORG_SGML_PATH=
211 PKG_CHECK_EXISTS([xorg-sgml-doctools m4_ifval([$1],[>= $1])],
212     [XORG_SGML_PATH=`$PKG_CONFIG --variable=sgmlrootdir xorg-sgml-doctools`],
213     [m4_ifval([$1],[:],
214         [if test x"$cross_compiling" != x"yes" ; then
215             AC_CHECK_FILE([$prefix/share/sgml/X11/defs.ent],
216                           [XORG_SGML_PATH=$prefix/share/sgml])
217          fi])
218     ])
219
220 # Define variables STYLESHEET_SRCDIR and XSL_STYLESHEET containing
221 # the path and the name of the doc stylesheet
222 if test "x$XORG_SGML_PATH" != "x" ; then
223    AC_MSG_RESULT([$XORG_SGML_PATH])
224    STYLESHEET_SRCDIR=$XORG_SGML_PATH/X11
225    XSL_STYLESHEET=$STYLESHEET_SRCDIR/xorg.xsl
226 else
227    AC_MSG_RESULT([no])
228 fi
229
230 AC_SUBST(XORG_SGML_PATH)
231 AC_SUBST(STYLESHEET_SRCDIR)
232 AC_SUBST(XSL_STYLESHEET)
233 AM_CONDITIONAL([HAVE_STYLESHEETS], [test "x$XSL_STYLESHEET" != "x"])
234 ]) # XORG_CHECK_SGML_DOCTOOLS
235
236 # XORG_CHECK_LINUXDOC
237 # -------------------
238 # Minimum version: 1.0.0
239 #
240 # Defines the variable MAKE_TEXT if the necessary tools and
241 # files are found. $(MAKE_TEXT) blah.sgml will then produce blah.txt.
242 # Whether or not the necessary tools and files are found can be checked
243 # with the AM_CONDITIONAL "BUILD_LINUXDOC"
244 AC_DEFUN([XORG_CHECK_LINUXDOC],[
245 AC_REQUIRE([XORG_CHECK_SGML_DOCTOOLS])
246 AC_REQUIRE([XORG_WITH_PS2PDF])
247
248 AC_PATH_PROG(LINUXDOC, linuxdoc)
249
250 AC_MSG_CHECKING([whether to build documentation])
251
252 if test x$XORG_SGML_PATH != x && test x$LINUXDOC != x ; then
253    BUILDDOC=yes
254 else
255    BUILDDOC=no
256 fi
257
258 AM_CONDITIONAL(BUILD_LINUXDOC, [test x$BUILDDOC = xyes])
259
260 AC_MSG_RESULT([$BUILDDOC])
261
262 AC_MSG_CHECKING([whether to build pdf documentation])
263
264 if test x$have_ps2pdf != xno && test x$BUILD_PDFDOC != xno; then
265    BUILDPDFDOC=yes
266 else
267    BUILDPDFDOC=no
268 fi
269
270 AM_CONDITIONAL(BUILD_PDFDOC, [test x$BUILDPDFDOC = xyes])
271
272 AC_MSG_RESULT([$BUILDPDFDOC])
273
274 MAKE_TEXT="SGML_SEARCH_PATH=$XORG_SGML_PATH GROFF_NO_SGR=y $LINUXDOC -B txt -f"
275 MAKE_PS="SGML_SEARCH_PATH=$XORG_SGML_PATH $LINUXDOC -B latex --papersize=letter --output=ps"
276 MAKE_PDF="$PS2PDF"
277 MAKE_HTML="SGML_SEARCH_PATH=$XORG_SGML_PATH $LINUXDOC  -B html --split=0"
278
279 AC_SUBST(MAKE_TEXT)
280 AC_SUBST(MAKE_PS)
281 AC_SUBST(MAKE_PDF)
282 AC_SUBST(MAKE_HTML)
283 ]) # XORG_CHECK_LINUXDOC
284
285 # XORG_CHECK_DOCBOOK
286 # -------------------
287 # Minimum version: 1.0.0
288 #
289 # Checks for the ability to build output formats from SGML DocBook source.
290 # For XXX in {TXT, PDF, PS, HTML}, the AM_CONDITIONAL "BUILD_XXXDOC"
291 # indicates whether the necessary tools and files are found and, if set,
292 # $(MAKE_XXX) blah.sgml will produce blah.xxx.
293 AC_DEFUN([XORG_CHECK_DOCBOOK],[
294 AC_REQUIRE([XORG_CHECK_SGML_DOCTOOLS])
295
296 BUILDTXTDOC=no
297 BUILDPDFDOC=no
298 BUILDPSDOC=no
299 BUILDHTMLDOC=no
300
301 AC_PATH_PROG(DOCBOOKPS, docbook2ps)
302 AC_PATH_PROG(DOCBOOKPDF, docbook2pdf)
303 AC_PATH_PROG(DOCBOOKHTML, docbook2html)
304 AC_PATH_PROG(DOCBOOKTXT, docbook2txt)
305
306 AC_MSG_CHECKING([whether to build text documentation])
307 if test x$XORG_SGML_PATH != x && test x$DOCBOOKTXT != x &&
308    test x$BUILD_TXTDOC != xno; then
309         BUILDTXTDOC=yes
310 fi
311 AM_CONDITIONAL(BUILD_TXTDOC, [test x$BUILDTXTDOC = xyes])
312 AC_MSG_RESULT([$BUILDTXTDOC])
313
314 AC_MSG_CHECKING([whether to build PDF documentation])
315 if test x$XORG_SGML_PATH != x && test x$DOCBOOKPDF != x &&
316    test x$BUILD_PDFDOC != xno; then
317         BUILDPDFDOC=yes
318 fi
319 AM_CONDITIONAL(BUILD_PDFDOC, [test x$BUILDPDFDOC = xyes])
320 AC_MSG_RESULT([$BUILDPDFDOC])
321
322 AC_MSG_CHECKING([whether to build PostScript documentation])
323 if test x$XORG_SGML_PATH != x && test x$DOCBOOKPS != x &&
324    test x$BUILD_PSDOC != xno; then
325         BUILDPSDOC=yes
326 fi
327 AM_CONDITIONAL(BUILD_PSDOC, [test x$BUILDPSDOC = xyes])
328 AC_MSG_RESULT([$BUILDPSDOC])
329
330 AC_MSG_CHECKING([whether to build HTML documentation])
331 if test x$XORG_SGML_PATH != x && test x$DOCBOOKHTML != x &&
332    test x$BUILD_HTMLDOC != xno; then
333         BUILDHTMLDOC=yes
334 fi
335 AM_CONDITIONAL(BUILD_HTMLDOC, [test x$BUILDHTMLDOC = xyes])
336 AC_MSG_RESULT([$BUILDHTMLDOC])
337
338 MAKE_TEXT="SGML_SEARCH_PATH=$XORG_SGML_PATH $DOCBOOKTXT"
339 MAKE_PS="SGML_SEARCH_PATH=$XORG_SGML_PATH $DOCBOOKPS"
340 MAKE_PDF="SGML_SEARCH_PATH=$XORG_SGML_PATH $DOCBOOKPDF"
341 MAKE_HTML="SGML_SEARCH_PATH=$XORG_SGML_PATH $DOCBOOKHTML"
342
343 AC_SUBST(MAKE_TEXT)
344 AC_SUBST(MAKE_PS)
345 AC_SUBST(MAKE_PDF)
346 AC_SUBST(MAKE_HTML)
347 ]) # XORG_CHECK_DOCBOOK
348
349 # XORG_WITH_XMLTO([MIN-VERSION], [DEFAULT])
350 # ----------------
351 # Minimum version: 1.5.0
352 # Minimum version for optional DEFAULT argument: 1.11.0
353 #
354 # Documentation tools are not always available on all platforms and sometimes
355 # not at the appropriate level. This macro enables a module to test for the
356 # presence of the tool and obtain it's path in separate variables. Coupled with
357 # the --with-xmlto option, it allows maximum flexibilty in making decisions
358 # as whether or not to use the xmlto package. When DEFAULT is not specified,
359 # --with-xmlto assumes 'auto'.
360 #
361 # Interface to module:
362 # HAVE_XMLTO:   used in makefiles to conditionally generate documentation
363 # XMLTO:        returns the path of the xmlto program found
364 #               returns the path set by the user in the environment
365 # --with-xmlto: 'yes' user instructs the module to use xmlto
366 #               'no' user instructs the module not to use xmlto
367 #
368 # Added in version 1.10.0
369 # HAVE_XMLTO_TEXT: used in makefiles to conditionally generate text documentation
370 #                  xmlto for text output requires either lynx, links, or w3m browsers
371 #
372 # If the user sets the value of XMLTO, AC_PATH_PROG skips testing the path.
373 #
374 AC_DEFUN([XORG_WITH_XMLTO],[
375 AC_ARG_VAR([XMLTO], [Path to xmlto command])
376 m4_define([_defopt], m4_default([$2], [auto]))
377 AC_ARG_WITH(xmlto,
378         AS_HELP_STRING([--with-xmlto],
379            [Use xmlto to regenerate documentation (default: ]_defopt[)]),
380            [use_xmlto=$withval], [use_xmlto=]_defopt)
381 m4_undefine([_defopt])
382
383 if test "x$use_xmlto" = x"auto"; then
384    AC_PATH_PROG([XMLTO], [xmlto])
385    if test "x$XMLTO" = "x"; then
386         AC_MSG_WARN([xmlto not found - documentation targets will be skipped])
387         have_xmlto=no
388    else
389         have_xmlto=yes
390    fi
391 elif test "x$use_xmlto" = x"yes" ; then
392    AC_PATH_PROG([XMLTO], [xmlto])
393    if test "x$XMLTO" = "x"; then
394         AC_MSG_ERROR([--with-xmlto=yes specified but xmlto not found in PATH])
395    fi
396    have_xmlto=yes
397 elif test "x$use_xmlto" = x"no" ; then
398    if test "x$XMLTO" != "x"; then
399       AC_MSG_WARN([ignoring XMLTO environment variable since --with-xmlto=no was specified])
400    fi
401    have_xmlto=no
402 else
403    AC_MSG_ERROR([--with-xmlto expects 'yes' or 'no'])
404 fi
405
406 # Test for a minimum version of xmlto, if provided.
407 m4_ifval([$1],
408 [if test "$have_xmlto" = yes; then
409     # scrape the xmlto version
410     AC_MSG_CHECKING([the xmlto version])
411     xmlto_version=`$XMLTO --version 2>/dev/null | cut -d' ' -f3`
412     AC_MSG_RESULT([$xmlto_version])
413     AS_VERSION_COMPARE([$xmlto_version], [$1],
414         [if test "x$use_xmlto" = xauto; then
415             AC_MSG_WARN([xmlto version $xmlto_version found, but $1 needed])
416             have_xmlto=no
417         else
418             AC_MSG_ERROR([xmlto version $xmlto_version found, but $1 needed])
419         fi])
420 fi])
421
422 # Test for the ability of xmlto to generate a text target
423 have_xmlto_text=no
424 cat > conftest.xml << "EOF"
425 EOF
426 AS_IF([test "$have_xmlto" = yes],
427       [AS_IF([$XMLTO --skip-validation txt conftest.xml >/dev/null 2>&1],
428              [have_xmlto_text=yes],
429              [AC_MSG_WARN([xmlto cannot generate text format, this format skipped])])])
430 rm -f conftest.xml
431 AM_CONDITIONAL([HAVE_XMLTO_TEXT], [test $have_xmlto_text = yes])
432 AM_CONDITIONAL([HAVE_XMLTO], [test "$have_xmlto" = yes])
433 ]) # XORG_WITH_XMLTO
434
435 # XORG_WITH_ASCIIDOC([MIN-VERSION], [DEFAULT])
436 # ----------------
437 # Minimum version: 1.5.0
438 # Minimum version for optional DEFAULT argument: 1.11.0
439 #
440 # Documentation tools are not always available on all platforms and sometimes
441 # not at the appropriate level. This macro enables a module to test for the
442 # presence of the tool and obtain it's path in separate variables. Coupled with
443 # the --with-asciidoc option, it allows maximum flexibilty in making decisions
444 # as whether or not to use the asciidoc package. When DEFAULT is not specified,
445 # --with-asciidoc assumes 'auto'.
446 #
447 # Interface to module:
448 # HAVE_ASCIIDOC: used in makefiles to conditionally generate documentation
449 # ASCIIDOC:      returns the path of the asciidoc program found
450 #                returns the path set by the user in the environment
451 # --with-asciidoc: 'yes' user instructs the module to use asciidoc
452 #                 'no' user instructs the module not to use asciidoc
453 #
454 # If the user sets the value of ASCIIDOC, AC_PATH_PROG skips testing the path.
455 #
456 AC_DEFUN([XORG_WITH_ASCIIDOC],[
457 AC_ARG_VAR([ASCIIDOC], [Path to asciidoc command])
458 m4_define([_defopt], m4_default([$2], [auto]))
459 AC_ARG_WITH(asciidoc,
460         AS_HELP_STRING([--with-asciidoc],
461            [Use asciidoc to regenerate documentation (default: ]_defopt[)]),
462            [use_asciidoc=$withval], [use_asciidoc=]_defopt)
463 m4_undefine([_defopt])
464
465 if test "x$use_asciidoc" = x"auto"; then
466    AC_PATH_PROG([ASCIIDOC], [asciidoc])
467    if test "x$ASCIIDOC" = "x"; then
468         AC_MSG_WARN([asciidoc not found - documentation targets will be skipped])
469         have_asciidoc=no
470    else
471         have_asciidoc=yes
472    fi
473 elif test "x$use_asciidoc" = x"yes" ; then
474    AC_PATH_PROG([ASCIIDOC], [asciidoc])
475    if test "x$ASCIIDOC" = "x"; then
476         AC_MSG_ERROR([--with-asciidoc=yes specified but asciidoc not found in PATH])
477    fi
478    have_asciidoc=yes
479 elif test "x$use_asciidoc" = x"no" ; then
480    if test "x$ASCIIDOC" != "x"; then
481       AC_MSG_WARN([ignoring ASCIIDOC environment variable since --with-asciidoc=no was specified])
482    fi
483    have_asciidoc=no
484 else
485    AC_MSG_ERROR([--with-asciidoc expects 'yes' or 'no'])
486 fi
487 m4_ifval([$1],
488 [if test "$have_asciidoc" = yes; then
489     # scrape the asciidoc version
490     AC_MSG_CHECKING([the asciidoc version])
491     asciidoc_version=`$ASCIIDOC --version 2>/dev/null | cut -d' ' -f2`
492     AC_MSG_RESULT([$asciidoc_version])
493     AS_VERSION_COMPARE([$asciidoc_version], [$1],
494         [if test "x$use_asciidoc" = xauto; then
495             AC_MSG_WARN([asciidoc version $asciidoc_version found, but $1 needed])
496             have_asciidoc=no
497         else
498             AC_MSG_ERROR([asciidoc version $asciidoc_version found, but $1 needed])
499         fi])
500 fi])
501 AM_CONDITIONAL([HAVE_ASCIIDOC], [test "$have_asciidoc" = yes])
502 ]) # XORG_WITH_ASCIIDOC
503
504 # XORG_WITH_DOXYGEN([MIN-VERSION], [DEFAULT])
505 # --------------------------------
506 # Minimum version: 1.5.0
507 # Minimum version for optional DEFAULT argument: 1.11.0
508 #
509 # Documentation tools are not always available on all platforms and sometimes
510 # not at the appropriate level. This macro enables a module to test for the
511 # presence of the tool and obtain it's path in separate variables. Coupled with
512 # the --with-doxygen option, it allows maximum flexibilty in making decisions
513 # as whether or not to use the doxygen package. When DEFAULT is not specified,
514 # --with-doxygen assumes 'auto'.
515 #
516 # Interface to module:
517 # HAVE_DOXYGEN: used in makefiles to conditionally generate documentation
518 # DOXYGEN:       returns the path of the doxygen program found
519 #                returns the path set by the user in the environment
520 # --with-doxygen: 'yes' user instructs the module to use doxygen
521 #                 'no' user instructs the module not to use doxygen
522 #
523 # If the user sets the value of DOXYGEN, AC_PATH_PROG skips testing the path.
524 #
525 AC_DEFUN([XORG_WITH_DOXYGEN],[
526 AC_ARG_VAR([DOXYGEN], [Path to doxygen command])
527 m4_define([_defopt], m4_default([$2], [auto]))
528 AC_ARG_WITH(doxygen,
529         AS_HELP_STRING([--with-doxygen],
530            [Use doxygen to regenerate documentation (default: ]_defopt[)]),
531            [use_doxygen=$withval], [use_doxygen=]_defopt)
532 m4_undefine([_defopt])
533
534 if test "x$use_doxygen" = x"auto"; then
535    AC_PATH_PROG([DOXYGEN], [doxygen])
536    if test "x$DOXYGEN" = "x"; then
537         AC_MSG_WARN([doxygen not found - documentation targets will be skipped])
538         have_doxygen=no
539    else
540         have_doxygen=yes
541    fi
542 elif test "x$use_doxygen" = x"yes" ; then
543    AC_PATH_PROG([DOXYGEN], [doxygen])
544    if test "x$DOXYGEN" = "x"; then
545         AC_MSG_ERROR([--with-doxygen=yes specified but doxygen not found in PATH])
546    fi
547    have_doxygen=yes
548 elif test "x$use_doxygen" = x"no" ; then
549    if test "x$DOXYGEN" != "x"; then
550       AC_MSG_WARN([ignoring DOXYGEN environment variable since --with-doxygen=no was specified])
551    fi
552    have_doxygen=no
553 else
554    AC_MSG_ERROR([--with-doxygen expects 'yes' or 'no'])
555 fi
556 m4_ifval([$1],
557 [if test "$have_doxygen" = yes; then
558     # scrape the doxygen version
559     AC_MSG_CHECKING([the doxygen version])
560     doxygen_version=`$DOXYGEN --version 2>/dev/null`
561     AC_MSG_RESULT([$doxygen_version])
562     AS_VERSION_COMPARE([$doxygen_version], [$1],
563         [if test "x$use_doxygen" = xauto; then
564             AC_MSG_WARN([doxygen version $doxygen_version found, but $1 needed])
565             have_doxygen=no
566         else
567             AC_MSG_ERROR([doxygen version $doxygen_version found, but $1 needed])
568         fi])
569 fi])
570 AM_CONDITIONAL([HAVE_DOXYGEN], [test "$have_doxygen" = yes])
571 ]) # XORG_WITH_DOXYGEN
572
573 # XORG_WITH_GROFF([DEFAULT])
574 # ----------------
575 # Minimum version: 1.6.0
576 # Minimum version for optional DEFAULT argument: 1.11.0
577 #
578 # Documentation tools are not always available on all platforms and sometimes
579 # not at the appropriate level. This macro enables a module to test for the
580 # presence of the tool and obtain it's path in separate variables. Coupled with
581 # the --with-groff option, it allows maximum flexibilty in making decisions
582 # as whether or not to use the groff package. When DEFAULT is not specified,
583 # --with-groff assumes 'auto'.
584 #
585 # Interface to module:
586 # HAVE_GROFF:    used in makefiles to conditionally generate documentation
587 # HAVE_GROFF_MM: the memorandum macros (-mm) package
588 # HAVE_GROFF_MS: the -ms macros package
589 # GROFF:         returns the path of the groff program found
590 #                returns the path set by the user in the environment
591 # --with-groff:  'yes' user instructs the module to use groff
592 #                'no' user instructs the module not to use groff
593 #
594 # Added in version 1.9.0:
595 # HAVE_GROFF_HTML: groff has dependencies to output HTML format:
596 #                  pnmcut pnmcrop pnmtopng pnmtops from the netpbm package.
597 #                  psselect from the psutils package.
598 #                  the ghostcript package. Refer to the grohtml man pages
599 #
600 # If the user sets the value of GROFF, AC_PATH_PROG skips testing the path.
601 #
602 # OS and distros often splits groff in a basic and full package, the former
603 # having the groff program and the later having devices, fonts and macros
604 # Checking for the groff executable is not enough.
605 #
606 # If macros are missing, we cannot assume that groff is useless, so we don't
607 # unset HAVE_GROFF or GROFF env variables.
608 # HAVE_GROFF_?? can never be true while HAVE_GROFF is false.
609 #
610 AC_DEFUN([XORG_WITH_GROFF],[
611 AC_ARG_VAR([GROFF], [Path to groff command])
612 m4_define([_defopt], m4_default([$1], [auto]))
613 AC_ARG_WITH(groff,
614         AS_HELP_STRING([--with-groff],
615            [Use groff to regenerate documentation (default: ]_defopt[)]),
616            [use_groff=$withval], [use_groff=]_defopt)
617 m4_undefine([_defopt])
618
619 if test "x$use_groff" = x"auto"; then
620    AC_PATH_PROG([GROFF], [groff])
621    if test "x$GROFF" = "x"; then
622         AC_MSG_WARN([groff not found - documentation targets will be skipped])
623         have_groff=no
624    else
625         have_groff=yes
626    fi
627 elif test "x$use_groff" = x"yes" ; then
628    AC_PATH_PROG([GROFF], [groff])
629    if test "x$GROFF" = "x"; then
630         AC_MSG_ERROR([--with-groff=yes specified but groff not found in PATH])
631    fi
632    have_groff=yes
633 elif test "x$use_groff" = x"no" ; then
634    if test "x$GROFF" != "x"; then
635       AC_MSG_WARN([ignoring GROFF environment variable since --with-groff=no was specified])
636    fi
637    have_groff=no
638 else
639    AC_MSG_ERROR([--with-groff expects 'yes' or 'no'])
640 fi
641
642 # We have groff, test for the presence of the macro packages
643 if test "x$have_groff" = x"yes"; then
644     AC_MSG_CHECKING([for ${GROFF} -ms macros])
645     if ${GROFF} -ms -I. /dev/null >/dev/null 2>&1 ; then
646         groff_ms_works=yes
647     else
648         groff_ms_works=no
649     fi
650     AC_MSG_RESULT([$groff_ms_works])
651     AC_MSG_CHECKING([for ${GROFF} -mm macros])
652     if ${GROFF} -mm -I. /dev/null >/dev/null 2>&1 ; then
653         groff_mm_works=yes
654     else
655         groff_mm_works=no
656     fi
657     AC_MSG_RESULT([$groff_mm_works])
658 fi
659
660 # We have groff, test for HTML dependencies, one command per package
661 if test "x$have_groff" = x"yes"; then
662    AC_PATH_PROGS(GS_PATH, [gs gswin32c])
663    AC_PATH_PROG(PNMTOPNG_PATH, [pnmtopng])
664    AC_PATH_PROG(PSSELECT_PATH, [psselect])
665    if test "x$GS_PATH" != "x" -a "x$PNMTOPNG_PATH" != "x" -a "x$PSSELECT_PATH" != "x"; then
666       have_groff_html=yes
667    else
668       have_groff_html=no
669       AC_MSG_WARN([grohtml dependencies not found - HTML Documentation skipped. Refer to grohtml man pages])
670    fi
671 fi
672
673 # Set Automake conditionals for Makefiles
674 AM_CONDITIONAL([HAVE_GROFF], [test "$have_groff" = yes])
675 AM_CONDITIONAL([HAVE_GROFF_MS], [test "$groff_ms_works" = yes])
676 AM_CONDITIONAL([HAVE_GROFF_MM], [test "$groff_mm_works" = yes])
677 AM_CONDITIONAL([HAVE_GROFF_HTML], [test "$have_groff_html" = yes])
678 ]) # XORG_WITH_GROFF
679
680 # XORG_WITH_FOP([DEFAULT])
681 # ----------------
682 # Minimum version: 1.6.0
683 # Minimum version for optional DEFAULT argument: 1.11.0
684 #
685 # Documentation tools are not always available on all platforms and sometimes
686 # not at the appropriate level. This macro enables a module to test for the
687 # presence of the tool and obtain it's path in separate variables. Coupled with
688 # the --with-fop option, it allows maximum flexibilty in making decisions
689 # as whether or not to use the fop package. When DEFAULT is not specified,
690 # --with-fop assumes 'auto'.
691 #
692 # Interface to module:
693 # HAVE_FOP:     used in makefiles to conditionally generate documentation
694 # FOP:          returns the path of the fop program found
695 #               returns the path set by the user in the environment
696 # --with-fop:   'yes' user instructs the module to use fop
697 #               'no' user instructs the module not to use fop
698 #
699 # If the user sets the value of FOP, AC_PATH_PROG skips testing the path.
700 #
701 AC_DEFUN([XORG_WITH_FOP],[
702 AC_ARG_VAR([FOP], [Path to fop command])
703 m4_define([_defopt], m4_default([$1], [auto]))
704 AC_ARG_WITH(fop,
705         AS_HELP_STRING([--with-fop],
706            [Use fop to regenerate documentation (default: ]_defopt[)]),
707            [use_fop=$withval], [use_fop=]_defopt)
708 m4_undefine([_defopt])
709
710 if test "x$use_fop" = x"auto"; then
711    AC_PATH_PROG([FOP], [fop])
712    if test "x$FOP" = "x"; then
713         AC_MSG_WARN([fop not found - documentation targets will be skipped])
714         have_fop=no
715    else
716         have_fop=yes
717    fi
718 elif test "x$use_fop" = x"yes" ; then
719    AC_PATH_PROG([FOP], [fop])
720    if test "x$FOP" = "x"; then
721         AC_MSG_ERROR([--with-fop=yes specified but fop not found in PATH])
722    fi
723    have_fop=yes
724 elif test "x$use_fop" = x"no" ; then
725    if test "x$FOP" != "x"; then
726       AC_MSG_WARN([ignoring FOP environment variable since --with-fop=no was specified])
727    fi
728    have_fop=no
729 else
730    AC_MSG_ERROR([--with-fop expects 'yes' or 'no'])
731 fi
732 AM_CONDITIONAL([HAVE_FOP], [test "$have_fop" = yes])
733 ]) # XORG_WITH_FOP
734
735 # XORG_WITH_PS2PDF([DEFAULT])
736 # ----------------
737 # Minimum version: 1.6.0
738 # Minimum version for optional DEFAULT argument: 1.11.0
739 #
740 # Documentation tools are not always available on all platforms and sometimes
741 # not at the appropriate level. This macro enables a module to test for the
742 # presence of the tool and obtain it's path in separate variables. Coupled with
743 # the --with-ps2pdf option, it allows maximum flexibilty in making decisions
744 # as whether or not to use the ps2pdf package. When DEFAULT is not specified,
745 # --with-ps2pdf assumes 'auto'.
746 #
747 # Interface to module:
748 # HAVE_PS2PDF:  used in makefiles to conditionally generate documentation
749 # PS2PDF:       returns the path of the ps2pdf program found
750 #               returns the path set by the user in the environment
751 # --with-ps2pdf: 'yes' user instructs the module to use ps2pdf
752 #                'no' user instructs the module not to use ps2pdf
753 #
754 # If the user sets the value of PS2PDF, AC_PATH_PROG skips testing the path.
755 #
756 AC_DEFUN([XORG_WITH_PS2PDF],[
757 AC_ARG_VAR([PS2PDF], [Path to ps2pdf command])
758 m4_define([_defopt], m4_default([$1], [auto]))
759 AC_ARG_WITH(ps2pdf,
760         AS_HELP_STRING([--with-ps2pdf],
761            [Use ps2pdf to regenerate documentation (default: ]_defopt[)]),
762            [use_ps2pdf=$withval], [use_ps2pdf=]_defopt)
763 m4_undefine([_defopt])
764
765 if test "x$use_ps2pdf" = x"auto"; then
766    AC_PATH_PROG([PS2PDF], [ps2pdf])
767    if test "x$PS2PDF" = "x"; then
768         AC_MSG_WARN([ps2pdf not found - documentation targets will be skipped])
769         have_ps2pdf=no
770    else
771         have_ps2pdf=yes
772    fi
773 elif test "x$use_ps2pdf" = x"yes" ; then
774    AC_PATH_PROG([PS2PDF], [ps2pdf])
775    if test "x$PS2PDF" = "x"; then
776         AC_MSG_ERROR([--with-ps2pdf=yes specified but ps2pdf not found in PATH])
777    fi
778    have_ps2pdf=yes
779 elif test "x$use_ps2pdf" = x"no" ; then
780    if test "x$PS2PDF" != "x"; then
781       AC_MSG_WARN([ignoring PS2PDF environment variable since --with-ps2pdf=no was specified])
782    fi
783    have_ps2pdf=no
784 else
785    AC_MSG_ERROR([--with-ps2pdf expects 'yes' or 'no'])
786 fi
787 AM_CONDITIONAL([HAVE_PS2PDF], [test "$have_ps2pdf" = yes])
788 ]) # XORG_WITH_PS2PDF
789
790 # XORG_ENABLE_DOCS (enable_docs=yes)
791 # ----------------
792 # Minimum version: 1.6.0
793 #
794 # Documentation tools are not always available on all platforms and sometimes
795 # not at the appropriate level. This macro enables a builder to skip all
796 # documentation targets except traditional man pages.
797 # Combined with the specific tool checking macros XORG_WITH_*, it provides
798 # maximum flexibilty in controlling documentation building.
799 # Refer to:
800 # XORG_WITH_XMLTO         --with-xmlto
801 # XORG_WITH_ASCIIDOC      --with-asciidoc
802 # XORG_WITH_DOXYGEN       --with-doxygen
803 # XORG_WITH_FOP           --with-fop
804 # XORG_WITH_GROFF         --with-groff
805 # XORG_WITH_PS2PDF        --with-ps2pdf
806 #
807 # Interface to module:
808 # ENABLE_DOCS:    used in makefiles to conditionally generate documentation
809 # --enable-docs: 'yes' user instructs the module to generate docs
810 #                'no' user instructs the module not to generate docs
811 # parm1:        specify the default value, yes or no.
812 #
813 AC_DEFUN([XORG_ENABLE_DOCS],[
814 m4_define([default], m4_default([$1], [yes]))
815 AC_ARG_ENABLE(docs,
816         AS_HELP_STRING([--enable-docs],
817            [Enable building the documentation (default: ]default[)]),
818            [build_docs=$enableval], [build_docs=]default)
819 m4_undefine([default])
820 AM_CONDITIONAL(ENABLE_DOCS, [test x$build_docs = xyes])
821 AC_MSG_CHECKING([whether to build documentation])
822 AC_MSG_RESULT([$build_docs])
823 ]) # XORG_ENABLE_DOCS
824
825 # XORG_ENABLE_DEVEL_DOCS (enable_devel_docs=yes)
826 # ----------------
827 # Minimum version: 1.6.0
828 #
829 # This macro enables a builder to skip all developer documentation.
830 # Combined with the specific tool checking macros XORG_WITH_*, it provides
831 # maximum flexibilty in controlling documentation building.
832 # Refer to:
833 # XORG_WITH_XMLTO         --with-xmlto
834 # XORG_WITH_ASCIIDOC      --with-asciidoc
835 # XORG_WITH_DOXYGEN       --with-doxygen
836 # XORG_WITH_FOP           --with-fop
837 # XORG_WITH_GROFF         --with-groff
838 # XORG_WITH_PS2PDF        --with-ps2pdf
839 #
840 # Interface to module:
841 # ENABLE_DEVEL_DOCS:    used in makefiles to conditionally generate developer docs
842 # --enable-devel-docs:  'yes' user instructs the module to generate developer docs
843 #                       'no' user instructs the module not to generate developer docs
844 # parm1:                specify the default value, yes or no.
845 #
846 AC_DEFUN([XORG_ENABLE_DEVEL_DOCS],[
847 m4_define([devel_default], m4_default([$1], [yes]))
848 AC_ARG_ENABLE(devel-docs,
849         AS_HELP_STRING([--enable-devel-docs],
850            [Enable building the developer documentation (default: ]devel_default[)]),
851            [build_devel_docs=$enableval], [build_devel_docs=]devel_default)
852 m4_undefine([devel_default])
853 AM_CONDITIONAL(ENABLE_DEVEL_DOCS, [test x$build_devel_docs = xyes])
854 AC_MSG_CHECKING([whether to build developer documentation])
855 AC_MSG_RESULT([$build_devel_docs])
856 ]) # XORG_ENABLE_DEVEL_DOCS
857
858 # XORG_ENABLE_SPECS (enable_specs=yes)
859 # ----------------
860 # Minimum version: 1.6.0
861 #
862 # This macro enables a builder to skip all functional specification targets.
863 # Combined with the specific tool checking macros XORG_WITH_*, it provides
864 # maximum flexibilty in controlling documentation building.
865 # Refer to:
866 # XORG_WITH_XMLTO         --with-xmlto
867 # XORG_WITH_ASCIIDOC      --with-asciidoc
868 # XORG_WITH_DOXYGEN       --with-doxygen
869 # XORG_WITH_FOP           --with-fop
870 # XORG_WITH_GROFF         --with-groff
871 # XORG_WITH_PS2PDF        --with-ps2pdf
872 #
873 # Interface to module:
874 # ENABLE_SPECS:         used in makefiles to conditionally generate specs
875 # --enable-specs:       'yes' user instructs the module to generate specs
876 #                       'no' user instructs the module not to generate specs
877 # parm1:                specify the default value, yes or no.
878 #
879 AC_DEFUN([XORG_ENABLE_SPECS],[
880 m4_define([spec_default], m4_default([$1], [yes]))
881 AC_ARG_ENABLE(specs,
882         AS_HELP_STRING([--enable-specs],
883            [Enable building the specs (default: ]spec_default[)]),
884            [build_specs=$enableval], [build_specs=]spec_default)
885 m4_undefine([spec_default])
886 AM_CONDITIONAL(ENABLE_SPECS, [test x$build_specs = xyes])
887 AC_MSG_CHECKING([whether to build functional specifications])
888 AC_MSG_RESULT([$build_specs])
889 ]) # XORG_ENABLE_SPECS
890
891 # XORG_CHECK_MALLOC_ZERO
892 # ----------------------
893 # Minimum version: 1.0.0
894 #
895 # Defines {MALLOC,XMALLOC,XTMALLOC}_ZERO_CFLAGS appropriately if
896 # malloc(0) returns NULL.  Packages should add one of these cflags to
897 # their AM_CFLAGS (or other appropriate *_CFLAGS) to use them.
898 AC_DEFUN([XORG_CHECK_MALLOC_ZERO],[
899 AC_ARG_ENABLE(malloc0returnsnull,
900         AS_HELP_STRING([--enable-malloc0returnsnull],
901                        [malloc(0) returns NULL (default: auto)]),
902         [MALLOC_ZERO_RETURNS_NULL=$enableval],
903         [MALLOC_ZERO_RETURNS_NULL=auto])
904
905 AC_MSG_CHECKING([whether malloc(0) returns NULL])
906 if test "x$MALLOC_ZERO_RETURNS_NULL" = xauto; then
907         AC_RUN_IFELSE([
908 char *malloc();
909 char *realloc();
910 char *calloc();
911 main() {
912     char *m0, *r0, *c0, *p;
913     m0 = malloc(0);
914     p = malloc(10);
915     r0 = realloc(p,0);
916     c0 = calloc(0);
917     exit(m0 == 0 || r0 == 0 || c0 == 0 ? 0 : 1);
918 }],
919                 [MALLOC_ZERO_RETURNS_NULL=yes],
920                 [MALLOC_ZERO_RETURNS_NULL=no],
921                 [MALLOC_ZERO_RETURNS_NULL=yes])
922 fi
923 AC_MSG_RESULT([$MALLOC_ZERO_RETURNS_NULL])
924
925 if test "x$MALLOC_ZERO_RETURNS_NULL" = xyes; then
926         MALLOC_ZERO_CFLAGS="-DMALLOC_0_RETURNS_NULL"
927         XMALLOC_ZERO_CFLAGS=$MALLOC_ZERO_CFLAGS
928         XTMALLOC_ZERO_CFLAGS="$MALLOC_ZERO_CFLAGS -DXTMALLOC_BC"
929 else
930         MALLOC_ZERO_CFLAGS=""
931         XMALLOC_ZERO_CFLAGS=""
932         XTMALLOC_ZERO_CFLAGS=""
933 fi
934
935 AC_SUBST([MALLOC_ZERO_CFLAGS])
936 AC_SUBST([XMALLOC_ZERO_CFLAGS])
937 AC_SUBST([XTMALLOC_ZERO_CFLAGS])
938 ]) # XORG_CHECK_MALLOC_ZERO
939
940 # XORG_WITH_LINT()
941 # ----------------
942 # Minimum version: 1.1.0
943 #
944 # This macro enables the use of a tool that flags some suspicious and
945 # non-portable constructs (likely to be bugs) in C language source code.
946 # It will attempt to locate the tool and use appropriate options.
947 # There are various lint type tools on different platforms.
948 #
949 # Interface to module:
950 # LINT:         returns the path to the tool found on the platform
951 #               or the value set to LINT on the configure cmd line
952 #               also an Automake conditional
953 # LINT_FLAGS:   an Automake variable with appropriate flags
954 #
955 # --with-lint:  'yes' user instructs the module to use lint
956 #               'no' user instructs the module not to use lint (default)
957 #
958 # If the user sets the value of LINT, AC_PATH_PROG skips testing the path.
959 # If the user sets the value of LINT_FLAGS, they are used verbatim.
960 #
961 AC_DEFUN([XORG_WITH_LINT],[
962
963 AC_ARG_VAR([LINT], [Path to a lint-style command])
964 AC_ARG_VAR([LINT_FLAGS], [Flags for the lint-style command])
965 AC_ARG_WITH(lint, [AS_HELP_STRING([--with-lint],
966                 [Use a lint-style source code checker (default: disabled)])],
967                 [use_lint=$withval], [use_lint=no])
968
969 # Obtain platform specific info like program name and options
970 # The lint program on FreeBSD and NetBSD is different from the one on Solaris
971 case $host_os in
972   *linux* | *openbsd* | kfreebsd*-gnu | darwin* | cygwin*)
973         lint_name=splint
974         lint_options="-badflag"
975         ;;
976   *freebsd* | *netbsd*)
977         lint_name=lint
978         lint_options="-u -b"
979         ;;
980   *solaris*)
981         lint_name=lint
982         lint_options="-u -b -h -erroff=E_INDISTING_FROM_TRUNC2"
983         ;;
984 esac
985
986 # Test for the presence of the program (either guessed by the code or spelled out by the user)
987 if test "x$use_lint" = x"yes" ; then
988    AC_PATH_PROG([LINT], [$lint_name])
989    if test "x$LINT" = "x"; then
990         AC_MSG_ERROR([--with-lint=yes specified but lint-style tool not found in PATH])
991    fi
992 elif test "x$use_lint" = x"no" ; then
993    if test "x$LINT" != "x"; then
994       AC_MSG_WARN([ignoring LINT environment variable since --with-lint=no was specified])
995    fi
996 else
997    AC_MSG_ERROR([--with-lint expects 'yes' or 'no'. Use LINT variable to specify path.])
998 fi
999
1000 # User supplied flags override default flags
1001 if test "x$LINT_FLAGS" != "x"; then
1002    lint_options=$LINT_FLAGS
1003 fi
1004
1005 AC_SUBST([LINT_FLAGS],[$lint_options])
1006 AM_CONDITIONAL(LINT, [test "x$LINT" != x])
1007
1008 ]) # XORG_WITH_LINT
1009
1010 # XORG_LINT_LIBRARY(LIBNAME)
1011 # --------------------------
1012 # Minimum version: 1.1.0
1013 #
1014 # Sets up flags for building lint libraries for checking programs that call
1015 # functions in the library.
1016 #
1017 # Interface to module:
1018 # LINTLIB               - Automake variable with the name of lint library file to make
1019 # MAKE_LINT_LIB         - Automake conditional
1020 #
1021 # --enable-lint-library:  - 'yes' user instructs the module to created a lint library
1022 #                         - 'no' user instructs the module not to create a lint library (default)
1023
1024 AC_DEFUN([XORG_LINT_LIBRARY],[
1025 AC_REQUIRE([XORG_WITH_LINT])
1026 AC_ARG_ENABLE(lint-library, [AS_HELP_STRING([--enable-lint-library],
1027         [Create lint library (default: disabled)])],
1028         [make_lint_lib=$enableval], [make_lint_lib=no])
1029
1030 if test "x$make_lint_lib" = x"yes" ; then
1031    LINTLIB=llib-l$1.ln
1032    if test "x$LINT" = "x"; then
1033         AC_MSG_ERROR([Cannot make lint library without --with-lint])
1034    fi
1035 elif test "x$make_lint_lib" != x"no" ; then
1036    AC_MSG_ERROR([--enable-lint-library expects 'yes' or 'no'.])
1037 fi
1038
1039 AC_SUBST(LINTLIB)
1040 AM_CONDITIONAL(MAKE_LINT_LIB, [test x$make_lint_lib != xno])
1041
1042 ]) # XORG_LINT_LIBRARY
1043
1044 # XORG_CWARNFLAGS
1045 # ---------------
1046 # Minimum version: 1.2.0
1047 #
1048 # Defines CWARNFLAGS to enable C compiler warnings.
1049 #
1050 AC_DEFUN([XORG_CWARNFLAGS], [
1051 AC_REQUIRE([AC_PROG_CC_C99])
1052 if  test "x$GCC" = xyes ; then
1053     CWARNFLAGS="-Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes \
1054 -Wmissing-declarations -Wnested-externs -fno-strict-aliasing \
1055 -Wbad-function-cast -Wformat=2"
1056     case `$CC -dumpversion` in
1057     3.4.* | 4.*)
1058         CWARNFLAGS="$CWARNFLAGS -Wold-style-definition -Wdeclaration-after-statement"
1059         ;;
1060     esac
1061 else
1062     AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
1063     if test "x$SUNCC" = "xyes"; then
1064         CWARNFLAGS="-v"
1065     fi
1066 fi
1067 AC_SUBST(CWARNFLAGS)
1068 ]) # XORG_CWARNFLAGS
1069
1070 # XORG_STRICT_OPTION
1071 # -----------------------
1072 # Minimum version: 1.3.0
1073 #
1074 # Add configure option to enable strict compilation
1075 AC_DEFUN([XORG_STRICT_OPTION], [
1076 # If the module's configure.ac calls AC_PROG_CC later on, CC gets set to C89
1077 AC_REQUIRE([AC_PROG_CC_C99])
1078 AC_REQUIRE([XORG_CWARNFLAGS])
1079
1080 AC_ARG_ENABLE(strict-compilation,
1081                           AS_HELP_STRING([--enable-strict-compilation],
1082                           [Enable all warnings from compiler and make them errors (default: disabled)]),
1083                           [STRICT_COMPILE=$enableval], [STRICT_COMPILE=no])
1084 if test "x$STRICT_COMPILE" = "xyes"; then
1085         AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
1086         AC_CHECK_DECL([__INTEL_COMPILER], [INTELCC="yes"], [INTELCC="no"])
1087         if test "x$GCC" = xyes ; then
1088                 STRICT_CFLAGS="-pedantic -Werror"
1089         elif test "x$SUNCC" = "xyes"; then
1090                 STRICT_CFLAGS="-errwarn"
1091     elif test "x$INTELCC" = "xyes"; then
1092                 STRICT_CFLAGS="-Werror"
1093         fi
1094 fi
1095 CWARNFLAGS="$CWARNFLAGS $STRICT_CFLAGS"
1096 AC_SUBST([CWARNFLAGS])
1097 ]) # XORG_STRICT_OPTION
1098
1099 # XORG_DEFAULT_OPTIONS
1100 # --------------------
1101 # Minimum version: 1.3.0
1102 #
1103 # Defines default options for X.Org modules.
1104 #
1105 AC_DEFUN([XORG_DEFAULT_OPTIONS], [
1106 AC_REQUIRE([AC_PROG_INSTALL])
1107 XORG_CWARNFLAGS
1108 XORG_STRICT_OPTION
1109 XORG_RELEASE_VERSION
1110 XORG_CHANGELOG
1111 XORG_INSTALL
1112 XORG_MANPAGE_SECTIONS
1113 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])],
1114     [AC_SUBST([AM_DEFAULT_VERBOSITY], [1])])
1115 ]) # XORG_DEFAULT_OPTIONS
1116
1117 # XORG_INSTALL()
1118 # ----------------
1119 # Minimum version: 1.4.0
1120 #
1121 # Defines the variable INSTALL_CMD as the command to copy
1122 # INSTALL from $prefix/share/util-macros.
1123 #
1124 AC_DEFUN([XORG_INSTALL], [
1125 AC_REQUIRE([PKG_PROG_PKG_CONFIG])
1126 macros_datadir=`$PKG_CONFIG --print-errors --variable=pkgdatadir xorg-macros`
1127 INSTALL_CMD="(cp -f "$macros_datadir/INSTALL" \$(top_srcdir)/.INSTALL.tmp && \
1128 mv \$(top_srcdir)/.INSTALL.tmp \$(top_srcdir)/INSTALL) \
1129 || (rm -f \$(top_srcdir)/.INSTALL.tmp; touch \$(top_srcdir)/INSTALL; \
1130 echo 'util-macros \"pkgdatadir\" from xorg-macros.pc not found: installing possibly empty INSTALL.' >&2)"
1131 AC_SUBST([INSTALL_CMD])
1132 ]) # XORG_INSTALL