Commit graph

160 commits

Author SHA1 Message Date
Jouke Witteveen
fcc11d05a6 Create $(let ...) providing lexically scoped variables
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.
2020-12-06 18:30:58 -05:00
Paul Smith
a8f4669b23 * doc/make.texi (Phony Targets): [SV 58961] Clarify pattern handling 2020-12-06 15:21:23 -05:00
Paul Smith
bd4829096c * doc/make.texi (Synchronized Terminal Output): [SV 58960] Fix link 2020-12-06 10:14:15 -05:00
Paul Smith
7044e0c93c [SV 59169] Add --debug=why and --debug=print options
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.
2020-12-05 16:25:12 -05:00
Paul Smith
2dc0280d82 Support "unexport" in target-specific variables.
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.
2020-11-29 17:57:33 -05:00
Paul Smith
f4f353bb54 * doc/make.texi (Include): Update behavior for missing included files 2020-10-28 11:10:52 -04:00
Paul Smith
62e8f029e9 [SV 58735] Define the order that makefiles are rebuilt.
Ensure that makefiles are rebuilt in the order in which make first
considered them, and document this behavior in the manual.

* NEWS: Add a note about the new behavior
* doc/make.text (How make Processes a Makefile): Document it.
* main.c (main): Inverse the list of makefile goals.
* read.c (read_all_makefiles): Add default makefiles to the list at
the front in reverse order, the same way other makefiles are added.
* tests/scripts/features/include: Add tests to verify rebuild order.
2020-07-19 13:56:23 -04:00
Paul Smith
f430a65ccb GNU Make release 4.3
* NEWS: Update for the release
* configure.ac: New release number
* doc/make.texi: New edition number
2020-01-19 17:04:52 -05:00
Paul Smith
dd6adfa454 Resolve some documentation issues
* doc/make.texi (Interrupts): [SV 46193] Recommend defensive recipes
* doc/make.texi: [SV 49262] Clarify interaction of prerequisites and
non-terminal match-anything rules.
2020-01-19 17:04:52 -05:00
Paul Smith
3b5e47b2e2 [SV 40657] Reinstate old behavior for suffix rules with prereqs
POSIX says that suffix rules cannot have prerequisites, but after
making this change we observed a number of makefiles "in the wild"
that were relying on this behavior and failed.

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

* NEWS: describe the change
* src/rule.c (convert_to_pattern): If posix_pedantic don't make a
pattern rule if prereqs exist.  Otherwise show a warning.
* tests/scripts/features/suffixrules: Add tests for the new behavior
including .POSIX vs. non-.POSIX.
2020-01-19 17:04:52 -05:00
Paul Smith
ec946d7e21 * doc/make.texi: Change the GFDL to an Appendix 2020-01-04 13:24:39 -05:00
Paul Smith
12b14f0484 Update copyright statements for 2020 2020-01-03 02:08:59 -05:00
Paul Smith
4e12a5fa45 Support the .EXTRA_PREREQS special variable
Initial implementation by Christof Warlich <cwarlich@gmx.de>

* NEWS: Announce the new feature.
* doc/make.texi (Other Special Variables): Document .EXTRA_PREREQS.
* src/dep.h (struct dep): New flag to note extra prereq deps.
* src/filedef.h (expand_extra_prereqs): Declare a function to expand
the value of .EXTRA_PREREQS.
* src/file.c (expand_extra_prereqs): Given a struct variable lookup
of .EXTRA_PREREQS, convert it into a list of deps and for each one
make sure it has a struct file and has the new flag set.
(snap_file): A new function invoked by hash_map that will perform
per-file operations: set up second expansion, intermediate, and also
.EXTRA_PREREQS.  Manage circular dependencies by ignoring them.
(snap_deps): Defer per-file operations until the end.  Look up the
global .EXTRA_PREREQS and pass it along to snap_file for each file.
* src/implicit.c (struct patdeps): Remember the extra prereqs flag.
(pattern_search): Transfer extra prereqs flag settings into the
matched pattern rule.
* src/rule.h (snap_implicit_rules): Rename count_implicit_rules to
snap_implicit_rules since we now do more than count.
* src/rule.c (snap_implicit_rules): As we walk through all the pattern
rules, add in any global .EXTRA_PREREQS to the dep list.  Ensure we
take them into account for the max number of prereqs and name length.
* src/main.c (main): Add extra-prereqs to .FEATURES.
Call the renamed snap_implicit_rules.
* tests/scripts/variables/EXTRA_PREREQS: Add tests.
2020-01-03 02:08:59 -05:00
Paul Smith
e666a6a021 * doc/make.text (Reading Makefiles): Rewrite to be more clear. 2019-10-06 15:48:53 -04:00
Paul Smith
ebe1d37104 * doc/make.texi (Recipe Execution): Correct example to use $(<[DF]) 2019-09-07 20:12:44 -04:00
Paul Smith
9be3c0e2b2 * doc/make.texi: Clarify that the jobserver pipe is "blocking" 2019-09-07 18:27:26 -04:00
Paul Smith
0967624050 * doc/make.tex (Substitution Refs): Clarify patsubst relationship. 2019-09-07 18:27:26 -04:00
Paul Smith
1c045bca52 * doc/make.texi: [SV 51974] Clarify makefile parsing operations. 2019-05-19 19:25:50 -04:00
Paul Smith
4ed31830cb * doc/make.texi: [SV 54116] Document whitespace removal trick.
Discovered and explained by Michael Henry <gnu@drmikehenry.com>
* tests/scripts/variables/flavors: Add a test to preserve the behavior.
2019-05-19 19:25:50 -04:00
Paul Smith
389dcb608f Update copyright statements for 2019 2019-05-19 15:27:26 -04:00
Kaz Kylheku
8c888d95f6 [SV 8297] Implement "grouped targets" for explicit rules.
This patch allows "grouped targets" using the &: syntax:

  tgt1 tgt2 ... tgtn &: pre1 pre2 ...
        recipe

