1dnl 2dnl RCSid: 3dnl $Id: configure.in,v 1.54 2015/10/10 04:17:10 sjg Exp $ 4dnl 5dnl Process this file with autoconf to produce a configure script 6dnl 7AC_PREREQ(2.50) 8AC_INIT([bmake], [20151009], [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 18AC_ARG_WITH(defshell, 19[ --with-defshell=SHELL use SHELL by default - must be sh compatible, use sh or ksh to pick the internal definitions], 20[case "${withval}" in 21yes) AC_MSG_ERROR(bad value ${withval} given for bmake DEFSHELL) ;; 22no) ;; 23*) case "$with_defshell" in 24 sh) DEFSHELL_INDEX=DEFSHELL_INDEX_SH;; # it's the default anyway 25 ksh) DEFSHELL_INDEX=DEFSHELL_INDEX_KSH;; 26 csh) DEFSHELL_INDEX=DEFSHELL_INDEX_CSH;; # kidding right? 27 *) defshell_path=$with_defshell;; # better be sh compatible! 28 esac 29 ;; 30 esac]) 31dnl 32use_meta=yes 33AC_ARG_WITH(meta, 34[ --without-meta dissable use of meta-mode], 35[case "${withval}" in 36yes|no) use_meta=${withval};; 37*) AC_MSG_ERROR(bad value ${withval} given for meta) ;; 38esac]) 39dnl 40AC_ARG_WITH(filemon, 41[ --with-filemon=path/filemon.h indicate path to filemon.h for meta-mode], 42[ case "/${withval}" in 43/no|*/filemon.h) filemon_h="${withval}";; 44*/filemon*) filemon_h="${withval}/filemon.h";; 45*) AC_MSG_ERROR(bad value ${withval} given for filemon) ;; 46esac], 47[ 48OS=`uname -s` 49for d in "/usr/include/dev/filemon" "$prefix/include/dev/filemon" "$srcdir/filemon" "$srcdir/../filemon" "$srcdir/../../sys/dev/filemon" 50do 51 for x in "/$OS" "" 52 do 53 filemon_h="$d$x/filemon.h" 54 test -s "$filemon_h" && break 55 done 56 test -s "$filemon_h" && break 57done 58test -s "${filemon_h:-/dev/null}" || filemon_h=no 59]) 60dnl echo "Note: use_meta=$use_meta filemon_h=$filemon_h" >&6 61case "$use_meta" in 62yes) 63 case "$filemon_h" in 64 *.h) echo "Using: filemon=$filemon_h" >&6;; 65 esac 66 ;; 67esac 68dnl 69dnl Check for OS problems 70dnl Solaris's signal.h only privides sigset_t etc if one of 71dnl _EXTENSIONS_ _POSIX_C_SOURCE or _XOPEN_SOURCE are defined. 72dnl The later two seem to cause more problems than they solve so if we 73dnl see _EXTENSIONS_ we use it. 74AC_USE_SYSTEM_EXTENSIONS 75dnl Checks for programs. 76AC_PROG_CC 77AC_PROG_GCC_TRADITIONAL 78AC_PROG_INSTALL 79dnl Executable suffix - normally empty; .exe on os2. 80AC_SUBST(ac_exe_suffix)dnl 81dnl 82dnl Hurd refuses to define PATH_MAX or MAXPATHLEN 83if test -x /usr/bin/getconf; then 84 bmake_path_max=`getconf PATH_MAX / 2> /dev/null` 85 # only a numeric response is useful 86 test ${bmake_path_max:-0} -gt 0 2> /dev/null || bmake_path_max= 87fi 88bmake_path_max=${bmake_path_max:-1024} 89if test $bmake_path_max -gt 1024; then 90 # this is all we expect 91 bmake_path_max=1024 92fi 93echo "Using: BMAKE_PATH_MAX=$bmake_path_max" >&6 94AC_SUBST(bmake_path_max)dnl 95dnl 96dnl AC_C_CROSS 97dnl 98 99dnl Checks for header files. 100AC_HEADER_STDC 101AC_HEADER_SYS_WAIT 102AC_HEADER_DIRENT 103dnl Keep this list sorted 104AC_CHECK_HEADERS( \ 105 ar.h \ 106 err.h \ 107 fcntl.h \ 108 limits.h \ 109 paths.h \ 110 poll.h \ 111 ranlib.h \ 112 string.h \ 113 sys/mman.h \ 114 sys/select.h \ 115 sys/socket.h \ 116 sys/sysctl.h \ 117 sys/time.h \ 118 sys/uio.h \ 119 unistd.h \ 120 utime.h \ 121 ) 122 123dnl Both *BSD and Linux have sys/cdefs.h, most do not. 124dnl If it is missing, we add -I${srcdir}/missing to CFLAGS 125dnl also if sys/cdefs.h does not have __RCSID we need to use ours 126dnl but we need to include the host's one too *sigh* 127AC_CHECK_HEADER(sys/cdefs.h, 128echo $ECHO_N "checking whether sys/cdefs.h is compatible... $ECHO_C" >&6 129AC_EGREP_CPP(yes, 130[#include <sys/cdefs.h> 131#ifdef __RCSID 132yes 133#endif 134], 135echo yes >&6, 136echo no >&6; CPPFLAGS="${CPPFLAGS} -I`cd ${srcdir}/missing && pwd` -DNEED_HOST_CDEFS_H"), 137CPPFLAGS="${CPPFLAGS} -I`cd ${srcdir}/missing && pwd`") 138 139dnl Checks for typedefs, structures, and compiler characteristics. 140AC_C___ATTRIBUTE__ 141AC_C_BIGENDIAN 142AC_C_CONST 143AC_TYPE_OFF_T 144AC_TYPE_PID_T 145AC_TYPE_SIZE_T 146AC_DECL_SYS_SIGLIST 147AC_HEADER_TIME 148AC_STRUCT_TM 149 150dnl Checks for library functions. 151AC_TYPE_SIGNAL 152AC_FUNC_VFORK 153AC_FUNC_VPRINTF 154AC_FUNC_WAIT3 155dnl Keep this list sorted 156AC_CHECK_FUNCS( \ 157 err \ 158 errx \ 159 getcwd \ 160 getenv \ 161 getopt \ 162 getwd \ 163 killpg \ 164 mmap \ 165 putenv \ 166 select \ 167 setenv \ 168 setpgid \ 169 setsid \ 170 sigaction \ 171 sigvec \ 172 snprintf \ 173 strerror \ 174 strftime \ 175 strsep \ 176 strtod \ 177 strtol \ 178 sysctl \ 179 unsetenv \ 180 vsnprintf \ 181 wait3 \ 182 wait4 \ 183 waitpid \ 184 warn \ 185 warnx \ 186 ) 187 188dnl functions which we may need to provide 189AC_REPLACE_FUNCS( \ 190 realpath \ 191 dirname \ 192 stresep \ 193 strlcpy \ 194 ) 195 196AC_CHECK_LIB([util], [emalloc], 197 [ AC_CHECK_LIB([util], [erealloc], 198 [ AC_CHECK_LIB([util], [estrdup], 199 [ AC_CHECK_LIB([util], [estrndup], 200 [ LIBS="$LIBS -lutil" 201 CPPFLAGS="$CPPFLAGS -DUSE_EMALLOC" ])])])]) 202 203dnl 204dnl Structures 205dnl 206AC_HEADER_STAT 207AC_STRUCT_ST_RDEV 208dnl 209echo "checking if compiler supports __func__" >&6 210AC_LANG(C) 211AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[[const char *func = __func__;]])],, 212 AC_DEFINE(__func__, __FUNCTION__, C99 function name)) 213dnl 214dnl we want this for unit-tests/Makefile 215echo $ECHO_N "checking if diff -u works... $ECHO_C" >&6 216if diff -u /dev/null /dev/null > /dev/null 2>&1; then 217 diff_u=-u 218 echo yes >&6 219else 220 diff_u= 221 echo no >&6 222fi 223dnl 224dnl AC_* don't quite cut it. 225dnl 226echo "checking for MACHINE & MACHINE_ARCH..." >&6 227cat > conftest.$ac_ext <<EOF 228#include "confdefs.h" 229#include <sys/param.h> 230#ifdef MACHINE 231machine=MACHINE 232#endif 233#ifdef MACHINE_ARCH 234machine_arch=MACHINE_ARCH 235#endif 236EOF 237 238default_machine=`(eval "$ac_cpp conftest.$ac_ext") 2>&5 | 239 egrep machine= | tr -d ' "'` 240rm -rf conftest* 241if test "$default_machine"; then 242 eval "$default_machine" 243fi 244machine=${machine:-`$srcdir/machine.sh`} 245machine_arch=${machine_arch:-`$srcdir/machine.sh arch`} 246echo "defaults: MACHINE=$machine, MACHINE_ARCH=$machine_arch" 1>&6 247dnl 248dnl now allow overrides 249dnl 250AC_ARG_WITH(machine, 251[ --with-machine=MACHINE explicitly set MACHINE], 252[case "${withval}" in 253yes) AC_MSG_ERROR(bad value ${withval} given for bmake MACHINE) ;; 254no) ;; 255generic) machine=`$srcdir/machine.sh`;; 256*) machine=$with_machine;; 257esac]) 258force_machine= 259AC_ARG_WITH(force_machine, 260[ --with-force-machine=MACHINE set FORCE_MACHINE], 261[case "${withval}" in 262yes) force_machine=FORCE_;; 263no) ;; 264*) force_machine=FORCE_; machine=$with_force_machine;; 265esac]) 266dnl 267force_machine_arch= 268AC_ARG_WITH(force_machine_arch, 269[ --with-force-machine-arch=MACHINE set FORCE_MACHINE_ARCH], 270[case "${withval}" in 271yes) force_machine_arch=FORCE_;; 272no) ;; 273*) force_machine_arch=FORCE_; machine_arch=$with_force_machine;; 274esac]) 275dnl 276AC_ARG_WITH(machine_arch, 277[ --with-machine_arch=MACHINE_ARCH explicitly set MACHINE_ARCH], 278[case "${withval}" in 279yes) AC_MSG_ERROR(bad value ${withval} given for bmake MACHINE_ARCH) ;; 280no) ;; 281*) machine_arch=$with_machine_arch;; 282esac]) 283dnl 284dnl Tell them what we ended up with 285dnl 286echo "Using: ${force_machine}MACHINE=$machine, MACHINE_ARCH=$machine_arch" 1>&6 287dnl 288dnl Allow folk to control _PATH_DEFSYSPATH 289dnl 290default_sys_path=\${prefix}/share/mk 291AC_ARG_WITH(default-sys-path, 292[ --with-default-sys-path=PATH:DIR:LIST use an explicit _PATH_DEFSYSPATH 293 MAKESYSPATH is a ':' separated list of directories 294 that bmake will search for system .mk files. 295 _PATH_DEFSYSPATH is its default value.], 296[case "${withval}" in 297yes) AC_MSG_ERROR(bad value ${withval} given for bmake _PATH_DEFSYSPATH) ;; 298no) ;; 299*) default_sys_path="$with_default_sys_path" 300 ;; 301esac]) 302dnl 303dnl Some folk don't like this one 304dnl 305AC_ARG_WITH(path-objdirprefix, 306[ --with-path-objdirprefix=PATH override _PATH_OBJDIRPREFIX], 307[case "${withval}" in 308yes) AC_MSG_ERROR(bad value ${withval} given for bmake _PATH_OBJDIRPREFIX) ;; 309no) CPPFLAGS="$CPPFLAGS -DNO_PATH_OBJDIRPREFIX" ;; 310*) CPPFLAGS="$CPPFLAGS \"-D_PATH_OBJDIRPREFIX=\\\"$with_path-objdir\\\"\"" ;; 311esac]) 312dnl 313dnl And this can be handy to do with out. 314dnl 315AC_ARG_ENABLE(pwd-override, 316[ --disable-pwd-override disable \$PWD overriding getcwd()], 317[case "${enableval}" in 318yes) ;; 319no) CPPFLAGS="$CPPFLAGS -DNO_PWD_OVERRIDE" ;; 320*) AC_MSG_ERROR(bad value ${enableval} given for pwd-override option) ;; 321esac]) 322dnl 323dnl Just for grins 324dnl 325AC_ARG_ENABLE(check-make-chdir, 326[ --disable-check-make-chdir disable make trying to guess 327 when it should automatically cd \${.CURDIR}], 328[case "${enableval}" in 329yes) ;; 330no) CPPFLAGS="$CPPFLAGS -DNO_CHECK_MAKE_CHDIR" ;; 331*) AC_MSG_ERROR(bad value ${enableval} given for check-make-chdir option) ;; 332esac]) 333dnl 334dnl On non-BSD systems, bootstrap won't work without mk 335dnl 336AC_ARG_WITH(mksrc, 337[ --with-mksrc=PATH tell makefile.boot where to find mk src], 338[case "${withval}" in 339""|yes|no) ;; 340*) test -s $withval/install-mk && mksrc=$withval || 341AC_MSG_ERROR(bad value ${withval} given for mksrc cannot find install-mk) 342;; 343esac 344]) 345dnl 346dnl Now make sure we have a value 347dnl 348srcdir=`cd $srcdir && pwd` 349for mksrc in $mksrc $srcdir/mk $srcdir/../mk mk 350do 351 test -s $mksrc/install-mk || continue 352 mksrc=`cd $mksrc && pwd` 353 break 354done 355mksrc=`echo $mksrc | sed "s,$srcdir,\\\${srcdir},"` 356echo "Using: MKSRC=$mksrc" 1>&6 357dnl On some systems we want a different default shell by default 358if test -x /usr/xpg4/bin/sh; then 359 defshell_path=${defshell_path:-/usr/xpg4/bin/sh} 360fi 361if test -n "$defshell_path"; then 362 echo "Using: SHELL=$defshell_path" >&6 363 AC_DEFINE_UNQUOTED(DEFSHELL_CUSTOM, "$defshell_path", Path of default shell) 364fi 365if test -n "$DEFSHELL_INDEX"; then 366 AC_DEFINE_UNQUOTED(DEFSHELL_INDEX, $DEFSHELL_INDEX, Shell spec to use by default) 367fi 368dnl 369AC_SUBST(machine) 370AC_SUBST(force_machine) 371AC_SUBST(machine_arch) 372AC_SUBST(mksrc) 373AC_SUBST(default_sys_path) 374AC_SUBST(INSTALL) 375AC_SUBST(GCC) 376AC_SUBST(diff_u) 377AC_SUBST(use_meta) 378AC_SUBST(filemon_h) 379AC_OUTPUT(makefile Makefile.config make-bootstrap.sh unit-tests/Makefile) 380 381cat <<EOF 382 383You can now run 384 385 sh ./make-bootstrap.sh 386 387to produce a fully functional bmake. 388 389EOF 390