Compare commits

..

18 Commits

Author SHA1 Message Date
Paul Smith
37e0010743 Prerelease GNU Make 4.4.0.91
* NEWS: Update the date.
* configure.ac: Change the release.
2023-02-19 09:53:26 -05:00
Paul Smith
536c3e2b37 * src/makeint.h [CYGWIN]: Use pipe mode for the jobserver 2023-02-19 08:52:02 -05:00
Paul Smith
4c9b922560 Don't block for child exit if other commands have completed
Running regression tests on a single CPU system shows that if a child
exits while we're checking prerequisites we might not notice it, and
then we might block waiting for the next child to exit before we try
to do more work even though we could.

* src/remake.c (update_goal_chain): Remember the command_count before
we start checking prerequisites and if it is different when we restart
at the top of the goal chain then don't block.
2023-02-19 01:27:22 -05:00
Paul Smith
2449ef3c88 Clean up depth handling in debug output
The indentation shown in debug output was misleading.  Increment the
depth when we are working on a prerequisite, not for the current
target.

* src/remake.c (check_dep): Increment depth only on recursion.
(update_file_1): Ditto.  Don't show "Finished..." if prereqs are
still running.
* src/implicit.c (pattern_search): Increment depth for the entire
search.
* tests/scripts/features/output-sync: Support debug output when run
by hand.
2023-02-19 01:25:57 -05:00
Paul Smith
fbf8c940e5 * src/makeint.h (WIN32_LEAN_AND_MEAN) [Windows]: Don't redefine.
Suggested for tcc builds by Christian Jullien <eligis@orange.fr>.
2023-02-19 01:02:16 -05:00
KO Myung-Hun
62194015fa * src/misc.c (ttyname) [OS/2]: Add an implementation for OS/2 kLIBC 2023-02-19 01:02:16 -05:00
Paul Smith
c85f68c4e9 Allow jobserver style to be forced to "pipe"
Some systems that support mkfifo() don't support the usage that GNU
make wants.  Provide a way to force using "pipe" jobserver mode even
when mkfifo() is available.

* src/makeint.h (MK_OS_HURD): Define if we're on Hurd.
(JOBSERVER_USE_FIFO): Define if we have mkfifo() and we're NOT on
Hurd.
* src/main.c (main): Test JOBSERVER_USE_FIFO not HAVE_MKFIFO.
* src/posixos.c (jobserver_setup): Ditto.
* maintMakefile: Create a config check test for forcing "pipe" mode.
* tests/run_make_tests.pl: Show discovered FEATURES in verbose mode.
2023-02-19 01:02:16 -05:00
Paul Smith
ffa28f3914 [SV 63668] Use autoconf to detect the default C++ compiler
* configure.ac: Add AC_PROG_CXX to search for a C++ compiler.
(MAKE_CXX): Add the discovered compiler to config.h.
* src/default.c (default_variables): Use MAKE_CXX as the C++ compiler.
2023-02-05 10:22:13 -05:00
Paul Smith
8f03e69af0 * doc/make.texi: Fix typo (reported by <mao492479407@163.com>) 2023-02-05 09:42:49 -05:00
Paul Smith
e819fc2022 * tests/scripts/variables/MAKEFLAGS: Fix some Perl warnings 2023-02-04 13:12:32 -05:00
Dmitry Goncharov
f21cd822a3 * doc/make.texi: [SV 63689] Fix typos in examples 2023-01-28 13:09:36 -05:00
Paul Smith
2f336608d8 * src/job.c: Switch from bit operators to flags macros
* src/remake.c: Ditto.
2023-01-28 13:05:08 -05:00
Paul Smith
faedfdb0af [SV 63667] In .POSIX, use shell flags -c when ignoring errors
* src/variable.c (lookup_variable_for_file): New function to retrieve
a variable assignment in a file context.
* src/variable.h (lookup_variable_for_file): Declare it.
* src/job.c (construct_command_argv): Look up .SHELLFLAGS.  If .POSIX
is set and we're using the default value, choose -c if we're ignoring
errors else choose -ec.
(construct_command_argv_internal): Ditto.
* tests/scripts/targets/POSIX: Add tests.
2023-01-28 13:04:47 -05:00
Dmitry Goncharov
9709d273b2 * tests/scripts/features/archives: [SV 63688] Quote cmd line vars 2023-01-28 09:46:23 -05:00
Paul Smith
eb0bd1aaec * README.in: Mention README.z/OS 2023-01-28 09:28:18 -05:00
Paul Smith
d2bf740e77 * tests/test_driver.pl: Convert z/OS answers for regex output
Allow z/OS customizations to apply to regex output matching.
* tests/scripts/features/output-sync: Use a regex for Terminated.
* tests/scripts/features/temp_stdin: Ditto.
2023-01-15 16:35:57 -05:00
Paul Smith
a8890796a4 * tests/scripts/features/archives: Use the configured compiler for CC 2023-01-15 16:35:57 -05:00
Paul Smith
be6bb0fd68 * configure.ac: Delay setting HAVE_GUILE until we're sure 2023-01-15 10:27:34 -05:00
22 changed files with 295 additions and 121 deletions

8
NEWS
View File

