Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
/Basic.mk
/ChangeLog
/ChangeLog-spell-corrected
/ChangeLog.orig
/Makefile
/Makefile.DOS
/Makefile.in
Expand Down
52 changes: 1 addition & 51 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ AH_BOTTOM(
# We have to enable "foreign" because ChangeLog is auto-generated
# Automake 1.15 and gnulib don't get along: gnulib has some strange error
# in the way it handles getloadavg.c which causes make distcheck to fail.
# http://lists.gnu.org/archive/html/bug-gnulib/2018-06/msg00024.html
# https://lists.gnu.org/archive/html/bug-gnulib/2018-06/msg00024.html
#
# We have to enable "info-in-builddir" because future versions of automake
# would place generated .info files in srcdir instead of builddir. Using that
Expand Down Expand Up @@ -658,56 +658,6 @@ Makefile lib/Makefile po/Makefile.in doc/Makefile \
tests/config-flags.pm \
libdebugger/Makefile
])
# We don't need this: the standard automake output suffices for POSIX systems.
#mk/Posix.mk

# We like mondo-warnings!
# Also force comments to be preserved. This helps when using ccache, in
# combination with GCC 7's implicit-fallthrough warning.
# check for some supported compiler flags, instead of have 'em hard coded in
# maintMakefile
# -Werror is too much, on different platform we get different warnings FOR
# e.g. guile headers.
# rocky: However to *test* for whether to use options below, we want to turn
# warnings into errors, hence, the separate check for -Werror.
WARN_TO_ERROR_CFLAG=""
AX_CHECK_COMPILE_FLAG([-Werror], [WARN_TO_ERROR_CFLAG="-Werror "])
CHECK_CFLAGS="
-C
-Wall
-Wbad-function-cast
-Wchar-subscripts
-Wdeclaration-after-statement
-Wdisabled-optimization
-Wduplicate-conk
-Wduplicate-enum
-Wendif-labels
-Wextra
-Wformat-security
-Wformat-signedness
-Wignore-qualifiers
-Winline
-Wlogical-op
-Wlong-long
-Wnested-externs
-Wno-sign-compare
-Wpointer-arith
-Wshadow
-Wtype-limits
-Wunused
-Wunused-but-set-parameter
-Wunused-parameter
-Wwrite-strings
"

# Warnings not used (because they trigger messages):
# -Wmissing-declarations
# -Wstrict-prototypes
# -Wundef

for OPT in $CHECK_CFLAGS; do
AX_CHECK_COMPILE_FLAG([$OPT $WARN_TO_ERROR_CFLAG], [AM_CFLAGS="$AM_CFLAGS $OPT"])
done

AC_SUBST([AM_CFLAGS])

Expand Down
5 changes: 3 additions & 2 deletions po/POTFILES.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# List of source files containing translatable strings.
# Copyright (C) 2000-2020 Free Software Foundation, Inc.
# Copyright (C) 2000-2022 Free Software Foundation, Inc.
# This file is part of GNU Make.
#
# GNU Make is free software; you can redistribute it and/or modify it under
Expand All @@ -13,7 +13,7 @@
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
# this program. If not, see <https://www.gnu.org/licenses/>.

libdebugger/break.c
libdebugger/cmd.c
Expand Down Expand Up @@ -52,6 +52,7 @@ src/read.c
src/remake.c
src/remote-cstms.c
src/rule.c
src/shuffle.c
src/signame.c
src/strcache.c
src/variable.c
Expand Down
4 changes: 3 additions & 1 deletion src/dep.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ struct nameseq
unsigned int ignore_mtime : 1; \
unsigned int staticpattern : 1; \
unsigned int need_2nd_expansion : 1; \
unsigned int ignore_automatic_vars : 1
unsigned int ignore_automatic_vars : 1; \
unsigned int is_explicit : 1; \
unsigned int wait_here : 1

