1 # Process this file with autoconf to produce a configure script.
3 # Copyright (C) 1993-2022 Free Software Foundation, Inc.
4 # This file is part of GNU Make.
6 # GNU Make is free software; you can redistribute it and/or modify it under
7 # the terms of the GNU General Public License as published by the Free Software
8 # Foundation; either version 3 of the License, or (at your option) any later
11 # GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
12 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 # You should have received a copy of the GNU General Public License along with
17 # this program. If not, see <https://www.gnu.org/licenses/>.
19 AC_INIT([GNU Make],[4.4],[bug-make@gnu.org])
24 AC_CONFIG_AUX_DIR([build-aux])
25 AC_CONFIG_SRCDIR([src/vpath.c])
26 AC_CONFIG_HEADERS([src/config.h])
28 AC_CONFIG_LIBOBJ_DIR([lib])
31 # We have to enable "foreign" because ChangeLog is auto-generated
32 # Automake 1.15 and gnulib don't get along: gnulib has some strange error
33 # in the way it handles getloadavg.c which causes make distcheck to fail.
34 # https://lists.gnu.org/archive/html/bug-gnulib/2018-06/msg00024.html
35 AM_INIT_AUTOMAKE([1.16.1 foreign -Werror -Wall])
37 # Checks for programs.
38 AC_USE_SYSTEM_EXTENSIONS
48 AC_CHECK_PROG([AR], [ar], [ar], [ar])
49 # Perl is needed for the test suite (only)
50 AC_CHECK_PROG([PERL], [perl], [perl], [perl])
52 # Specialized system macros
56 # Enable gettext, in "external" mode.
57 AM_GNU_GETTEXT_VERSION([0.19.4])
58 AM_GNU_GETTEXT([external])
60 # Checks for libraries.
61 AC_SEARCH_LIBS([strerror],[cposix])
62 AC_SEARCH_LIBS([getpwnam], [sun])
67 AC_CHECK_HEADERS([stdlib.h locale.h unistd.h limits.h fcntl.h string.h \
68 memory.h sys/param.h sys/resource.h sys/timeb.h sys/time.h \
69 sys/select.h sys/file.h spawn.h])
81 # Check for sig_atomic_t
84 # Find out whether our struct stat returns nanosecond resolution timestamps.
86 AC_STRUCT_ST_MTIM_NSEC
87 AC_CACHE_CHECK([whether to use high resolution file timestamps],
88 [make_cv_file_timestamp_hi_res],
89 [ make_cv_file_timestamp_hi_res=no
90 AS_IF([test "$ac_cv_struct_st_mtim_nsec" != no],
91 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
93 # include <inttypes.h>
95 [[char a[0x7fffffff < (uintmax_t)-1 >> 30 ? 1 : -1];]])],
96 [make_cv_file_timestamp_hi_res=yes])
98 AS_IF([test "$make_cv_file_timestamp_hi_res" = yes], [val=1], [val=0])
99 AC_DEFINE_UNQUOTED([FILE_TIMESTAMP_HI_RES], [$val],
100 [Use high resolution file timestamps if nonzero.])
102 AS_IF([test "$make_cv_file_timestamp_hi_res" = yes],
103 [ # Solaris 2.5.1 needs -lposix4 to get the clock_gettime function.
104 # Solaris 7 prefers the library name -lrt to the obsolescent name -lposix4.
105 AC_SEARCH_LIBS([clock_gettime], [rt posix4])
106 AS_IF([test "$ac_cv_search_clock_gettime" != no],
107 [ AC_DEFINE([HAVE_CLOCK_GETTIME], [1],
108 [Define to 1 if you have the clock_gettime function.])
112 # See if we have a standard version of gettimeofday(). Since actual
113 # implementations can differ, just make sure we have the most common
115 AC_CACHE_CHECK([for standard gettimeofday], [ac_cv_func_gettimeofday],
116 [ac_cv_func_gettimeofday=no
117 AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <sys/time.h>
120 struct timeval t; t.tv_sec = -1; t.tv_usec = -1;
121 return gettimeofday (&t, 0) != 0
122 || t.tv_sec < 0 || t.tv_usec < 0;
124 [ac_cv_func_gettimeofday=yes],
125 [ac_cv_func_gettimeofday=no],
126 [ac_cv_func_gettimeofday="no (cross-compiling)"])])
127 AS_IF([test "$ac_cv_func_gettimeofday" = yes],
128 [ AC_DEFINE([HAVE_GETTIMEOFDAY], [1],
129 [Define to 1 if you have a standard gettimeofday function])
132 AC_CHECK_FUNCS([strtoll strdup strndup stpcpy memrchr mempcpy umask mkstemp \
133 mktemp fdopen dup dup2 getcwd realpath sigsetmask sigaction \
134 getgroups seteuid setegid setlinebuf setreuid setregid \
135 mkfifo getrlimit setrlimit setvbuf pipe strerror strsignal \
136 lstat readlink atexit isatty ttyname pselect posix_spawn \
137 posix_spawnattr_setsigmask])
139 # We need to check declarations, not just existence, because on Tru64 this
140 # function is not declared without special flags, which themselves cause
141 # other problems. We'll just use our own.
142 AC_CHECK_DECLS([bsd_signal], [], [], [[#define _GNU_SOURCE 1
143 #include <signal.h>]])
147 # Rumor has it that strcasecmp lives in -lresolv on some odd systems.
148 # It doesn't hurt much to use our own if we can't find it so I don't
149 # make the effort here.
150 AC_CHECK_FUNCS([strcasecmp strncasecmp strcmpi strncmpi stricmp strnicmp])
152 # strcoll() is used by the GNU glob library
154 AC_FUNC_CLOSEDIR_VOID
156 # dir.c and our glob.c use dirent.d_type if available
157 AC_STRUCT_DIRENT_D_TYPE
159 # See if the user wants to add (or not) GNU Guile support
160 AC_ARG_WITH([guile], [AS_HELP_STRING([--with-guile],
161 [Support GNU Guile for embedded scripting])])
163 # Annoyingly, each version of Guile comes with it's own PC file so we have to
164 # specify them as individual packages. Ugh.
167 AS_IF([test "x$with_guile" != xno],
168 [ guile_versions="3.0 2.2 2.0 1.8"
171 AC_MSG_CHECKING([for GNU Guile])
172 for v in $guile_versions; do
173 PKG_CHECK_EXISTS([guile-$v], [guile_version=$v; have_guile=yes; break], [])
175 AC_MSG_RESULT([$guile_version])
176 AS_IF([test "$have_guile" = yes],
177 [ PKG_CHECK_MODULES(GUILE, [guile-$guile_version])
178 # Unfortunately pkg doesn't help in multi-arch environments where the
179 # package is installed for some architectures but not others; we need
181 keep_CPPFLAGS="$CPPFLAGS"
183 CPPFLAGS="$CPPFLAGS $GUILE_CFLAGS"
184 LIBS="$LIBS $GUILE_LIBS"
185 AC_CHECK_HEADER([libguile.h],
186 [AC_DEFINE([HAVE_GUILE], [1], [Embed GNU Guile support])],
188 [/* Avoid configuration error warnings. */])
189 AS_IF([test "$have_guile" = yes],
190 [ AC_MSG_CHECKING([whether we can link GNU Guile])
191 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
192 #include <libguile.h>
194 guile_init (void *arg)
200 scm_with_guile (guile_init, 0);
204 AC_MSG_RESULT([$have_guile])])
205 CPPFLAGS="$keep_CPPFLAGS"
210 AM_CONDITIONAL([HAVE_GUILE], [test "$have_guile" = "yes"])
212 AC_CHECK_DECLS([sys_siglist, _sys_siglist, __sys_siglist], , ,
215 /* NetBSD declares sys_siglist in unistd.h. */
222 # Check out the wait reality.
223 AC_CHECK_HEADERS([sys/wait.h],[],[],[[#include <sys/types.h>]])
224 AC_CHECK_FUNCS([waitpid wait3])
225 AC_CACHE_CHECK([for union wait], [make_cv_union_wait],
226 [ AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
227 #include <sys/wait.h>]],
228 [[union wait status; int pid; pid = wait (&status);
230 /* Some POSIXoid systems have both the new-style macros and the old
231 union wait type, and they do not work together. If union wait
232 conflicts with WEXITSTATUS et al, we don't want to use it at all. */
233 if (WEXITSTATUS (status) != 0) pid = -1;
235 /* If we have WEXITSTATUS and WTERMSIG, just use them on ints. */
236 -- blow chunks here --
240 /* Make sure union wait works with waitpid. */
241 pid = waitpid (-1, &status, 0);
244 [make_cv_union_wait=yes],
245 [make_cv_union_wait=no])
247 AS_IF([test "$make_cv_union_wait" = yes],
248 [ AC_DEFINE([HAVE_UNION_WAIT], [1],
249 [Define to 1 if you have the 'union wait' type in <sys/wait.h>.])
253 # If we're building on Windows/DOS/OS/2, add some support for DOS drive specs.
254 AS_IF([test "$PATH_SEPARATOR" = ';'],
255 [ AC_DEFINE([HAVE_DOS_PATHS], [1],
256 [Define to 1 if your system requires backslashes or drive specs in pathnames.])
259 # See if the user wants to use pmake's "customs" distributed build capability
260 AC_SUBST([REMOTE]) REMOTE=stub
262 AC_ARG_WITH([customs],
263 [AS_HELP_STRING([--with-customs=DIR],[enable remote jobs via Customs--see README.customs])],
264 [ AS_CASE([$withval], [n|no], [:],
265 [make_cppflags="$CPPFLAGS"
268 [CPPFLAGS="$CPPFLAGS -I$with_customs/include/customs"
269 make_ldflags="$LDFLAGS -L$with_customs/lib"])
271 AC_CHECK_HEADER([customs.h],
274 LIBS="$LIBS -lcustoms" LDFLAGS="$make_ldflags"],
276 CPPFLAGS="$make_cppflags" make_badcust=yes])
280 # Tell automake about this, so it can include the right .c files.
281 AM_CONDITIONAL([USE_CUSTOMS], [test "$use_customs" = true])
283 # See if the user asked to handle case insensitive file systems.
284 AH_TEMPLATE([HAVE_CASE_INSENSITIVE_FS], [Use case insensitive file names])
285 AC_ARG_ENABLE([case-insensitive-file-system],
286 AS_HELP_STRING([--enable-case-insensitive-file-system],[assume file systems are case insensitive]),
287 [AS_IF([test "$enableval" = yes], [AC_DEFINE([HAVE_CASE_INSENSITIVE_FS])])])
289 # See if we can handle the job server feature, and if the user wants it.
290 AC_ARG_ENABLE([job-server],
291 AS_HELP_STRING([--disable-job-server],[disallow recursive make communication during -jN]),
292 [make_cv_job_server="$enableval" user_job_server="$enableval"],
293 [make_cv_job_server="yes"])
295 AS_IF([test "$ac_cv_func_waitpid" = no && test "$ac_cv_func_wait3" = no],
296 [has_wait_nohang=no],
297 [has_wait_nohang=yes])
299 AC_CACHE_CHECK([for SA_RESTART], [make_cv_sa_restart], [
300 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <signal.h>]],
301 [[return SA_RESTART;]])],
302 [make_cv_sa_restart=yes],
303 [make_cv_sa_restart=no])])
305 AS_IF([test "$make_cv_sa_restart" != no],
306 [ AC_DEFINE([HAVE_SA_RESTART], [1],
307 [Define to 1 if <signal.h> defines the SA_RESTART constant.])
310 # Only allow jobserver on systems that support it
311 AS_CASE([/$ac_cv_func_pipe/$ac_cv_func_sigaction/$make_cv_sa_restart/$has_wait_nohang/],
312 [*/no/*], [make_cv_job_server=no])
314 # Also supported on OS2 and MinGW
315 AS_CASE([$host_os], [os2*|mingw*], [make_cv_job_server=yes])
317 # If we support it and the user didn't disable it, build with jobserver
318 AS_CASE([/$make_cv_job_server/$user_job_server/],
319 [*/no/*], [: no jobserver],
320 [AC_DEFINE(MAKE_JOBSERVER, 1,
321 [Define to 1 to enable job server support in GNU make.])
324 # If dl*() functions are supported we can enable the load operation
325 AC_CHECK_DECLS([dlopen, dlsym, dlerror], [], [],
326 [[#include <dlfcn.h>]])
328 AC_ARG_ENABLE([load],
329 AS_HELP_STRING([--disable-load],[disable support for the 'load' operation]),
330 [make_cv_load="$enableval" user_load="$enableval"],
331 [make_cv_load="yes"])
333 AS_CASE([/$ac_cv_have_decl_dlopen/$ac_cv_have_decl_dlsym/$ac_cv_have_decl_dlerror/],
334 [*/no/*], [make_cv_load=no])
337 AS_IF([test "$make_cv_load" = yes], [
338 AC_SEARCH_LIBS([dlopen], [dl], [], [make_cv_load=])
341 AS_CASE([/$make_cv_load/$user_load/],
342 [*/no/*], [make_cv_load=no],
343 [AC_DEFINE(MAKE_LOAD, 1,
344 [Define to 1 to enable 'load' support in GNU make.])
347 # If we want load support, we might need to link with export-dynamic.
348 # See if we can figure it out. Unfortunately this is very difficult.
349 # For example passing -rdynamic to the SunPRO linker gives a warning
350 # but succeeds and creates a shared object, not an executable!
351 AS_IF([test "$make_cv_load" = yes], [
352 AC_MSG_CHECKING([If the linker accepts -Wl,--export-dynamic])
353 old_LDFLAGS="$LDFLAGS"
354 LDFLAGS="$LDFLAGS -Wl,--export-dynamic"
355 AC_LINK_IFELSE([AC_LANG_SOURCE([int main(){}])],
356 [AC_MSG_RESULT([yes])
357 AC_SUBST([AM_LDFLAGS], [-Wl,--export-dynamic])],
359 AC_MSG_CHECKING([If the linker accepts -rdynamic])
360 LDFLAGS="$old_LDFLAGS -rdynamic"
361 AC_LINK_IFELSE([AC_LANG_SOURCE([int main(){}])],
362 [AC_MSG_RESULT([yes])
363 AC_SUBST([AM_LDFLAGS], [-rdynamic])],
364 [AC_MSG_RESULT([no])])
366 LDFLAGS="$old_LDFLAGS"
369 # if we have both lstat() and readlink() then we can support symlink
371 AS_IF([test "$ac_cv_func_lstat" = yes && test "$ac_cv_func_readlink" = yes],
372 [ AC_DEFINE([MAKE_SYMLINKS], [1],
373 [Define to 1 to enable symbolic link timestamp checking.])
376 # Use posix_spawn if we have support and the user didn't disable it
378 AC_ARG_ENABLE([posix-spawn],
379 AS_HELP_STRING([--disable-posix-spawn],[disable support for posix_spawn()]),
380 [make_cv_posix_spawn="$enableval" user_posix_spawn="$enableval"],
381 [make_cv_posix_spawn="yes"])
383 AS_CASE([/$ac_cv_header_spawn/$ac_cv_func_posix_spawn/],
384 [*/no/*], [make_cv_posix_spawn=no])
386 AS_IF([test "$make_cv_posix_spawn" = yes],
387 AC_CACHE_CHECK([for posix_spawn that fails synchronously],
388 [make_cv_synchronous_posix_spawn],
389 [make_cv_synchronous_posix_spawn=no
390 AC_RUN_IFELSE([AC_LANG_SOURCE([[
393 extern char **environ;
395 char path[[]] = "./xxx-non-existent";
396 char *argv[[]] = {path, 0};
397 return posix_spawn (0, path, 0, 0, argv, environ) == ENOENT ? 0 : 1;
399 [make_cv_synchronous_posix_spawn=yes],
400 [make_cv_synchronous_posix_spawn=no],
401 [make_cv_synchronous_posix_spawn="no (cross-compiling)"])]))
403 AS_CASE([/$user_posix_spawn/$make_cv_posix_spawn/$make_cv_synchronous_posix_spawn/],
404 [*/no/*], [make_cv_posix_spawn=no],
405 [AC_DEFINE(USE_POSIX_SPAWN, 1, [Define to 1 to use posix_spawn().])
408 # Find the SCCS commands, so we can include them in our default rules.
410 AC_CACHE_CHECK([for location of SCCS get command], [make_cv_path_sccs_get], [
411 AS_IF([test -f /usr/sccs/get],
412 [make_cv_path_sccs_get=/usr/sccs/get],
413 [make_cv_path_sccs_get=get])
415 AC_DEFINE_UNQUOTED([SCCS_GET], ["$make_cv_path_sccs_get"],
416 [Define to the name of the SCCS 'get' command.])
418 ac_clean_files="$ac_clean_files s.conftest conftoast" # Remove these later.
419 AS_IF([(/usr/sccs/admin -n s.conftest || admin -n s.conftest) >/dev/null 2>&1 &&
421 [ # We successfully created an SCCS file.
422 AC_CACHE_CHECK([if SCCS get command understands -G], [make_cv_sys_get_minus_G],
423 [AS_IF([$make_cv_path_sccs_get -Gconftoast s.conftest >/dev/null 2>&1 &&
425 [make_cv_sys_get_minus_G=yes],
426 [make_cv_sys_get_minus_G=no])
428 AS_IF([test "$make_cv_sys_get_minus_G" = yes],
429 [AC_DEFINE([SCCS_GET_MINUS_G], [1],
430 [Define to 1 if the SCCS 'get' command understands the '-G<file>' option.])
433 rm -f s.conftest conftoast
435 # Let the makefile know what our build host is
437 AC_DEFINE_UNQUOTED([MAKE_HOST],["$host"],[Build host information.])
439 AC_SUBST([MAKE_HOST])
442 AM_CONDITIONAL([WINDOWSENV], [false])
446 [AM_CONDITIONAL([WINDOWSENV], [true])
448 AC_DEFINE([WINDOWS32], [1], [Build for the WINDOWS32 API.])
449 AC_DEFINE([HAVE_DOS_PATHS], [1], [Support DOS-style pathnames.])
452 AC_DEFINE_UNQUOTED([PATH_SEPARATOR_CHAR],['$PATH_SEPARATOR'],
453 [Define to the character that separates directories in PATH.])
455 AC_DEFINE_UNQUOTED([HAVE_DECL_GETLOADAVG],[$HAVE_DECL_GETLOADAVG],
456 [Define to 1 if you have the declaration of 'getloadavg'.])
458 # Remember that we ran configure to generate config.h
460 AC_DEFINE([MK_CONFIGURE], [1],
461 [Define to 1 if config.h is generated by running the configure script.])
463 # Include the Maintainer's Makefile section, if it's here.
465 MAINT_MAKEFILE=/dev/null
466 AS_IF([test -r "$srcdir/maintMakefile"],
467 [ MAINT_MAKEFILE="$srcdir/maintMakefile"
469 AC_SUBST_FILE([MAINT_MAKEFILE])
471 # Allow building with dmalloc
474 # Forcibly disable SET_MAKE. If it's set it breaks things like the test
478 # Sanity check and inform the user of what we found
480 AS_IF([test "x$make_badcust" = xyes], [
482 echo "WARNING: --with-customs specified but no customs.h could be found;"
483 echo " disabling Customs support."
487 AS_CASE([$with_customs],
488 [""|n|no|y|ye|yes], [:],
489 [AS_IF([test -f "$with_customs/lib/libcustoms.a"], [:],
491 echo "WARNING: '$with_customs/lib' does not appear to contain the"
492 echo " Customs library. You must build and install Customs"
493 echo " before compiling GNU make."
497 AS_IF([test "x$has_wait_nohang" = xno],
499 echo "WARNING: Your system has neither waitpid() nor wait3()."
500 echo " Without one of these, signal handling is unreliable."
501 echo " You should be aware that running GNU make with -j"
502 echo " could result in erratic behavior."
506 AS_IF([test "x$make_cv_job_server" = xno && test "x$user_job_server" = xyes],
508 echo "WARNING: Make job server requires a POSIX-ish system that"
509 echo " supports the pipe(), sigaction(), and either"
510 echo " waitpid() or wait3() functions. Your system doesn't"
511 echo " appear to provide one or more of those."
512 echo " Disabling job server support."
516 AS_IF([test "x$make_cv_load" = xno && test "x$user_load" = xyes],
518 echo "WARNING: 'load' support requires a POSIX-ish system that"
519 echo " supports the dlopen(), dlsym(), and dlerror() functions."
520 echo " Your system doesn't appear to provide one or more of these."
521 echo " Disabling 'load' support."
525 AS_IF([test "x$make_cv_posix_spawn" = xno && test "x$user_posix_spawn" = xyes],
527 echo "WARNING: posix_spawn() is not supported on this system."
531 # autoconf initializes $prefix to NONE.
532 AM_CONDITIONAL([KNOWN_PREFIX],
533 [test "x$prefix" = xNONE -o "x$prefix" = x/usr/local \
534 -o "x$prefix" = x/usr/gnu -o "x$prefix" = x/usr])
536 # Specify what files are to be created.
537 AC_CONFIG_FILES([build.cfg tests/config-flags.pm \
538 Makefile lib/Makefile doc/Makefile po/Makefile.in])
539 # We don't need this: the standard automake output suffices for POSIX systems.
542 # Put build.sh in the build directory so it's easy to find
543 AC_CONFIG_LINKS([build.sh:build.sh])
550 dnl comment-start: "dnl "
552 dnl comment-start-skip: "\\bdnl\\b\\s *"
553 dnl compile-command: "make configure config.h.in"