Merge lp:~bregma/frame/lp-966290 into lp:frame

Proposed by Stephen M. Webb
Status: Merged
Merged at revision: 78
Proposed branch: lp:~bregma/frame/lp-966290
Merge into: lp:frame
Diff against target: 1983 lines (+1963/-1)
3 files modified
autogen.sh (+1/-1)
m4/xorg-gtest.m4 (+110/-0)
m4/xorg-macros.m4 (+1852/-0)
To merge this branch: bzr merge lp:~bregma/frame/lp-966290
Reviewer Review Type Date Requested Status
Chase Douglas (community) Approve
Review via email: mp+99546@code.launchpad.net

Description of the change

Adds missing autoconf macros to the project (lp: #966290).

The package has been failing to build from source in the daily build PPA since use of the xorg-gtest macros was introduced in the autoconf sources (configure.in) but not guaranteed to be available in a build system (PPA etc). The resolution is to include the source required to build the package in the package itself. Updated releases of the dependent macro will be copied in automatically when available because of the AM_ACLOCAL flags already present in Makefile.am, so this will not be a maintenance problem.

The problem is reproducible in a local pbuilder or sbuild environment, as is the solution.

To post a comment you must log in.
Revision history for this message
Chase Douglas (chasedouglas) wrote :

Without autoreconf's --force option, which is not used in autogen.sh, aclocal --install will only overwrite a file present in m4/ if the system installed script has a serial version that is newer. It will not overwrite scripts that do not have a serial number. See http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/Serials.html#Serials.

The xorg-macros.m4 file doesn't have serial numbers, so if we committed it we would need to either use autoreconf --force in autogen.sh, or we would need to be diligent about updating it. I don't think we will ever be building in an environment without xorg-macros due to upstream convention and the scripts being available in Ubuntu main, so I would lean towards not committing it.

review: Needs Fixing
Revision history for this message
Stephen M. Webb (bregma) wrote :

The distro packaging should be using --with autoreconf for all builds, which will run dh_autoreconf, which (a) always runs with --force, because that's the point and (2) uses md5 checksums and not serial numbers by default to avoid the problem you mention above. See dh_autoreconf(1).

The autogen.sh should use --force anyway until there is good reason not to, since it's the most desirable behaviour. I can add that.

All PPA/pbuilder/cowbuilder/sbuild/buildd builds are in an environment without a system-installed xorg-macros.m4 file. One could add xutils-dev as a build dependency or add libxorg-gtest-dev as a build dependency so it gets pulled in transitively (and assuming --with-autoreconf). Then again, the latter would also fix the whole daily build problem, assuming packaging builds have dh_auto_check disabled (like, say, having DEB_BUILD_OPTIONS contain "nocheck").

Would it be better to move the entire fix into the packaging?

Revision history for this message
Chase Douglas (chasedouglas) wrote :

I think it would be best to leave xutils-dev and libxorg-gtest-dev out of the package building, and instead fix things in the upstream distribution. We also can't depend on libxorg-gtest-dev quite yet anyways, because libgtest-dev hasn't passed MIR approval last I checked (xorg-gtest has).

That means we need to use autoreconf --force in autogen.sh, or add --force to AM_ACLOCAL flags, or both. I'm not sure what is the best option, but I'm fine with any of these resolutions.

lp:~bregma/frame/lp-966290 updated
79. By Stephen M. Webb

Defaulted --force in autogen.sh to force embedded script copies to get updated automatically.
- also removed mandatory verbose and passed command-line options so --verbose or --make can be added as desired

Revision history for this message
Stephen M. Webb (bregma) wrote :

Modified autogen.sh appropriately (see comment in commit). Adding --force in autogen.sh will also refresh config.status, config.sub, and ltmain.sh if the developer has a newer version on their system.

I forgot libxorg-gtest-dev wasn't in main: that rules out the packaging fix approach, and for consistency both m4 files should be kept with the sources so developers don't get unexpected failures on a fresh checkout.

Revision history for this message
Chase Douglas (chasedouglas) wrote :

Fine with me. Looking forward to having daily builds again :).

review: Approve
Revision history for this message
Chase Douglas (chasedouglas) wrote :

Oh, the .bzrignore file needs to have the xorg macro scripts removed.

Revision history for this message
Chase Douglas (chasedouglas) wrote :

I fixed up the .bzrignore file when I merged the branch.

Preview Diff

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

Subscribers

People subscribed via source and target branches