* src/read.c (parse_var_assignment): If called in a target-specific
variable context don't allow define/undefine as variable assignments.
* test/scripts/variables/define: Add a test.
* test/scripts/variables/undefine: Add a test.
Add a new function $(let ...) which allows lexically scoped variables.
* NEWS: Add information on this feature.
* doc/make.texi (Let Function): Document the 'let' function.
* src/function.c (func_let): Create the 'let' built-in function.
* tests/scripts/functions/let: Test the 'let' built-in function.
Add debug options to print recipes even if they would otherwise be
silent, and to print the reason that a target was considered out of
date.
Modify --trace to simply be a shorthand for --debug=print,why.
* NEWS: Announce changes.
* doc/make.texi (Summary of Options): Document the new options.
* doc/make.1: Ditto.
* src/debug.h: Add new flags DB_PRINT and DB_WHY.
* src/makeint.h: Remove the trace_flag variable.
* src/job.c (start_job_command): Check debug flags not trace_flag.
(new_job): Ditto.
* src/main.c (trace_flag): Make a static variable for switches.
(decode_debug_flags): Set DB_PRINT and DB_WHY if trace_flag is set.
* tests/scripts/variables/GNUMAKEFLAGS: Update known-good messages.
* tests/scripts/variables/MAKEFLAGS: Ditto.
If a -include file does not exist, then some subsequent operation
creates it, then allow it to be successfully included.
* src/read.c (eval_makefile): If our last mtime was NONEXISTENT then
reset it to 0 so we'll check it again.
* tests/scripts/features/include: Add a test for this behavior.
Each time we invoke a command it's possible that it will change the
filesystem in ways that were not described by the target. If that
happens but we have cached previous directory contents then we may
make decisions or report results based on obsolete information.
Keep a count of how many commands we've invoked, and remember the
current command count every time we load the contents of a directory.
If we request the directory and the current command count has changed
we know the cache is outdated so reload from scratch.
* NEWS: Announce the change.
* src/makeint.h (command_count): Create a global counter.
* src/main.c (command_count): Ditto.
* src/job.c (reap_children): Increment the counter on job completion.
* src/function.c (func_file): Increment if we write a file.
* src/dir.c (clear_directory_contents): Clear the current contents of
a cached directory.
(struct directory_contents): Remember the counter value.
(struct directory): Remember the counter value for non-existing dirs.
(find_directory): If we have a cached directory and the count hasn't
changed then return it. Else, clear the previous contents and re-read
from scratch.
* tests/scripts/features/dircache: Add tests of the directory cache.
Rewrite the environment variable algorithm to correctly inherit
export settings from parent variable sets. The new algorithm
for computing the table of environment variables is:
- Start with the most local variable set and proceed to global.
- If the variable already exists in the table and we don't know
its export status, update it with the current variable's status.
- If the variable is not in the table and it's not global, add it
regardless of its status so if it's unexported we remember that.
- If the variable is not in the table and is global, check its
export status and don't add it if we won't export it.
Then when generating the environment variables, check the export
status of each variable in case it was a target-specific variable
and we have determined it should not be exported.
Rework SHELL handling to check at the end whether we added it or
not and if we didn't, add the value from the environment.
* NEWS: Announce support for target-specific "unexport"."
* doc/make.texi (Target-specific): Document the support.
* src/variable.h (enum variable_export): Make into a global type.
* src/read.c (struct vmodifiers): Use enum variable_export rather
than individual booleans.
(parse_var_assignment): Parse the "unexport" keyword.
(eval): Remember the vmodifier value in the variable.
(record_target_var): Ditto.
* src/variable.c (should_export): Check if the variable should be
exported.
(target_environment): Implement the above algorithm.
* tests/scripts/features/export: Test export/unexport with variable
assignments on the same line.
* tests/scripts/features/targetvars: Add a comprehensive suite of
tests for different types of target-specific export / unexport.
* tests/scripts/variables/SHELL: Update the comment.
When checking for invalid environment variable names we searched the
entire name string instead of just the first LENGTH chars; this could
cause us to incorrectly decide the variable was not exportable.
Dmitry Goncharov <dgoncharov@users.sf.net> found this bug and
provided a test case and sample fix: I used the test but chose a
slightly different fix.
* src/variable.c (define_variable_in_set): check the variable name
not the input string.
* tests/scripts/features/targetvars: Ensure environment variable
values are exported.
GNU make must recognize some special targets as they are defined.
Because of the way targets are defined, we were not recognizing these
special targets until we were handling the NEXT statement. However
that's too late for some special targets such as .POSIX etc. which can
change the behavior of make during parsing.
Check for special targets earlier, as soon as we've finished parsing
the target introduction line (before we've even parsed the recipe).
* NEWS: Mention the change.
* src/read.c (check_specials): New function to look for special
targets. Move checks from eval() and record_files() to this new
function.
(eval): Call check_specials() after we've completed parsing the target
introduction line. Move default goal detection to check_specials().
(record_files): Move handling of .POSIX, .SECONDEXPANSION, and
.ONESHELL to check_specials().
* tests/scripts/misc/bs-nl: Remove workaround for late .POSIX issue.
* tests/scripts/targets/POSIX: Add a comment.
* src/function.c (func_filter_filterout): Allocate arrays to hold
pattern and word information rather than creating linked lists on
the stack.
* tests/scripts/functions/filter-out: Test large filters.
Ensure that makefiles are rebuilt in the order in which make first
considered them, and document this behavior in the manual.
* NEWS: Add a note about the new behavior
* doc/make.text (How make Processes a Makefile): Document it.
* main.c (main): Inverse the list of makefile goals.
* read.c (read_all_makefiles): Add default makefiles to the list at
the front in reverse order, the same way other makefiles are added.
* tests/scripts/features/include: Add tests to verify rebuild order.
The "[" link may be missing during OS boostrapping.
* build.sh: Convert "[ ... ]" to "test ..."
* maintMakefile: Ditto.
* scripts/copyright-update: Ditto
* tests/scripts/features/reinvoke: Ditto
* tests/scripts/features/targetvars: Ditto
When using execvp() if $PATH is not present in the environment
it will automatically search the system default PATH string. Emulate
this by passing the system default PATH to find_in_given_path() if
we don't find PATH in the environment.
* src/job.c (child_execute_job): Use confstr(_CS_PATH) if PATH is not
found.
Rather than having an %extraENV that is added to the default %ENV
and resetting %ENV _before_ each test, allow the test setup to
modify %ENV directly as needed then reset %ENV _after_ each test.
* tests/test_driver.pl: Remove unused %extraENV.
(resetENV): Don't add in %extraENV.
(_run_command): Reset after we run the command rather than before.
* tests/scripts/features/export: Convert %extraENV to %ENV
* tests/scripts/features/jobserver: Ditto
* tests/scripts/features/parallelism: Ditto
* tests/scripts/features/targetvars: Ditto
* tests/scripts/functions/eval: Ditto
* tests/scripts/functions/foreach: Ditto
* tests/scripts/functions/origin: Ditto
* tests/scripts/misc/general4: Ditto
* tests/scripts/options/dash-e: Ditto
* tests/scripts/targets/POSIX: Ditto
* tests/scripts/variables/GNUMAKEFLAGS: Ditto
* tests/scripts/variables/SHELL: Ditto
We want to process -C options as early as possible, before we might
write informational messages, so that Entering/Leaving messages have
the correct directory.
* src/main.c (main): Move code dealing with changing directories
before parsing of the jobserver auth flag.
* tests/scripts/features/jobserver: Test the order of enter/leave.
Previously if --no-print-directory was seen anywhere even once
(environment, command line, etc.) it would always take precedence
over any --print-directory option. Change this so that the last
seen option (which will be the command line, if present there) takes
precedence.
* NEWS: Mark this change in behavior.
* src/makeint.h (print_directory): A new variable to control printing.
* src/output.c (output_dump): Use the new variable.
(output_start): Ditto.
* src/main.c: Add a new variable print_directory. Use -1 for
print_directory_flag so we know of the option was seen or not. Add a
new default_print_directory_flag set to -1 to keep options from being
added.
(switches): Use flag_off for --no-print-directory, rather than a
separate inhibit_print_directory_flag.
(main): If print_directory_flag was set by the user, use that for
print_directory. If not, compute the print_directory value based on
-s, -C, and sub-makes as before.
* tests/scripts/variables/GNUMAKEFLAGS: -w is not added automatically
* tests/scripts/options/print-directory: Add tests for overriding
print-directory options.
POSIX says that suffix rules cannot have prerequisites, but after
making this change we observed a number of makefiles "in the wild"
that were relying on this behavior and failed.
For .POSIX: makefiles, obey POSIX. Otherwise preserve the old
behavior. However, generate a warning so users know this is a
problem. In a future version we will change all behavior to be
POSIX-conforming.
* NEWS: describe the change
* src/rule.c (convert_to_pattern): If posix_pedantic don't make a
pattern rule if prereqs exist. Otherwise show a warning.
* tests/scripts/features/suffixrules: Add tests for the new behavior
including .POSIX vs. non-.POSIX.
Initial implementation by Christof Warlich <cwarlich@gmx.de>
* NEWS: Announce the new feature.
* doc/make.texi (Other Special Variables): Document .EXTRA_PREREQS.
* src/dep.h (struct dep): New flag to note extra prereq deps.
* src/filedef.h (expand_extra_prereqs): Declare a function to expand
the value of .EXTRA_PREREQS.
* src/file.c (expand_extra_prereqs): Given a struct variable lookup
of .EXTRA_PREREQS, convert it into a list of deps and for each one
make sure it has a struct file and has the new flag set.
(snap_file): A new function invoked by hash_map that will perform
per-file operations: set up second expansion, intermediate, and also
.EXTRA_PREREQS. Manage circular dependencies by ignoring them.
(snap_deps): Defer per-file operations until the end. Look up the
global .EXTRA_PREREQS and pass it along to snap_file for each file.
* src/implicit.c (struct patdeps): Remember the extra prereqs flag.
(pattern_search): Transfer extra prereqs flag settings into the
matched pattern rule.
* src/rule.h (snap_implicit_rules): Rename count_implicit_rules to
snap_implicit_rules since we now do more than count.
* src/rule.c (snap_implicit_rules): As we walk through all the pattern
rules, add in any global .EXTRA_PREREQS to the dep list. Ensure we
take them into account for the max number of prereqs and name length.
* src/main.c (main): Add extra-prereqs to .FEATURES.
Call the renamed snap_implicit_rules.
* tests/scripts/variables/EXTRA_PREREQS: Add tests.
Avoid using posix_spawn implementations that fail asynchronously when
the spawned program can't be invoked: this means instead of getting
an error such as "No such file or directory" we get just "Exit 127".
Original implementation of the configure.ac macro provided by
Martin Dorey <martin.dorey@hds.com>
Original implementation of the regression tests provided by
Dmitry Goncharov <dgoncharov@users.sf.net>
* configure.ac: Test whether posix_spawn fails asynchronously. In a
cross-compilation environment, assume that it does not. If we detect
that it does, fall back to fork/exec.
* tests/scripts/features/exec: Add regression tests for different
shebang invocation methods.
* src/dep.h: Add a new flag PARSEFS_ONEWORD
* src/read.c (parse_file_seq): If PARSEFS_ONEWORD is given, treat the
entire incoming string as a single pattern.
* src/implicit.c (pattern_search): Pass PARSEFS_ONEWORD when parsing
patterns for wildcards.
* tests/scripts/features/patternrules: Add a new test.
If the stem matches a path containing a directory not just a
filename, make sure the second expansion of $* in the
prerequisites matches $* in the recipe. This requires using
$(*F) when replacing % in the first expansion to preserve the
simple filename.
* src/implicit.c (pattern_search): If lastslash is set prepend
the directory onto the stem. Then use $(*F) when expanding %.
* tests/scripts/features/se_implicit: Add a test case
On Windows the path to the helper tool will contain '\': this will
fail if recipes are run with a POSIX shell. Convert '\' to '/'
on Windows. While here, escape any spaces in the path as well.
* tests/thelp.pl: Rename from tests/jhelp.pl.
(op): Use names instead of options for the operations.
(op): Add new operations for sleep, mkdir, and rm.
(op): Enhance wait to time out
* tests/run_make_tests.pl: Add a new #HELPER# replacement
(subst_make_string): Use fully-qualified path to thelp.pl
* tests/scripts/features/parallelism: Update to use thelp.pl
and the new named operations. Use thelp.pl sleep instead of
system-specific sleep commands.
* tests/scripts/features/output-sync: Update to use thelp.pl
instead of complex shell scripts.
* Makefile.am: Distribute tests/thelp.pl instead of tests/jhelp.pl
* tests/config-flags.pm.W32: Create a predefined Windows file.
* Makefile.am (test_FILES): Add it to the distribution.
* build_w32.bat: Install tests/config-flags.pm if not existing.
* tests/run_make_tests.pl (get_config): Create new function.
* tests/scripts/features/archives: Call get_config() rather than
using %CONFIG_FLAGS directly.
* tests/scripts/features/load: Ditto.
* tests/scripts/features/loadapi: Ditto.
* tests/scripts/functions/wildcard: Ditto.
This reverts commit 6264deece3.
Further investigation discovers that the real issue is that
GNU Emacs compile mode doesn't have a matching regex for GNU
make error messages generated when targets fail. I submitted
a patch to GNU Emacs adding a matcher for compile mode.
Ensure we properly reduce job_slots_used if a command fails because
it doesn't exist/can't be started.
* src/job.h (struct child): Add a field jobslot to be set when using
a job slot.
* src/job.c (start_waiting_job): Remember if we are using a job slot.
(reap_children): Reduce number of job slots used by jobslot.
Go through both run_make_tests.pl and test_driver.pl and slightly
modernize the Perl and clean up indentation etc. Fix a number of
warnings in the test scripts detected by running with -w.
* tests/test_driver.pl: Move make error string detection out of the
base test driver.
(run_all_tests): Ensure that we always look for tests in the cwd.
* tests/run_make_tests.pl: Use File::Spec for path manipulations.
Correctly use setlocale() when detecting error strings.
Get configuration from the config-flags.pm file not config.status.
* tests/scripts/features/archives: Use new $cwddir variable.
* tests/scripts/features/reinvoke: Add missing semicolon.
* tests/scripts/features/vpath2: Avoid non-existent variable.
* tests/scripts/functions/foreach: Escape variables.
* tests/scripts/misc/bs-nl: Remove non-existing \v escape sequence.
* tests/scripts/misc/general4: Use handy create_file().
* tests/scripts/options/dash-C: Use Cwd/$cwddir.
* tests/scripts/options/dash-I: Use subst_make_string() and #PWD#.
* tests/scripts/options/symlinks: Use File::Spec.
* tests/scripts/targets/DEFAULT: Use create_file and run_make_test.
* tests/scripts/variables/CURDIR: Use run_make_test.
* tests/scripts/variables/automatic: Remove extraneous "\".
* tests/scripts/vms/library: Remove extra "my" and extraneous "\".