1dnl 2dnl RCSid: 3dnl $Id: configure.in,v 1.87 2022/09/09 20:00:53 sjg Exp $ 4dnl 5dnl Process this file with autoconf to produce a configure script 6dnl 7AC_PREREQ([2.71]) 8AC_INIT([bmake],[20220909],[sjg@NetBSD.org]) 9AC_CONFIG_HEADERS(config.h) 10 11dnl make srcdir absolute 12case "$srcdir" in 13/*) ;; 14*) srcdir=`cd $srcdir && 'pwd'`;; 15esac 16 17dnl get _MAKE_VERSION 18. $srcdir/VERSION 19OS=`uname -s` 20 21dnl function to set DEFSHELL_INDEX 22use_defshell() { 23 case "$defshell_path$DEFSHELL_INDEX" in 24 "") ;; 25 *) return 0;; 26 esac 27 case "$1" in 28 *csh) # we must be desperate 29 DEFSHELL_INDEX=DEFSHELL_INDEX_CSH;; 30 *ksh) 31 DEFSHELL_INDEX=DEFSHELL_INDEX_KSH;; 32 sh|/bin/sh) 33 DEFSHELL_INDEX=DEFSHELL_INDEX_SH;; 34 *) DEFSHELL_INDEX=DEFSHELL_INDEX_CUSTOM 35 defshell_path=$1 36 ;; 37 esac 38 case "$1" in 39 /bin/*) ;; 40 */*) defshell_path=$1;; 41 esac 42} 43dnl 44AC_ARG_WITH(defshell, 45[ --with-defshell=SHELL use SHELL by default - must be sh compatible, use sh or ksh to pick the internal definitions], 46[case "${withval}" in 47yes) AC_MSG_ERROR(bad value ${withval} given for bmake DEFSHELL) ;; 48no) ;; 49*) use_defshell $with_defshell;; 50esac]) 51dnl 52case "$OS" in 53CYGWIN*|MINGW*) use_makefile=no;; 54*) use_makefile=yes;; 55esac 56AC_ARG_WITH(makefile, 57[ --without-makefile disable use of generated makefile], 58[case "${withval}" in 59yes|no) use_makefile=${withval};; 60*) AC_MSG_ERROR(bad value ${withval} given for makefile) ;; 61esac]) 62dnl 63use_meta=yes 64AC_ARG_WITH(meta, 65[ --without-meta disable use of meta-mode], 66[case "${withval}" in 67yes|no) use_meta=${withval};; 68*) AC_MSG_ERROR(bad value ${withval} given for meta) ;; 69esac]) 70dnl 71AC_ARG_WITH(filemon, 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 74/no) use_filemon=no;; 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) ;; 79esac 80case "$use_filemon,$filemon_h" in 81,*.h) use_filemon=dev;; 82esac 83], 84[ 85case "$OS" in 86NetBSD) filemon_h=no use_filemon=ktrace;; 87*) 88 for d in "/usr/include/dev/filemon" "$prefix/include/dev/filemon" "$srcdir/../../sys/dev/filemon" 89 do 90 for x in "/$OS" "" 91 do 92 filemon_h="$d$x/filemon.h" 93 test -s "$filemon_h" && break 94 done 95 test -s "$filemon_h" && { use_filemon=dev; break; } 96 done 97 ;; 98esac 99use_filemon=${use_filemon:-no} 100case "$use_filemon" in 101dev) ;; 102*) filemon_h=no;; 103esac 104]) 105dnl echo "Note: use_meta=$use_meta use_filemon=$use_filemon filemon_h=$filemon_h" >&6 106case "$use_meta" in 107yes) 108 case "$use_filemon" in 109 no) ;; 110 *) echo "Using: filemon_${use_filemon}.c" >&6;; 111 esac 112 ;; 113esac 114dnl 115dnl Check for OS problems 116dnl 117dnl Minix 3 at least has bugs in headers where _NETBSD_SOURCE 118dnl is needed for compilation 119case "$OS" in 120Minix) CPPFLAGS="${CPPFLAGS} -D_NETBSD_SOURCE" 121 test -x /usr/pkg/bin/clang && CC=${CC:-clang} 122 ;; 123SCO_SV) # /bin/sh is not usable 124 ALT_DEF_SHELLS="/bin/lsh /usr/bin/bash /bin/ksh" 125 CPPFLAGS="${CPPFLAGS} -DFORCE_USE_SHELL" 126 ;; 127esac 128dnl 129dnl Not everyone groks TZ=Europe/Berlin 130dnl which is used by the localtime tests 131echo $ECHO_N "checking whether system has timezone Europe/Berlin... $ECHO_C" >&6 132if test -f /usr/share/zoneinfo/Europe/Berlin; then 133 echo yes >&6 134 # seems a safe bet 135 UTC_1=Europe/Berlin 136else 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 140 UTC_1=UTC-1 141 echo no, using UTC-1 >&6 142 else 143 echo no >&6 144 fi 145fi 146dnl 147dnl Add some places to look for compilers 148oldPATH=$PATH 149for d in /usr/gnu/bin 150do 151 test -d $d || continue 152 PATH=$PATH:$d 153done 154export PATH 155dnl Solaris's signal.h only privides sigset_t etc if one of 156dnl _EXTENSIONS_ _POSIX_C_SOURCE or _XOPEN_SOURCE are defined. 157dnl The later two seem to cause more problems than they solve so if we 158dnl see _EXTENSIONS_ we use it. 159AC_USE_SYSTEM_EXTENSIONS 160dnl Checks for programs. 161AC_PROG_CC 162AC_PROG_INSTALL 163dnl Executable suffix - normally empty; .exe on os2. 164AC_SUBST(ac_exe_suffix)dnl 165dnl 166dnl Hurd refuses to define PATH_MAX or MAXPATHLEN 167if 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= 171fi 172bmake_path_max=${bmake_path_max:-1024} 173if test $bmake_path_max -gt 1024; then 174 # this is all we expect 175 bmake_path_max=1024 176fi 177echo "Using: BMAKE_PATH_MAX=$bmake_path_max" >&6 178AC_SUBST(bmake_path_max)dnl 179dnl 180dnl if type does not work which(1) had better! 181dnl note we cannot rely on type returning non-zero on failure 182if (type cat) > /dev/null 2>&1; then 183: which 184which() { 185 type "$@" | sed 's,[[()]],,g;s,^[[^/]][[^/]]*,,;q' 186} 187fi 188dnl if CC is somewhere that was not in PATH we need its full path 189dnl watch out for included flags! 190case "$CC" in 191/*) ;; 192*) 193 for x in $CC 194 do 195 _cc=`which $x` 196 break 197 done 198 if test -x ${_cc:-/dev/null}; then 199 _cc_dir=`dirname $_cc` 200 case ":$oldPATH:" in 201 *:$_cc_dir:*) ;; 202 *) CC=$_cc_dir/$CC;; 203 esac 204 fi 205 ;; 206esac 207dnl Checks for header files. 208AC_HEADER_SYS_WAIT 209AC_HEADER_DIRENT 210dnl Keep this list sorted 211AC_CHECK_HEADERS(sys/param.h) 212dnl On BSDi at least we really need sys/param.h for sys/sysctl.h 213AC_CHECK_HEADERS([sys/sysctl.h], [], [], 214[#ifdef HAVE_SYS_PARAM_H 215# include <sys/param.h> 216# endif 217]) 218 219AC_CHECK_HEADERS( \ 220 ar.h \ 221 err.h \ 222 fcntl.h \ 223 libgen.h \ 224 limits.h \ 225 paths.h \ 226 poll.h \ 227 ranlib.h \ 228 sys/mman.h \ 229 sys/select.h \ 230 sys/socket.h \ 231 sys/time.h \ 232 sys/uio.h \ 233 utime.h \ 234 ) 235 236dnl Both *BSD and Linux have sys/cdefs.h, most do not. 237dnl If it is missing, we add -I${srcdir}/missing to CFLAGS 238AC_CHECK_HEADER(sys/cdefs.h,, 239CPPFLAGS="${CPPFLAGS} -I`cd ${srcdir}/missing && pwd`") 240 241dnl Checks for typedefs, structures, and compiler characteristics. 242AC_C___ATTRIBUTE__ 243AC_C_BIGENDIAN 244AC_C_CONST 245AC_C_INLINE 246AC_TYPE_INT64_T 247AC_TYPE_LONG_LONG_INT 248AC_TYPE_MODE_T 249AC_TYPE_OFF_T 250AC_TYPE_PID_T 251AC_TYPE_SIZE_T 252AC_TYPE_UINT32_T 253AC_CHECK_DECLS([sys_siglist],[],[],[#include <signal.h> 254/* NetBSD declares sys_siglist in unistd.h. */ 255#ifdef HAVE_UNISTD_H 256# include <unistd.h> 257#endif 258]) 259 260AC_CHECK_HEADERS_ONCE([sys/time.h]) 261 262AC_STRUCT_TM 263 264dnl we need sig_atomic_t 265AH_TEMPLATE([sig_atomic_t],[type that signal handlers can safely frob]) 266AC_CHECK_TYPES([sig_atomic_t],[],[], 267[ 268#ifdef HAVE_SYS_TYPES_H 269#include <sys/types.h> 270#endif 271#include <signal.h> 272]) 273 274dnl Checks for library functions. 275AC_FUNC_FORK 276AC_FUNC_VPRINTF 277AC_FUNC_WAIT3 278dnl Keep this list sorted 279AC_CHECK_FUNCS( \ 280 err \ 281 errx \ 282 getcwd \ 283 getenv \ 284 getwd \ 285 killpg \ 286 mmap \ 287 putenv \ 288 select \ 289 setenv \ 290 setpgid \ 291 setrlimit \ 292 setsid \ 293 sigaddset \ 294 sigpending \ 295 sigprocmask \ 296 sigsetmask \ 297 sigsuspend \ 298 sigvec \ 299 snprintf \ 300 strerror \ 301 stresep \ 302 strftime \ 303 strsep \ 304 strtod \ 305 strtol \ 306 strtoll \ 307 strtoul \ 308 sysctl \ 309 unsetenv \ 310 vsnprintf \ 311 wait3 \ 312 wait4 \ 313 waitpid \ 314 warn \ 315 warnx \ 316 ) 317 318dnl functions which we may need to provide 319AC_REPLACE_FUNCS( \ 320 getopt \ 321 realpath \ 322 dirname \ 323 sigaction \ 324 stresep \ 325 strlcpy \ 326 ) 327 328AC_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" ])])])]) 334 335dnl 336dnl Structures 337dnl 338AC_HEADER_STAT 339dnl 340echo "checking if compiler supports __func__" >&6 341AC_LANG(C) 342AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[[const char *func = __func__;]])],, 343 AC_DEFINE(__func__, __FUNCTION__, C99 function name)) 344dnl 345dnl we want this for unit-tests/Makefile 346dnl GNU diff is known to support -u 347if test -x /usr/gnu/bin/diff; then 348 diff=/usr/gnu/bin/diff 349 diff_u=-u 350else 351 diff=${diff:-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 354 diff_u=-u 355 echo yes >&6 356 else 357 diff_u= 358 echo no >&6 359 fi 360fi 361dnl 362dnl AC_* don't quite cut it. 363dnl 364echo "checking for MACHINE & MACHINE_ARCH..." >&6 365cat > conftest.$ac_ext <<EOF 366#include "confdefs.h" 367#include <sys/param.h> 368#ifdef MACHINE 369machine=MACHINE 370#endif 371#ifdef MACHINE_ARCH 372machine_arch=MACHINE_ARCH 373#endif 374EOF 375 376default_machine=`(eval "$ac_cpp conftest.$ac_ext") 2>&5 | 377 grep machine= | tr -d ' "'` 378rm -rf conftest* 379if test "$default_machine"; then 380 eval "$default_machine" 381fi 382machine=${machine:-`$srcdir/machine.sh`} 383machine_arch=${machine_arch:-`$srcdir/machine.sh arch`} 384echo "defaults: MACHINE=$machine, MACHINE_ARCH=$machine_arch" 1>&6 385dnl 386dnl now allow overrides 387dnl 388AC_ARG_WITH(machine, 389[ --with-machine=MACHINE explicitly set MACHINE], 390[case "${withval}" in 391yes) AC_MSG_ERROR(bad value ${withval} given for bmake MACHINE) ;; 392no) ;; 393generic) machine=`$srcdir/machine.sh`;; 394*) machine=$with_machine;; 395esac]) 396force_machine= 397AC_ARG_WITH(force_machine, 398[ --with-force-machine=MACHINE set FORCE_MACHINE], 399[case "${withval}" in 400yes) force_machine=FORCE_;; 401no) ;; 402*) force_machine=FORCE_; machine=$with_force_machine;; 403esac]) 404dnl 405force_machine_arch= 406AC_ARG_WITH(force_machine_arch, 407[ --with-force-machine-arch=MACHINE set FORCE_MACHINE_ARCH], 408[case "${withval}" in 409yes) force_machine_arch=FORCE_;; 410no) ;; 411*) force_machine_arch=FORCE_; machine_arch=$with_force_machine_arch;; 412esac]) 413dnl 414AC_ARG_WITH(machine_arch, 415[ --with-machine_arch=MACHINE_ARCH explicitly set MACHINE_ARCH], 416[case "${withval}" in 417yes) AC_MSG_ERROR(bad value ${withval} given for bmake MACHINE_ARCH) ;; 418no) ;; 419*) machine_arch=$with_machine_arch;; 420esac]) 421dnl 422dnl Tell them what we ended up with 423dnl 424echo "Using: ${force_machine}MACHINE=$machine, ${force_machine_arch}MACHINE_ARCH=$machine_arch" 1>&6 425dnl 426dnl Allow folk to control _PATH_DEFSYSPATH 427dnl 428default_sys_path=\${prefix}/share/mk 429AC_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 435yes) AC_MSG_ERROR(bad value ${withval} given for bmake _PATH_DEFSYSPATH) ;; 436no) ;; 437*) default_sys_path="$with_default_sys_path" 438 ;; 439esac]) 440dnl 441dnl Some folk don't like this one 442dnl 443AC_ARG_WITH(path-objdirprefix, 444[ --with-path-objdirprefix=PATH override _PATH_OBJDIRPREFIX], 445[case "${withval}" in 446yes) AC_MSG_ERROR(bad value ${withval} given for bmake _PATH_OBJDIRPREFIX) ;; 447no) CPPFLAGS="$CPPFLAGS -DNO_PATH_OBJDIRPREFIX" ;; 448*) CPPFLAGS="$CPPFLAGS \"-D_PATH_OBJDIRPREFIX=\\\"$with_path-objdir\\\"\"" ;; 449esac]) 450dnl 451dnl And this can be handy to do with out. 452dnl 453AC_ARG_ENABLE(pwd-override, 454[ --disable-pwd-override disable $PWD overriding getcwd()], 455[case "${enableval}" in 456yes) ;; 457no) CPPFLAGS="$CPPFLAGS -DNO_PWD_OVERRIDE" ;; 458*) AC_MSG_ERROR(bad value ${enableval} given for pwd-override option) ;; 459esac]) 460dnl 461dnl Just for grins 462dnl 463AC_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 467yes) ;; 468no) CPPFLAGS="$CPPFLAGS -DNO_CHECK_MAKE_CHDIR" ;; 469*) AC_MSG_ERROR(bad value ${enableval} given for check-make-chdir option) ;; 470esac]) 471dnl 472dnl On non-BSD systems, bootstrap won't work without mk 473dnl 474AC_ARG_WITH(mksrc, 475[ --with-mksrc=PATH tell makefile.boot where to find mk src], 476[case "${withval}" in 477""|yes|no) ;; 478*) test -s $withval/install-mk && mksrc=$withval || 479AC_MSG_ERROR(bad value ${withval} given for mksrc cannot find install-mk) 480;; 481esac 482]) 483dnl 484dnl Now make sure we have a value 485dnl 486srcdir=`cd $srcdir && pwd` 487for mksrc in $mksrc $srcdir/mk $srcdir/../mk mk 488do 489 test -s $mksrc/install-mk || continue 490 mksrc=`cd $mksrc && pwd` 491 break 492done 493mksrc=`echo $mksrc | sed "s,$srcdir,\\\${srcdir},"` 494echo "Using: MKSRC=$mksrc" 1>&6 495dnl On some systems we want a different default shell by default 496for sh in /usr/xpg4/bin/sh $ALT_DEF_SHELLS 497do 498 test -x $sh || continue 499 use_defshell $sh 500 break 501done 502case "$defshell_path$DEFSHELL_INDEX" in 503"") ;; 504*DEFSHELL_INDEX_CUSTOM) 505 echo "Using: SHELL=$defshell_path" >&6 506 AC_DEFINE_UNQUOTED(DEFSHELL_CUSTOM, "$defshell_path", Path of default shell) 507 ;; 508/*INDEX*) 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) 511AC_DEFINE_UNQUOTED(DEFSHELL_PATH, "$defshell_path", Path of default shell) 512 ;; 513*) 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) 516 ;; 517esac 518dnl 519dnl Some systems have deprecated egrep in favor of grep -E 520case "`echo bmake | egrep 'a|b' 2>&1`" in 521bmake) egrep=egrep;; 522*) egrep='grep -E';; 523esac 524dnl 525AC_SUBST(egrep) 526AC_SUBST(machine) 527AC_SUBST(force_machine) 528AC_SUBST(machine_arch) 529AC_SUBST(force_machine_arch) 530AC_SUBST(mksrc) 531AC_SUBST(default_sys_path) 532AC_SUBST(INSTALL) 533AC_SUBST(GCC) 534AC_SUBST(diff) 535AC_SUBST(diff_u) 536AC_SUBST(use_meta) 537AC_SUBST(use_filemon) 538AC_SUBST(filemon_h) 539AC_SUBST(_MAKE_VERSION) 540AC_SUBST(UTC_1) 541bm_outfiles="Makefile.config unit-tests/Makefile.config make-bootstrap.sh" 542if test $use_makefile = yes; then 543 bm_outfiles="makefile $bm_outfiles" 544fi 545 546here=`'pwd'` 547: srcdir=$srcdir 548: here= $here 549case "$here" in 550$srcdir/obj*) # make sure we put unit-tests/Makefile.config in the right place 551 obj=`basename $here` 552 mkdir -p $srcdir/unit-tests/$obj 553 test -d unit-tests || ln -s ../unit-tests/$obj unit-tests 554 ;; 555esac 556 557AC_CONFIG_FILES([$bm_outfiles]) 558AC_OUTPUT 559cat <<EOF 560 561You can now run 562 563 sh ./make-bootstrap.sh 564 565to produce a fully functional bmake. 566 567EOF 568