156034b9aabc4f29460fbd061b4f1c1c7f6a2e49
[dragonfly.git] / contrib / bmake / configure.in
1 dnl
2 dnl RCSid:
3 dnl     $Id: configure.in,v 1.45 2012/06/20 22:43:41 sjg Exp $
4 dnl
5 dnl Process this file with autoconf to produce a configure script
6 dnl
7 AC_INIT([bmake], [20120620], [sjg@NetBSD.org])
8 AC_CONFIG_HEADER(config.h)
9
10 dnl
11 AC_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
14 yes)   AC_MSG_ERROR(bad value ${withval} given for bmake DEFSHELL) ;;
15 no)    ;;
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])
24 dnl
25 use_meta=yes
26 AC_ARG_WITH(meta,
27 [ --without-meta dissable use of meta-mode],
28 [case "${withval}" in
29 yes|no) use_meta=${withval};;
30 *) AC_MSG_ERROR(bad value ${withval} given for meta) ;;
31 esac])
32 dnl
33 AC_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) ;;
39 esac],
40 [
41 OS=`uname -s`
42 for d in "/usr/include/dev/filemon" "$prefix/include/dev/filemon" "$srcdir/filemon" "$srcdir/../filemon" "$srcdir/../../sys/dev/filemon"
43 do
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
50 done
51 test -s "${filemon_h:-/dev/null}" || filemon_h=no
52 ])
53 dnl echo "Note: use_meta=$use_meta filemon_h=$filemon_h" >&6
54 case "$use_meta" in
55 yes)
56         case "$filemon_h" in
57         *.h) echo "Using: filemon=$filemon_h" >&6;;
58         esac
59         ;;
60 esac
61 dnl
62 dnl Check for OS problems
63 dnl Solaris's signal.h only privides sigset_t etc if one of
64 dnl _EXTENSIONS_ _POSIX_C_SOURCE or _XOPEN_SOURCE are defined.
65 dnl The later two seem to cause more problems than they solve so if we
66 dnl see _EXTENSIONS_ we use it.
67 AC_USE_SYSTEM_EXTENSIONS
68 dnl Checks for programs.
69 AC_PROG_CC
70 AC_PROG_GCC_TRADITIONAL
71 AC_PROG_INSTALL
72 dnl Executable suffix - normally empty; .exe on os2.
73 AC_SUBST(ac_exe_suffix)dnl
74
75 dnl
76 dnl Check if /bin/sh will pass .MAKE.LEVEL
77 echo $ECHO_N "checking if sh will pass .MAKE. variables... $ECHO_C" >&6
78 ok=`env .MAKE.LEVEL=1 /bin/sh -c env | grep LEVEL=`
79 case "$ok" in
80 "") echo no >&6; CPPFLAGS="${CPPFLAGS} -DNEED_MAKE_LEVEL_SAFE";;
81 *) echo yes >&6;;
82 esac
83
84 dnl
85 dnl AC_C_CROSS
86 dnl
87
88 dnl Checks for header files.
89 AC_HEADER_STDC
90 AC_HEADER_SYS_WAIT
91 AC_HEADER_DIRENT
92 dnl Keep this list sorted
93 AC_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
110 dnl Both *BSD and Linux have sys/cdefs.h, most do not.
111 dnl If it is missing, we add -I${srcdir}/missing to CFLAGS
112 dnl also if sys/cdefs.h does not have __RCSID we need to use ours
113 dnl but we need to include the host's one too *sigh*
114 AC_CHECK_HEADER(sys/cdefs.h,
115 echo $ECHO_N "checking whether sys/cdefs.h is compatible... $ECHO_C" >&6
116 AC_EGREP_CPP(yes,
117 [#include <sys/cdefs.h>
118 #ifdef __RCSID
119 yes
120 #endif
121 ],
122 echo yes  >&6,
123 echo no  >&6; CPPFLAGS="${CPPFLAGS} -I`cd ${srcdir}/missing && pwd` -DNEED_HOST_CDEFS_H"),
124 CPPFLAGS="${CPPFLAGS} -I`cd ${srcdir}/missing && pwd`")
125
126 dnl Checks for typedefs, structures, and compiler characteristics.
127 AC_C___ATTRIBUTE__
128 AC_C_BIGENDIAN
129 AC_C_CONST
130 AC_TYPE_OFF_T
131 AC_TYPE_PID_T
132 AC_TYPE_SIZE_T
133 AC_DECL_SYS_SIGLIST
134 AC_HEADER_TIME
135 AC_STRUCT_TM
136
137 dnl Checks for library functions.
138 AC_TYPE_SIGNAL
139 AC_FUNC_VFORK
140 AC_FUNC_VPRINTF
141 AC_FUNC_WAIT3
142 dnl Keep this list sorted
143 AC_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
174 dnl functions which we may need to provide
175 AC_REPLACE_FUNCS( \
176         realpath \
177         dirname \
178         stresep \
179         strlcpy \
180         )
181
182 AC_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
189 dnl
190 dnl Structures
191 dnl
192 AC_HEADER_STAT
193 AC_STRUCT_ST_RDEV
194 dnl
195 dnl we want this for unit-tests/Makefile
196 echo $ECHO_N "checking if diff -u works... $ECHO_C" >&6
197 if diff -u /dev/null /dev/null > /dev/null 2>&1; then
198    diff_u=-u
199    echo yes >&6
200 else
201    diff_u=
202    echo no >&6
203 fi
204 dnl
205 dnl AC_* don't quite cut it.
206 dnl 
207 echo "checking for MACHINE & MACHINE_ARCH..." >&6
208 cat > conftest.$ac_ext <<EOF
209 #include "confdefs.h"
210 #include <sys/param.h>
211 #ifdef MACHINE
212 machine=MACHINE
213 #endif
214 #ifdef MACHINE_ARCH
215 machine_arch=MACHINE_ARCH
216 #endif
217 EOF
218
219 default_machine=`(eval "$ac_cpp conftest.$ac_ext") 2>&5 | 
220         egrep machine= | tr -d ' "'`
221 rm -rf conftest*
222 if test "$default_machine"; then
223         eval "$default_machine"
224 fi
225 machine=${machine:-`$srcdir/machine.sh`}
226 machine_arch=${machine_arch:-`$srcdir/machine.sh arch`}
227 echo "defaults: MACHINE=$machine, MACHINE_ARCH=$machine_arch" 1>&6
228 dnl
229 dnl now allow overrides
230 dnl
231 AC_ARG_WITH(machine,
232 [  --with-machine=MACHINE  explicitly set MACHINE],
233 [case "${withval}" in
234 yes)   AC_MSG_ERROR(bad value ${withval} given for bmake MACHINE) ;;
235 no)    ;;
236 generic) machine=`$srcdir/machine.sh`;;
237 *)     machine=$with_machine;;
238 esac])
239 force_machine=
240 AC_ARG_WITH(force_machine,
241 [  --with-force-machine=MACHINE  set FORCE_MACHINE],
242 [case "${withval}" in
243 yes)   force_machine=FORCE_;;
244 no)    ;;
245 *)     force_machine=FORCE_; machine=$with_force_machine;;
246 esac])
247 dnl
248 force_machine_arch=
249 AC_ARG_WITH(force_machine_arch,
250 [  --with-force-machine-arch=MACHINE  set FORCE_MACHINE_ARCH],
251 [case "${withval}" in
252 yes)   force_machine_arch=FORCE_;;
253 no)    ;;
254 *)     force_machine_arch=FORCE_; machine_arch=$with_force_machine;;
255 esac])
256 dnl
257 AC_ARG_WITH(machine_arch,
258 [  --with-machine_arch=MACHINE_ARCH  explicitly set MACHINE_ARCH],
259 [case "${withval}" in
260 yes)   AC_MSG_ERROR(bad value ${withval} given for bmake MACHINE_ARCH) ;;
261 no)    ;;
262 *)     machine_arch=$with_machine_arch;;
263 esac])
264 dnl
265 dnl Tell them what we ended up with
266 dnl
267 echo "Using: ${force_machine}MACHINE=$machine, MACHINE_ARCH=$machine_arch" 1>&6
268 dnl
269 dnl Allow folk to control _PATH_DEFSYSPATH
270 dnl
271 default_sys_path=\${prefix}/share/mk
272 AC_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
278 yes)    AC_MSG_ERROR(bad value ${withval} given for bmake _PATH_DEFSYSPATH) ;;
279 no)     ;;
280 *)      default_sys_path="$with_default_sys_path"
281         ;;
282 esac])
283 dnl
284 dnl Some folk don't like this one
285 dnl
286 AC_ARG_WITH(path-objdirprefix,
287 [  --with-path-objdirprefix=PATH  override _PATH_OBJDIRPREFIX],
288 [case "${withval}" in
289 yes)   AC_MSG_ERROR(bad value ${withval} given for bmake _PATH_OBJDIRPREFIX) ;;
290 no)    CPPFLAGS="$CPPFLAGS -DNO_PATH_OBJDIRPREFIX" ;;
291 *)     CPPFLAGS="$CPPFLAGS \"-D_PATH_OBJDIRPREFIX=\\\"$with_path-objdir\\\"\"" ;;
292 esac])
293 dnl
294 dnl And this can be handy to do with out.
295 dnl
296 AC_ARG_ENABLE(pwd-override,
297 [  --disable-pwd-override  disable \$PWD overriding getcwd()],
298 [case "${enableval}" in
299 yes)   ;;
300 no)    CPPFLAGS="$CPPFLAGS -DNO_PWD_OVERRIDE" ;;
301 *)     AC_MSG_ERROR(bad value ${enableval} given for pwd-override option) ;;
302 esac])
303 dnl
304 dnl Just for grins
305 dnl
306 AC_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
310 yes)   ;;
311 no)    CPPFLAGS="$CPPFLAGS -DNO_CHECK_MAKE_CHDIR" ;;
312 *)     AC_MSG_ERROR(bad value ${enableval} given for check-make-chdir option) ;;
313 esac])
314 dnl
315 dnl On non-BSD systems, bootstrap won't work without mk
316 dnl
317 AC_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 ||
322 AC_MSG_ERROR(bad value ${withval} given for mksrc cannot find install-mk)
323 ;;
324 esac
325 ])
326 dnl
327 dnl Now make sure we have a value
328 dnl
329 srcdir=`cd $srcdir && pwd`
330 for mksrc in $mksrc $srcdir/mk $srcdir/../mk mk
331 do
332         test -s $mksrc/install-mk || continue
333         mksrc=`cd $mksrc && pwd`
334         break
335 done
336 mksrc=`echo $mksrc | sed "s,$srcdir,\\\${srcdir},"`
337 echo "Using: MKSRC=$mksrc" 1>&6
338 dnl On some systems we want a different default shell by default
339 if test -x /usr/xpg4/bin/sh; then
340         defshell_path=${defshell_path:-/usr/xpg4/bin/sh}
341 fi
342 if test -n "$defshell_path"; then
343         echo "Using: SHELL=$defshell_path"  >&6
344         AC_DEFINE_UNQUOTED(DEFSHELL_CUSTOM, "$defshell_path", Path of default shell)
345 fi
346 if test -n "$DEFSHELL_INDEX"; then
347        AC_DEFINE_UNQUOTED(DEFSHELL_INDEX, $DEFSHELL_INDEX, Shell spec to use by default)
348 fi        
349 dnl
350 AC_SUBST(machine)
351 AC_SUBST(force_machine)
352 AC_SUBST(machine_arch)
353 AC_SUBST(mksrc)
354 AC_SUBST(default_sys_path)
355 AC_SUBST(INSTALL)
356 AC_SUBST(GCC)
357 AC_SUBST(diff_u)
358 AC_SUBST(use_meta)
359 AC_SUBST(filemon_h)
360 AC_OUTPUT(Makefile make-bootstrap.sh unit-tests/Makefile)
361
362 cat <<EOF
363
364 You can now run
365
366         sh ./make-bootstrap.sh
367
368 to produce a fully functional bmake.
369
370 EOF