]> git.ipfire.org Git - thirdparty/make.git/log
thirdparty/make.git
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.

2 years agoUpdate support for OS/2
Paul Smith [Sun, 8 Jan 2023 23:44:25 +0000 (18:44 -0500)] 
Update support for OS/2

Patches provided by KO Myung-Hun <komh78@gmail.com>

* NEWS: Add a note.
* AUTHORS: Add a new author.
* README.OS2: Updates to build instructions.
* src/dir.c (dir_contents_file_exists_p): Use a stack copy when
modifying a const string.
* src/job.c (construct_command_argv_internal): Ditto.
Reuse variables rather than re-defining them.
(exec_command): Cast a const string (we don't change it anyway).
* src/getopt.c (_getopt_initialize): Reference unused variables.
(_getopt_internal): Add block braces to quiet the compiler.
* src/main.c (main): Cast argument to child_execute_job().
* src/posixos.c (set_blocking): Reference unused variables.
* src/remake.c (f_mtime): Delete useless code.

2 years ago[SV 17448] Ignore whitespace around $(file ...) names
Paul Smith [Sun, 8 Jan 2023 23:06:54 +0000 (18:06 -0500)] 
[SV 17448] Ignore whitespace around $(file ...) names

The other issues related to whitespace reported in this bug are
not addressed by this change.

* src/functions.c (func_file): Strip whitespace from the start and
end of the filename provided to the $(file ...) function.
* tests/scripts/functions/file: Add tests for this.
* tests/test_driver.pl: Use 3-arg version of open().

2 years ago[SV 61218] Ensure MAKEFLAGS is expanded even with -e
Paul Smith [Sun, 8 Jan 2023 21:40:55 +0000 (16:40 -0500)] 
[SV 61218] Ensure MAKEFLAGS is expanded even with -e

If -e was given we weren't expanding MAKEFLAGS before passing it
through the environment to jobs: we don't expand variables we
receive from the environment and when -e is given we set the
origin of MAKEFLAGS to "environment override".  Check for MAKEFLAGS
specifically, which seems like a hack but I don't have a better
idea offhand.

* src/main.c (main): Drive-by: use o_default for MAKEOVERRIDES.
* src/variable.c (target_environment): Always expand MAKEFLAGS
regardless of the origin type.
* tests/scripts/options/dash-e: Create a test.

2 years ago[SV 62654] Support GNU Make on z/OS
Paul Smith [Sun, 8 Jan 2023 02:50:59 +0000 (21:50 -0500)] 
[SV 62654] Support GNU Make on z/OS

Original patches provided by Igor Todorovski <itodorov@ca.ibm.com>
Reworked by Paul Smith <psmith@gnu.org>.
Thanks to IBM for providing a test system.

* NEWS: Announce support.
* AUTHORS: Ditto.
* README.zOS: Provide details on building GNU Make on z/OS.
* build.sh (get_mk_var): z/OS sh has a strange bug which causes it to
generate extra lines of output: rework the function to print output
as we compute it instead of collecting it into a variable, which
works around this bug.
* src/makeint.h: Declare MK_OS_ZOS if we're building for z/OS.
* src/arscan.c: Don't include <ar.h> on z/OS.
* src/job.c: We can't change environ in ASCII mode on z/OS.
* src/main.c: Ditto.  Also we can't use pselect() on z/OS.
* src/posixos.c: pselect() seems to hang on z/OS: don't use it.
* tests/run_make_tests.pl: Handle different exit codes on z/OS.
* tests/test_driver.pl: Preserve some special z/OS env.vars.
Add special checks to output comparisons when on z/OS.
* tests/scripts/features/archives: Don't validate names.  Don't
try to compile empty files as IBM compilers complain.
* tests/scripts/features/shell_assignment: Fix octal value of #.
* tests/scripts/features/temp_stdin: Don't print "term".
* tests/scripts/functions/shell: Handle shell exit codes.
* tests/scripts/targets/ONESHELL: Ditto.
* tests/scripts/targets/POSIX: sh -x prints differently.
* tests/scripts/variables/SHELL: Ditto.

2 years agoCreate src/mkcustom.h which is included by config.h
Paul Smith [Sun, 8 Jan 2023 14:38:59 +0000 (09:38 -0500)] 
Create src/mkcustom.h which is included by config.h

Put declarations for missing functions which we create in src/misc.c
into a file which is included by config.h via AH_BOTTOM().  This
ensures those prototypes are available, even in files added to
lib/... from gnulib.

* src/mkcustom.h: Add a new file with function declarations.
* configure.ac: Include src/mkcustom.h in config.h with AH_BOTTOM()
* Makefile.am: Add the header to the SRCS list.
* src/makeint.h: Remove content that we added to src/mkcustom.h.
* src/config.ami: Add #include "mkcustom.h" to specialized config.h.
* src/config.h-vms: Ditto.
* src/config.h.W32: Ditto.
* src/configh.dos: Ditto.

2 years agoInclude <strings.h> globally
Paul Smith [Sun, 8 Jan 2023 02:59:16 +0000 (21:59 -0500)] 
Include <strings.h> globally

Various code uses str{,n}casecmp() so include <strings.h>, if it
exists, everywhere.

* configure.ac: Check for <strings.h> explicitly.
* src/makeint.h: Include it if HAVE_STRINGS_H, for str{,n}casecmp().
* src/job.c: Remove include of <strings.h>.
* src/main.c: Ditto.

2 years ago* gl/lib/glob.c: Don't try to support _LIBC, don't use __stat()
Paul Smith [Sun, 8 Jan 2023 03:01:19 +0000 (22:01 -0500)] 
* gl/lib/glob.c: Don't try to support _LIBC, don't use __stat()

2 years ago[SV 63609] Avoid buffer overrun in --warn-undefined-variables
Paul Smith [Tue, 3 Jan 2023 07:14:24 +0000 (02:14 -0500)] 
[SV 63609] Avoid buffer overrun in --warn-undefined-variables

Reported by Dmitry Goncharov <dgoncharov@users.sf.net>

* src/variable.c (struct defined_vars): Create a struct that holds the
name and length of each variable name.
(warn_undefined): Check the lengths before comparing the contents.
* tests/scripts/options/warn-undefined-variables: Add a test.

2 years ago[SV 14927] Allow parallel builds for archives
Paul Smith [Tue, 3 Jan 2023 06:57:35 +0000 (01:57 -0500)] 
[SV 14927] Allow parallel builds for archives

Compare the timestamp of the object file (if it exists) with the
archived object and if the object file is newer, ensure it's updated
in the archive.

* NEWS: Announce the new capability.
* doc/make.texi (Dangers When Using Archives): Explain how to enable
parallel builds with archives.
* src/remake.c (f_mtime): For archive element files check the mod
time of the object file (if it exists) against the archive object
(if it exists).
* tests/scripts/features/archives: Add tests for this capability.

2 years ago[SV 61463] Don't export inherited private variables
Paul Smith [Mon, 2 Jan 2023 16:23:09 +0000 (11:23 -0500)] 
[SV 61463] Don't export inherited private variables

If a parent target has an exported variable that is private, don't
export it in child targets.

* NEWS: Mention this change.
* src/variable.c (target_environment): Ignore private inherited
variables.
* tests/thelp.pl: Add a new "env" operation to show env.var. values.
* tests/scripts/variables/private: Verify this new behavior.

2 years agoUpdate ancient glob/fnmatch implementations
Paul Smith [Mon, 2 Jan 2023 05:52:32 +0000 (00:52 -0500)] 
Update ancient glob/fnmatch implementations

I looked again at trying to use the latest gnulib implemenentations
of GNU glob and fnmatch, and the effort required to extract them
from gnulib and make them portable to systems which don't support
configure is simply far too daunting for me.  However it's clear
that the previous implementations are growing too long on the tooth
to continue to be used without some maintenance, so perform some
upkeep on them.

- Remove support for pre-ANSI function definitions.
- Remove the obsolete "register" keyword.
- Assume standard ISO C90/C99 header file support.
- Assume standard ISO C "void" and "const" support.
- Avoid symbols prefixed with "__" as they're reserved.

* maintMakefile: Add a rule to verify lib has the latest content.
* src/dir.c: Use void* not __ptr_t which was removed.
* gl/lib/glob.c: See above.
* gl/lib/fnmatch.in.h: See above.
* gl/lib/glob.in.h: See above.
* gl/lib/fnmatch.c: See above.  Remove __strchrnul(): it is not
checked anywhere and is only used in one place anyway.

2 years ago* doc/make.texi (Special Targets): Fix minor typo
Paul Smith [Mon, 2 Jan 2023 05:13:28 +0000 (00:13 -0500)] 
* doc/make.texi (Special Targets): Fix minor typo

Reported by Andrey Melnikov <vafilor@gmail.com>.

2 years agoDon't free uninitialized hash_table
Paul Smith [Sun, 1 Jan 2023 14:44:59 +0000 (09:44 -0500)] 
Don't free uninitialized hash_table

* src/dir.c (clear_directory_contents): We use ht_vec to mark when
we have initialized the hash_table: don't free if it's NULL.
(everywhere): Use NULL instead of 0 when working with pointers.

2 years ago* maintMakefile: Add missing quote
Paul Smith [Sun, 1 Jan 2023 14:55:24 +0000 (09:55 -0500)] 
* maintMakefile: Add missing quote

2 years agoConvert references from "GNU make" to "GNU Make"
Paul Smith [Sun, 1 Jan 2023 21:25:39 +0000 (16:25 -0500)] 
Convert references from "GNU make" to "GNU Make"

2 years agoUpdate to the latest gnulib stable branch
Paul Smith [Sun, 1 Jan 2023 21:08:35 +0000 (16:08 -0500)] 
Update to the latest gnulib stable branch

* bootstrap.conf: Request the latest gnulib stable branch.
* README.git: Recommend the argument form of autogen/autopull.
* bootstrap: Import the latest version of bootstrap.
* bootstrap-funclib.sh: Ditto.
* autogen.sh: Ditto.
* autopull.sh: Ditto.

2 years agoUpdate the copyright year on all files
Paul Smith [Sun, 1 Jan 2023 15:04:37 +0000 (10:04 -0500)] 
Update the copyright year on all files

2 years agoApply spelling fixes discovered by Codespell
Paul Smith [Sat, 31 Dec 2022 18:21:09 +0000 (13:21 -0500)] 
Apply spelling fixes discovered by Codespell

* maintMakefile: Apply spelling fixes.
* src/file.c: Ditto.
* src/misc.c: Ditto.
* src/remake.c: Ditto.
* src/vmsjobs.c: Ditto.
* src/w32/pathstuff.c: Ditto.
* tests/test_driver.pl: Ditto.
* tests/run_make_tests.com: Ditto
* tests/scripts/features/implicit_search: Ditto
* tests/scripts/features/output-sync: Ditto
* tests/scripts/features/patternrules: Ditto
* tests/scripts/features/se_explicit: Ditto
* tests/scripts/features/statipattrules: Ditto
* tests/scripts/functions/foreach: Ditto
* tests/scripts/variables/MAKEFLAGS: Ditto

2 years agoAvoid using false(1) in regression tests
Paul Smith [Sat, 31 Dec 2022 15:31:24 +0000 (10:31 -0500)] 
Avoid using false(1) in regression tests

The POSIX standard only requires false(1) to return a "non-zero" exit
code; almost all systems return 1 but some (Solaris!!!) return 255 or
possibly even other values.  Use our helper "fail" instead.

* tests/thelp.pl: Have the "fail" command obey -q.
* tests/scripts/features/parallelism: Helper -q no longer prints fail.
* tests/scripts/targets/POSIX: Replace false with #HELPER# -q fail 1.
* tests/scripts/variables/MAKEFLAGS: Ditto.
* tests/scripts/variables/SHELL: Ditto.

2 years agoMake bootstrap.bat more portable
Paul Smith [Mon, 26 Dec 2022 18:10:26 +0000 (13:10 -0500)] 
Make bootstrap.bat more portable

Using backslashes in a sed command line is tricky as different programs
use them differently as escape sequences.  Eli Zaretskii points out
that Windows "echo" doesn't do any processing, so rework all our sed
invocations to use script files created by echo.

* bootstrap.bat: Use echo to create sed script files instead of -e.
* Basic.mk.template: Fix typo in the comments.
* .gitignore: Ignore any .sed scripts.

2 years ago* NEWS: Add a section for the next release
Paul Smith [Sat, 24 Dec 2022 20:48:48 +0000 (15:48 -0500)] 
* NEWS: Add a section for the next release

Add a note for the MAKEFLAGS enhancements.

2 years ago[SV 63439, SV 63452] Don't warn on undefined internal variables
Paul Smith [Sat, 24 Dec 2022 15:30:13 +0000 (10:30 -0500)] 
[SV 63439, SV 63452] Don't warn on undefined internal variables

Don't generate undefined variable warnings for variables that are
internal / special to make and where the empty string is valid.
Rather than defining them to empty, which could introduce unwanted
behavior, keep a list of variable names which we should never warn
about.

* src/variable.h (warn_undefined): Convert the macro to a function.
* src/variable.c (defined_vars): Always "defined" variable names.
(warn_undefined): Implement as a function and check against the
defined_vars before generating a warning.
* src/read.c (read_all_makefiles): No need to reset warning flag.
* src/vpath.c (build_vpath_lists): Ditto.
* tests/scripts/options/warn-undefined-variables: Expand all the
pre-defined variables to ensure warnings are not generated.

2 years ago[SV 63552] Change directories before constructing include paths
Paul Smith [Sat, 24 Dec 2022 14:26:24 +0000 (09:26 -0500)] 
[SV 63552] Change directories before constructing include paths

* src/makeint.h (reset_makeflags): New function to handle changing
MAKEFLAGS from within makefiles.  Remove decode_env_switches().
* src/variable.c (set_special_var): Call reset_makeflags() instead
of various internal methods.
* src/main.c (decode_env_switches): Only internal now so make static.
(decode_switches): Don't invoke construct_include_path() yet.
(reset_makeflags): Decode env switches and construct include paths.
(main): Construct include paths after we process -C options.
* tests/scripts/options/dash-C: Rewrite to use new test constructs.
Add a test using both -C and -I together.
Add a test for multiple -C options.

2 years agotests [WINDOWS32]: Support Strawberry Perl on Windows
Paul Smith [Mon, 19 Dec 2022 05:24:42 +0000 (00:24 -0500)] 
tests [WINDOWS32]: Support Strawberry Perl on Windows

Strawberry Perl has some different behaviors from ActiveState Perl
which impact the test suite:

- Avoid Perl's chomp() as it may not remove CRs; chomp() may remove
  only the final NL but not the CR in a CRNL line ending.
- Strawberry Perl doesn't support ActiveState's system(1, ...) form.
- Strawberry Perl (or msys?) does something weird with "/tmp" when
  provided to exec(), replacing it with the user's %TEMP%.
- Strawberry Perl uses msys paths like /c/foo instead of C:\foo.

* tests/test_driver.pl (get_osname): Strawberry Perl uses 'msys' as
its $^O so if we see that use a port of 'W32'.
(_run_with_timeout): Strawberry Perl doesn't support the special
system(1, ...) form of system() so use POSIX standard fork/exec.
(compare_answer): Paths generated by Strawberry Perl use msys path
format (e.g., /c/foo instead of C:\foo); check for those differences
and compare RE against both the unmodified and modified log.
* tests/run_make_tests.pl (set_defaults): Switch from chomp to s///
to remove CRNL and NL line endings.
* tests/scripts/features/errors: Executing directories on Strawberry
will give an error; translate it to Windows error output format.
* tests/scripts/features/output-sync: Ditto.
* tests/scripts/features/temp_stdin: Ditto.
* tests/scripts/functions/realpath: Ditto.
* tests/scripts/options/dash-I: Ditto.
* tests/scripts/variables/INCLUDE_DIRS: Ditto.
* tests/scripts/misc/close_stdout: /dev/full is reported as existing
on Strawberry Perl, but it doesn't do anything.  Skip the test.
* tests/scripts/variables/MAKEFLAGS: When an argument containing
/tmp is passed to a program via exec(), something replaces it with
the expansion of the %TEMP% variable.  Instead of using /tmp create
a local directory to use.

2 years ago* tests/test_driver.pl: Remember if something failed and report it
Paul Smith [Tue, 20 Dec 2022 07:06:03 +0000 (02:06 -0500)] 
* tests/test_driver.pl: Remember if something failed and report it

2 years ago[WINDOWS32] Remove CRNL from FormatMessage() result string
Paul Smith [Mon, 19 Dec 2022 05:20:06 +0000 (00:20 -0500)] 
[WINDOWS32] Remove CRNL from FormatMessage() result string

Sometimes the error message is expected to contain a newline, other
times it is not.  Also the result of FormatMessage() sometimes ends
in CRNL already: when printed via fprintf() the final newline is
converted to CRNL, giving an output of CRCRNL which causes tests
to fail to match.  Remove any CR/NL chars from the result string.

* src/job.c (reap_children): Add \n to the error message fprintf.
(exec_command): Ditto.
* src/w32/subproc/w32err.c (map_windows32_error_to_string): Remove
any trailing CR or NL from the string before returning.

2 years ago[SV 63537] Document and test flippable switches
Dmitry Goncharov [Sun, 18 Dec 2022 15:29:17 +0000 (10:29 -0500)] 
[SV 63537] Document and test flippable switches

* doc/make.texi (Options/Recursion): Clarify that MAKEFLAGS values
from the environment have precedence over those set in the makefile.
* tests/scripts/variables/MAKEFLAGS: Check boolean switches -k/-S,
-w/--no-print-directory and -s/--no-silent as follows:
1. A switch can be enabled or disabled on the command line.
2. A switch can be enabled or disabled in env.
3. A switch can be enabled or disabled in makefile.
4. Command line beats env and makefile.
5. Env beats makefile.
6. MAKEFLAGS contains each specified switch at parse and build time.
7. If switches are specified in multiple origins, MAKEFLAGS contains
   the winning switch at parse and build time.
8. MAKEFLAGS does not contain the losing switch.
Also test that --debug settings from different origins are combined
together into one option.

2 years ago[SV 63537] Pass enabled-by-default switches to submake
Dmitry Goncharov [Sun, 18 Dec 2022 19:43:41 +0000 (14:43 -0500)] 
[SV 63537] Pass enabled-by-default switches to submake

Certain switches, such as -S or --no-silent, turn on behavior that is
enabled by default.  When a switch is specified via the command line,
makefile, or env, ensure the switch is added to MAKEFLAGS.

* src/main.c (struct command_switch): Add bit "specified".
(switches): Initialize command_switch->specified.
(decode_switches): Set command_switch->specified.
(define_makeflags): Check command_switch->specified.

2 years ago[SV 63537] Remember the origin of command line options
Dmitry Goncharov [Sun, 18 Dec 2022 15:01:30 +0000 (10:01 -0500)] 
[SV 63537] Remember the origin of command line options

Certain options can be flipped on and off: -k/-S, -s/--no-silent, and
-w/--no-print-directory.  Ensure they behave as follows:
 1. A switch can be enabled or disabled on the command line.
 2. A switch can be enabled or disabled in env.
 3. A switch can be enabled or disabled in makefile.
 4. Command line beats env and makefile.
 5. Env beats makefile.

* src/main.c: Add variables to hold the origin of relevant options.
(struct command_switch): Add origin field.
(switches): Set a pointer to hold the origin of relevant options.
(decode_switches): For any switch that can be specified in makefile or
env, honor the switch only if cs->origin is not set or the specified
origin beats cs->origin.  Set cs->origin when relevant.

2 years ago[SV 63537] Fix setting -w in makefiles
Dmitry Goncharov [Sun, 18 Dec 2022 14:49:34 +0000 (09:49 -0500)] 
[SV 63537] Fix setting -w in makefiles

* src/makeint.h: Replace print_directory flag with should_print_dir().
* src/main.c (main): Remove print_directory flag and related code.
(should_print_dir): Create.
* src/output.c (output_dump): Use should_print_dir().
(output_start): Ditto.

2 years ago[SV 63484] Force included makefiles to be explicit
Dmitry Goncharov [Sat, 17 Dec 2022 19:12:41 +0000 (14:12 -0500)] 
[SV 63484] Force included makefiles to be explicit

Ensure included makefiles are not treated as intermediate, even if
they are created by an implicit rule.
Reported by Patrick Oppenlander <patrick.oppenlander@gmail.com>.

* src/read.c (eval_makefile): Mark makefiles as explicit.
* tests/scripts/features/include: Add a test.

2 years ago[SV 63516] [DOS] Support include files with drivespecs
Paul Smith [Sat, 17 Dec 2022 16:01:31 +0000 (11:01 -0500)] 
[SV 63516] [DOS] Support include files with drivespecs

* src/makeint.h (HAVE_DRIVESPEC): Create a macro to check.
* src/main.c (.FEATURES): Add "dospaths" as a feature.
* src/read.c (eval_makefile) [DOS]: If the included makefile name
starts with a drivespec, don't search the include directories.
* doc/make.texi (Include): Document this behavior.
* tests/scripts/features/include: Add a test.

2 years ago* src/job.c (new_job): [SV 63510] Trace phony prerequisite rebuilds
Paul Smith [Sat, 17 Dec 2022 19:01:02 +0000 (14:01 -0500)] 
* src/job.c (new_job): [SV 63510] Trace phony prerequisite rebuilds

2 years ago* configure.ac: Update for a new release
Paul Smith [Sun, 18 Dec 2022 19:40:26 +0000 (14:40 -0500)] 
* configure.ac: Update for a new release

* README.git: Add some packages needed for building from Git.
* AUTHORS: Updates.

2 years ago[SV 63417] Ensure global .NOTINTERMEDIATE disables all intermediates
Dmitry Goncharov [Sun, 27 Nov 2022 20:40:28 +0000 (15:40 -0500)] 
[SV 63417] Ensure global .NOTINTERMEDIATE disables all intermediates

Fix .NOTINTERMEDIATE without prerequisites to disable intermediate
status for all targets.

* src/makeint.h: Declare extern no_intermediates.
* src/main.c: Add global definition of no_intermediates.
* src/file.c: Remove static no_intermediates to use global variable.
(remove_intermediates): Check no_intermediates.
* src/implicit.c (pattern_search): For a file found by implicit search
set file->notintermediate if no_intermediates is set.
* src/remake.c (update_file_1): Don't set file->secondary for a
pre-existing file if no_intermediates is set.  The check for
no_intermediates here is redundant, but won't hurt: keep it in case
things change so that it matters.
* tests/scripts/targets/NOTINTERMEDIATE: Fix a test.

2 years ago* doc/make.texi: Use $(firstword) rather than $(word 1,)
Paul Smith [Sun, 27 Nov 2022 20:31:56 +0000 (15:31 -0500)] 
* doc/make.texi: Use $(firstword) rather than $(word 1,)

2 years ago[SV 63347] Always add command line variable assignments to MAKEFLAGS
Dmitry Goncharov [Sun, 27 Nov 2022 19:09:17 +0000 (14:09 -0500)] 
[SV 63347] Always add command line variable assignments to MAKEFLAGS

This commit introduces two visible changes:
1. Keep command line variable assignments in MAKEFLAGS at all times,
   even while parsing makefiles.
2. Define makeflags immediately when a makefile modifies MAKEFLAGS.

The new MAKEFLAGS and MAKEOVERRIDES initialization procedure:
1. decode_switches (argc, argv, o_command) is called to parse command
   line variable assignments.
2. Command line variable assignments go through quote_for_env.
   Initialize -*-command-variables-*- to the quoted values.
3. MAKEOVERRIDES is initialized to refer to -*-command-variables-*-
   with origin o_env to keep the definitions in the database intact.
4. define_makeflags() is called which adds MAKEOVERRIDES to MAKEFLAGS.
5. Makefiles are parsed.  If a makefile modifies MAKEFLAGS, the new
   value of MAKEFLAGS is defined right away.
6. Env switches are decoded again as o_env.  The definitions set by
   decode_switches at step 1 stay intact, as o_command beats o_env.

We must preserve the original intact definitions in order to detect
failure cases; for example:
  $ cat makefile
  all:; $(hello)
  $ make hello='$(world'
  makefile:1: *** unterminated variable reference.  Stop.

* src/makeint.h: Declare enum variable_origin, struct variable and
define_makeflags().  Add parameter origin to decode_env_switches().
* src/main.c (define_makeflags): Remove "all". If a variable is
assigned on the command line then append MAKEOVERRIDES to MAKEFLAGS.
(decode_env_switches): Replace parameter env with origin.
(decode_switches): Replace parameter env with origin.
Treat origin == o_command as env == 0.
(handle_non_switch_argument): Replace parameter env with origin.
Treat origin == o_command as env == 0.
(main): Call decode_switches() with origin==o_command before parsing
makefiles.  Call decode_switches() with origin==o_env after parsing
makefiles.
* src/variable.c (set_special_var): Define makeflags at parse time,
each time a makefile modifies MAKEFLAGS.
(do_variable_definition): Strip command line variable assignments from
MAKEFLAGS before appending extra flags.  set_special_var() adds them
back.
* tests/scripts/variables/MAKEFLAGS: Add tests.