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