1ffab5952Smrgdnl @configure_input@
2ffab5952Smrgdnl
36781a5f7Smrgdnl Copyright (c) 2005, 2023, Oracle and/or its affiliates.
443c16309Smrgdnl
5ffab5952Smrgdnl Permission is hereby granted, free of charge, to any person obtaining a
6ffab5952Smrgdnl copy of this software and associated documentation files (the "Software"),
7ffab5952Smrgdnl to deal in the Software without restriction, including without limitation
8ffab5952Smrgdnl the rights to use, copy, modify, merge, publish, distribute, sublicense,
9ffab5952Smrgdnl and/or sell copies of the Software, and to permit persons to whom the
10ffab5952Smrgdnl Software is furnished to do so, subject to the following conditions:
11ffab5952Smrgdnl
12ffab5952Smrgdnl The above copyright notice and this permission notice (including the next
13ffab5952Smrgdnl paragraph) shall be included in all copies or substantial portions of the
14ffab5952Smrgdnl Software.
15ffab5952Smrgdnl
16ffab5952Smrgdnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17ffab5952Smrgdnl IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18ffab5952Smrgdnl FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19ffab5952Smrgdnl THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20ffab5952Smrgdnl LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21ffab5952Smrgdnl FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22ffab5952Smrgdnl DEALINGS IN THE SOFTWARE.
23ffab5952Smrg
24ffab5952Smrg# XORG_MACROS_VERSION(required-version)
25ffab5952Smrg# -------------------------------------
26ffab5952Smrg# Minimum version: 1.1.0
27ffab5952Smrg#
28ffab5952Smrg# If you're using a macro added in Version 1.1 or newer, include this in
29ffab5952Smrg# your configure.ac with the minimum required version, such as:
30ffab5952Smrg# XORG_MACROS_VERSION(1.1)
31ffab5952Smrg#
32ffab5952Smrg# To ensure that this macro is defined, also add:
33ffab5952Smrg# m4_ifndef([XORG_MACROS_VERSION],
34ffab5952Smrg#     [m4_fatal([must install xorg-macros 1.1 or later before running autoconf/autogen])])
35ffab5952Smrg#
36ffab5952Smrg#
3743c16309Smrg# See the "minimum version" comment for each macro you use to see what
38ffab5952Smrg# version you require.
39ffab5952Smrgm4_defun([XORG_MACROS_VERSION],[
40ffab5952Smrgm4_define([vers_have], [@VERSION@])
41ffab5952Smrgm4_define([maj_have], m4_substr(vers_have, 0, m4_index(vers_have, [.])))
42ffab5952Smrgm4_define([maj_needed], m4_substr([$1], 0, m4_index([$1], [.])))
43ffab5952Smrgm4_if(m4_cmp(maj_have, maj_needed), 0,,
44ffab5952Smrg    [m4_fatal([xorg-macros major version ]maj_needed[ is required but ]vers_have[ found])])
45ffab5952Smrgm4_if(m4_version_compare(vers_have, [$1]), -1,
46ffab5952Smrg    [m4_fatal([xorg-macros version $1 or higher is required but ]vers_have[ found])])
47ffab5952Smrgm4_undefine([vers_have])
48ffab5952Smrgm4_undefine([maj_have])
49ffab5952Smrgm4_undefine([maj_needed])
50ffab5952Smrg]) # XORG_MACROS_VERSION
51ffab5952Smrg
52ffab5952Smrg# XORG_PROG_RAWCPP()
53ffab5952Smrg# ------------------
54ffab5952Smrg# Minimum version: 1.0.0
55ffab5952Smrg#
56ffab5952Smrg# Find cpp program and necessary flags for use in pre-processing text files
57ffab5952Smrg# such as man pages and config files
58ffab5952SmrgAC_DEFUN([XORG_PROG_RAWCPP],[
59ffab5952SmrgAC_REQUIRE([AC_PROG_CPP])
6045aa2fbfSmrgAC_PATH_TOOL(RAWCPP, [cpp], [${CPP}],
61ffab5952Smrg   [$PATH:/bin:/usr/bin:/usr/lib:/usr/libexec:/usr/ccs/lib:/usr/ccs/lbin:/lib])
62ffab5952Smrg
63ffab5952Smrg# Check for flag to avoid builtin definitions - assumes unix is predefined,
64ffab5952Smrg# which is not the best choice for supporting other OS'es, but covers most
65ffab5952Smrg# of the ones we need for now.
66ffab5952SmrgAC_MSG_CHECKING([if $RAWCPP requires -undef])
6762044635SmrgAC_LANG_CONFTEST([AC_LANG_SOURCE([[Does cpp redefine unix ?]])])
68ffab5952Smrgif test `${RAWCPP} < conftest.$ac_ext | grep -c 'unix'` -eq 1 ; then
69ffab5952Smrg	AC_MSG_RESULT([no])
70ffab5952Smrgelse
71ffab5952Smrg	if test `${RAWCPP} -undef < conftest.$ac_ext | grep -c 'unix'` -eq 1 ; then
72ffab5952Smrg		RAWCPPFLAGS=-undef
73ffab5952Smrg		AC_MSG_RESULT([yes])
74ffab5952Smrg	# under Cygwin unix is still defined even with -undef
75ffab5952Smrg	elif test `${RAWCPP} -undef -ansi < conftest.$ac_ext | grep -c 'unix'` -eq 1 ; then
76ffab5952Smrg		RAWCPPFLAGS="-undef -ansi"
77ffab5952Smrg		AC_MSG_RESULT([yes, with -ansi])
78ffab5952Smrg	else
79ffab5952Smrg		AC_MSG_ERROR([${RAWCPP} defines unix with or without -undef.  I don't know what to do.])
80ffab5952Smrg	fi
81ffab5952Smrgfi
82ffab5952Smrgrm -f conftest.$ac_ext
83ffab5952Smrg
84ffab5952SmrgAC_MSG_CHECKING([if $RAWCPP requires -traditional])
8562044635SmrgAC_LANG_CONFTEST([AC_LANG_SOURCE([[Does cpp preserve   "whitespace"?]])])
86220ad8cdSmrgif test `${RAWCPP} < conftest.$ac_ext | grep -c 'preserve   "'` -eq 1 ; then
87ffab5952Smrg	AC_MSG_RESULT([no])
88ffab5952Smrgelse
89220ad8cdSmrg	if test `${RAWCPP} -traditional < conftest.$ac_ext | grep -c 'preserve   "'` -eq 1 ; then
90c1197e68Smrg		TRADITIONALCPPFLAGS="-traditional"
91ffab5952Smrg		RAWCPPFLAGS="${RAWCPPFLAGS} -traditional"
92ffab5952Smrg		AC_MSG_RESULT([yes])
93ffab5952Smrg	else
94ffab5952Smrg		AC_MSG_ERROR([${RAWCPP} does not preserve whitespace with or without -traditional.  I don't know what to do.])
95ffab5952Smrg	fi
96ffab5952Smrgfi
97ffab5952Smrgrm -f conftest.$ac_ext
98ffab5952SmrgAC_SUBST(RAWCPPFLAGS)
99c1197e68SmrgAC_SUBST(TRADITIONALCPPFLAGS)
100ffab5952Smrg]) # XORG_PROG_RAWCPP
101ffab5952Smrg
102ffab5952Smrg# XORG_MANPAGE_SECTIONS()
103ffab5952Smrg# -----------------------
104ffab5952Smrg# Minimum version: 1.0.0
105ffab5952Smrg#
106ffab5952Smrg# Determine which sections man pages go in for the different man page types
107ffab5952Smrg# on this OS - replaces *ManSuffix settings in old Imake *.cf per-os files.
108ffab5952Smrg# Not sure if there's any better way than just hardcoding by OS name.
109ffab5952Smrg# Override default settings by setting environment variables
110ffab5952Smrg# Added MAN_SUBSTS in version 1.8
111ffab5952Smrg# Added AC_PROG_SED in version 1.8
112ffab5952Smrg
113ffab5952SmrgAC_DEFUN([XORG_MANPAGE_SECTIONS],[
114ffab5952SmrgAC_REQUIRE([AC_CANONICAL_HOST])
115ffab5952SmrgAC_REQUIRE([AC_PROG_SED])
116ffab5952Smrg
1179fa8ffe7Smrgcase $host_os in
1189fa8ffe7Smrg    solaris*)
1199fa8ffe7Smrg        # Solaris 2.0 - 11.3 use SysV man page section numbers, so we
1209fa8ffe7Smrg        # check for a man page file found in later versions that use
1219fa8ffe7Smrg        # traditional section numbers instead
1229fa8ffe7Smrg        AC_CHECK_FILE([/usr/share/man/man7/attributes.7],
1239fa8ffe7Smrg                [SYSV_MAN_SECTIONS=false], [SYSV_MAN_SECTIONS=true])
1249fa8ffe7Smrg        ;;
1259fa8ffe7Smrg    *) SYSV_MAN_SECTIONS=false ;;
1269fa8ffe7Smrgesac
1279fa8ffe7Smrg
128ffab5952Smrgif test x$APP_MAN_SUFFIX = x    ; then
129ffab5952Smrg    APP_MAN_SUFFIX=1
130ffab5952Smrgfi
131ffab5952Smrgif test x$APP_MAN_DIR = x    ; then
132ffab5952Smrg    APP_MAN_DIR='$(mandir)/man$(APP_MAN_SUFFIX)'
133ffab5952Smrgfi
134ffab5952Smrg
135ffab5952Smrgif test x$LIB_MAN_SUFFIX = x    ; then
136ffab5952Smrg    LIB_MAN_SUFFIX=3
137ffab5952Smrgfi
138ffab5952Smrgif test x$LIB_MAN_DIR = x    ; then
139ffab5952Smrg    LIB_MAN_DIR='$(mandir)/man$(LIB_MAN_SUFFIX)'
140ffab5952Smrgfi
141ffab5952Smrg
142ffab5952Smrgif test x$FILE_MAN_SUFFIX = x    ; then
1439fa8ffe7Smrg    case $SYSV_MAN_SECTIONS in
1449fa8ffe7Smrg	true)				FILE_MAN_SUFFIX=4  ;;
14567e4e4deSmrg	*)				FILE_MAN_SUFFIX=5  ;;
146ffab5952Smrg    esac
147ffab5952Smrgfi
148ffab5952Smrgif test x$FILE_MAN_DIR = x    ; then
149ffab5952Smrg    FILE_MAN_DIR='$(mandir)/man$(FILE_MAN_SUFFIX)'
150ffab5952Smrgfi
151ffab5952Smrg
152ffab5952Smrgif test x$MISC_MAN_SUFFIX = x    ; then
1539fa8ffe7Smrg    case $SYSV_MAN_SECTIONS in
1549fa8ffe7Smrg	true)				MISC_MAN_SUFFIX=5  ;;
15567e4e4deSmrg	*)				MISC_MAN_SUFFIX=7  ;;
156ffab5952Smrg    esac
157ffab5952Smrgfi
158ffab5952Smrgif test x$MISC_MAN_DIR = x    ; then
159ffab5952Smrg    MISC_MAN_DIR='$(mandir)/man$(MISC_MAN_SUFFIX)'
160ffab5952Smrgfi
161ffab5952Smrg
162ffab5952Smrgif test x$DRIVER_MAN_SUFFIX = x    ; then
1639fa8ffe7Smrg    case $SYSV_MAN_SECTIONS in
1649fa8ffe7Smrg	true)				DRIVER_MAN_SUFFIX=7  ;;
16567e4e4deSmrg	*)				DRIVER_MAN_SUFFIX=4  ;;
166ffab5952Smrg    esac
167ffab5952Smrgfi
168ffab5952Smrgif test x$DRIVER_MAN_DIR = x    ; then
169ffab5952Smrg    DRIVER_MAN_DIR='$(mandir)/man$(DRIVER_MAN_SUFFIX)'
170ffab5952Smrgfi
171ffab5952Smrg
172ffab5952Smrgif test x$ADMIN_MAN_SUFFIX = x    ; then
1739fa8ffe7Smrg    case $SYSV_MAN_SECTIONS in
1749fa8ffe7Smrg	true)				ADMIN_MAN_SUFFIX=1m ;;
17567e4e4deSmrg	*)				ADMIN_MAN_SUFFIX=8  ;;
176ffab5952Smrg    esac
177ffab5952Smrgfi
178ffab5952Smrgif test x$ADMIN_MAN_DIR = x    ; then
179ffab5952Smrg    ADMIN_MAN_DIR='$(mandir)/man$(ADMIN_MAN_SUFFIX)'
180ffab5952Smrgfi
181ffab5952Smrg
182ffab5952Smrg
183ffab5952SmrgAC_SUBST([APP_MAN_SUFFIX])
184ffab5952SmrgAC_SUBST([LIB_MAN_SUFFIX])
185ffab5952SmrgAC_SUBST([FILE_MAN_SUFFIX])
186ffab5952SmrgAC_SUBST([MISC_MAN_SUFFIX])
187ffab5952SmrgAC_SUBST([DRIVER_MAN_SUFFIX])
188ffab5952SmrgAC_SUBST([ADMIN_MAN_SUFFIX])
189ffab5952SmrgAC_SUBST([APP_MAN_DIR])
190ffab5952SmrgAC_SUBST([LIB_MAN_DIR])
191ffab5952SmrgAC_SUBST([FILE_MAN_DIR])
192ffab5952SmrgAC_SUBST([MISC_MAN_DIR])
193ffab5952SmrgAC_SUBST([DRIVER_MAN_DIR])
194ffab5952SmrgAC_SUBST([ADMIN_MAN_DIR])
195ffab5952Smrg
196ffab5952SmrgXORG_MAN_PAGE="X Version 11"
197ffab5952SmrgAC_SUBST([XORG_MAN_PAGE])
198ffab5952SmrgMAN_SUBSTS="\
199ffab5952Smrg	-e 's|__vendorversion__|\"\$(PACKAGE_STRING)\" \"\$(XORG_MAN_PAGE)\"|' \
200ffab5952Smrg	-e 's|__xorgversion__|\"\$(PACKAGE_STRING)\" \"\$(XORG_MAN_PAGE)\"|' \
201ffab5952Smrg	-e 's|__xservername__|Xorg|g' \
202ffab5952Smrg	-e 's|__xconfigfile__|xorg.conf|g' \
203ffab5952Smrg	-e 's|__projectroot__|\$(prefix)|g' \
204ffab5952Smrg	-e 's|__apploaddir__|\$(appdefaultdir)|g' \
205ffab5952Smrg	-e 's|__appmansuffix__|\$(APP_MAN_SUFFIX)|g' \
206ffab5952Smrg	-e 's|__drivermansuffix__|\$(DRIVER_MAN_SUFFIX)|g' \
207ffab5952Smrg	-e 's|__adminmansuffix__|\$(ADMIN_MAN_SUFFIX)|g' \
208ffab5952Smrg	-e 's|__libmansuffix__|\$(LIB_MAN_SUFFIX)|g' \
209ffab5952Smrg	-e 's|__miscmansuffix__|\$(MISC_MAN_SUFFIX)|g' \
210ffab5952Smrg	-e 's|__filemansuffix__|\$(FILE_MAN_SUFFIX)|g'"
211ffab5952SmrgAC_SUBST([MAN_SUBSTS])
212ffab5952Smrg
213ffab5952Smrg]) # XORG_MANPAGE_SECTIONS
214ffab5952Smrg
215ffab5952Smrg# XORG_CHECK_SGML_DOCTOOLS([MIN-VERSION])
216ffab5952Smrg# ------------------------
217ffab5952Smrg# Minimum version: 1.7.0
218ffab5952Smrg#
219ffab5952Smrg# Defines the variable XORG_SGML_PATH containing the location of X11/defs.ent
220ffab5952Smrg# provided by xorg-sgml-doctools, if installed.
221ffab5952SmrgAC_DEFUN([XORG_CHECK_SGML_DOCTOOLS],[
222ffab5952SmrgAC_MSG_CHECKING([for X.Org SGML entities m4_ifval([$1],[>= $1])])
223ffab5952SmrgXORG_SGML_PATH=
224ffab5952SmrgPKG_CHECK_EXISTS([xorg-sgml-doctools m4_ifval([$1],[>= $1])],
225ffab5952Smrg    [XORG_SGML_PATH=`$PKG_CONFIG --variable=sgmlrootdir xorg-sgml-doctools`],
226ffab5952Smrg    [m4_ifval([$1],[:],
227ffab5952Smrg        [if test x"$cross_compiling" != x"yes" ; then
228ffab5952Smrg            AC_CHECK_FILE([$prefix/share/sgml/X11/defs.ent],
229ffab5952Smrg                          [XORG_SGML_PATH=$prefix/share/sgml])
230ffab5952Smrg         fi])
231ffab5952Smrg    ])
232ffab5952Smrg
233ffab5952Smrg# Define variables STYLESHEET_SRCDIR and XSL_STYLESHEET containing
234ffab5952Smrg# the path and the name of the doc stylesheet
235ffab5952Smrgif test "x$XORG_SGML_PATH" != "x" ; then
236ffab5952Smrg   AC_MSG_RESULT([$XORG_SGML_PATH])
237ffab5952Smrg   STYLESHEET_SRCDIR=$XORG_SGML_PATH/X11
238ffab5952Smrg   XSL_STYLESHEET=$STYLESHEET_SRCDIR/xorg.xsl
239ffab5952Smrgelse
240ffab5952Smrg   AC_MSG_RESULT([no])
241ffab5952Smrgfi
242ffab5952Smrg
243ffab5952SmrgAC_SUBST(XORG_SGML_PATH)
244ffab5952SmrgAC_SUBST(STYLESHEET_SRCDIR)
245ffab5952SmrgAC_SUBST(XSL_STYLESHEET)
246ffab5952SmrgAM_CONDITIONAL([HAVE_STYLESHEETS], [test "x$XSL_STYLESHEET" != "x"])
247ffab5952Smrg]) # XORG_CHECK_SGML_DOCTOOLS
248ffab5952Smrg
249ffab5952Smrg# XORG_CHECK_LINUXDOC
250ffab5952Smrg# -------------------
251ffab5952Smrg# Minimum version: 1.0.0
252ffab5952Smrg#
253ffab5952Smrg# Defines the variable MAKE_TEXT if the necessary tools and
254ffab5952Smrg# files are found. $(MAKE_TEXT) blah.sgml will then produce blah.txt.
255ffab5952Smrg# Whether or not the necessary tools and files are found can be checked
256ffab5952Smrg# with the AM_CONDITIONAL "BUILD_LINUXDOC"
257ffab5952SmrgAC_DEFUN([XORG_CHECK_LINUXDOC],[
258ffab5952SmrgAC_REQUIRE([XORG_CHECK_SGML_DOCTOOLS])
259ffab5952SmrgAC_REQUIRE([XORG_WITH_PS2PDF])
260ffab5952Smrg
261ffab5952SmrgAC_PATH_PROG(LINUXDOC, linuxdoc)
262ffab5952Smrg
263ffab5952SmrgAC_MSG_CHECKING([whether to build documentation])
264ffab5952Smrg
265ffab5952Smrgif test x$XORG_SGML_PATH != x && test x$LINUXDOC != x ; then
266ffab5952Smrg   BUILDDOC=yes
267ffab5952Smrgelse
268ffab5952Smrg   BUILDDOC=no
269ffab5952Smrgfi
270ffab5952Smrg
271ffab5952SmrgAM_CONDITIONAL(BUILD_LINUXDOC, [test x$BUILDDOC = xyes])
272ffab5952Smrg
273ffab5952SmrgAC_MSG_RESULT([$BUILDDOC])
274ffab5952Smrg
275ffab5952SmrgAC_MSG_CHECKING([whether to build pdf documentation])
276ffab5952Smrg
277ffab5952Smrgif test x$have_ps2pdf != xno && test x$BUILD_PDFDOC != xno; then
278ffab5952Smrg   BUILDPDFDOC=yes
279ffab5952Smrgelse
280ffab5952Smrg   BUILDPDFDOC=no
281ffab5952Smrgfi
282ffab5952Smrg
283ffab5952SmrgAM_CONDITIONAL(BUILD_PDFDOC, [test x$BUILDPDFDOC = xyes])
284ffab5952Smrg
285ffab5952SmrgAC_MSG_RESULT([$BUILDPDFDOC])
286ffab5952Smrg
287ffab5952SmrgMAKE_TEXT="SGML_SEARCH_PATH=$XORG_SGML_PATH GROFF_NO_SGR=y $LINUXDOC -B txt -f"
288ffab5952SmrgMAKE_PS="SGML_SEARCH_PATH=$XORG_SGML_PATH $LINUXDOC -B latex --papersize=letter --output=ps"
289ffab5952SmrgMAKE_PDF="$PS2PDF"
290ffab5952SmrgMAKE_HTML="SGML_SEARCH_PATH=$XORG_SGML_PATH $LINUXDOC  -B html --split=0"
291ffab5952Smrg
292ffab5952SmrgAC_SUBST(MAKE_TEXT)
293ffab5952SmrgAC_SUBST(MAKE_PS)
294ffab5952SmrgAC_SUBST(MAKE_PDF)
295ffab5952SmrgAC_SUBST(MAKE_HTML)
296ffab5952Smrg]) # XORG_CHECK_LINUXDOC
297ffab5952Smrg
298ffab5952Smrg# XORG_CHECK_DOCBOOK
299ffab5952Smrg# -------------------
300ffab5952Smrg# Minimum version: 1.0.0
301ffab5952Smrg#
302ffab5952Smrg# Checks for the ability to build output formats from SGML DocBook source.
303ffab5952Smrg# For XXX in {TXT, PDF, PS, HTML}, the AM_CONDITIONAL "BUILD_XXXDOC"
304ffab5952Smrg# indicates whether the necessary tools and files are found and, if set,
305ffab5952Smrg# $(MAKE_XXX) blah.sgml will produce blah.xxx.
306ffab5952SmrgAC_DEFUN([XORG_CHECK_DOCBOOK],[
307ffab5952SmrgAC_REQUIRE([XORG_CHECK_SGML_DOCTOOLS])
308ffab5952Smrg
309ffab5952SmrgBUILDTXTDOC=no
310ffab5952SmrgBUILDPDFDOC=no
311ffab5952SmrgBUILDPSDOC=no
312ffab5952SmrgBUILDHTMLDOC=no
313ffab5952Smrg
314ffab5952SmrgAC_PATH_PROG(DOCBOOKPS, docbook2ps)
315ffab5952SmrgAC_PATH_PROG(DOCBOOKPDF, docbook2pdf)
316ffab5952SmrgAC_PATH_PROG(DOCBOOKHTML, docbook2html)
317ffab5952SmrgAC_PATH_PROG(DOCBOOKTXT, docbook2txt)
318ffab5952Smrg
319ffab5952SmrgAC_MSG_CHECKING([whether to build text documentation])
320ffab5952Smrgif test x$XORG_SGML_PATH != x && test x$DOCBOOKTXT != x &&
321ffab5952Smrg   test x$BUILD_TXTDOC != xno; then
322ffab5952Smrg	BUILDTXTDOC=yes
323ffab5952Smrgfi
324ffab5952SmrgAM_CONDITIONAL(BUILD_TXTDOC, [test x$BUILDTXTDOC = xyes])
325ffab5952SmrgAC_MSG_RESULT([$BUILDTXTDOC])
326ffab5952Smrg
327ffab5952SmrgAC_MSG_CHECKING([whether to build PDF documentation])
328ffab5952Smrgif test x$XORG_SGML_PATH != x && test x$DOCBOOKPDF != x &&
329ffab5952Smrg   test x$BUILD_PDFDOC != xno; then
330ffab5952Smrg	BUILDPDFDOC=yes
331ffab5952Smrgfi
332ffab5952SmrgAM_CONDITIONAL(BUILD_PDFDOC, [test x$BUILDPDFDOC = xyes])
333ffab5952SmrgAC_MSG_RESULT([$BUILDPDFDOC])
334ffab5952Smrg
335ffab5952SmrgAC_MSG_CHECKING([whether to build PostScript documentation])
336ffab5952Smrgif test x$XORG_SGML_PATH != x && test x$DOCBOOKPS != x &&
337ffab5952Smrg   test x$BUILD_PSDOC != xno; then
338ffab5952Smrg	BUILDPSDOC=yes
339ffab5952Smrgfi
340ffab5952SmrgAM_CONDITIONAL(BUILD_PSDOC, [test x$BUILDPSDOC = xyes])
341ffab5952SmrgAC_MSG_RESULT([$BUILDPSDOC])
342ffab5952Smrg
343ffab5952SmrgAC_MSG_CHECKING([whether to build HTML documentation])
344ffab5952Smrgif test x$XORG_SGML_PATH != x && test x$DOCBOOKHTML != x &&
345ffab5952Smrg   test x$BUILD_HTMLDOC != xno; then
346ffab5952Smrg	BUILDHTMLDOC=yes
347ffab5952Smrgfi
348ffab5952SmrgAM_CONDITIONAL(BUILD_HTMLDOC, [test x$BUILDHTMLDOC = xyes])
349ffab5952SmrgAC_MSG_RESULT([$BUILDHTMLDOC])
350ffab5952Smrg
351ffab5952SmrgMAKE_TEXT="SGML_SEARCH_PATH=$XORG_SGML_PATH $DOCBOOKTXT"
352ffab5952SmrgMAKE_PS="SGML_SEARCH_PATH=$XORG_SGML_PATH $DOCBOOKPS"
353ffab5952SmrgMAKE_PDF="SGML_SEARCH_PATH=$XORG_SGML_PATH $DOCBOOKPDF"
354ffab5952SmrgMAKE_HTML="SGML_SEARCH_PATH=$XORG_SGML_PATH $DOCBOOKHTML"
355ffab5952Smrg
356ffab5952SmrgAC_SUBST(MAKE_TEXT)
357ffab5952SmrgAC_SUBST(MAKE_PS)
358ffab5952SmrgAC_SUBST(MAKE_PDF)
359ffab5952SmrgAC_SUBST(MAKE_HTML)
360ffab5952Smrg]) # XORG_CHECK_DOCBOOK
361ffab5952Smrg
362ffab5952Smrg# XORG_WITH_XMLTO([MIN-VERSION], [DEFAULT])
363ffab5952Smrg# ----------------
364ffab5952Smrg# Minimum version: 1.5.0
365ffab5952Smrg# Minimum version for optional DEFAULT argument: 1.11.0
366ffab5952Smrg#
367ffab5952Smrg# Documentation tools are not always available on all platforms and sometimes
368ffab5952Smrg# not at the appropriate level. This macro enables a module to test for the
369ffab5952Smrg# presence of the tool and obtain it's path in separate variables. Coupled with
3706781a5f7Smrg# the --with-xmlto option, it allows maximum flexibility in making decisions
371ffab5952Smrg# as whether or not to use the xmlto package. When DEFAULT is not specified,
372ffab5952Smrg# --with-xmlto assumes 'auto'.
373ffab5952Smrg#
374ffab5952Smrg# Interface to module:
375ffab5952Smrg# HAVE_XMLTO: 	used in makefiles to conditionally generate documentation
376ffab5952Smrg# XMLTO:	returns the path of the xmlto program found
377ffab5952Smrg#		returns the path set by the user in the environment
378ffab5952Smrg# --with-xmlto:	'yes' user instructs the module to use xmlto
379ffab5952Smrg#		'no' user instructs the module not to use xmlto
380ffab5952Smrg#
381ffab5952Smrg# Added in version 1.10.0
382ffab5952Smrg# HAVE_XMLTO_TEXT: used in makefiles to conditionally generate text documentation
383ffab5952Smrg#                  xmlto for text output requires either lynx, links, or w3m browsers
384ffab5952Smrg#
385ffab5952Smrg# If the user sets the value of XMLTO, AC_PATH_PROG skips testing the path.
386ffab5952Smrg#
387ffab5952SmrgAC_DEFUN([XORG_WITH_XMLTO],[
388ffab5952SmrgAC_ARG_VAR([XMLTO], [Path to xmlto command])
389ffab5952Smrgm4_define([_defopt], m4_default([$2], [auto]))
390ffab5952SmrgAC_ARG_WITH(xmlto,
391ffab5952Smrg	AS_HELP_STRING([--with-xmlto],
392ffab5952Smrg	   [Use xmlto to regenerate documentation (default: ]_defopt[)]),
393ffab5952Smrg	   [use_xmlto=$withval], [use_xmlto=]_defopt)
394ffab5952Smrgm4_undefine([_defopt])
395ffab5952Smrg
396ffab5952Smrgif test "x$use_xmlto" = x"auto"; then
397ffab5952Smrg   AC_PATH_PROG([XMLTO], [xmlto])
398ffab5952Smrg   if test "x$XMLTO" = "x"; then
399ffab5952Smrg        AC_MSG_WARN([xmlto not found - documentation targets will be skipped])
400ffab5952Smrg	have_xmlto=no
401ffab5952Smrg   else
402ffab5952Smrg        have_xmlto=yes
403ffab5952Smrg   fi
404ffab5952Smrgelif test "x$use_xmlto" = x"yes" ; then
405ffab5952Smrg   AC_PATH_PROG([XMLTO], [xmlto])
406ffab5952Smrg   if test "x$XMLTO" = "x"; then
407ffab5952Smrg        AC_MSG_ERROR([--with-xmlto=yes specified but xmlto not found in PATH])
408ffab5952Smrg   fi
409ffab5952Smrg   have_xmlto=yes
410ffab5952Smrgelif test "x$use_xmlto" = x"no" ; then
411ffab5952Smrg   if test "x$XMLTO" != "x"; then
412ffab5952Smrg      AC_MSG_WARN([ignoring XMLTO environment variable since --with-xmlto=no was specified])
413ffab5952Smrg   fi
414ffab5952Smrg   have_xmlto=no
415ffab5952Smrgelse
416ffab5952Smrg   AC_MSG_ERROR([--with-xmlto expects 'yes' or 'no'])
417ffab5952Smrgfi
418ffab5952Smrg
419ffab5952Smrg# Test for a minimum version of xmlto, if provided.
420ffab5952Smrgm4_ifval([$1],
421ffab5952Smrg[if test "$have_xmlto" = yes; then
422ffab5952Smrg    # scrape the xmlto version
423ffab5952Smrg    AC_MSG_CHECKING([the xmlto version])
424ffab5952Smrg    xmlto_version=`$XMLTO --version 2>/dev/null | cut -d' ' -f3`
425ffab5952Smrg    AC_MSG_RESULT([$xmlto_version])
426ffab5952Smrg    AS_VERSION_COMPARE([$xmlto_version], [$1],
427ffab5952Smrg        [if test "x$use_xmlto" = xauto; then
428ffab5952Smrg            AC_MSG_WARN([xmlto version $xmlto_version found, but $1 needed])
429ffab5952Smrg            have_xmlto=no
430ffab5952Smrg        else
431ffab5952Smrg            AC_MSG_ERROR([xmlto version $xmlto_version found, but $1 needed])
432ffab5952Smrg        fi])
433ffab5952Smrgfi])
434ffab5952Smrg
435ffab5952Smrg# Test for the ability of xmlto to generate a text target
43667e4e4deSmrg#
43767e4e4deSmrg# NOTE: xmlto 0.0.27 or higher return a non-zero return code in the
43867e4e4deSmrg# following test for empty XML docbook files.
43967e4e4deSmrg# For compatibility reasons use the following empty XML docbook file and if
44067e4e4deSmrg# it fails try it again with a non-empty XML file.
441ffab5952Smrghave_xmlto_text=no
442ffab5952Smrgcat > conftest.xml << "EOF"
443ffab5952SmrgEOF
444ffab5952SmrgAS_IF([test "$have_xmlto" = yes],
445ffab5952Smrg      [AS_IF([$XMLTO --skip-validation txt conftest.xml >/dev/null 2>&1],
446ffab5952Smrg             [have_xmlto_text=yes],
44767e4e4deSmrg             [# Try it again with a non-empty XML file.
44867e4e4deSmrg              cat > conftest.xml << "EOF"
44967e4e4deSmrg<x></x>
45067e4e4deSmrgEOF
45167e4e4deSmrg              AS_IF([$XMLTO --skip-validation txt conftest.xml >/dev/null 2>&1],
45267e4e4deSmrg                    [have_xmlto_text=yes],
45367e4e4deSmrg                    [AC_MSG_WARN([xmlto cannot generate text format, this format skipped])])])])
454ffab5952Smrgrm -f conftest.xml
455ffab5952SmrgAM_CONDITIONAL([HAVE_XMLTO_TEXT], [test $have_xmlto_text = yes])
456ffab5952SmrgAM_CONDITIONAL([HAVE_XMLTO], [test "$have_xmlto" = yes])
457ffab5952Smrg]) # XORG_WITH_XMLTO
458ffab5952Smrg
45962044635Smrg# XORG_WITH_XSLTPROC([MIN-VERSION], [DEFAULT])
46062044635Smrg# --------------------------------------------
46162044635Smrg# Minimum version: 1.12.0
46262044635Smrg# Minimum version for optional DEFAULT argument: 1.12.0
46362044635Smrg#
46462044635Smrg# XSLT (Extensible Stylesheet Language Transformations) is a declarative,
46562044635Smrg# XML-based language used for the transformation of XML documents.
46662044635Smrg# The xsltproc command line tool is for applying XSLT stylesheets to XML documents.
46762044635Smrg# It is used under the cover by xmlto to generate html files from DocBook/XML.
46862044635Smrg# The XSLT processor is often used as a standalone tool for transformations.
46962044635Smrg# It should not be assumed that this tool is used only to work with documnetation.
47062044635Smrg# When DEFAULT is not specified, --with-xsltproc assumes 'auto'.
47162044635Smrg#
47262044635Smrg# Interface to module:
47362044635Smrg# HAVE_XSLTPROC: used in makefiles to conditionally generate documentation
47462044635Smrg# XSLTPROC:	 returns the path of the xsltproc program found
47562044635Smrg#		 returns the path set by the user in the environment
47662044635Smrg# --with-xsltproc: 'yes' user instructs the module to use xsltproc
47762044635Smrg#		  'no' user instructs the module not to use xsltproc
47862044635Smrg# have_xsltproc: returns yes if xsltproc found in PATH or no
47962044635Smrg#
48062044635Smrg# If the user sets the value of XSLTPROC, AC_PATH_PROG skips testing the path.
48162044635Smrg#
48262044635SmrgAC_DEFUN([XORG_WITH_XSLTPROC],[
48362044635SmrgAC_ARG_VAR([XSLTPROC], [Path to xsltproc command])
48462044635Smrg# Preserves the interface, should it be implemented later
48562044635Smrgm4_ifval([$1], [m4_warn([syntax], [Checking for xsltproc MIN-VERSION is not implemented])])
48662044635Smrgm4_define([_defopt], m4_default([$2], [auto]))
48762044635SmrgAC_ARG_WITH(xsltproc,
48862044635Smrg	AS_HELP_STRING([--with-xsltproc],
48962044635Smrg	   [Use xsltproc for the transformation of XML documents (default: ]_defopt[)]),
49062044635Smrg	   [use_xsltproc=$withval], [use_xsltproc=]_defopt)
49162044635Smrgm4_undefine([_defopt])
49262044635Smrg
49362044635Smrgif test "x$use_xsltproc" = x"auto"; then
49462044635Smrg   AC_PATH_PROG([XSLTPROC], [xsltproc])
49562044635Smrg   if test "x$XSLTPROC" = "x"; then
49662044635Smrg        AC_MSG_WARN([xsltproc not found - cannot transform XML documents])
49762044635Smrg	have_xsltproc=no
49862044635Smrg   else
49962044635Smrg        have_xsltproc=yes
50062044635Smrg   fi
50162044635Smrgelif test "x$use_xsltproc" = x"yes" ; then
50262044635Smrg   AC_PATH_PROG([XSLTPROC], [xsltproc])
50362044635Smrg   if test "x$XSLTPROC" = "x"; then
50462044635Smrg        AC_MSG_ERROR([--with-xsltproc=yes specified but xsltproc not found in PATH])
50562044635Smrg   fi
50662044635Smrg   have_xsltproc=yes
50762044635Smrgelif test "x$use_xsltproc" = x"no" ; then
50862044635Smrg   if test "x$XSLTPROC" != "x"; then
50962044635Smrg      AC_MSG_WARN([ignoring XSLTPROC environment variable since --with-xsltproc=no was specified])
51062044635Smrg   fi
51162044635Smrg   have_xsltproc=no
51262044635Smrgelse
51362044635Smrg   AC_MSG_ERROR([--with-xsltproc expects 'yes' or 'no'])
51462044635Smrgfi
51562044635Smrg
51662044635SmrgAM_CONDITIONAL([HAVE_XSLTPROC], [test "$have_xsltproc" = yes])
51762044635Smrg]) # XORG_WITH_XSLTPROC
51862044635Smrg
51962044635Smrg# XORG_WITH_PERL([MIN-VERSION], [DEFAULT])
52062044635Smrg# ----------------------------------------
52162044635Smrg# Minimum version: 1.15.0
52262044635Smrg#
52362044635Smrg# PERL (Practical Extraction and Report Language) is a language optimized for
52462044635Smrg# scanning arbitrary text files, extracting information from those text files,
52562044635Smrg# and printing reports based on that information.
52662044635Smrg#
52762044635Smrg# When DEFAULT is not specified, --with-perl assumes 'auto'.
52862044635Smrg#
52962044635Smrg# Interface to module:
53062044635Smrg# HAVE_PERL: used in makefiles to conditionally scan text files
53162044635Smrg# PERL:	     returns the path of the perl program found
53262044635Smrg#	     returns the path set by the user in the environment
53362044635Smrg# --with-perl: 'yes' user instructs the module to use perl
53462044635Smrg#	       'no' user instructs the module not to use perl
53562044635Smrg# have_perl: returns yes if perl found in PATH or no
53662044635Smrg#
53762044635Smrg# If the user sets the value of PERL, AC_PATH_PROG skips testing the path.
53862044635Smrg#
53962044635SmrgAC_DEFUN([XORG_WITH_PERL],[
54062044635SmrgAC_ARG_VAR([PERL], [Path to perl command])
54162044635Smrg# Preserves the interface, should it be implemented later
54262044635Smrgm4_ifval([$1], [m4_warn([syntax], [Checking for perl MIN-VERSION is not implemented])])
54362044635Smrgm4_define([_defopt], m4_default([$2], [auto]))
54462044635SmrgAC_ARG_WITH(perl,
54562044635Smrg	AS_HELP_STRING([--with-perl],
54662044635Smrg	   [Use perl for extracting information from files (default: ]_defopt[)]),
54762044635Smrg	   [use_perl=$withval], [use_perl=]_defopt)
54862044635Smrgm4_undefine([_defopt])
54962044635Smrg
55062044635Smrgif test "x$use_perl" = x"auto"; then
55162044635Smrg   AC_PATH_PROG([PERL], [perl])
55262044635Smrg   if test "x$PERL" = "x"; then
55362044635Smrg        AC_MSG_WARN([perl not found - cannot extract information and report])
55462044635Smrg	have_perl=no
55562044635Smrg   else
55662044635Smrg        have_perl=yes
55762044635Smrg   fi
55862044635Smrgelif test "x$use_perl" = x"yes" ; then
55962044635Smrg   AC_PATH_PROG([PERL], [perl])
56062044635Smrg   if test "x$PERL" = "x"; then
56162044635Smrg        AC_MSG_ERROR([--with-perl=yes specified but perl not found in PATH])
56262044635Smrg   fi
56362044635Smrg   have_perl=yes
56462044635Smrgelif test "x$use_perl" = x"no" ; then
56562044635Smrg   if test "x$PERL" != "x"; then
56662044635Smrg      AC_MSG_WARN([ignoring PERL environment variable since --with-perl=no was specified])
56762044635Smrg   fi
56862044635Smrg   have_perl=no
56962044635Smrgelse
57062044635Smrg   AC_MSG_ERROR([--with-perl expects 'yes' or 'no'])
57162044635Smrgfi
57262044635Smrg
57362044635SmrgAM_CONDITIONAL([HAVE_PERL], [test "$have_perl" = yes])
57462044635Smrg]) # XORG_WITH_PERL
57562044635Smrg
576ffab5952Smrg# XORG_WITH_ASCIIDOC([MIN-VERSION], [DEFAULT])
577ffab5952Smrg# ----------------
578ffab5952Smrg# Minimum version: 1.5.0
579ffab5952Smrg# Minimum version for optional DEFAULT argument: 1.11.0
580ffab5952Smrg#
581ffab5952Smrg# Documentation tools are not always available on all platforms and sometimes
582ffab5952Smrg# not at the appropriate level. This macro enables a module to test for the
583ffab5952Smrg# presence of the tool and obtain it's path in separate variables. Coupled with
5846781a5f7Smrg# the --with-asciidoc option, it allows maximum flexibility in making decisions
585ffab5952Smrg# as whether or not to use the asciidoc package. When DEFAULT is not specified,
586ffab5952Smrg# --with-asciidoc assumes 'auto'.
587ffab5952Smrg#
588ffab5952Smrg# Interface to module:
589ffab5952Smrg# HAVE_ASCIIDOC: used in makefiles to conditionally generate documentation
590ffab5952Smrg# ASCIIDOC:	 returns the path of the asciidoc program found
591ffab5952Smrg#		 returns the path set by the user in the environment
592ffab5952Smrg# --with-asciidoc: 'yes' user instructs the module to use asciidoc
593ffab5952Smrg#		  'no' user instructs the module not to use asciidoc
594ffab5952Smrg#
595ffab5952Smrg# If the user sets the value of ASCIIDOC, AC_PATH_PROG skips testing the path.
596ffab5952Smrg#
597ffab5952SmrgAC_DEFUN([XORG_WITH_ASCIIDOC],[
598ffab5952SmrgAC_ARG_VAR([ASCIIDOC], [Path to asciidoc command])
599ffab5952Smrgm4_define([_defopt], m4_default([$2], [auto]))
600ffab5952SmrgAC_ARG_WITH(asciidoc,
601ffab5952Smrg	AS_HELP_STRING([--with-asciidoc],
602ffab5952Smrg	   [Use asciidoc to regenerate documentation (default: ]_defopt[)]),
603ffab5952Smrg	   [use_asciidoc=$withval], [use_asciidoc=]_defopt)
604ffab5952Smrgm4_undefine([_defopt])
605ffab5952Smrg
606ffab5952Smrgif test "x$use_asciidoc" = x"auto"; then
607ffab5952Smrg   AC_PATH_PROG([ASCIIDOC], [asciidoc])
608ffab5952Smrg   if test "x$ASCIIDOC" = "x"; then
609ffab5952Smrg        AC_MSG_WARN([asciidoc not found - documentation targets will be skipped])
610ffab5952Smrg	have_asciidoc=no
611ffab5952Smrg   else
612ffab5952Smrg        have_asciidoc=yes
613ffab5952Smrg   fi
614ffab5952Smrgelif test "x$use_asciidoc" = x"yes" ; then
615ffab5952Smrg   AC_PATH_PROG([ASCIIDOC], [asciidoc])
616ffab5952Smrg   if test "x$ASCIIDOC" = "x"; then
617ffab5952Smrg        AC_MSG_ERROR([--with-asciidoc=yes specified but asciidoc not found in PATH])
618ffab5952Smrg   fi
619ffab5952Smrg   have_asciidoc=yes
620ffab5952Smrgelif test "x$use_asciidoc" = x"no" ; then
621ffab5952Smrg   if test "x$ASCIIDOC" != "x"; then
622ffab5952Smrg      AC_MSG_WARN([ignoring ASCIIDOC environment variable since --with-asciidoc=no was specified])
623ffab5952Smrg   fi
624ffab5952Smrg   have_asciidoc=no
625ffab5952Smrgelse
626ffab5952Smrg   AC_MSG_ERROR([--with-asciidoc expects 'yes' or 'no'])
627ffab5952Smrgfi
628ffab5952Smrgm4_ifval([$1],
629ffab5952Smrg[if test "$have_asciidoc" = yes; then
630ffab5952Smrg    # scrape the asciidoc version
631ffab5952Smrg    AC_MSG_CHECKING([the asciidoc version])
632ffab5952Smrg    asciidoc_version=`$ASCIIDOC --version 2>/dev/null | cut -d' ' -f2`
633ffab5952Smrg    AC_MSG_RESULT([$asciidoc_version])
634ffab5952Smrg    AS_VERSION_COMPARE([$asciidoc_version], [$1],
635ffab5952Smrg        [if test "x$use_asciidoc" = xauto; then
636ffab5952Smrg            AC_MSG_WARN([asciidoc version $asciidoc_version found, but $1 needed])
637ffab5952Smrg            have_asciidoc=no
638ffab5952Smrg        else
639ffab5952Smrg            AC_MSG_ERROR([asciidoc version $asciidoc_version found, but $1 needed])
640ffab5952Smrg        fi])
641ffab5952Smrgfi])
642ffab5952SmrgAM_CONDITIONAL([HAVE_ASCIIDOC], [test "$have_asciidoc" = yes])
643ffab5952Smrg]) # XORG_WITH_ASCIIDOC
644ffab5952Smrg
645ffab5952Smrg# XORG_WITH_DOXYGEN([MIN-VERSION], [DEFAULT])
64643c16309Smrg# -------------------------------------------
647ffab5952Smrg# Minimum version: 1.5.0
648ffab5952Smrg# Minimum version for optional DEFAULT argument: 1.11.0
64943c16309Smrg# Minimum version for optional DOT checking: 1.18.0
650ffab5952Smrg#
651ffab5952Smrg# Documentation tools are not always available on all platforms and sometimes
652ffab5952Smrg# not at the appropriate level. This macro enables a module to test for the
653ffab5952Smrg# presence of the tool and obtain it's path in separate variables. Coupled with
6546781a5f7Smrg# the --with-doxygen option, it allows maximum flexibility in making decisions
655ffab5952Smrg# as whether or not to use the doxygen package. When DEFAULT is not specified,
656ffab5952Smrg# --with-doxygen assumes 'auto'.
657ffab5952Smrg#
658ffab5952Smrg# Interface to module:
659ffab5952Smrg# HAVE_DOXYGEN: used in makefiles to conditionally generate documentation
660ffab5952Smrg# DOXYGEN:	 returns the path of the doxygen program found
661ffab5952Smrg#		 returns the path set by the user in the environment
662ffab5952Smrg# --with-doxygen: 'yes' user instructs the module to use doxygen
663ffab5952Smrg#		  'no' user instructs the module not to use doxygen
664ffab5952Smrg#
665ffab5952Smrg# If the user sets the value of DOXYGEN, AC_PATH_PROG skips testing the path.
666ffab5952Smrg#
667ffab5952SmrgAC_DEFUN([XORG_WITH_DOXYGEN],[
668ffab5952SmrgAC_ARG_VAR([DOXYGEN], [Path to doxygen command])
66943c16309SmrgAC_ARG_VAR([DOT], [Path to the dot graphics utility])
670ffab5952Smrgm4_define([_defopt], m4_default([$2], [auto]))
671ffab5952SmrgAC_ARG_WITH(doxygen,
672ffab5952Smrg	AS_HELP_STRING([--with-doxygen],
673ffab5952Smrg	   [Use doxygen to regenerate documentation (default: ]_defopt[)]),
674ffab5952Smrg	   [use_doxygen=$withval], [use_doxygen=]_defopt)
675ffab5952Smrgm4_undefine([_defopt])
676ffab5952Smrg
677ffab5952Smrgif test "x$use_doxygen" = x"auto"; then
678ffab5952Smrg   AC_PATH_PROG([DOXYGEN], [doxygen])
679ffab5952Smrg   if test "x$DOXYGEN" = "x"; then
680ffab5952Smrg        AC_MSG_WARN([doxygen not found - documentation targets will be skipped])
681ffab5952Smrg	have_doxygen=no
682ffab5952Smrg   else
683ffab5952Smrg        have_doxygen=yes
684ffab5952Smrg   fi
685ffab5952Smrgelif test "x$use_doxygen" = x"yes" ; then
686ffab5952Smrg   AC_PATH_PROG([DOXYGEN], [doxygen])
687ffab5952Smrg   if test "x$DOXYGEN" = "x"; then
688ffab5952Smrg        AC_MSG_ERROR([--with-doxygen=yes specified but doxygen not found in PATH])
689ffab5952Smrg   fi
690ffab5952Smrg   have_doxygen=yes
691ffab5952Smrgelif test "x$use_doxygen" = x"no" ; then
692ffab5952Smrg   if test "x$DOXYGEN" != "x"; then
693ffab5952Smrg      AC_MSG_WARN([ignoring DOXYGEN environment variable since --with-doxygen=no was specified])
694ffab5952Smrg   fi
695ffab5952Smrg   have_doxygen=no
696ffab5952Smrgelse
697ffab5952Smrg   AC_MSG_ERROR([--with-doxygen expects 'yes' or 'no'])
698ffab5952Smrgfi
699ffab5952Smrgm4_ifval([$1],
700ffab5952Smrg[if test "$have_doxygen" = yes; then
701ffab5952Smrg    # scrape the doxygen version
702ffab5952Smrg    AC_MSG_CHECKING([the doxygen version])
703ffab5952Smrg    doxygen_version=`$DOXYGEN --version 2>/dev/null`
704ffab5952Smrg    AC_MSG_RESULT([$doxygen_version])
705ffab5952Smrg    AS_VERSION_COMPARE([$doxygen_version], [$1],
706ffab5952Smrg        [if test "x$use_doxygen" = xauto; then
707ffab5952Smrg            AC_MSG_WARN([doxygen version $doxygen_version found, but $1 needed])
708ffab5952Smrg            have_doxygen=no
709ffab5952Smrg        else
710ffab5952Smrg            AC_MSG_ERROR([doxygen version $doxygen_version found, but $1 needed])
711ffab5952Smrg        fi])
712ffab5952Smrgfi])
71343c16309Smrg
71443c16309Smrgdnl Check for DOT if we have doxygen. The caller decides if it is mandatory
71543c16309Smrgdnl HAVE_DOT is a variable that can be used in your doxygen.in config file:
71643c16309Smrgdnl 	HAVE_DOT = @HAVE_DOT@
71743c16309SmrgHAVE_DOT=no
71843c16309Smrgif test "x$have_doxygen" = "xyes"; then
71943c16309Smrg  AC_PATH_PROG([DOT], [dot])
72043c16309Smrg    if test "x$DOT" != "x"; then
72143c16309Smrg      HAVE_DOT=yes
72243c16309Smrg    fi
72343c16309Smrgfi
72443c16309Smrg
72543c16309SmrgAC_SUBST([HAVE_DOT])
72643c16309SmrgAM_CONDITIONAL([HAVE_DOT], [test "$HAVE_DOT" = "yes"])
727ffab5952SmrgAM_CONDITIONAL([HAVE_DOXYGEN], [test "$have_doxygen" = yes])
728ffab5952Smrg]) # XORG_WITH_DOXYGEN
729ffab5952Smrg
730ffab5952Smrg# XORG_WITH_GROFF([DEFAULT])
731ffab5952Smrg# ----------------
732ffab5952Smrg# Minimum version: 1.6.0
733ffab5952Smrg# Minimum version for optional DEFAULT argument: 1.11.0
734ffab5952Smrg#
735ffab5952Smrg# Documentation tools are not always available on all platforms and sometimes
736ffab5952Smrg# not at the appropriate level. This macro enables a module to test for the
737ffab5952Smrg# presence of the tool and obtain it's path in separate variables. Coupled with
7386781a5f7Smrg# the --with-groff option, it allows maximum flexibility in making decisions
739ffab5952Smrg# as whether or not to use the groff package. When DEFAULT is not specified,
740ffab5952Smrg# --with-groff assumes 'auto'.
741ffab5952Smrg#
742ffab5952Smrg# Interface to module:
743ffab5952Smrg# HAVE_GROFF:	 used in makefiles to conditionally generate documentation
744ffab5952Smrg# HAVE_GROFF_MM: the memorandum macros (-mm) package
745ffab5952Smrg# HAVE_GROFF_MS: the -ms macros package
746ffab5952Smrg# GROFF:	 returns the path of the groff program found
747ffab5952Smrg#		 returns the path set by the user in the environment
748ffab5952Smrg# --with-groff:	 'yes' user instructs the module to use groff
749ffab5952Smrg#		 'no' user instructs the module not to use groff
750ffab5952Smrg#
751ffab5952Smrg# Added in version 1.9.0:
752ffab5952Smrg# HAVE_GROFF_HTML: groff has dependencies to output HTML format:
753ffab5952Smrg#		   pnmcut pnmcrop pnmtopng pnmtops from the netpbm package.
754ffab5952Smrg#		   psselect from the psutils package.
755ffab5952Smrg#		   the ghostcript package. Refer to the grohtml man pages
756ffab5952Smrg#
757ffab5952Smrg# If the user sets the value of GROFF, AC_PATH_PROG skips testing the path.
758ffab5952Smrg#
759ffab5952Smrg# OS and distros often splits groff in a basic and full package, the former
760ffab5952Smrg# having the groff program and the later having devices, fonts and macros
761ffab5952Smrg# Checking for the groff executable is not enough.
762ffab5952Smrg#
763ffab5952Smrg# If macros are missing, we cannot assume that groff is useless, so we don't
764ffab5952Smrg# unset HAVE_GROFF or GROFF env variables.
765ffab5952Smrg# HAVE_GROFF_?? can never be true while HAVE_GROFF is false.
766ffab5952Smrg#
767ffab5952SmrgAC_DEFUN([XORG_WITH_GROFF],[
768ffab5952SmrgAC_ARG_VAR([GROFF], [Path to groff command])
769ffab5952Smrgm4_define([_defopt], m4_default([$1], [auto]))
770ffab5952SmrgAC_ARG_WITH(groff,
771ffab5952Smrg	AS_HELP_STRING([--with-groff],
772ffab5952Smrg	   [Use groff to regenerate documentation (default: ]_defopt[)]),
773ffab5952Smrg	   [use_groff=$withval], [use_groff=]_defopt)
774ffab5952Smrgm4_undefine([_defopt])
775ffab5952Smrg
776ffab5952Smrgif test "x$use_groff" = x"auto"; then
777ffab5952Smrg   AC_PATH_PROG([GROFF], [groff])
778ffab5952Smrg   if test "x$GROFF" = "x"; then
779ffab5952Smrg        AC_MSG_WARN([groff not found - documentation targets will be skipped])
780ffab5952Smrg	have_groff=no
781ffab5952Smrg   else
782ffab5952Smrg        have_groff=yes
783ffab5952Smrg   fi
784ffab5952Smrgelif test "x$use_groff" = x"yes" ; then
785ffab5952Smrg   AC_PATH_PROG([GROFF], [groff])
786ffab5952Smrg   if test "x$GROFF" = "x"; then
787ffab5952Smrg        AC_MSG_ERROR([--with-groff=yes specified but groff not found in PATH])
788ffab5952Smrg   fi
789ffab5952Smrg   have_groff=yes
790ffab5952Smrgelif test "x$use_groff" = x"no" ; then
791ffab5952Smrg   if test "x$GROFF" != "x"; then
792ffab5952Smrg      AC_MSG_WARN([ignoring GROFF environment variable since --with-groff=no was specified])
793ffab5952Smrg   fi
794ffab5952Smrg   have_groff=no
795ffab5952Smrgelse
796ffab5952Smrg   AC_MSG_ERROR([--with-groff expects 'yes' or 'no'])
797ffab5952Smrgfi
798ffab5952Smrg
799ffab5952Smrg# We have groff, test for the presence of the macro packages
800ffab5952Smrgif test "x$have_groff" = x"yes"; then
801ffab5952Smrg    AC_MSG_CHECKING([for ${GROFF} -ms macros])
802ffab5952Smrg    if ${GROFF} -ms -I. /dev/null >/dev/null 2>&1 ; then
803ffab5952Smrg        groff_ms_works=yes
804ffab5952Smrg    else
805ffab5952Smrg        groff_ms_works=no
806ffab5952Smrg    fi
807ffab5952Smrg    AC_MSG_RESULT([$groff_ms_works])
808ffab5952Smrg    AC_MSG_CHECKING([for ${GROFF} -mm macros])
809ffab5952Smrg    if ${GROFF} -mm -I. /dev/null >/dev/null 2>&1 ; then
810ffab5952Smrg        groff_mm_works=yes
811ffab5952Smrg    else
812ffab5952Smrg        groff_mm_works=no
813ffab5952Smrg    fi
814ffab5952Smrg    AC_MSG_RESULT([$groff_mm_works])
815ffab5952Smrgfi
816ffab5952Smrg
817ffab5952Smrg# We have groff, test for HTML dependencies, one command per package
818ffab5952Smrgif test "x$have_groff" = x"yes"; then
819ffab5952Smrg   AC_PATH_PROGS(GS_PATH, [gs gswin32c])
820ffab5952Smrg   AC_PATH_PROG(PNMTOPNG_PATH, [pnmtopng])
821ffab5952Smrg   AC_PATH_PROG(PSSELECT_PATH, [psselect])
822ffab5952Smrg   if test "x$GS_PATH" != "x" -a "x$PNMTOPNG_PATH" != "x" -a "x$PSSELECT_PATH" != "x"; then
823ffab5952Smrg      have_groff_html=yes
824ffab5952Smrg   else
825ffab5952Smrg      have_groff_html=no
826ffab5952Smrg      AC_MSG_WARN([grohtml dependencies not found - HTML Documentation skipped. Refer to grohtml man pages])
827ffab5952Smrg   fi
828ffab5952Smrgfi
829ffab5952Smrg
830ffab5952Smrg# Set Automake conditionals for Makefiles
831ffab5952SmrgAM_CONDITIONAL([HAVE_GROFF], [test "$have_groff" = yes])
832ffab5952SmrgAM_CONDITIONAL([HAVE_GROFF_MS], [test "$groff_ms_works" = yes])
833ffab5952SmrgAM_CONDITIONAL([HAVE_GROFF_MM], [test "$groff_mm_works" = yes])
834ffab5952SmrgAM_CONDITIONAL([HAVE_GROFF_HTML], [test "$have_groff_html" = yes])
835ffab5952Smrg]) # XORG_WITH_GROFF
836ffab5952Smrg
83762044635Smrg# XORG_WITH_FOP([MIN-VERSION], [DEFAULT])
83862044635Smrg# ---------------------------------------
839ffab5952Smrg# Minimum version: 1.6.0
840ffab5952Smrg# Minimum version for optional DEFAULT argument: 1.11.0
84162044635Smrg# Minimum version for optional MIN-VERSION argument: 1.15.0
842ffab5952Smrg#
843ffab5952Smrg# Documentation tools are not always available on all platforms and sometimes
844ffab5952Smrg# not at the appropriate level. This macro enables a module to test for the
845ffab5952Smrg# presence of the tool and obtain it's path in separate variables. Coupled with
8466781a5f7Smrg# the --with-fop option, it allows maximum flexibility in making decisions
847ffab5952Smrg# as whether or not to use the fop package. When DEFAULT is not specified,
848ffab5952Smrg# --with-fop assumes 'auto'.
849ffab5952Smrg#
850ffab5952Smrg# Interface to module:
851ffab5952Smrg# HAVE_FOP: 	used in makefiles to conditionally generate documentation
852ffab5952Smrg# FOP:	 	returns the path of the fop program found
853ffab5952Smrg#		returns the path set by the user in the environment
854ffab5952Smrg# --with-fop: 	'yes' user instructs the module to use fop
855ffab5952Smrg#		'no' user instructs the module not to use fop
856ffab5952Smrg#
857ffab5952Smrg# If the user sets the value of FOP, AC_PATH_PROG skips testing the path.
858ffab5952Smrg#
859ffab5952SmrgAC_DEFUN([XORG_WITH_FOP],[
860ffab5952SmrgAC_ARG_VAR([FOP], [Path to fop command])
86162044635Smrgm4_define([_defopt], m4_default([$2], [auto]))
862ffab5952SmrgAC_ARG_WITH(fop,
863ffab5952Smrg	AS_HELP_STRING([--with-fop],
864ffab5952Smrg	   [Use fop to regenerate documentation (default: ]_defopt[)]),
865ffab5952Smrg	   [use_fop=$withval], [use_fop=]_defopt)
866ffab5952Smrgm4_undefine([_defopt])
867ffab5952Smrg
868ffab5952Smrgif test "x$use_fop" = x"auto"; then
869ffab5952Smrg   AC_PATH_PROG([FOP], [fop])
870ffab5952Smrg   if test "x$FOP" = "x"; then
871ffab5952Smrg        AC_MSG_WARN([fop not found - documentation targets will be skipped])
872ffab5952Smrg	have_fop=no
873ffab5952Smrg   else
874ffab5952Smrg        have_fop=yes
875ffab5952Smrg   fi
876ffab5952Smrgelif test "x$use_fop" = x"yes" ; then
877ffab5952Smrg   AC_PATH_PROG([FOP], [fop])
878ffab5952Smrg   if test "x$FOP" = "x"; then
879ffab5952Smrg        AC_MSG_ERROR([--with-fop=yes specified but fop not found in PATH])
880ffab5952Smrg   fi
881ffab5952Smrg   have_fop=yes
882ffab5952Smrgelif test "x$use_fop" = x"no" ; then
883ffab5952Smrg   if test "x$FOP" != "x"; then
884ffab5952Smrg      AC_MSG_WARN([ignoring FOP environment variable since --with-fop=no was specified])
885ffab5952Smrg   fi
886ffab5952Smrg   have_fop=no
887ffab5952Smrgelse
888ffab5952Smrg   AC_MSG_ERROR([--with-fop expects 'yes' or 'no'])
889ffab5952Smrgfi
89062044635Smrg
89162044635Smrg# Test for a minimum version of fop, if provided.
89262044635Smrgm4_ifval([$1],
89362044635Smrg[if test "$have_fop" = yes; then
89462044635Smrg    # scrape the fop version
89562044635Smrg    AC_MSG_CHECKING([for fop minimum version])
89662044635Smrg    fop_version=`$FOP -version 2>/dev/null | cut -d' ' -f3`
89762044635Smrg    AC_MSG_RESULT([$fop_version])
89862044635Smrg    AS_VERSION_COMPARE([$fop_version], [$1],
89962044635Smrg        [if test "x$use_fop" = xauto; then
90062044635Smrg            AC_MSG_WARN([fop version $fop_version found, but $1 needed])
90162044635Smrg            have_fop=no
90262044635Smrg        else
90362044635Smrg            AC_MSG_ERROR([fop version $fop_version found, but $1 needed])
90462044635Smrg        fi])
90562044635Smrgfi])
906ffab5952SmrgAM_CONDITIONAL([HAVE_FOP], [test "$have_fop" = yes])
907ffab5952Smrg]) # XORG_WITH_FOP
908ffab5952Smrg
909c1197e68Smrg# XORG_WITH_M4([MIN-VERSION])
910c1197e68Smrg# ---------------------------
911c1197e68Smrg# Minimum version: 1.19.0
912c1197e68Smrg#
913c1197e68Smrg# This macro attempts to locate an m4 macro processor which supports
914c1197e68Smrg# -I option and is only useful for modules relying on M4 in order to
915c1197e68Smrg# expand macros in source code files.
916c1197e68Smrg#
917c1197e68Smrg# Interface to module:
918c1197e68Smrg# M4:	 	returns the path of the m4 program found
919c1197e68Smrg#		returns the path set by the user in the environment
920c1197e68Smrg#
921c1197e68SmrgAC_DEFUN([XORG_WITH_M4], [
922c1197e68SmrgAC_CACHE_CHECK([for m4 that supports -I option], [ac_cv_path_M4],
923c1197e68Smrg   [AC_PATH_PROGS_FEATURE_CHECK([M4], [m4 gm4],
924c1197e68Smrg       [[$ac_path_M4 -I. /dev/null > /dev/null 2>&1 && \
925c1197e68Smrg         ac_cv_path_M4=$ac_path_M4 ac_path_M4_found=:]],
926c1197e68Smrg   [AC_MSG_ERROR([could not find m4 that supports -I option])],
927c1197e68Smrg   [$PATH:/usr/gnu/bin])])
928c1197e68Smrg
929c1197e68SmrgAC_SUBST([M4], [$ac_cv_path_M4])
930c1197e68Smrg]) # XORG_WITH_M4
931c1197e68Smrg
932ffab5952Smrg# XORG_WITH_PS2PDF([DEFAULT])
933ffab5952Smrg# ----------------
934ffab5952Smrg# Minimum version: 1.6.0
935ffab5952Smrg# Minimum version for optional DEFAULT argument: 1.11.0
936ffab5952Smrg#
937ffab5952Smrg# Documentation tools are not always available on all platforms and sometimes
938ffab5952Smrg# not at the appropriate level. This macro enables a module to test for the
939ffab5952Smrg# presence of the tool and obtain it's path in separate variables. Coupled with
9406781a5f7Smrg# the --with-ps2pdf option, it allows maximum flexibility in making decisions
941ffab5952Smrg# as whether or not to use the ps2pdf package. When DEFAULT is not specified,
942ffab5952Smrg# --with-ps2pdf assumes 'auto'.
943ffab5952Smrg#
944ffab5952Smrg# Interface to module:
945ffab5952Smrg# HAVE_PS2PDF: 	used in makefiles to conditionally generate documentation
946ffab5952Smrg# PS2PDF:	returns the path of the ps2pdf program found
947ffab5952Smrg#		returns the path set by the user in the environment
948ffab5952Smrg# --with-ps2pdf: 'yes' user instructs the module to use ps2pdf
949ffab5952Smrg#		 'no' user instructs the module not to use ps2pdf
950ffab5952Smrg#
951ffab5952Smrg# If the user sets the value of PS2PDF, AC_PATH_PROG skips testing the path.
952ffab5952Smrg#
953ffab5952SmrgAC_DEFUN([XORG_WITH_PS2PDF],[
954ffab5952SmrgAC_ARG_VAR([PS2PDF], [Path to ps2pdf command])
955ffab5952Smrgm4_define([_defopt], m4_default([$1], [auto]))
956ffab5952SmrgAC_ARG_WITH(ps2pdf,
957ffab5952Smrg	AS_HELP_STRING([--with-ps2pdf],
958ffab5952Smrg	   [Use ps2pdf to regenerate documentation (default: ]_defopt[)]),
959ffab5952Smrg	   [use_ps2pdf=$withval], [use_ps2pdf=]_defopt)
960ffab5952Smrgm4_undefine([_defopt])
961ffab5952Smrg
962ffab5952Smrgif test "x$use_ps2pdf" = x"auto"; then
963ffab5952Smrg   AC_PATH_PROG([PS2PDF], [ps2pdf])
964ffab5952Smrg   if test "x$PS2PDF" = "x"; then
965ffab5952Smrg        AC_MSG_WARN([ps2pdf not found - documentation targets will be skipped])
966ffab5952Smrg	have_ps2pdf=no
967ffab5952Smrg   else
968ffab5952Smrg        have_ps2pdf=yes
969ffab5952Smrg   fi
970ffab5952Smrgelif test "x$use_ps2pdf" = x"yes" ; then
971ffab5952Smrg   AC_PATH_PROG([PS2PDF], [ps2pdf])
972ffab5952Smrg   if test "x$PS2PDF" = "x"; then
973ffab5952Smrg        AC_MSG_ERROR([--with-ps2pdf=yes specified but ps2pdf not found in PATH])
974ffab5952Smrg   fi
975ffab5952Smrg   have_ps2pdf=yes
976ffab5952Smrgelif test "x$use_ps2pdf" = x"no" ; then
977ffab5952Smrg   if test "x$PS2PDF" != "x"; then
978ffab5952Smrg      AC_MSG_WARN([ignoring PS2PDF environment variable since --with-ps2pdf=no was specified])
979ffab5952Smrg   fi
980ffab5952Smrg   have_ps2pdf=no
981ffab5952Smrgelse
982ffab5952Smrg   AC_MSG_ERROR([--with-ps2pdf expects 'yes' or 'no'])
983ffab5952Smrgfi
984ffab5952SmrgAM_CONDITIONAL([HAVE_PS2PDF], [test "$have_ps2pdf" = yes])
985ffab5952Smrg]) # XORG_WITH_PS2PDF
986ffab5952Smrg
987ffab5952Smrg# XORG_ENABLE_DOCS (enable_docs=yes)
988ffab5952Smrg# ----------------
989ffab5952Smrg# Minimum version: 1.6.0
990ffab5952Smrg#
991ffab5952Smrg# Documentation tools are not always available on all platforms and sometimes
992ffab5952Smrg# not at the appropriate level. This macro enables a builder to skip all
993ffab5952Smrg# documentation targets except traditional man pages.
994ffab5952Smrg# Combined with the specific tool checking macros XORG_WITH_*, it provides
9956781a5f7Smrg# maximum flexibility in controlling documentation building.
996ffab5952Smrg# Refer to:
997ffab5952Smrg# XORG_WITH_XMLTO         --with-xmlto
998ffab5952Smrg# XORG_WITH_ASCIIDOC      --with-asciidoc
999ffab5952Smrg# XORG_WITH_DOXYGEN       --with-doxygen
1000ffab5952Smrg# XORG_WITH_FOP           --with-fop
1001ffab5952Smrg# XORG_WITH_GROFF         --with-groff
1002ffab5952Smrg# XORG_WITH_PS2PDF        --with-ps2pdf
1003ffab5952Smrg#
1004ffab5952Smrg# Interface to module:
1005ffab5952Smrg# ENABLE_DOCS: 	  used in makefiles to conditionally generate documentation
1006ffab5952Smrg# --enable-docs: 'yes' user instructs the module to generate docs
1007ffab5952Smrg#		 'no' user instructs the module not to generate docs
1008ffab5952Smrg# parm1:	specify the default value, yes or no.
1009ffab5952Smrg#
1010ffab5952SmrgAC_DEFUN([XORG_ENABLE_DOCS],[
101162044635Smrgm4_define([docs_default], m4_default([$1], [yes]))
1012ffab5952SmrgAC_ARG_ENABLE(docs,
1013ffab5952Smrg	AS_HELP_STRING([--enable-docs],
101462044635Smrg	   [Enable building the documentation (default: ]docs_default[)]),
101562044635Smrg	   [build_docs=$enableval], [build_docs=]docs_default)
101662044635Smrgm4_undefine([docs_default])
1017ffab5952SmrgAM_CONDITIONAL(ENABLE_DOCS, [test x$build_docs = xyes])
1018ffab5952SmrgAC_MSG_CHECKING([whether to build documentation])
1019ffab5952SmrgAC_MSG_RESULT([$build_docs])
1020ffab5952Smrg]) # XORG_ENABLE_DOCS
1021ffab5952Smrg
1022ffab5952Smrg# XORG_ENABLE_DEVEL_DOCS (enable_devel_docs=yes)
1023ffab5952Smrg# ----------------
1024ffab5952Smrg# Minimum version: 1.6.0
1025ffab5952Smrg#
1026ffab5952Smrg# This macro enables a builder to skip all developer documentation.
1027ffab5952Smrg# Combined with the specific tool checking macros XORG_WITH_*, it provides
10286781a5f7Smrg# maximum flexibility in controlling documentation building.
1029ffab5952Smrg# Refer to:
1030ffab5952Smrg# XORG_WITH_XMLTO         --with-xmlto
1031ffab5952Smrg# XORG_WITH_ASCIIDOC      --with-asciidoc
1032ffab5952Smrg# XORG_WITH_DOXYGEN       --with-doxygen
1033ffab5952Smrg# XORG_WITH_FOP           --with-fop
1034ffab5952Smrg# XORG_WITH_GROFF         --with-groff
1035ffab5952Smrg# XORG_WITH_PS2PDF        --with-ps2pdf
1036ffab5952Smrg#
1037ffab5952Smrg# Interface to module:
1038ffab5952Smrg# ENABLE_DEVEL_DOCS:	used in makefiles to conditionally generate developer docs
1039ffab5952Smrg# --enable-devel-docs:	'yes' user instructs the module to generate developer docs
1040ffab5952Smrg#			'no' user instructs the module not to generate developer docs
1041ffab5952Smrg# parm1:		specify the default value, yes or no.
1042ffab5952Smrg#
1043ffab5952SmrgAC_DEFUN([XORG_ENABLE_DEVEL_DOCS],[
1044ffab5952Smrgm4_define([devel_default], m4_default([$1], [yes]))
1045ffab5952SmrgAC_ARG_ENABLE(devel-docs,
1046ffab5952Smrg	AS_HELP_STRING([--enable-devel-docs],
1047ffab5952Smrg	   [Enable building the developer documentation (default: ]devel_default[)]),
1048ffab5952Smrg	   [build_devel_docs=$enableval], [build_devel_docs=]devel_default)
1049ffab5952Smrgm4_undefine([devel_default])
1050ffab5952SmrgAM_CONDITIONAL(ENABLE_DEVEL_DOCS, [test x$build_devel_docs = xyes])
1051ffab5952SmrgAC_MSG_CHECKING([whether to build developer documentation])
1052ffab5952SmrgAC_MSG_RESULT([$build_devel_docs])
1053ffab5952Smrg]) # XORG_ENABLE_DEVEL_DOCS
1054ffab5952Smrg
1055ffab5952Smrg# XORG_ENABLE_SPECS (enable_specs=yes)
1056ffab5952Smrg# ----------------
1057ffab5952Smrg# Minimum version: 1.6.0
1058ffab5952Smrg#
1059ffab5952Smrg# This macro enables a builder to skip all functional specification targets.
1060ffab5952Smrg# Combined with the specific tool checking macros XORG_WITH_*, it provides
10616781a5f7Smrg# maximum flexibility in controlling documentation building.
1062ffab5952Smrg# Refer to:
1063ffab5952Smrg# XORG_WITH_XMLTO         --with-xmlto
1064ffab5952Smrg# XORG_WITH_ASCIIDOC      --with-asciidoc
1065ffab5952Smrg# XORG_WITH_DOXYGEN       --with-doxygen
1066ffab5952Smrg# XORG_WITH_FOP           --with-fop
1067ffab5952Smrg# XORG_WITH_GROFF         --with-groff
1068ffab5952Smrg# XORG_WITH_PS2PDF        --with-ps2pdf
1069ffab5952Smrg#
1070ffab5952Smrg# Interface to module:
1071ffab5952Smrg# ENABLE_SPECS:		used in makefiles to conditionally generate specs
1072ffab5952Smrg# --enable-specs:	'yes' user instructs the module to generate specs
1073ffab5952Smrg#			'no' user instructs the module not to generate specs
1074ffab5952Smrg# parm1:		specify the default value, yes or no.
1075ffab5952Smrg#
1076ffab5952SmrgAC_DEFUN([XORG_ENABLE_SPECS],[
1077ffab5952Smrgm4_define([spec_default], m4_default([$1], [yes]))
1078ffab5952SmrgAC_ARG_ENABLE(specs,
1079ffab5952Smrg	AS_HELP_STRING([--enable-specs],
1080ffab5952Smrg	   [Enable building the specs (default: ]spec_default[)]),
1081ffab5952Smrg	   [build_specs=$enableval], [build_specs=]spec_default)
1082ffab5952Smrgm4_undefine([spec_default])
1083ffab5952SmrgAM_CONDITIONAL(ENABLE_SPECS, [test x$build_specs = xyes])
1084ffab5952SmrgAC_MSG_CHECKING([whether to build functional specifications])
1085ffab5952SmrgAC_MSG_RESULT([$build_specs])
1086ffab5952Smrg]) # XORG_ENABLE_SPECS
1087ffab5952Smrg
108862044635Smrg# XORG_ENABLE_UNIT_TESTS (enable_unit_tests=auto)
108962044635Smrg# ----------------------------------------------
109062044635Smrg# Minimum version: 1.13.0
109162044635Smrg#
109262044635Smrg# This macro enables a builder to enable/disable unit testing
109362044635Smrg# It makes no assumption about the test cases implementation
109462044635Smrg# Test cases may or may not use Automake "Support for test suites"
109562044635Smrg# They may or may not use the software utility library GLib
109662044635Smrg#
109762044635Smrg# When used in conjunction with XORG_WITH_GLIB, use both AM_CONDITIONAL
109862044635Smrg# ENABLE_UNIT_TESTS and HAVE_GLIB. Not all unit tests may use glib.
109962044635Smrg# The variable enable_unit_tests is used by other macros in this file.
110062044635Smrg#
110162044635Smrg# Interface to module:
110262044635Smrg# ENABLE_UNIT_TESTS:	used in makefiles to conditionally build tests
110362044635Smrg# enable_unit_tests:    used in configure.ac for additional configuration
110462044635Smrg# --enable-unit-tests:	'yes' user instructs the module to build tests
110562044635Smrg#			'no' user instructs the module not to build tests
110662044635Smrg# parm1:		specify the default value, yes or no.
110762044635Smrg#
110862044635SmrgAC_DEFUN([XORG_ENABLE_UNIT_TESTS],[
110962044635SmrgAC_BEFORE([$0], [XORG_WITH_GLIB])
111062044635SmrgAC_BEFORE([$0], [XORG_LD_WRAP])
11113ae17ff1SmrgAC_REQUIRE([XORG_MEMORY_CHECK_FLAGS])
111262044635Smrgm4_define([_defopt], m4_default([$1], [auto]))
111362044635SmrgAC_ARG_ENABLE(unit-tests, AS_HELP_STRING([--enable-unit-tests],
111462044635Smrg	[Enable building unit test cases (default: ]_defopt[)]),
111562044635Smrg	[enable_unit_tests=$enableval], [enable_unit_tests=]_defopt)
111662044635Smrgm4_undefine([_defopt])
111762044635SmrgAM_CONDITIONAL(ENABLE_UNIT_TESTS, [test "x$enable_unit_tests" != xno])
111862044635SmrgAC_MSG_CHECKING([whether to build unit test cases])
111962044635SmrgAC_MSG_RESULT([$enable_unit_tests])
112062044635Smrg]) # XORG_ENABLE_UNIT_TESTS
112162044635Smrg
11223ae17ff1Smrg# XORG_ENABLE_INTEGRATION_TESTS (enable_unit_tests=auto)
11233ae17ff1Smrg# ------------------------------------------------------
11243ae17ff1Smrg# Minimum version: 1.17.0
11253ae17ff1Smrg#
11263ae17ff1Smrg# This macro enables a builder to enable/disable integration testing
11273ae17ff1Smrg# It makes no assumption about the test cases' implementation
11283ae17ff1Smrg# Test cases may or may not use Automake "Support for test suites"
11293ae17ff1Smrg#
11303ae17ff1Smrg# Please see XORG_ENABLE_UNIT_TESTS for unit test support. Unit test support
11313ae17ff1Smrg# usually requires less dependencies and may be built and run under less
11323ae17ff1Smrg# stringent environments than integration tests.
11333ae17ff1Smrg#
11343ae17ff1Smrg# Interface to module:
11353ae17ff1Smrg# ENABLE_INTEGRATION_TESTS:   used in makefiles to conditionally build tests
11363ae17ff1Smrg# enable_integration_tests:   used in configure.ac for additional configuration
11373ae17ff1Smrg# --enable-integration-tests: 'yes' user instructs the module to build tests
11383ae17ff1Smrg#                             'no' user instructs the module not to build tests
11393ae17ff1Smrg# parm1:                      specify the default value, yes or no.
11403ae17ff1Smrg#
11413ae17ff1SmrgAC_DEFUN([XORG_ENABLE_INTEGRATION_TESTS],[
11423ae17ff1SmrgAC_REQUIRE([XORG_MEMORY_CHECK_FLAGS])
11433ae17ff1Smrgm4_define([_defopt], m4_default([$1], [auto]))
11443ae17ff1SmrgAC_ARG_ENABLE(integration-tests, AS_HELP_STRING([--enable-integration-tests],
11453ae17ff1Smrg	[Enable building integration test cases (default: ]_defopt[)]),
11463ae17ff1Smrg	[enable_integration_tests=$enableval],
11473ae17ff1Smrg	[enable_integration_tests=]_defopt)
11483ae17ff1Smrgm4_undefine([_defopt])
11493ae17ff1SmrgAM_CONDITIONAL([ENABLE_INTEGRATION_TESTS],
11503ae17ff1Smrg	[test "x$enable_integration_tests" != xno])
11513ae17ff1SmrgAC_MSG_CHECKING([whether to build unit test cases])
11523ae17ff1SmrgAC_MSG_RESULT([$enable_integration_tests])
11533ae17ff1Smrg]) # XORG_ENABLE_INTEGRATION_TESTS
11543ae17ff1Smrg
115562044635Smrg# XORG_WITH_GLIB([MIN-VERSION], [DEFAULT])
115662044635Smrg# ----------------------------------------
115762044635Smrg# Minimum version: 1.13.0
115862044635Smrg#
115962044635Smrg# GLib is a library which provides advanced data structures and functions.
116062044635Smrg# This macro enables a module to test for the presence of Glib.
116162044635Smrg#
116262044635Smrg# When used with ENABLE_UNIT_TESTS, it is assumed GLib is used for unit testing.
116362044635Smrg# Otherwise the value of $enable_unit_tests is blank.
116462044635Smrg#
11653ae17ff1Smrg# Please see XORG_ENABLE_INTEGRATION_TESTS for integration test support. Unit
11663ae17ff1Smrg# test support usually requires less dependencies and may be built and run under
11673ae17ff1Smrg# less stringent environments than integration tests.
11683ae17ff1Smrg#
116962044635Smrg# Interface to module:
117062044635Smrg# HAVE_GLIB: used in makefiles to conditionally build targets
117162044635Smrg# with_glib: used in configure.ac to know if GLib has been found
117262044635Smrg# --with-glib:	'yes' user instructs the module to use glib
117362044635Smrg#		'no' user instructs the module not to use glib
117462044635Smrg#
117562044635SmrgAC_DEFUN([XORG_WITH_GLIB],[
117662044635SmrgAC_REQUIRE([PKG_PROG_PKG_CONFIG])
117762044635Smrgm4_define([_defopt], m4_default([$2], [auto]))
117862044635SmrgAC_ARG_WITH(glib, AS_HELP_STRING([--with-glib],
117962044635Smrg	[Use GLib library for unit testing (default: ]_defopt[)]),
118062044635Smrg	[with_glib=$withval], [with_glib=]_defopt)
118162044635Smrgm4_undefine([_defopt])
118262044635Smrg
118362044635Smrghave_glib=no
118462044635Smrg# Do not probe GLib if user explicitly disabled unit testing
118562044635Smrgif test "x$enable_unit_tests" != x"no"; then
118662044635Smrg  # Do not probe GLib if user explicitly disabled it
118762044635Smrg  if test "x$with_glib" != x"no"; then
118862044635Smrg    m4_ifval(
118962044635Smrg      [$1],
119062044635Smrg      [PKG_CHECK_MODULES([GLIB], [glib-2.0 >= $1], [have_glib=yes], [have_glib=no])],
119162044635Smrg      [PKG_CHECK_MODULES([GLIB], [glib-2.0], [have_glib=yes], [have_glib=no])]
119262044635Smrg    )
119362044635Smrg  fi
119462044635Smrgfi
119562044635Smrg
119662044635Smrg# Not having GLib when unit testing has been explicitly requested is an error
119762044635Smrgif test "x$enable_unit_tests" = x"yes"; then
119862044635Smrg  if test "x$have_glib" = x"no"; then
119962044635Smrg    AC_MSG_ERROR([--enable-unit-tests=yes specified but glib-2.0 not found])
120062044635Smrg  fi
120162044635Smrgfi
120262044635Smrg
120362044635Smrg# Having unit testing disabled when GLib has been explicitly requested is an error
120462044635Smrgif test "x$enable_unit_tests" = x"no"; then
120562044635Smrg  if test "x$with_glib" = x"yes"; then
120662044635Smrg    AC_MSG_ERROR([--enable-unit-tests=yes specified but glib-2.0 not found])
120762044635Smrg  fi
120862044635Smrgfi
120962044635Smrg
121062044635Smrg# Not having GLib when it has been explicitly requested is an error
121162044635Smrgif test "x$with_glib" = x"yes"; then
121262044635Smrg  if test "x$have_glib" = x"no"; then
121362044635Smrg    AC_MSG_ERROR([--with-glib=yes specified but glib-2.0 not found])
121462044635Smrg  fi
121562044635Smrgfi
121662044635Smrg
121762044635SmrgAM_CONDITIONAL([HAVE_GLIB], [test "$have_glib" = yes])
121862044635Smrg]) # XORG_WITH_GLIB
121962044635Smrg
12203ae17ff1Smrg# XORG_LD_WRAP([required|optional])
12213ae17ff1Smrg# ---------------------------------
122262044635Smrg# Minimum version: 1.13.0
122362044635Smrg#
122462044635Smrg# Check if linker supports -wrap, passed via compiler flags
122562044635Smrg#
122662044635Smrg# When used with ENABLE_UNIT_TESTS, it is assumed -wrap is used for unit testing.
122762044635Smrg# Otherwise the value of $enable_unit_tests is blank.
122862044635Smrg#
12293ae17ff1Smrg# Argument added in 1.16.0 - default is "required", to match existing behavior
12303ae17ff1Smrg# of returning an error if enable_unit_tests is yes, and ld -wrap is not
12313ae17ff1Smrg# available, an argument of "optional" allows use when some unit tests require
12323ae17ff1Smrg# ld -wrap and others do not.
12333ae17ff1Smrg#
123462044635SmrgAC_DEFUN([XORG_LD_WRAP],[
12353ae17ff1SmrgXORG_CHECK_LINKER_FLAGS([-Wl,-wrap,exit],[have_ld_wrap=yes],[have_ld_wrap=no],
12363ae17ff1Smrg    [AC_LANG_PROGRAM([#include <stdlib.h>
12373ae17ff1Smrg                      void __wrap_exit(int status) { return; }],
12383ae17ff1Smrg                     [exit(0);])])
123962044635Smrg# Not having ld wrap when unit testing has been explicitly requested is an error
12403ae17ff1Smrgif test "x$enable_unit_tests" = x"yes" -a "x$1" != "xoptional"; then
124162044635Smrg  if test "x$have_ld_wrap" = x"no"; then
124262044635Smrg    AC_MSG_ERROR([--enable-unit-tests=yes specified but ld -wrap support is not available])
124362044635Smrg  fi
124462044635Smrgfi
124562044635SmrgAM_CONDITIONAL([HAVE_LD_WRAP], [test "$have_ld_wrap" = yes])
124662044635Smrg#
124762044635Smrg]) # XORG_LD_WRAP
124862044635Smrg
124962044635Smrg# XORG_CHECK_LINKER_FLAGS
125062044635Smrg# -----------------------
125162044635Smrg# SYNOPSIS
125262044635Smrg#
12533ae17ff1Smrg#   XORG_CHECK_LINKER_FLAGS(FLAGS, [ACTION-SUCCESS], [ACTION-FAILURE], [PROGRAM-SOURCE])
125462044635Smrg#
125562044635Smrg# DESCRIPTION
125662044635Smrg#
125762044635Smrg#   Check whether the given linker FLAGS work with the current language's
125862044635Smrg#   linker, or whether they give an error.
125962044635Smrg#
126062044635Smrg#   ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
126162044635Smrg#   success/failure.
126262044635Smrg#
12633ae17ff1Smrg#   PROGRAM-SOURCE is the program source to link with, if needed
12643ae17ff1Smrg#
126562044635Smrg#   NOTE: Based on AX_CHECK_COMPILER_FLAGS.
126662044635Smrg#
126762044635Smrg# LICENSE
126862044635Smrg#
126962044635Smrg#   Copyright (c) 2009 Mike Frysinger <vapier@gentoo.org>
127062044635Smrg#   Copyright (c) 2009 Steven G. Johnson <stevenj@alum.mit.edu>
127162044635Smrg#   Copyright (c) 2009 Matteo Frigo
127262044635Smrg#
127362044635Smrg#   This program is free software: you can redistribute it and/or modify it
127462044635Smrg#   under the terms of the GNU General Public License as published by the
127562044635Smrg#   Free Software Foundation, either version 3 of the License, or (at your
127662044635Smrg#   option) any later version.
127762044635Smrg#
127862044635Smrg#   This program is distributed in the hope that it will be useful, but
127962044635Smrg#   WITHOUT ANY WARRANTY; without even the implied warranty of
128062044635Smrg#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
128162044635Smrg#   Public License for more details.
128262044635Smrg#
128362044635Smrg#   You should have received a copy of the GNU General Public License along
128462044635Smrg#   with this program. If not, see <http://www.gnu.org/licenses/>.
128562044635Smrg#
128662044635Smrg#   As a special exception, the respective Autoconf Macro's copyright owner
128762044635Smrg#   gives unlimited permission to copy, distribute and modify the configure
128862044635Smrg#   scripts that are the output of Autoconf when processing the Macro. You
128962044635Smrg#   need not follow the terms of the GNU General Public License when using
129062044635Smrg#   or distributing such scripts, even though portions of the text of the
129162044635Smrg#   Macro appear in them. The GNU General Public License (GPL) does govern
129262044635Smrg#   all other use of the material that constitutes the Autoconf Macro.
129362044635Smrg#
129462044635Smrg#   This special exception to the GPL applies to versions of the Autoconf
129562044635Smrg#   Macro released by the Autoconf Archive. When you make and distribute a
129662044635Smrg#   modified version of the Autoconf Macro, you may extend this special
129762044635Smrg#   exception to the GPL to apply to your modified version as well.#
129862044635SmrgAC_DEFUN([XORG_CHECK_LINKER_FLAGS],
129962044635Smrg[AC_MSG_CHECKING([whether the linker accepts $1])
130062044635Smrgdnl Some hackery here since AC_CACHE_VAL can't handle a non-literal varname:
130162044635SmrgAS_LITERAL_IF([$1],
130262044635Smrg  [AC_CACHE_VAL(AS_TR_SH(xorg_cv_linker_flags_[$1]), [
130362044635Smrg      ax_save_FLAGS=$LDFLAGS
130462044635Smrg      LDFLAGS="$1"
13053ae17ff1Smrg      AC_LINK_IFELSE([m4_default([$4],[AC_LANG_PROGRAM()])],
130662044635Smrg        AS_TR_SH(xorg_cv_linker_flags_[$1])=yes,
130762044635Smrg        AS_TR_SH(xorg_cv_linker_flags_[$1])=no)
130862044635Smrg      LDFLAGS=$ax_save_FLAGS])],
130962044635Smrg  [ax_save_FLAGS=$LDFLAGS
131062044635Smrg   LDFLAGS="$1"
131162044635Smrg   AC_LINK_IFELSE([AC_LANG_PROGRAM()],
131262044635Smrg     eval AS_TR_SH(xorg_cv_linker_flags_[$1])=yes,
131362044635Smrg     eval AS_TR_SH(xorg_cv_linker_flags_[$1])=no)
131462044635Smrg   LDFLAGS=$ax_save_FLAGS])
131562044635Smrgeval xorg_check_linker_flags=$AS_TR_SH(xorg_cv_linker_flags_[$1])
131662044635SmrgAC_MSG_RESULT($xorg_check_linker_flags)
131762044635Smrgif test "x$xorg_check_linker_flags" = xyes; then
131862044635Smrg	m4_default([$2], :)
131962044635Smrgelse
132062044635Smrg	m4_default([$3], :)
132162044635Smrgfi
132262044635Smrg]) # XORG_CHECK_LINKER_FLAGS
132362044635Smrg
13243ae17ff1Smrg# XORG_MEMORY_CHECK_FLAGS
13253ae17ff1Smrg# -----------------------
13263ae17ff1Smrg# Minimum version: 1.16.0
13273ae17ff1Smrg#
13283ae17ff1Smrg# This macro attempts to find appropriate memory checking functionality
13293ae17ff1Smrg# for various platforms which unit testing code may use to catch various
13303ae17ff1Smrg# forms of memory allocation and access errors in testing.
13313ae17ff1Smrg#
13323ae17ff1Smrg# Interface to module:
13333ae17ff1Smrg# XORG_MALLOC_DEBUG_ENV - environment variables to set to enable debugging
13343ae17ff1Smrg#                         Usually added to TESTS_ENVIRONMENT in Makefile.am
13353ae17ff1Smrg#
13363ae17ff1Smrg# If the user sets the value of XORG_MALLOC_DEBUG_ENV, it is used verbatim.
13373ae17ff1Smrg#
13383ae17ff1SmrgAC_DEFUN([XORG_MEMORY_CHECK_FLAGS],[
13393ae17ff1Smrg
13403ae17ff1SmrgAC_REQUIRE([AC_CANONICAL_HOST])
13413ae17ff1SmrgAC_ARG_VAR([XORG_MALLOC_DEBUG_ENV],
13423ae17ff1Smrg           [Environment variables to enable memory checking in tests])
13433ae17ff1Smrg
13443ae17ff1Smrg# Check for different types of support on different platforms
13453ae17ff1Smrgcase $host_os in
13463ae17ff1Smrg    solaris*)
13473ae17ff1Smrg        AC_CHECK_LIB([umem], [umem_alloc],
13483ae17ff1Smrg            [malloc_debug_env='LD_PRELOAD=libumem.so UMEM_DEBUG=default'])
13493ae17ff1Smrg        ;;
13503ae17ff1Smrg    *-gnu*) # GNU libc - Value is used as a single byte bit pattern,
13513ae17ff1Smrg        # both directly and inverted, so should not be 0 or 255.
13523ae17ff1Smrg        malloc_debug_env='MALLOC_PERTURB_=15'
13533ae17ff1Smrg        ;;
13543ae17ff1Smrg    darwin*)
13553ae17ff1Smrg        malloc_debug_env='MallocPreScribble=1 MallocScribble=1 DYLD_INSERT_LIBRARIES=/usr/lib/libgmalloc.dylib'
13563ae17ff1Smrg        ;;
13573ae17ff1Smrg    *bsd*)
13583ae17ff1Smrg        malloc_debug_env='MallocPreScribble=1 MallocScribble=1'
13593ae17ff1Smrg        ;;
13603ae17ff1Smrgesac
13613ae17ff1Smrg
13623ae17ff1Smrg# User supplied flags override default flags
13633ae17ff1Smrgif test "x$XORG_MALLOC_DEBUG_ENV" != "x"; then
13643ae17ff1Smrg    malloc_debug_env="$XORG_MALLOC_DEBUG_ENV"
13653ae17ff1Smrgfi
13663ae17ff1Smrg
13673ae17ff1SmrgAC_SUBST([XORG_MALLOC_DEBUG_ENV],[$malloc_debug_env])
13683ae17ff1Smrg]) # XORG_WITH_LINT
13693ae17ff1Smrg
1370ffab5952Smrg# XORG_CHECK_MALLOC_ZERO
1371ffab5952Smrg# ----------------------
1372ffab5952Smrg# Minimum version: 1.0.0
1373ffab5952Smrg#
1374ffab5952Smrg# Defines {MALLOC,XMALLOC,XTMALLOC}_ZERO_CFLAGS appropriately if
1375ffab5952Smrg# malloc(0) returns NULL.  Packages should add one of these cflags to
1376ffab5952Smrg# their AM_CFLAGS (or other appropriate *_CFLAGS) to use them.
1377ea972ba2Smrg#
1378ea972ba2Smrg# No longer actually tests since there is no guarantee applications will
1379ea972ba2Smrg# run with the same malloc implementation we tested against, and the cost
1380ea972ba2Smrg# of always ensuring the size passed to malloc is non-zero is minimal now.
1381ea972ba2Smrg# Still allows builders to override when they have complete control over
1382ea972ba2Smrg# which malloc implementation will be used.
1383ffab5952SmrgAC_DEFUN([XORG_CHECK_MALLOC_ZERO],[
1384ffab5952SmrgAC_ARG_ENABLE(malloc0returnsnull,
1385ffab5952Smrg	AS_HELP_STRING([--enable-malloc0returnsnull],
1386ea972ba2Smrg		       [assume malloc(0) can return NULL (default: yes)]),
1387ffab5952Smrg	[MALLOC_ZERO_RETURNS_NULL=$enableval],
1388ea972ba2Smrg	[MALLOC_ZERO_RETURNS_NULL=yes])
1389ea972ba2Smrg
1390ea972ba2SmrgAC_MSG_CHECKING([whether to act as if malloc(0) can return NULL])
1391ffab5952SmrgAC_MSG_RESULT([$MALLOC_ZERO_RETURNS_NULL])
1392ffab5952Smrg
1393ffab5952Smrgif test "x$MALLOC_ZERO_RETURNS_NULL" = xyes; then
1394ffab5952Smrg	MALLOC_ZERO_CFLAGS="-DMALLOC_0_RETURNS_NULL"
1395ffab5952Smrg	XMALLOC_ZERO_CFLAGS=$MALLOC_ZERO_CFLAGS
1396ffab5952Smrg	XTMALLOC_ZERO_CFLAGS="$MALLOC_ZERO_CFLAGS -DXTMALLOC_BC"
1397ffab5952Smrgelse
1398ffab5952Smrg	MALLOC_ZERO_CFLAGS=""
1399ffab5952Smrg	XMALLOC_ZERO_CFLAGS=""
1400ffab5952Smrg	XTMALLOC_ZERO_CFLAGS=""
1401ffab5952Smrgfi
1402ffab5952Smrg
1403ffab5952SmrgAC_SUBST([MALLOC_ZERO_CFLAGS])
1404ffab5952SmrgAC_SUBST([XMALLOC_ZERO_CFLAGS])
1405ffab5952SmrgAC_SUBST([XTMALLOC_ZERO_CFLAGS])
1406ffab5952Smrg]) # XORG_CHECK_MALLOC_ZERO
1407ffab5952Smrg
1408ffab5952Smrg# XORG_WITH_LINT()
1409ffab5952Smrg# ----------------
1410ffab5952Smrg# Minimum version: 1.1.0
1411ffab5952Smrg#
1412ffab5952Smrg# This macro enables the use of a tool that flags some suspicious and
1413ffab5952Smrg# non-portable constructs (likely to be bugs) in C language source code.
1414ffab5952Smrg# It will attempt to locate the tool and use appropriate options.
1415ffab5952Smrg# There are various lint type tools on different platforms.
1416ffab5952Smrg#
1417ffab5952Smrg# Interface to module:
1418ffab5952Smrg# LINT:		returns the path to the tool found on the platform
1419ffab5952Smrg#		or the value set to LINT on the configure cmd line
1420ffab5952Smrg#		also an Automake conditional
1421ffab5952Smrg# LINT_FLAGS:	an Automake variable with appropriate flags
1422ffab5952Smrg#
1423ffab5952Smrg# --with-lint:	'yes' user instructs the module to use lint
1424ffab5952Smrg#		'no' user instructs the module not to use lint (default)
1425ffab5952Smrg#
1426ffab5952Smrg# If the user sets the value of LINT, AC_PATH_PROG skips testing the path.
1427ffab5952Smrg# If the user sets the value of LINT_FLAGS, they are used verbatim.
1428ffab5952Smrg#
1429ffab5952SmrgAC_DEFUN([XORG_WITH_LINT],[
1430ffab5952Smrg
1431ffab5952SmrgAC_ARG_VAR([LINT], [Path to a lint-style command])
1432ffab5952SmrgAC_ARG_VAR([LINT_FLAGS], [Flags for the lint-style command])
1433ffab5952SmrgAC_ARG_WITH(lint, [AS_HELP_STRING([--with-lint],
1434ffab5952Smrg		[Use a lint-style source code checker (default: disabled)])],
1435ffab5952Smrg		[use_lint=$withval], [use_lint=no])
1436ffab5952Smrg
1437ffab5952Smrg# Obtain platform specific info like program name and options
1438ffab5952Smrg# The lint program on FreeBSD and NetBSD is different from the one on Solaris
1439ffab5952Smrgcase $host_os in
1440ffab5952Smrg  *linux* | *openbsd* | kfreebsd*-gnu | darwin* | cygwin*)
1441ffab5952Smrg	lint_name=splint
1442ffab5952Smrg	lint_options="-badflag"
1443ffab5952Smrg	;;
1444ffab5952Smrg  *freebsd* | *netbsd*)
1445ffab5952Smrg	lint_name=lint
1446ffab5952Smrg	lint_options="-u -b"
1447ffab5952Smrg	;;
1448ffab5952Smrg  *solaris*)
1449ffab5952Smrg	lint_name=lint
1450ffab5952Smrg	lint_options="-u -b -h -erroff=E_INDISTING_FROM_TRUNC2"
1451ffab5952Smrg	;;
1452ffab5952Smrgesac
1453ffab5952Smrg
1454ffab5952Smrg# Test for the presence of the program (either guessed by the code or spelled out by the user)
1455ffab5952Smrgif test "x$use_lint" = x"yes" ; then
1456ffab5952Smrg   AC_PATH_PROG([LINT], [$lint_name])
1457ffab5952Smrg   if test "x$LINT" = "x"; then
1458ffab5952Smrg        AC_MSG_ERROR([--with-lint=yes specified but lint-style tool not found in PATH])
1459ffab5952Smrg   fi
1460ffab5952Smrgelif test "x$use_lint" = x"no" ; then
1461ffab5952Smrg   if test "x$LINT" != "x"; then
1462ffab5952Smrg      AC_MSG_WARN([ignoring LINT environment variable since --with-lint=no was specified])
1463ffab5952Smrg   fi
1464ffab5952Smrgelse
1465ffab5952Smrg   AC_MSG_ERROR([--with-lint expects 'yes' or 'no'. Use LINT variable to specify path.])
1466ffab5952Smrgfi
1467ffab5952Smrg
1468ffab5952Smrg# User supplied flags override default flags
1469ffab5952Smrgif test "x$LINT_FLAGS" != "x"; then
1470ffab5952Smrg   lint_options=$LINT_FLAGS
1471ffab5952Smrgfi
1472ffab5952Smrg
1473ffab5952SmrgAC_SUBST([LINT_FLAGS],[$lint_options])
1474ffab5952SmrgAM_CONDITIONAL(LINT, [test "x$LINT" != x])
1475ffab5952Smrg
1476ffab5952Smrg]) # XORG_WITH_LINT
1477ffab5952Smrg
1478ffab5952Smrg# XORG_LINT_LIBRARY(LIBNAME)
1479ffab5952Smrg# --------------------------
1480ffab5952Smrg# Minimum version: 1.1.0
1481ffab5952Smrg#
1482ffab5952Smrg# Sets up flags for building lint libraries for checking programs that call
1483ffab5952Smrg# functions in the library.
1484ffab5952Smrg#
1485ffab5952Smrg# Interface to module:
1486ffab5952Smrg# LINTLIB		- Automake variable with the name of lint library file to make
1487ffab5952Smrg# MAKE_LINT_LIB		- Automake conditional
1488ffab5952Smrg#
1489ffab5952Smrg# --enable-lint-library:  - 'yes' user instructs the module to created a lint library
1490ffab5952Smrg#			  - 'no' user instructs the module not to create a lint library (default)
1491ffab5952Smrg
1492ffab5952SmrgAC_DEFUN([XORG_LINT_LIBRARY],[
1493ffab5952SmrgAC_REQUIRE([XORG_WITH_LINT])
1494ffab5952SmrgAC_ARG_ENABLE(lint-library, [AS_HELP_STRING([--enable-lint-library],
1495ffab5952Smrg	[Create lint library (default: disabled)])],
1496ffab5952Smrg	[make_lint_lib=$enableval], [make_lint_lib=no])
1497ffab5952Smrg
1498ffab5952Smrgif test "x$make_lint_lib" = x"yes" ; then
1499ffab5952Smrg   LINTLIB=llib-l$1.ln
1500ffab5952Smrg   if test "x$LINT" = "x"; then
1501ffab5952Smrg        AC_MSG_ERROR([Cannot make lint library without --with-lint])
1502ffab5952Smrg   fi
1503ffab5952Smrgelif test "x$make_lint_lib" != x"no" ; then
1504ffab5952Smrg   AC_MSG_ERROR([--enable-lint-library expects 'yes' or 'no'.])
1505ffab5952Smrgfi
1506ffab5952Smrg
1507ffab5952SmrgAC_SUBST(LINTLIB)
1508ffab5952SmrgAM_CONDITIONAL(MAKE_LINT_LIB, [test x$make_lint_lib != xno])
1509ffab5952Smrg
1510ffab5952Smrg]) # XORG_LINT_LIBRARY
1511ffab5952Smrg
151262044635Smrg# XORG_COMPILER_BRAND
151362044635Smrg# -------------------
151462044635Smrg# Minimum version: 1.14.0
151562044635Smrg#
151662044635Smrg# Checks for various brands of compilers and sets flags as appropriate:
151762044635Smrg#   GNU gcc - relies on AC_PROG_CC (via AC_PROG_CC_C99) to set GCC to "yes"
15183ae17ff1Smrg#   GNU g++ - relies on AC_PROG_CXX to set GXX to "yes"
151962044635Smrg#   clang compiler - sets CLANGCC to "yes"
152062044635Smrg#   Intel compiler - sets INTELCC to "yes"
152162044635Smrg#   Sun/Oracle Solaris Studio cc - sets SUNCC to "yes"
152262044635Smrg#
152362044635SmrgAC_DEFUN([XORG_COMPILER_BRAND], [
15243ae17ff1SmrgAC_LANG_CASE(
15253ae17ff1Smrg	[C], [
15266781a5f7Smrg		dnl autoconf-2.70 folded AC_PROG_CC_C99 into AC_PROG_CC
15276781a5f7Smrg		dnl and complains that AC_PROG_CC_C99 is obsolete
15286781a5f7Smrg		m4_version_prereq([2.70],
15296781a5f7Smrg			[AC_REQUIRE([AC_PROG_CC])],
15306781a5f7Smrg			[AC_REQUIRE([AC_PROG_CC_C99])])
15313ae17ff1Smrg	],
15323ae17ff1Smrg	[C++], [
15333ae17ff1Smrg		AC_REQUIRE([AC_PROG_CXX])
15343ae17ff1Smrg	]
15353ae17ff1Smrg)
153662044635SmrgAC_CHECK_DECL([__clang__], [CLANGCC="yes"], [CLANGCC="no"])
153762044635SmrgAC_CHECK_DECL([__INTEL_COMPILER], [INTELCC="yes"], [INTELCC="no"])
153862044635SmrgAC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
153962044635Smrg]) # XORG_COMPILER_BRAND
154062044635Smrg
15413ae17ff1Smrg# XORG_TESTSET_CFLAG(<variable>, <flag>, [<alternative flag>, ...])
15423ae17ff1Smrg# ---------------
15433ae17ff1Smrg# Minimum version: 1.16.0
15443ae17ff1Smrg#
15453ae17ff1Smrg# Test if the compiler works when passed the given flag as a command line argument.
15466781a5f7Smrg# If it succeeds, the flag is appended to the given variable.  If not, it tries the
15473ae17ff1Smrg# next flag in the list until there are no more options.
15483ae17ff1Smrg#
15493ae17ff1Smrg# Note that this does not guarantee that the compiler supports the flag as some
15503ae17ff1Smrg# compilers will simply ignore arguments that they do not understand, but we do
15513ae17ff1Smrg# attempt to weed out false positives by using -Werror=unknown-warning-option and
15523ae17ff1Smrg# -Werror=unused-command-line-argument
15533ae17ff1Smrg#
15543ae17ff1SmrgAC_DEFUN([XORG_TESTSET_CFLAG], [
15553ae17ff1Smrgm4_if([$#], 0, [m4_fatal([XORG_TESTSET_CFLAG was given with an unsupported number of arguments])])
15563ae17ff1Smrgm4_if([$#], 1, [m4_fatal([XORG_TESTSET_CFLAG was given with an unsupported number of arguments])])
15573ae17ff1Smrg
15583ae17ff1SmrgAC_LANG_COMPILER_REQUIRE
15593ae17ff1Smrg
15603ae17ff1SmrgAC_LANG_CASE(
15613ae17ff1Smrg	[C], [
15626781a5f7Smrg		dnl autoconf-2.70 folded AC_PROG_CC_C99 into AC_PROG_CC
15636781a5f7Smrg		dnl and complains that AC_PROG_CC_C99 is obsolete
15646781a5f7Smrg		m4_version_prereq([2.70],
15656781a5f7Smrg			[AC_REQUIRE([AC_PROG_CC])],
15666781a5f7Smrg			[AC_REQUIRE([AC_PROG_CC_C99])])
15673ae17ff1Smrg		define([PREFIX], [C])
15683ae17ff1Smrg		define([CACHE_PREFIX], [cc])
15693ae17ff1Smrg		define([COMPILER], [$CC])
15703ae17ff1Smrg	],
15713ae17ff1Smrg	[C++], [
15723ae17ff1Smrg		define([PREFIX], [CXX])
15733ae17ff1Smrg		define([CACHE_PREFIX], [cxx])
15743ae17ff1Smrg		define([COMPILER], [$CXX])
15753ae17ff1Smrg	]
15763ae17ff1Smrg)
15773ae17ff1Smrg
15783ae17ff1Smrg[xorg_testset_save_]PREFIX[FLAGS]="$PREFIX[FLAGS]"
15793ae17ff1Smrg
15803ae17ff1Smrgif test "x$[xorg_testset_]CACHE_PREFIX[_unknown_warning_option]" = "x" ; then
15813ae17ff1Smrg	PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unknown-warning-option"
15823ae17ff1Smrg	AC_CACHE_CHECK([if ]COMPILER[ supports -Werror=unknown-warning-option],
15833ae17ff1Smrg			[xorg_cv_]CACHE_PREFIX[_flag_unknown_warning_option],
15843ae17ff1Smrg			AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])],
15853ae17ff1Smrg					  [xorg_cv_]CACHE_PREFIX[_flag_unknown_warning_option=yes],
15863ae17ff1Smrg					  [xorg_cv_]CACHE_PREFIX[_flag_unknown_warning_option=no]))
15873ae17ff1Smrg	[xorg_testset_]CACHE_PREFIX[_unknown_warning_option]=$[xorg_cv_]CACHE_PREFIX[_flag_unknown_warning_option]
15883ae17ff1Smrg	PREFIX[FLAGS]="$[xorg_testset_save_]PREFIX[FLAGS]"
15893ae17ff1Smrgfi
15903ae17ff1Smrg
15913ae17ff1Smrgif test "x$[xorg_testset_]CACHE_PREFIX[_unused_command_line_argument]" = "x" ; then
15923ae17ff1Smrg	if test "x$[xorg_testset_]CACHE_PREFIX[_unknown_warning_option]" = "xyes" ; then
15933ae17ff1Smrg		PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unknown-warning-option"
15943ae17ff1Smrg	fi
15953ae17ff1Smrg	PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unused-command-line-argument"
15963ae17ff1Smrg	AC_CACHE_CHECK([if ]COMPILER[ supports -Werror=unused-command-line-argument],
15973ae17ff1Smrg			[xorg_cv_]CACHE_PREFIX[_flag_unused_command_line_argument],
15983ae17ff1Smrg			AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])],
15993ae17ff1Smrg					  [xorg_cv_]CACHE_PREFIX[_flag_unused_command_line_argument=yes],
16003ae17ff1Smrg					  [xorg_cv_]CACHE_PREFIX[_flag_unused_command_line_argument=no]))
16013ae17ff1Smrg	[xorg_testset_]CACHE_PREFIX[_unused_command_line_argument]=$[xorg_cv_]CACHE_PREFIX[_flag_unused_command_line_argument]
16023ae17ff1Smrg	PREFIX[FLAGS]="$[xorg_testset_save_]PREFIX[FLAGS]"
16033ae17ff1Smrgfi
16043ae17ff1Smrg
16053ae17ff1Smrgfound="no"
16063ae17ff1Smrgm4_foreach([flag], m4_cdr($@), [
16073ae17ff1Smrg	if test $found = "no" ; then
160843c16309Smrg		if test "x$xorg_testset_]CACHE_PREFIX[_unknown_warning_option" = "xyes" ; then
16093ae17ff1Smrg			PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unknown-warning-option"
16103ae17ff1Smrg		fi
16113ae17ff1Smrg
161243c16309Smrg		if test "x$xorg_testset_]CACHE_PREFIX[_unused_command_line_argument" = "xyes" ; then
16133ae17ff1Smrg			PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unused-command-line-argument"
16143ae17ff1Smrg		fi
16153ae17ff1Smrg
16163ae17ff1Smrg		PREFIX[FLAGS]="$PREFIX[FLAGS] ]flag["
16173ae17ff1Smrg
16183ae17ff1Smrgdnl Some hackery here since AC_CACHE_VAL can't handle a non-literal varname
161943c16309Smrg		AC_MSG_CHECKING([if ]COMPILER[ supports ]flag[])
16203ae17ff1Smrg		cacheid=AS_TR_SH([xorg_cv_]CACHE_PREFIX[_flag_]flag[])
16213ae17ff1Smrg		AC_CACHE_VAL($cacheid,
16223ae17ff1Smrg			     [AC_LINK_IFELSE([AC_LANG_PROGRAM([int i;])],
16233ae17ff1Smrg					     [eval $cacheid=yes],
16243ae17ff1Smrg					     [eval $cacheid=no])])
16253ae17ff1Smrg
16263ae17ff1Smrg		PREFIX[FLAGS]="$[xorg_testset_save_]PREFIX[FLAGS]"
16273ae17ff1Smrg
16283ae17ff1Smrg		eval supported=\$$cacheid
16293ae17ff1Smrg		AC_MSG_RESULT([$supported])
16303ae17ff1Smrg		if test "$supported" = "yes" ; then
16313ae17ff1Smrg			$1="$$1 ]flag["
16323ae17ff1Smrg			found="yes"
16333ae17ff1Smrg		fi
16343ae17ff1Smrg	fi
16353ae17ff1Smrg])
16363ae17ff1Smrg]) # XORG_TESTSET_CFLAG
16373ae17ff1Smrg
16383ae17ff1Smrg# XORG_COMPILER_FLAGS
16393ae17ff1Smrg# ---------------
16403ae17ff1Smrg# Minimum version: 1.16.0
16413ae17ff1Smrg#
16423ae17ff1Smrg# Defines BASE_CFLAGS or BASE_CXXFLAGS to contain a set of command line
16433ae17ff1Smrg# arguments supported by the selected compiler which do NOT alter the generated
16443ae17ff1Smrg# code.  These arguments will cause the compiler to print various warnings
16453ae17ff1Smrg# during compilation AND turn a conservative set of warnings into errors.
16463ae17ff1Smrg#
16473ae17ff1Smrg# The set of flags supported by BASE_CFLAGS and BASE_CXXFLAGS will grow in
16483ae17ff1Smrg# future versions of util-macros as options are added to new compilers.
16493ae17ff1Smrg#
16503ae17ff1SmrgAC_DEFUN([XORG_COMPILER_FLAGS], [
16513ae17ff1SmrgAC_REQUIRE([XORG_COMPILER_BRAND])
16523ae17ff1Smrg
16533ae17ff1SmrgAC_ARG_ENABLE(selective-werror,
16543ae17ff1Smrg              AS_HELP_STRING([--disable-selective-werror],
16553ae17ff1Smrg                             [Turn off selective compiler errors. (default: enabled)]),
16563ae17ff1Smrg              [SELECTIVE_WERROR=$enableval],
16573ae17ff1Smrg              [SELECTIVE_WERROR=yes])
16583ae17ff1Smrg
16593ae17ff1SmrgAC_LANG_CASE(
16603ae17ff1Smrg        [C], [
16613ae17ff1Smrg                define([PREFIX], [C])
16623ae17ff1Smrg        ],
16633ae17ff1Smrg        [C++], [
16643ae17ff1Smrg                define([PREFIX], [CXX])
16653ae17ff1Smrg        ]
16663ae17ff1Smrg)
16673ae17ff1Smrg# -v is too short to test reliably with XORG_TESTSET_CFLAG
16683ae17ff1Smrgif test "x$SUNCC" = "xyes"; then
16693ae17ff1Smrg    [BASE_]PREFIX[FLAGS]="-v"
16703ae17ff1Smrgelse
16713ae17ff1Smrg    [BASE_]PREFIX[FLAGS]=""
16723ae17ff1Smrgfi
16733ae17ff1Smrg
16743ae17ff1Smrg# This chunk of warnings were those that existed in the legacy CWARNFLAGS
16753ae17ff1SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wall])
16763ae17ff1SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wpointer-arith])
16773ae17ff1SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-declarations])
16783ae17ff1SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wformat=2], [-Wformat])
16793ae17ff1Smrg
16803ae17ff1SmrgAC_LANG_CASE(
16813ae17ff1Smrg	[C], [
16823ae17ff1Smrg		XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wstrict-prototypes])
16833ae17ff1Smrg		XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-prototypes])
16843ae17ff1Smrg		XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wnested-externs])
16853ae17ff1Smrg		XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wbad-function-cast])
168643c16309Smrg		XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wold-style-definition], [-fd])
16873ae17ff1Smrg	]
16883ae17ff1Smrg)
16893ae17ff1Smrg
16903ae17ff1Smrg# This chunk adds additional warnings that could catch undesired effects.
16913ae17ff1SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wunused])
16923ae17ff1SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wuninitialized])
16933ae17ff1SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wshadow])
16943ae17ff1SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-noreturn])
16953ae17ff1SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-format-attribute])
16963ae17ff1SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wredundant-decls])
1697c1197e68SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wlogical-op])
16983ae17ff1Smrg
16993ae17ff1Smrg# These are currently disabled because they are noisy.  They will be enabled
17003ae17ff1Smrg# in the future once the codebase is sufficiently modernized to silence
17013ae17ff1Smrg# them.  For now, I don't want them to drown out the other warnings.
17023ae17ff1Smrg# XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wparentheses])
17033ae17ff1Smrg# XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wcast-align])
170443c16309Smrg# XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wcast-qual])
17053ae17ff1Smrg
17066781a5f7Smrg# Turn some warnings into errors, so we don't accidentally get successful builds
17073ae17ff1Smrg# when there are problems that should be fixed.
17083ae17ff1Smrg
17093ae17ff1Smrgif test "x$SELECTIVE_WERROR" = "xyes" ; then
17103ae17ff1SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=implicit], [-errwarn=E_NO_EXPLICIT_TYPE_GIVEN -errwarn=E_NO_IMPLICIT_DECL_ALLOWED])
17113ae17ff1SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=nonnull])
17123ae17ff1SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=init-self])
17133ae17ff1SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=main])
17143ae17ff1SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=missing-braces])
17153ae17ff1SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=sequence-point])
17163ae17ff1SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=return-type], [-errwarn=E_FUNC_HAS_NO_RETURN_STMT])
17173ae17ff1SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=trigraphs])
17183ae17ff1SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=array-bounds])
17193ae17ff1SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=write-strings])
17203ae17ff1SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=address])
17213ae17ff1SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=int-to-pointer-cast], [-errwarn=E_BAD_PTR_INT_COMBINATION])
17223ae17ff1SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=pointer-to-int-cast]) # Also -errwarn=E_BAD_PTR_INT_COMBINATION
17233ae17ff1Smrgelse
17243ae17ff1SmrgAC_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])
17253ae17ff1SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wimplicit])
17263ae17ff1SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wnonnull])
17273ae17ff1SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Winit-self])
17283ae17ff1SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmain])
17293ae17ff1SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-braces])
17303ae17ff1SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wsequence-point])
17313ae17ff1SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wreturn-type])
17323ae17ff1SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wtrigraphs])
17333ae17ff1SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Warray-bounds])
17343ae17ff1SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wwrite-strings])
17353ae17ff1SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Waddress])
17363ae17ff1SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wint-to-pointer-cast])
17373ae17ff1SmrgXORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wpointer-to-int-cast])
17383ae17ff1Smrgfi
17393ae17ff1Smrg
17403ae17ff1SmrgAC_SUBST([BASE_]PREFIX[FLAGS])
17413ae17ff1Smrg]) # XORG_COMPILER_FLAGS
17423ae17ff1Smrg
1743ffab5952Smrg# XORG_CWARNFLAGS
1744ffab5952Smrg# ---------------
1745ffab5952Smrg# Minimum version: 1.2.0
17463ae17ff1Smrg# Deprecated since: 1.16.0 (Use XORG_COMPILER_FLAGS instead)
1747ffab5952Smrg#
1748ffab5952Smrg# Defines CWARNFLAGS to enable C compiler warnings.
1749ffab5952Smrg#
17503ae17ff1Smrg# This function is deprecated because it defines -fno-strict-aliasing
17513ae17ff1Smrg# which alters the code generated by the compiler.  If -fno-strict-aliasing
17523ae17ff1Smrg# is needed, then it should be added explicitly in the module when
17533ae17ff1Smrg# it is updated to use BASE_CFLAGS.
17543ae17ff1Smrg#
1755ffab5952SmrgAC_DEFUN([XORG_CWARNFLAGS], [
17563ae17ff1SmrgAC_REQUIRE([XORG_COMPILER_FLAGS])
175762044635SmrgAC_REQUIRE([XORG_COMPILER_BRAND])
17583ae17ff1SmrgAC_LANG_CASE(
17593ae17ff1Smrg	[C], [
17603ae17ff1Smrg		CWARNFLAGS="$BASE_CFLAGS"
17613ae17ff1Smrg		if  test "x$GCC" = xyes ; then
17623ae17ff1Smrg		    CWARNFLAGS="$CWARNFLAGS -fno-strict-aliasing"
17633ae17ff1Smrg		fi
17643ae17ff1Smrg		AC_SUBST(CWARNFLAGS)
17653ae17ff1Smrg	]
17663ae17ff1Smrg)
1767ffab5952Smrg]) # XORG_CWARNFLAGS
1768ffab5952Smrg
1769ffab5952Smrg# XORG_STRICT_OPTION
1770ffab5952Smrg# -----------------------
1771ffab5952Smrg# Minimum version: 1.3.0
1772ffab5952Smrg#
177362044635Smrg# Add configure option to enable strict compilation flags, such as treating
177462044635Smrg# warnings as fatal errors.
177562044635Smrg# If --enable-strict-compilation is passed to configure, adds strict flags to
17763ae17ff1Smrg# $BASE_CFLAGS or $BASE_CXXFLAGS and the deprecated $CWARNFLAGS.
177762044635Smrg#
177862044635Smrg# Starting in 1.14.0 also exports $STRICT_CFLAGS for use in other tests or
177962044635Smrg# when strict compilation is unconditionally desired.
1780ffab5952SmrgAC_DEFUN([XORG_STRICT_OPTION], [
1781ffab5952SmrgAC_REQUIRE([XORG_CWARNFLAGS])
17823ae17ff1SmrgAC_REQUIRE([XORG_COMPILER_FLAGS])
1783ffab5952Smrg
1784ffab5952SmrgAC_ARG_ENABLE(strict-compilation,
1785ffab5952Smrg			  AS_HELP_STRING([--enable-strict-compilation],
1786ffab5952Smrg			  [Enable all warnings from compiler and make them errors (default: disabled)]),
1787ffab5952Smrg			  [STRICT_COMPILE=$enableval], [STRICT_COMPILE=no])
17883ae17ff1Smrg
17893ae17ff1SmrgAC_LANG_CASE(
17903ae17ff1Smrg        [C], [
17913ae17ff1Smrg                define([PREFIX], [C])
17923ae17ff1Smrg        ],
17933ae17ff1Smrg        [C++], [
17943ae17ff1Smrg                define([PREFIX], [CXX])
17953ae17ff1Smrg        ]
17963ae17ff1Smrg)
17973ae17ff1Smrg
17983ae17ff1Smrg[STRICT_]PREFIX[FLAGS]=""
17993ae17ff1SmrgXORG_TESTSET_CFLAG([[STRICT_]PREFIX[FLAGS]], [-pedantic])
18003ae17ff1SmrgXORG_TESTSET_CFLAG([[STRICT_]PREFIX[FLAGS]], [-Werror], [-errwarn])
18013ae17ff1Smrg
18023ae17ff1Smrg# Earlier versions of gcc (eg: 4.2) support -Werror=attributes, but do not
18033ae17ff1Smrg# activate it with -Werror, so we add it here explicitly.
18043ae17ff1SmrgXORG_TESTSET_CFLAG([[STRICT_]PREFIX[FLAGS]], [-Werror=attributes])
18053ae17ff1Smrg
1806ffab5952Smrgif test "x$STRICT_COMPILE" = "xyes"; then
18073ae17ff1Smrg    [BASE_]PREFIX[FLAGS]="$[BASE_]PREFIX[FLAGS] $[STRICT_]PREFIX[FLAGS]"
18083ae17ff1Smrg    AC_LANG_CASE([C], [CWARNFLAGS="$CWARNFLAGS $STRICT_CFLAGS"])
1809ffab5952Smrgfi
18103ae17ff1SmrgAC_SUBST([STRICT_]PREFIX[FLAGS])
18113ae17ff1SmrgAC_SUBST([BASE_]PREFIX[FLAGS])
18123ae17ff1SmrgAC_LANG_CASE([C], AC_SUBST([CWARNFLAGS]))
1813ffab5952Smrg]) # XORG_STRICT_OPTION
1814ffab5952Smrg
18156781a5f7Smrg# XORG_DEFAULT_NOCODE_OPTIONS
18166781a5f7Smrg# ---------------------------
18176781a5f7Smrg# Minimum version: 1.20.0
18186781a5f7Smrg#
18196781a5f7Smrg# Defines default options for X.Org modules which don't compile code,
18206781a5f7Smrg# such as fonts, bitmaps, cursors, and docs.
18216781a5f7Smrg#
18226781a5f7SmrgAC_DEFUN([XORG_DEFAULT_NOCODE_OPTIONS], [
18236781a5f7SmrgAC_REQUIRE([AC_PROG_INSTALL])
18246781a5f7SmrgXORG_RELEASE_VERSION
18256781a5f7SmrgXORG_CHANGELOG
18266781a5f7SmrgXORG_INSTALL
18276781a5f7SmrgXORG_MANPAGE_SECTIONS
18286781a5f7Smrgm4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])],
18296781a5f7Smrg    [AC_SUBST([AM_DEFAULT_VERBOSITY], [1])])
18306781a5f7Smrg]) # XORG_DEFAULT_NOCODE_OPTIONS
18316781a5f7Smrg
1832ffab5952Smrg# XORG_DEFAULT_OPTIONS
1833ffab5952Smrg# --------------------
1834ffab5952Smrg# Minimum version: 1.3.0
1835ffab5952Smrg#
18366781a5f7Smrg# Defines default options for X.Org modules which compile code.
1837ffab5952Smrg#
1838ffab5952SmrgAC_DEFUN([XORG_DEFAULT_OPTIONS], [
1839ffab5952SmrgAC_REQUIRE([AC_PROG_INSTALL])
18403ae17ff1SmrgXORG_COMPILER_FLAGS
1841ffab5952SmrgXORG_CWARNFLAGS
1842ffab5952SmrgXORG_STRICT_OPTION
18436781a5f7SmrgXORG_DEFAULT_NOCODE_OPTIONS
1844ffab5952Smrg]) # XORG_DEFAULT_OPTIONS
1845ffab5952Smrg
1846ffab5952Smrg# XORG_INSTALL()
1847ffab5952Smrg# ----------------
1848ffab5952Smrg# Minimum version: 1.4.0
1849ffab5952Smrg#
1850ffab5952Smrg# Defines the variable INSTALL_CMD as the command to copy
1851ffab5952Smrg# INSTALL from $prefix/share/util-macros.
1852ffab5952Smrg#
1853ffab5952SmrgAC_DEFUN([XORG_INSTALL], [
1854ffab5952SmrgAC_REQUIRE([PKG_PROG_PKG_CONFIG])
1855ffab5952Smrgmacros_datadir=`$PKG_CONFIG --print-errors --variable=pkgdatadir xorg-macros`
1856ffab5952SmrgINSTALL_CMD="(cp -f "$macros_datadir/INSTALL" \$(top_srcdir)/.INSTALL.tmp && \
1857ffab5952Smrgmv \$(top_srcdir)/.INSTALL.tmp \$(top_srcdir)/INSTALL) \
18589fa8ffe7Smrg|| (rm -f \$(top_srcdir)/.INSTALL.tmp; test -e \$(top_srcdir)/INSTALL || ( \
18599fa8ffe7Smrgtouch \$(top_srcdir)/INSTALL; \
18609fa8ffe7Smrgecho 'failed to copy INSTALL from util-macros: installing empty INSTALL.' >&2))"
1861ffab5952SmrgAC_SUBST([INSTALL_CMD])
1862ffab5952Smrg]) # XORG_INSTALL
1863