3 dnl $Id: configure.in,v 1.85 2021/10/23 20:57:08 sjg Exp $
5 dnl Process this file with autoconf to produce a configure script
8 AC_INIT([bmake], [20211020], [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 AC_PROG_GCC_TRADITIONAL
165 dnl Executable suffix - normally empty; .exe on os2.
166 AC_SUBST(ac_exe_suffix)dnl
168 dnl Hurd refuses to define PATH_MAX or MAXPATHLEN
169 if test -x /usr/bin/getconf; then
170 bmake_path_max=`getconf PATH_MAX / 2> /dev/null`
171 # only a numeric response is useful
172 test ${bmake_path_max:-0} -gt 0 2> /dev/null || bmake_path_max=
174 bmake_path_max=${bmake_path_max:-1024}
175 if test $bmake_path_max -gt 1024; then
176 # this is all we expect
179 echo "Using: BMAKE_PATH_MAX=$bmake_path_max" >&6
180 AC_SUBST(bmake_path_max)dnl
184 dnl if type does not work which(1) had better!
185 dnl note we cannot rely on type returning non-zero on failure
186 if (type cat) > /dev/null 2>&1; then
189 type "$@" | sed 's,[[()]],,g;s,^[[^/]][[^/]]*,,;q'
192 dnl if CC is somewhere that was not in PATH we need its full path
193 dnl watch out for included flags!
202 if test -x ${_cc:-/dev/null}; then
203 _cc_dir=`dirname $_cc`
211 dnl Checks for header files.
214 dnl Keep this list sorted
215 AC_CHECK_HEADERS(sys/param.h)
216 dnl On BSDi at least we really need sys/param.h for sys/sysctl.h
217 AC_CHECK_HEADERS([sys/sysctl.h], [], [],
218 [#ifdef HAVE_SYS_PARAM_H
219 # include <sys/param.h>
240 dnl Both *BSD and Linux have sys/cdefs.h, most do not.
241 dnl If it is missing, we add -I${srcdir}/missing to CFLAGS
242 AC_CHECK_HEADER(sys/cdefs.h,,
243 CPPFLAGS="${CPPFLAGS} -I`cd ${srcdir}/missing && pwd`")
245 dnl Checks for typedefs, structures, and compiler characteristics.
251 AC_TYPE_LONG_LONG_INT
261 dnl we need sig_atomic_t
262 AH_TEMPLATE([sig_atomic_t],[type that signal handlers can safely frob])
263 AC_CHECK_TYPES([sig_atomic_t],[],[],
265 #ifdef HAVE_SYS_TYPES_H
266 #include <sys/types.h>
271 dnl Checks for library functions.
276 dnl Keep this list sorted
316 dnl functions which we may need to provide
326 AC_CHECK_LIB([util], [emalloc],
327 [ AC_CHECK_LIB([util], [erealloc],
328 [ AC_CHECK_LIB([util], [estrdup],
329 [ AC_CHECK_LIB([util], [estrndup],
330 [ LIBS="$LIBS -lutil"
331 CPPFLAGS="$CPPFLAGS -DUSE_EMALLOC" ])])])])
339 echo "checking if compiler supports __func__" >&6
341 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[[const char *func = __func__;]])],,
342 AC_DEFINE(__func__, __FUNCTION__, C99 function name))
344 dnl we want this for unit-tests/Makefile
345 dnl GNU diff is known to support -u
346 if test -x /usr/gnu/bin/diff; then
347 diff=/usr/gnu/bin/diff
351 echo $ECHO_N "checking if $diff -u works... $ECHO_C" >&6
352 if $diff -u /dev/null /dev/null > /dev/null 2>&1; then
361 dnl AC_* don't quite cut it.
363 echo "checking for MACHINE & MACHINE_ARCH..." >&6
364 cat > conftest.$ac_ext <<EOF
365 #include "confdefs.h"
366 #include <sys/param.h>
371 machine_arch=MACHINE_ARCH
375 default_machine=`(eval "$ac_cpp conftest.$ac_ext") 2>&5 |
376 egrep machine= | tr -d ' "'`
378 if test "$default_machine"; then
379 eval "$default_machine"
381 machine=${machine:-`$srcdir/machine.sh`}
382 machine_arch=${machine_arch:-`$srcdir/machine.sh arch`}
383 echo "defaults: MACHINE=$machine, MACHINE_ARCH=$machine_arch" 1>&6
385 dnl now allow overrides
388 [ --with-machine=MACHINE explicitly set MACHINE],
389 [case "${withval}" in
390 yes) AC_MSG_ERROR(bad value ${withval} given for bmake MACHINE) ;;
392 generic) machine=`$srcdir/machine.sh`;;
393 *) machine=$with_machine;;
396 AC_ARG_WITH(force_machine,
397 [ --with-force-machine=MACHINE set FORCE_MACHINE],
398 [case "${withval}" in
399 yes) force_machine=FORCE_;;
401 *) force_machine=FORCE_; machine=$with_force_machine;;
405 AC_ARG_WITH(force_machine_arch,
406 [ --with-force-machine-arch=MACHINE set FORCE_MACHINE_ARCH],
407 [case "${withval}" in
408 yes) force_machine_arch=FORCE_;;
410 *) force_machine_arch=FORCE_; machine_arch=$with_force_machine_arch;;
413 AC_ARG_WITH(machine_arch,
414 [ --with-machine_arch=MACHINE_ARCH explicitly set MACHINE_ARCH],
415 [case "${withval}" in
416 yes) AC_MSG_ERROR(bad value ${withval} given for bmake MACHINE_ARCH) ;;
418 *) machine_arch=$with_machine_arch;;
421 dnl Tell them what we ended up with
423 echo "Using: ${force_machine}MACHINE=$machine, ${force_machine_arch}MACHINE_ARCH=$machine_arch" 1>&6
425 dnl Allow folk to control _PATH_DEFSYSPATH
427 default_sys_path=\${prefix}/share/mk
428 AC_ARG_WITH(default-sys-path,
429 [ --with-default-sys-path=PATH:DIR:LIST use an explicit _PATH_DEFSYSPATH
430 MAKESYSPATH is a ':' separated list of directories
431 that bmake will search for system .mk files.
432 _PATH_DEFSYSPATH is its default value.],
433 [case "${withval}" in
434 yes) AC_MSG_ERROR(bad value ${withval} given for bmake _PATH_DEFSYSPATH) ;;
436 *) default_sys_path="$with_default_sys_path"
440 dnl Some folk don't like this one
442 AC_ARG_WITH(path-objdirprefix,
443 [ --with-path-objdirprefix=PATH override _PATH_OBJDIRPREFIX],
444 [case "${withval}" in
445 yes) AC_MSG_ERROR(bad value ${withval} given for bmake _PATH_OBJDIRPREFIX) ;;
446 no) CPPFLAGS="$CPPFLAGS -DNO_PATH_OBJDIRPREFIX" ;;
447 *) CPPFLAGS="$CPPFLAGS \"-D_PATH_OBJDIRPREFIX=\\\"$with_path-objdir\\\"\"" ;;
450 dnl And this can be handy to do with out.
452 AC_ARG_ENABLE(pwd-override,
453 [ --disable-pwd-override disable $PWD overriding getcwd()],
454 [case "${enableval}" in
456 no) CPPFLAGS="$CPPFLAGS -DNO_PWD_OVERRIDE" ;;
457 *) AC_MSG_ERROR(bad value ${enableval} given for pwd-override option) ;;
462 AC_ARG_ENABLE(check-make-chdir,
463 [ --disable-check-make-chdir disable make trying to guess
464 when it should automatically cd ${.CURDIR}],
465 [case "${enableval}" in
467 no) CPPFLAGS="$CPPFLAGS -DNO_CHECK_MAKE_CHDIR" ;;
468 *) AC_MSG_ERROR(bad value ${enableval} given for check-make-chdir option) ;;
471 dnl On non-BSD systems, bootstrap won't work without mk
474 [ --with-mksrc=PATH tell makefile.boot where to find mk src],
475 [case "${withval}" in
477 *) test -s $withval/install-mk && mksrc=$withval ||
478 AC_MSG_ERROR(bad value ${withval} given for mksrc cannot find install-mk)
483 dnl Now make sure we have a value
485 srcdir=`cd $srcdir && pwd`
486 for mksrc in $mksrc $srcdir/mk $srcdir/../mk mk
488 test -s $mksrc/install-mk || continue
489 mksrc=`cd $mksrc && pwd`
492 mksrc=`echo $mksrc | sed "s,$srcdir,\\\${srcdir},"`
493 echo "Using: MKSRC=$mksrc" 1>&6
494 dnl On some systems we want a different default shell by default
495 for sh in /usr/xpg4/bin/sh $ALT_DEF_SHELLS
497 test -x $sh || continue
501 case "$defshell_path$DEFSHELL_INDEX" in
503 *DEFSHELL_INDEX_CUSTOM)
504 echo "Using: SHELL=$defshell_path" >&6
505 AC_DEFINE_UNQUOTED(DEFSHELL_CUSTOM, "$defshell_path", Path of default shell)
508 echo "Using: SHELL=$DEFSHELL_INDEX ($defshell_path)" | sed 's,DEFSHELL_INDEX_,,' >&6
509 AC_DEFINE_UNQUOTED(DEFSHELL_INDEX, $DEFSHELL_INDEX, Shell spec to use by default)
510 AC_DEFINE_UNQUOTED(DEFSHELL_PATH, "$defshell_path", Path of default shell)
513 echo "Using: SHELL=$DEFSHELL_INDEX" | sed 's,DEFSHELL_INDEX_,,' >&6
514 AC_DEFINE_UNQUOTED(DEFSHELL_INDEX, $DEFSHELL_INDEX, Shell spec to use by default)
519 AC_SUBST(force_machine)
520 AC_SUBST(machine_arch)
521 AC_SUBST(force_machine_arch)
523 AC_SUBST(default_sys_path)
529 AC_SUBST(use_filemon)
531 AC_SUBST(_MAKE_VERSION)
533 bm_outfiles="Makefile.config unit-tests/Makefile.config make-bootstrap.sh"
534 if test $use_makefile = yes; then
535 bm_outfiles="makefile $bm_outfiles"
542 $srcdir/obj*) # make sure we put unit-tests/Makefile.config in the right place
544 mkdir -p $srcdir/unit-tests/$obj
545 test -d unit-tests || ln -s ../unit-tests/$obj unit-tests
549 AC_OUTPUT($bm_outfiles)
554 sh ./make-bootstrap.sh
556 to produce a fully functional bmake.