]> git.ipfire.org Git - thirdparty/make.git/log
thirdparty/make.git
19 months ago[SV 65006] Allow secondary expansion of .EXTRA_PREREQS
Dmitry Goncharov [Sat, 6 Jan 2024 22:39:43 +0000 (17:39 -0500)] 
[SV 65006] Allow secondary expansion of .EXTRA_PREREQS

* src/rule.c (snap_implicit_rules): Set need_2nd_expansion of each
  prerequisite of global .EXTRA_PREREQS.
* src/file.c (snap_file):  Set need_2nd_expansion of each prerequisite
  of target-specific .EXTRA_PREREQS.
* tests/scripts/variables/EXTRA_PREREQS: Add tests.

Reported by Daniel Gerber <dg@atufi.org>.

19 months ago* src/function.c (func_let): Don't edit nonexistent values
Jouke Witteveen [Tue, 2 Jan 2024 00:27:44 +0000 (19:27 -0500)] 
* src/function.c (func_let): Don't edit nonexistent values

* tests/scripts/functions/let: Test trailing whitespace in value list.

19 months ago* doc/make.texi (Text Functions): [SV 64818] Remove redundant text
Paul Smith [Sun, 3 Dec 2023 23:28:25 +0000 (18:28 -0500)] 
* doc/make.texi (Text Functions): [SV 64818] Remove redundant text

19 months ago* .clangd: Add configuration for the clangd LSP server
Paul Smith [Sun, 3 Dec 2023 23:00:01 +0000 (18:00 -0500)] 
* .clangd: Add configuration for the clangd LSP server

20 months ago* doc/make.texi: [SV 64924] Add missing parenthesis
Paul Smith [Mon, 27 Nov 2023 04:21:55 +0000 (23:21 -0500)] 
* doc/make.texi: [SV 64924] Add missing parenthesis

20 months ago* doc/make.texi: Add a quick reference appendix
Paul Smith [Mon, 27 Nov 2023 04:21:06 +0000 (23:21 -0500)] 
* doc/make.texi: Add a quick reference appendix

20 months ago* src/function.c (function_table_entry): Sort
Paul Smith [Mon, 27 Nov 2023 04:20:22 +0000 (23:20 -0500)] 
* src/function.c (function_table_entry): Sort

23 months agomake.texi: Cleanup
Paul Smith [Tue, 29 Aug 2023 18:24:33 +0000 (14:24 -0400)] 
make.texi: Cleanup

23 months agomake.texi: Add an appendix with troubleshooting tips
Paul Smith [Fri, 25 Aug 2023 15:10:34 +0000 (11:10 -0400)] 
make.texi: Add an appendix with troubleshooting tips

23 months agodoc/make.texi: Clean up references to GNU Make
Paul Smith [Tue, 29 Aug 2023 19:20:31 +0000 (15:20 -0400)] 
doc/make.texi: Clean up references to GNU Make

23 months agodoc/make.texi: Remove unnecessary @node arguments
Paul Smith [Tue, 29 Aug 2023 18:44:50 +0000 (14:44 -0400)] 
doc/make.texi: Remove unnecessary @node arguments

23 months agobootstrap.conf: Update to the latest gnulib stable branch
Paul Smith [Fri, 25 Aug 2023 15:10:14 +0000 (11:10 -0400)] 
bootstrap.conf: Update to the latest gnulib stable branch

2 years ago* AUTHORS: Updates
Paul Smith [Tue, 4 Jul 2023 18:19:37 +0000 (14:19 -0400)] 
* AUTHORS: Updates

2 years agoFix GCC compile warning for "bad-function-cast" on Windows
Torbjörn SVENSSON [Fri, 9 Jun 2023 19:00:32 +0000 (21:00 +0200)] 
Fix GCC compile warning for "bad-function-cast" on Windows

Trick the compiler by hiding the cast in a function call.

* src/os.h: Declare the new function.
* src/w32/w32os.c (get_handle_for_fd): Convert and cast a file
descriptor into a Windows HANDLE.
(check_io_state): Call the new function rather than casting.
(osync_release): Ditto.
(fd_inherit): Ditto.
(fd_noinherit): Ditto.
* src/function.c (windows32_openpipe): Ditto.
* src/w32/compat/posixfcn.c (isatty): Ditto.
* src/w32/subproc/sub_proc.c (process_easy): Ditto.

2 years agoFix GCC compile warning for "format-signedness" in Windows
Torbjörn SVENSSON [Fri, 9 Jun 2023 19:00:31 +0000 (21:00 +0200)] 
Fix GCC compile warning for "format-signedness" in Windows

* src/job.c (reap_children): Use unsigned int for DWORD.
* src/w32/subproc/sub_proc.c (process_easy): Ditto.
* src/w32/w32os.c (jobserver_setup): Ditto.
(jobserver_release): Ditto.
(jobserver_acquire): Ditto.

2 years ago* src/w32/compat/posixfcn.c (ttyname): Avoid const char*
Torbjörn SVENSSON [Fri, 9 Jun 2023 14:09:54 +0000 (16:09 +0200)] 
* src/w32/compat/posixfcn.c (ttyname): Avoid const char*

2 years agoFix GCC compile warning for "unused-parameter" on Windows
Torbjörn SVENSSON [Fri, 9 Jun 2023 14:09:55 +0000 (16:09 +0200)] 
Fix GCC compile warning for "unused-parameter" on Windows

* src/w32/compat/posixfcn.c (isatty): Avoid unused-parameter warnings.
(jobserver_pre_child): Ditto.
(jobserver_post_child): Ditto.
(jobserver_acquire): Ditto.
(fd_set_append): Ditto.

2 years agoFix GCC compile warning format-security on Windows
Torbjörn SVENSSON [Fri, 9 Jun 2023 14:09:53 +0000 (16:09 +0200)] 
Fix GCC compile warning format-security on Windows