@@ -1,6 +1,6 @@
GNU Make NEWS -*-indented-text-*-
History of user-visible changes.
14 January 2023
19 February 2023
See the end of this file for copyrights and conditions.
@@ -10,7 +10,7 @@ See the README file and the GNU Make manual for instructions for
reporting bugs.
Version 4.4.0.90 (14 Jan 2023)
Version 4.4.0.91 (19 Feb 2023)
This release is primarily a bug-fix release.
A complete list of bugs fixed in this version is available here:
@@ -44,6 +44,10 @@ https://sv.gnu.org/bugs/index.php?group=make&report_id=111&fix_release_id=110&se
* Updates to allow building on OS/2
Provided by KO Myung-Hun <komh78@gmail.com>
* Disable FIFO jobserver on GNU/Hurd and Cygwin
Experimentation shows that the new FIFO-based jobserver doesn't work well on
GNU/Hurd or Cygwin: revert these systems to use the pipe-based jobserver.
Version 4.4 (31 Oct 2022)

View File

@@ -184,6 +184,8 @@ Ports
- See README.Amiga for details about GNU Make on AmigaDOS.
- See README.zOS for details about GNU Make on z/OS.
- See README.W32 for details about GNU Make on Windows NT, 95, or 98.
- See README.DOS for compilation instructions on MS-DOS and MS-Windows

View File

