1dnl 2dnl RCSid: 3dnl $Id: configure.in,v 1.56 2015/10/25 05:20:48 sjg Exp $ 4dnl 5dnl Process this file with autoconf to produce a configure script 6dnl 7AC_PREREQ(2.50) 8AC_INIT([bmake], [20151022], [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(sys/param.h) 105dnl On BSDi at least we really need sys/param.h for sys/sysctl.h 106AC_CHECK_HEADERS([sys/sysctl.h], [], [], 107[#ifdef HAVE_SYS_PARAM_H 108# include <sys/param.h> 109# endif 110]) 111 112AC_CHECK_HEADERS( \ 113 ar.h \ 114 err.h \ 115 fcntl.h \ 116 libgen.h \ 117 limits.h \ 118 paths.h \ 119 poll.h \ 120 ranlib.h \ 121 string.h \ 122 sys/mman.h \ 123 sys/select.h \ 124 sys/socket.h \ 125 sys/time.h \ 126 sys/uio.h \ 127 unistd.h \ 128 utime.h \ 129 ) 130 131dnl Both *BSD and Linux have sys/cdefs.h, most do not. 132dnl If it is missing, we add -I${srcdir}/missing to CFLAGS 133dnl also if sys/cdefs.h does not have __RCSID we need to use ours 134dnl but we need to include the host's one too *sigh* 135AC_CHECK_HEADER(sys/cdefs.h, 136echo $ECHO_N "checking whether sys/cdefs.h is compatible... $ECHO_C" >&6 137AC_EGREP_CPP(yes, 138[#include <sys/cdefs.h> 139#ifdef __RCSID 140yes 141#endif 142], 143echo yes >&6, 144echo no >&6; CPPFLAGS="${CPPFLAGS} -I`cd ${srcdir}/missing && pwd` -DNEED_HOST_CDEFS_H"), 145CPPFLAGS="${CPPFLAGS} -I`cd ${srcdir}/missing && pwd`") 146 147dnl Checks for typedefs, structures, and compiler characteristics. 148AC_C___ATTRIBUTE__ 149AC_C_BIGENDIAN 150AC_C_CONST 151AC_TYPE_OFF_T 152AC_TYPE_PID_T 153AC_TYPE_SIZE_T 154AC_TYPE_UINT32_T 155AC_DECL_SYS_SIGLIST 156AC_HEADER_TIME 157AC_STRUCT_TM 158 159dnl Checks for library functions. 160AC_TYPE_SIGNAL 161AC_FUNC_VFORK 162AC_FUNC_VPRINTF 163AC_FUNC_WAIT3 164dnl Keep this list sorted 165AC_CHECK_FUNCS( \ 166 err \ 167 errx \ 168 getcwd \ 169 getenv \ 170 getopt \ 171 getwd \ 172 killpg \ 173 mmap \ 174 putenv \ 175 select \ 176 setenv \ 177 setpgid \ 178 setsid \ 179 sigaction \ 180 sigvec \ 181 snprintf \ 182 strerror \ 183 strftime \ 184 strsep \ 185 strtod \ 186 strtol \ 187 sysctl \ 188 unsetenv \ 189 vsnprintf \ 190 wait3 \ 191 wait4 \ 192 waitpid \ 193 warn \ 194 warnx \ 195 ) 196 197dnl functions which we may need to provide 198AC_REPLACE_FUNCS( \ 199 realpath \ 200 dirname \ 201 stresep \ 202 strlcpy \ 203 ) 204 205AC_CHECK_LIB([util], [emalloc], 206 [ AC_CHECK_LIB([util], [erealloc], 207 [ AC_CHECK_LIB([util], [estrdup], 208 [ AC_CHECK_LIB([util], [estrndup], 209 [ LIBS="$LIBS -lutil" 210 CPPFLAGS="$CPPFLAGS -DUSE_EMALLOC" ])])])]) 211 212dnl 213dnl Structures 214dnl 215AC_HEADER_STAT 216AC_STRUCT_ST_RDEV 217dnl 218echo "checking if compiler supports __func__" >&6 219AC_LANG(C) 220AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[[const char *func = __func__;]])],, 221 AC_DEFINE(__func__, __FUNCTION__, C99 function name)) 222dnl 223dnl we want this for unit-tests/Makefile 224echo $ECHO_N "checking if diff -u works... $ECHO_C" >&6 225if diff -u /dev/null /dev/null > /dev/null 2>&1; then 226 diff_u=-u 227 echo yes >&6 228else 229 diff_u= 230 echo no >&6 231fi 232dnl 233dnl AC_* don't quite cut it. 234dnl 235echo "checking for MACHINE & MACHINE_ARCH..." >&6 236cat > conftest.$ac_ext <<EOF 237#include "confdefs.h" 238#include <sys/param.h> 239#ifdef MACHINE 240machine=MACHINE 241#endif 242#ifdef MACHINE_ARCH 243machine_arch=MACHINE_ARCH 244#endif 245EOF 246 247default_machine=`(eval "$ac_cpp conftest.$ac_ext") 2>&5 | 248 egrep machine= | tr -d ' "'` 249rm -rf conftest* 250if test "$default_machine"; then 251 eval "$default_machine" 252fi 253machine=${machine:-`$srcdir/machine.sh`} 254machine_arch=${machine_arch:-`$srcdir/machine.sh arch`} 255echo "defaults: MACHINE=$machine, MACHINE_ARCH=$machine_arch" 1>&6 256dnl 257dnl now allow overrides 258dnl 259AC_ARG_WITH(machine, 260[ --with-machine=MACHINE explicitly set MACHINE], 261[case "${withval}" in 262yes) AC_MSG_ERROR(bad value ${withval} given for bmake MACHINE) ;; 263no) ;; 264generic) machine=`$srcdir/machine.sh`;; 265*) machine=$with_machine;; 266esac]) 267force_machine= 268AC_ARG_WITH(force_machine, 269[ --with-force-machine=MACHINE set FORCE_MACHINE], 270[case "${withval}" in 271yes) force_machine=FORCE_;; 272no) ;; 273*) force_machine=FORCE_; machine=$with_force_machine;; 274esac]) 275dnl 276force_machine_arch= 277AC_ARG_WITH(force_machine_arch, 278[ --with-force-machine-arch=MACHINE set FORCE_MACHINE_ARCH], 279[case "${withval}" in 280yes) force_machine_arch=FORCE_;; 281no) ;; 282*) force_machine_arch=FORCE_; machine_arch=$with_force_machine;; 283esac]) 284dnl 285AC_ARG_WITH(machine_arch, 286[ --with-machine_arch=MACHINE_ARCH explicitly set MACHINE_ARCH], 287[case "${withval}" in 288yes) AC_MSG_ERROR(bad value ${withval} given for bmake MACHINE_ARCH) ;; 289no) ;; 290*) machine_arch=$with_machine_arch;; 291esac]) 292dnl 293dnl Tell them what we ended up with 294dnl 295echo "Using: ${force_machine}MACHINE=$machine, MACHINE_ARCH=$machine_arch" 1>&6 296dnl 297dnl Allow folk to control _PATH_DEFSYSPATH 298dnl 299default_sys_path=\${prefix}/share/mk 300AC_ARG_WITH(default-sys-path, 301[ --with-default-sys-path=PATH:DIR:LIST use an explicit _PATH_DEFSYSPATH 302 MAKESYSPATH is a ':' separated list of directories 303 that bmake will search for system .mk files. 304 _PATH_DEFSYSPATH is its default value.], 305[case "${withval}" in 306yes) AC_MSG_ERROR(bad value ${withval} given for bmake _PATH_DEFSYSPATH) ;; 307no) ;; 308*) default_sys_path="$with_default_sys_path" 309 ;; 310esac]) 311dnl 312dnl Some folk don't like this one 313dnl 314AC_ARG_WITH(path-objdirprefix, 315[ --with-path-objdirprefix=PATH override _PATH_OBJDIRPREFIX], 316[case "${withval}" in 317yes) AC_MSG_ERROR(bad value ${withval} given for bmake _PATH_OBJDIRPREFIX) ;; 318no) CPPFLAGS="$CPPFLAGS -DNO_PATH_OBJDIRPREFIX" ;; 319*) CPPFLAGS="$CPPFLAGS \"-D_PATH_OBJDIRPREFIX=\\\"$with_path-objdir\\\"\"" ;; 320esac]) 321dnl 322dnl And this can be handy to do with out. 323dnl 324AC_ARG_ENABLE(pwd-override, 325[ --disable-pwd-override disable \$PWD overriding getcwd()], 326[case "${enableval}" in 327yes) ;; 328no) CPPFLAGS="$CPPFLAGS -DNO_PWD_OVERRIDE" ;; 329*) AC_MSG_ERROR(bad value ${enableval} given for pwd-override option) ;; 330esac]) 331dnl 332dnl Just for grins 333dnl 334AC_ARG_ENABLE(check-make-chdir, 335[ --disable-check-make-chdir disable make trying to guess 336 when it should automatically cd \${.CURDIR}], 337[case "${enableval}" in 338yes) ;; 339no) CPPFLAGS="$CPPFLAGS -DNO_CHECK_MAKE_CHDIR" ;; 340*) AC_MSG_ERROR(bad value ${enableval} given for check-make-chdir option) ;; 341esac]) 342dnl 343dnl On non-BSD systems, bootstrap won't work without mk 344dnl 345AC_ARG_WITH(mksrc, 346[ --with-mksrc=PATH tell makefile.boot where to find mk src], 347[case "${withval}" in 348""|yes|no) ;; 349*) test -s $withval/install-mk && mksrc=$withval || 350AC_MSG_ERROR(bad value ${withval} given for mksrc cannot find install-mk) 351;; 352esac 353]) 354dnl 355dnl Now make sure we have a value 356dnl 357srcdir=`cd $srcdir && pwd` 358for mksrc in $mksrc $srcdir/mk $srcdir/../mk mk 359do 360 test -s $mksrc/install-mk || continue 361 mksrc=`cd $mksrc && pwd` 362 break 363done 364mksrc=`echo $mksrc | sed "s,$srcdir,\\\${srcdir},"` 365echo "Using: MKSRC=$mksrc" 1>&6 366dnl On some systems we want a different default shell by default 367if test -x /usr/xpg4/bin/sh; then 368 defshell_path=${defshell_path:-/usr/xpg4/bin/sh} 369fi 370if test -n "$defshell_path"; then 371 echo "Using: SHELL=$defshell_path" >&6 372 AC_DEFINE_UNQUOTED(DEFSHELL_CUSTOM, "$defshell_path", Path of default shell) 373fi 374if test -n "$DEFSHELL_INDEX"; then 375 AC_DEFINE_UNQUOTED(DEFSHELL_INDEX, $DEFSHELL_INDEX, Shell spec to use by default) 376fi 377dnl 378AC_SUBST(machine) 379AC_SUBST(force_machine) 380AC_SUBST(machine_arch) 381AC_SUBST(mksrc) 382AC_SUBST(default_sys_path) 383AC_SUBST(INSTALL) 384AC_SUBST(GCC) 385AC_SUBST(diff_u) 386AC_SUBST(use_meta) 387AC_SUBST(filemon_h) 388AC_OUTPUT(makefile Makefile.config make-bootstrap.sh unit-tests/Makefile) 389 390cat <<EOF 391 392You can now run 393 394 sh ./make-bootstrap.sh 395 396to produce a fully functional bmake. 397 398EOF 399