* src/job.c (create_batch_file): Avoid non-static format strings.
* src/main.c (handle_runtime_exceptions): Ditto.
* src/w32/subproc/w32err.c (map_windows32_error_to_string): Ditto.

2 years agoFix GCC compile warning declaration-after-statement on Windows
Torbjörn SVENSSON [Fri, 9 Jun 2023 14:09:52 +0000 (16:09 +0200)] 
Fix GCC compile warning declaration-after-statement on Windows

* src/w32/w32os.c (check_io_state): Move the HANDLE declarations.

2 years agoAdd a UTF-8 resource when building for Windows
Costas Argyris [Mon, 19 Jun 2023 13:51:13 +0000 (09:51 -0400)] 
Add a UTF-8 resource when building for Windows

If a resource compiler is available, use it to add a UTF-8 resource
to the GNU Make executable on Windows.  As a result, GNU Make will
use UTF-8 as its ANSI code page, enabling it to work with UTF-8
encoded Makefiles, understand UTF-8 paths passed to it, etc.

These build process changes apply to all 3 ways that GNU Make can
be built for Windows:

1) configure
2) Basic.mk
3) build_w32.bat

When building with Visual Studio the resource compiler should always
be available.

When building with GCC or TCC, it depends on the availability of
'windres'.

If a resource compiler is not available, don't fail the build but
just proceed without the UTF-8 resource, effectively ignoring this
feature.

The UTF-8 resource only has an effect when GNU Make is running on a
minimum target version of Windows Version 1903 (May 2019 Update).
When the built GNU Make is running on an earlier version of Windows,
the embedded UTF-8 resource has no effect.

Code page information is added to --version output to tell users what
code pages are being used by any combination of GNU Make build (with
or without the UTF-8 resource) and Windows version that GNU Make is
running on (earlier than 1903 or not).

* README.git: Fix a typo.
* configure.ac: Search for windres and set WINDRES / HAVE_WINDRES.
* Makefile.am: Add manifest and resource files to EXTRA_DIST and
add a windres invocation to build them.
* build_w32.bat: Add support to build resource files.
* src/main.c (print_version): Add codepage info to Windows output.
* src/w32/utf8.manifest: Add a windres manifest file.
* src/w32/utf8.rc: Add a windres resource file.
* Basic.mk.template: Add support for building resource files.
* mk/Windows32.mk: Support windres resource files.
* .gitignore: Ignore TCC output directories.

2 years ago[SV 64124] Avoid stack overflows for large command lines
Paul Smith [Mon, 19 Jun 2023 14:00:11 +0000 (10:00 -0400)] 
[SV 64124] Avoid stack overflows for large command lines

Modify areas dealing with large command lines to use the heap rather
than relying on alloca / stack space.

* src/main.c (main): Allocate potentially large buffers with xmalloc.
(decode_env_switches): Ditto.
* src/function.c (func_error): Replace alloca with xmalloc/free.
* tests/scripts/features/expand: Add a newline for readable diffs.

2 years ago* po/LINGUAS: Add support for Georgian translation
Paul Smith [Mon, 19 Jun 2023 14:04:25 +0000 (10:04 -0400)] 
* po/LINGUAS: Add support for Georgian translation

2 years ago* NEWS: Set a prerelease version
Paul Smith [Mon, 19 Jun 2023 14:04:47 +0000 (10:04 -0400)] 
* NEWS: Set a prerelease version

2 years ago[SV 64815] Recipe lines cannot contain conditional statements
Paul Smith [Tue, 23 May 2023 03:36:13 +0000 (23:36 -0400)] 
[SV 64815] Recipe lines cannot contain conditional statements

* NEWS: Mention this change.
* src/read.c (eval): Check for ignoring for any line even if not
in a rule context.
* tests/scripts/features/conditionals: Write new tests.

2 years agomake -p now uses consistent timestamp format
Paul Eggert [Wed, 10 May 2023 19:10:16 +0000 (12:10 -0700)] 
make -p now uses consistent timestamp format

* NEWS: mention this.
* src/main.c (safer_ctime, time_now): Remove.
(print_data_base): Use file_timestamp_sprintf to format timestamps.

2 years agomake -p buffer overrun fix with outlandish current time
Paul Eggert [Wed, 10 May 2023 19:10:14 +0000 (12:10 -0700)] 
make -p buffer overrun fix with outlandish current time

* src/main.c (safer_ctime): New function.
(print_data_base): Use it.

2 years agomake -p uses same clock as rest of 'make'
Paul Eggert [Wed, 10 May 2023 19:10:15 +0000 (12:10 -0700)] 
make -p uses same clock as rest of 'make'

Without this patch, the output of 'make -p' would generate output that
sometimes incorrectly implied that the clock jumped backwards.
* src/main.c (time_now): New function.
(print_data_base): Use it.

2 years ago[SV 63219] Support an "unload" function for loaded objects
Paul Smith [Sun, 7 May 2023 20:51:12 +0000 (16:51 -0400)] 
[SV 63219] Support an "unload" function for loaded objects

If a loaded object defines a symbol <object>_gmk_unload, assume it's
a function and invoke it whenever the loaded object is unloaded.
Original implementation by Dmitry Goncharov <dgoncharov@users.sf.net>

* NEWS: Announce the change.
* doc/make.texi: Describe the behavior.
* src/gnumake.h: Add information to the comments.
* src/makeint.h (unload_all): Declare a new function.
* src/main.c (die): Invoke unload_all().
* src/load.c (unload_func_t): Declare a new type for unload.
(struct load_list): Remember the unload symbol if it exists.
(load_object): Move the parsing of the object name from load_file.
Check for the _gmk_unload symbol and if found, remember it.
(load_file): Allow load_object to do object filename parsing.
(unload_file): Remove the load_list entry when unloading the object.
(unload_all): Unload all the loaded objects.
* tests/scripts/features/loadapi: Test the unload function.

