Change make license
[platform/upstream/make.git] / configure.ac
1 # Process this file with autoconf to produce a configure script.
2 #
3 # Copyright (C) 1993-2020 Free Software Foundation, Inc.
4 # This file is part of GNU Make.
5 #
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
9 # version.
10 #
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
14 # details.
15 #
16 # You should have received a copy of the GNU General Public License along with
17 # this program.  If not, see <http://www.gnu.org/licenses/>.
18
19 AC_INIT([GNU make],[4.3],[bug-make@gnu.org])
20
21 AC_PREREQ([2.69])
22
23 # Autoconf setup
24 AC_CONFIG_AUX_DIR([build-aux])
25 AC_CONFIG_SRCDIR([src/vpath.c])
26 AC_CONFIG_HEADERS([src/config.h])
27
28 AC_CONFIG_LIBOBJ_DIR([lib])
29
30 # Automake setup
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 # http://lists.gnu.org/archive/html/bug-gnulib/2018-06/msg00024.html
35 AM_INIT_AUTOMAKE([1.15.1 foreign -Werror -Wall])
36
37 # Checks for programs.
38 AC_USE_SYSTEM_EXTENSIONS
39 AC_PROG_CC
40
41 # Configure gnulib
42 gl_EARLY
43 gl_INIT
44
45 AC_PROG_INSTALL
46 AC_PROG_RANLIB
47 AC_PROG_CPP
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])
51
52 # Specialized system macros
53 AC_CANONICAL_HOST
54 AC_AIX
55 AC_ISC_POSIX
56 AC_MINIX
57 AC_C_BIGENDIAN
58
59 # Enable gettext, in "external" mode.
60 AM_GNU_GETTEXT_VERSION([0.19.4])
61 AM_GNU_GETTEXT([external])
62
63 # This test must come as early as possible after the compiler configuration
64 # tests, because the choice of the file model can (in principle) affect
65 # whether functions and headers are available, whether they work, etc.
66 AC_SYS_LARGEFILE
67
68 # Checks for libraries.
69 AC_SEARCH_LIBS([getpwnam], [sun])
70
71 # Checks for header files.
72 AC_HEADER_STDC
73 AC_HEADER_DIRENT
74 AC_HEADER_STAT
75 AC_HEADER_TIME
76 AC_CHECK_HEADERS([stdlib.h locale.h unistd.h limits.h fcntl.h string.h \
77                   memory.h sys/param.h sys/resource.h sys/time.h sys/timeb.h \
78                   sys/select.h sys/file.h spawn.h])
79
80 AM_PROG_CC_C_O
81 AC_C_CONST
82 AC_TYPE_SIGNAL
83 AC_TYPE_UID_T
84 AC_TYPE_PID_T
85 AC_TYPE_OFF_T
86 AC_TYPE_SIZE_T
87 AC_TYPE_SSIZE_T
88 AC_TYPE_UINTMAX_T
89
90 # Find out whether our struct stat returns nanosecond resolution timestamps.
91
92 AC_STRUCT_ST_MTIM_NSEC
93 AC_CACHE_CHECK([whether to use high resolution file timestamps],
94                [make_cv_file_timestamp_hi_res],
95 [ make_cv_file_timestamp_hi_res=no
96   AS_IF([test "$ac_cv_struct_st_mtim_nsec" != no],
97         [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
98 #if HAVE_INTTYPES_H
99 # include <inttypes.h>
100 #endif]],
101                       [[char a[0x7fffffff < (uintmax_t)-1 >> 30 ? 1 : -1];]])],
102         [make_cv_file_timestamp_hi_res=yes])
103   ])])
104 AS_IF([test "$make_cv_file_timestamp_hi_res" = yes], [val=1], [val=0])
105 AC_DEFINE_UNQUOTED([FILE_TIMESTAMP_HI_RES], [$val],
106                    [Use high resolution file timestamps if nonzero.])
107
108 AS_IF([test "$make_cv_file_timestamp_hi_res" = yes],
109 [ # Solaris 2.5.1 needs -lposix4 to get the clock_gettime function.
110   # Solaris 7 prefers the library name -lrt to the obsolescent name -lposix4.
111   AC_SEARCH_LIBS([clock_gettime], [rt posix4])
112   AS_IF([test "$ac_cv_search_clock_gettime" != no],
113   [ AC_DEFINE([HAVE_CLOCK_GETTIME], [1],
114               [Define to 1 if you have the clock_gettime function.])
115   ])
116 ])
117
118 # Check for DOS-style pathnames.
119 pds_AC_DOS_PATHS
120
121 # See if we have a standard version of gettimeofday().  Since actual
122 # implementations can differ, just make sure we have the most common
123 # one.
124 AC_CACHE_CHECK([for standard gettimeofday], [ac_cv_func_gettimeofday],
125   [ac_cv_func_gettimeofday=no
126    AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <sys/time.h>
127                   int main ()
128                   {
129                     struct timeval t; t.tv_sec = -1; t.tv_usec = -1;
130                     return gettimeofday (&t, 0) != 0
131                           || t.tv_sec < 0 || t.tv_usec < 0;
132                   }]])],
133                   [ac_cv_func_gettimeofday=yes],
134                   [ac_cv_func_gettimeofday=no],
135                   [ac_cv_func_gettimeofday="no (cross-compiling)"])])
136 AS_IF([test "$ac_cv_func_gettimeofday" = yes],
137 [ AC_DEFINE([HAVE_GETTIMEOFDAY], [1],
138             [Define to 1 if you have a standard gettimeofday function])
139 ])
140
141 AC_CHECK_FUNCS([strdup strndup memrchr umask mkstemp mktemp fdopen \
142                 dup dup2 getcwd realpath sigsetmask sigaction \
143                 getgroups seteuid setegid setlinebuf setreuid setregid \
144                 getrlimit setrlimit setvbuf pipe strsignal \
145                 lstat readlink atexit isatty ttyname pselect posix_spawn \
146                 posix_spawnattr_setsigmask])
147
148 # We need to check declarations, not just existence, because on Tru64 this
149 # function is not declared without special flags, which themselves cause
150 # other problems.  We'll just use our own.
151 AC_CHECK_DECLS([bsd_signal], [], [], [[#define _GNU_SOURCE 1
152 #include <signal.h>]])
153
154 AC_FUNC_FORK
155
156 AC_FUNC_SETVBUF_REVERSED
157
158 # Rumor has it that strcasecmp lives in -lresolv on some odd systems.
159 # It doesn't hurt much to use our own if we can't find it so I don't
160 # make the effort here.
161 AC_CHECK_FUNCS([strcasecmp strncasecmp strcmpi strncmpi stricmp strnicmp])
162
163 # strcoll() is used by the GNU glob library
164 AC_FUNC_STRCOLL
165 AC_FUNC_CLOSEDIR_VOID
166
167 # dir.c and our glob.c use dirent.d_type if available
168 AC_STRUCT_DIRENT_D_TYPE
169
170 # See if the user wants to add (or not) GNU Guile support
171 AC_ARG_WITH([guile], [AS_HELP_STRING([--with-guile],
172             [Support GNU Guile for embedded scripting])])
173
174 # Annoyingly, each version of Guile comes with it's own PC file so we have to
175 # specify them as individual packages.  Ugh.
176 PKG_PROG_PKG_CONFIG
177
178 AS_IF([test "x$with_guile" != xno],
179 [ guile_versions="3.0 2.2 2.0 1.8"
180   guile_version=no
181   have_guile=no
182   AC_MSG_CHECKING([for GNU Guile])
183   for v in $guile_versions; do
184     PKG_CHECK_EXISTS([guile-$v], [guile_version=$v; have_guile=yes; break], [])
185   done
186   AC_MSG_RESULT([$guile_version])
187   AS_IF([test "$have_guile" = yes],
188   [ PKG_CHECK_MODULES(GUILE, [guile-$guile_version])
189     # Unfortunately Guile requires a C99 compiler but GNU make doesn't, so
190     # verify we can actually compile the header.
191     keep_CPPFLAGS="$CPPFLAGS"
192     CPPFLAGS="$CPPFLAGS $pkg_cv_GUILE_CFLAGS"
193     AC_CHECK_HEADER([libguile.h],
194                     [AC_DEFINE([HAVE_GUILE], [1], [Embed GNU Guile support])],
195                     [have_guile=no],
196                     [/* Avoid configuration error warnings. */])
197     CPPFLAGS="$keep_CPPFLAGS"
198   ])
199 ])
200
201 AM_CONDITIONAL([HAVE_GUILE], [test "$have_guile" = "yes"])
202
203 AC_CHECK_DECLS([sys_siglist, _sys_siglist, __sys_siglist], , ,
204   [AC_INCLUDES_DEFAULT
205 #include <signal.h>
206 /* NetBSD declares sys_siglist in unistd.h.  */
207 #if HAVE_UNISTD_H
208 # include <unistd.h>
209 #endif
210 ])
211
212
213 # Check out the wait reality.
214 AC_CHECK_HEADERS([sys/wait.h],[],[],[[#include <sys/types.h>]])
215 AC_CHECK_FUNCS([waitpid wait3])
216 AC_CACHE_CHECK([for union wait], [make_cv_union_wait],
217 [ AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
218 #include <sys/wait.h>]],
219      [[union wait status; int pid; pid = wait (&status);
220 #ifdef WEXITSTATUS
221 /* Some POSIXoid systems have both the new-style macros and the old
222    union wait type, and they do not work together.  If union wait
223    conflicts with WEXITSTATUS et al, we don't want to use it at all.  */
224         if (WEXITSTATUS (status) != 0) pid = -1;
225 #ifdef WTERMSIG
226         /* If we have WEXITSTATUS and WTERMSIG, just use them on ints.  */
227         -- blow chunks here --
228 #endif
229 #endif
230 #ifdef HAVE_WAITPID
231         /* Make sure union wait works with waitpid.  */
232         pid = waitpid (-1, &status, 0);
233 #endif
234       ]])],
235     [make_cv_union_wait=yes],
236     [make_cv_union_wait=no])
237 ])
238 AS_IF([test "$make_cv_union_wait" = yes],
239 [ AC_DEFINE([HAVE_UNION_WAIT], [1],
240             [Define to 1 if you have the 'union wait' type in <sys/wait.h>.])
241 ])
242
243
244 # If we're building on Windows/DOS/OS/2, add some support for DOS drive specs.
245 AS_IF([test "$PATH_SEPARATOR" = ';'],
246 [ AC_DEFINE([HAVE_DOS_PATHS], [1],
247             [Define to 1 if your system requires backslashes or drive specs in pathnames.])
248 ])
249
250 # See if the user wants to use pmake's "customs" distributed build capability
251 AC_SUBST([REMOTE]) REMOTE=stub
252 use_customs=false
253 AC_ARG_WITH([customs],
254 [AC_HELP_STRING([--with-customs=DIR],
255                 [enable remote jobs via Customs--see README.customs])],
256 [ AS_CASE([$withval], [n|no], [:],
257     [make_cppflags="$CPPFLAGS"
258      AS_CASE([$withval],
259              [y|ye|yes], [:],
260              [CPPFLAGS="$CPPFLAGS -I$with_customs/include/customs"
261               make_ldflags="$LDFLAGS -L$with_customs/lib"])
262      CF_NETLIBS
263      AC_CHECK_HEADER([customs.h],
264                      [use_customs=true
265                       REMOTE=cstms
266                       LIBS="$LIBS -lcustoms" LDFLAGS="$make_ldflags"],
267                      [with_customs=no
268                       CPPFLAGS="$make_cppflags" make_badcust=yes])
269     ])
270 ])
271
272 # Tell automake about this, so it can include the right .c files.
273 AM_CONDITIONAL([USE_CUSTOMS], [test "$use_customs" = true])
274
275 # See if the user asked to handle case insensitive file systems.
276 AH_TEMPLATE([HAVE_CASE_INSENSITIVE_FS], [Use case insensitive file names])
277 AC_ARG_ENABLE([case-insensitive-file-system],
278   AC_HELP_STRING([--enable-case-insensitive-file-system],
279                  [assume file systems are case insensitive]),
280   [AS_IF([test "$enableval" = yes], [AC_DEFINE([HAVE_CASE_INSENSITIVE_FS])])])
281
282 # See if we can handle the job server feature, and if the user wants it.
283 AC_ARG_ENABLE([job-server],
284   AC_HELP_STRING([--disable-job-server],
285                  [disallow recursive make communication during -jN]),
286   [make_cv_job_server="$enableval" user_job_server="$enableval"],
287   [make_cv_job_server="yes"])
288
289 AS_IF([test "$ac_cv_func_waitpid" = no && test "$ac_cv_func_wait3" = no],
290       [has_wait_nohang=no],
291       [has_wait_nohang=yes])
292
293 AC_CACHE_CHECK([for SA_RESTART], [make_cv_sa_restart], [
294   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <signal.h>]],
295       [[return SA_RESTART;]])],
296     [make_cv_sa_restart=yes],
297     [make_cv_sa_restart=no])])
298
299 AS_IF([test "$make_cv_sa_restart" != no],
300 [ AC_DEFINE([HAVE_SA_RESTART], [1],
301      [Define to 1 if <signal.h> defines the SA_RESTART constant.])
302 ])
303
304 # Only allow jobserver on systems that support it
305 AS_CASE([/$ac_cv_func_pipe/$ac_cv_func_sigaction/$make_cv_sa_restart/$has_wait_nohang/],
306   [*/no/*], [make_cv_job_server=no])
307
308 # Also supported on OS2 and MinGW
309 AS_CASE([$host_os], [os2*|mingw*], [make_cv_job_server=yes])
310
311 # If we support it and the user didn't disable it, build with jobserver
312 AS_CASE([/$make_cv_job_server/$user_job_server/],
313   [*/no/*], [: no jobserver],
314   [AC_DEFINE(MAKE_JOBSERVER, 1,
315              [Define to 1 to enable job server support in GNU make.])
316   ])
317
318 # If dl*() functions are supported we can enable the load operation
319 AC_CHECK_DECLS([dlopen, dlsym, dlerror], [], [],
320   [[#include <dlfcn.h>]])
321
322 AC_ARG_ENABLE([load],
323   AC_HELP_STRING([--disable-load],
324                  [disable support for the 'load' operation]),
325   [make_cv_load="$enableval" user_load="$enableval"],
326   [make_cv_load="yes"])
327
328 AS_CASE([/$ac_cv_have_decl_dlopen/$ac_cv_have_decl_dlsym/$ac_cv_have_decl_dlerror/],
329   [*/no/*], [make_cv_load=no])
330
331 # We might need -ldl
332 AS_IF([test "$make_cv_load" = yes], [
333   AC_SEARCH_LIBS([dlopen], [dl], [], [make_cv_load=])
334   ])
335
336 AS_CASE([/$make_cv_load/$user_load/],
337   [*/no/*], [make_cv_load=no],
338   [AC_DEFINE(MAKE_LOAD, 1,
339              [Define to 1 to enable 'load' support in GNU make.])
340   ])
341
342 # If we want load support, we might need to link with export-dynamic.
343 # See if we can figure it out.  Unfortunately this is very difficult.
344 # For example passing -rdynamic to the SunPRO linker gives a warning
345 # but succeeds and creates a shared object, not an executable!
346 AS_IF([test "$make_cv_load" = yes], [
347   AC_MSG_CHECKING([If the linker accepts -Wl,--export-dynamic])
348   old_LDFLAGS="$LDFLAGS"
349   LDFLAGS="$LDFLAGS -Wl,--export-dynamic"
350   AC_LINK_IFELSE([AC_LANG_SOURCE([int main(){}])],
351     [AC_MSG_RESULT([yes])
352      AC_SUBST([AM_LDFLAGS], [-Wl,--export-dynamic])],
353     [AC_MSG_RESULT([no])
354      AC_MSG_CHECKING([If the linker accepts -rdynamic])
355      LDFLAGS="$old_LDFLAGS -rdynamic"
356      AC_LINK_IFELSE([AC_LANG_SOURCE([int main(){}])],
357        [AC_MSG_RESULT([yes])
358         AC_SUBST([AM_LDFLAGS], [-rdynamic])],
359        [AC_MSG_RESULT([no])])
360    ])
361   LDFLAGS="$old_LDFLAGS"
362 ])
363
364 # if we have both lstat() and readlink() then we can support symlink
365 # timechecks.
366 AS_IF([test "$ac_cv_func_lstat" = yes && test "$ac_cv_func_readlink" = yes],
367   [ AC_DEFINE([MAKE_SYMLINKS], [1],
368               [Define to 1 to enable symbolic link timestamp checking.])
369 ])
370
371 # Use posix_spawn if we have support and the user didn't disable it
372
373 AC_ARG_ENABLE([posix-spawn],
374   AC_HELP_STRING([--disable-posix-spawn],
375                  [disable support for posix_spawn()]),
376   [make_cv_posix_spawn="$enableval" user_posix_spawn="$enableval"],
377   [make_cv_posix_spawn="yes"])
378
379 AS_CASE([/$ac_cv_header_spawn/$ac_cv_func_posix_spawn/],
380   [*/no/*], [make_cv_posix_spawn=no])
381
382 AS_IF([test "$make_cv_posix_spawn" = yes],
383   AC_CACHE_CHECK([for posix_spawn that fails synchronously],
384     [make_cv_synchronous_posix_spawn],
385     [make_cv_synchronous_posix_spawn=no
386      AC_RUN_IFELSE([AC_LANG_SOURCE([[
387        #include <spawn.h>
388        #include <string.h>
389
390        extern char **environ;
391
392        int main() {
393          char* path = strdup("./non-existent");
394          char *argv[[2]];
395          argv[[0]] = path;
396          argv[[1]] =  0;
397          return posix_spawn(0, path, 0, 0, argv, environ);
398        }]])],
399        [make_cv_synchronous_posix_spawn=no],
400        [make_cv_synchronous_posix_spawn=yes],
401        [make_cv_synchronous_posix_spawn="no (cross-compiling)"])]))
402
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().])
406   ])
407
408 # Find the SCCS commands, so we can include them in our default rules.
409
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])
414 ])
415 AC_DEFINE_UNQUOTED([SCCS_GET], ["$make_cv_path_sccs_get"],
416                    [Define to the name of the SCCS 'get' command.])
417
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 &&
420    test -f s.conftest],
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 &&
424             test -f conftoast],
425            [make_cv_sys_get_minus_G=yes],
426            [make_cv_sys_get_minus_G=no])
427     ])
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.])
431     ])
432 ])
433 rm -f s.conftest conftoast
434
435 # Let the makefile know what our build host is
436
437 AC_DEFINE_UNQUOTED([MAKE_HOST],["$host"],[Build host information.])
438 MAKE_HOST="$host"
439 AC_SUBST([MAKE_HOST])
440
441 w32_target_env=no
442 AM_CONDITIONAL([WINDOWSENV], [false])
443
444 AS_CASE([$host],
445   [*-*-mingw32],
446    [AM_CONDITIONAL([WINDOWSENV], [true])
447     w32_target_env=yes
448     AC_DEFINE([WINDOWS32], [1], [Use platform specific coding])
449     AC_DEFINE([HAVE_DOS_PATHS], [1], [Use platform specific coding])
450   ])
451
452 AC_DEFINE_UNQUOTED([PATH_SEPARATOR_CHAR],['$PATH_SEPARATOR'],
453         [Define to the character that separates directories in PATH.])
454
455 # Include the Maintainer's Makefile section, if it's here.
456
457 MAINT_MAKEFILE=/dev/null
458 AS_IF([test -r "$srcdir/maintMakefile"],
459 [ MAINT_MAKEFILE="$srcdir/maintMakefile"
460 ])
461 AC_SUBST_FILE([MAINT_MAKEFILE])
462
463 # Allow building with dmalloc
464 AM_WITH_DMALLOC
465
466 # Forcibly disable SET_MAKE.  If it's set it breaks things like the test
467 # scripts, etc.
468 SET_MAKE=
469
470 # Sanity check and inform the user of what we found
471
472 AS_IF([test "x$make_badcust" = xyes], [
473 echo
474 echo "WARNING: --with-customs specified but no customs.h could be found;"
475 echo "         disabling Customs support."
476 echo
477 ])
478
479 AS_CASE([$with_customs],
480 [""|n|no|y|ye|yes], [:],
481 [AS_IF([test -f "$with_customs/lib/libcustoms.a"], [:],
482 [ echo
483   echo "WARNING: '$with_customs/lib' does not appear to contain the"
484   echo "         Customs library.  You must build and install Customs"
485   echo "         before compiling GNU make."
486   echo
487 ])])
488
489 AS_IF([test "x$has_wait_nohang" = xno],
490 [ echo
491   echo "WARNING: Your system has neither waitpid() nor wait3()."
492   echo "         Without one of these, signal handling is unreliable."
493   echo "         You should be aware that running GNU make with -j"
494   echo "         could result in erratic behavior."
495   echo
496 ])
497
498 AS_IF([test "x$make_cv_job_server" = xno && test "x$user_job_server" = xyes],
499 [ echo
500   echo "WARNING: Make job server requires a POSIX-ish system that"
501   echo "         supports the pipe(), sigaction(), and either"
502   echo "         waitpid() or wait3() functions.  Your system doesn't"
503   echo "         appear to provide one or more of those."
504   echo "         Disabling job server support."
505   echo
506 ])
507
508 AS_IF([test "x$make_cv_load" = xno && test "x$user_load" = xyes],
509 [ echo
510   echo "WARNING: 'load' support requires a POSIX-ish system that"
511   echo "         supports the dlopen(), dlsym(), and dlerror() functions."
512   echo "         Your system doesn't appear to provide one or more of these."
513   echo "         Disabling 'load' support."
514   echo
515 ])
516
517 AS_IF([test "x$make_cv_posix_spawn" = xno && test "x$user_posix_spawn" = xyes],
518 [ echo
519   echo "WARNING: posix_spawn() is not supported on this system."
520   echo
521 ])
522
523 # Specify what files are to be created.
524 AC_CONFIG_FILES([Makefile build.cfg lib/Makefile po/Makefile.in doc/Makefile \
525                  tests/config-flags.pm])
526 # We don't need this: the standard automake output suffices for POSIX systems.
527 #mk/Posix.mk
528
529 # OK, do it!
530
531 AC_OUTPUT
532
533 dnl Local Variables:
534 dnl comment-start: "dnl "
535 dnl comment-end: ""
536 dnl comment-start-skip: "\\bdnl\\b\\s *"
537 dnl compile-command: "make configure config.h.in"
538 dnl End: