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