2 years agoRemove the "preview" status from the loaded object feature
Paul Smith [Sat, 6 May 2023 20:21:39 +0000 (16:21 -0400)] 
Remove the "preview" status from the loaded object feature

Add an ABI version both to the header file and passed to the setup
function.  Unfortunately this itself is an ABI break and I couldn't
find a good way to avoid it.

* NEWS: Announce the ABI is not a preview and the incompatibility.
* doc/make.texi: Remove the preview warnings for object loading.
Document the new ABI version argument.
* src/gnumake.h (GMK_ABI_VERSION): Set the ABI version to 1.
Add comments documenting the format of the setup function.
* src/load.c (setup_func_t): Rename from load_func_t.
(load_file): Pass the ABI version to the setup function.
* tests/scripts/features/load: Rework the setup function.
* tests/scripts/features/loadapi: Ditto.

2 years ago* src/read.c (eval): [SV 40942] Allow targets named "load"
Paul Smith [Sat, 6 May 2023 20:12:11 +0000 (16:12 -0400)] 
* src/read.c (eval): [SV 40942] Allow targets named "load"

Previously "load:" worked but "load :" failed.  Allow the latter as
well.  This doesn't fix all issues; "load foo :" is still treated
as a load operation for "foo" and ":".  Avoids SV 50413 as well.
* tests/scripts/features/load: Write tests.

2 years ago* tests/test_driver.pl: Show info about failed tests
Paul Smith [Sat, 6 May 2023 18:45:56 +0000 (14:45 -0400)] 
* tests/test_driver.pl: Show info about failed tests

Remove working directories for skipped tests.
We use different directories per test so don't keep rmfiles.

2 years ago* tests/scripts/features/comments: Add missing "1;"
Paul Smith [Sat, 6 May 2023 18:45:09 +0000 (14:45 -0400)] 
* tests/scripts/features/comments: Add missing "1;"

2 years ago[SV 64124] Avoid use-after-free in expand_variable_buf()
Dmitry Goncharov [Sun, 30 Apr 2023 13:39:04 +0000 (09:39 -0400)] 
[SV 64124] Avoid use-after-free in expand_variable_buf()

When the expanded value of the variable in buf occupies more space
than available in variable_buffer, function variable_buffer_output
reallocates variable_buffer: return a pointer into the new memory,
not the old memory.

* src/expand.c (expand_variable_buf): Preserve the offset of buf and
return that offset into the (potentially reallocated) buffer.
* tests/scripts/features/expand: Add tests.

2 years ago[SV 64115] Suppress warnings about undefined GNUMAKEFLAGS
Dmitry Goncharov [Sun, 30 Apr 2023 13:30:19 +0000 (09:30 -0400)] 
[SV 64115] Suppress warnings about undefined GNUMAKEFLAGS

* src/variable.c (defined_vars): Add GNUMAKEFLAGS to defined variables.
* tests/scripts/options/warn: Add a test.

2 years ago[SV 64107] Disable builtins immediately on -R or -r
Dmitry Goncharov [Sun, 30 Apr 2023 13:26:29 +0000 (09:26 -0400)] 
[SV 64107] Disable builtins immediately on -R or -r

Disable builtin variables and rules immediately, when -R or -r is
added to MAKEFLAGS inside the makefile.

* src/main.c (disable_builtins): Add new function disable_builtins().
(main): Call disable_builtins().
(reset_makeflags): Call disable_builtins().
* tests/scripts/options/dash-r: Add tests.
* tests/scripts/variables/MAKEFLAGS: Update tests.

2 years ago* tests/scripts/features/double_colon: Test parallel double-colon rules
Paul Smith [Sun, 30 Apr 2023 13:19:06 +0000 (09:19 -0400)] 
* tests/scripts/features/double_colon: Test parallel double-colon rules

Original test proposed by Dmitry Goncharov <dgoncharov@users.sf.net>

2 years ago* src/remake.c (update_goal_chain): [SV 64016] Avoid double negation
Dmitry Goncharov [Sun, 30 Apr 2023 13:07:17 +0000 (09:07 -0400)] 
* src/remake.c (update_goal_chain): [SV 64016] Avoid double negation

2 years ago* NEWS: Note the change to the tests suite
Paul Smith [Sun, 23 Apr 2023 15:35:02 +0000 (11:35 -0400)] 
* NEWS: Note the change to the tests suite

2 years ago* src/warnings.c (decode_warn_actions): [SV 63990] Handle errors
Paul Smith [Mon, 3 Apr 2023 11:58:46 +0000 (07:58 -0400)] 
* src/warnings.c (decode_warn_actions): [SV 63990] Handle errors

2 years agoMove local headers after system headers
Paul Smith [Mon, 3 Apr 2023 11:48:51 +0000 (07:48 -0400)] 
Move local headers after system headers

Avoid compiler warnings on Windows by moving local headers after
system headers.

* src/job.c: Move all headers other than makeint.h.
* src/main.c: Ditto.
* src/read.c: Ditto.

2 years agotests: Run each file in a separate directory
Paul Smith [Sun, 2 Apr 2023 21:32:09 +0000 (17:32 -0400)] 
tests: Run each file in a separate directory

Avoid cross-contamination between test files by creating a new
working directory for each file, and setting it as the current
directory before starting the tests in that file.

Rename the test output as tNNN.{base,log,diff,mk} where NNN is
a test number starting with 001 for the first test.  It is
slightly more annoying to find diff files since you can't use
autocomplete directly but it is simpler to match things.

Detect the source directory as the location of the test_driver.pl
script, so remove the separate -srcdir option.

