10941
10941
AC_MSG_RESULT([$build_specs])
10942
10942
]) # XORG_ENABLE_SPECS
10944
# XORG_ENABLE_UNIT_TESTS (enable_unit_tests=auto)
10945
# ----------------------------------------------
10946
# Minimum version: 1.13.0
10948
# This macro enables a builder to enable/disable unit testing
10949
# It makes no assumption about the test cases implementation
10950
# Test cases may or may not use Automake "Support for test suites"
10951
# They may or may not use the software utility library GLib
10953
# When used in conjunction with XORG_WITH_GLIB, use both AM_CONDITIONAL
10954
# ENABLE_UNIT_TESTS and HAVE_GLIB. Not all unit tests may use glib.
10955
# The variable enable_unit_tests is used by other macros in this file.
10957
# Interface to module:
10958
# ENABLE_UNIT_TESTS: used in makefiles to conditionally build tests
10959
# enable_unit_tests: used in configure.ac for additional configuration
10960
# --enable-unit-tests: 'yes' user instructs the module to build tests
10961
# 'no' user instructs the module not to build tests
10962
# parm1: specify the default value, yes or no.
10964
AC_DEFUN([XORG_ENABLE_UNIT_TESTS],[
10965
AC_BEFORE([$0], [XORG_WITH_GLIB])
10966
AC_BEFORE([$0], [XORG_LD_WRAP])
10967
m4_define([_defopt], m4_default([$1], [auto]))
10968
AC_ARG_ENABLE(unit-tests, AS_HELP_STRING([--enable-unit-tests],
10969
[Enable building unit test cases (default: ]_defopt[)]),
10970
[enable_unit_tests=$enableval], [enable_unit_tests=]_defopt)
10971
m4_undefine([_defopt])
10972
AM_CONDITIONAL(ENABLE_UNIT_TESTS, [test "x$enable_unit_tests" != xno])
10973
AC_MSG_CHECKING([whether to build unit test cases])
10974
AC_MSG_RESULT([$enable_unit_tests])
10975
]) # XORG_ENABLE_UNIT_TESTS
10977
# XORG_WITH_GLIB([MIN-VERSION], [DEFAULT])
10978
# ----------------------------------------
10979
# Minimum version: 1.13.0
10981
# GLib is a library which provides advanced data structures and functions.
10982
# This macro enables a module to test for the presence of Glib.
10984
# When used with ENABLE_UNIT_TESTS, it is assumed GLib is used for unit testing.
10985
# Otherwise the value of $enable_unit_tests is blank.
10987
# Interface to module:
10988
# HAVE_GLIB: used in makefiles to conditionally build targets
10989
# with_glib: used in configure.ac to know if GLib has been found
10990
# --with-glib: 'yes' user instructs the module to use glib
10991
# 'no' user instructs the module not to use glib
10993
AC_DEFUN([XORG_WITH_GLIB],[
10994
AC_REQUIRE([PKG_PROG_PKG_CONFIG])
10995
m4_define([_defopt], m4_default([$2], [auto]))
10996
AC_ARG_WITH(glib, AS_HELP_STRING([--with-glib],
10997
[Use GLib library for unit testing (default: ]_defopt[)]),
10998
[with_glib=$withval], [with_glib=]_defopt)
10999
m4_undefine([_defopt])
11002
# Do not probe GLib if user explicitly disabled unit testing
11003
if test "x$enable_unit_tests" != x"no"; then
11004
# Do not probe GLib if user explicitly disabled it
11005
if test "x$with_glib" != x"no"; then
11008
[PKG_CHECK_MODULES([GLIB], [glib-2.0 >= $1], [have_glib=yes], [have_glib=no])],
11009
[PKG_CHECK_MODULES([GLIB], [glib-2.0], [have_glib=yes], [have_glib=no])]
11014
# Not having GLib when unit testing has been explicitly requested is an error
11015
if test "x$enable_unit_tests" = x"yes"; then
11016
if test "x$have_glib" = x"no"; then
11017
AC_MSG_ERROR([--enable-unit-tests=yes specified but glib-2.0 not found])
11021
# Having unit testing disabled when GLib has been explicitly requested is an error
11022
if test "x$enable_unit_tests" = x"no"; then
11023
if test "x$with_glib" = x"yes"; then
11024
AC_MSG_ERROR([--enable-unit-tests=yes specified but glib-2.0 not found])
11028
# Not having GLib when it has been explicitly requested is an error
11029
if test "x$with_glib" = x"yes"; then
11030
if test "x$have_glib" = x"no"; then
11031
AC_MSG_ERROR([--with-glib=yes specified but glib-2.0 not found])
11035
AM_CONDITIONAL([HAVE_GLIB], [test "$have_glib" = yes])
11036
]) # XORG_WITH_GLIB
11040
# Minimum version: 1.13.0
11042
# Check if linker supports -wrap, passed via compiler flags
11044
# When used with ENABLE_UNIT_TESTS, it is assumed -wrap is used for unit testing.
11045
# Otherwise the value of $enable_unit_tests is blank.
11047
AC_DEFUN([XORG_LD_WRAP],[
11048
XORG_CHECK_LINKER_FLAGS([-Wl,-wrap,exit],[have_ld_wrap=yes],[have_ld_wrap=no])
11049
# Not having ld wrap when unit testing has been explicitly requested is an error
11050
if test "x$enable_unit_tests" = x"yes"; then
11051
if test "x$have_ld_wrap" = x"no"; then
11052
AC_MSG_ERROR([--enable-unit-tests=yes specified but ld -wrap support is not available])
11055
AM_CONDITIONAL([HAVE_LD_WRAP], [test "$have_ld_wrap" = yes])
11059
# XORG_CHECK_LINKER_FLAGS
11060
# -----------------------
11063
# XORG_CHECK_LINKER_FLAGS(FLAGS, [ACTION-SUCCESS], [ACTION-FAILURE])
11067
# Check whether the given linker FLAGS work with the current language's
11068
# linker, or whether they give an error.
11070
# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
11073
# NOTE: Based on AX_CHECK_COMPILER_FLAGS.
11077
# Copyright (c) 2009 Mike Frysinger <vapier@gentoo.org>
11078
# Copyright (c) 2009 Steven G. Johnson <stevenj@alum.mit.edu>
11079
# Copyright (c) 2009 Matteo Frigo
11081
# This program is free software: you can redistribute it and/or modify it
11082
# under the terms of the GNU General Public License as published by the
11083
# Free Software Foundation, either version 3 of the License, or (at your
11084
# option) any later version.
11086
# This program is distributed in the hope that it will be useful, but
11087
# WITHOUT ANY WARRANTY; without even the implied warranty of
11088
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
11089
# Public License for more details.
11091
# You should have received a copy of the GNU General Public License along
11092
# with this program. If not, see <http://www.gnu.org/licenses/>.
11094
# As a special exception, the respective Autoconf Macro's copyright owner
11095
# gives unlimited permission to copy, distribute and modify the configure
11096
# scripts that are the output of Autoconf when processing the Macro. You
11097
# need not follow the terms of the GNU General Public License when using
11098
# or distributing such scripts, even though portions of the text of the
11099
# Macro appear in them. The GNU General Public License (GPL) does govern
11100
# all other use of the material that constitutes the Autoconf Macro.
11102
# This special exception to the GPL applies to versions of the Autoconf
11103
# Macro released by the Autoconf Archive. When you make and distribute a
11104
# modified version of the Autoconf Macro, you may extend this special
11105
# exception to the GPL to apply to your modified version as well.#
11106
AC_DEFUN([XORG_CHECK_LINKER_FLAGS],
11107
[AC_MSG_CHECKING([whether the linker accepts $1])
11108
dnl Some hackery here since AC_CACHE_VAL can't handle a non-literal varname:
11109
AS_LITERAL_IF([$1],
11110
[AC_CACHE_VAL(AS_TR_SH(xorg_cv_linker_flags_[$1]), [
11111
ax_save_FLAGS=$LDFLAGS
11113
AC_LINK_IFELSE([AC_LANG_PROGRAM()],
11114
AS_TR_SH(xorg_cv_linker_flags_[$1])=yes,
11115
AS_TR_SH(xorg_cv_linker_flags_[$1])=no)
11116
LDFLAGS=$ax_save_FLAGS])],
11117
[ax_save_FLAGS=$LDFLAGS
11119
AC_LINK_IFELSE([AC_LANG_PROGRAM()],
11120
eval AS_TR_SH(xorg_cv_linker_flags_[$1])=yes,
11121
eval AS_TR_SH(xorg_cv_linker_flags_[$1])=no)
11122
LDFLAGS=$ax_save_FLAGS])
11123
eval xorg_check_linker_flags=$AS_TR_SH(xorg_cv_linker_flags_[$1])
11124
AC_MSG_RESULT($xorg_check_linker_flags)
11125
if test "x$xorg_check_linker_flags" = xyes; then
11126
m4_default([$2], :)
11128
m4_default([$3], :)
11130
]) # XORG_CHECK_LINKER_FLAGS
10944
11132
# XORG_CHECK_MALLOC_ZERO
10945
11133
# ----------------------
10946
11134
# Minimum version: 1.0.0