]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - contrib/atf/atf-c/atf-common.m4
MFC r270507:
[FreeBSD/stable/10.git] / contrib / atf / atf-c / atf-common.m4
1 dnl
2 dnl Automated Testing Framework (atf)
3 dnl
4 dnl Copyright 2011 Google Inc.
5 dnl All rights reserved.
6 dnl
7 dnl Redistribution and use in source and binary forms, with or without
8 dnl modification, are permitted provided that the following conditions are
9 dnl met:
10 dnl
11 dnl * Redistributions of source code must retain the above copyright
12 dnl   notice, this list of conditions and the following disclaimer.
13 dnl * Redistributions in binary form must reproduce the above copyright
14 dnl   notice, this list of conditions and the following disclaimer in the
15 dnl   documentation and/or other materials provided with the distribution.
16 dnl * Neither the name of Google Inc. nor the names of its contributors
17 dnl   may be used to endorse or promote products derived from this software
18 dnl   without specific prior written permission.
19 dnl
20 dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 dnl "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 dnl LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 dnl A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 dnl OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 dnl SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 dnl LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 dnl DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 dnl THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 dnl (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 dnl OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 dnl
32
33 dnl ATF_ARG_WITH
34 dnl
35 dnl Adds a --with-atf flag to the configure script that allows the user to
36 dnl enable or disable atf support.
37 dnl
38 dnl The ATF_CHECK_{C,CXX,SH} macros honor the flag defined herein if
39 dnl instantiated.  If not instantiated, they will request the presence of
40 dnl the libraries unconditionally.
41 dnl
42 dnl Defines the WITH_ATF Automake conditional if ATF has been found by any
43 dnl of the ATF_CHECK_{C,CXX,SH} macros.
44 AC_DEFUN([ATF_ARG_WITH], [
45     m4_define([atf_arg_with_called], [yes])
46
47     m4_divert_text([DEFAULTS], [with_atf=auto])
48     AC_ARG_WITH([atf],
49                 [AS_HELP_STRING([--with-atf=<yes|no|auto>],
50                                 [build atf-based test programs])],
51                 [with_atf=${withval}], [with_atf=auto])
52
53     m4_divert_text([DEFAULTS], [
54         found_atf_c=no
55         found_atf_cxx=no
56         found_atf_sh=no
57     ])
58     AM_CONDITIONAL([WITH_ATF], [test x"${found_atf_c}" = x"yes" -o \
59                                      x"${found_atf_cxx}" = x"yes" -o \
60                                      x"${found_atf_sh}" = x"yes"])
61 ])
62
63 dnl _ATF_CHECK_ARG_WITH(check, error_message)
64 dnl
65 dnl Internal macro to execute a check conditional on the --with-atf flag
66 dnl and handle the result accordingly.
67 dnl
68 dnl 'check' specifies the piece of code to be run to detect the feature.
69 dnl This code must set the 'found' shell variable to yes or no depending
70 dnl on the raw result of the check.
71 AC_DEFUN([_ATF_CHECK_ARG_WITH], [
72     m4_ifdef([atf_arg_with_called], [
73         m4_fatal([ATF_ARG_WITH must be called after the ATF_CHECK_* checks])
74     ])
75
76     m4_divert_text([DEFAULTS], [with_atf=yes])
77
78     if test x"${with_atf}" = x"no"; then
79         _found=no
80     else
81         $1
82         if test x"${with_atf}" = x"auto"; then
83             _found="${found}"
84         else
85             if test x"${found}" = x"yes"; then
86                 _found=yes
87             else
88                 AC_MSG_ERROR([$2])
89             fi
90         fi
91     fi
92 ])