* Makefile.am: Remove hacks to create symlinks when building
out-of-tree, and remove -srcdir option from run_make_tests.
* tests/test_driver.pl: Locate $srcpath based on __FILE__, then
compute $toppath as its parent.  Set $scriptpath under $srcpath
and $workpath under the current directory.  Toss $*_filename
and modify get_logfile() etc. to use the suffix directly.  Add
a chdir() around the invocation of the test.
* tests/run_make_tests.pl: Throw out the -srcdir option and use
$srcpath set in test_driver.pl.  The #WORK# helper is no longer
useful so remove it.  Set #PWD# to the current working dir. Always
search the local directory and $srcpath for config-flags.pm.
Use $srcpath for finding the thelp.pl script.
* tests/scripts/features/vpath: Don't put things in work/ as it
is no longer a subdirectory.
* tests/scripts/features/vpathgpath: Ditto.
* tests/scripts/features/vpathplus: Ditto.
* tests/scripts/misc/general1: Ditto.
* tests/scripts/misc/general2: Ditto.
* tests/scripts/options/dash-k: Ditto.
* tests/scripts/options/symlinks: Use $testpath as the working
directory.
* tests/scripts/variables/GNUMAKEFLAGS: Use the test helper to
display env var values (grepping for GNUMAKEFLAGS finds extra things
now that it is our current working directory).

2 years ago* tests/scripts/targets/WAIT: Add whitespace to avoid W32 issues
Paul Smith [Sun, 2 Apr 2023 21:30:27 +0000 (17:30 -0400)] 
* tests/scripts/targets/WAIT: Add whitespace to avoid W32 issues

On Windows systems, "X:" for any "X" is considered a drive letter
so add whitespace.

2 years ago[SV 63856] Fix pruning of double-colon rules
Dmitry Goncharov [Sun, 2 Apr 2023 15:04:26 +0000 (11:04 -0400)] 
[SV 63856] Fix pruning of double-colon rules

Given this setup:

  $ cat Makefile
  A::; @echo A-1 && sleep 1 && echo A-1 done
  A::; @echo A-2 && sleep 1 && echo A-2 done
  A::; @echo A-3 && sleep 1 && echo A-3 done
  B::; @echo B-1 && sleep 1 && echo B-1 done
  B::; @echo B-2 && sleep 1 && echo B-2 done
  B::; @echo B-3 && sleep 1 && echo B-3 done

  $ make -j8 A .WAIT B

All recipes for A should be started sequentially and complete before
any recipe for B is started, then all recipes for B should be started
sequentially.  This wasn't happening because the double-colon target
was getting pruned too early.

* src/remake.c (update_file): Don't prune a target if it's a double
colon rule which is complete, but there are other recipes to run for
this target: we want those other recipes to be run first.
* tests/scripts/targets/WAIT: Test .WAIT with double colon rules.

2 years ago[SV 63856] Implement .WAIT on the command line
Dmitry Goncharov [Sun, 2 Apr 2023 14:50:17 +0000 (10:50 -0400)] 
[SV 63856] Implement .WAIT on the command line

* src/main.c (handle_non_switch_argument): Return 1 if arg is .WAIT.
(decode_switches): Set wait_here for a goal that follows .WAIT.
* src/remake.c (update_goal_chain): Honor wait_here for a command
line goal.  Don't allow double-colon targets to continue if .WAIT is
given for one of them.
* tests/scripts/targets/WAIT: Add .WAIT tests.

2 years ago[SV 63981] Don't warn on explicit -j1
Paul Smith [Sun, 2 Apr 2023 14:29:37 +0000 (10:29 -0400)] 
[SV 63981] Don't warn on explicit -j1

If -j1 is given explicitly on the command line don't warn about it.

* src/main.c (main): Skip the warning if -j1.
* tests/scripts/features/jobserver: Add a test for this behavior.

2 years ago* NEWS: Mention the new .WARNINGS variable
Paul Smith [Sun, 2 Apr 2023 14:29:19 +0000 (10:29 -0400)] 
* NEWS: Mention the new .WARNINGS variable

2 years ago* doc/make.texi: Clean up function and variable references
Paul Smith [Sun, 2 Apr 2023 14:01:04 +0000 (10:01 -0400)] 
* doc/make.texi: Clean up function and variable references

Avoid unnecessary extra remarks in the index and remove duplicates.

2 years agoAdjust output strings to be aligned
Paul Smith [Sat, 1 Apr 2023 19:57:04 +0000 (15:57 -0400)] 
Adjust output strings to be aligned

Change error and fatal messages to start with lowercase and not
end with a period.  Note a few very common messages were left
as-is, just in case some other tools parse them.

Also modify the test known-good-output to satisfy the messages.

2 years agoAdd support for .WARNINGS special variable
Paul Smith [Sat, 18 Mar 2023 21:24:45 +0000 (17:24 -0400)] 
Add support for .WARNINGS special variable

Create a new special variable, .WARNINGS, to allow per-makefile
control over warnings.  The command line settings will override
this.

Move the handling of warning flags to a new file: src/warning.c.
Allow the decode to work with generic strings, and call it from
decode_switches().

* Makefile.am: Add new file src/warning.c.
* build_w32.bat: Ditto.
* builddos.bat: Ditto.
* po/POTFILES.in: Ditto.
* src/makeint.h: #define for the .WARNINGS variable name.
* src/warning.h: Add declarations for methods moved from main.c.
Rename the enum warning_state to warning_action.
* src/warning.c: New file.  Move all warning encode/decode here
from main.c.
* src/main.c: Move methods into warning.c and call those methods
instead.
(main): Set .WARNINGS as a special variable.
* src/job.c (construct_command_argv): Rename to warning_action.
* src/read.c (tilde_expand): Ditto.
* src/variable.c (set_special_var): Update warnings when the
.WARNINGS special variable is set.
* tests/scripts/options/warn: Check invalid warning options.
* tests/scripts/variables/WARNINGS: Add tests for the .WARNINGS
special variable.

