Commit graph

2672 commits

Author SHA1 Message Date
Paul Smith
19ae6fe72a [SV 59230] Ensure environment variables are exportable
When checking for invalid environment variable names we searched the
entire name string instead of just the first LENGTH chars; this could
cause us to incorrectly decide the variable was not exportable.

Dmitry Goncharov <dgoncharov@users.sf.net> found this bug and
provided a test case and sample fix: I used the test but chose a
slightly different fix.

* src/variable.c (define_variable_in_set): check the variable name
not the input string.
* tests/scripts/features/targetvars: Ensure environment variable
values are exported.
2020-11-29 17:55:32 -05:00
Paul Smith
0e020bbc24 * src/default.c (default_variables) [AIX]: [SV 59096] Fix ARFLAGS
Reported by Dmitry Goncharov <dgoncharov@users.sf.net>, with a patch
changing the pattern rule for building archives.  I decided to
change the default value of ARFLAGS on AIX instead.
2020-11-29 17:55:32 -05:00
Paul Smith
c01222c018 [SV 35711] Check for special targets earlier
GNU make must recognize some special targets as they are defined.
Because of the way targets are defined, we were not recognizing these
special targets until we were handling the NEXT statement.  However
that's too late for some special targets such as .POSIX etc. which can
change the behavior of make during parsing.