When the &: separator is used (in single or double colon forms), all
the targets are understood to be built by a single invocation of the
recipe.  This is accomplished by piggy-backing on the already-existing
pattern rule feature, using the file's "also_make" list.

* NEWS: Add information about grouped targets.
* doc/make.texi (Multiple Targets): Add information on grouped targets.
(Pattern Intro): Refer to the new section to discuss multiple patterns.
* src/main.c (main): Add "grouped-targets" to .FEATURES
* src/read.c (make_word_type): Add new types for &: and &::.
(eval): Recognize the &: and &:: separator and remember when used.
(record_files): Accept an indicator of whether the rule is grouped.
If so, update also_make for each file to depend on the other files.
(get_next_mword): Recognize the &: and &:: word types.
* tests/scripts/features/grouped_targets: New test script.
* AUTHORS: Add Kaz Kylheku
2019-05-12 16:29:20 -04:00
Paul Smith
ac11ec5497 * doc/make.texi (Remaking Makefiles): [SV 52273] Note MAKE_RESTARTS 2018-09-15 16:12:44 -04:00
Paul Smith
8fd614e238 * doc/make.texi: [SV 48970] Clarify the value of $? 2018-09-15 15:08:47 -04:00
Paul Smith
92032bc16a * doc/make.text: [SV 54360] Weaken "obsolete" language in the manual.
There's no need to frighten users away from capabilities which are
perfectly reasonable and definitely not going away, by calling them
obsolete or discouraged in the manual.
2018-09-15 15:08:47 -04:00
Ola Olsson
73ac4526b9 * doc/make.texi: Updated language 2018-07-01 12:23:09 -04:00
Paul Smith
afbecbd9dc * all: Update Copyright statements for 2018 2018-07-01 12:22:04 -04:00
Paul Smith
fb779d2f1e Rework directory structure to use GNU-recommended "src" directory.
Move the source code (other than glob) into the "src" subdirectory.
Update all scripting and recommendations to support this change.