struct dep
{
Expand Down
80 changes: 53 additions & 27 deletions src/expand.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Builtin function expansion header for GNU Make.
Copyright (C) 1988-2020 Free Software Foundation, Inc.
/* Variable expansion functions for GNU Make.
Copyright (C) 1988-2022 Free Software Foundation, Inc.
This file is part of GNU Make.

GNU Make is free software; you can redistribute it and/or modify it under the
Expand All @@ -12,15 +12,16 @@ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. */
this program. If not, see <https://www.gnu.org/licenses/>. */

#include "makeint.h"

#include <assert.h>

#include "commands.h"
#include "debug.h"
#include "filedef.h"
#include "job.h"
#include "commands.h"
#include "variable.h"
#include "rule.h"
#include "function.h"
Expand All @@ -43,6 +44,9 @@ const gmk_floc **expanding_var = &reading_file;

#define VARIABLE_BUFFER_ZONE 5

char * variable_expand (const char *line);


static size_t variable_buffer_length;
char *variable_buffer;

Expand All @@ -68,13 +72,13 @@ variable_buffer_output (char *ptr, const char *string, size_t length)
ptr = variable_buffer + offset;
}

memcpy (ptr, string, length);
return ptr + length;
return mempcpy (ptr, string, length);
}

/* Return a pointer to the beginning of the variable buffer. */
/* Return a pointer to the beginning of the variable buffer.
This is called from main() and it should never be null afterward. */

