3 dnl $Id: configure.in,v 1.87 2022/09/09 20:00:53 sjg Exp $
5 dnl Process this file with autoconf to produce a configure script
8 AC_INIT([bmake],[20220909],[sjg@NetBSD.org])
9 AC_CONFIG_HEADERS(config.h)
11 dnl make srcdir absolute
14 *) srcdir=`cd $srcdir && 'pwd'`;;
21 dnl function to set DEFSHELL_INDEX
23 case "$defshell_path$DEFSHELL_INDEX" in
28 *csh) # we must be desperate
29 DEFSHELL_INDEX=DEFSHELL_INDEX_CSH;;
31 DEFSHELL_INDEX=DEFSHELL_INDEX_KSH;;
33 DEFSHELL_INDEX=DEFSHELL_INDEX_SH;;
34 *) DEFSHELL_INDEX=DEFSHELL_INDEX_CUSTOM
40 */*) defshell_path=$1;;
45 [ --with-defshell=SHELL use SHELL by default - must be sh compatible, use sh or ksh to pick the internal definitions],
47 yes) AC_MSG_ERROR(bad value ${withval} given for bmake DEFSHELL) ;;
49 *) use_defshell $with_defshell;;
53 CYGWIN*|MINGW*) use_makefile=no;;
57 [ --without-makefile disable use of generated makefile],
59 yes|no) use_makefile=${withval};;
60 *) AC_MSG_ERROR(bad value ${withval} given for makefile) ;;
65 [ --without-meta disable use of meta-mode],
67 yes|no) use_meta=${withval};;
68 *) AC_MSG_ERROR(bad value ${withval} given for meta) ;;
72 [ --with-filemon={no,dev,ktrace,path/filemon.h} indicate filemon method for meta-mode. Path to filemon.h implies dev],
73 [ case "/${withval}" in
75 /*trace) filemon_h=no use_filemon="${withval}";;
76 */filemon.h) filemon_h="${withval}";;
77 */filemon*) filemon_h="${withval}/filemon.h";;
78 *) AC_MSG_ERROR(bad value ${withval} given for filemon) ;;
80 case "$use_filemon,$filemon_h" in
81 ,*.h) use_filemon=dev;;
86 NetBSD) filemon_h=no use_filemon=ktrace;;
88 for d in "/usr/include/dev/filemon" "$prefix/include/dev/filemon" "$srcdir/../../sys/dev/filemon"
92 filemon_h="$d$x/filemon.h"
93 test -s "$filemon_h" && break
95 test -s "$filemon_h" && { use_filemon=dev; break; }
99 use_filemon=${use_filemon:-no}
100 case "$use_filemon" in
105 dnl echo "Note: use_meta=$use_meta use_filemon=$use_filemon filemon_h=$filemon_h" >&6
108 case "$use_filemon" in
110 *) echo "Using: filemon_${use_filemon}.c" >&6;;
115 dnl Check for OS problems
117 dnl Minix 3 at least has bugs in headers where _NETBSD_SOURCE
118 dnl is needed for compilation
120 Minix) CPPFLAGS="${CPPFLAGS} -D_NETBSD_SOURCE"
121 test -x /usr/pkg/bin/clang && CC=${CC:-clang}
123 SCO_SV) # /bin/sh is not usable
124 ALT_DEF_SHELLS="/bin/lsh /usr/bin/bash /bin/ksh"
125 CPPFLAGS="${CPPFLAGS} -DFORCE_USE_SHELL"
129 dnl Not everyone groks TZ=Europe/Berlin
130 dnl which is used by the localtime tests
131 echo $ECHO_N "checking whether system has timezone Europe/Berlin... $ECHO_C" >&6
132 if test -f /usr/share/zoneinfo/Europe/Berlin; then
137 utcH=`TZ=UTC date +%H 2> /dev/null`
138 utc_1H=`TZ=UTC-1 date +%H 2> /dev/null`
139 if test ${utcH-0} -lt ${utc_1H-0}; then
141 echo no, using UTC-1 >&6
147 dnl Add some places to look for compilers
149 for d in /usr/gnu/bin
151 test -d $d || continue
155 dnl Solaris's signal.h only privides sigset_t etc if one of
156 dnl _EXTENSIONS_ _POSIX_C_SOURCE or _XOPEN_SOURCE are defined.
157 dnl The later two seem to cause more problems than they solve so if we
158 dnl see _EXTENSIONS_ we use it.
159 AC_USE_SYSTEM_EXTENSIONS
160 dnl Checks for programs.
163 dnl Executable suffix - normally empty; .exe on os2.
164 AC_SUBST(ac_exe_suffix)dnl
166 dnl Hurd refuses to define PATH_MAX or MAXPATHLEN
167 if test -x /usr/bin/getconf; then
168 bmake_path_max=`getconf PATH_MAX / 2> /dev/null`
169 # only a numeric response is useful
170 test ${bmake_path_max:-0} -gt 0 2> /dev/null || bmake_path_max=
172 bmake_path_max=${bmake_path_max:-1024}
173 if test $bmake_path_max -gt 1024; then
174 # this is all we expect
177 echo "Using: BMAKE_PATH_MAX=$bmake_path_max" >&6
178 AC_SUBST(bmake_path_max)dnl
180 dnl if type does not work which(1) had better!
181 dnl note we cannot rely on type returning non-zero on failure
182 if (type cat) > /dev/null 2>&1; then
185 type "$@" | sed 's,[[()]],,g;s,^[[^/]][[^/]]*,,;q'
188 dnl if CC is somewhere that was not in PATH we need its full path
189 dnl watch out for included flags!
198 if test -x ${_cc:-/dev/null}; then
199 _cc_dir=`dirname $_cc`
207 dnl Checks for header files.
210 dnl Keep this list sorted
211 AC_CHECK_HEADERS(sys/param.h)
212 dnl On BSDi at least we really need sys/param.h for sys/sysctl.h
213 AC_CHECK_HEADERS([sys/sysctl.h], [], [],
214 [#ifdef HAVE_SYS_PARAM_H
215 # include <sys/param.h>
236 dnl Both *BSD and Linux have sys/cdefs.h, most do not.
237 dnl If it is missing, we add -I${srcdir}/missing to CFLAGS
238 AC_CHECK_HEADER(sys/cdefs.h,,
239 CPPFLAGS="${CPPFLAGS} -I`cd ${srcdir}/missing && pwd`")
241 dnl Checks for typedefs, structures, and compiler characteristics.
247 AC_TYPE_LONG_LONG_INT
253 AC_CHECK_DECLS([sys_siglist],[],[],[#include <signal.h>
254 /* NetBSD declares sys_siglist in unistd.h. */
260 AC_CHECK_HEADERS_ONCE([sys/time.h])
264 dnl we need sig_atomic_t
265 AH_TEMPLATE([sig_atomic_t],[type that signal handlers can safely frob])
266 AC_CHECK_TYPES([sig_atomic_t],[],[],
268 #ifdef HAVE_SYS_TYPES_H
269 #include <sys/types.h>
274 dnl Checks for library functions.
278 dnl Keep this list sorted
318 dnl functions which we may need to provide
328 AC_CHECK_LIB([util], [emalloc],
329 [ AC_CHECK_LIB([util], [erealloc],
330 [ AC_CHECK_LIB([util], [estrdup],
331 [ AC_CHECK_LIB([util], [estrndup],
332 [ LIBS="$LIBS -lutil"
333 CPPFLAGS="$CPPFLAGS -DUSE_EMALLOC" ])])])])
340 echo "checking if compiler supports __func__" >&6
342 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[[const char *func = __func__;]])],,
343 AC_DEFINE(__func__, __FUNCTION__, C99 function name))
345 dnl we want this for unit-tests/Makefile
346 dnl GNU diff is known to support -u
347 if test -x /usr/gnu/bin/diff; then
348 diff=/usr/gnu/bin/diff
352 echo $ECHO_N "checking if $diff -u works... $ECHO_C" >&6
353 if $diff -u /dev/null /dev/null > /dev/null 2>&1; then
362 dnl AC_* don't quite cut it.
364 echo "checking for MACHINE & MACHINE_ARCH..." >&6
365 cat > conftest.$ac_ext <<EOF
366 #include "confdefs.h"
367 #include <sys/param.h>
372 machine_arch=MACHINE_ARCH
376 default_machine=`(eval "$ac_cpp conftest.$ac_ext") 2>&5 |
377 grep machine= | tr -d ' "'`
379 if test "$default_machine"; then
380 eval "$default_machine"
382 machine=${machine:-`$srcdir/machine.sh`}
383 machine_arch=${machine_arch:-`$srcdir/machine.sh arch`}
384 echo "defaults: MACHINE=$machine, MACHINE_ARCH=$machine_arch" 1>&6
386 dnl now allow overrides
389 [ --with-machine=MACHINE explicitly set MACHINE],
390 [case "${withval}" in
391 yes) AC_MSG_ERROR(bad value ${withval} given for bmake MACHINE) ;;
393 generic) machine=`$srcdir/machine.sh`;;
394 *) machine=$with_machine;;
397 AC_ARG_WITH(force_machine,
398 [ --with-force-machine=MACHINE set FORCE_MACHINE],
399 [case "${withval}" in
400 yes) force_machine=FORCE_;;
402 *) force_machine=FORCE_; machine=$with_force_machine;;
406 AC_ARG_WITH(force_machine_arch,
407 [ --with-force-machine-arch=MACHINE set FORCE_MACHINE_ARCH],
408 [case "${withval}" in
409 yes) force_machine_arch=FORCE_;;
411 *) force_machine_arch=FORCE_; machine_arch=$with_force_machine_arch;;
414 AC_ARG_WITH(machine_arch,
415 [ --with-machine_arch=MACHINE_ARCH explicitly set MACHINE_ARCH],
416 [case "${withval}" in
417 yes) AC_MSG_ERROR(bad value ${withval} given for bmake MACHINE_ARCH) ;;
419 *) machine_arch=$with_machine_arch;;
422 dnl Tell them what we ended up with
424 echo "Using: ${force_machine}MACHINE=$machine, ${force_machine_arch}MACHINE_ARCH=$machine_arch" 1>&6
426 dnl Allow folk to control _PATH_DEFSYSPATH
428 default_sys_path=\${prefix}/share/mk
429 AC_ARG_WITH(default-sys-path,
430 [ --with-default-sys-path=PATH:DIR:LIST use an explicit _PATH_DEFSYSPATH
431 MAKESYSPATH is a ':' separated list of directories
432 that bmake will search for system .mk files.
433 _PATH_DEFSYSPATH is its default value.],
434 [case "${withval}" in
435 yes) AC_MSG_ERROR(bad value ${withval} given for bmake _PATH_DEFSYSPATH) ;;
437 *) default_sys_path="$with_default_sys_path"
441 dnl Some folk don't like this one
443 AC_ARG_WITH(path-objdirprefix,
444 [ --with-path-objdirprefix=PATH override _PATH_OBJDIRPREFIX],
445 [case "${withval}" in
446 yes) AC_MSG_ERROR(bad value ${withval} given for bmake _PATH_OBJDIRPREFIX) ;;
447 no) CPPFLAGS="$CPPFLAGS -DNO_PATH_OBJDIRPREFIX" ;;
448 *) CPPFLAGS="$CPPFLAGS \"-D_PATH_OBJDIRPREFIX=\\\"$with_path-objdir\\\"\"" ;;
451 dnl And this can be handy to do with out.
453 AC_ARG_ENABLE(pwd-override,
454 [ --disable-pwd-override disable $PWD overriding getcwd()],
455 [case "${enableval}" in
457 no) CPPFLAGS="$CPPFLAGS -DNO_PWD_OVERRIDE" ;;
458 *) AC_MSG_ERROR(bad value ${enableval} given for pwd-override option) ;;
463 AC_ARG_ENABLE(check-make-chdir,
464 [ --disable-check-make-chdir disable make trying to guess
465 when it should automatically cd ${.CURDIR}],
466 [case "${enableval}" in
468 no) CPPFLAGS="$CPPFLAGS -DNO_CHECK_MAKE_CHDIR" ;;
469 *) AC_MSG_ERROR(bad value ${enableval} given for check-make-chdir option) ;;
472 dnl On non-BSD systems, bootstrap won't work without mk
475 [ --with-mksrc=PATH tell makefile.boot where to find mk src],
476 [case "${withval}" in
478 *) test -s $withval/install-mk && mksrc=$withval ||
479 AC_MSG_ERROR(bad value ${withval} given for mksrc cannot find install-mk)
484 dnl Now make sure we have a value
486 srcdir=`cd $srcdir && pwd`
487 for mksrc in $mksrc $srcdir/mk $srcdir/../mk mk
489 test -s $mksrc/install-mk || continue
490 mksrc=`cd $mksrc && pwd`
493 mksrc=`echo $mksrc | sed "s,$srcdir,\\\${srcdir},"`
494 echo "Using: MKSRC=$mksrc" 1>&6
495 dnl On some systems we want a different default shell by default
496 for sh in /usr/xpg4/bin/sh $ALT_DEF_SHELLS
498 test -x $sh || continue
502 case "$defshell_path$DEFSHELL_INDEX" in
504 *DEFSHELL_INDEX_CUSTOM)
505 echo "Using: SHELL=$defshell_path" >&6
506 AC_DEFINE_UNQUOTED(DEFSHELL_CUSTOM, "$defshell_path", Path of default shell)
509 echo "Using: SHELL=$DEFSHELL_INDEX ($defshell_path)" | sed 's,DEFSHELL_INDEX_,,' >&6
510 AC_DEFINE_UNQUOTED(DEFSHELL_INDEX, $DEFSHELL_INDEX, Shell spec to use by default)
511 AC_DEFINE_UNQUOTED(DEFSHELL_PATH, "$defshell_path", Path of default shell)
514 echo "Using: SHELL=$DEFSHELL_INDEX" | sed 's,DEFSHELL_INDEX_,,' >&6
515 AC_DEFINE_UNQUOTED(DEFSHELL_INDEX, $DEFSHELL_INDEX, Shell spec to use by default)
519 dnl Some systems have deprecated egrep in favor of grep -E
520 case "`echo bmake | egrep 'a|b' 2>&1`" in
527 AC_SUBST(force_machine)
528 AC_SUBST(machine_arch)
529 AC_SUBST(force_machine_arch)
531 AC_SUBST(default_sys_path)
537 AC_SUBST(use_filemon)
539 AC_SUBST(_MAKE_VERSION)
541 bm_outfiles="Makefile.config unit-tests/Makefile.config make-bootstrap.sh"
542 if test $use_makefile = yes; then
543 bm_outfiles="makefile $bm_outfiles"
550 $srcdir/obj*) # make sure we put unit-tests/Makefile.config in the right place
552 mkdir -p $srcdir/unit-tests/$obj
553 test -d unit-tests || ln -s ../unit-tests/$obj unit-tests
557 AC_CONFIG_FILES([$bm_outfiles])
563 sh ./make-bootstrap.sh
565 to produce a fully functional bmake.