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