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