static char *
char *
initialize_variable_output (void)
{
/* If we don't have a variable output buffer yet, get one. */
Expand All @@ -91,6 +95,22 @@ initialize_variable_output (void)

/* Recursively expand V. The returned string is malloc'd. */

/** Expand PSZ_LINE. Expansion uses P_FILE_SET if it is not NULL. */
char *
variable_expand_set (char *psz_line, variable_set_list_t *p_file_vars)
{
char *psz_result;
variable_set_list_t *p_vars_save;

p_vars_save = current_variable_set_list;
if (p_file_vars)
current_variable_set_list = p_file_vars;
psz_result = variable_expand (psz_line);
current_variable_set_list = p_vars_save;

return psz_result;
}

static char *allocated_variable_append (const struct variable *v);

char *
Expand All @@ -102,6 +122,29 @@ recursively_expand_for_file (struct variable *v, struct file *file)
struct variable_set_list *save = 0;
int set_reading = 0;

/* If we're expanding to put into the environment of a shell function then
ignore any recursion issues: for backward-compatibility we will use
the value of the environment variable we were started with. */
if (v->expanding && env_recursion)
{
size_t nl = strlen (v->name);
char **ep;
DB (DB_VERBOSE,
(_("%s:%lu: not recursively expanding %s to export to shell function\n"),
v->fileinfo.filenm, v->fileinfo.lineno, v->name));

/* We could create a hash for the original environment for speed, but a
reasonably written makefile shouldn't hit this situation... */
for (ep = environ; *ep != 0; ++ep)
if ((*ep)[nl] == '=' && strncmp (*ep, v->name, nl) == 0)
return xstrdup ((*ep) + nl + 1);

/* If there's nothing in the parent environment, use the empty string.
This isn't quite correct since the variable should not exist at all,
but getting that to work would be involved. */
return xstrdup ("");
}

/* Don't install a new location if this location is empty.
This can happen for command-line variables, builtin variables, etc. */
saved_varp = expanding_var;
Expand Down Expand Up @@ -189,7 +232,6 @@ reference_variable (char *o, const char *name, size_t length)
if (v == 0)
warn_undefined (name, length);


/* If there's no variable by that name or it has no value, stop now. */
if (v == 0 || (*v->value == '\0' && !v->append))
return o;
Expand Down Expand Up @@ -230,7 +272,7 @@ variable_expand_string (char *line, const char *string, size_t length)
if (length == 0)
{
variable_buffer_output (o, "", 1);
return (variable_buffer);
return variable_buffer;
}

/* We need a copy of STRING: due to eval, it's possible that it will get
Expand Down Expand Up @@ -503,27 +545,11 @@ variable_expand_for_file (const char *line, struct file *file)
return result;
}

/** Expand PSZ_LINE. Expansion uses P_FILE_SET if it is not NULL. */
char *
variable_expand_set (char *psz_line, variable_set_list_t *p_file_vars)
{
char *psz_result;
variable_set_list_t *p_vars_save;

p_vars_save = current_variable_set_list;
if (p_file_vars)
current_variable_set_list = p_file_vars;
psz_result = variable_expand (psz_line);
current_variable_set_list = p_vars_save;

return psz_result;
}

/* Like allocated_variable_expand, but for += target-specific variables.
First recursively construct the variable value from its appended parts in
any upper variable sets. Then expand the resulting value. */

static char *
char *
variable_append (const char *name, size_t length,
const struct variable_set_list *set, int local)
{
Expand Down
45 changes: 32 additions & 13 deletions src/file.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Target file management for GNU Make.
Copyright (C) 1988-2020 Free Software Foundation, Inc.
Copyright (C) 1988-2025 Free Software Foundation, Inc.
This file is part of GNU Make.

GNU Make is free software; you can redistribute it and/or modify it under the
Expand All @@ -12,7 +12,7 @@ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. */
this program. If not, see <https://www.gnu.org/licenses/>. */

#include "makeint.h"
#include "file_basic.h"
Expand All @@ -23,6 +23,7 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
#include "file.h"
#include "dep.h"
#include "job.h"
#include "shuffle.h"
#include "commands.h"
#include "variable.h"
#include "debug.h"
Expand All @@ -42,6 +43,14 @@ int snapped_deps = 0;

/* Hash table of files the makefile knows how to make. */

/* We can't free files we take out of the hash table, because they are still
likely pointed to in various places. The check_renamed() will be used if
we come across these, to find the new correct file. This is mainly to
prevent leak checkers from complaining. */
static struct file **rehashed_files = NULL;
static size_t rehashed_files_len = 0;
#define REHASHED_FILES_INCR 5

/* Whether or not .SECONDARY with no prerequisites was given. */
static int all_secondary = 0;

Expand All @@ -67,8 +76,7 @@ rehash_file (struct file *from_file, const char *to_hname)

/* Find the end of the renamed list for the "from" file. */
file_key.hname = from_file->hname;
while (from_file->renamed != 0)
from_file = from_file->renamed;
check_renamed (from_file);
if (file_hash_cmp (from_file, &file_key))
/* hname changed unexpectedly!! */
abort ();
Expand Down Expand Up @@ -107,25 +115,25 @@ rehash_file (struct file *from_file, const char *to_hname)
{
size_t l = strlen (from_file->name);
/* We have two sets of commands. We will go with the
one given in the rule explicitly mentioning this name,
one given in the rule found through directory search,
but give a message to let the user know what's going on. */
if (to_file->cmds->fileinfo.filenm != 0)
error (&from_file->cmds->fileinfo,
l + strlen (to_file->cmds->fileinfo.filenm) + INTSTR_LENGTH,
_("Recipe was specified for file '%s' at %s:%lu,"),
from_file->name, to_file->cmds->fileinfo.filenm,
to_file->cmds->fileinfo.lineno);
_("recipe was specified for file '%s' at %s:%lu,"),
from_file->name, from_file->cmds->fileinfo.filenm,
from_file->cmds->fileinfo.lineno);
else
error (&from_file->cmds->fileinfo, l,
_("Recipe for file '%s' was found by implicit rule search,"),
_("recipe for file '%s' was found by implicit rule search,"),
from_file->name);
l += strlen (to_hname);
error (&from_file->cmds->fileinfo, l,
_("but '%s' is now considered the same file as '%s'."),
_("but '%s' is now considered the same file as '%s'"),
from_file->name, to_hname);
error (&from_file->cmds->fileinfo, l,
_("Recipe for '%s' will be ignored in favor of the one for '%s'."),
to_hname, from_file->name);
_("recipe for '%s' will be ignored in favor of the one for '%s'"),
from_file->name, to_hname);
}
}

Expand Down Expand Up @@ -164,18 +172,29 @@ rehash_file (struct file *from_file, const char *to_hname)

#define MERGE(field) to_file->field |= from_file->field
MERGE (precious);
MERGE (loaded);
MERGE (tried_implicit);
MERGE (updating);
MERGE (updated);
MERGE (is_target);
MERGE (cmd_target);
MERGE (phony);
MERGE (loaded);
/* Don't merge intermediate because this file might be pre-existing */
MERGE (is_explicit);
MERGE (secondary);
MERGE (notintermediate);
MERGE (ignore_vpath);
#undef MERGE

to_file->builtin = 0;
from_file->renamed = to_file;

if (rehashed_files_len % REHASHED_FILES_INCR == 0)
rehashed_files = xrealloc (rehashed_files,
sizeof (struct file *) * (rehashed_files_len + REHASHED_FILES_INCR));

rehashed_files[rehashed_files_len++] = from_file;

}

/* Rename FILE to NAME. This is not as simple as resetting
Expand Down
Loading