Check for special targets earlier, as soon as we've finished parsing
the target introduction line (before we've even parsed the recipe).

* NEWS: Mention the change.
* src/read.c (check_specials): New function to look for special
targets.  Move checks from eval() and record_files() to this new
function.
(eval): Call check_specials() after we've completed parsing the target
introduction line.  Move default goal detection to check_specials().
(record_files): Move handling of .POSIX, .SECONDEXPANSION, and
.ONESHELL to check_specials().
* tests/scripts/misc/bs-nl: Remove workaround for late .POSIX issue.
* tests/scripts/targets/POSIX: Add a comment.
2020-11-29 17:55:02 -05:00
Paul Smith
957aa450a0 * .ccls: Disable clang compare against static string warning 2020-11-29 10:02:45 -05:00
Paul Smith
e49e11e069 [SV 59093] Rewrite filter/filter-out to avoid large stack usage
* src/function.c (func_filter_filterout): Allocate arrays to hold
pattern and word information rather than creating linked lists on
the stack.
* tests/scripts/functions/filter-out: Test large filters.
2020-11-13 00:44:24 -05:00
Paul Smith
f4f353bb54 * doc/make.texi (Include): Update behavior for missing included files 2020-10-28 11:10:52 -04:00
Paul Smith
a80b0096f5 * NEWS: [SV 58435] Document minimum C compiler version requirement
* configure.ac: Require c99 via AC_PROG_CC_C99
2020-07-19 18:59:06 -04:00
Paul Smith
62e8f029e9 [SV 58735] Define the order that makefiles are rebuilt.
Ensure that makefiles are rebuilt in the order in which make first
considered them, and document this behavior in the manual.

* NEWS: Add a note about the new behavior
* doc/make.text (How make Processes a Makefile): Document it.
* main.c (main): Inverse the list of makefile goals.
* read.c (read_all_makefiles): Add default makefiles to the list at
the front in reverse order, the same way other makefiles are added.
* tests/scripts/features/include: Add tests to verify rebuild order.
2020-07-19 13:56:23 -04:00
Paul Smith
db7658e042 * src/makeint.h: [ARM] [SV 58347] Don't assume ARM is not POSIX 2020-07-10 11:59:40 -04:00
Paul Smith
fa7f95c66c * src/job.c (unblock_sigs): [!POSIX] [SV 58743] Fix syntax errors 2020-07-10 11:59:38 -04:00
Paul Smith
df5f30a76a * NEWS: Fix some tortured grammar. 2020-05-14 01:00:28 -04:00
Paul Smith
1770540217 [SV 57930] Cast char to unsigned char to call ctype functions
This cast was already done almost everywhere: fix some stragglers.

* src/load.c (load_file): Cast char to unsigned char.
* src/misc.c (strcasecmp, strncasecmp): [!POSIX] Ditto.
* src/dir.c (vms_hash): [VMS] Ditto.
* src/vms_progname.c (set_program_name): [VMS] Ditto.
* src/vms_jobs.c (posix_parse_dq): [VMS] Ditto.
(posix_parse_dollar): [VMS] Ditto.
(build_vms_cmd): [VMS] Ditto.
(child_execute_job): [VMS] Ditto.
2020-05-03 14:54:56 -04:00
Paul Smith
c8a6263eb5 Convert [ ... ] to test ... in scripting.
The "[" link may be missing during OS boostrapping.

* build.sh: Convert "[ ... ]" to "test ..."
* maintMakefile: Ditto.
* scripts/copyright-update: Ditto
* tests/scripts/features/reinvoke: Ditto
* tests/scripts/features/targetvars: Ditto
2020-05-03 14:23:56 -04:00
Paul Smith
a015d1f822 * maintMakefile: Clean up output 2020-05-03 14:23:56 -04:00
Paul Smith
c604e53a45 * mainMakefile: Check that INSTALL exists in the dist file
For some reason the INSTALL file symlinked to gnulib was omitted from
the 4.3 release package: I can't reproduce this but check for it.
2020-05-03 14:23:40 -04:00
Kevin Buettner
d79fe162c0 [SV 58232] Disable inheritance of jobserver FDs for recursive make
A parent make will invoke a sub-make with close-on-exec disabled for
the jobserver pipe FDs.  Force close-on-exec to be to be enabled in
the sub-make so the pipe is not always passed to child jobs.

I have a test case which, when invoked with a suitable -j switch,
will hang if the recipe inherits the jobserver pipe.  This test case
was inspired by a real world case in which testing GDB on Fedora
would hang due to some poorly written test GDB cases having been
passed the jobserver file descriptors.

* src/posixos.c (jobserver_parse_auth): Call fd_noinherit() for
jobserver pipe descriptors.

Copyright-paperwork-exempt: yes
2020-05-02 20:09:29 -04:00
Paul Smith
0c326a66c9 [SV 57674] Use the system default PATH if $PATH is not set
When using execvp() if $PATH is not present in the environment
it will automatically search the system default PATH string.  Emulate
this by passing the system default PATH to find_in_given_path() if
we don't find PATH in the environment.

* src/job.c (child_execute_job): Use confstr(_CS_PATH) if PATH is not
found.
2020-04-01 02:02:57 -04:00
Paul Smith
f79bde1a6d tests: Simplify customization of %ENV
Rather than having an %extraENV that is added to the default %ENV
and resetting %ENV _before_ each test, allow the test setup to
modify %ENV directly as needed then reset %ENV _after_ each test.

* tests/test_driver.pl: Remove unused %extraENV.
(resetENV): Don't add in %extraENV.
(_run_command): Reset after we run the command rather than before.
* tests/scripts/features/export: Convert %extraENV to %ENV
* tests/scripts/features/jobserver: Ditto
* tests/scripts/features/parallelism: Ditto
* tests/scripts/features/targetvars: Ditto
* tests/scripts/functions/eval: Ditto
* tests/scripts/functions/foreach: Ditto
* tests/scripts/functions/origin: Ditto
* tests/scripts/misc/general4: Ditto
* tests/scripts/options/dash-e: Ditto
* tests/scripts/targets/POSIX: Ditto
* tests/scripts/variables/GNUMAKEFLAGS: Ditto
* tests/scripts/variables/SHELL: Ditto
2020-04-01 02:02:57 -04:00
Jens Rehsack
289108cc9b * src/output.h: [WINDOWS32] [SV 57888] Use gnulib fcntl if available
If gnulib fcntl is available (for MinGW32) use it rather than our
homegrown version.

Signed-off-by: Jens Rehsack <sno@netbsd.org>
Copyright-paperwork-exempt: yes
2020-03-31 01:07:43 -04:00
Jens Rehsack
61c413d5ea * src/w32/compat/dirent.c: [SV 57888] Use gnulib opendir on MinGW32
Signed-off-by: Jens Rehsack <sno@netbsd.org>
Copyright-paperwork-exempt: yes
2020-03-31 00:50:21 -04:00
Jens Rehsack
d3a53d5d16 * src/dir.c (local_stat): [WINDOWS32] Fix buffer-overflow warning.
[SV 57888] Provide space for the path to use MAXPATHLEN plus nul.

Signed-off-by: Jens Rehsack <sno@netbsd.org>
Copyright-paperwork-exempt: yes
2020-03-31 00:48:57 -04:00
Paul Smith
1306023a4f [SV 57896] Change directories before checking jobserver auth
We want to process -C options as early as possible, before we might
write informational messages, so that Entering/Leaving messages have
the correct directory.

* src/main.c (main): Move code dealing with changing directories
before parsing of the jobserver auth flag.
* tests/scripts/features/jobserver: Test the order of enter/leave.
2020-03-31 00:33:13 -04:00
Paul Smith
80b90b7866 [SV 57967] Only set APPEND mode for regular files
APPEND is a permanent mode shared by all users of a file.  If we
set it on a tty, pipe, etc. it will stay in effect even after make
exits, which can cause problems.

Patch provided by 0xef967c36@gmail.com

* src/output.c (set_append_mode): Check for a regular file.

Copyright-paperwork-exempt: yes
2020-03-31 00:19:20 -04:00
Paul Smith
8e024a2532 Obey order of multiple print/no-print directory options
Previously if --no-print-directory was seen anywhere even once
(environment, command line, etc.) it would always take precedence
over any --print-directory option.  Change this so that the last
seen option (which will be the command line, if present there) takes
precedence.

* NEWS: Mark this change in behavior.
* src/makeint.h (print_directory): A new variable to control printing.
* src/output.c (output_dump): Use the new variable.
(output_start): Ditto.
* src/main.c: Add a new variable print_directory.  Use -1 for
print_directory_flag so we know of the option was seen or not.  Add a
new default_print_directory_flag set to -1 to keep options from being
added.
(switches): Use flag_off for --no-print-directory, rather than a
separate inhibit_print_directory_flag.
(main): If print_directory_flag was set by the user, use that for
print_directory.  If not, compute the print_directory value based on
-s, -C, and sub-makes as before.
* tests/scripts/variables/GNUMAKEFLAGS: -w is not added automatically
* tests/scripts/options/print-directory: Add tests for overriding
print-directory options.
2020-03-31 00:17:49 -04:00
Paul Smith
660a2eafe5 * NEWS: Update 4.3 with information on .SILENT / -s 2020-03-29 17:50:34 -04:00
Eli Zaretskii
8277806db6 * NEWS: Mention the new tcc support. 2020-02-29 11:16:19 +02:00
Christian Jullien
6ba5ea022a Add support for building with Tiny C for MS-Windows
* src/config.h.W32.template (HAVE_DIRECT_H, HAVE_STRCASECMP)
(HAVE_STRNCASECMP, HAVE_UMASK): Add __TINYC__ to MinGW condition.
(BATCH_MODE_ONLY_SHELL): Make this the default for Tiny C.

* build_w32.bat: Support building with Tiny C's tcc compiler.
2020-02-29 11:14:46 +02:00
Paul Smith
4533348826 Apply spelling corrections from Fossies spellcheck
See https://fossies.org/features.html#codespell
Spelling issues in Git commit messages or lib/* source are not applied.

* README.OS2.template: Apply spelling corrections.
* README.VMS: Ditto.
* src/commands.c: Ditto.
* src/config.ami.template: Ditto.
* src/configh.dos.template: Ditto.
* src/job.c: Ditto.
* src/job.h: Ditto.
* src/read.c: Ditto.
* src/variable.c: Ditto.
* src/vms_exit.c: Ditto.
* src/vms_export_symbol.c: Ditto.
* src/vms_progname.c: Ditto.
* src/vmsfunctions.c: Ditto.
* src/vmsjobs.c: Ditto.
* src/w32/pathstuff.c: Ditto.
* tests/scripts/variables/automatic: Ditto.
* tests/test_driver.pl: Ditto.
2020-01-20 19:25:54 -05:00
Paul Smith
68fbad6667 Update to GNU make 4.3.90
* NEWS: Add a 4.3.90 section and update Savannah bug URL
* configure.ac (AC_INIT): Change release to 4.3.90
2020-01-20 19:25:54 -05:00
Paul Smith
f430a65ccb GNU Make release 4.3
* NEWS: Update for the release
* configure.ac: New release number
* doc/make.texi: New edition number
2020-01-19 17:04:52 -05:00
Paul Smith
c30da63fd2 * configure.ac (guile): Check for Guile 3.0 installations 2020-01-19 17:04:52 -05:00
Paul Smith
3fb7312e9f * src/job.c (sh_cmds): [SV 57625] Update builtin shell command list 2020-01-19 17:04:52 -05:00
Paul Smith
dd6adfa454 Resolve some documentation issues
* doc/make.texi (Interrupts): [SV 46193] Recommend defensive recipes
* doc/make.texi: [SV 49262] Clarify interaction of prerequisites and
non-terminal match-anything rules.
2020-01-19 17:04:52 -05:00
Paul Smith
3b5e47b2e2 [SV 40657] Reinstate old behavior for suffix rules with prereqs
POSIX says that suffix rules cannot have prerequisites, but after
making this change we observed a number of makefiles "in the wild"
that were relying on this behavior and failed.

For .POSIX: makefiles, obey POSIX.  Otherwise preserve the old
behavior.  However, generate a warning so users know this is a
problem.  In a future version we will change all behavior to be
POSIX-conforming.

* NEWS: describe the change
* src/rule.c (convert_to_pattern): If posix_pedantic don't make a
pattern rule if prereqs exist.  Otherwise show a warning.
* tests/scripts/features/suffixrules: Add tests for the new behavior
including .POSIX vs. non-.POSIX.
2020-01-19 17:04:52 -05:00
Dmitry Goncharov
4e277f6fbd * tests/test_driver.pl: Enhance error messages 2020-01-05 10:46:58 -05:00
Paul Smith
ec946d7e21 * doc/make.texi: Change the GFDL to an Appendix 2020-01-04 13:24:39 -05:00
Paul Smith
16d06006a4 * NEWS: Clarify authorship of new features. 2020-01-04 13:24:39 -05:00
Paul Smith
b774aebffa Enable compilation with C90 compilers
* configure.ac: Try compiling Guile headers: they don't work with C90.
* maintMakefile: Simplify config checks via target-specific variables.
* src/makeint.h: Use ATTRIBUTE rather than defining __attribute__,
as that causes compile issues with system headers.
(ENUM_BITFIELD): Don't use enum bitfields in ANSI mode.
* src/main.c: Use ATTRIBUTE instead of __attribute__.
* src/job.h: Ditto.
* src/file.c: Don't define variables inside for loops.
* src/rule.c: Ditto.
* src/dep.h (SI): Only use static inline in non-ANSI mode.
2020-01-04 13:23:23 -05:00
Paul Smith
06de697268 * bootstrap: Update to the latest gnulib version 2020-01-03 15:44:13 -05:00
Paul Smith
fdfe0446b6 Release GNU make 4.2.93
* NEWS: Update the release and date
* configure.ac: Update the release number
2020-01-03 02:08:59 -05:00
Paul Smith
12b14f0484 Update copyright statements for 2020 2020-01-03 02:08:59 -05:00
Paul Smith
4e12a5fa45 Support the .EXTRA_PREREQS special variable
Initial implementation by Christof Warlich <cwarlich@gmx.de>

* NEWS: Announce the new feature.
* doc/make.texi (Other Special Variables): Document .EXTRA_PREREQS.
* src/dep.h (struct dep): New flag to note extra prereq deps.
* src/filedef.h (expand_extra_prereqs): Declare a function to expand
the value of .EXTRA_PREREQS.
* src/file.c (expand_extra_prereqs): Given a struct variable lookup
of .EXTRA_PREREQS, convert it into a list of deps and for each one
make sure it has a struct file and has the new flag set.
(snap_file): A new function invoked by hash_map that will perform
per-file operations: set up second expansion, intermediate, and also
.EXTRA_PREREQS.  Manage circular dependencies by ignoring them.
(snap_deps): Defer per-file operations until the end.  Look up the
global .EXTRA_PREREQS and pass it along to snap_file for each file.
* src/implicit.c (struct patdeps): Remember the extra prereqs flag.
(pattern_search): Transfer extra prereqs flag settings into the
matched pattern rule.
* src/rule.h (snap_implicit_rules): Rename count_implicit_rules to
snap_implicit_rules since we now do more than count.
* src/rule.c (snap_implicit_rules): As we walk through all the pattern
rules, add in any global .EXTRA_PREREQS to the dep list.  Ensure we
take them into account for the max number of prereqs and name length.
* src/main.c (main): Add extra-prereqs to .FEATURES.
Call the renamed snap_implicit_rules.
* tests/scripts/variables/EXTRA_PREREQS: Add tests.
2020-01-03 02:08:59 -05:00
Paul Smith
e56243fe57 * tests/scripts/features/patternrules: Use Windows-compatible quoting 2020-01-03 02:08:59 -05:00
Paul Smith
7449abfe1b * tests/test_driver.pl: Compute full path to Perl interpreter 2020-01-03 02:08:59 -05:00
Paul Smith
53b9770b40 * tests/scripts/features/exec: Don't use $ENV in the description 2020-01-03 02:08:59 -05:00
Paul Smith
766baeef0a * src/makeint.h: Add a declaration for memrchr() 2020-01-03 02:08:59 -05:00
Paul Smith
ee204c78f2 * NEWS: Remove info about disabled /proc/loadavg usage. 2019-12-27 01:42:25 -05:00
Paul Smith
e64674b718 [SV 57022] Avoid posix_spawn which fails asynchronously
Avoid using posix_spawn implementations that fail asynchronously when
the spawned program can't be invoked: this means instead of getting
an error such as "No such file or directory" we get just "Exit 127".

Original implementation of the configure.ac macro provided by
Martin Dorey <martin.dorey@hds.com>

Original implementation of the regression tests provided by
Dmitry Goncharov <dgoncharov@users.sf.net>

* configure.ac: Test whether posix_spawn fails asynchronously.  In a
cross-compilation environment, assume that it does not.  If we detect
that it does, fall back to fork/exec.
* tests/scripts/features/exec: Add regression tests for different
shebang invocation methods.
2019-12-27 01:37:17 -05:00
Paul Smith
564fb212a7 [SV 56655] Allow pattern expansion to contain spaces
* src/dep.h: Add a new flag PARSEFS_ONEWORD
* src/read.c (parse_file_seq): If PARSEFS_ONEWORD is given, treat the
entire incoming string as a single pattern.
* src/implicit.c (pattern_search): Pass PARSEFS_ONEWORD when parsing
patterns for wildcards.
* tests/scripts/features/patternrules: Add a new test.
2019-12-26 18:39:56 -05:00
Ben Wijen
30cc10093b * src/misc.c (spin): On WINDOWS32 use Sleep() instead of sleep() 2019-12-18 09:05:40 -05:00