2 years agoAdd new warnings invalid-var and invalid-ref
Paul Smith [Sun, 26 Feb 2023 23:24:30 +0000 (18:24 -0500)] 
Add new warnings invalid-var and invalid-ref

The "invalid-var" warning triggers if the makefile attempts to assign
a value to an invalid variable name (a name containing whitespace).
The "invalid-ref" warning triggers if the makefile attempts to
reference an invalid variable name.  Both new warnings have a default
action of "warn".

* NEWS: Add these new warnings.
* doc/make.1: Document them in the man page.
* doc/make.texi (Warnings): Document them in the user's manual.
* src/warning.h: Add enum values for the new warning types.
* src/main.c (initialize_warnings): Initialize the new warnings.
* src/variable.h (undefine_variable_in_set, undefine_variable_global):
Ask callers to provide a struct floc specifying where the variable
is undefined.
* src/read.c (do_undefine): Pass floc when undefining.
* src/variable.c (check_valid_name): If invalid-var is enabled, check
the variable name.
(define_variable_in_set): Call it.
(undefine_variable_in_set): Ditto.
(check_variable_reference): If invalid-ref is enabled, check the
variable reference.
(lookup_variable): Call it.
(lookup_variable_in_set): Ditto.
* tests/scripts/options/warn: Add tests for the new warning types.

2 years agoIntroduce a --warn command line option
Paul Smith [Sun, 26 Feb 2023 23:04:14 +0000 (18:04 -0500)] 
Introduce a --warn command line option

Replace the singleton --warn-undefined-variables with infrastructure
to manage multiple warnings: the --warn option can take an action
"ignore", "warn", or "error" (which will apply to all warnings), or
a specific warning type and an action for that type.  Multiple
options can be provided and are consolidated.

* NEWS: Announce the new option.
* doc/make.1: Document in the man page.
* doc/make.texi (Warnings): Document in the user's manual.
* Makefile.am: Add new header warning.h.
* src/warning.h: Define enum for actions and warning types, and
macros to test whether they are set.  Keep the default settings
separate so that we can correctly reconstruct MAKEFLAGS.
* src/makeint.h: Remove deprecated warn_undefined_variables_flag.
* src/main.c: Create global variables to hold warning settings.
(switches): Add a new switch for --warn.
(initialize_warnings): Set the default warning actions.
(main): Call initialize_warnings().
(encode_warning_state, decode_warning_state): Convert warning states
between strings and enums.
(encode_warning_name, decode_warning_name): Convert warning names
between strings and enums.
(decode_warn_flags): Convert a --warn option into enum values.  If
deprecated warn_undefined_variables_flag is set convert it to --warn.
(decode_switches): Don't remove duplicates of --warn since order
matters.  Call decode_warn_flags() to handle --warn.
(define_makeflags): Special-case handling of --warn options written
to MAKEFLAGS: write out the current settings.
* src/read.c (tilde_expand): Use new warning control macros.
* src/variable.c (warn_undefined): Ditto.
* src/job.c (construct_command_argv): Ditto.
* tests/scripts/options/warn: Rename from warn-undefined-variables
and add tests for --warn.
* tests/scripts/variables/MAKEFLAGS: Expect the new behavior.

2 years agoClean up memory leak warnings from ASAN and Valgrind
Paul Smith [Sun, 26 Mar 2023 19:35:00 +0000 (15:35 -0400)] 
Clean up memory leak warnings from ASAN and Valgrind

* src/main.c (main): Add "sanitize" to .FEATURES if ASAN is enabled.
* src/expand.c (expand_variable_output): Remember "recursive" setting
in case it's changed by the expansion of the variable.
* src/file.c (rehash_file): If we drop a file from the global 'files'
hash, remember it in rehashed_files.  We can't free it because it's
still being referenced (callers will invoke check_renamed()) but
it will be a leak since it's no longer referenced by 'files'.
* src/remake.c (update_file_1): If we drop a dependency, remember it
in dropped_list.  We can't free it because it's still being referenced
by callers but it will be a leak since it's no longer referenced as
a prerequisite.
* tests/scripts/functions/guile: Don't run Guile tests when ASAN is
enabled.
* tests/scripts/functions/wildcard: Enabling ASAN causes glob(3) to
break!  Don't run this test.
* tests/scripts/features/exec: Valgrind's exec() doesn't support
scripts with no shbang.
* tests/scripts/jobserver: Valgrind fails if TMPDIR is set to an
invalid directory: skip those tests.
* tests/scripts/features/output-sync: Ditto.
* tests/scripts/features/temp_stdin: Ditto.

2 years agoCreate helper functions for pushing file contexts
Paul Smith [Sun, 26 Mar 2023 21:29:50 +0000 (17:29 -0400)] 
Create helper functions for pushing file contexts

* src/variable.h (install_file_context, restore_file_context): Add
declarations for new functions.
* src/variable.c (install_file_context, restore_file_context): Define
the new functions.
(lookup_variable_for_file): Call them.
* src/expand.c (recursively_expand_for_file): Ditto.
(allocated_expand_variable_for_file): Ditto.
(expand_string_for_file): Ditto.

2 years agoAdd functions to directly expand variables by name
Paul Smith [Sat, 25 Mar 2023 23:15:20 +0000 (19:15 -0400)] 
Add functions to directly expand variables by name

Replace all locally-created "$("+varname+")" and similar constructs
with calls to these new functions.

