3 dnl $Id: configure.in,v 1.70 2021/02/01 18:29:26 sjg Exp $
5 dnl Process this file with autoconf to produce a configure script
8 AC_INIT([bmake], [20210201], [sjg@NetBSD.org])
9 AC_CONFIG_HEADERS(config.h)
11 dnl make srcdir absolute
14 *) srcdir=`cd $srcdir && pwd`;;
23 [ --with-defshell=SHELL use SHELL by default - must be sh compatible, use sh or ksh to pick the internal definitions],
25 yes) AC_MSG_ERROR(bad value ${withval} given for bmake DEFSHELL) ;;
27 *) case "$with_defshell" in
28 sh) DEFSHELL_INDEX=DEFSHELL_INDEX_SH;; # it's the default anyway
29 ksh) DEFSHELL_INDEX=DEFSHELL_INDEX_KSH;;
30 csh) DEFSHELL_INDEX=DEFSHELL_INDEX_CSH;; # kidding right?
31 *) defshell_path=$with_defshell;; # better be sh compatible!
37 CYGWIN*|MINGW*) use_makefile=no;;
41 [ --without-makefile disable use of generated makefile],
43 yes|no) use_makefile=${withval};;
44 *) AC_MSG_ERROR(bad value ${withval} given for makefile) ;;
49 [ --without-meta disable use of meta-mode],
51 yes|no) use_meta=${withval};;
52 *) AC_MSG_ERROR(bad value ${withval} given for meta) ;;
56 [ --with-filemon={no,dev,ktrace,path/filemon.h} indicate filemon method for meta-mode. Path to filemon.h implies dev],
57 [ case "/${withval}" in
59 /*trace) filemon_h=no use_filemon="${withval}";;
60 */filemon.h) filemon_h="${withval}";;
61 */filemon*) filemon_h="${withval}/filemon.h";;
62 *) AC_MSG_ERROR(bad value ${withval} given for filemon) ;;
64 case "$use_filemon,$filemon_h" in
65 ,*.h) use_filemon=dev;;
70 NetBSD) filemon_h=no use_filemon=ktrace;;
72 for d in "/usr/include/dev/filemon" "$prefix/include/dev/filemon" "$srcdir/../../sys/dev/filemon"
76 filemon_h="$d$x/filemon.h"
77 test -s "$filemon_h" && break
79 test -s "$filemon_h" && { use_filemon=dev; break; }
83 use_filemon=${use_filemon:-no}
84 case "$use_filemon" in
89 dnl echo "Note: use_meta=$use_meta use_filemon=$use_filemon filemon_h=$filemon_h" >&6
92 case "$use_filemon" in
94 *) echo "Using: filemon_${use_filemon}.c" >&6;;
99 dnl Check for OS problems
100 dnl Solaris's signal.h only privides sigset_t etc if one of
101 dnl _EXTENSIONS_ _POSIX_C_SOURCE or _XOPEN_SOURCE are defined.
102 dnl The later two seem to cause more problems than they solve so if we
103 dnl see _EXTENSIONS_ we use it.
104 AC_USE_SYSTEM_EXTENSIONS
105 dnl Checks for programs.
108 dnl AC_PROG_GCC_TRADITIONAL
110 dnl Executable suffix - normally empty; .exe on os2.
111 AC_SUBST(ac_exe_suffix)dnl
113 dnl Hurd refuses to define PATH_MAX or MAXPATHLEN
114 if test -x /usr/bin/getconf; then
115 bmake_path_max=`getconf PATH_MAX / 2> /dev/null`
116 # only a numeric response is useful
117 test ${bmake_path_max:-0} -gt 0 2> /dev/null || bmake_path_max=
119 bmake_path_max=${bmake_path_max:-1024}
120 if test $bmake_path_max -gt 1024; then
121 # this is all we expect
124 echo "Using: BMAKE_PATH_MAX=$bmake_path_max" >&6
125 AC_SUBST(bmake_path_max)dnl
130 dnl Checks for header files.
133 dnl Keep this list sorted
134 AC_CHECK_HEADERS(sys/param.h)
135 dnl On BSDi at least we really need sys/param.h for sys/sysctl.h
136 AC_CHECK_HEADERS([sys/sysctl.h], [], [],
137 [#ifdef HAVE_SYS_PARAM_H
138 # include <sys/param.h>
159 dnl Both *BSD and Linux have sys/cdefs.h, most do not.
160 dnl If it is missing, we add -I${srcdir}/missing to CFLAGS
161 dnl also if sys/cdefs.h does not have __RCSID we need to use ours
162 dnl but we need to include the host's one too *sigh*
163 AC_CHECK_HEADER(sys/cdefs.h,
164 echo $ECHO_N "checking whether sys/cdefs.h is compatible... $ECHO_C" >&6
166 [#include <sys/cdefs.h>
172 echo no >&6; CPPFLAGS="${CPPFLAGS} -I`cd ${srcdir}/missing && pwd` -DNEED_HOST_CDEFS_H"),
173 CPPFLAGS="${CPPFLAGS} -I`cd ${srcdir}/missing && pwd`")
175 dnl Checks for typedefs, structures, and compiler characteristics.
188 dnl we need sig_atomic_t
189 AH_TEMPLATE([sig_atomic_t],[type that signal handlers can safely frob])
190 AC_CHECK_TYPE(sig_atomic_t,,[
191 AC_DEFINE([sig_atomic_t],[int],)
193 #ifdef HAVE_SYS_TYPES_H
194 #include <sys/types.h>
199 dnl Checks for library functions.
204 dnl Keep this list sorted
237 dnl functions which we may need to provide
245 AC_CHECK_LIB([util], [emalloc],
246 [ AC_CHECK_LIB([util], [erealloc],
247 [ AC_CHECK_LIB([util], [estrdup],
248 [ AC_CHECK_LIB([util], [estrndup],
249 [ LIBS="$LIBS -lutil"
250 CPPFLAGS="$CPPFLAGS -DUSE_EMALLOC" ])])])])
258 echo "checking if compiler supports __func__" >&6
260 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[[const char *func = __func__;]])],,
261 AC_DEFINE(__func__, __FUNCTION__, C99 function name))
263 dnl we want this for unit-tests/Makefile
264 echo $ECHO_N "checking if diff -u works... $ECHO_C" >&6
265 if diff -u /dev/null /dev/null > /dev/null 2>&1; then
273 dnl AC_* don't quite cut it.
275 echo "checking for MACHINE & MACHINE_ARCH..." >&6
276 cat > conftest.$ac_ext <<EOF
277 #include "confdefs.h"
278 #include <sys/param.h>
283 machine_arch=MACHINE_ARCH
287 default_machine=`(eval "$ac_cpp conftest.$ac_ext") 2>&5 |
288 egrep machine= | tr -d ' "'`
290 if test "$default_machine"; then
291 eval "$default_machine"
293 machine=${machine:-`$srcdir/machine.sh`}
294 machine_arch=${machine_arch:-`$srcdir/machine.sh arch`}
295 echo "defaults: MACHINE=$machine, MACHINE_ARCH=$machine_arch" 1>&6
297 dnl now allow overrides
300 [ --with-machine=MACHINE explicitly set MACHINE],
301 [case "${withval}" in
302 yes) AC_MSG_ERROR(bad value ${withval} given for bmake MACHINE) ;;
304 generic) machine=`$srcdir/machine.sh`;;
305 *) machine=$with_machine;;
308 AC_ARG_WITH(force_machine,
309 [ --with-force-machine=MACHINE set FORCE_MACHINE],
310 [case "${withval}" in
311 yes) force_machine=FORCE_;;
313 *) force_machine=FORCE_; machine=$with_force_machine;;
317 AC_ARG_WITH(force_machine_arch,
318 [ --with-force-machine-arch=MACHINE set FORCE_MACHINE_ARCH],
319 [case "${withval}" in
320 yes) force_machine_arch=FORCE_;;
322 *) force_machine_arch=FORCE_; machine_arch=$with_force_machine_arch;;
325 AC_ARG_WITH(machine_arch,
326 [ --with-machine_arch=MACHINE_ARCH explicitly set MACHINE_ARCH],
327 [case "${withval}" in
328 yes) AC_MSG_ERROR(bad value ${withval} given for bmake MACHINE_ARCH) ;;
330 *) machine_arch=$with_machine_arch;;
333 dnl Tell them what we ended up with
335 echo "Using: ${force_machine}MACHINE=$machine, ${force_machine_arch}MACHINE_ARCH=$machine_arch" 1>&6
337 dnl Allow folk to control _PATH_DEFSYSPATH
339 default_sys_path=\${prefix}/share/mk
340 AC_ARG_WITH(default-sys-path,
341 [ --with-default-sys-path=PATH:DIR:LIST use an explicit _PATH_DEFSYSPATH
342 MAKESYSPATH is a ':' separated list of directories
343 that bmake will search for system .mk files.
344 _PATH_DEFSYSPATH is its default value.],
345 [case "${withval}" in
346 yes) AC_MSG_ERROR(bad value ${withval} given for bmake _PATH_DEFSYSPATH) ;;
348 *) default_sys_path="$with_default_sys_path"
352 dnl Some folk don't like this one
354 AC_ARG_WITH(path-objdirprefix,
355 [ --with-path-objdirprefix=PATH override _PATH_OBJDIRPREFIX],
356 [case "${withval}" in
357 yes) AC_MSG_ERROR(bad value ${withval} given for bmake _PATH_OBJDIRPREFIX) ;;
358 no) CPPFLAGS="$CPPFLAGS -DNO_PATH_OBJDIRPREFIX" ;;
359 *) CPPFLAGS="$CPPFLAGS \"-D_PATH_OBJDIRPREFIX=\\\"$with_path-objdir\\\"\"" ;;
362 dnl And this can be handy to do with out.
364 AC_ARG_ENABLE(pwd-override,
365 [ --disable-pwd-override disable $PWD overriding getcwd()],
366 [case "${enableval}" in
368 no) CPPFLAGS="$CPPFLAGS -DNO_PWD_OVERRIDE" ;;
369 *) AC_MSG_ERROR(bad value ${enableval} given for pwd-override option) ;;
374 AC_ARG_ENABLE(check-make-chdir,
375 [ --disable-check-make-chdir disable make trying to guess
376 when it should automatically cd ${.CURDIR}],
377 [case "${enableval}" in
379 no) CPPFLAGS="$CPPFLAGS -DNO_CHECK_MAKE_CHDIR" ;;
380 *) AC_MSG_ERROR(bad value ${enableval} given for check-make-chdir option) ;;
383 dnl On non-BSD systems, bootstrap won't work without mk
386 [ --with-mksrc=PATH tell makefile.boot where to find mk src],
387 [case "${withval}" in
389 *) test -s $withval/install-mk && mksrc=$withval ||
390 AC_MSG_ERROR(bad value ${withval} given for mksrc cannot find install-mk)
395 dnl Now make sure we have a value
397 srcdir=`cd $srcdir && pwd`
398 for mksrc in $mksrc $srcdir/mk $srcdir/../mk mk
400 test -s $mksrc/install-mk || continue
401 mksrc=`cd $mksrc && pwd`
404 mksrc=`echo $mksrc | sed "s,$srcdir,\\\${srcdir},"`
405 echo "Using: MKSRC=$mksrc" 1>&6
406 dnl On some systems we want a different default shell by default
407 if test -x /usr/xpg4/bin/sh; then
408 defshell_path=${defshell_path:-/usr/xpg4/bin/sh}
410 if test -n "$defshell_path"; then
411 echo "Using: SHELL=$defshell_path" >&6
412 AC_DEFINE_UNQUOTED(DEFSHELL_CUSTOM, "$defshell_path", Path of default shell)
414 if test -n "$DEFSHELL_INDEX"; then
415 AC_DEFINE_UNQUOTED(DEFSHELL_INDEX, $DEFSHELL_INDEX, Shell spec to use by default)
419 AC_SUBST(force_machine)
420 AC_SUBST(machine_arch)
421 AC_SUBST(force_machine_arch)
423 AC_SUBST(default_sys_path)
428 AC_SUBST(use_filemon)
430 AC_SUBST(_MAKE_VERSION)
431 bm_outfiles="Makefile.config unit-tests/Makefile.config make-bootstrap.sh"
432 if test $use_makefile = yes; then
433 bm_outfiles="makefile $bm_outfiles"
435 AC_OUTPUT($bm_outfiles)
440 sh ./make-bootstrap.sh
442 to produce a fully functional bmake.