* *.c, *.h, w32/*: Move to src/
* configure.ac, Makefile.am, maintMakefile: Locate new source files.
* Basic.mk.template, mk/*: Update for new source file locations.
* NEWS, README.DOS.template: Update for new locations.
* build.template, build_w32.bat, builddos.bat: Ditto.
* po/POTFILES.in: Ditto
* tests/run_make_tests.pl, tests/scripts/features/load*: Ditto.
* make.1: Move to doc.
* mk/VMS.mk: Add support for building on VMS (hopefully).
* makefile.vms, prepare_w32.bat: Remove.
* SCOPTIONS: Update to define HAVE_CONFIG_H
2017-11-19 14:07:22 -05:00
Paul Smith
7ef56bc8dc Update copyright statements for 2017. 2017-07-09 21:52:28 -04:00
Paul Smith
b90fabc8d6 * NEWS: Do not insert a space during '+=' if the value is empty.
* doc/make.texi (Appending): Document this behavior.
* variable.c (do_variable_definition): Only add a space if the variable
value is not empty.
* tests/scripts/variables/flavors: Test this behavior.
2017-06-04 18:37:21 -04:00
Paul Smith
e20c48e385 * doc/make.texi: [SV 50304] Add missing close parenthesis. 2017-06-04 18:37:20 -04:00
Paul Smith
d351c1fef2 * main.c (switches): Add -E as an alias for --eval.
* make.1: Document the -E and --eval options.
* doc/make.texi: Document the -E option.
* tests/scripts/options/eval: Test the -E option and MAKEFILES.
* NEWS: Add information about the new option.
2016-12-28 09:25:51 -05:00
Paul Smith
3daaa4dd3e * main.c (switches): Add --no-silent to undo -s options.
* make.1: Document the new flag.
* doc/make.texi: Document the new flag.  Remove suggestions that the
.SILENT special target is deprecated or should not be used.
* tests/scripts/options/dash-s: Test the -s and --no-silent options.
* NEWS: Add information about the new option.
2016-12-28 09:25:34 -05:00
Paul Smith
db72ca1b7d * doc/make.texi: [SV 48951] Fix documentation typo. 2016-12-25 18:18:45 -05:00
Paul Smith
ec61980122 GNU Make release 4.2. 2016-05-22 09:25:55 -04:00
Paul Smith
5bd7ad2b22 Preserve the real value of -jN in MAKEFLAGS using jobserver.
Previously if the jobserver was active, MAKEFLAGS would contain only
the -j option but not the number (not -j5 or whatever) so users
could not discover that value.  Allow that value to be provided in
MAKEFLAGS without error but still give warnings if -jN is provided
on the command line if the jobserver is already activated.

* NEWS: Discuss the new behavior.
* os.h, posixos.c, w32/w32os.c: Return success/failure from
jobserver_setup() and jobserver_parse_auth().
* main.c (main): Separate the command line storage of job slots (now
in arg_job_slots) from the control storage (in job_slots).  Make a
distinction between -jN flags read from MAKEFLAGS and those seen
on the command line: for the latter if the jobserver is enabled then
warn and disable it, as before.
* tests/scripts/features/jobserver: Add new testing.
2016-04-04 01:38:37 -04:00
Paul Smith
b8a8af6550 * make.texi: Confirm that CURDIR contains an absolute path. 2016-04-04 01:36:08 -04:00
Paul Smith
360b76af84 * docs/make.texi: [SV 47392] Add "Integrating make" chapter. 2016-04-04 01:36:08 -04:00
Paul Smith
2b9dd215d5 * function.c (func_file): Support reading from files.
* NEWS: Add information about reading files.
* make.texi (File Function): Describe reading files.
* tests/scripts/functions/file: Test new features for $(file ...)
2016-03-21 00:44:53 -04:00
Paul Smith
fc2ddebdae * doc/make.texi (Setting Variables): Fix typo (add comma). 2016-03-20 14:23:46 -04:00
Paul Smith
798ebd241b Update Copyright statements for the new year. 2016-02-28 12:55:20 -05:00
Paul Smith
4db6d0c694 * doc/make.texi: [SV 47163] Fix typo in 'ifdef' documentation. 2016-02-28 12:41:41 -05:00
Paul Smith
b754a35df7 * doc/make.texi: [SV 35455] Add more uses for Empty Recipes. 2016-02-28 12:35:15 -05:00
Paul Smith
43181f1f82 [SV 28092] Preserve the exit status of the $(shell...) function.
Add a new variable .SHELLSTATUS which holds the exit status of the
last-invoked shell function or != assignment.

* NEWS, doc/make.texi: Document the change.
* function.c (shell_completed, msdos_openpipe, func_shell_base): Add
shell_completed() to handle the completion of the shell, by setting
.SHELLSTATUS.  Call it where needed.
* job.c (child_handler): Call shell_completed().
* tests/scripts/functions/shell: Add tests for .SHELLSTATUS.
2015-07-12 21:03:24 -04:00
Paul Smith
0a3a0756b9 Update Copyright statements for 2014. 2014-09-30 09:32:42 -04:00
Paul Smith
9a2451af0b * main.c, NEWS, doc/make.text: Rename MAKE_TTY* to MAKE_TERM* 2014-09-15 09:30:40 -04:00
Paul Smith
7f9ce6e97b * main.c (main): Set MAKE_TTYOUT and MAKE_TTYERR.
* configure.ac: Test for isatty() and ttyname()
* makeint.h: provide a substitute for ttyname() if it's not available.
* config.ami.template, config.h-vms.template, config.h.W32.template:
define/undefine HAVE_ISATTY/HAVE_TTYNAME macros.
* NEWS, doc/make.texi: Document these new variables.
2014-09-14 01:03:19 -04:00
Paul Smith
986632ec23 * doc/make.texi: Clarify implicit rule lookup of phony targets
Reported by Frank Heckenbach <f.heckenbach@fh-soft.de>
2014-09-07 20:02:31 -04:00
Paul Smith
e364498113 [SV 41983] Support omitting the text argument to $(file ...)
Reported by Tim Murphy <tnmurphy@gmail.com>
* function.c (func_file): Only write TEXT if it is not NULL.
* NEWS, doc/make.texi: Document the new feature
* tests/scripts/functions/file: Verify that the no-text version of
  $(file ...) works and doesn't add a newline.
2014-07-07 01:59:03 -04:00
Paul Smith
01a745025d Add support for updating the GNU make web pages.
Add makefile rules for updating the http://www.gnu.org/software/make
web pages, including the online GNU make manual.
2013-10-13 16:48:22 -04:00
Paul Smith
4792e154b6 Convert to auto-generated ChangeLog files.
Rename existing ChangeLog files so they won't be distributed.
Add targets to maintMakefile to generate ChangeLog from the Git
repository.  This will require a version of gnulib be available.
Because ChangeLog is auto-generated, we have to switch our
automake mode to "foreign" or it will complain and fail.
2013-10-13 16:48:22 -04:00