@@ -16,7 +16,7 @@
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <https://www.gnu.org/licenses/>.
AC_INIT([GNU Make],[4.4.0.90],[bug-make@gnu.org])
AC_INIT([GNU Make],[4.4.0.91],[bug-make@gnu.org])
AC_PREREQ([2.69])
@@ -37,6 +37,8 @@ AM_INIT_AUTOMAKE([1.16.1 foreign -Werror -Wall])
# Checks for programs.
AC_USE_SYSTEM_EXTENSIONS
AC_PROG_CC
AC_PROG_CXX
AC_DEFINE_UNQUOTED(MAKE_CXX, ["$CXX"], [Default C++ compiler.])
# Configure gnulib
gl_EARLY
@@ -183,7 +185,7 @@ AS_IF([test "x$with_guile" != xno],
CPPFLAGS="$CPPFLAGS $GUILE_CFLAGS"
LIBS="$LIBS $GUILE_LIBS"
AC_CHECK_HEADER([libguile.h],
[AC_DEFINE([HAVE_GUILE], [1], [Embed GNU Guile support])],
[have_guile=yes],
[have_guile=no],
[/* Avoid configuration error warnings. */])
AS_IF([test "$have_guile" = yes],
@@ -207,6 +209,8 @@ guile_init (void *arg)
])
])
AS_IF([test "$have_guile" = yes],
[AC_DEFINE([HAVE_GUILE], [1], [Embed GNU Guile support])])
AM_CONDITIONAL([HAVE_GUILE], [test "$have_guile" = "yes"])
AC_CHECK_DECLS([sys_siglist, _sys_siglist, __sys_siglist], , ,

View File

@@ -2153,7 +2153,7 @@ The wildcard characters in @code{make} are @samp{*}, @samp{?} and
specifies a list of all the files (in the working directory) whose names
end in @samp{.c}.
If an expression matches multiple files than the results will be
If an expression matches multiple files then the results will be
sorted.@footnote{Some older versions of GNU @code{make} did not sort the
results of wildcard expansion.} However multiple expressions will not be
globally sorted. For example, @file{*.c *.h} will list all the files whose
@@ -11529,7 +11529,7 @@ rules by adding these lines to your makefile:
@example
(%) : % ;
%.a : ; $(AR) $(ARFLAGS) $@ $?
%.a : ; $(AR) $(ARFLAGS) $@@ $?
@end example
The first line changes the rule that updates an individual object in the
@@ -11548,7 +11548,7 @@ If you prefer to write an explicit rule you can use:
@example
libfoo.a: libfoo.a(x.o y.o @dots{})
$(AR) $(ARFLAGS) $@ $?
$(AR) $(ARFLAGS) $@@ $?
@end example
@node Archive Suffix Rules, , Archive Pitfalls, Archives

View File

@@ -274,6 +274,7 @@ CFGCHECK_MAKEFLAGS = # CFLAGS='$(AM_CFLAGS)'
checkcfg.strict-c90: CFGCHECK_CONFIGFLAGS = CFLAGS='-std=c90 -pedantic'
checkcfg.strict-c90: CFGCHECK_MAKEFLAGS =
checkcfg.job-pipe: CFGCHECK_CONFIGFLAGS = CPPFLAGS=-DJOBSERVER_USE_FIFO=0
checkcfg.no-jobserver:CFGCHECK_CONFIGFLAGS = --disable-job-server
checkcfg.no-load: CFGCHECK_CONFIGFLAGS = --disable-load
checkcfg.no-guile: CFGCHECK_CONFIGFLAGS = --without-guile
@@ -289,6 +290,7 @@ checkcfg.no-archives: CFGCHECK_CONFIGFLAGS = CPPFLAGS=-DNO_ARCHIVES
CONFIG_CHECKS := \
checkcfg.strict-c90 \
checkcfg.job-pipe \
checkcfg.no-jobserver \
checkcfg.no-load \
checkcfg.no-guile \

View File

@@ -527,18 +527,24 @@ static const char *default_variables[] =
"AS", "as",
#ifdef GCC_IS_NATIVE
"CC", "gcc",
# ifdef __MSDOS__
"CXX", "gpp", /* g++ is an invalid name on MSDOS */
# else
"CXX", "gcc",
# endif /* __MSDOS__ */
"OBJC", "gcc",
#else
"CC", "cc",
"CXX", "g++",
"OBJC", "cc",
#endif
#ifdef MAKE_CXX
"CXX", MAKE_CXX,
#else
# ifdef GCC_IS_NATIVE
# ifdef __MSDOS__
"CXX", "gpp", /* g++ is an invalid name on MSDOS */
# else
"CXX", "gcc",
# endif /* __MSDOS__ */
# else
"CXX", "g++",
# endif
#endif
/* This expands to $(CO) $(COFLAGS) $< $@ if $@ does not exist,
and to the empty string if $@ does exist. */
"CHECKOUT,v", "+$(if $(wildcard $@),,$(CO) $(COFLAGS) $< $@)",

View File

@@ -272,6 +272,8 @@ pattern_search (struct file *file, int archive,
PATH_VAR (stem_str); /* @@ Need to get rid of stem, stemlen, etc. */
++depth;
#ifndef NO_ARCHIVES
if (archive || ar_name (filename))
lastslash = 0;
@@ -893,7 +895,7 @@ pattern_search (struct file *file, int archive,
if (pattern_search (int_file,
0,
depth + 1,
depth,
recursions + 1,
allow_compat_rules))
{
@@ -1139,6 +1141,8 @@ pattern_search (struct file *file, int archive,
free (tryrules);
free (deplist);
--depth;
if (rule)
{
DBS (DB_IMPLICIT, (_("Found implicit rule '%s' for '%s'.\n"),

View File

@@ -1193,7 +1193,7 @@ start_job_command (struct child *child)
| child->file->cmds->lines_flags[child->command_line - 1]);
p = child->command_ptr;
child->noerror = ((flags & COMMANDS_NOERROR) != 0);
child->noerror = ANY_SET (flags, COMMANDS_NOERROR);
while (*p != '\0')
{
@@ -1209,7 +1209,7 @@ start_job_command (struct child *child)
++p;
}
child->recursive = ((flags & COMMANDS_RECURSE) != 0);
child->recursive = ANY_SET (flags, COMMANDS_RECURSE);
/* Update the file's command flags with any new ones we found. We only
keep the COMMANDS_RECURSE setting. Even this isn't 100% correct; we are
@@ -1294,7 +1294,7 @@ start_job_command (struct child *child)
command line, or 'succeeded' otherwise. The exit status of 1 tells the
user that -q is saying 'something to do'; the exit status for a random
error is 2. */
if (argv != 0 && question_flag && !(flags & COMMANDS_RECURSE))
if (argv != 0 && question_flag && NONE_SET (flags, COMMANDS_RECURSE))
{
FREE_ARGV (argv);
#ifdef VMS
@@ -1310,7 +1310,7 @@ start_job_command (struct child *child)
#endif
}
if (touch_flag && !(flags & COMMANDS_RECURSE))
if (touch_flag && NONE_SET (flags, COMMANDS_RECURSE))
{
/* Go on to the next command. It might be the recursive one.
We construct ARGV only to find the end of the command line. */
@@ -1344,7 +1344,7 @@ start_job_command (struct child *child)
in SYNC_RECURSE mode or this command is not recursive. We'll also check
output_sync separately below in case it changes due to error. */
child->output.syncout = output_sync && (output_sync == OUTPUT_SYNC_RECURSE
|| !(flags & COMMANDS_RECURSE));
|| NONE_SET (flags, COMMANDS_RECURSE));
OUTPUT_SET (&child->output);
@@ -1355,7 +1355,7 @@ start_job_command (struct child *child)
/* Print the command if appropriate. */
if (just_print_flag || ISDB (DB_PRINT)
|| (!(flags & COMMANDS_SILENT) && !run_silent))
|| (NONE_SET (flags, COMMANDS_SILENT) && !run_silent))
OS (message, 0, "%s", p);
/* Tell update_goal_chain that a command has been started on behalf of
@@ -1395,7 +1395,7 @@ start_job_command (struct child *child)
/* If -n was given, recurse to get the next line in the sequence. */
if (just_print_flag && !(flags & COMMANDS_RECURSE))
if (just_print_flag && NONE_SET (flags, COMMANDS_RECURSE))
{
FREE_ARGV (argv);
goto next_command;
@@ -1464,12 +1464,12 @@ start_job_command (struct child *child)
#else
jobserver_pre_child (flags & COMMANDS_RECURSE);
jobserver_pre_child (ANY_SET (flags, COMMANDS_RECURSE));
child->pid = child_execute_job ((struct childbase *)child,
child->good_stdin, argv);
jobserver_post_child (flags & COMMANDS_RECURSE);
jobserver_post_child (ANY_SET (flags, COMMANDS_RECURSE));
#endif /* !VMS */
}
@@ -2886,7 +2886,7 @@ construct_command_argv_internal (char *line, char **restp, const char *shell,
return 0;
if (shellflags == 0)
shellflags = posix_pedantic ? "-ec" : "-c";
shellflags = posix_pedantic && NONE_SET (flags, COMMANDS_NOERROR) ? "-ec" : "-c";
/* See if it is safe to parse commands internally. */
if (shell == 0)
@@ -3538,7 +3538,7 @@ construct_command_argv_internal (char *line, char **restp, const char *shell,
/* Some shells do not work well when invoked as 'sh -c xxx' to run a
command line (e.g. Cygnus GNUWIN32 sh.exe on W32 systems). In these
cases, run commands via a script file. */
if (just_print_flag && !(flags & COMMANDS_RECURSE))
if (just_print_flag && NONE_SET (flags, COMMANDS_RECURSE))
{
/* Need to allocate new_argv, although it's unused, because
start_job_command will want to free it and its 0'th element. */
@@ -3710,6 +3710,7 @@ construct_command_argv (char *line, char **restp, struct file *file,
char **argv;
{
struct variable *var;
/* Turn off --warn-undefined-variables while we expand SHELL and IFS. */
int save = warn_undefined_variables_flag;
warn_undefined_variables_flag = 0;
@@ -3770,7 +3771,15 @@ construct_command_argv (char *line, char **restp, struct file *file,
}
#endif /* __EMX__ */
shellflags = allocated_variable_expand_for_file ("$(.SHELLFLAGS)", file);
var = lookup_variable_for_file (STRING_SIZE_TUPLE (".SHELLFLAGS"), file);
if (!var)
shellflags = xstrdup ("");
else if (posix_pedantic && var->origin == o_default)
/* In POSIX mode we default to -ec, unless we're ignoring errors. */
shellflags = xstrdup (ANY_SET (cmd_flags, COMMANDS_NOERROR) ? "-c" : "-ec");
else
shellflags = allocated_variable_expand_for_file (var->value, file);
ifs = allocated_variable_expand_for_file ("$(IFS)", file);
warn_undefined_variables_flag = save;

View File

@@ -234,6 +234,7 @@ static const int inf_jobs = 0;
char *jobserver_auth = NULL;
/* Style for the jobserver. */
static char *jobserver_style = NULL;
/* Shuffle mode for goals and prerequisites. */
@@ -1447,7 +1448,7 @@ main (int argc, char **argv, char **envp)
#endif
#ifdef MAKE_JOBSERVER
" jobserver"
# ifdef HAVE_MKFIFO
# if JOBSERVER_USE_FIFO
" jobserver-fifo"
# endif
#endif

View File

@@ -83,6 +83,12 @@ extern int errno;
#endif
/* Define macros specifying which OS we are building for. */
#if __gnu_hurd__
# define MK_OS_HURD 1
#endif
#if __CYGWIN__
# define MK_OS_CYGWIN 1
#endif
#if defined(__MVS__)
# define MK_OS_ZOS 1
#endif
@@ -390,7 +396,9 @@ extern int unixy_shell;
# endif
/* Include only the minimal stuff from windows.h. */
# define WIN32_LEAN_AND_MEAN
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
# endif
#endif /* WINDOWS32 */
/* ALL_SET() evaluates the second argument twice. */
@@ -742,6 +750,14 @@ extern char cmd_prefix;
extern unsigned int no_intermediates;
#if HAVE_MKFIFO
/* It seems that mkfifo() is not working correctly, or at least not the way
GNU make wants it to work, on GNU/Hurd and Cygwin so don't use it there. */
# if !defined(JOBSERVER_USE_FIFO) && !MK_OS_HURD && !MK_OS_CYGWIN
# define JOBSERVER_USE_FIFO 1
# endif
#endif
#define JOBSERVER_AUTH_OPT "jobserver-auth"
extern char *jobserver_auth;

View File

@@ -28,6 +28,11 @@ this program. If not, see <https://www.gnu.org/licenses/>. */
# include <io.h>
#endif
#ifdef __EMX__
# define INCL_DOS
# include <os2.h>
#endif
#ifdef HAVE_FCNTL_H
# include <fcntl.h>
#else
@@ -781,6 +786,40 @@ get_tmpfile (char **name)
}
#if HAVE_TTYNAME && defined(__EMX__)
/* OS/2 kLIBC has a declaration for ttyname(), so configure finds it.
But, it is not implemented! Roll our own. */
char *ttyname (int fd)
{
ULONG type;
ULONG attr;
ULONG rc;
rc = DosQueryHType (fd, &type, &attr);
if (rc)
{
errno = EBADF;
return NULL;
}
if (type == HANDTYPE_DEVICE)
{
if (attr & 3) /* 1 = KBD$, 2 = SCREEN$ */
return (char *) "/dev/con";
if (attr & 4) /* 4 = NUL */
return (char *) "/dev/nul";
if (attr & 8) /* 8 = CLOCK$ */
return (char *) "/dev/clock$";
}
errno = ENOTTY;
return NULL;
}
#endif
#if !HAVE_STRCASECMP && !HAVE_STRICMP && !HAVE_STRCMPI
/* If we don't have strcasecmp() (from POSIX), or anything that can substitute
for it, define our own version. */

View File

@@ -147,8 +147,8 @@ jobserver_setup (int slots, const char *style)
{
int r;
#if HAVE_MKFIFO
if (style == NULL || strcmp (style, "fifo") == 0)
#if JOBSERVER_USE_FIFO
if (!style || strcmp (style, "fifo") == 0)
{
/* Unfortunately glibc warns about uses of mktemp even though we aren't
using it in dangerous way here. So avoid this by generating our own

View File

@@ -109,6 +109,7 @@ check_also_make (const struct file *file)
enum update_status
update_goal_chain (struct goaldep *goaldeps)
{
unsigned long last_cmd_count = 0;
int t = touch_flag, q = question_flag, n = just_print_flag;
enum update_status status = us_none;
@@ -134,9 +135,12 @@ update_goal_chain (struct goaldep *goaldeps)
start_waiting_jobs ();
/* Wait for a child to die. */
/* Check for exited children. If no children have finished since the
last time we looked, then block until one exits. If some have
exited don't block, so we can possibly do more work. */
reap_children (1, 0);
reap_children (last_cmd_count == command_count, 0);
last_cmd_count = command_count;
lastgoal = 0;
gu = goals;
@@ -491,8 +495,6 @@ update_file_1 (struct file *file, unsigned int depth)
fail. */
file->no_diag = file->dontcare;
++depth;
/* Notice recursive update of the same file. */
start_updating (file);
@@ -500,6 +502,9 @@ update_file_1 (struct file *file, unsigned int depth)
remember this one to turn off updating. */
ofile = file;
/* Increase the depth for reporting how we build the file. */
++depth;
/* Looking at the file's modtime beforehand allows the possibility
that its name may be changed by a VPATH search, and thus it may
not need an implicit rule. If this were not done, the file
@@ -734,16 +739,18 @@ update_file_1 (struct file *file, unsigned int depth)
finish_updating (file);
finish_updating (ofile);
DBF (DB_VERBOSE, _("Finished prerequisites of target file '%s'.\n"));
/* We've decided what we need to do to build the file. */
--depth;
if (running)
{
set_command_state (file, cs_deps_running);
--depth;
DBF (DB_VERBOSE, _("The prerequisites of '%s' are being made.\n"));
return us_success;
}
DBF (DB_VERBOSE, _("Finished prerequisites of target file '%s'.\n"));
/* If any dependency failed, give up now. */
if (dep_status)
@@ -752,8 +759,6 @@ update_file_1 (struct file *file, unsigned int depth)
file->update_status = dep_status == us_none ? us_failed : dep_status;
notice_finished_file (file);
--depth;
DBF (DB_VERBOSE, _("Giving up on target file '%s'.\n"));
if (depth == 0 && keep_going_flag
@@ -828,16 +833,13 @@ update_file_1 (struct file *file, unsigned int depth)
if (fmt)
{
print_spaces (depth);
print_spaces (depth+1);
printf (fmt, dep_name (d), file->name);
fflush (stdout);
}
}
}
/* Here depth returns to the value it had when we were called. */
depth--;
if (file->double_colon && file->deps == 0)
{
must_make = 1;
@@ -958,7 +960,7 @@ notice_finished_file (struct file *file)
we don't want to do the touching. */
unsigned int i;
for (i = 0; i < file->cmds->ncommand_lines; ++i)
if (!(file->cmds->lines_flags[i] & COMMANDS_RECURSE))
if (NONE_SET (file->cmds->lines_flags[i], COMMANDS_RECURSE))
goto have_nonrecursing;
}
else
@@ -999,7 +1001,7 @@ notice_finished_file (struct file *file)
if ((question_flag || just_print_flag || touch_flag) && file->cmds)
{
for (i = file->cmds->ncommand_lines; i > 0; --i)
if (! (file->cmds->lines_flags[i-1] & COMMANDS_RECURSE))
if (NONE_SET (file->cmds->lines_flags[i-1], COMMANDS_RECURSE))
break;
}
@@ -1084,7 +1086,6 @@ check_dep (struct file *file, unsigned int depth,
struct dep *d;
enum update_status dep_status = us_success;
++depth;
start_updating (file);
/* We might change file if we find a different one via vpath;
@@ -1182,7 +1183,7 @@ check_dep (struct file *file, unsigned int depth,
d->file->parent = file;
maybe_make = *must_make_ptr;
new = check_dep (d->file, depth, this_mtime, &maybe_make);
new = check_dep (d->file, depth+1, this_mtime, &maybe_make);
if (new > dep_status)
dep_status = new;

View File

@@ -538,6 +538,29 @@ lookup_variable (const char *name, size_t length)
return 0;
}
/* Lookup a variable whose name is a string starting at NAME
and with LENGTH chars. NAME need not be null-terminated.
Returns address of the 'struct variable' containing all info
on the variable, or nil if no such variable is defined. */
struct variable *
lookup_variable_for_file (const char *name, size_t length, struct file *file)
{
struct variable *var;
struct variable_set_list *savev;
if (file == NULL)
return lookup_variable (name, length);
savev = current_variable_set_list;
current_variable_set_list = file->variables;
var = lookup_variable (name, length);
current_variable_set_list = savev;
return var;
}
/* Lookup a variable whose name is a string starting at NAME
and with LENGTH chars in set SET. NAME need not be null-terminated.

View File

@@ -182,6 +182,8 @@ void define_new_function(const floc *flocp, const char *name,
unsigned int min, unsigned int max, unsigned int flags,
gmk_func_ptr func);
struct variable *lookup_variable (const char *name, size_t length);
struct variable *lookup_variable_for_file (const char *name, size_t length,
struct file *file);
struct variable *lookup_variable_in_set (const char *name, size_t length,
const struct variable_set *set);

View File

@@ -671,6 +671,7 @@ sub set_more_defaults
create_file('features.mk', 'all:;$(info $(.FEATURES))');
%FEATURES = map { $_ => 1 } split /\s+/, `$make_path -sf features.mk`;
print "$make_path FEATURES: @{[%FEATURES]}\n" if $verbose;
unlink('features.mk');
# Find the default values for different built-in variables

View File

@@ -35,7 +35,7 @@ $redir = '' if $osname eq 'VMS';
# This is the value from src/default.c
my $arflags = $osname eq 'aix' ? '-Xany -rv' : '-rv';
my $arvar = "AR=$ar";
my $arvar = "AR=\"$ar\"";
# Newer versions of binutils can be built with --enable-deterministic-archives
# which forces all timestamps (among other things) to always be 0, defeating
@@ -44,7 +44,7 @@ unlink('libxx.a');
$_ = `$ar ${arflags}U libxx.a a1.o $redir`;
if ($? == 0) {
$arflags = "${arflags}U";
$arvar = "$arvar ARFLAGS=$arflags";
$arvar = "$arvar ARFLAGS=\"$arflags\"";
}
# Some versions of ar print different things on creation. Find out.
@@ -254,12 +254,16 @@ create_file('a.c', 'int i;');
create_file('b.c', 'int j;');
utouch(-20, 'a.c', 'b.c');
my $cc = get_config('CC') || 'cc';
my $vars = "CC=\"$cc\" $arvar";
run_make_test(q!
mylib.a: mylib.a(a.o b.o)
(%): % ;
%.a: ; $(AR) $(ARFLAGS) $@ $?
%.o : %.c ; @echo Compile $<; $(COMPILE.c) -o $@ $<
!, $arvar, "Compile a.c\nCompile b.c\n$ar $arflags mylib.a a.o b.o\n${create2}rm b.o a.o");
!,
$vars, "Compile a.c\nCompile b.c\n$ar $arflags mylib.a a.o b.o\n${create2}rm b.o a.o");
run_make_test(undef, $arvar, "#MAKE#: 'mylib.a' is up to date.");

View File

@@ -38,10 +38,10 @@ sub output_sync_clean {
# reliable. If things are too fast, then sometimes a different job will steal
# the output sync lock and the output is mis-ordered from what we expect.
sub output_sync_wait {
return subst_make_string("#HELPER# -q wait ../mksync.$_[0] sleep 1");
return subst_make_string("#HELPER# \$Q wait ../mksync.$_[0] sleep 1");
}
sub output_sync_set {
return subst_make_string("#HELPER# -q file ../mksync.$_[0]");
return subst_make_string("#HELPER# \$Q file ../mksync.$_[0]");
}
@syncfiles = qw(mksync.foo mksync.foo_start mksync.bar mksync.bar_start);
@@ -66,27 +66,32 @@ open(MAKEFILE,"> foo/Makefile");
print MAKEFILE <<EOF;
all: foo
foo: foo-base ; \@$set_foo
foo: foo-base ; $set_foo
foo-base:
\t\@echo foo: start
\t\@$wait_bar
\t$wait_bar
\t\@echo foo: end
foo-job: foo-job-base ; \@$set_foo
foo-job: foo-job-base ; $set_foo
foo-job-base:
\t\@$wait_bar_start
\t$wait_bar_start
\t\@echo foo: start
\t\@$set_foo_start
\t\@$wait_bar
\t$set_foo_start
\t$wait_bar
\t\@echo foo: end
foo-fail:
\t\@echo foo-fail: start
\t\@$wait_bar
\t$wait_bar
\t\@echo foo-fail: end
\t\@exit 1
\texit 1
V :=
\$V.SILENT:
Q :=
\$VQ := -q
EOF
close(MAKEFILE);
@@ -94,24 +99,29 @@ open(MAKEFILE,"> bar/Makefile");
print MAKEFILE <<EOF;
all: bar baz
bar: bar-base ; \@$set_bar
bar: bar-base ; $set_bar
bar-base:
\t\@echo bar: start
\t\@echo bar: end
bar-job: bar-job-base ; \@$set_bar
bar-job: bar-job-base ; $set_bar
bar-job-base:
\t\@echo bar: start
\t\@$set_bar_start
\t\@$wait_foo_start
\t$set_bar_start
\t$wait_foo_start
\t\@echo bar: end
baz: baz-base
baz-base:
\t\@echo baz: start
\t\@$wait_foo
\t$wait_foo
\t\@echo baz: end
V :=
\$V.SILENT:
Q :=
\$VQ := -q
EOF
close(MAKEFILE);
@@ -353,15 +363,15 @@ s/\r?\n//g;
if (/^[0-9]+$/) {
use POSIX ();
# SV 63157.
# Test that make removes temporary files, even when a signal is received.
# The general test_driver postprocessing will ensure the temporary file used
# to synchronize output and the jobserver fifo are both removed.
# sleep is needed to let make write its "... Terminated" message to the log
# file.
# Test that make removes temporary files, even when a signal is received. The
# general test_driver postprocessing will ensure the temporary file used to
# synchronize output and the jobserver fifo are both removed. sleep is needed
# to let make write its "... Terminated" message to the log file. Must use
# REGEX because some systems (MacOS) add extra text after Terminated.
run_make_test(q!
pid:=$(shell echo $$PPID)
all:; @#HELPER# -q term $(pid) sleep 10
!, '-O -j2', '#MAKE#: *** [#MAKEFILE#:3: all] Terminated', POSIX::SIGTERM);
!, '-O -j2', '/#MAKE#: \*\*\* \[#MAKEFILE#:3: all] Terminated/', POSIX::SIGTERM);
}
unlink($fout);

View File

@@ -58,12 +58,11 @@ use POSIX ();
# sv 63157.
# Test that make removes the temporary file which holds make code from stdin,
# even when a signal is received.
# include bye.mk and bye.mk: rule is needed to cause make to keep the temporary
# file for re-exec. Without re-exec make will remove the file before the signal
# arrives.
# sleep is needed to let make write its "... Terminated" message to the log
# file.
# even when a signal is received. include bye.mk and bye.mk: rule is needed
# to cause make to keep the temporary file for re-exec. Without re-exec make
# will remove the file before the signal arrives. sleep is needed to let make
# write its "... Terminated" message to the log file. Must use REGEX because
# some systems (MacOS) add extra text after Terminated.
&utouch(-600, 'bye.mk');
close(STDIN);
open(STDIN, "<", 'input.mk') || die "$0: cannot open input.mk for reading: $!";
@@ -75,7 +74,7 @@ all:;
bye.mk: force; @#HELPER# -q term $(pid) sleep 10
force:
!,
'-f-', '#MAKE#: *** [#MAKEFILE#:5: bye.mk] Terminated', POSIX::SIGTERM);
'-f-', '/#MAKE#: \*\*\* \[#MAKEFILE#:5: bye.mk] Terminated/', POSIX::SIGTERM);
}
unlink($fout);

View File

@@ -7,12 +7,52 @@ $details = "";
# Ensure turning on .POSIX enables the -e flag for the shell
run_make_test(qq!
run_make_test(q!
.POSIX:
all: ; \@#HELPER# -q fail 1; true
all: ; @#HELPER# -q fail 1; #HELPER# out hello
!,
'', "#MAKE#: *** [#MAKEFILE#:3: all] Error 1\n", 512);
# But explicit settings must still take precedence
run_make_test(q!
.POSIX:
all: ; @-#HELPER# -q fail 1; #HELPER# out hello
.SHELLFLAGS = -c
!,
'', "hello");
run_make_test(q!
.POSIX:
all: ; @-#HELPER# -q fail 1; #HELPER# out hello
all: .SHELLFLAGS = -c
!,
'', "hello");
# SV 63667: We shouldn't add -e to sh if errors are ignored
run_make_test(q!
.POSIX:
all: ; @-#HELPER# -q fail 1; #HELPER# out hello
!,
'', "hello\n");
# But explicit settings must still take precedence
run_make_test(q!
.POSIX:
all: ; @-#HELPER# -q fail 1; #HELPER# out hello
.SHELLFLAGS = -ec
!,
'', "#MAKE#: [#MAKEFILE#:3: all] Error 1 (ignored)\n");
run_make_test(q!
.POSIX:
all: ; @-#HELPER# -q fail 1; #HELPER# out hello
all: .SHELLFLAGS = -ec
!,
'', "#MAKE#: [#MAKEFILE#:3: all] Error 1 (ignored)\n");
# User settings must override .POSIX
# In the standard .POSIX must be the first thing in the makefile
# but we relax that rule in GNU Make.

View File

@@ -209,7 +209,7 @@ $answer
# sv 63347.
# Same as above, with makefile setting the value of the same variables as
# defined on the cli.
my $answer = 'erR -- hello:=world FOO=bar';
$answer = 'erR -- hello:=world FOO=bar';
run_make_test(q!
$(info $(MAKEFLAGS))
FOO=moon
@@ -224,7 +224,7 @@ $answer
# sv 63347.
# Same as above, with makefile overriding the value of cli definition.
my $answer = 'erR -- hello:=world FOO=bar';
$answer = 'erR -- hello:=world FOO=bar';
run_make_test(q!
$(info $(MAKEFLAGS))
override FOO=moon
@@ -240,7 +240,7 @@ $answer
# Same as above, and makefile overrides the value of cli definition.
# resets MAKEOVERRIDES.
my $answer = 'rR -- hello:=world FOO=bar';
$answer = 'rR -- hello:=world FOO=bar';
run_make_test(q!
$(info $(MAKEFLAGS))
override FOO=moon
@@ -259,7 +259,7 @@ rR -- \nrR
# sv 63347.
# MAKEFLAGS set is env and makefile sets MAKEFLAGS and there is a command
# line definition.
my $answer = ' -- bye=moon hello=world';
$answer = ' -- bye=moon hello=world';
$ENV{'MAKEFLAGS'} = 'hello=world';
run_make_test(q!
$(info $(MAKEFLAGS))
@@ -271,7 +271,7 @@ all:; $(info $(MAKEFLAGS))
# sv 63347.
# Conditional assignment and MAKEFLAGS.
my $answer = 'B -- bye=moon hello=world';
$answer = 'B -- bye=moon hello=world';
$ENV{'MAKEFLAGS'} = 'hello=world';
run_make_test(q!
$(info $(MAKEFLAGS))
@@ -389,7 +389,7 @@ all:; $(info good)
# contains the winning switch at parse and build time.
# 9. MAKEFLAGS does not contain the beaten switch.
my @flavors = ('=', ':=', ':::=', '+=');
@flavors = ('=', ':=', ':::=', '+=');
# sv 63537
# -w vs --no-print-directory
@@ -489,8 +489,8 @@ run_make_test("
MAKEFLAGS${fl}--no-print-directory
\$(info \$(MAKEFLAGS))
all:
\$(info \$(MAKEFLAGS))
\$(MAKE) -C lib2
\t \$(info \$(MAKEFLAGS))
\t \$(MAKE) -C lib2
", '-w',
"#MAKE#: Entering directory '#PWD#'
w
@@ -511,8 +511,8 @@ run_make_test("
MAKEFLAGS${fl}--no-print-directory
\$(info \$(MAKEFLAGS))
all:
\$(info \$(MAKEFLAGS))
\$(MAKE) -C lib2
\t \$(info \$(MAKEFLAGS))
\t \$(MAKE) -C lib2
", '',
"#MAKE#: Entering directory '#PWD#'
w
@@ -535,66 +535,70 @@ rmdir('lib2');
# -S in env.
$ENV{'MAKEFLAGS'} = '-S';
run_make_test(q!
.RECIPEPREFIX := >
$(info $(MAKEFLAGS))
all: one two
one:
$(info $(MAKEFLAGS))
#HELPER# -q fail 1
> $(info $(MAKEFLAGS))
> #HELPER# -q fail 1
two:; $(info $@)
!, '',
"S
S
#HELPER# -q fail 1
#MAKE#: *** [#MAKEFILE#:6: one] Error 1", 512);
#MAKE#: *** [#MAKEFILE#:7: one] Error 1", 512);
# -S in env, -k on the command line.
$ENV{'MAKEFLAGS'} = '-S';
run_make_test(q!
.RECIPEPREFIX := >
$(info $(MAKEFLAGS))
all: one two
one:
$(info $(MAKEFLAGS))
#HELPER# -q fail 1
> $(info $(MAKEFLAGS))
> #HELPER# -q fail 1
two:; $(info $@)
!, '-k',
"k
k
#HELPER# -q fail 1
#MAKE#: *** [#MAKEFILE#:6: one] Error 1
#MAKE#: *** [#MAKEFILE#:7: one] Error 1
two
#MAKE#: Target 'all' not remade because of errors.", 512);
# -k in env.
$ENV{'MAKEFLAGS'} = '-k';
run_make_test(q!
.RECIPEPREFIX := >
$(info $(MAKEFLAGS))
all: one two
one:
$(info $(MAKEFLAGS))
#HELPER# -q fail 1
> $(info $(MAKEFLAGS))
> #HELPER# -q fail 1
two:; $(info $@)
!, '',
"k
k
#HELPER# -q fail 1
#MAKE#: *** [#MAKEFILE#:6: one] Error 1
#MAKE#: *** [#MAKEFILE#:7: one] Error 1
two
#MAKE#: Target 'all' not remade because of errors.", 512);
# -k in env, -S on the command line.
$ENV{'MAKEFLAGS'} = '-k';
run_make_test(q!
.RECIPEPREFIX := >
$(info $(MAKEFLAGS))
all: one two
one:
$(info $(MAKEFLAGS))
#HELPER# -q fail 1
> $(info $(MAKEFLAGS))
> #HELPER# -q fail 1
two:; $(info $@)
!, '-S',
"S
S
#HELPER# -q fail 1
#MAKE#: *** [#MAKEFILE#:6: one] Error 1", 512);
#MAKE#: *** [#MAKEFILE#:7: one] Error 1", 512);
delete $ENV{'MAKEFLAGS'};
@@ -605,8 +609,8 @@ MAKEFLAGS${fl}-k
\$(info \$(MAKEFLAGS))
all: one two
one:
\$(info \$(MAKEFLAGS))
#HELPER# -q fail 1
\t \$(info \$(MAKEFLAGS))
\t #HELPER# -q fail 1
two:; \$(info \$@)
", '',
"k
@@ -625,8 +629,8 @@ MAKEFLAGS${fl}-k
\$(info \$(MAKEFLAGS))
all: one two
one:
\$(info \$(MAKEFLAGS))
#HELPER# -q fail 1
\t \$(info \$(MAKEFLAGS))
\t #HELPER# -q fail 1
two:; \$(info \$@)
", '-S',
"S
@@ -644,8 +648,8 @@ MAKEFLAGS${fl}-k
\$(info \$(MAKEFLAGS))
all: one two
one:
\$(info \$(MAKEFLAGS))
#HELPER# -q fail 1
\t \$(info \$(MAKEFLAGS))
\t #HELPER# -q fail 1
two:; \$(info \$@)
", '',
"S
@@ -664,8 +668,8 @@ MAKEFLAGS${fl}-S
\$(info \$(MAKEFLAGS))
all: one two
one:
\$(info \$(MAKEFLAGS))
#HELPER# -q fail 1
\t \$(info \$(MAKEFLAGS))
\t #HELPER# -q fail 1
two:; \$(info \$@)
", '',
"S
@@ -681,8 +685,8 @@ MAKEFLAGS${fl}-S
\$(info \$(MAKEFLAGS))
all: one two
one:
\$(info \$(MAKEFLAGS))
#HELPER# -q fail 1
\t \$(info \$(MAKEFLAGS))
\t #HELPER# -q fail 1
two:; \$(info \$@)
", '-k',
"k
@@ -702,8 +706,8 @@ MAKEFLAGS${fl}-S
\$(info \$(MAKEFLAGS))
all: one two
one:
\$(info \$(MAKEFLAGS))
#HELPER# -q fail 1
\t \$(info \$(MAKEFLAGS))
\t #HELPER# -q fail 1
two:; \$(info \$@)
", '',
"k

View File

@@ -908,9 +908,9 @@ sub compare_answer_vms
return 0;
}
sub compare_answer_zos
sub convert_answer_zos
{
my ($kgo, $log) = @_;
my ($log) = @_;
# z/OS emits "Error 143" or "SIGTERM" instead of terminated
$log =~ s/Error 143/Terminated/gm;
@@ -920,7 +920,7 @@ sub compare_answer_zos
$log =~ s/EDC5129I No such file or directory\./No such file or directory/gm;
$log =~ s/FSUM7351 not found/not found/gm;
return $log eq $kgo;
return $log;
}
sub compare_answer
@@ -939,10 +939,16 @@ sub compare_answer
$log =~ s,\r\n,\n,gs;
return 1 if ($log eq $kgo);
# Keep these in case it's a regex
# Keep the originals in case it's a regex
$mkgo = $kgo;
$mlog = $log;
# z/OS has quirky outputs
if ($osname eq 'os390') {
$mlog = convert_answer_zos($mlog);
return 1 if ($mlog eq $kgo);
}
# Some versions of Perl on Windows use /c instead of C:
$mkgo =~ s,\b([A-Z]):,/\L$1,g;
$mlog =~ s,\b([A-Z]):,/\L$1,g;
@@ -956,9 +962,6 @@ sub compare_answer
# VMS is a whole thing...
return 1 if ($osname eq 'VMS' && compare_answer_vms($kgo, $log));
# z/OS has its own quirks
return 1 if ($osname eq 'os390' && compare_answer_zos($kgo, $log));
# See if the answer might be a regex.
if ($kgo =~ m,^/(.+)/$,) {
# Check the regex against both the original and modified strings