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