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