1dnl
2dnl Automated Testing Framework (atf)
3dnl
4dnl Copyright (c) 2007, 2008, 2009, 2010 The NetBSD Foundation, Inc.
5dnl All rights reserved.
6dnl
7dnl Redistribution and use in source and binary forms, with or without
8dnl modification, are permitted provided that the following conditions
9dnl are met:
10dnl 1. Redistributions of source code must retain the above copyright
11dnl    notice, this list of conditions and the following disclaimer.
12dnl 2. Redistributions in binary form must reproduce the above copyright
13dnl    notice, this list of conditions and the following disclaimer in the
14dnl    documentation and/or other materials provided with the distribution.
15dnl
16dnl THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
17dnl CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
18dnl INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19dnl MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20dnl IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
21dnl DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22dnl DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23dnl GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24dnl INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25dnl IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26dnl OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27dnl IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28dnl
29
30dnl -----------------------------------------------------------------------
31dnl Initialize the GNU build system.
32dnl -----------------------------------------------------------------------
33
34AC_INIT([Automated Testing Framework], [0.12], [atf-devel@NetBSD.org], [atf],
35        [http://www.NetBSD.org/~jmmv/atf/])
36AC_PREREQ([2.65])
37AC_COPYRIGHT([Copyright (c) 2007, 2008, 2009, 2010 The NetBSD Foundation, Inc.])
38AC_DEFINE([PACKAGE_COPYRIGHT],
39          ["Copyright (c) 2007, 2008, 2009, 2010 The NetBSD Foundation, Inc."],
40          [Define to the copyright string applicable to this package.])
41AC_CONFIG_AUX_DIR([admin])
42AC_CONFIG_HEADERS([bconfig.h])
43AC_CONFIG_MACRO_DIR([m4])
44AC_CONFIG_SRCDIR([atf-c.h])
45AC_CONFIG_TESTDIR([bootstrap])
46
47AC_CANONICAL_TARGET
48
49AM_INIT_AUTOMAKE([1.9 check-news foreign subdir-objects -Wall])
50
51LT_INIT([disable-shared])
52dnl This is just a hack to reverse the meaning of the --enable-shared
53dnl flag provided by libtool.  We want it to default to building static
54dnl libraries only for now, but these are painful during development.
55dnl It is nice to have an easy way to enable shared library builds.
56dnl
57dnl TODO(1.0): Enable shared libraries by default, and fix their
58dnl -version-info.
59AC_ARG_ENABLE(unstable-shared,
60    AS_HELP_STRING([--enable-unstable-shared],
61        [Enables the build of shared libraries with unstable ABIs/APIs]),
62    [case $enableval in
63     yes|no) enable_shared=${enableval} ;;
64     *) enable_shared=${enableval} ;;
65     esac],
66    [enable_shared=no])
67
68dnl -----------------------------------------------------------------------
69dnl Check for the C and C++ compilers and required features.
70dnl -----------------------------------------------------------------------
71
72AC_LANG(C)
73AC_PROG_CC
74AM_PROG_CC_C_O
75dnl The C compiler check automatically aborts if the compiler does not work.
76dnl Nothing to do here.
77
78AC_LANG(C++)
79AC_PROG_CXX
80AC_CACHE_CHECK([whether the C++ compiler works],
81               [atf_cv_prog_cxx_works],
82               [AC_LANG_PUSH([C++])
83                AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
84                               [atf_cv_prog_cxx_works=yes],
85                               [atf_cv_prog_cxx_works=no])
86                AC_LANG_POP])
87if test "${atf_cv_prog_cxx_works}" = no; then
88    AC_MSG_ERROR([C++ compiler cannot create executables])
89fi
90
91ATF_DEVELOPER_MODE
92
93ATF_MODULE_APPLICATION
94ATF_MODULE_DEFS
95ATF_MODULE_ENV
96ATF_MODULE_FS
97ATF_MODULE_SANITY
98ATF_MODULE_SIGNALS
99
100ATF_RUNTIME_TOOL([ATF_BUILD_CC],
101                 [C compiler to use at runtime], [${CC}])
102ATF_RUNTIME_TOOL([ATF_BUILD_CFLAGS],
103                 [C compiler flags to use at runtime], [${CFLAGS}])
104ATF_RUNTIME_TOOL([ATF_BUILD_CPP],
105                 [C/C++ preprocessor to use at runtime], [${CPP}])
106ATF_RUNTIME_TOOL([ATF_BUILD_CPPFLAGS],
107                 [C/C++ preprocessor flags to use at runtime], [${CPPFLAGS}])
108ATF_RUNTIME_TOOL([ATF_BUILD_CXX],
109                 [C++ compiler to use at runtime], [${CXX}])
110ATF_RUNTIME_TOOL([ATF_BUILD_CXXFLAGS],
111                 [C++ compiler flags to use at runtime], [${CXXFLAGS}])
112
113dnl -----------------------------------------------------------------------
114dnl Generation of files in srcdir.
115dnl -----------------------------------------------------------------------
116
117dnl BSD make(1) doesn't deal with targets specified as './foo' well: they
118dnl need to be specified as 'foo'.  The following hack is to workaround this
119dnl issue.
120if test "${srcdir}" = .; then
121    target_srcdir=
122else
123    target_srcdir="${srcdir}/"
124fi
125AC_SUBST([target_srcdir])
126
127dnl -----------------------------------------------------------------------
128dnl Architecture and machine checks.
129dnl -----------------------------------------------------------------------
130
131machine=${target_cpu}
132
133case ${machine} in
134    i@<:@3-9@:>@86)
135        arch=i386
136        ;;
137    x86_64)
138        arch=amd64
139        ;;
140    *)
141        arch=${machine}
142        ;;
143esac
144
145AC_MSG_NOTICE([Machine type: ${machine}, architecture: ${arch}])
146AC_SUBST(atf_arch, ${arch})
147AC_SUBST(atf_machine, ${machine})
148
149dnl -----------------------------------------------------------------------
150dnl User-customizable variables.
151dnl -----------------------------------------------------------------------
152
153AC_ARG_VAR([ATF_CONFSUBDIR],
154           [Subdirectory of sysconfdir under which to look for files])
155if test x"${ATF_CONFSUBDIR-unset}" = x"unset"; then
156    ATF_CONFSUBDIR=atf
157else
158    case ${ATF_CONFSUBDIR} in
159    /*)
160        AC_MSG_ERROR([ATF_CONFSUBDIR must hold a relative path])
161        ;;
162    *)
163        ;;
164    esac
165fi
166if test x"${ATF_CONFSUBDIR}" = x""; then
167    AC_SUBST(atf_confdir, \${sysconfdir})
168else
169    AC_SUBST(atf_confdir, \${sysconfdir}/${ATF_CONFSUBDIR})
170fi
171
172AC_ARG_VAR([ATF_WORKDIR],
173           [Default location to use for ATF work directories])
174if test x"${ATF_WORKDIR}" = x""; then
175    for t in /tmp /var/tmp; do
176        if test -d ${t}; then
177            ATF_WORKDIR=${t}
178            break
179        fi
180    done
181    if test x"${ATF_WORKDIR}" = x""; then
182        AC_MSG_ERROR([Could not guess a value for ATF_WORKDIR])
183    fi
184else
185    case ${ATF_WORKDIR} in
186    /*)
187        ;;
188    *)
189        AC_MSG_ERROR([ATF_WORKDIR must hold an absolute path])
190        ;;
191    esac
192fi
193
194AC_SUBST(atf_cssdir, \${datadir}/examples/atf)
195AC_SUBST(atf_dtddir, \${datadir}/xml/atf)
196AC_SUBST(atf_egdir, \${datadir}/examples/atf)
197AC_SUBST(atf_pkgconfigdir, \${libdir}/pkgconfig)
198AC_SUBST(atf_xsldir, \${datadir}/xsl/atf)
199
200dnl -----------------------------------------------------------------------
201dnl Check for the shell and portability problems.
202dnl -----------------------------------------------------------------------
203
204AC_ARG_VAR([ATF_SHELL], [Location of the POSIX shell interpreter to use])
205if test x"${ATF_SHELL}" = x""; then
206    AC_PATH_PROGS(ATF_SHELL, [bash sh])
207else
208    case ${ATF_SHELL} in
209    /*)
210        ;;
211    *)
212        AC_MSG_ERROR([ATF_SHELL must hold an absolute path])
213        ;;
214    esac
215fi
216if test x"${ATF_SHELL}" = x""; then
217    AC_MSG_ERROR([No POSIX shell interpreter found; maybe set ATF_SHELL?])
218fi
219
220dnl -----------------------------------------------------------------------
221dnl Check for required tools.
222dnl -----------------------------------------------------------------------
223
224AC_PATH_PROG([MTN], [mtn])
225
226dnl -----------------------------------------------------------------------
227dnl Finally, generate output.
228dnl -----------------------------------------------------------------------
229
230AC_OUTPUT([Makefile atf-c/defs.h])
231
232if test ${enable_shared} = yes; then
233    AC_MSG_WARN([Shared libraries with unstable ABIs/APIs have been enabled.])
234    AC_MSG_WARN([Please do not install them as part of a binary package.])
235fi
236
237dnl vim: syntax=m4:expandtab:shiftwidth=4:softtabstop=4
238