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