* src/expand.c (expand_variable_output): Call expand_string_output()
on the expansion of a variable value.  Replaces reference_variable().
(expand_variable_buf): Like expand_variable_output() but return the
starting location of the result.
(allocated_expand_variable): Like expand_variable_buf() but return
an allocated string.
(expand_string_buf): Call expand_variable_output().
* src/variable.h: Declare the new functions.
* src/function.c (func_call): Call expand_variable_output() instead
of expand_string_buf().
* src/main.c (decode_env_switches): Call expand_variable() instead
of expand_string().
* src/remake.c (library_search): Call allocated_expand_variable()
instead of expand_string() plus xstrdup().
* src/vpath.c (build_vpath_lists): Expand VPATH and GPATH using
expand_variable() instead of expand_string().
* src/w32/subproc/sub_proc.c (process_begin): Use expand_variable()
to expand SHELL.  Also use alloc() in case the result is larger than
PATH_MAX.

2 years agoClean up expand.c
Paul Smith [Sat, 25 Mar 2023 21:53:19 +0000 (17:53 -0400)] 
Clean up expand.c

Clarify the naming and documentation on functions in src/expand.c:
- variable_expand -> expand_string
- variable_expand_string -> expand_string_buf
- variable_expand_for_file -> expand_string_for_file
- allocated_variable_expand -> allocated_expand_string
- allocated_variable_expand_for_file ->
  allocated_expand_string_for_file
Change all callers to use the new names.

* src/variable.h: Rename the functions and macros.
* src/expand.c: Ditto.
* src/file.c: Use the new function names.
* src/function.c: Ditto.
* src/implicit.c: Ditto.
* src/job.c: Ditto.
* src/loadapi.c: Ditto.
* src/main.c: Ditto.
* src/read.c: Ditto.
* src/remake.c: Ditto.
* src/variable.c: Ditto.
* src/vpath.c: Ditto.
* src/w32/subproc/sub_proc.c: Ditto.

2 years ago* src/expand.c (swap_variable_buffer): Swap two variable buffers
Paul Smith [Sat, 25 Mar 2023 20:25:32 +0000 (16:25 -0400)] 
* src/expand.c (swap_variable_buffer): Swap two variable buffers

Return the current buffer instead of freeing it.
(variable_append): Use install/swap to handle variable buffers.
(allocated_variable_expand_for_file): Ditto.
* src/variable.c (shell_result): Ditto.
* src/variable.h: Declare the new function.

2 years agoEnsure variable_buffer is always nul-terminated
Paul Smith [Sun, 26 Mar 2023 13:24:06 +0000 (09:24 -0400)] 
Ensure variable_buffer is always nul-terminated

* src/expand.c (variable_buffer_output): Allocate an extra byte and
set it to nul.  For safety, add assert() on PTR.
(variable_expand_string): Don't call variable_buffer_output just to
add a nul byte.
(allocated_variable_append): Ditto.

2 years ago[SV 63867] Don't use --sort to generate error report tar files
Paul Smith [Sun, 5 Mar 2023 14:09:46 +0000 (09:09 -0500)] 
[SV 63867] Don't use --sort to generate error report tar files

Older versions of GNU tar parse the TAR_OPTIONS variable, but do not
accept the --sort option: remove it before creating the error report
tar files.  Note we still require a modern GNU tar to create release
tar files.  Reported by Dmitry Goncharov <dgoncharov@users.sf.net>

* Makefile.am (check-regression): Remove --sort from TAR_OPTIONS

2 years agoDirectly handle $\ line endings
Paul Smith [Sun, 26 Feb 2023 22:30:15 +0000 (17:30 -0500)] 
Directly handle $\ line endings

Previously we used the fact that this line ending expanded to "$ "
which would then expand to the empty string.  This has problems if
you enable warnings for undefined variables, so directly implement
this special (but documented) trick in the GNU Make parser.

As a side-effect this also removes all previous whitespace when
in GNU Make mode (not in POSIX mode) just as it would without "$".

* src/misc.c (collapse_continuations): Check for "$\" and remove it.
* tests/scripts/variables/flavors: Add regression tests including
with previous whitespace, and escaped/unescaped "$"

2 years ago* src/main.c (define_makefiles): Simplify by using variable_buffer
Paul Smith [Sun, 26 Feb 2023 22:15:56 +0000 (17:15 -0500)] 
* src/main.c (define_makefiles): Simplify by using variable_buffer

Toss the previous implementation which first computed a locally
allocated list of options, then used alloca() to create a buffer
of the right size and populate it.  Instead, use variable_buffer
to append to the string directly.  First add all single-letter
options without arguments, then add options with arguments.

2 years agoClean up some preprocessor operations
Paul Smith [Mon, 16 Jan 2023 18:01:09 +0000 (13:01 -0500)] 
Clean up some preprocessor operations

2 years agoUse MK_OS_OS2 macro instead of __EMX__
Paul Smith [Mon, 16 Jan 2023 05:24:13 +0000 (00:24 -0500)] 
Use MK_OS_OS2 macro instead of __EMX__

