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