3 dnl $Id: configure.in,v 1.45 2012/06/20 22:43:41 sjg Exp $
5 dnl Process this file with autoconf to produce a configure script
7 AC_INIT([bmake], [20120620], [sjg@NetBSD.org])
8 AC_CONFIG_HEADER(config.h)
12 [ --with-defshell=SHELL use SHELL by default - must be sh compatible, use sh or ksh to pick the internal definitions],
14 yes) AC_MSG_ERROR(bad value ${withval} given for bmake DEFSHELL) ;;
16 *) case "$with_defshell" in
17 sh) DEFSHELL_INDEX=DEFSHELL_INDEX_SH;; # it's the default anyway
18 ksh) DEFSHELL_INDEX=DEFSHELL_INDEX_KSH;;
19 csh) DEFSHELL_INDEX=DEFSHELL_INDEX_CSH;; # kidding right?
20 *) defshell_path=$with_defshell;; # better be sh compatible!
27 [ --without-meta dissable use of meta-mode],
29 yes|no) use_meta=${withval};;
30 *) AC_MSG_ERROR(bad value ${withval} given for meta) ;;
34 [ --with-filemon=path/filemon.h indicate path to filemon.h for meta-mode],
35 [ case "/${withval}" in
36 /no|*/filemon.h) filemon_h="${withval}";;
37 */filemon*) filemon_h="${withval}/filemon.h";;
38 *) AC_MSG_ERROR(bad value ${withval} given for filemon) ;;
42 for d in "/usr/include/dev/filemon" "$prefix/include/dev/filemon" "$srcdir/filemon" "$srcdir/../filemon" "$srcdir/../../sys/dev/filemon"
46 filemon_h="$d$x/filemon.h"
47 test -s "$filemon_h" && break
49 test -s "$filemon_h" && break
51 test -s "${filemon_h:-/dev/null}" || filemon_h=no
53 dnl echo "Note: use_meta=$use_meta filemon_h=$filemon_h" >&6
57 *.h) echo "Using: filemon=$filemon_h" >&6;;
62 dnl Check for OS problems
63 dnl Solaris's signal.h only privides sigset_t etc if one of
64 dnl _EXTENSIONS_ _POSIX_C_SOURCE or _XOPEN_SOURCE are defined.
65 dnl The later two seem to cause more problems than they solve so if we
66 dnl see _EXTENSIONS_ we use it.
67 AC_USE_SYSTEM_EXTENSIONS
68 dnl Checks for programs.
70 AC_PROG_GCC_TRADITIONAL
72 dnl Executable suffix - normally empty; .exe on os2.
73 AC_SUBST(ac_exe_suffix)dnl
76 dnl Check if /bin/sh will pass .MAKE.LEVEL
77 echo $ECHO_N "checking if sh will pass .MAKE. variables... $ECHO_C" >&6
78 ok=`env .MAKE.LEVEL=1 /bin/sh -c env | grep LEVEL=`
80 "") echo no >&6; CPPFLAGS="${CPPFLAGS} -DNEED_MAKE_LEVEL_SAFE";;
88 dnl Checks for header files.
92 dnl Keep this list sorted
110 dnl Both *BSD and Linux have sys/cdefs.h, most do not.
111 dnl If it is missing, we add -I${srcdir}/missing to CFLAGS
112 dnl also if sys/cdefs.h does not have __RCSID we need to use ours
113 dnl but we need to include the host's one too *sigh*
114 AC_CHECK_HEADER(sys/cdefs.h,
115 echo $ECHO_N "checking whether sys/cdefs.h is compatible... $ECHO_C" >&6
117 [#include <sys/cdefs.h>
123 echo no >&6; CPPFLAGS="${CPPFLAGS} -I`cd ${srcdir}/missing && pwd` -DNEED_HOST_CDEFS_H"),
124 CPPFLAGS="${CPPFLAGS} -I`cd ${srcdir}/missing && pwd`")
126 dnl Checks for typedefs, structures, and compiler characteristics.
137 dnl Checks for library functions.
142 dnl Keep this list sorted
174 dnl functions which we may need to provide
182 AC_CHECK_LIB([util], [emalloc],
183 [ AC_CHECK_LIB([util], [erealloc],
184 [ AC_CHECK_LIB([util], [estrdup],
185 [ AC_CHECK_LIB([util], [estrndup],
186 [ LIBS="$LIBS -lutil"
187 CPPFLAGS="$CPPFLAGS -DUSE_EMALLOC" ])])])])
195 dnl we want this for unit-tests/Makefile
196 echo $ECHO_N "checking if diff -u works... $ECHO_C" >&6
197 if diff -u /dev/null /dev/null > /dev/null 2>&1; then
205 dnl AC_* don't quite cut it.
207 echo "checking for MACHINE & MACHINE_ARCH..." >&6
208 cat > conftest.$ac_ext <<EOF
209 #include "confdefs.h"
210 #include <sys/param.h>
215 machine_arch=MACHINE_ARCH
219 default_machine=`(eval "$ac_cpp conftest.$ac_ext") 2>&5 |
220 egrep machine= | tr -d ' "'`
222 if test "$default_machine"; then
223 eval "$default_machine"
225 machine=${machine:-`$srcdir/machine.sh`}
226 machine_arch=${machine_arch:-`$srcdir/machine.sh arch`}
227 echo "defaults: MACHINE=$machine, MACHINE_ARCH=$machine_arch" 1>&6
229 dnl now allow overrides
232 [ --with-machine=MACHINE explicitly set MACHINE],
233 [case "${withval}" in
234 yes) AC_MSG_ERROR(bad value ${withval} given for bmake MACHINE) ;;
236 generic) machine=`$srcdir/machine.sh`;;
237 *) machine=$with_machine;;
240 AC_ARG_WITH(force_machine,
241 [ --with-force-machine=MACHINE set FORCE_MACHINE],
242 [case "${withval}" in
243 yes) force_machine=FORCE_;;
245 *) force_machine=FORCE_; machine=$with_force_machine;;
249 AC_ARG_WITH(force_machine_arch,
250 [ --with-force-machine-arch=MACHINE set FORCE_MACHINE_ARCH],
251 [case "${withval}" in
252 yes) force_machine_arch=FORCE_;;
254 *) force_machine_arch=FORCE_; machine_arch=$with_force_machine;;
257 AC_ARG_WITH(machine_arch,
258 [ --with-machine_arch=MACHINE_ARCH explicitly set MACHINE_ARCH],
259 [case "${withval}" in
260 yes) AC_MSG_ERROR(bad value ${withval} given for bmake MACHINE_ARCH) ;;
262 *) machine_arch=$with_machine_arch;;
265 dnl Tell them what we ended up with
267 echo "Using: ${force_machine}MACHINE=$machine, MACHINE_ARCH=$machine_arch" 1>&6
269 dnl Allow folk to control _PATH_DEFSYSPATH
271 default_sys_path=\${prefix}/share/mk
272 AC_ARG_WITH(default-sys-path,
273 [ --with-default-sys-path=PATH:DIR:LIST use an explicit _PATH_DEFSYSPATH
274 MAKESYSPATH is a ':' separated list of directories
275 that bmake will search for system .mk files.
276 _PATH_DEFSYSPATH is its default value.],
277 [case "${withval}" in
278 yes) AC_MSG_ERROR(bad value ${withval} given for bmake _PATH_DEFSYSPATH) ;;
280 *) default_sys_path="$with_default_sys_path"
284 dnl Some folk don't like this one
286 AC_ARG_WITH(path-objdirprefix,
287 [ --with-path-objdirprefix=PATH override _PATH_OBJDIRPREFIX],
288 [case "${withval}" in
289 yes) AC_MSG_ERROR(bad value ${withval} given for bmake _PATH_OBJDIRPREFIX) ;;
290 no) CPPFLAGS="$CPPFLAGS -DNO_PATH_OBJDIRPREFIX" ;;
291 *) CPPFLAGS="$CPPFLAGS \"-D_PATH_OBJDIRPREFIX=\\\"$with_path-objdir\\\"\"" ;;
294 dnl And this can be handy to do with out.
296 AC_ARG_ENABLE(pwd-override,
297 [ --disable-pwd-override disable \$PWD overriding getcwd()],
298 [case "${enableval}" in
300 no) CPPFLAGS="$CPPFLAGS -DNO_PWD_OVERRIDE" ;;
301 *) AC_MSG_ERROR(bad value ${enableval} given for pwd-override option) ;;
306 AC_ARG_ENABLE(check-make-chdir,
307 [ --disable-check-make-chdir disable make trying to guess
308 when it should automatically cd \${.CURDIR}],
309 [case "${enableval}" in
311 no) CPPFLAGS="$CPPFLAGS -DNO_CHECK_MAKE_CHDIR" ;;
312 *) AC_MSG_ERROR(bad value ${enableval} given for check-make-chdir option) ;;
315 dnl On non-BSD systems, bootstrap won't work without mk
318 [ --with-mksrc=PATH tell makefile.boot where to find mk src],
319 [case "${withval}" in
321 *) test -s $withval/install-mk && mksrc=$withval ||
322 AC_MSG_ERROR(bad value ${withval} given for mksrc cannot find install-mk)
327 dnl Now make sure we have a value
329 srcdir=`cd $srcdir && pwd`
330 for mksrc in $mksrc $srcdir/mk $srcdir/../mk mk
332 test -s $mksrc/install-mk || continue
333 mksrc=`cd $mksrc && pwd`
336 mksrc=`echo $mksrc | sed "s,$srcdir,\\\${srcdir},"`
337 echo "Using: MKSRC=$mksrc" 1>&6
338 dnl On some systems we want a different default shell by default
339 if test -x /usr/xpg4/bin/sh; then
340 defshell_path=${defshell_path:-/usr/xpg4/bin/sh}
342 if test -n "$defshell_path"; then
343 echo "Using: SHELL=$defshell_path" >&6
344 AC_DEFINE_UNQUOTED(DEFSHELL_CUSTOM, "$defshell_path", Path of default shell)
346 if test -n "$DEFSHELL_INDEX"; then
347 AC_DEFINE_UNQUOTED(DEFSHELL_INDEX, $DEFSHELL_INDEX, Shell spec to use by default)
351 AC_SUBST(force_machine)
352 AC_SUBST(machine_arch)
354 AC_SUBST(default_sys_path)
360 AC_OUTPUT(Makefile make-bootstrap.sh unit-tests/Makefile)
366 sh ./make-bootstrap.sh
368 to produce a fully functional bmake.