* src/makeint.h: Set MK_OS_OS2 to 1 if __EMX__ is set.
* src/*: Convert #if refs to __EMX__, to use MK_OS_OS2.

2 years agoUse MK_OS_DOS macro instead of __MSDOS__
Paul Smith [Mon, 16 Jan 2023 05:03:13 +0000 (00:03 -0500)] 
Use MK_OS_DOS macro instead of __MSDOS__

* src/configh.dos: Set MK_OS_DOS to 1
* src/*: Convert #if refs to __MSDOS__, to use MK_OS_DOS.
* gl/lib/*: Ditto.

2 years agoRename WINDOWS32 macro to MK_OS_W32
Paul Smith [Sun, 15 Jan 2023 23:27:13 +0000 (18:27 -0500)] 
Rename WINDOWS32 macro to MK_OS_W32

* configure.ac: Set MK_OS_W32 to 1 if we're on Windows32.
* src/config.h.W32: Ditto.
* mk/Windows32.mk: Ditto.
* src/makeint.h: Convert #if refs to WINDOWS32, to use MK_OS_W32.
* src/*: Ditto.
* src/w32/*: Ditto.
* gl/lib/*: Ditto.

2 years agoRename VMS macro to MK_OS_VMS
Paul Smith [Sun, 15 Jan 2023 23:04:36 +0000 (18:04 -0500)] 
Rename VMS macro to MK_OS_VMS

* src/makeint.h: Set MK_OS_VMS to 1 if we're on VMS.
* src/*: Convert all #if references to VMS, to use MK_OS_VMS.
* gl/lib/*: Ditto.

2 years agoRemove support for AmigaOS
Paul Smith [Sun, 15 Jan 2023 22:32:15 +0000 (17:32 -0500)] 
Remove support for AmigaOS

There is a lot of specialized code for supporting AmigaOS and it has
not been maintained for a number of years.  It's highly unlikely that
the latest versions even compile properly on AmigaOS anymore.  After
requesting that someone step forward to own the maintenance of the
port in the GNU Make 4.4 release and getting no takers, I removed it.

* NEWS: Announce the removal.
* README.in: Remove README.Amiga reference.
* README.Amiga: Remove unused file.
* SCOPTIONS: Ditto.
* src/amiga.c: Ditto.
* src/amiga.h: Ditto.
* src/config.ami: Ditto.
* mk/Amiga.mk: Ditto.
* Makefile.am: Remove references to deleted files.
* Basic.mk.template: Ditto.
* maintMakefile: Ditto.
* src/commands.c: Remove ifdef'd Amiga code.
* src/default.c: Ditto.
* src/dir.c: Ditto.
* src/file.c: Ditto.
* src/function.c: Ditto.
* src/job.c: Ditto.
* src/job.h: Ditto.
* src/main.c: Ditto.
* src/os.h: Ditto.
* src/read.c: Ditto.
* src/remake.c: Ditto.

2 years ago* README.git: Clarify some release steps
Paul Smith [Sun, 26 Feb 2023 20:52:25 +0000 (15:52 -0500)] 
* README.git: Clarify some release steps

* README.in: Update some info and remove some obsolete notes.

2 years ago* NEWS: Update for the next release
Paul Smith [Sun, 26 Feb 2023 20:40:18 +0000 (15:40 -0500)] 
* NEWS: Update for the next release

* configure.ac: Set the version for the next release.

2 years agoGNU Make release 4.4.1 4.4.1
Paul Smith [Sun, 26 Feb 2023 16:01:43 +0000 (11:01 -0500)] 
GNU Make release 4.4.1

* NEWS: Set the release number and date.
* configure.ac: Update the version.
* README.git: Remind to update doc/make.1.
* doc/make.1: Update the date.  Fix some "GNU Make" references.
* doc/make.texi: Update the edition.

2 years ago* tests/scripts/options/dash-l: Simplify the test via the helper
Paul Smith [Sun, 26 Feb 2023 17:43:27 +0000 (12:43 -0500)] 
* tests/scripts/options/dash-l: Simplify the test via the helper

* tests/thelp.pl: Add "exist" and "noexist" operators.

2 years ago* README.W32: Add Windows 11
Paul Smith [Wed, 22 Feb 2023 01:53:11 +0000 (20:53 -0500)] 
* README.W32: Add Windows 11

* build_w32.bat: Ditto.

2 years agoUse a recursive environment if any command needs it
Paul Smith [Wed, 22 Feb 2023 01:32:12 +0000 (20:32 -0500)] 
Use a recursive environment if any command needs it

We only create one target environment for all commands in a recipe.
Ensure it's set for recursive make if ANY command is recursive, not
just the first one.

* src/job.c (start_job_command): Check for any recursive command.
* tests/scripts/features/jobserver: Test recursion on second line.

2 years ago* src/main.c (main): Install suffix rules near pattern updates
Dmitry Goncharov [Tue, 21 Feb 2023 05:04:13 +0000 (00:04 -0500)] 
* src/main.c (main): Install suffix rules near pattern updates

2 years ago* Makefile.am: Add mkconfig.h to the test error file
Paul Smith [Tue, 21 Feb 2023 04:29:26 +0000 (23:29 -0500)] 
* Makefile.am: Add mkconfig.h to the test error file

2 years ago[SV 63821] Don't set up default suffix rules if makefile sets -r
Dmitry Goncharov [Mon, 20 Feb 2023 20:17:24 +0000 (15:17 -0500)] 
[SV 63821] Don't set up default suffix rules if makefile sets -r

When built-in rules are disabled by adding -r to MAKEFLAGS in the
makefile, don't add suffix rules at all so that if suffixes are
added back via .SUFFIXES, the rules are still not there.

* src/main.c (main): Set default suffix rules after parsing makefiles.
* src/default.c (install_default_suffix_rules): Install a default
suffix rule only if there is no user defined rule.
* tests/scripts/features/suffixrules: Add tests.

2 years ago* tests/scripts/misc/general4: Only test empty PATH on UNIX
Paul Smith [Mon, 20 Feb 2023 16:11:59 +0000 (11:11 -0500)] 
* tests/scripts/misc/general4: Only test empty PATH on UNIX

2 years ago* gl/modules/make-glob: Avoid glibc glob if bug #866 is present
Paul Smith [Sun, 19 Feb 2023 22:43:12 +0000 (17:43 -0500)] 
* gl/modules/make-glob: Avoid glibc glob if bug #866 is present

2 years ago* tests/scripts/features/include [AIX]: Set explicit timestamps
Paul Smith [Sun, 19 Feb 2023 20:35:22 +0000 (15:35 -0500)] 
* tests/scripts/features/include [AIX]: Set explicit timestamps

2 years ago* tests/scripts/features/archives: Set CC properly
Paul Smith [Sun, 19 Feb 2023 19:49:56 +0000 (14:49 -0500)] 
* tests/scripts/features/archives: Set CC properly

2 years agoPrerelease GNU Make 4.4.0.91 4.4.0.91
Paul Smith [Sun, 19 Feb 2023 14:53:26 +0000 (09:53 -0500)] 
Prerelease GNU Make 4.4.0.91

* NEWS: Update the date.
* configure.ac: Change the release.

2 years ago* src/makeint.h [CYGWIN]: Use pipe mode for the jobserver
Paul Smith [Sun, 19 Feb 2023 13:52:02 +0000 (08:52 -0500)] 
* src/makeint.h [CYGWIN]: Use pipe mode for the jobserver

2 years agoDon't block for child exit if other commands have completed
Paul Smith [Sun, 19 Feb 2023 05:40:48 +0000 (00:40 -0500)] 
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.

2 years agoClean up depth handling in debug output
Paul Smith [Sat, 18 Feb 2023 21:08:51 +0000 (16:08 -0500)] 
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.

2 years ago* src/makeint.h (WIN32_LEAN_AND_MEAN) [Windows]: Don't redefine.
Paul Smith [Sat, 18 Feb 2023 18:48:27 +0000 (13:48 -0500)] 
* src/makeint.h (WIN32_LEAN_AND_MEAN) [Windows]: Don't redefine.

Suggested for tcc builds by Christian Jullien <eligis@orange.fr>.

2 years ago* src/misc.c (ttyname) [OS/2]: Add an implementation for OS/2 kLIBC
KO Myung-Hun [Sat, 18 Feb 2023 18:43:16 +0000 (13:43 -0500)] 
* src/misc.c (ttyname) [OS/2]: Add an implementation for OS/2 kLIBC

2 years agoAllow jobserver style to be forced to "pipe"
Paul Smith [Sat, 18 Feb 2023 18:20:00 +0000 (13:20 -0500)] 
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.

2 years ago[SV 63668] Use autoconf to detect the default C++ compiler
Paul Smith [Sun, 5 Feb 2023 15:22:13 +0000 (10:22 -0500)] 
[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.

2 years ago* doc/make.texi: Fix typo (reported by <mao492479407@163.com>)
Paul Smith [Sun, 5 Feb 2023 14:42:49 +0000 (09:42 -0500)] 
* doc/make.texi: Fix typo (reported by <mao492479407@163.com>)

2 years ago* tests/scripts/variables/MAKEFLAGS: Fix some Perl warnings
Paul Smith [Sat, 4 Feb 2023 18:12:32 +0000 (13:12 -0500)] 
* tests/scripts/variables/MAKEFLAGS: Fix some Perl warnings

2 years ago* doc/make.texi: [SV 63689] Fix typos in examples
Dmitry Goncharov [Sat, 28 Jan 2023 18:09:36 +0000 (13:09 -0500)] 
* doc/make.texi: [SV 63689] Fix typos in examples

2 years ago* src/job.c: Switch from bit operators to flags macros
Paul Smith [Sat, 28 Jan 2023 18:01:39 +0000 (13:01 -0500)] 
* src/job.c: Switch from bit operators to flags macros

* src/remake.c: Ditto.

2 years ago[SV 63667] In .POSIX, use shell flags -c when ignoring errors
Paul Smith [Sat, 28 Jan 2023 16:03:54 +0000 (11:03 -0500)] 
[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.

2 years ago* tests/scripts/features/archives: [SV 63688] Quote cmd line vars
Dmitry Goncharov [Sat, 28 Jan 2023 14:41:49 +0000 (09:41 -0500)] 
* tests/scripts/features/archives: [SV 63688] Quote cmd line vars

2 years ago* README.in: Mention README.z/OS
Paul Smith [Sat, 28 Jan 2023 14:28:18 +0000 (09:28 -0500)] 
* README.in: Mention README.z/OS

2 years ago* tests/test_driver.pl: Convert z/OS answers for regex output
Paul Smith [Sun, 15 Jan 2023 15:53:38 +0000 (10:53 -0500)] 
* 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.

2 years ago* tests/scripts/features/archives: Use the configured compiler for CC
Paul Smith [Sun, 15 Jan 2023 15:27:53 +0000 (10:27 -0500)] 
* tests/scripts/features/archives: Use the configured compiler for CC

2 years ago* configure.ac: Delay setting HAVE_GUILE until we're sure
Paul Smith [Sun, 15 Jan 2023 15:27:34 +0000 (10:27 -0500)] 
* configure.ac: Delay setting HAVE_GUILE until we're sure

2 years agoPrerelease GNU Make 4.4.0.90 4.4.0.90
Paul Smith [Sat, 14 Jan 2023 19:05:18 +0000 (14:05 -0500)] 
Prerelease GNU Make 4.4.0.90

* NEWS: Update the date.
* README.git: Fix a typo.
* maintMakefile (check-alt-config): Report success.
(upload-*): Use the gnulib gnupload script for uploads.

2 years ago* tests/scripts/features/reinvoke: Warn about closing STDIN.
Paul Smith [Thu, 12 Jan 2023 00:17:07 +0000 (19:17 -0500)] 
* tests/scripts/features/reinvoke: Warn about closing STDIN.

* tests/scripts/features/temp_stdin: Ditto.
* tests/scripts/options/dash-f: Ditto.

2 years ago[SV 63638] Fix processing PATH on MS-Windows
Eli Zaretskii [Wed, 11 Jan 2023 13:44:56 +0000 (15:44 +0200)] 
[SV 63638] Fix processing PATH on MS-Windows

* src/variable.c (sync_Path_environment): Pass only the value of
PATH to convert_Path_to_windows32, excluding the "PATH=" part.