Compare commits

...

578 Commits

Author SHA1 Message Date
Paul Smith
d523661ce2 [SV 66499] Detect jobserver values that are too large
Set the jobserver pipe to non-blocking before writing tokens; if a
token write fails the user's jobserver value is too large so fail.

Original implementation: Dmitry Goncharov <dgoncharov@users.sf.net>

* src/posixos.c (set_blocking): Split into force_blocking() which
always enables/disables blocking; set_blocking() may call it.
(jobserver_setup): Set the write side of the pipe to non-blocking
before writing tokens.  If it fails with EAGAIN we know the pipe
is full: create a fatal error.
* tests/scripts/features/jobserver: Test a too-large jobserver.
2024-12-08 23:30:37 -05:00
Paul Smith
f12a4fddce jobserver: Ensure the named pipe is deleted on error
Make sure the jobserver named pipe is deleted even if the
jobserver_setup() function calls fatal() and exits early.

* src/main.c (clean_jobserver): Always reset_jobserver().
* src/posixos.c (jobserver_setup): Set job_root up front.
* tests/test_driver.pl: Print out the logfile pathname on error.
For tests with regex matches this might be the only file available.
Don't print the base filename unless one is created.
2024-12-08 23:30:37 -05:00
Paul Smith
186522e480 * doc/make.texi: [SV 66324] Fix a typo 2024-12-08 23:30:00 -05:00
Dmitry Goncharov
aa8626ce09 [SV 66273] Double-colon targets must not be intermediate
An explicitly mentioned double-colon target cannot be intermediate.

* src/read.c (record_files): Set file->is_explicit in the case of an
explicitly mentioned file built by a double colon rule.
* src/file.c (print_file): Have print_file print whether a file is
explicitly mentioned.
* tests/scripts/features/patternrules: Add tests.
2024-10-01 22:27:25 -04:00
Dmitry Goncharov
93704dd565 [SV 66268] Include newlines in file removal error message
* src/file.c (remove_intermediates): Fix an error message about a
failure to remove an intermediate file.
* tests/scripts/features/patternrules: Add tests.
2024-10-01 22:14:31 -04:00
Paul Smith
101bf5636f * doc/make.texi: Clarify -j versus -jN behavior 2024-09-02 16:23:36 -04:00
Sergei Trofimovich
9251546bac Fix biased shuffle by avoiding already "struck" elements
Artem Klimov noticed that current shuffle implementation suffers from
probability bias due to a typical bug in the shuffling implementation.

When we consider already shuffled element we slightly bias their
propability.

https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#The_modern_algorithm
suggests shuffling each "struck" element only once.

Before the change probabilities of 4-element array to land from `i`
index to `j` index are:

          0     1     2     3
      _____ _____ _____ _____
  0 | 25.00 29.30 24.60 21.10
  1 | 25.00 22.25 28.13 24.63
  2 | 25.00 23.44 22.26 29.30
  3 | 25.00 25.01 25.01 24.98

Note that `0->1` probability is almost 29% while `0->3` os only 21%.

After the change probabilities are not as biased:

          0     1     2     3
      _____ _____ _____ _____
  0 | 24.99 24.99 25.01 25.01
  1 | 24.99 25.04 24.99 24.99
  2 | 25.01 25.00 25.00 24.99
  3 | 25.01 24.98 25.00 25.01

* src/shuffle.c (random_shuffle_array): Fix biased shuffle by avoiding
already "struck" elements.
2024-09-02 15:11:36 -04:00
Paul Smith
7dc23aff30 * doc/make.texi: GNUMAKEFLAGS is only read from the environment 2024-09-02 14:54:23 -04:00
Paul Eggert
0267eb64fa Check for snprintf truncation on W32
* src/main.c (find_and_set_default_shell) [MK_OS_W32]:
Do not use a buffer that snprintf truncated.
2024-09-02 14:43:24 -04:00
Paul Eggert
bba4427b5d Fix unlikely pointer overflow in abspath
* src/function.c (abspath): len is now ptrdiff_t,
to avoid GCC warning about comparing signed to unsigned.
It really is a pointer difference, after all.
Rejigger comparision to avoid undefined behavior
if dest + len is an invalid pointer.
2024-09-02 14:43:24 -04:00
Paul Eggert
c23a7e6232 Prefer memcpy to strncpy if either will do
strncpy is trickier and a bit slower.
* src/function.c (func_realpath, func_abspath):
* src/misc.c (xstrndup):
Prefer memcpy or mempcpy to strncpy when the source length is known.
2024-09-02 14:43:24 -04:00
Paul Eggert
4d3bf7838f Omit unused PATH_MAX code
* src/makeint.h (GET_PATH_MAX, PATH_VAR):
Simplify, since PATH_MAX is always defined here.
(NEED_GET_PATH_MAX): Remove.
* src/misc.c (get_path_max) [NEED_GET_PATH_MAX]: Remove.
2024-09-02 14:43:24 -04:00
Paul Eggert
8c8c7fc226 Avoid strlen calls after sprintf
* src/file.c (file_timestamp_sprintf):
* src/function.c (func_words, func_call):
* src/job.c (child_error):
* src/main.c (define_makeflags):
* src/output.c (message, error, fatal):
Use return value from sprintf instead of calling strlen
on the resulting buffer.
2024-09-02 14:43:24 -04:00
Paul Smith
9fee98f843 [SV 65759] Document special handling of "-" command line option
* doc/make.1: Add information on "-" option handling.
* doc/make.texi: Ditto.
2024-09-02 13:48:41 -04:00
Dan D
f800f8bae3 [SV 65777] Add more const
Add more const to static arrays.  On some systems this allows more
data to be placed in RO segments and shared between multiple
instances of the make executable.  Anyway more const is good hygiene.

* src/default.c: Add const to arrays.
* src/function.c: Ditto.
* src/hash.c: Ditto.
* src/hash.h: Ditto.
* src/job.c: Ditto.
* src/read.c: Ditto.
* src/remake.c: Ditto.
* src/rule.c: Ditto.
* src/rule.h: Ditto.
2024-09-02 13:48:30 -04:00
Paul Smith
39a4c81062 Remove obsolete email address for the FSF
* doc/make.texi: Use the newer email address in the manual.
* gl/lib/fnmatch.c: Use a URL instead of a street address.
* gl/lib/fnmatch.in.h: Ditto.
* gl/lib/glob.c: Ditto.
* gl/lib/glob.in.h: Ditto.
2024-09-01 21:12:37 -04:00
Paul Smith
d97e048b08 * bootstrap.conf: Update to newer prerequisites 2024-09-01 21:09:42 -04:00
Paul Smith
c63a5bc6a2 [SV 65917] Mark also_make targets as updated in make -n
Suggested patch by Hannes Domani <ssbssa@yahoo.de>

* src/remake.c (notice_finished_file): When run with -n, mark
also_make targets as updated.
* tests/scripts/options/dash-n: Test pattern and grouped targets.
2024-08-04 23:53:26 -04:00
Paul Smith
bc979e4949 * src/job.c (new_job): [SV-66030] Show all also-make targets 2024-08-04 17:16:23 -04:00
Paul Smith
6970561de0 Don't add a target to its own also_make list
* src/dep.h (copy_dep): Make a copy of one struct dep.
* src/misc.c (copy_dep): Implement the new function.
(copy_dep_chain): Call copy_dep() for each dep in the chain.
* src/read.c (record_files): Write our own copy loop and omit the
current file from its own also_make list.  Since we don't keep
the function's also_make, free it.
2024-08-04 17:13:07 -04:00
Paul Smith
f0db5e321f * doc/make.texi: [SV-65982] Clarify what --debug=makefile does 2024-08-04 16:04:19 -04:00
Paul Smith
8653c25fcf * src/remake.c (update_file_1): [SV 65999] Clarify debug output 2024-08-04 16:02:19 -04:00
Paul Smith
4d883c414d * doc/make.texi: [SV-66018] Mention .ONESHELL in [-+@] docs 2024-08-04 16:02:19 -04:00
Dmitry Goncharov
034f862361 [SV 66037] Avoid hang/crash from MAKEFLAGS=... on command line
Make enters an infinite loop when some option and MAKEFLAGS=<value>
are specified on the command line.  For example,
    $ make -r MAKEFLAGS=hello=world

If decode_switches() runs handle_non_switch_argument() from within
the getopt() loop, it would recursively call decode_switches() to
enter a new getopt() loop, corrupting the state of the outer loop.

* src/main.c (decode_switches): Save up non-option arguments and run
handle_non_switch_argument() only after we're done with getopt().
* tests/scripts/variables/MAKEFLAGS: Add tests.
2024-08-04 16:00:48 -04:00
Paul Smith
49b955a50d * doc/make.texi (Overview): Update reference to POSIX.1-2024 2024-08-04 15:21:59 -04:00
Paul Smith
69038e62e0 * src/warning.h: Put warnings into alphabetical order.
* src/warning.c: Ditto.
* tests/scripts/options/warn: Fix tests for the new order.
2024-08-04 15:21:59 -04:00
Dmitry Goncharov
a9e3eb1eec [SV 65739] Add warning circular-dep.
Add a warning to control circular dependency detection.  Use "warn" as
the default action to be backward-compatible.

* src/warning.h (enum warning_type): Add warning type wt_circular_dep.
* src/warning.c (warn_init): Set default wt_circular_dep to w_warn.
* src/remake.c (update_file_1): Consult the circular-dep warning to
handle circular dependencies.
* tests/scripts/options/warn: Test --warn circular-dep flag.
* tests/scripts/variables/WARNINGS: Test .WARNINGS circular-dep flag.
* doc/make.texi: Document circular-dep warning.
* doc/make.1: Ditto.
2024-08-04 15:21:59 -04:00
Dmitry Goncharov
e3f938caf8 * tests/scripts/functions/shell: [SV 65323] Run huge var test in bash
The long variable name causes ksh to crash.  Some systems use ksh as
/bin/sh, so force bash if it's available else skip the test.
2024-05-06 14:11:17 -04:00
Dmitry Goncharov
40664fef1f [SV 65324] disable_builtins: Don't dereference NULL suffix_file
Make crashes when -r and MAKEFLAGS= are specified on the command line.

On startup make begins to process command line arguments.
During processing of "MAKEFLAGS=" make calls reset_makeflags, which in
turn calls disable_builtins, which dereferences null suffix_file.
Here is the backtrace.

0 disable_builtins main.c:3482
1 reset_makeflags main.c:3104
2 set_special_var variable.c:1325
3 do_variable_definition variable.c:1693
4 try_variable_definition variable.c:1889
5 handle_non_switch_argument main.c:3021
6 decode_switches main.c:3150
7 main main.c:1621

* src/main.c (disable_builtins): Avoid dereferencing null suffix_file.
* tests/scripts/features/suffixrules: Add a test.
2024-05-06 14:11:17 -04:00
Paul Smith
f7985ab827 * make.texi (How to Use Variables): [SV 65536] Rewrite this chapter
Re-reading this chapter I decided it was time to introduce a complete
rewrite, of at least parts of this.  Much of the enhancements added
over the years were in the wrong place or not clear.
2024-05-06 14:11:17 -04:00
Paul Smith
8339232a2f * .dir-locals.el: Correct bug reference regex format 2024-04-14 15:51:23 -04:00
Paul Smith
949952258e [SV 65537] Update to newer gnulib
* bootstrap.conf: Switch to gnulib stable-202401 branch.
* maintMakefile: Support an EXTRA_CFLAGS variable in maintainer mode.
* README.git: Describe how to use it.
2024-04-14 15:27:37 -04:00
Paul Smith
479c54f6ed * NEWS: Clean up UTF-8 issues 2024-04-14 15:27:12 -04:00
Paul Smith
033330e34c * doc/make.texi (Pattern Rules): Clarify that rules must have recipes. 2024-03-28 19:14:25 -04:00
Paul Eggert
61ee4578f5 * src/arscan.c (parse_int): Fix integer overflow test
Use intprops.h macros rather than trying to detect integer overflow by
hand, and doing it incorrectly.  Example of incorrect behavior:
if val == 3689348814741910323, base == 10, UINTMAX_WIDTH == 64, and
 *ptr == '0' then (val*base)+(*ptr-'0') yields 18446744073709551614
which is greater than val even though overflow has occurred.
Fortunately this bug could not be triggered on GNU/Linux hosts,
although it may be possible on platforms (if any) where struct ar_hdr
has members so large that they can represent integers that do not fit
int uintmax_t.
2024-03-28 19:08:13 -04:00
KO Myung-Hun
f289ece6cf * src/makeint.h (JOBSERVER_USE_FIFO): Do not define on OS/2.
mkfifo() on OS/2 is a dummy, it even returns a wrong value on error.
2024-03-28 19:08:13 -04:00
Paul Smith
d791fb4139 * src/variable.c (do_variable_definition) [W32]: Fix bad variable. 2024-03-28 19:08:13 -04:00
Marco Sirabella
0b91f42f58 * src/arscan.c (ar_name_equal): Support GNU ar's -P option. 2024-03-28 19:08:13 -04:00
Marco Sirabella
882d59c672 * tests/README: Fix sample run_make_tests command line. 2024-03-24 16:36:35 -04:00
Paul Smith
5fc62f8295 * doc/make.texi: GNU Make does set GNUMAKEFLAGS, to empty. 2024-03-24 16:29:14 -04:00
Paul Smith
3d4f3e0627 * doc/make.texi: Document temporary file name prefix
* src/posixos.c (jobserver_setup): Set prefix for FIFO temp file.
Ensure it can't conflict with a "normal" temp file.
* src/w32/w32os.c (os_anontmp): Set prefix for anon temp files.
2024-03-24 16:23:28 -04:00
Paul Smith
242603fa46 [SV 65268] Un-set append mode for stdout/stderr on exit
It turns out that options set on stdout/stderr last after exit.
Leaving append-mode enabled can break other facilities, so reset the
flags on stdout/stderr before we exit.

* src/os.h: Add a new fd_reset_append() to reset flags on FDs.
Modify fd_set_append() to return the old flags.
* src/posixos.c (fd_reset_append): Set provided flags on the FD.
(fd_set_append): Return the previous flags set on the FD.
* src/output.c (output_init): Preserve old flags for stdout/stderr.
(output_close): Reset flags for stdout/stderr.
* src/w32/w32os.c: Implement dummy methods.
2024-03-24 15:25:53 -04:00
Paul Smith
b8a2a4424b [SV 65273] configure.ac: Remove check for sys/timeb.h
GNU Make doesn't use ftime(); we only checked for this to work around
an error in the completely obsolete SCO 3.2 system.  Since ftime() is
deprecated, including sys/timeb.h has started throwing warnings on
newer systems so just remove it completely.
Reported by: Collin Funk <collin.funk1@gmail.com>

* configure.ac: Remove the check for sys/timeb.h.
* src/makeint.h: Remove the include of sys/timeb.h.
* src/config.h-vms: Don't define HAVE_SYS_TIMEB_H.
* src/config.h.W32: Ditto.
2024-03-24 15:25:18 -04:00
Jouke Witteveen
bfbf169b63 [SV 65448] intcmp: Compare values instead of magnitudes
* src/function.c (func_intcmp): Reverse comparison direction when
both arguments are negative.
* tests/scripts/functions/intcmp: Add tests and remove useless ones.
2024-03-24 14:08:59 -04:00
Paul Smith
21a538ce8f [SV 65359] doc/make.texi: Describe invalid export variable names 2024-03-24 14:05:45 -04:00
Paul Smith
3176b60566 [SV 64085] Handle .POSIX plus .IGNORE correctly
POSIX requires that a conforming makefile should not use -e if
 1) make is invoked with -i
 2) A .IGNORE target exists with no prerequisites
 3) The current target is a prerequisite of .IGNORE

* src/job.c (start_job_command): Add the target's flags when
constructing argv so it can check (3) above.
(construct_command_argv_internal): Don't set shellflags if it's not
set: this only happens if we're parsing for the slow path and we
don't need them.
(construct_command_argv): Don't allocate buffers if not needed.
When detecting "-ec", check the global ignore_errors_flag and the
current command line flags.
* tests/scripts/targets/IGNORE: Add tests for .IGNORE.
* tests/scripts/targets/POSIX: Add tests for the three cases above.
2024-02-04 19:41:50 -05:00
Dmitry Goncharov
07187db947 [SV 64822, SV 36486] Fix appending to a pattern specific variable
Appending to a pattern specific variable produces an incorrect value
in the presence of a command line definition or an env override of
the variable.  Also, fix pattern/target-specific appending to a
variable with origin override.

* At parse time record_target_var sets the value of a pattern
  specific variable to the value defined on command line or to the
  value of the env override.
* Later, at build time, recursively_expand_for_file appends this
  value of the variable (set in record_target_var) to the command
  line value again, regardless of the origin of the variable.

This patch modifies recursively_expand_for_file to avoid appending,
unless the origin of the variable beats or equals the origin of one
of the parent definitions of this variable.

Reported by Rob <robw9739@gmail.com>,
Brian Vandenberg <phantall@gmail.com>,
Markus Oberhumer <markus@oberhumer.com>.

* NEWS: Note the change.
* src/variable.c (do_variable_definition): Avoid merging a
pattern-specific variable with the parent definition when a command
line or env override is present.
* src/expand.c (recursively_expand_for_file): Avoid appending to a
pattern-specific variable, unless the origin of this pattern-specific
variable beats or equals the origin of one of the parent definitions
of this variable.
* doc/make.texi (Override Directive): Add missing cross-reference.
* tests/scripts/variables/append: Add tests.
2024-02-04 18:26:21 -05:00
Paul Smith
a493d9ab6c * NEWS: Clean up 2024-02-04 11:34:49 -05:00
Dmitry Goncharov
a382ac6cd1 [SV 64803] Set origin for unmodified variables after -e
Ensure the origin of all variables inherited from the environment is
"environment override" if -e is given.  Previously only variables
that were set in the makefile had this origin.

PDS: Most of these changes are from Dmitry but I slightly modified
the algorithm: instead of rearranging the way in which MAKEFLAGS is
parsed we reset the env_override value to the default before we
re-parse MAKEFLAGS, then we set the origin of all env vars to the
correct value based on the new setting.

* NEWS: Mention the change for backward-compatibility.
* src/main.c (main): Ensure MAKEFLAGS is always marked special.
(reset_makeflags): Set env_overrides back to default before parsing
MAKEFLAGS.
(decode_switches): Call reset_env_override() to check for changes.
* src/variable.h (reset_env_override): Declare a new function.
* src/variable.c (reset_env_override): Go through all env variables
and ensure the origin is correct based on env_overrides.
(set_env_override): Helper function for the hash.
* tests/scripts/functions/foreach: Fix tests.
* tests/scripts/functions/let: Ditto.
* tests/scripts/functions/origin: Ditto.
* tests/scripts/options/dash-e: Add tests.
2024-02-04 11:34:49 -05:00
Paul Smith
63b602e74f * tests/test_driver.pl: Add cd to the .run output file 2024-02-04 11:34:49 -05:00
Dmitry Goncharov
ec348f51d0 Replace target_var boolean with enum variable_scope
Replace the target_var boolean with an enum to distinguish between
global, target-specific, and pattern-specific variables when defining.

* src/variable.h (enum variable_scope): Introduce enum variable_scope.
Replace parameter target_var of type int with enum variable_scope.
* src/load.c (load_file): Ditto.
* src/main.c (handle_non_switch_argument): Ditto.
* src/read.c (eval_makefile): Ditto.
(eval): Ditto.
(do_define): Ditto.
(record_target_var): Ditto.
(construct_include_path): Ditto.
* src/variable.c (initialize_file_variables): Ditto.
(shell_result): Ditto.
(try_variable_definition): Ditto.
(do_variable_definition): Ditto.
2024-02-04 11:32:50 -05:00
Paul Smith
51e56a028e * doc/make.texi: Grammar improvements.
Reported-by: David Apps <davidapps3+gnu@gmail.com>
2024-01-28 14:21:00 -05:00
Paul Smith
1eff20f6f6 Support conditional modifiers on all assignment operators
Rework the single "?=" operator to instead allow a "?" modifier to be
prepended to ANY assignment operator.  If "?" is given then the
variable is assigned (using whatever operator comes next) if and only
if the variable is not already defined.  If it is defined then no
action is taken (the right-hand side is not expanded, etc.)

* NEWS: Announce this new feature.
* doc/make.texi: Modify the documentation around assignment operators.
* src/variable.h: Remove the f_conditional variable flavor.
(do_variable_definition): Add an argument specifying conditional.
* src/variable.c (parse_variable_definition): Use the existing flag
"conditional" to remember if we saw "?" rather than the flavor.
When we see "?" skip it and continue trying to parse an assignment.
(try_variable_definition): Pass condition to do_variable_definition().
(initialize_file_variables): Ditto.
(do_variable_definition): Check for conditional up-front: quit if set.
Remove handling of obsolete f_conditional flavor.
* src/read.c (eval_makefile): MAKEFILE_LIST is not conditional.
(do_define): Unset conditional for define with no operator.  Pass the
conditional flag to do_variable_definition().
(construct_include_path): .INCLUDE_DIRS is not conditional.
* src/load.c (load_file): .LOADED is not conditional.
* tests/scripts/variables/conditional: Add new tests.
2024-01-28 14:20:47 -05:00
Paul Smith
82708b3a3a Remove unnecessary parsing during makefile read
* src/read.c (make_word_type): Remove w_varassign from the enum.
(get_next_mword): This function is never called on a string in a place
where we might find a variable assignment.  Any variable assignments
have already been handled via try_variable_definition(), so we don't
need to check for them here.
* tests/scripts/variables/flavors: Check triple-colon assignment in
target-specific variables.
2024-01-27 16:40:36 -05:00
Paul Smith
828906b6dc Create a common method for skipping variable references
* README.git: Add some notes about using ASAN.
* src/makeint.h: Declare skip_references().
* src/misc.c (skip_reference): A new function that will skip over a
variable reference, counting matching open paren/brace characters.
* src/implicit.c (get_next_word): Replace code with skip_reference().
* src/read.c (conditional_line): Ditto.
(find_map_unquote): Ditto.
(get_next_mword): Ditto.
(parse_variable_definition): Ditto.
* src/function.c (handle_function): Make clear that the passed in
pointers are not modified if the function returns false.
* src/expand.c (expand_string_buf): Don't create local variables to
call handle_function() since it doesn't modify its arguments.
* src/job.c (new_job): Small simplifications.
2024-01-27 16:40:36 -05:00
Paul Smith
b936970956 * src/misc.c (writebuf, readbuf): Return a constant -1 2024-01-27 16:40:36 -05:00
Dmitry Goncharov
1e43a5d104 [SV 65211] Fix load and loadapi tests.
* scripts/features/load: Suppress unused variable compiler warnings.
* scripts/features/loadapi: Ditto.
2024-01-27 16:40:36 -05:00
Paul Smith
25049fef16 [SV 65172] Avoid buffer overruns when expanding for $(shell ...)
Reported-by: MIAOW Miao <guoyr_2013@hotmail.com>
Patch from: Henrik Carlqvist <hc981@poolhem.se>
Test from: Dmitry Goncharov <dgoncharov@users.sf.net>

* src/expand.c (recursively_expand_for_file): Check the variable name
before checking for equality so we don't overrun the buffer.
* tests/scripts/functions/shell: Add a test with a very long variable.
2024-01-27 16:40:36 -05:00
Paul Smith
31036e648f [SV 64571] Add --print-targets option
Add an option to print a list of targets defined in the makefiles.
Don't print targets of implicit rules, or special targets.  To
support this remember which files are deemed suffix rule targets.

Add a missing warning for single-suffix targets with prerequisites.

Suggested by many.  Sample implementation by Tim <tdhutt@gmail.com>.

* NEWS: Announce the new option and single-suffix warning.
* doc/make.1: Add --print-targets to the man page.
* doc/make.texi: Add --print-targets to the documentation.  Clean up
the text around the definition of suffix rules.
* src/main.c (print_targets_flag): New variable for --print-targets.
(switches): Add a new long option --print-targets.
(main): If the option was provided call print_targets() and exit.
* src/filedef.h (struct file): Add a "suffix" boolean value.  Remove
print_prereqs() since it's static.  Add new print_targets().
* src/file.c (rehash_file): Merge the new suffix value.
(print_prereqs): Used only locally: change to static.
(print_target): Print targets which are not suffix rule targets and
are not special targets.
(print_targets): Call print_target() on each file.
* src/rule.c (convert_to_pattern): Make maxsuffix local; it doesn't
need to be static.  Emit ignoring prerequisites for single-suffix
rules as well as double-suffix rules.  Remember which files are
actually suffix rules.
* tests/scripts/features/suffixrules: Test single-suffix behavior.
* tests/scripts/options/print-targets: Add tests for --print-targets.
2024-01-08 23:31:58 -05:00
Paul Smith
1ff728bff4 * src/makeint.h: Add an ARRAYLEN macro to compute array sizes
* src/main.c: Replace inline array length computation with ARRAYLEN.
* src/function.c: Ditto.
* src/read.h: Ditto.
2024-01-07 11:28:23 -05:00
Paul Smith
1161779ef8 * doc/make.texi (Text Functions): [SV 64339] Clarify pattern use. 2024-01-07 10:22:20 -05:00
Paul Smith
a80670ad41 * (all): Update Copyright year to 2024 2024-01-06 18:06:09 -05:00
Paul Smith
d86448fe5f [SV 64402] Correct locating "," in ifeq/ifneq conditionals
Ensure that we correctly skip the entirety of a macro or function
reference when searching for the "," separator in an ifeq/ifneq
conditional, including using "$," and also "${foo,bar}".  Note that
this change means that parenthesis OTHER than those used for variable
expansion are not considered special, any longer.

* NEWS: Announce the change.
* src/read.c (conditional_line): Skip variable references when looking
  for "," and ensure that we match closing parens/braces properly.
* tests/scripts/features/conditionals: Add tests for this behavior.
2024-01-06 17:42:40 -05:00
Dmitry Goncharov
33932663b0 [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>.
2024-01-06 17:39:43 -05:00
Jouke Witteveen
89bea82af3 * src/function.c (func_let): Don't edit nonexistent values
* tests/scripts/functions/let: Test trailing whitespace in value list.
2024-01-01 19:31:37 -05:00
Paul Smith
dd1980426e * doc/make.texi (Text Functions): [SV 64818] Remove redundant text 2024-01-01 19:24:37 -05:00
Paul Smith
2ce7e40822 * .clangd: Add configuration for the clangd LSP server 2024-01-01 19:24:37 -05:00
Paul Smith
b1e240c554 * doc/make.texi: [SV 64924] Add missing parenthesis 2023-11-26 23:21:55 -05:00
Paul Smith
7fa40eb4fc * doc/make.texi: Add a quick reference appendix 2023-11-26 23:21:06 -05:00
Paul Smith
8817efe46a * src/function.c (function_table_entry): Sort 2023-11-26 23:20:22 -05:00
Paul Smith
66adfb7c6f make.texi: Cleanup 2023-09-01 16:57:58 -04:00
Paul Smith
9af3e60f4d make.texi: Add an appendix with troubleshooting tips 2023-08-29 15:39:16 -04:00
Paul Smith
8061929963 doc/make.texi: Clean up references to GNU Make 2023-08-29 15:20:31 -04:00
Paul Smith
cd33c9a1e9 doc/make.texi: Remove unnecessary @node arguments 2023-08-29 14:44:50 -04:00
Paul Smith
c4ecd9d9eb bootstrap.conf: Update to the latest gnulib stable branch 2023-08-25 11:10:14 -04:00
Paul Smith
6b7f35cb0b * AUTHORS: Updates 2023-07-04 14:26:58 -04:00
Torbjörn SVENSSON
1000374759 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.
2023-07-04 14:26:58 -04:00
Torbjörn SVENSSON
8d76fb8778 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.
2023-07-01 12:49:24 -04:00
Torbjörn SVENSSON
ee366afbf1 * src/w32/compat/posixfcn.c (ttyname): Avoid const char* 2023-07-01 12:49:24 -04:00
Torbjörn SVENSSON
b686980c66 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.
2023-07-01 12:49:24 -04:00
Torbjörn SVENSSON
8e5c96c318 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.
2023-07-01 12:49:24 -04:00
Torbjörn SVENSSON
363bdaef8c Fix GCC compile warning declaration-after-statement on Windows
* src/w32/w32os.c (check_io_state): Move the HANDLE declarations.
2023-07-01 12:49:20 -04:00
Costas Argyris
b2bf660abc 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.
2023-06-19 13:29:52 -04:00
Paul Smith
04f4c2b8d9 [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.
2023-06-19 13:27:50 -04:00
Paul Smith
347316fdf6 * po/LINGUAS: Add support for Georgian translation 2023-06-19 10:05:19 -04:00
Paul Smith
1a03888afa * NEWS: Set a prerelease version 2023-06-19 10:05:19 -04:00
Paul Smith
07fcee35f0 [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.
2023-05-22 23:36:13 -04:00
Paul Eggert
c85b71a396 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.
2023-05-14 18:26:35 -04:00
Paul Eggert
032f784601 make -p buffer overrun fix with outlandish current time
* src/main.c (safer_ctime): New function.
(print_data_base): Use it.
2023-05-14 18:26:35 -04:00
Paul Eggert
78e6a89b19 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.
2023-05-14 18:26:35 -04:00
Paul Smith
1748e66414 [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.
2023-05-14 18:26:35 -04:00
Paul Smith
8e0e6c678f 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.
2023-05-07 16:51:06 -04:00
Paul Smith
3f28ec2f58 * 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.
2023-05-07 16:51:06 -04:00
Paul Smith
24a84f99bb * 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.
2023-05-07 16:51:06 -04:00
Paul Smith
05c86bfcb2 * tests/scripts/features/comments: Add missing "1;" 2023-05-06 14:45:09 -04:00
Dmitry Goncharov
06c75a35b9 [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.
2023-04-30 09:41:02 -04:00
Dmitry Goncharov
ebe0a1c9f1 [SV 64115] Suppress warnings about undefined GNUMAKEFLAGS
* src/variable.c (defined_vars): Add GNUMAKEFLAGS to defined variables.
* tests/scripts/options/warn: Add a test.
2023-04-30 09:40:50 -04:00
Dmitry Goncharov
0880e5c86a [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.
2023-04-30 09:40:50 -04:00
Paul Smith
0e06c75889 * tests/scripts/features/double_colon: Test parallel double-colon rules
Original test proposed by Dmitry Goncharov <dgoncharov@users.sf.net>
2023-04-30 09:40:50 -04:00
Dmitry Goncharov
5340a3d5d1 * src/remake.c (update_goal_chain): [SV 64016] Avoid double negation 2023-04-30 09:40:47 -04:00
Paul Smith
fec72ea308 * NEWS: Note the change to the tests suite 2023-04-23 11:35:02 -04:00
Paul Smith
6cf6311332 * src/warnings.c (decode_warn_actions): [SV 63990] Handle errors 2023-04-03 08:05:54 -04:00
Paul Smith
c4329fb953 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.
2023-04-03 07:48:51 -04:00
Paul Smith
971b02d58e 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).
2023-04-02 17:32:09 -04:00
Paul Smith
fdd61fc068 * 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.
2023-04-02 17:30:27 -04:00
Dmitry Goncharov
80727d709c [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.
2023-04-02 11:12:19 -04:00
Dmitry Goncharov
cd46baab90 [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.
2023-04-02 11:12:11 -04:00
Paul Smith
54b3202f8d [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.
2023-04-02 10:29:37 -04:00
Paul Smith
5111087e12 * NEWS: Mention the new .WARNINGS variable 2023-04-02 10:29:19 -04:00
Paul Smith
0552b0abc8 * doc/make.texi: Clean up function and variable references
Avoid unnecessary extra remarks in the index and remove duplicates.
2023-04-02 10:02:18 -04:00
Paul Smith
c2792d6129 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.
2023-04-02 10:02:18 -04:00
Paul Smith
a0d1e76d60 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.
2023-04-02 10:02:18 -04:00
Paul Smith
03ecd94488 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.
2023-04-01 11:13:12 -04:00
Paul Smith
2611e1991f 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.
2023-04-01 11:13:12 -04:00
Paul Smith
9db74434cd 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.
2023-04-01 11:13:12 -04:00
Paul Smith
23f70b0cb8 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.
2023-04-01 11:13:12 -04:00
Paul Smith
78c8c44326 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.
2023-04-01 11:13:12 -04:00
Paul Smith
caf1d4c28f 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.
2023-03-26 16:48:48 -04:00
Paul Smith
f99d083418 * 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.
2023-03-26 09:24:49 -04:00
Paul Smith
a367c0640f 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.
2023-03-26 09:24:06 -04:00
Paul Smith
3088e3e698 [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
2023-03-25 16:02:59 -04:00
Paul Smith
bf7f690202 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 "$"
2023-02-26 17:30:15 -05:00
Paul Smith
5d1fe2b16d * 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.
2023-02-26 17:15:56 -05:00
Paul Smith
8285852e55 Clean up some preprocessor operations 2023-01-16 13:01:09 -05:00
Paul Smith
9b9f3351d1 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.
2023-01-16 00:24:13 -05:00
Paul Smith
6f3e9e9b84 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.
2023-01-16 00:03:13 -05:00
Paul Smith
6128c3e266 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.
2023-01-15 18:27:13 -05:00
Paul Smith
ceb52b5d1b 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.
2023-01-15 18:04:36 -05:00
Paul Smith
d4692df20d 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.
2023-01-15 17:32:15 -05:00
Paul Smith
e6bd61d949 * README.git: Clarify some release steps
* README.in: Update some info and remove some obsolete notes.
2023-02-26 15:52:25 -05:00
Paul Smith
fcefae5ec9 * NEWS: Update for the next release
* configure.ac: Set the version for the next release.
2023-02-26 15:40:18 -05:00
Paul Smith
d66a65ad5a 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.
2023-02-26 13:46:22 -05:00
Paul Smith
8093e2eee3 * tests/scripts/options/dash-l: Simplify the test via the helper
* tests/thelp.pl: Add "exist" and "noexist" operators.
2023-02-26 13:46:02 -05:00
Paul Smith
74dab224b3 * README.W32: Add Windows 11
* build_w32.bat: Ditto.
2023-02-21 20:54:48 -05:00
Paul Smith
8b8cc3a825 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.
2023-02-21 20:53:48 -05:00
Dmitry Goncharov
9b6fedef1c * src/main.c (main): Install suffix rules near pattern updates 2023-02-21 00:04:13 -05:00
Paul Smith
8ddb628927 * Makefile.am: Add mkconfig.h to the test error file 2023-02-20 23:29:26 -05:00
Dmitry Goncharov
e9dd614d73 [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.
2023-02-20 15:17:24 -05:00
Paul Smith
f5dc17ac2d * tests/scripts/misc/general4: Only test empty PATH on UNIX 2023-02-20 11:11:59 -05:00
Paul Smith
ac159491da * gl/modules/make-glob: Avoid glibc glob if bug #866 is present 2023-02-19 17:43:12 -05:00
Paul Smith
4436655568 * tests/scripts/features/include [AIX]: Set explicit timestamps 2023-02-19 15:35:22 -05:00
Paul Smith
549fc56102 * tests/scripts/features/archives: Set CC properly 2023-02-19 14:49:56 -05:00
Paul Smith
37e0010743 Prerelease GNU Make 4.4.0.91
* NEWS: Update the date.
* configure.ac: Change the release.
2023-02-19 09:53:26 -05:00
Paul Smith
536c3e2b37 * src/makeint.h [CYGWIN]: Use pipe mode for the jobserver 2023-02-19 08:52:02 -05:00
Paul Smith
4c9b922560 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.
2023-02-19 01:27:22 -05:00
Paul Smith
2449ef3c88 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.
2023-02-19 01:25:57 -05:00
Paul Smith
fbf8c940e5 * src/makeint.h (WIN32_LEAN_AND_MEAN) [Windows]: Don't redefine.
Suggested for tcc builds by Christian Jullien <eligis@orange.fr>.
2023-02-19 01:02:16 -05:00
KO Myung-Hun
62194015fa * src/misc.c (ttyname) [OS/2]: Add an implementation for OS/2 kLIBC 2023-02-19 01:02:16 -05:00
Paul Smith
c85f68c4e9 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.
2023-02-19 01:02:16 -05:00
Paul Smith
ffa28f3914 [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.
2023-02-05 10:22:13 -05:00
Paul Smith
8f03e69af0 * doc/make.texi: Fix typo (reported by <mao492479407@163.com>) 2023-02-05 09:42:49 -05:00
Paul Smith
e819fc2022 * tests/scripts/variables/MAKEFLAGS: Fix some Perl warnings 2023-02-04 13:12:32 -05:00
Dmitry Goncharov
f21cd822a3 * doc/make.texi: [SV 63689] Fix typos in examples 2023-01-28 13:09:36 -05:00
Paul Smith
2f336608d8 * src/job.c: Switch from bit operators to flags macros
* src/remake.c: Ditto.
2023-01-28 13:05:08 -05:00
Paul Smith
faedfdb0af [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.
2023-01-28 13:04:47 -05:00
Dmitry Goncharov
9709d273b2 * tests/scripts/features/archives: [SV 63688] Quote cmd line vars 2023-01-28 09:46:23 -05:00
Paul Smith
eb0bd1aaec * README.in: Mention README.z/OS 2023-01-28 09:28:18 -05:00
Paul Smith
d2bf740e77 * 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.
2023-01-15 16:35:57 -05:00
Paul Smith
a8890796a4 * tests/scripts/features/archives: Use the configured compiler for CC 2023-01-15 16:35:57 -05:00
Paul Smith
be6bb0fd68 * configure.ac: Delay setting HAVE_GUILE until we're sure 2023-01-15 10:27:34 -05:00
Paul Smith
db351fe85b 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.
2023-01-14 17:07:04 -05:00
Paul Smith
8a0d7fd4ef * tests/scripts/features/reinvoke: Warn about closing STDIN.
* tests/scripts/features/temp_stdin: Ditto.
* tests/scripts/options/dash-f: Ditto.
2023-01-11 20:35:11 -05:00
Eli Zaretskii
f51fc130cc [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.
2023-01-11 15:44:56 +02:00
Paul Smith
b99b6cdf3c 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.
2023-01-08 18:44:25 -05:00
Paul Smith
36f955b0e8 [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().
2023-01-08 18:06:54 -05:00
Paul Smith
a275f4e9ab [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.
2023-01-08 16:40:55 -05:00
Paul Smith
11444fb001 [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.
2023-01-08 10:45:38 -05:00
Paul Smith
0de7a0d3bf 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.
2023-01-08 10:45:24 -05:00
Paul Smith
1656cd051c 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.
2023-01-08 10:24:09 -05:00
Paul Smith
31a1337c23 * gl/lib/glob.c: Don't try to support _LIBC, don't use __stat() 2023-01-07 22:02:06 -05:00
Paul Smith
5ae02ff8c1 [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.
2023-01-03 02:14:24 -05:00
Paul Smith
1ceeb8c64b [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.
2023-01-03 01:57:35 -05:00
Paul Smith
8791d2b38e [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.
2023-01-02 23:02:33 -05:00
Paul Smith
f91b8bbb34 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.
2023-01-02 22:53:05 -05:00
Paul Smith
8dc66b6c31 * doc/make.texi (Special Targets): Fix minor typo
Reported by Andrey Melnikov <vafilor@gmail.com>.
2023-01-02 00:13:28 -05:00
Paul Smith
ccbaf3861d 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.
2023-01-01 17:05:12 -05:00
Paul Smith
c4fbfe8b5e * maintMakefile: Add missing quote 2023-01-01 17:05:12 -05:00
Paul Smith
e7ce3a655e Convert references from "GNU make" to "GNU Make" 2023-01-01 17:05:12 -05:00
Paul Smith
c580ebae8d 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.
2023-01-01 17:05:12 -05:00
Paul Smith
56d2978141 Update the copyright year on all files 2023-01-01 10:06:01 -05:00
Paul Smith
c91b269f66 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
2022-12-31 13:21:09 -05:00
Paul Smith
29f453739f 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.
2022-12-31 10:51:24 -05:00
Paul Smith
937e9aa32d 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.
2022-12-26 13:10:26 -05:00
Paul Smith
8e9c7db1e1 * NEWS: Add a section for the next release
Add a note for the MAKEFLAGS enhancements.
2022-12-24 15:48:48 -05:00
Paul Smith
15dfad96d7 [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.
2022-12-24 10:52:49 -05:00
Paul Smith
76d2e5d98d [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.
2022-12-24 10:52:43 -05:00
Paul Smith
a581146562 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.
2022-12-20 02:14:18 -05:00
Paul Smith
b2c7446023 * tests/test_driver.pl: Remember if something failed and report it 2022-12-20 02:07:28 -05:00
Paul Smith
89427039c3 [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.
2022-12-19 00:20:06 -05:00
Dmitry Goncharov
7d8756a4a3 [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.
2022-12-18 20:06:38 -05:00
Dmitry Goncharov
8e805c7ba6 [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.
2022-12-18 20:06:38 -05:00
Dmitry Goncharov
132528b266 [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.
2022-12-18 20:06:38 -05:00
Dmitry Goncharov
8f9e7722ff [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.
2022-12-18 20:06:38 -05:00
Dmitry Goncharov
95c2db7b8d [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.
2022-12-18 20:06:38 -05:00
Paul Smith
5d1b757517 [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.
2022-12-18 20:06:38 -05:00
Paul Smith
c0023150f1 * src/job.c (new_job): [SV 63510] Trace phony prerequisite rebuilds 2022-12-18 14:44:17 -05:00
Paul Smith
a89eef87e6 * configure.ac: Update for a new release
* README.git: Add some packages needed for building from Git.
* AUTHORS: Updates.
2022-12-18 14:44:17 -05:00
Dmitry Goncharov
6164608900 [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.
2022-11-28 10:50:55 -05:00
Paul Smith
a99183ed2b * doc/make.texi: Use $(firstword) rather than $(word 1,) 2022-11-28 10:50:55 -05:00
Dmitry Goncharov
dc2d963989 [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.
2022-11-28 10:50:55 -05:00
Paul Smith
53b8f6a5da * src/main.c (main): [SV 63373] Don't use macros with memcmp()
Reported by djm <mccannd@uk.ibm.com>
2022-11-16 10:00:34 -05:00
Paul Smith
6c1a6dd77c Add specific hints for errors due to invalid conditionals
* src/read.c (eval): If "missing separator" appears to be due to
missing space after ifeq/ifneq, give a hint about the error.
* tests/scripts/misc/failure: Check for these types of failures.
* tests/scripts/variables/special: Move error checking unrelated
to special variables, to misc/failure.
2022-11-15 10:50:34 -05:00
Dmitry Goncharov
1b51ba1f5d [SV 63333] Be more lenient when failing to create temporary files
If make cannot create a temporary lock file for output sync, continue
without output sync enabled rather than dying.

However, if make cannot store a makefile from stdin to a temporary
file that is still a fatal error.

* misc.c (get_tmppath): Keep running on failure to generate a
temporary file name.
(get_tmpfd): Keep running on failure to get a temporary file.
(get_tmpfile): Keep running on failure to open a temporary file.
Ensure memory is freed if we return an error.
* posixos.c (os_anontmp): Keep running on failure to open an
anonymous temporary file.
* output.c (setup_tmpfile): Print an error on failure to create an
output sync lock file.
* main.c (main): Die on failure to store makefile from stdin to a
temporary file.
* tests/scripts/features/output-sync: Add tests.
* tests/scripts/features/temp_stdin: Ditto.
2022-11-13 16:34:01 -05:00
Paul Smith
4c9d87f4ae Keep going if we can't connect to the jobserver
* src/posixos.c (jobserver_parse_auth): Don't invoke fatal() if we
can't connect to an existing jobserver: just keep going without it.
* src/w32/w32os.c (jobserver_parse_auth): Ditto.
* tests/scripts/features/jobserver: Add a test for invalid FIFO
auth files.
2022-11-13 10:39:48 -05:00
Paul Smith
bb5df35133 * src/dir.c (dir_contents_file_exists_p): Show dir name in error.
If we fail to read a directory show the directory name in the error
message.  Pass struct directory instead of directory_contents to
allow that.
(dir_file_exists_p): Change dir_contents_file_exists_p caller.
(open_dirstrem): Ditto.
2022-11-13 10:39:48 -05:00
Paul Smith
92ab2e642d * src/main.c (main): [SV 63307] Handle SIGPIPE as a fatal signal
Always ignoring SIGPIPE is visible to child processes.
2022-11-13 10:39:48 -05:00
Paul Smith
deb4ff272a [SV 63315] tests: Simplify TERM signaling
Tests that try to kill the make process were not behaving as expected
on OpenBSD: the signal was sent from make to its children but the
sleep didn't die.  Something odd about the way the shell treats TERM.
To reduce platform dependencies add "term" to the helper tool and run
that instead of kill / sleep.

* tests/thelp.pl: Add a new operation "term" that takes a PID.
* tests/scripts/features/output-sync: Use it.
* tests/scripts/features/temp_stdin: Ditto.
2022-11-13 10:39:48 -05:00
Paul Smith
e80ce6fc90 [SV 63315] Allocate function names when defining functions
* src/function.c (define_new_function): Don't keep a pointer to the
user-provided name of a user-defined function: if the .so is unloaded
it will point to garbage.  Add the name to the strcache instead.
2022-11-13 10:39:48 -05:00
Paul Smith
d71c0bb0ce tests: Don't convert \ to / when checking regex's
When tests compare the output they will try converting backslashes
to slashes to see if that works.  When we compare using regex's,
we can't do that because backslashes can escape special characters.

* tests/test_driver.pl (compare_output): Clean up this function.
(compare_answer_vms) [VMS]: Comparing answers on VMS is complex;
move all of it into its own function returning 0/1.
(compare_answer): A new function to compare answers: return 0/1.
Remember the CRLF->LF conversion forever; only check \ -> / when
we compare strings, not regex's.
2022-11-13 10:39:48 -05:00
Justine Tunney
090d99dd2d * src/hash.c (jhash_string): Help the compiler optimize the hash
Invoke memcpy() with a constant length, where possible.

Copyright-paperwork-exempt: yes
2022-11-13 10:38:50 -05:00
Paul Smith
6b45f89adb * src/config.h.W32 [TCC]: Only redefine strtoll if not defined 2022-11-12 10:34:35 -05:00
Eli Zaretskii
11f7198f64 * src/config.h.W32: Fix last change. 2022-11-09 15:15:20 +02:00
Eli Zaretskii
4321c5e562 Fix build with Tiny C
* src/config.h.W32 (strtoll, strtoull) [__TINYC__]: Redirect to
_strtoi64 and _strtoui64, respectively.  Reported by Christian
Jullien <eligis@orange.fr>.
2022-11-05 16:46:58 +02:00
Paul Smith
ed493f6c91 Release GNU Make 4.4
* NEWS: Update the version and date.
* configure.ac: Update the version.
* doc/make.texi: Update the EDITION.
2022-10-31 02:23:04 -04:00
Paul Smith
7c3260bbdd * README.git: Update and clarify release operations 2022-10-31 02:23:04 -04:00
Paul Smith
38b19976f5 Fix issues found by ASAN and Coverity
* tests/test_driver.pl: Preserve the LSAN_OPTIONS variable.
* tests/scripts/targets/ONESHELL: Don't set a local variable.
* tests/scripts/functions/let: Test empty let variable.
* src/posixos.c (osync_parse_mutex): Free existing osync_tmpfile.
* src/misc.c (get_tmpfd): Set umask() before invoking mkstemp().
* src/ar.c (ar_parse_name): Check invalid name (shouldn't happen).
* src/function.c (define_new_function): Free previous function entry
when replacing it with a new one.
* src/job.c (child_execute_job): Initialize pid for safety.
(construct_command_argv_internal): In oneshell mode ensure that the
returned argv has the right format (0th element is a pointer to the
entire buffer).
2022-10-31 02:23:04 -04:00
Paul Smith
1dd52ab472 Avoid C99 constructs
Although gnulib requires C99, most of the code does compile with a
C90 compiler (perhaps with a lot of warnings).  Reinstate our C90
configuration test, and clean up a few C99 things that crept in.

* src/job.c (construct_command_argv_internal): Don't use loop-local
variables or C++ comments.
* src/read.c (eval_makefile): Don't use loop-local variables.
2022-10-29 13:36:21 -04:00
Paul Smith
92789aa2e7 * build.sh: Allow a "keep-going" mode during builds 2022-10-29 13:36:21 -04:00
Paul Smith
4e18732a1d tests: Avoid the use of File::Temp->newdir()
This was added in Perl 5.8 but some systems still only provide older
versions such as Perl 5.6.  We don't really need it anyway.
Paul Eggert <eggert@cs.ucla.edu> reported this issue.

* tests/README: Update this to be a bit more modern.
* tests/test_driver.pl: Delete the $TEMPDIR variable.
* tests/scripts/features/temp_stdin: Use $temppath not $TEMPDIR.
2022-10-29 13:36:21 -04:00
Paul Smith
11f9da227e * src/posixos.c (os_anontmp): [SV 63287] Only fail O_TMPFILE once
Reported by Dmitry Goncharov <dgoncharov@users.sf.net>.
2022-10-29 13:36:21 -04:00
Paul Smith
b92340a1ea [SV 62174] Force locale to be "C" before retrieving error messages
We attempt to do this with POSIX::setlocale() but apparently on some
systems (AIX) this isn't sufficient.  So, in addition force the LC
environment variables to use "C".
Reported by Dmitry Goncharov <dgoncharov@users.sf.net>.

* tests/run_make_tests.pl: Move the global setup into set_default().
Force the %ENV locale variables to use the ones we'll use when running
make, then reset them back again after we find error messages.
2022-10-28 17:39:06 -04:00
Paul Smith
8064aee4f9 * src/job.c: [SV 63185] Don't use ifdef with HAVE_DECL_* macros 2022-10-27 15:20:40 -04:00
Paul Smith
cf78e65fda * tests/scripts/features/exec: Don't test with C shells
Using C shells (csh, tcsh) with make is known to be problematic due
to incorrect ways it handles open file descriptors, at least.  If
the user's shell is *csh then don't try it during exec tests.
2022-10-25 14:49:10 -04:00
Paul Smith
04f0d8427f Increase the test framework timeout from 5s to 60s
It seems that some of the test environments hit the 5s timeout on
some tests.  Since it doesn't really matter, as long as we don't
hang forever, increase the timeout to 60s.

* tests/test_driver.pl: Increase $test_timout to 60.  We don't need
to handle VMS timeouts specially anymore.
* tests/scripts/features/parallelism: We don't need to override the
default timeout anymore.
* tests/scripts/features/patternrules: Remove confusing comment.
2022-10-25 14:44:26 -04:00
Paul Smith
f8401ad28b * Makefile.am (check-regression): Add a random suffix to results file
Put the results into a subdirectory for easy unpacking.
* .gitignore: Ignore it.
2022-10-25 14:42:52 -04:00
Paul Smith
e4b3bf7f97 Release GNU Make 4.3.92
* configure.ac: Modify the release version.
* NEWS: Update the version and date.
2022-10-24 02:14:42 -04:00
Paul Smith
d18a87d0a4 [SV 63260] Don't recurse forever if setup_tmpfile() fails
If we fail during setup_tmpfile() we'll try to write an error, which
will invoke setup_tmpfile() again, etc.  Avoid infinite recursion.
Original patch by Dmitry Goncharov <dgoncharov@users.sf.net>

* src/output.c (setup_tmpfile): Remember we're in this function and
return immediately if we enter it during recursion.
(message): Remember the starting location and use that instead of
fmtbuf.buffer.
(error): Ditto.
(fatal): Ditto.
2022-10-24 01:50:12 -04:00
Paul Smith
41c35f2ffe * src/output.c (_outputs): Don't use invalid output sync FDs
Just write to stdout/stderr in this situation.
2022-10-24 01:50:12 -04:00
Paul Smith
deb4a42c3e * src/misc.c (get_tmpdir): Report errors if tmpdirs are invalid
* src/main.c (main): Set up initial temporary directories.
2022-10-24 01:50:12 -04:00
Dmitry Goncharov
252c26bd20 * src/posixos.c (os_anontmp): If O_TMPFILE fails try dup() method. 2022-10-23 18:41:50 -04:00
Paul Smith
6f8da5f4b8 * src/rule.c (get_rule_defn): Don't use STRING_SIZE_TUPLE in mempcpy
If mempcpy() is a macro then STRING_SIZE_TUPLE won't compile.
2022-10-23 18:41:50 -04:00
Paul Smith
c46b5a9e0e Provide a maintainer-only debug method
Generating debug logs to stdout or stderr makes it impossible to
run tests etc. so create a dumb DBG facility to log to a temp file.
This exists only in maintainer mode and the DBG macro gives a
compile error if it's used in non-maintainer mode.

* src/makeint.h (DBG): Call dbg() in maintainer mode, else error.
(dbg): Define it in maintainer mode.
* src/misc.c (dbg): Open a log file for append, write, then close.
2022-10-23 18:41:50 -04:00
Paul Smith
b4157d2ff4 * configure.ac: Check that we can link with Guile
On multi-arch systems we may be able to find the header file but
not successfully link the library.
2022-10-22 22:40:26 -04:00
Paul Smith
f364e0d8d6 Set PATH_MAX on systems without a default value
Some systems (HURD) use fully-dynamic pathnames, with no limit.
We can't support this without significant effort so for now set
PATH_MAX to a large value.

* src/makeint.h: Set PATH_MAX to 4096 if not set and MAXPATHLEN
is also not set.  Remove MAXPATHLEN setting: we won't use it.
* src/misc.c (get_path_max): If we can't get the path max via
pathconf() use the default PATH_MAX.
* src/dir.c (find_directory) [W32]: Use MAX_PATH not MAXPATHLEN.
(local_stat) [W32]: Ditto.
* src/job.c (create_batch_file) [W32]: Ditto.
* src/remake.c (name_mtime) [W32]: Ditto.
* src/w32/w32os.c (os_anontmp) [W32]: Ditto.
2022-10-22 22:40:26 -04:00
Paul Smith
bb0c05a7f0 [SV 63098] Enhance detection of missing peer also-make targets
The previous attempt to detect missing peer targets for implicit
rules had some holes.  Move the detection to notice_finished_file().

* src/remake.c (check_also_make): If we don't have the current mtime
for the file, obtain it.
(update_goal_chain): Don't call check_also_make() here.
(check_dep): Ditto.
(notice_finished_file): If we finished running an implicit rule that
has also_make targets, invoke check_also_make().
2022-10-22 22:40:26 -04:00
Paul Smith
f987d181c4 Collect failure details when the regression tests fail
* README.in: Add a section on running regression tests.
* Makefile.am (check-regression): Capture the test run output, and
on failure collect configure and test results into a tar file.
2022-10-22 22:40:26 -04:00
Paul Smith
cad3ddd165 Enhance tests to work on different systems
The GNU platform testers reported a number of test errors on
different systems; try to address them.

* tests/thelp.pl: A number of tests timed out with a 4-second
timeout.  Increase the default timeout to 10 seconds.
* tests/run_make_tests.pl: Executing directories on cygwin behaves
differently in Perl than make so skip these tests there.
* tests/scripts/options/symlinks: Check for the symlink feature
in make, rather than whether the system supports them.
* tests/scripts/features/implicit_search: On some systems "false"
exits with a different exit code.  Use the helper instead.
* tests/scripts/features/loadapi: Ditto.
* tests/scripts/features/output-sync: Sleep before make -f bar in
the first test as well as the second one.
* tests/scripts/features/exec: Skip on cygwin, which seems to
be "UNIX" but where scripts don't run normally.
* tests/scripts/misc/fopen-fail: Skip on cygwin, where make
eventually exits with exit code 0 and no error messages.
2022-10-22 22:37:49 -04:00
Dmitry Goncharov
54214176b1 [SV 63243] tests: Avoid SIGTERM racing with make error messages
Original patch from Frank Heckenbach <f.heckenbach@fh-soft.de>.

* tests/scripts/features/output-sync: Introduce a sleep to let make
write its error message.  Some systems use different names for
SIGTERM so match with a regex.
* tests/scripts/features/temp_stdin: Ditto.
2022-10-22 10:02:41 -04:00
Dmitry Goncharov
c2f92c980f [SV 63236] Fix getloadavg related error message on AIX
On AIX getloadavg keeps errno intact when it fails, resulting in a
bogus error message from make.

* src/job.c (load_too_high): Reset errno before calling getloadavg.
2022-10-22 09:45:40 -04:00
Dmitry Goncharov
5b1ca277ca [SV 63248] Ignore SIGPIPE
Don't terminate when make's output is redirected to a pipe and the
reader exits early; e.g.:
  $ echo 'all:; sleep 2' | make -f- -j2 -O |:

This lets us unlink temporary files, and tell the user that make was
not able to write its output.
Reported by Frank Heckenbach <f.heckenbach@fh-soft.de>.

* src/main.c (main): Ignore SIGPIPE.
* src/posixos.c (osync_clear): Fix a memory leak.
2022-10-22 09:45:40 -04:00
Paul Smith
7c71df5695 * NEWS: Release GNU make 4.3.91 2022-10-18 14:37:47 -04:00
Paul Smith
a0956c1803 * AUTHORS: Update the authors list. 2022-10-18 14:37:47 -04:00
Paul Smith
4ec74e568d * NEWS: Use GNU Make instead of GNU make
* README.git: Ditto.
* README.Amiga: Ditto.
* README.DOS: Ditto.
* README.OS2: Ditto.
* README.VMS: Ditto.
* README.W32: Ditto.
* README.customs: Ditto.
* make-gdb.py: Ditto.
* tests/run_make_tests.pl: Ditto.
2022-10-18 14:37:47 -04:00
Paul Smith
d9fc1ac5d2 Update URLs to use https rather than http
* (all): Change http:// to https://
* README.W32: Remove invalid link to mingw.org.
2022-10-18 14:37:47 -04:00
Paul Smith
9f55e9fd13 Rework temp file handling to avoid GNU libc warnings
Original patch provided by Paul Eggert <eggert@cs.ucla.edu>.
GNU libc will generate a link-time warning if we use mktemp() even
though we are using it safely (we only use it with mkfifo()).
Avoid this and clean up some handling.

First, check all calls related to temporary files and exit with a
fatal error and a useful message if we can't obtain them.  In some
situations it might be possible to continue with reduced capability
but it's not worth the effort.

On POSIX systems we can create anonymous temp files using O_TMPFILE
if it's supported, else if we're using the default location and we
have dup(2), we can use standard tmpfile() and get an FD from it.

If we need a named temp file and FILE* and we have mkstemp() we can
use that, else if we have fdopen() we can get a temp FD and open it.
If none of those are available all we can do is generate a temp name
then open it with fopen() which is not secure.

* src/makeint.h (get_tmpdir): Declare it for use elsewhere.
* src/misc.c (get_tmpdir): Make it public not static.
(get_tmptemplate): Simplify the implementation.
(get_tmppath): Only define this if we have to have it to avoid
warnings from GNU libc.
(get_tmpfd): Generate fatal errors on error.
(get_tmpfile): Ditto.  Open files in "wb+" mode to match tmpfile().
Require a filename pointer (all callers want it).
* src/os.h (os_anontmp): Implement for posixos.c as well.
* src/posix.c (jobserver_setup): Don't use mktemp to avoid GNU libc
errors.  Instead construct the FIFO name based on the PID.
(osync_setup): get_tmpfd() can't fail so don't check it.
(os_anontmp): If the system supports O_TMPFILE use it.  If not, and
we want to create the temporary file in the default directory, we
can use tmpfile() then use dup() to copy the file descriptor.
* src/main.c (main): get_tmpfile() can't fail.
* src/vmsjobs.c (child_execute_job): get_tmpfile() can't fail.
2022-10-18 14:20:44 -04:00
Paul Smith
7bb7bb4ba4 Add ISDIRSEP() helper macro and use it
Create a ISDIRSEP() macro to check for directory separator chars
using the stopchar_map, and replace inline checks and explicit
STOP_SET calls with this macro.

* src/makeint.h (ISDIRSEP): Create the macro using MAP_DIRSEP.
* src/dir.c (find_directory): Replace inline checks with ISDIRSEP.
(file_exists_p): Ditto.
(file_impossible): Ditto.
(file_impossible_p): Ditto.
(local_stat): Ditto.
* src/file.c (lookup_file): Ditto.
* src/function.c (abspath): Ditto.
* src/job.c (_is_unixy_shell): Ditto.
(is_bourne_compatible_shell): Ditto.
(construct_command_argv): Ditto.
* src/main.c (find_and_set_default_shell): Ditto.
(main): Ditto.
* src/read.c (eval): Ditto.
(parse_file_seq): Ditto.
* src/remake.c (name_mtime): Ditto.
* src/vpath.c (construct_vpath_list): Ditto.
2022-10-18 14:20:44 -04:00
Paul Smith
b79791533b Add preprocessor macros for different platforms
* configure.ac: MK_CONFIGURE shows config.h was generated by configure.
* src/config.ami: Define MK_AMIGAOS.
* src/config.h-vms: Define MK_VMS.
* src/configh.dos: Define MK_DJGPP.
* src/config.h.W32: Define MK_W32 and WINDOWS32.
* src/build_w32.bat: Let WINDOWS32 be defined by config.h.  Remove
unused setting of WIN32.
* src/job.c: Clean up use of WIN32.
* src/main.c: Ditto.
* tests/scripts/features/default_names: Ditto.
2022-10-18 14:20:44 -04:00
Paul Smith
9d24d41801 Check for recipe line count overflow before it overflows
awk 'BEGIN {
       print "x:"
       for (i = 0; i < 65536; i++)
         printf "\techo %d\n", i}
    ' | make -f -

Outputs only "make: 'x' is up to date."  Larger values run only the
lines above 65536.  Reported by Paul Eggert <eggert@cs.ucla.edu>.

* src/commands.c (chop_commands): Check the line count before it has
a chance to overflow.  Use size_t for max count so it can't overflow.
Remove stray 'd' in diagnostic.
2022-10-18 14:20:44 -04:00
Paul Smith
2d943d3d2e Remove template files to simplify distribution creation
The README templates were not useful since the replacement step
didn't have anything to replace: rename them.

Rather than creating template files for the config variants, create
mkconfig.h.in containg PACKAGE_* variables to be replaced, and have
config variant header files include it.  Note on POSIX we don't use
this, and continue to generate a single config.h.in file.

Use config.status to convert the README.in and mkconfig.h.in files
during distribution creation.

Modify all users of VERSION to use PACKAGE_VERSION instead.

* configure.ac: Use GNU Make not GNU make as the package name.
* README.in: Use GNU Make not GNU make.
* README.git: Remove references to README.W32.template.
* .gitignore: Update for new behavior.
* Basic.mk.template: Remove unused posix_SOURCES and VERSION, and
references to unshipped mk/Posix.mk
* Makefile.am: Add src/mkconfig.h as an extra dist file.
* bootstrap.bat: Rewrite mkconfig.h.in to mkconfig.h
* maintMakefile: Remove obsolete template files; add mkconfig.h.in.
* prepare_vms.com: Rewrite mkconfig.h.in to mkconfig.h
* mk/VMS.mk: Fix incorrect header file prerequisite.
* src/mkconfig.h.in: New file containing PACKAGE variables.
* src/config.ami: Include mkconfig.h.
* src/config.h.W32: Ditto.
* src/configh.dos: Ditto.
* src/config.h-vms: Ditto.
* src/version.c: Use PACKAGE_VERSION not VERSION.
2022-10-18 14:20:44 -04:00
Juan M. Guerrero
b16913a67e Support building with DJGPP 2.05
* builddos.bat: Use env var settings for paths.  Fix a typo in
expand.o.  Add the missing load.o compilation and link.  Enable
Guile support.  Copy Basic.mk from the correct location.
* src/configh.dos.templage: DJGPP supports strtoll() and ssize_t
given new enough versions.  Set preprocessor variables to 1 not 0.
2022-10-16 16:19:42 -04:00
Paul Smith
72ee43c473 * src/job.c: [SV 63185] Include sys/loadavg.h if needed. 2022-10-16 16:19:42 -04:00
Paul Smith
e5e538fb7a [SV 63215] Remember the random seed for shuffle mode
Basic fix provided by James Hilliard <james.hilliard1@gmail.com>.
Ensure we remember and propagate the random seed we generate during
shuffle mode.  Also add a debug statement displaying the seed.

* src/shuffle.c (shuffle_set_mode): Init and save the randoms seed.
* src/misc.c (make_rand): Code cleanups.
* src/main.c (main): Show a debug message containing the seed.
2022-10-16 16:18:21 -04:00
Paul Smith
c453f898a0 Use (void) rather than () in function declarations
In C, a function declaration with () allows any set of arguments.
Use (void) to mean "no arguments".

* src/dep.h: Switch () to (void) for functions with no arguments.
* src/makeint.h: Ditto.
* src/os.h: Ditto.
* src/shuffle.h: Ditto.
* src/variable.h: Ditto.
2022-10-15 18:39:32 -04:00
Paul Smith
18c4b508ef [SV 63157] Ensure temporary files are removed when signaled
Original patch from Dmitry Goncharov <dgoncharov@users.sf.net>.
When handling a fatal signal ensure the temporary files for
stdin and the jobserver fifo (if in use) are deleted.

* src/makeint.h (temp_stdin_unlink): Declare a new method.
* src/main.c (temp_stdin_unlink): Delete the stdin temporary file
if it exists.  If the unlink fails and we're not handling a signal
then show an error.
(main): Call temp_stdin_unlink() instead of unlinking by hand.
* src/commands.c (fatal_error_signal): Invoke cleanup methods if
we're handling a fatal signal.
* tests/scripts/features/output-sync: Test signal handling during
output sync and jobserver with FIFO.
* tests/scripts/features/temp_stdin: Test signal handling when
makefiles are read from stdin.
2022-10-15 18:39:32 -04:00
Paul Smith
383eb3a923 * src/posixos.c (job_root): Remember root jobserver instances
(jobserver_setup): Set job_root to true.
(jobserver_clear): if we're the root instance and we're using a
FIFO, unlink it.  If we're not in a signal handler, free memory.
(jobserver_acquire_all): Call jobserver_clear().
(sync_root): Rename from sync_parent for consistency.
2022-10-15 18:39:32 -04:00
Paul Smith
01b1d4f401 Set the proper type for variables set in signal handlers
* bootstrap.conf: Get gnulib's sig_atomic_t type checking M4 macro.
* configure.ac: Invoke it.
* src/makeint.h (handling_fatal_signal): Set the type correctly.
* src/commands.c (handling_fatal_signal): Ditto.
2022-10-15 18:39:32 -04:00
Dmitry Goncharov
bf2d71498c * tests/test_driver.pl (toplevel): [SV 63156] Keep temp env vars 2022-10-08 11:53:19 -04:00
Paul Smith
3e20e376b7 Clean up some warnings on Windows builds
* src/arscan.c (parse_int): Avoid conversion from int to char and
check for overflow given a max value.
(ar_scan): Check intmax sizes then cast to the proper type.
(ar_member_touch): Get proper return type from ar_scan and cast it
to off_t.
* src/function.c (a_word_hash_cmp): Don't cast from size_t to int.
(func_filter_filterout): Count using unsigned long to avoid casts.
(construct_include_path): Explicitly cast to void*.
* src/shuffle.c (reverse_shuffle_array): Use size_t index.
* src/w32/subproc/sub_proc.c (process_wait_for_multiple_objects):
Initialize the return value in case the count is 0.
2022-10-03 16:08:14 -04:00
Paul Smith
7ddfc42ee3 * src/misc.c (make_lltoa): Use printf format macro from makeint.h
(make_ulltoa): Ditto.
2022-10-03 15:11:57 -04:00
Paul Smith
ca92d83cde * src/arscan.c (ar_scan): Avoid sign comparison warnings
Pacify 12.2.1 20220819 (Red Hat 12.2.1-2) -Wsign-compare by checking
the readbuf() return explicitly for errors then casting from ssize_t.
Initial patch provided by Paul Eggert <eggert@cs.ucla.edu>.
2022-10-03 15:11:57 -04:00
Paul Eggert
ae80eefe65 Support systems with 32-bit long and 64-bit time_t
Don't assume that time_t fits in long, as some hosts (e.g.,
glibc x86 -D_TIME_BITS=64) have 32-bit long and 64-bit time_t.

* bootstrap.conf (gnulib_modules): Add largefile, to support files
with timestamps after Y2038 on hosts with 32-bit long.
* configure.ac: Do not call AC_SYS_LARGEFILE, as the largefile module
does that for us.
* src/makeint.h (PRIdMAX, PRIuMAX, SCNdMAX): Define if not already
defined (taken from gnulib).
* src/ar.c: Include intprops.h, for TYPE_MAXIMUM, as
INTEGER_TYPE_MAXIMUM does not work on time_t without issuing a bunch
of warnings.
(ar_member_date): Check that result is in time_t range.
(ar_member_date_1): Use intmax_t to hold the date.
(ar_glob_match): Ditto.
* src/arscan.c (VMS_function, VMS_function_ret, ar_scan)
(parse_int, ar_scan, ar_member_pos, ar_member_touch)
(describe_member): Convert long int to intmax_t.
* src/file.c (file_timestamp_sprintf): Use intmax_t/uintmax_t instead
of long/unsigned long for values that might be time_t.
* src/arscan.c (ar_member_touch): Fix buffer overrun if the timestamp
is too large.
2022-10-03 15:11:57 -04:00
Paul Smith
01142a53c9 Add support for intmax_t
* configure.ac: Ask autoconf to detect it.
* src/config.ami.template: Add #define intmax_t for AmigaOS.
* src/config.h-vms.template: Add #define intmax_t for VMS.
* src/config.h.W32.template: Add #define intmax_t for Windows.
* src/configh.dos.template: Add #define intmax_t for MS-DOS/DJPP.
2022-10-03 15:11:57 -04:00
Paul Smith
dee6af912a * NEWS: Deprecate Xenix 2022-10-03 15:11:57 -04:00
Paul Smith
7296991d6c [SV 63098] Temporarily revert the change to pattern rule behavior
The fix for SV 12078 caused a backward-compatibility issue with some
makefiles.  In order to allow users to resolve this issue, revert
that change for this release cycle: it will be reinstated in the
next release cycle.  Introduce a warning if we detect that the recipe
of a multi-target pattern rule doesn't create all the targets.

* NEWS: Announce the future backward-incompatibility.
* doc/make.texi (Pattern Intro): Describe the behavior and that it
will change in the future.
* src/remake.c (check_also_make): Check for also_make targets that
were not created and generate a warning.
(update_goal_chain): Call the new function.
(check_dep): Ditto.
(update_file_1): Defer implicit rule detection until after we check
all the also_make files (as it used to be).
* tests/scripts/features/patternrules: Add tests of the new warning.
Skip the tests for SV 12078.
2022-10-02 10:18:21 -04:00
Paul Smith
d51ac70122 * doc/make.texi (Prerequisite Types): [SV 58056] Clarify ordering. 2022-10-02 09:30:20 -04:00
Paul Smith
3cb84fe933 * src/filedef.h (is_ordinary_mtime): Check for "ordinary" mod time.
* src/remake.c (update_file_1): Use the new macro.
2022-10-02 08:55:29 -04:00
Paul Smith
ad84ec2fdc * src/remake.c (update_file_1): Return valid enum element, not 0. 2022-10-02 08:55:29 -04:00
Paul Smith
26b9f30714 * NEWS: Announce deprecation of OS/2 and AmigaOS ports 2022-10-02 08:55:29 -04:00
Paul Smith
5ac80176a3 * src/main.c (main): Add debug output for jobserver and osync.
* src/posixos.c (jobserver_setup): Remove redundant debug output.
(jobserver_parse_auth): Ditto.
2022-10-02 08:46:00 -04:00
Andreas Schwab
c801a7fb67 [SV 63111] Ensure output-sync is cleaned on re-exec and recursion
Now that output-sync is using a separate file as a mutex rather than
stdout, ensure the new file descriptor is closed before re-exec and
not inherited by children.

* src/main.c (main): Call osync_clear() before re-exec.
* src/posixos.c (osync_setup): Reset output-sync handle inheritance.
(osync_parse_mutex): Ditto.

Copyright-paperwork-exempt: yes
2022-10-02 08:46:00 -04:00
Paul Smith
c2eddf9be2 * src/function.c: Change int to uint to align with gmk_func_ptr 2022-10-01 11:47:41 -04:00
Dmitry Goncharov
f8852311cc * doc/make.texi (Loaded Object API): [SV 63126] Fix typos and examples 2022-10-01 11:47:41 -04:00
Paul Smith
a99378ebe4 Implement a simple xorshift 32bit random number generator
Avoid relying on the system random number generator for our random
shuffle, so that the same seed gives the same results on all systems.
This generator doesn't need to be amazing, just pretty good, so don't
bother with xorshift* or xorshift+, etc.

* src/makeint.h: Declare make_seed() and make_rand().
* src/misc.c (make_seed): Set the seed value for the RNG.
(make_rand): Return the next random number.  If the seed was not set
initialize it first.
* src/shuffle.c (shuffle_set_mode): If we don't get a seed from the
user just leave it unset (0).
(shuffle_deps_recursive): Use make_seed() not srand().
(random_shuffle_array): Use make_rand() not rand().
2022-10-01 11:45:39 -04:00
Dmitry Goncharov
6c87f3fb85 [SV 63100] Set the floc of every created goal dep struct
* src/read.c (eval): Initialize the goaldep floc pointer.
* tests/scripts/features/loadapi: Verify that the floc is set after
unloading and reloading dynamic objects.
2022-09-25 17:09:08 -04:00
Paul Smith
38116baee9 * doc/make.texi: Update out of date behavior for grouped targets. 2022-09-25 16:58:36 -04:00
Paul Smith
614033f8c6 * README.git: Announce releases to the platform-testers list 2022-09-25 16:57:31 -04:00
Paul Smith
f3640ecf4f Provide new functions to convert long long to string
The previous attempt to use PRI* macros to avoid compiler-specific
printf format specifiers didn't work because we are using raw
long long type, not the uintX_t types.  On systems where long and
long long are the same size, uint64_t might be type "long" and PRId64
is just "ld".

Instead write new functions that convert [unsigned] long long to a
string and call those instead.

* src/makeint.h: Declare make_lltoa() and make_ulltoa().
* src/misc.c (make_lltoa): New function that writes a long long value
into a provided buffer.  Return the buffer for ease-of-use.
(make_ulltoa): Ditto, for unsigned long long.
* src/function.c (func_wordlist): Call these new methods.  Also
rework the error strings so we share the translated string.
* src/dir.c (print_dir_data_base): Call the new methods instead of
using MSVC macros.
2022-09-25 16:57:31 -04:00
Paul Smith
c4e232e44f Always restore global environ if we use vfork
We may change the global environ variable in the child; when using
vfork() this also sets it in the parent.  Preserve the parent's
environ in child_execute_job() so it takes effect for all callers.

Reported by Denis Excoffier <bug-tar@Denis-Excoffier.org>
Root cause found by Martin Dorey <Martin.Dorey@hitachivantara.com>

* src/job.c (start_job_command): Remove save/restore of the parent
environment.
(child_execute_job): Add save/restore of the parent environment,
if we use vfork().
* tests/scripts/functions/shell: Add a test the crashes if we don't
reset environ after we run $(shell ...).
2022-09-25 16:57:31 -04:00
Dmitry Goncharov
aa99e810a9 * configure.ac: [SV 63070] Clean up the test program for posix_spawn. 2022-09-25 16:57:13 -04:00
Paul Smith
8f49029561 * src/posixos.c (osync_clear): Don't close invalid FDs. 2022-09-25 13:37:12 -04:00
Paul Smith
f7ed583675 * maintMakefile: Use gnulib ncftpput-ftp if ncftpput is missing. 2022-09-25 13:37:12 -04:00
Paul Smith
cf7f7de7ae * src/misc.c (strncasecmp): Use size_t for length to match std.
* src/misc.h (strncasecmp): Fix the declaration.
2022-09-25 13:37:12 -04:00
Paul Smith
d4cb7ae6d4 * configure.ac: Update to GNU make 4.3.91
* NEWS: Update the version and clarify some backward-compat issues.
2022-09-25 13:37:12 -04:00
Eli Zaretskii
387d349dc8 Fix compiler warnings in the MS-Windows build.
* src/w32/w32os.c (osync_get_mutex, osync_parse_mutex): Cast to
DWORD_PTR when converting integers to HANDLEs and vice versa.

* src/w32/pathstuff.c (w32ify): Pacify compiler warnings about
'strncpy'.

* src/makeint.h (PRId64) [!HAVE_INTTYPES_H]: Define if undefined.
* src/function.c (func_wordlist): Use PRId64 instead of %lld.
2022-09-25 17:11:12 +03:00
Eli Zaretskii
caad0e2181 Avoid compilation warnings
* src/implicit.c: (pattern_search):
* src/main.c: (main): Avoid compilation warnings for variables
only used when compiling a debug version with assertions.
2022-09-24 21:15:41 +03:00
Paul Smith
990d6f9b9a Release GNU make 4.3.90
* NEWS: Update for the prerelease.
* bootstrap.conf: Choose the latest stable gnulib.
* README.git: Updates.
2022-09-20 13:23:44 -04:00
Paul Smith
134480787e * tests/script/parallelism: Force wait to remove races. 2022-09-20 13:23:44 -04:00
Dmitry Goncharov
a9a4919909 [SV 56301] Fail if an included makefile can't be built
Fail if a mandatory include file fails to be built even if it's
built as part of a grouped target where the other include file
is optional.

* src/main.c (main): If a makefile doesn't build set any_failed.
* tests/scripts/features/include: Add tests.
* tests/scripts/options/dash-k: Stop after include build failure.
2022-09-20 03:55:39 -04:00
Paul Smith
d12ff78cb2 * tests/scripts/features/statipattrules: [SV 17374] Add test
Verify that double-colon static pattern rules work.
2022-09-20 03:55:39 -04:00
Paul Smith
fabb03eac4 [SV 12078, SV 62809] Rebuild grouped targets if any is missing
If any of a set of grouped targets is missing or out of date, even
if make is not trying to build that target, rebuild them all.
Ensure this is true for explicit grouped targets as well as pattern
rule grouped targets.

Original patch by Jonathan Gravel <jo@stashed.dev>

* src/remake.c (update_file_1): After matching any pattern rules,
go through the also_make targets and set noexist as needed.  Also
compute the oldest this_mtime.
* tests/scripts/features/grouped_targets: Add regression tests.
* tests/scripts/features/patternrules: Ditto.
* tests/features/vpath: Rewrite to use modern run_make_test().
Add a test that we check for VPATH before implicit rule search.
Move the tests in vpath2 and vpath3 into this suite.
* tests/features/vpathplus: Rewrite to use modern run_make_test().
2022-09-20 03:55:39 -04:00
Dmitry Goncharov
618c53a225 * tests/scripts/targets/WAIT: [SV 63071] Remove possible test races. 2022-09-17 13:22:35 -04:00
Paul Smith
88d126d6c4 * doc/make.texi (Parallel Disable): Add clarifications.
* NEWS: Suggest how to change makefiles that use $(MAKEFLAGS).
2022-09-13 18:22:29 -04:00
Paul Smith
f6ea899d83 [SV 13862] Implement the .WAIT special target
The next version of the POSIX standard defines parallel execution
and requires the .WAIT special target as is implemented in some other
versions of make.

This implementation behaves similarly to others in that it does not
create a relationship between targets in the dependency graph, so
that the same two targets may be run in parallel if they appear as
prerequisites elsewhere without .WAIT between them.

Now that we support .WAIT it's trivial to also support prerequisites
of the .NOTPARALLEL special target, which forces the prerequisites of
those targets to be run serially (as if .WAIT was specified between
each one).

* NEWS: Announce the new .WAIT and .NOTPARALLEL support.
* doc/make.texi (Parallel Disable): A new section to discuss ways in
which parallel execution can be controlled.  Modify cross-refs to
refer to this section.
* src/dep.h (struct dep): Add a new wait_here boolean.
(parse_file_seq): Add PARSEFS_WAIT to check for .WAIT dependencies.
* src/file.c (split_prereqs): Use PARSEFS_WAIT.
(snap_deps): If .NOTPARALLEL has prerequisites, set .WAIT between
each of _their_ prerequisites.
(print_prereqs): Add back in .WAIT when printing prerequisites.
* src/implicit.c (struct patdeps): Preserve wait_here.
(pattern_search): Ditto.  Use PARSEFS_WAIT when parsing prereqs for
pattern rule expansion.
* src/read.c (check_specials): Don't give up early: remembering to
update these options is not worth the rare speedup.
(check_special_file): If .WAIT is given as a target show an error--
once--if it has prereqs or commands.
(record_files): Call check_special_file on each target.
(parse_file_seq): If PARSEFS_WAIT is given, look for .WAIT prereqs.
If we see one assume that we are building a struct dep chain and set
the wait_here option while not putting it into the list.
* src/remake.c (update_file_1): If wait_here is set and we are still
running, then stop trying to build this target's prerequisites.
* src/rule.c (get_rule_defn): Add .WAIT to the prerequisite list.
* src/shuffle.c (shuffle_deps): Don't shuffle the prerequisite list
if .WAIT appears anywhere in it.
* tests/scripts/targets/WAIT: Add a test suite for this feature.
2022-09-12 18:35:29 -04:00
Dmitry Goncharov
ee861a4e9f [SV 63045] Reload each intact unloaded shared object
If makefile rules do not update an unloaded shared object, load it
again.  Avoid double loading of the same object if the setup function
returns -1.

* src/filedef.h (struct file): Add "unloaded" flag.
* src/makeint.h (load_file): Take struct file *.
(unload_file): Return int.
* src/main.c (main): Reload unloaded shared objects if they weren't
updated.
* src/commands.c (execute_file_commands): Set "unloaded" and reset
"loaded" when a shared object is unloaded.
* src/read.c (eval): Set "loaded" and reset "unloaded" when a shared
object is loaded.  Add successfully loaded files to the db.
* src/load.c (load_file): Check "loaded" to avoid double loading the
same object.  Fix a memory leak of string loaded.  Return -1, rather
than 1, if the object is already loaded. This fixes double loading of
the same object when the setup routine returns -1.
(load_object): Add a log message.
(unload_file): Return an error on dlclose failure.  Log a message.
* tests/scripts/features/loadapi: Add new tests.
2022-09-12 02:05:18 -04:00
Sergei Trofimovich
ca4234c4b5 [SV 63047] Fix shuffle of SECONDEXPANSION prerequisites
Commit 07eea3aa4 `make --shuffle` prevented shuffling prerequisites
that use .SECONDEXPANSION, since shuffle happens before expansion.
This has two problems:
1. No shuffling happens for such prerequisites.
2. Use-after-free when outdated '->shuf' links are used.

Add a reshuffle into expansion phase right after dependency changes.

* src/file.c (expand_deps): Add reshuffle if dependencies change.
* src/shuffle.c (identity_shuffle_array): Fix comment typo.
* tests/scripts/options/shuffle: Add new SECONDEXPANSION test.
2022-09-12 01:05:31 -04:00
Paul Smith
257b82ac1f * doc/make.texi (How Make Works): Clarify default goal exceptions. 2022-09-11 15:09:13 -04:00
Paul Smith
aac4004444 * src/shuffle.c: Minor coding changes. 2022-09-11 14:04:58 -04:00
Paul Smith
86fc644dcc Support the MAKE_TMPDIR environment variable
Allow build systems to choose an alternative location for make to
store its temporary files.

* NEWS: Announce the new environment variable.
* doc/make.texi (Temporary Files): Provide documentation.
* src/misc.c (get_tmpdir): Split into a new function.  Compute the
temporary directory and store it in a static location.
* tests/scripts/features/jobserver: Add a test of MAKE_TMPDIR.
2022-09-11 10:56:08 -04:00
Paul Smith
02b3a6ad46 [SV 62898] Document ways to hide special chars from make functions
* doc/make.texi (Function Call Syntax): Add a subsubheading describing
which special characters may need to be hidden from make functions.
2022-09-10 23:14:02 -04:00
Dmitry Goncharov
77734be2af [SV 63044] load: Update .LOADED if the setup function returns -1
* src/load.c (load_file): Update .LOADED if setup returns non-0.
* tests/scripts/features/load: Change the return value based on an
environment variable.  Ensure that returning -1 still adds to
.LOADED.  Also add a test that verifies that make doesn't try to
rebuild the loaded file if -1 is returned.
2022-09-10 22:42:28 -04:00
Paul Smith
820210ab85 Enhance the make.texi formatting
Notes provided by Tzvetelin Katchov <katchov@gnu.org>.

* doc/make.texi: Remove obsolete @refill statements.  Add some breaks
to overfull lines.  Fix up some example text.
2022-09-10 18:35:47 -04:00
Paul Smith
77706874a7 Clean up maintMakefile
Notes provided by Tzvetelin Katchov <katchov@gnu.org>

* maintMakefile (git-very-clean): Add -x to git clean.
(GNULIBDIR): Use GNULIB_SRCDIR, or the local module if not set.
2022-09-10 18:35:41 -04:00
Paul Smith
a9548aeb8f [SV 63037] Fix tests for newer OS / compiler
* tests/scripts/features/load: Add function prototypes.
* tests/scripts/features/temp_stdin: Only set user execute bits.
Some configurations don't allow changing the group bits...??
2022-09-10 17:15:23 -04:00
Paul Smith
70ba0357a0 [SV 63040] shell: Fall back to the callers environment
If we detect a recursive variable reference when constructing the
environment for the shell function, return the original value from the
caller's environment.  Other options such as failing, returning the
empty string, or returning the unexpanded make variable value have
been shown to not behave well in real-world environments.  If the
variable doesn't exist in the caller's environment, return the empty
string.

Found by Sergei Trofimovich <slyich@gmail.com> when testing older
versions of autoconf.

* NEWS: Clarify this behavior.
* doc/make.texi (Shell Function): Ditto.  Also add info about !=.
* src/expand.c (recursively_expand_for_file): Search the caller's
environment if we detect a recursive variable expansion.
* tests/scripts/functions/shell: Add tests for this behavior.
2022-09-10 16:27:47 -04:00
Paul Smith
7d48401707 [SV 63016] Don't fail exporting to $(shell ...)
The fix for SV 10593 caused recursive expansion errors when exporting
a variable that contains a $(shell ...) invocation.  If we see this
type of recursion, ignore it and expand to the empty string rather
than failing.

* src/variable.h (env_recursion): New global variable.
* src/variable.c (target_environment): If creating the environment
for a $(shell ...) function increment env_recursion.  Remove the
check for expansion in a shell function context.
* src/expand.c (recursively_expand_for_file): Check for recursive
expansion in a $(shell ...) environment context and if present,
show the verbose message and return the empty string.
* tests/scripts/functions/shell: Add a test for this situation.
2022-09-08 03:04:15 -04:00
Paul Smith
1fc13bf576 Ensure debug output ends in newline
* src/load.c (load_object): Debug output strings must include \n.
* src/variable.c (target_environment): Ditto.
* src/posixos.c: Remove extra newlines.
2022-09-08 03:04:15 -04:00
Paul Smith
896908180e Sanitize tar file ownership, mode, and order
For reproducibility ensure all files in the dist tar file are owned by
root, and sorted by name.  Force the mode on all files to be writable
by the owner and not writable by group or user, by default.

Remove unnecessary execute permissions from build_w32.bat.

Recommended by Tzvetelin Katchov <katchov@gnu.org>.
2022-09-08 03:04:15 -04:00
Paul Smith
80e9a422e4 bootstrap: Update to the latest gnulib bootstrap model
* README.git: Document the changes.
* bootstrap.conf: Set GNULIB_REVISION to avoid random updates.
* configure.ac: Set the minimum autoconf version back to 2.69:
that's the most common version deployed today, and it still works.
* bootstrap: Copy the latest from gnulib.
* autogen.sh: Ditto.
* autopull.sh: Ditto.
* bootstrap-funclib.sh: Ditto.
2022-09-08 03:04:04 -04:00
Paul Smith
15a7e3830f Fix tests for MacOS and Windows
* maintMakefile: Remove the template headers as prerequisites.
* tests/scripts/features/jobserver: Only test fifo if enabled.
* tests/scripts/variables/INCLUDE_DIRS: On MacOS none of the default
directories exist so .INCLUDE_DIRS is empty by default.
* tests/scripts/features/se_explicit: Fail via exit.  cp will show
different error messages on different systems.
* tests/scripts/features/se_implicit: Ditto.
* tests/scripts/features/se_statpat: Ditto.
2022-08-30 21:05:34 -04:00
Paul Smith
26e359c71d [SV 62840] Don't change IO buffering before printing version
If users run 'make --version | head -n1' they expect make to exit
with a success (0) code.  This works because the pipe forces the
default buffering on stdout to be fully buffered so all the output
is printed to the pipe in a single write(2) and won't fail.  However
due to output sync we forcibly set stdout to line buffered, which
means if the reader closes the pipe fast enough make will exit with
an error code because the write to stdout failed.

Move the setup done in output_init() back into main() where it can
be done in a proper order.  Rework the order of operations during
startup so that we check for help and version flags before we change
the buffering.  Clean up the behavior of print_usage().

Original changes from Dmitry Goncharov <dgoncharov@users.sf.net>.

* src/main.c (switches): Don't send --version in the environment.
(print_usage): Add a blank line after the version before the usage.
Move the die() into this function since we always die() afterward.
Note the die will flush so no need to do it explicitly.
(print_version): The caller will fflush when appropriate.
(close_stdout): Move from output.c so it is installed early.
(decode_switches): Only call print_usage on error, not for --help.
(main): Install the close_stdout handler immediately after start.
Move the calls to print_usage() due to --help and --version to be
called immediately after we decode the switches.  Move the buffer set
here from output_init(), immediately after we know we'll be running.
* src/output.c (output_init): Move buffer setting to main().
(close_stdout): Move to main().
2022-08-30 21:04:48 -04:00
Paul Smith
4da2055a10 Rework output sync to lock a temp file on POSIX
Some POSIX systems do not allow locks to be taken on non-files, such
as pipes.  This is a problem since very often make is invoked with
its stdout redirected to a pipe.  Also, if stdout is redirected to a
file that already has a lock on it for some other reason (perhaps a
shared file such as /dev/null) it can cause a hang.

This means our previous method of locking stdout, although it had some
nice advantages, is not portable enough.  Instead, use a temporary
file and take the lock on that.  We pass the name of the file to child
make processes.  On Windows we continue to use a shared mutex for
output sync.

Remove POSIX emulation functions like fcntl from Windows; instead
follow the lead of the jobserver and create an interface in os.h for
output sync, and move the OS-specific content to posixos.c and
w32os.c.

* NEWS: Add a note.
* src/makeint.h (ALL_SET): Check that all bits are set.
* src/os.h: Add bits for checking the state of stdin/stdout/stderr.
Add prototypes for OS-specific output sync methods.
* src/posixos.c (check_io_state): Determine the status of stdin,
stdout, stderr an return a suite of bits describing them.
(osync_enabled): If the global variable holding the FD of the lock
file (osync_handle) is valid return true.
(osync_setup): Create a temporary file and remember its name in a
global variable (osync_tmpfile), and set osync_handle.
(osync_get_mutex): If output sync is enabled, return the filename
of the lock file prefixed with "fnm:" to denote a filename.
(osync_parse_mutex): If the provided filename has the wrong format
disable output sync.  Else open the lock file and set osync_handle.
(osync_clear): Close osync_handle.  If we're the parent make, then
also unlink the temporary file.
(osync_acquire): Take a lock on the osync_handle descriptor.
(osync_release): Release the lock on the osync_handle descriptor.
(fd_set_append): Add APPEND mode to a file descriptor.
* src/w32/w32os.c: Perform the same actions as posixos.c, copying
the details from src/w32/compat/posixfcn.c.  Use a mutex rather
than locking a temporary file.
* src/output.h: Remove all the OS-specific content.
* src/output.c: Remove all the OS-specific content.
(set_append_mode): Remove and replace with fd_set_append().
(sync_init): Remove and replace with check_io_state().
(acquire_semaphore): Remove and replace with osync_acquire().
(release_semaphore): Remove and replace with osync_release().
(setup_tmpfile): If the IO state is not obtained, get it.  If stdout
and/or stderr are valid, set up a tempfile to capture them.
(output_init): Set io_state if not set already, and check it when
deciding whether to close stdout on exit.
* src/main.c (main): If we're syncing, set up the mutex using the
new osync_setup() / osync_parse_mutex() methods.
(prepare_mutex_handl_string): Replace with osync_parse_mutex().
(die): Call osync_clear().
* src/w32/compat/posixfcn.c: Remove implementations of fcntl(),
record_sync_mutex(), create_mutex(), and same_stream().
2022-08-30 15:44:43 -04:00
Paul Smith
a2ba5ccbda Add get_tmpfd() and allow anonymous temp files
The output sync feature wants a file descriptor not a FILE*.  We were
using tmpfile() but this returns FILE* which means we needed to dup()
the descriptor then fclose() the original, which is just unnecessary
overhead for every command we run.

Create a get_tmpfd() method that returns a file descriptor directly
by using mkstemp() if available, else do the best we can.

Also allow anonymous temp files if the filename pointer is NULL.
This causes the file to be unlinked.  On Windows this requires a
special open so add an os_anontmp() method to handle this.

* src/makeint.h: Add prototype for get_tmpfd().
* src/misc.c (get_tmpfd): If we have mkstemp() use that, else just
open(2).  If we don't want to keep the filename, unlink the file.
(get_tmpfile): Use get_tmpfd() if we have fdopen(), else use fopen().
* src/output.c (output_tmpfd): Call get_tmpfd() with NULL.
* src/os.h (os_anontmp): On Windows make this a function, else fails.
* src/w32/compat/posixcfn.c (tmpfile): Move to w32os.c:os_anontmp().
* src/w32/w32os.c (os_anontmp): Create a temp file that will be deleted
when the process exits, and return a file descriptor to it.
2022-08-30 15:39:02 -04:00
Paul Smith
5eff618c8c test_driver: check for leftover temp files after each test
Reset the temp directory for every test to a local directory, then
after each test see if any new temp files were created and not
deleted: if they were then fail the test.  Rather than delete the
temp files we leave them there and avoid reporting files that were
seen before, so the user can investigate them.

Rewrite the temp_stdin tests to rely on this built-in behavior
rather than implementing the checks directly.

* tests/test_driver.pl: Create a $TEMPDIR variable pointing to a
temporary directory outside the test temp directory.
(toplevel) Before starting any tests create a temp directory and set
the POSIX and Windows temp directory environment variables to use it.
(compare_output) Check the contents of the temp directory.  If any
new files have appeared, fail the test.
* tests/scripts/features/temp_stdin: Remove check_tempfile() and
all users of it, plus setting of temp environment variables.
2022-08-29 00:09:10 -04:00
Dmitry Goncharov
10e130b207 [SV 62908] Don't free fifo_name twice during error handling
* src/posixos.c (jobserver_setup): Set fifo_name to NULL after free.
* tests/scripts/features/jobserver: Add tests.
2022-08-22 21:27:08 -04:00
Paul Smith
62da1c45e5 Fix bootstrap.bat for bootstrapping on Windows
* README.git: Clarify that these methods are lightly tested.
* build_w32.bat: Don't support any config step: fail if not completed.
Move the config steps into bootstrap.bat.  Don't print compile lines
by default and add a --verbose option to show them.
* bootstrap.bat: Ensure we have curl and sed before we do anything.
Pull the latest necessary files from gnulib.  Create a convert.sed
script that can update the various template files, and update
Basic.mk, config.h.W32, and gmk-default.h.
* tests/run_make_tests.pl: Remove CRLF rather than using chop.  If we
run perl in Git for Bash it seems to handle newlines differently.
* tests/scripts/features/temp_stdin: Remove the make copy and close
STDIN so we can delete the temp file on Windows.
* .gitignore: Ignore the convert.sed script.
2022-08-22 21:19:18 -04:00
Paul Smith
ab31f0b594 * doc/make.texi (Variables/Recursion): [SV 56446] Clarify export docs 2022-08-14 14:06:31 -04:00
Paul Smith
8f1b6bca46 * doc/make.texi (Goals): [SV 51306] Improve MAKECMDGOALS example 2022-08-07 17:32:07 -04:00
Dmitry Goncharov
6faa02247e * doc/make.texi (Remaking Makefiles): [SV 61623] Add optimization 2022-08-07 17:31:50 -04:00
Paul Smith
c72e1ec446 * doc/make.texi (Chained Rules): [SV 61957] Clarify NOTINTERMEDIATE 2022-08-03 00:13:34 -04:00
Paul Smith
91d87ccf32 [SV 62496] Fix example of testing MAKEFLAGS
* doc/make.texi (Options/Recursion): Define the layout of MAKEFLAGS.
(Testing Flags): Fix the example to test the first word.
2022-08-03 00:05:39 -04:00
Paul Smith
7ad2593b2d Support implementing the jobserver using named pipes
Using anonymous pipes for jobserver support has some advantages:
for example there is nothing on disk that needs to be cleaned up.
However it has many obscure problems, related to the fact that in
order for it to work we need to ensure these resources are properly
passed through to child processes that want to use the jobserver.
At the same time we don't want to pass the pipe to process which
DON'T know about the jobserver.

Other processes can open file descriptors which we then think are
our jobserver, but aren't.  And, we open the pipe file descriptors
in blocking mode which doesn't work for all users.

See issues such as SV 57178, SV 57242, and SV 62397

To avoid these issues, use named pipes (on systems where they are
available) instead of anonoymous pipes.  This simplifies many things:
we never need to pass open file descriptors to our children; they
can open the jobserver named pipe.  We don't need to worry about
recursive vs. non-recursive children.  Users don't have to "pass
through" the resources if they are invoking sub-makes.  Each child
can open its own file descriptor and set blocking as needed.

The downside is the named pipe exists on disk and so must be cleaned
up when the "top-level" make instance exits.

In order to allow make to continue to be used in build systems where
older versions of GNU make, or other tools that want to use the
jobserver, but don't understand named pipes, introduce a new option
--jobserver-style that allows the user to choose anonymous pipes.

* NEWS: Announce the change and the --jobserver-style option.
* doc/make.1: Add --jobserver-style documentation.
* doc/make.texi (Special Variables): Add missing items to .FEATURES.
(Options Summary): Add --jobserver-style.
(POSIX Jobserver): Named pipes, changes to --jobserver-auth, and the
--jobserver-style option.
(Windows Jobserver): Document --jobserver-style for Windows.
* configure.ac: Check for mkfifo.
* src/config.h-vms.template: Undefined HAVE_MKFIFO.
* src/config.h.W32.template: Ditto.
* src/main.c: Add jobserver-style as a new command line option.
(main): Add jobserver-fifo to .FEATURES if supported.  Pass the style
option to jobserver_setup().
* src/os.h (jobserver_setup): Accept a style string option.
* src/posixos.c (enum js_type): Enumeration of the jobserver style.
(js_type): Which style we are currently using.
(fifo_name): The path to the named pipe (if in use).
(jobserver_setup): If no style is given, or "fifo" is given, set up a
named pipe: get a temporary file and use mkfifo() on it, then open it
for reading and writing.  If something fails fall back to anonymous
pipes.
(jobserver_parse_auth): Parse jobserver-auth to determine the style.
If we are using a named pipe, open it.  If we're using anonymous pipes
ensure they're valid as before.
(jobserver_get_invalid_auth): Don't invalidate the jobserver when
using named pipes.
(jobserver_clear): Clean up memory used for named pipes.
(jobserver_acquire_all): Unlink the named pipe when done.
* src/w32/w32os.c (jobserver_setup): Check the style argument.
* tests/scripts/features/jobserver: Use --jobserver-style to test
the anonymous pipe behavior, and also test named pipe/semaphore
behavior.  Check invalid jobserver-style options.
* tests/scripts/functions/shell: Use --jobserver-style to test the
anonymous pipe behavior, and also test named pipe/semaphore
behavior.
2022-08-02 23:36:35 -04:00
Paul Smith
09cce75c30 Enhance get_tmpfile() and add get_tmppath()
Move all the logic on creating temporary files into misc.c, and add
a new function get_tmppath() that returns the pathname to a temporary
file without creating or opening it.

* src/makeint.h: Add a declaration for get_tmppath().  Remove the
template argument from get_tmpfile(): it will compute its own.
* src/main.c (main): Remove the logic for computing templates.
* src/vmsjobs.c (child_execute_job): Ditto.
* src/misc.c (get_tmptemplate): New function to return an allocated
template string for use with various mktemp-style functions.
(get_tmppath): Return an allocated path to a temporary file, but do
not create it.  Generally this should be avoided due to TOCTOU issues.
(get_tmpfile): Use get_tmptemplate() to generate a template rather
than using one passed in.  If we don't have mkstemp() then use
get_tmppath() to compute the path of a temp file.
2022-08-02 23:36:35 -04:00
Dmitry Goncharov
07eea3aa49 [SV 62706] Only second-expand targets that might be built
Second-expand only the prerequisites of the targets being built.
Defer second-expanding the prerequisites of targets until we need
to decide if they should be built.

* NEWS: Mention the change in behavior.
* doc/make.texi (Secondary Expansion): Document the new behavior.
* src/filedef.h (struct file): Add flag snapped.
(expand_deps): Declare a function to second expand the
prerequisites of a target.
* src/file.c (rehash_file): Merge flag snapped.
(expand_deps): Remove qualifier static. Check flag snapped.
(snap_deps): Remove the loop which performed second expansion for all
targets.
* src/remake.c (update_file_1): Second expand the prerequisites of
the considered target.
* tests/scripts/features/se_explicit: Add tests.
* tests/scripts/features/se_implicit: Ditto.
* tests/scripts/features/se_statpat: Ditto.
2022-07-30 18:40:28 -04:00
Paul Smith
16e14b4114 Disable the jobserver in non-recursive children
Savannah issues such as SV 57242 and SV 62397 show how passing
references to closed file descriptors via the --jobserver-auth option
in MAKEFLAGS can lead to problematic outcomes.

When computing the child environment for a non-recursive shell, add
an extra option to MAKEFLAGS to disable the file descriptors for the
jobserver.

Unfortunately this doesn't modify the value of the make variable
MAKEFLAGS, it only modifies the value of the sub-shell environment
variable MAKEFLAGS.  This can lead to confusion if the user is not
considering the distinction.

* src/makeint.h: Publish the jobserver-auth value.  Add a global
definition of the name of the command line option.
* src/os.h (jobserver_get_invalid_auth): New function to return a
string invalidating the jobserver-auth option.
* src/w32/w32os.c (jobserver_get_invaid_auth): Implement it.  On
Windows we use a semaphore so there's no need to invalidate.
* src/posixos.c (jobserver_parse_auth): If we parse the invalid
auth string, don't set up the jobserver.
(jobserver_get_invalid_auth): Return an invalid option.
* src/variable.h (target_environment): Specify if the target
environment is for a recursive shell or non-recursive shell.
* src/variable.c (target_environment): Move checking for MAKELEVEL
into the loop rather than doing it at the end.
Along with this, check for MAKEFLAGS and MFLAGS, and update them
based on whether we're invoking a recursive or non-recursive child,
and also on whether it's necessary to invalidate the jobserver.
* src/function.c (func_shell_base): Shell functions can never be
recursive to pass 0 to target_environment().
* src/job.c (start_job_command): Specify whether the child is
recursive when calling target_environment().
* src/main.c: Export jobserver_auth.  sync_mutex doesn't need to
be exported.  Use the global definition for the option name.
* tests/scripts/variables/MAKEFLAGS: Add tests for $MAKEFLAGS.
2022-07-30 18:40:28 -04:00
Paul Smith
77881d2281 Ensure that MAKEFLAGS is set when invoking $(shell ...)
* src/main.c (main): Don't reset the jobserver if the number of
slots has not changed.
(define_makeflags): Add all normal flags even when ALL is not set.
* tests/scripts/functions/shell: Test invoking make in $(shell ...).
* tests/scripts/variables/MAKEFLAGS: Test the value of MAKEFLAGS in
$(shell ...).
2022-07-30 18:40:28 -04:00
Paul Smith
2fe96e4a41 Take advantage of mempcpy() and stpcpy()
* src/makeint.h (stpcpy): Add missing declaration.
* src/amiga.c (MyExecute): Avoid extra strlen using stpcpy.
* src/function.c (func_shell_base): Ditto.
(func_error): Use memcpy() not strcpy() when we know the length.
* src/job.c (construct_command_argv_internal): Use stpcpy().
* src/main.c (main): Ditto.
(define_makeflags): Ditto.
* src/variable.c (print_target_variables): Use memcpy() when we know
the length.
* src/commands.c (set_file_variables): Use mempcpy().
* src/expand.c (variable_buffer_output): Ditto.
* src/file.c (expand_deps): Ditto.
* src/function.c (abspath): Ditto.
(handle_function): Ditto.
* src/implicit.c (pattern_search): Ditto.
* src/job.c (construct_command_argv_internal): Use mempcpy() and
don't add multiple spaces when there are no shell flags.
* src/main.c (decode_env_switches): Use mempcpy() to simplify.
(define_makeflags): Ditto.
* src/variable.c (selective_vpath_search): Ditto.
2022-07-30 18:40:21 -04:00
Paul Smith
dd24a4c1cf Convert HAVE_GETLOADAVG to HAVE_DECL_GETLOADAVG
We want to know if getloadavg() is declared, not if we have it.

* configure.ac: Add it as a define (why is this not the default?)
* src/job.c: Conditionalize declaration on HAVE_DECL_GETLOADAVG.
* config.ami.template: Rename HAVE_GETLOADAVG to HAVE_DECL_GETLOADAVG.
* config.h-vms.template: Ditto.
* config.h.W32.template: Ditto.
Clean up and add new elements from latest config.h.
2022-07-09 11:09:17 -04:00
Paul Smith
f36c6c7347 Merge in the latest gnulib findprog-in module 2022-07-09 11:08:49 -04:00
Paul Smith
87d24154af Merge in the latest gnulib concat-filename module 2022-07-09 11:07:23 -04:00
Paul Smith
614557d04c Merge in the latest gnulib getloadavg module 2022-07-09 11:05:14 -04:00
Paul Smith
047544785b Initial merge of the gnulib-port branch 2022-07-09 10:56:05 -04:00
Paul Smith
73b08af181 Move our local m4 macros to gl/m4
The gl subdirectory contains our local versions of gnulib module
implementations, so move m4/acinclude.m4 and m4/dospaths.m4 there.

* gl/modules/make-macros: Create a new module to handle the macros.
* bootstrap.conf: Add the new module.
* configure.ac: Macro invocation is moved to make-macros.
* m4/.gitignore: Delete unnecessary ignore file: m4 is empty.
* .gitignore: Add m4/ as an ignored directory.
2022-07-09 10:47:13 -04:00
Paul Smith
5c1d9e54c7 Move our fnmatch/glob implementation into gl/lib
The gl subdirectory contains our local versions of gnulib module
implementations, so move fnmatch* and glob* from lib to gl/lib.

* gl/modules/make-glob: Add a proper Files: section.
* lib/.gitignore: Delete unnecessary ignore file: lib is empty.
* .gitignore: Add lib/ as an ignored directory.
2022-07-09 10:47:13 -04:00
Paul Smith
2d7b5d6d80 * tests/run_make_tests.pl: Exit 1 if we detect an error. 2022-07-09 10:47:13 -04:00
Paul Smith
5dc7358547 * configure.ac: Remove AC_FUNC_SETVBUF_REVERSED.
This macro is obsolete: no useful system has this problem anymore.
* src/output.c (output_init): Remove reference to SETVBUF_REVERSED.
* src/config.ami.template: Remove undef of SETVBUF_REVERSED.
* src/config.h-vms.template: Ditto.
* src/config.h.W32.template: Ditto.
2022-07-09 10:47:13 -04:00
Paul Smith
e33af0fb4a * configure.ac: Check for stpcpy() support.
* src/misc.c (stpcpy): Define it if not provided.
2022-07-09 10:47:13 -04:00
Paul Smith
6f7e06ec4e getloadavg: Remove support for privileged invocation
This was needed when getloadavg required privileged access; in this
case GNU make needed to be installed as a setgid program.  But this
hasn't been supported by gnulib getloadavg() since 2011 and systems
are no longer using it, so remove it.

* src/makeint.h (user_access): Remove unnecessary function.
(make_access): Ditto.
(child_access): Ditto.
* src/misc.c: Remove implementations of the *_access() functions.
* src/main.c (main): Remove unneeded call to user_access().
* src/job.c (load_too_high): Remove calls to {make,user}_access().
(exec_command): Remove call to child_access().
* src/remote-cstms.c: Remove calls to these methods.  I suppose it
might be possible this is needed and was piggy-backing on the
privileged setting but since that's been broken for a while I doubt
this is needed.  If so we can bring back the implementation into
this source file.
* src/config.h.W32.template: Remove GETLOADAVG_PRIVILEGED undef.
* src/config.h-vms.template: Ditto.
* src/config.ami.template: Ditto.
2022-07-09 10:47:13 -04:00
Paul Smith
3f3eecc115 * maintMakefile: Allow checkcfg rules to succeed.
We can no longer pass our mondo-warnings options to the builds,
as these will impact all the code including gnulib code, and this
won't work.  Also allow the caller to disable either the build.sh
or makefile invocation, for testing.
* Makefile.am: Allow the caller to reset the path to the make
binary to be tested.  Remove c90 test: gnulib doesn't support it.
2022-07-09 10:46:47 -04:00
Paul Smith
b09e9af0b8 * build.sh: Manage libgnu_a-prefixed source files 2022-07-09 10:46:47 -04:00
Paul Smith
9992cb0b83 bootstrap: Remove strerror()
* bootstrap.conf: Remove strerror module
* configure.ac: Add a check for strerror
* src/misc.c: Add a default strerror() if not found
2022-07-09 10:46:47 -04:00
Paul Smith
0cbee1b475 bootstrap: Remove strtoll()
This pulls in entirely too much stuff we don't need.  Instead grab
just the gnulib source file, then include it in src/misc.c.

* bootstrap.conf: Add just the lib/strtol.c source file.
* configure.ac: Check for strtoll.
* src/misc.c: Include strtol.c, with QUAD set, if needed.
2022-07-09 10:46:47 -04:00
Paul Smith
d63925d863 bootstrap: Remove gnulib version of mempcpy()
This pulls in a metric ton of stuff that we otherwise don't need, just
for a one-liner that we already have a replacement for in src/misc.c.

* bootstrap.conf: Remove mempcpy
* configure.ac: Add mempcpy to AC_CHECK_FUNCS
2022-07-09 10:46:47 -04:00
Paul Smith
0793658c09 Run autoupdate and clean up autoconf usage
We can assume that the return type of a signal handler is void.
We can assume that, if sys/time.h exists, it can be included
with time.h.

* bootstrap: Get the latest version
* configure.ac: Require a newer version of autoconf.
Remove unnecessary AC_PROG_CC_C99 (already have AC_PROC_CC).
Remove unnecessary AC_AIX, AC_ISC_POSIX, AC_MINIX.
Remove unnecessary AC_HEADER_STDC, AC_HEADER_TIME, AC_TYPE_SIGNAL.
Use strerror to search for the cposix library.
* src/commands.c (fatal_error_signal): Assume return type is void.
* src/commands.h: Ditto.
* src/job.c: Ditto.
* src/job.h: Ditto.
* src/main.c: Ditto.
* src/makeint.h: Ditto.
Don't bother with TIME_WITH_SYS_TIME.
* src/remote-cstms.c: Check HAVE_SYS_TIME_H.
* src/config.ami.template: Remove RETSIGTYPE.
* src/config.h-vms.template: Ditto.
* src/config.h.W32.template: Ditto.
Remove TIME_WITH_SYS_TIME.
2022-07-09 10:46:47 -04:00
Paul Smith
98da874c43 [SV 10593] Export variables to $(shell ...) commands
Export all variables, including exported makefile variables, when
invoking a shell for the $(shell ...) function.  If we detect a
recursive variable expansion, silently ignore that variable and do
not export it.  We do print a debug message.

* NEWS: Announce the potential backward-incompatibility.
* doc/make.texi (Shell Function): Document the export behavior.
* src/main.c (main): Add "shell-export" to .FEATURES.
* src/job.h: New function to free struct childbase.
* src/job.c (free_childbase): Implement it; call from free_child.
* src/function.c (func_shell_base): Use target_environment() to
obtain the proper environment for the shell function.
Use free_childbase() to free memory.
(windows32_openpipe): Don't reset the environment: the caller
already provided a proper PATH variable in envp.
* src/variable.c (target_environment): If we detect a recursive
expansion and we're called from func_shell, ignore the variable.
(sync_Path_environment): Simplify and reduce memory allocation.
* tests/scripts/functions/shell: Add tests for this.
2022-07-09 10:44:21 -04:00
Dmitry Goncharov
88d6c22a48 [SV 62650] Show correct warning when combining targets
* src/file.c (rehash_file): Fix warning message.
(rehash_file): Fix comment to match the behavior.
* tests/scripts/features/se_explicit: Fix test.
* tests/scripts/features/mult_rules: Add a new test.
2022-07-09 10:44:00 -04:00
Dmitry Goncharov
c3b39d0654 [SV 62514] Honor command line interface flags
Commit f2771aa614 introduced a bug where some switches were left out
of MAKEFLAGS.  Instead of resetting switches, get the same results by
filtering out duplicates.

* src/makeint.h: Remove reset_switches.
* src/main.c: (reset_switches): Remove reset_switches.
* (main): Remove call to reset_switches.
* (decode_switches): Filter out duplicate flags.
* src/variable.c: (set_special_var):  Remove call to reset_switches.
* tests/scripts/variables/MAKEFLAGS: Verify that duplicate flags are
properly filtered out.
2022-07-09 10:43:33 -04:00
Paul Smith
fe55d6e1e3 Add gnulib findprog-in 2022-07-07 02:12:54 -04:00
Paul Smith
768f287a06 Add gnulib concat-filename 2022-07-07 02:12:54 -04:00
Paul Smith
8dd302cda6 Add gnulib getloadavg 2022-07-07 01:53:08 -04:00
Paul Smith
df75efb114 Initial gnulib-port branch commit 2022-07-07 01:53:08 -04:00
Paul Smith
3ec497f8f8 Don't add GNUMAKEFLAGS to the environment
If GNUMAKEFLAGS was not present in the environment when we started,
don't add it.

* src/main.c (main): Don't mess with GNUMAKEFLAGS unless it exists.
* tests/scripts/variables/GNUMAKEFLAGS: Test this behavior.
2022-06-19 14:35:27 -04:00
Paul Smith
84ed34ba5a * tests/test_driver.pl: Don't freak if diff can't be found 2022-06-18 16:42:37 -04:00
Paul Smith
08c964b4ac * build_w32.bat [WIN]: Use call for all invocations 2022-06-18 16:42:11 -04:00
Paul Smith
97e51c0285 Avoid overwriting buffers with long pathnames
Reported, with initial patch, by Gisle Vanem <gvanem@online.no>

* src/main.c (find_and_set_default_shell) [W32]: Pass search_token
directly to w32ify: no need to make a copy first.  When we need to
construct a path, use snprintf() to be sure we don't overwrite
the locally-allocated buffer.
* src/w32/pathstuff.c (w32ify) [W32]: Use the malloc version of
_fullpath(), followed by strncpy(), to avoid overwriting buffers.
2022-06-17 19:55:11 -04:00
Paul Smith
59abb46bc9 * tests/scripts/features/temp_stdin: Remove nested "my"
* tests/scripts/features/statipattrules: Remove unset variable refs.
2022-06-04 19:04:37 -04:00
Dmitry Goncharov
6d6f12b0c3 * tests/scripts/features/archives: Fix typo 2022-06-04 19:04:37 -04:00
Sergei Trofimovich
621d3196fa [SV 62100] Add '--shuffle' option support
Introduce non-deterministic ordering into goal and prerequisite
traversal to help tease out inconsistent failures that may happen
when running in parallel build mode.

Introduce second order into each dependency chain:
1. Existing order is syntactic order reachable via 'dep->next'
2. New order is shuffled order stored as 'dep->shuf' in each 'dep'

When updating goals and prerequisites and '--shuffle' is provided,
use the shuffled order to walk the graph.  When automatic variable
are set always use the syntactic order of parameters.

* Makefile.am: Add new src/shuffle.c and src/shuffle.h file.
* build_w32.bat: Ditto.
* builddos.bat: Ditto.
* makefile.com: Ditto.
* po/POTFILES.in: Ditto.
* doc/make.texi: Add documentation for --shuffle.
* doc/make.1: Ditto.
* src/dep.h (DEP): Add the shuf pointer.
* src/filedef.h (struct file): Add was_shuffled flag.
* src/main.c: (shuffle_mode): Global flag for the shuffle mode.
(usage): Add the --shuffle option.
(switches): Ditto.
(main): Set shuffle_mode based on the command line parameter.
Reshuffle prerequisites if requested.
* src/remake.c (update_goal_chain): Walk the shuffled list if enabled.
(update_file_1): Ditto.
* src/shuffle.h: Provide an interface for shuffling prerequisites.
* src/shuffle.c: Implement option parsing and prerequisite shuffling.
* tests/scripts/options/shuffle: Test shuffle option and modes.
2022-06-04 19:04:37 -04:00
Paul Smith
e4b7ac21dc * src/misc.c (make_toui): Parse a string into an unsigned int
* src/makeint.h: Declare it.
* src/arscan.c (ar_scan): Replace atoi() calls with make_toui().
Modify some integral types to be more correct.
* src/job.c (load_too_high): Replace atoi() calls with make_toui().
* src/main.c (main): Ditto.
(decode_switches): Ditto.
2022-06-04 18:34:15 -04:00
Paul Smith
d444b87173 * src/misc.c (make_pid): A function to return the PID
* src/makeint.h: Declare it.
* src/commands.c (fatal_error_signal): Call it.
2022-06-04 17:04:38 -04:00
Paul Smith
1c179f9636 * po/LINGUAS: Add a translation for Romanian 2022-06-04 17:04:38 -04:00
Noah Goldstein
5690084634 Replace strcmp() with memcmp() where possible
memcmp() is always faster than strcmp().  In places where we already
know that both buffers have sufficient size, replace strcmp() with
memcmp().

* src/main.c (main): Replace strncmp() with memcmp()==0.
* src/read.c (word1eq): Ditto.
* src/commands.c (set_file_variables): Ditto.
* src/function.c (func_filter_filterout): Ditto.
(a_word_hash_cmp): Use STRING_N_COMPARE since we know the length.
(func_sort): Replace strcmp() with memcmp().
2022-04-24 17:52:54 -04:00
Noah Goldstein
9fa63eb918 hash: Remove unnecessary isupper() check before tolower()
The standard requires that tolower() returns its argument if there's
no valid lowercase conversion: it's not necessary to check isupper()
before invoking tolower().

Comparing the performance of the old ISTRING_HASH to the new one
on all the files present in GLIBC.

  Data Type            Old Time   New Time
  Alternating case    24985.754  13883.422
  random case         35211.777  13569.051
  all lower           18818.974  13706.645
  all upper           38859.454  13506.315

* src/hash.h (ISTRING_HASH_1): Omit isupper() check.
(ISTRING_HASH_2): Ditto.
2022-04-24 17:52:54 -04:00
Dmitry Goncharov
668eda0527 [SV 62206] Fix %-substitution in second expansion of pattern rules
During second expansion of pattern rules only the first pattern in
each "group" was being substituted.  E.g. in this makefile:

  .SECONDEXPANSION:
  all: hello.x
  %.x: $$(wordlist 1, 99, %.1 %.%.2) ; $(info $@ from $^)
  hello.1 hello.\%.2 \%.1 \%.\%.2: ;

the output would build "hello.1" and "%.%.2" because each function
is considered a single "word" and only the first pattern is replaced.

Fix the expansion so each whitespace-separated string is considered a
word and the first pattern is replaced, giving "hello.1" and
"hello.%.2".

* src/rule.c (snap_implicit_rules): Keep enough space to replace %
with $(*F) if necessary.
* src/implicit.c (pattern_search): During second expansion break each
get_next_word result into individual words and replace the first % in
each with $* or $(*F) as needed.
* tests/scripts/features/patternrules: Add tests for variations.
2022-04-24 17:52:07 -04:00
Dmitry Goncharov
4e1be4a60c [SV 62175] Rework secondary expansion tests
The hash function we use can yield different results on big- and
little-endian systems which makes test output different.  Choose
names to avoid this.

* tests/scripts/features/patternrules: Choose portable target names.
* tests/scripts/features/se_explicit: Ditto.
* tests/scripts/features/se_implicit: Ditto.
2022-04-24 14:56:26 -04:00
Paul Smith
5b1e871d2d * Makefile.am (check-regression): Rename jhelp to thelp 2022-04-24 13:48:03 -04:00
Paul Smith
2da3bb46f2 * tests/scripts/options/dash-f: [SV 62118] Close STDIN
On Windows we can't delete open files, so close STDIN before
removing the temporary input file.
2022-04-24 13:48:03 -04:00
Paul Smith
b264d3d4f8 * tests/scripts/features/reinvoke: [SV 62088] Close STDIN
On Windows we can't delete open files, so close STDIN before
removing the temporary input file.
2022-04-24 13:48:03 -04:00
Paul Smith
51c1c07e7a * tests/test_driver.pl (run_all_tests): Keep one copy of STDIN 2022-04-24 13:48:03 -04:00
Paul Smith
700af780af * Makefile.am: Add INSTALL to the EXTRA_DIST files 2022-04-24 10:39:32 -04:00
Dmitry Goncharov
f14824878d [SV 62356] If -R is set in the makefile, disable -r
If -R is given on the command line it implies -r as well; make this
same assumption if -R is provided in MAKEFLAGS set in the makefile.

* src/main.c (main): Check no_builtin_variables_flag after reading
makefiles.
* tests/scripts/options/dash-r: Add a test.
2022-04-24 10:39:32 -04:00
Dmitry Goncharov
8c2aa889bb [SV 62324] Simplify set_file_variables by passing in the stem
Previously we always used the file->stem value as our stem in
set_file_variables(); when that wasn't correct we had to temporarily
set that value while the function was called, then reset it afterward.
This led to issues (for example when we assumed the stem was a cached
string but it wasn't).

Avoid this by passing in the stem as an argument so that different
values can be provided.

Add tests to verify this.

* src/commands.c (set_file_variables): Take second parameter stem to
relieve the callers of set_file_variables() from setting/restoring
file->stem.
* src/commands.h (set_file_variables): Ditto.
(execute_file_commands): Pass file->stem to set_file_variables().
* src/file.c (expand_deps): Pass d->stem to set_file_variables() and
remove set and restore of file->stem.
* src/implicit.c (pattern_search): Pass stem to set_file_variables()
and remove set and restore of file->stem.
* tests/scripts/features/se_explicit: Add new tests.
* tests/scripts/features/se_implicit: Ditto.
* tests/scripts/features/se_statpat: Ditto.
* tests/scripts/variables/automatic: Ditto.
2022-04-24 10:39:32 -04:00
Dmitry Goncharov
bb21dd4d2d [SV 62278] Only expand the first pattern during secondary expansion
During normal pattern rule expansion only the first pattern (%) is
expanded; however during secondary expansion all patterns were
expanded.  Modify secondary expansion to match the behavior of normal
expansion.

Implementation tweaked by Paul Smith <psmith@gnu.org>

* src/file.c (expand_deps): Don't use subst_expand() which replaces
all % with $*: instead replace only the first one, by hand.
Fix a memory leak where the dep structure was not always freed.
* tests/scripts/features/statipattrules: Use .RECIPEPREFIX not TAB.
Add a series of tests verifying that static pattern rules with and
without secondary expansion both return the same results.
2022-04-24 10:39:32 -04:00
Paul Smith
93fd0c0c9a * src/commands.h: [SV 62213] Forward-declare struct file / child 2022-04-24 10:39:32 -04:00
Paul Smith
cf56036c60 * tests/test_driver.pl (toplevel): [SV 62174] Enforce the C locale 2022-04-24 10:39:32 -04:00
Paul Smith
88ceff8b2f [SV 62173] Fix archive tests for non-GNU systems
Original patch from Dmitry Goncharov <dgoncharov@users.sf.net>

Fix the ar flags to match the default values in make.  If the
U option is supported, add it to the end not the beginning,
since ARFLAGS now starts with a "-".

* tests/test_driver.pl: Add defaults for global variables.
(get_osname): Preserve $osname if it's set from $^O
* tests/scripts/features/archive: Set the default arflags.
If "U" is available add it to the end of the flags.
2022-04-24 10:39:32 -04:00
Dmitry Goncharov
9755d4c09c * tests/scripts/options/dash-l: [SV 62172] Skip if not available 2022-04-24 10:39:32 -04:00
Dmitry Goncharov
634ef057ad * src/read.c (check_specials): [SV 62171] Reset ARFLAGS under .POSIX 2022-04-24 10:39:32 -04:00
Dmitry Goncharov
949c0464a9 [SV 62145] Remove a stdin temp file on re-exec failure.
If the re-exec fails, be sure to remove a temp makefile that was
created to read from stdin.

* src/job.c (exec_command): Return on failure.
(child_execute_job): Call exit if exec_command returns.
* src/job.h (exec_command): Don't mark as NORETURN.
* src/main.c (main): Unlink stdin temporary file if re-exec fails.
* tests/run_make_tests.pl: Get value for ERR_nonexe_file/ERR_exe_dir.
* tests/scripts/features/temp_stdin: Test that temp file unlink works.
2022-04-24 10:39:32 -04:00
Paul Smith
416664b1e7 * tests/scripts/features/errors: Fix Perl warnings
* tests/scripts/options/dash-f: Ditto.
2022-04-18 16:57:06 -04:00
Paul Smith
667d70eac2 [SV 62118] Correctly handle -f- options on re-exec
The -f, -file, and --makefile options were not properly handled when
re-exec'ing due to makefile updates.  This problem, plus a patch and
tests, was reported by Dmitry Goncharov <dgoncharov@users.sf.net>.

While examining this I found another bug: after re-exec we forgot the
batch file was temporary and never deleted it.

I decided to fix all these problems at once using a different fix
than Dmitry's: I created a new internal-only command-line option,
--temp-stdin.  When reconstructing the make options for a re-exec,
replace the -f/--file/--makefile option that reads from stdin with
--temp-stdin=<filename> so that the re-exec'd version of make knows
it's a temporary batch file and will delete it.

We no longer need to add the -o options because the re-exec'd make
knows this is a temporary makefile and treats it as such.

To simplify, replace the --file and --makefile options taking a
filename, with just -f<filename> on re-exec.

Some examples of the rewrite:

  User command line               Re-exec command line
  -----------------               --------------------
  -f-                             --temp-stdin=<batch>
  --file -                        --temp-stdin=<batch>
  -f - --makefile a.mk            --temp-stdin=<batch> -fa.mk
  --file=a.mk                     -fa.mk
  -fa.mk                          -fa.mk
  -Rf a.mk                        -Rf a.mk
  -Rf-                            -R --temp-stdin=<batch>

* src/main.c (stdin_offset): Remember the offset into the makefiles
list of the batch file read from stdin.  Remove stdin_nm.
(struct command_switch): Create a new --temp-stdin option, which
also updates the makefiles list.
(main): Add the temporary filename to the string cache.
Move the tempfile handling after checking makefile arguments for "-"
so that files provided via --temp-stdin are also handled specially.
When rewriting re-exec options, we may need one more than we had
originally so create a new argv list.  Walk through the original
list and convert it to the new list, following the above process.
(decode_switches): Set the stdin_offset flag if we see --temp-stdin.
* tests/scripts/options/dash-f: Add many more tests, provided by
Dmitry Goncharov <dgoncharov@users.sf.net>.
2022-02-27 18:01:13 -05:00
Paul Smith
b9078e5bd3 * tests/scripts/variables/MAKE_RESTARTS: Remove TAB chars 2022-02-27 18:01:13 -05:00
Paul Smith
0de7b74896 * README.git: Fix compiler options for ASAN 2022-02-27 18:01:13 -05:00
Paul Smith
236589642e Remove extraneous characters from fatal() calls
The fatal() method adds ".  Stop.\n" to every message.

* src/amiga.c (MyExecute): Remove newline from fatal() message.
* src/job.c (<various>): Ditto.
* src/file.c (snap_deps): Remove "." from fatal() message.
* src/main.c (main): Ditto.
* src/load.c: Ditto.
* tests/scripts/targets/NOTINTERMEDIATE: Fix expected output.
2022-02-27 18:01:13 -05:00
Paul Smith
cb9ac2b0cc * src/main.c: Ensure the stdin temp file is deleted when dying. 2022-02-27 18:01:13 -05:00
Dmitry Goncharov
40a6751abf [SV 62088] Avoid re-exec due to stdin.
The fix for SV 60595 causes make to re-execute when the makefile is
read from stdin.  E.g.
    $ printf 'all:; $(info hello)' | make -sf -

Reported by Sergei Trofimovich <siarheit@google.com>
Test added by Paul Smith <psmith@gnu.org>

* src/main.c (main): Set the mtime of the stdin temporary file.
* tests/scripts/features/reinvoke: Add a test.
2022-02-27 18:00:47 -05:00
Paul Smith
1bc35a7ae7 tests: Allow run_make_test() to avoid passing -f
We already use undef makefile strings to mean "re-use the previous
makefile", so if the string is empty we'll assume it means "don't
use a makefile at all" (don't add -f).

* tests/run_make_tests.pl (run_make_test): If the makefile string
is empty, don't create a makefile or add -f.
* tests/scripts/features/include: Change empty makefile to "\n".
* tests/scripts/misc/close_stdout: Ditto.
* tests/scripts/options/dash-r: Ditto.
2022-02-27 17:47:42 -05:00
Paul Smith
8cdaabbf8e tests: Preserve Windows temp environment variables
* src/main.c (main): Show the temp filename on error.  Also on
Windows prefer TMP, then TEMP, and only lastly TMPDIR.
* tests/test_driver.pl: Add TMP, TEMP, and USERPROFILE to the list
of environment variables to preserve.
2022-02-27 17:47:19 -05:00
Paul Smith
2be8661433 * tests/test_driver.pl: Support STDIN redirection.
Before running tests, duplicate STDIN then reset it after the test
completes.  Also when -keep is provided, preserve the base and run
files.
2022-02-26 17:19:26 -05:00
Paul Smith
8b3e678ace Ensure buffers are large enough for integer values
Issue raised by Sergei Trofimovich <siarheit@google.com>

* src/makeint.h (INTSTR_LENGTH): Update for unsigned values.
* src/function.c (func_lastword): Use INTSTR_LENGTH as buffer size.
(shell_function_completed): Ditto.
(func_call): Ditto.
* src/remote-cstms.c (start_remote_job): Ditto.
2022-02-21 09:29:41 -05:00
Paul Smith
ec09ec775a * <all>: Update copyright notices. 2022-02-10 14:48:26 -05:00
Paul Smith
bdaeca49e9 * doc/make.1: Use "target" from the SYNOPSIS.
Reported by Helge Kreutzmann <debian@helgefjell.de>
2022-02-06 18:46:32 -05:00
Paul Smith
342a9bb54b Don't write $(shell ...) stdout to stderr on failure
If a $(shell ...) invocation failed due to a command-not-found error,
make wrote the stdout of that shell to our stderr for some reason.
That seems very wrong.

If the command's stderr was not redirected then its output would have
already been written to its stderr, and if it was redirected then we
shouldn't take it upon ourselves to force it to go to stderr!

* src/function.c (func_shell_base): Append shell stdout even if the
shell command failed.
* tests/run_make_tests.pl: Determine the error generated for
command-not-found situations.
* tests/scripts/functions/shell: Verify that redirecting stderr to
stdout will behave properly if the command is not found.
2022-02-06 18:46:32 -05:00
Paul Smith
6761122be0 * Basic.mk.template: Allow arguments to the check target. 2022-02-06 18:46:32 -05:00
Dmitry Goncharov
1fd0bfaf1e [SV 61805] Support quoted whitespace in .SHELLFLAGS with .ONESHELL
* src/job.c (construct_command_argv_internal): Call recursively to
parse .SHELLFLAGS when .ONESHELL is active.
* tests/scripts/targets/ONESHELL: Add tests.
2022-02-06 18:46:32 -05:00
Paul Smith
8eb171e469 * tests/scripts/features/double_colon: Update for modern tests. 2022-02-06 18:46:32 -05:00
Paul Smith
7154e316b7 * tests/scripts/features/implicit_search: Add -r for safety. 2022-02-06 18:46:32 -05:00
Dmitry Goncharov
f3e345c869 [SV 48643] Add more tests of intermediates and unrelated targets
If a prereq of a pattern is explicitly mentioned as a prereq of an
unrelated rule, it should not be considered an intermediate file.

* tests/scripts/features/double_colon: Add tests mentioning unrelated
explicit targets.
* tests/scripts/features/grouped_targets: Ditto.
* tests/scripts/features/implicit_search: Ditto.
* tests/scripts/features/patternrules: Ditto.
* tests/scripts/features/se_implicit: Ditto.
* tests/scripts/features/statipattrules: Ditto.
2022-02-06 18:46:32 -05:00
Dmitry Goncharov
d34f46c1f3 [SV 48643] Make prereqs mentioned in unrelated rules explicit
* src/implicit.c (pattern_search): Set is_explicit when a prereq
is mentioned in an unrelated rule.
2022-02-06 18:46:32 -05:00
Dmitry Goncharov
f0ab709640 * src/implicit.c (pattern_search): [SV 61864] Fix debug output. 2022-02-06 18:46:32 -05:00
Paul Smith
5f2d114c6d Avoid interleaved $(info ) output
Since $(info ) function output is written using two system calls for
the message and the newline, it's possible for output from another
parallel make job to sneak in between them.

Reported by Paul Eggert <eggert@cs.ucla.edu>, who saw the report from
Lars Ingebrigtsen <https://bugs.gnu.org/53358>.

* src/function.c (func_error): Paul provided a fix but instead I
rewrote the entire function: it's not possible for it to be invoked
with anything other than exactly one argument so don't worry about
re-combining the arguments.
2022-02-06 18:46:32 -05:00
Paul Smith
cbe0d2e47f * tests/scripts/features/implicit_search: [SV 48643] Cleanups. 2022-02-06 18:46:32 -05:00
Paul Smith
f485881d4a * src/implicit.c (pattern_search): Use const ptrs when possible.
Change suggested by Joe Filion <joefilion4@gmail.com>
2022-02-06 18:46:32 -05:00
Paul Smith
15db387f18 * src/job.c (load_too_high): Re-enable Linux /proc/loadavg checks.
Further experimentation shows that my previous thinking that there
was a problem using this was woefully mistaken.  The value generated
by the kernel shows runn*ABLE* processes not runn*ING* processes.
* NEWS: Announce the change.
2022-02-06 18:46:32 -05:00
Paul Smith
aab51f7ef2 * doc/make.texi (Using One Shell): Correct example to use $<. 2022-02-06 18:46:29 -05:00
Jouke Witteveen
2b25eac587 * src/function.c (parse_textint): Handle ints without 0 properly.
* tests/scripts/functions/intcmp: Add tests for values without 0.
2022-01-17 19:11:59 -05:00
Paul Smith
e72c5e021f [SV 61226] Revert changes to detect missing included files
The fix for SV 60595 introduced a backward-incompatibility: rules that
purported to rebuild included files, but didn't actually do so, were
treated as errors whereas before they were ignored.  This breaks a
common idiom in makefiles where an empty recipe is created for an
included makefile so make doesn't complain if it doesn't exist.

Unfortunately this means make cannot diagnose some types of errors.

Extra tests supplied by Dmitry Goncharov <dgoncharov@users.sf.net>.

* doc/make.texi (Including Other Makefiles): Clarify this behavior.
* src/main.c (main): Don't run the new check-for-errors behavior.
* tests/scripts/features/reinvoke: Reset tests of the "old" behavior
and add new tests for this situation.
2022-01-17 18:45:47 -05:00
Paul Smith
b6a779d262 Ensure that loaded functions increment the command count
Since we don't know what a loaded function (via Guile or load) may
do, increment the command count just in case.

* src/function.c (struct file_table_entry): New adds_command bool.
(FT_ENTRY): Initialize it to 0 for built-in functions.
(expand_builtin_function): If adds_command, increment the count.
(define_new_function): Set adds_command for loaded functions.
2022-01-17 18:45:47 -05:00
Paul Smith
26f4bb89bd * src/read.c (tilde_expand): Put back '/' before returning.
Joe Filion <joefilion4@gmail.com> noted that the string is modified,
and Henrik Carlqvist <hc94@poolhem.se> noticed that it wasn't put
back in all cases.
2022-01-17 18:38:32 -05:00
Paul Smith
320714ae85 * tests/scripts/targets/INTERMEDIATE: Rewrite for new test method 2021-12-29 15:27:04 -05:00
Paul Smith
6682fbc2cb Do not force targets to be SECONDARY
In SV 43677 we forced targets to be secondary if we found an
intermediate file that was listed as a prerequisite of another
target.  This overrides .INTERMEDIATE settings, so doesn't work.
Now that we have an is_explicit flag in targets, use that instead.

* src/implicit.c (pattern_search): Remove setting of secondary.
Preserve the value of the is_explicit flag when creating a new
file target, and consider it when setting the intermediate flag.
* tests/scripts/features/patternrules: Add a test w/out INTERMEDIATE
* tests/scripts/targets/INTERMEDIATE: Add a test with INTERMEDIATE
2021-12-29 15:26:56 -05:00
Dmitry Goncharov
f2b130bda8 [SV 48643] Preserve target-specific variables on intermediate files
Target-specific variables used to define the target as "ought to
exist" so they could never be intermediate.  Now they can be, so
merge the target-specific variables from the intermediate target
so they're not lost.

* src/implicit.c (pattern_search): Use merge_variable_set_lists
to merge target-specific variables.
* tests/scripts/features/implicit_search: Add tests of target-
specific variable assignments and implicit rules.
2021-12-29 15:26:56 -05:00
Paul Smith
8aba33a8bd * README.template: Clean up patch submission information 2021-12-29 15:26:54 -05:00
Jouke Witteveen
d365bdfdbc * src/read.c (find_percent_cached): [SV 60798] Silence GCC11 warnings 2021-12-19 16:55:50 -05:00
Jouke Witteveen
f440c3ebe2 [SV 60798] Silence bogus GCC10 and GCC11 warnings
* src/main.c (main): Use a separate variable to track final character.
* src/read.c (eval): Track the semicolon position not one beyond it.
* src/variable.c (do_variable_definition): Include a default switch
case to ease the work of the exhaustiveness prover.
2021-12-19 16:55:50 -05:00
Paul Smith
3efba8a145 Update documentation with instructions for patch submission
* README.template: Add notes on how to submit patches.
* README.git: Point to the README.
* doc/make.texi: Ditto.
2021-12-19 16:55:50 -05:00
Paul Smith
e7b2f6818c Change HTTP URLs to use HTTPS instead
Also remove unnecessary tests/COPYING file.

* README.template: Change http: to https:
* README.git: Ditto
* doc/make.texi: Ditto
* doc/make.1: Ditto
* src/main.c: Ditto
* maintMakefile: Remove invalid URL
2021-12-19 16:55:50 -05:00
Paul Smith
c90db9276a * src/makeint.h: Compute INTSTR_LENGTH based on size of intmax_t
Math suggested by Edward Welbourne <edward.welbourne@qt.io>
2021-12-19 16:55:47 -05:00
Paul Eggert
7192d0ec4a Remove arbitrary limits on intcmp integers
We don't need to parse strings into C integer values to compare them.

* src/function.c (parse_textint): Find boundaries of a numeric string.
(func_intcmp): Use parse_textint() to compare integers textually.
* tests/scripts/functions/intcmp: Test with extra-large numbers.
2021-12-19 16:34:19 -05:00
Paul Smith
9230bfb9ae Use a well-known error string for out-of-bound function arguments
* src/function.c (parse_numeric): Check for empty value and error.
If we find ERANGE just print our own error, not strerror.
(func_word): Use a generic "not good" error message.
(func_wordlist): Ditto
(func_intcmp): Ditto
* tests/run_make_tests.pl: Remove code to find strerror(ERANGE)
* tests/scrips/functions/intcmp: Update the error message.
* tests/scrips/functions/word: Ditto.
2021-12-19 16:34:19 -05:00
Paul Smith
55b993ae09 * doc/make.text (Wildcards): Document that glob results are sorted. 2021-12-19 16:34:19 -05:00
Paul Smith
1d20aa7247 [SV 61621] Don't use POSIX_SPAWN_RESETIDS with posix_spawn()
When make is invoked in a environment where the user namespace is
restricted, such as under unshare(1) (on GNU/Linux), it won't be able
to find its real UID so the effective UID can't be set to it and
posix_spawn() will fail with EINVAL.

It's not less safe to run recipe jobs using the same UID values that
make was invoked with, so don't worry about this flag.

* src/job.c (child_execute_job): Don't set POSIX_SPAWN_RESETIDS flag.
2021-12-19 16:34:10 -05:00
Paul Smith
21f7ac8f47 * .gitignore: Ignore patch files. 2021-12-05 14:22:37 -05:00
U2FsdGVkX1
aa376ad638 * src/commands.c (fatal_error_signal) [W32]: Use %lu for DWORD.
* src/function.c (windows32_openpipe) [W32]: Ditto.

Copyright-paperwork-exempt: yes
2021-11-28 15:51:37 -05:00
Paul Smith
35b51df110 * NEWS: Update with author details 2021-11-28 14:34:05 -05:00
Paul Smith
e62f4cf9a2 Special-case Windows error results
* tests/scripts/features/errors: Match Windows-specific errors.
* tests/scripts/features/targetvars: Match Windows-specific errors.
* tests/scripts/misc/general4: Match Windows-specific errors.
2021-11-28 14:27:10 -05:00
Paul Smith
116767901f Convert word, wordlist, and intcmp functions to use long long
Modify make functions that parse integer values to use long long
values instead of long: on Windows long is the same as int (4 bytes)
and we don't want behavior to differ between different platforms.

* bootstrap.conf: Change strtol module to strtoll module.
* src/function.c (parse_numeric): Use strtoll() and return long long.
(func_word): Use long long.
(func_wordlist): Use long long.  Verify second argument is >= 0.
(func_intcmp): Use long long.
* src/config.ami.template: Don't define HAVE_STRTOLL.
* src/config-vms.template: Define HAVE_STRTOLL.
* src/config.W32.template: Define HAVE_STRTOLL.
* tests/run_make_tests.pl: Set $ERR_out_of_range to the proper string.
* tests/scripts/functions/word: Rework to use the new style and avoid
TAB characters.  Verify trailing whitespace is ignored.  Add a test
for a negative second argument to wordlist.  Add tests for max signed
integer values.  Use $ERR_out_of_range for the error string.
* tests/scripts/functions/intcmp: Add tests for min and max signed
integer values.  Use $ERR_out_of_range for the error string.
2021-11-28 14:27:10 -05:00
Jouke Witteveen
71eb0a8038 Introduce $(intcmp ...) for numerical comparison
Numbers can come from $(words ...), automatic variables such as
$(MAKELEVEL), from environment variables, or from shell output such as
through $(shell expr ...).  The $(intcmp ...) function allows
conditional evaluation controlled by numerical variables.

* NEWS: Announce this feature.
* doc/make.texi (Functions for Conditionals): Document 'intcmp'.
* src/function.c (func_intcmp): Create the 'intcmp' built-in function.
* tests/scripts/functions/intcmp: Test the 'intcmp' built-in function.
2021-11-28 14:27:10 -05:00
Jouke Witteveen
d9291d09b8 Use strtol() instead of atoi()
strtol() is part of C89 and a fallback is provided by gnulib.

* src/function.c (func_word, func_wordlist): Change atoi to strtol.
* test/scripts/functions/word: Add out-of-range verification testing.
2021-11-28 14:26:28 -05:00
Jouke Witteveen
f3ad572099 * src/makeint.h: Removed unused atol declaration 2021-11-27 22:05:29 -05:00
Paul Smith
cefe747e85 * src/implicit.c (pattern_search): Fix text for easier translation. 2021-11-27 22:00:12 -05:00
Paul Smith
3ecf97d3af [SV 48643] Update the implicit rule search docs
* NEWS: Announce the change.
* doc/make.texi (Implicit Rule Search): Update the definition of
"ought to exist" and add the extra step for compatibility mode.
2021-11-27 22:00:12 -05:00
Dmitry Goncharov
21d3865973 [SV 48643] Enhance "ought to exist" definition
The traditional definition of "ought to exist" in the user's manual can
lead to make choosing a poor series of chained implicit rules.  Modify
that rule so that we first attempt to resolve implicit rules by
considering targets which are only (a) targets or (b) explicit
prerequisites of the current target.

For backward-compatibility, if we don't find a solution using that
algorithm use the previous definition where "ought to exist" means
"mentioned as a prerequisite of any target".

* src/implicit.c (pattern_search): An extra argument controls whether
to perform the backward-compatible rule search or not.  If a prereq is
a target, or if it's a prerequisite of THIS target, then choose it.
If we get to the end and haven't found a match, but we have found a
potential compatibility rule, then retry with compat rules enabled.
If we're searching with compat rules enabled and we find a file
mentioned as a prerequisite of ANY target, then use it.
* tests/features/implicit_search: Provide a large suite of tests for
different steps of implicit rule search.
2021-11-27 22:00:05 -05:00
Paul Smith
29d92d4091 tests: Enhance output to contain filename/line number info
* tests/scripts/options/dash-I: Use string comparison operator.
* tests/test_driver.pl (cmd2str): New method to convert a
command line to a string with proper quoting.
* tests/run_make_tests.pl (create_command): Call cmd2str() to format
the command.  Add the filename/line number to the output.
2021-11-27 14:03:44 -05:00
Dmitry Goncharov
f8f9d371ff [SV 61042] Enhance logging of implicit rule search
Logging of implicit rule search gives limited information as to why a
given implicit rule was rejected, and if no implicit rule is found we
get the confusing "No rule to make target" result when the real issue
is that some prerequisite of some implicit rule could not be built.

Enhance logging around implicit rule search as follows:
1. The messages which refer to a rule print a description (the targets
   and prerequisites) of the rule.
2. A new message tells when a rule is rejected, along with the reason.
3. The 'Looking for an implicit rule...' message is printed for every
   prerequisite, not just the top-level target.
4. "Trying harder" message is printed, when intermediate prerequisites
   are going to be searched.
5. The 'No rule found...' and 'Found implicit rule...' messages are
   printed for every prerequisite, not just the top-level target.
6. "Ought to exist...", "Found..." or "Not found..." message is
   printed for each prerequisite.

* src/rule.h (struct rule): Remember the definition of the rule.
* src/rule.c (get_rule_defn): Compute the definition of a rule.
(install_pattern_rule): Initialize the definition to empty.
(create_pattern_rule): Ditto.
(freerule): Free the definition.
(print_rule): Use the definition when printing rules.
* src/remake.c (update_file_1): Push debug output down into
try_implicit_rule().
* src/implicit.c (try_implicit_rule): Add debugging
(pattern_search): Show the rule definition in various debug output.
Add new debug messages for implicit rule search.

Additional changes by Paul Smith <psmith@gnu.org>:

Since we usually don't need the rule definition, defer computing it
until we do.

* bootstrap.conf: Include the mempcpy Gnulib module.
* src/makeint.h (mempcpy): Declare mempcpy if not available.
* src/misc.c (mempcpy): Define mempcpy if not available.
* src/config.h-vms.template: Don't set HAVE_MEMPCPY.
* src/config.h.W32.template: Ditto.
* src/rule.h (get_rule_defn): Return the definition of a rule.
* src/rule.c (get_rule_defn): If we don't have a definition compute
it; either way return it.
* src/implicit.c (pattern_search): Rework the handling of explicit
prerequisites to pattern rules to be more clear.  There is no change
in behavior.
2021-10-18 23:00:21 -04:00
Dmitry Goncharov
f5af979357 * doc/make.texi (Special Targets): [SV 61122] Add .SECONDARY example 2021-10-17 19:08:16 -04:00
Paul Smith
76cb186732 * README.git: Update C version prerequisite 2021-10-17 19:08:16 -04:00
Paul Smith
6c06c547dc Add support for the POSIX :::= assignment operator.
POSIX Issue 8 will require a new assignment operator, :::=.
This operator behaves similarly to the BSD make := operator: the
right-hand side is expanded immediately, but then the value is
re-escaped (all '$' are converted to '$$') and the resulting variable
is considered a recursive variable: the value is re-expanded on use.

* src/variable.h (enum variable_flavor): Add f_expand flavor.
* src/variable.c (do_variable_definition): When defining f_expand,
post-process the result to re-escape '$' characters.
Remove default: to the compiler warns about un-handled enum values.
Set recursive values for both f_recursive and f_expand.
(parse_variable_definition): Rewrite this method.
The previous version was annoying to extend to ':::='.
(print_variable): Remove default: so the compiler warns us about
un-handled enum values.
* src/function.c (func_origin): Remove default: so the compiler warns
us about un-handled enum values.
* doc/make.texi: Add documentation for :::=.
* tests/scripts/variables/define: Add a test for define :::=.
* tests/scripts/variables/flavors: Add tests for :::=.
* tests/scripts/variables/negative: Add tests for :::=.
2021-09-20 00:29:31 -04:00
Paul Smith
c5d4b7b2f2 Clean up more Windows warnings.
* src/config.h.W32.template: Re-enable warnings that we don't violate.
Add a new disabled warning: 4130 (logical operation on address of
string constant).
* src/w32/compat/posixfcn.c: Make makeint.h the first included header.
* src/w32/subproc/sub_proc.c: Ditto.  It includes config.h already.
2021-09-07 01:14:33 -04:00
Dmitry Goncharov
9e4b3d3f4c [SV 60435] Ensure intermediate grouped files are removed
If multiple intermediate files are built together be sure all of them
are removed after make is finished.  Continue to ensure that targets
that exist before make starts are not removed even if they appear to be
intermediate.

Add a number of tests to pattern rules to verify this behavior.

* src/filedef.h (struct file): Add a new is_explicit bitfield.
* src/file.c (rehash_file): Merge the is_explicit bit.
(enter_prereqs): Set is_explicit if the file is explicitly mentioned.
* src/implicit.c (pattern_search): Set intermediate on the file if it's
not explicit.
(record_files): Set is_explicit if a file is mentioned as a target.
* src/remake.c (update_file_1): Set secondary on files that already
exist so they won't be removed.
* tests/scripts/features/double_colon: Add a test for double-colon
pattern rules.
* tests/scripts/features/patternrules: Update KGO for tests where more
files are removed.
Add new tests to verify handling removal of intermediate files in the
context of grouped pattern targets.
2021-09-07 01:14:20 -04:00
Paul Smith
5a96d5a066 * src/default.c (default_variables): Use CPP in PREPROCESS.S. 2021-09-06 20:42:34 -04:00
Dmitry Goncharov
4488592dda * src/main.c (decode_debug_flags): [SV 607777] Preserve -d options
* tests/scripts/options/dash-d: Test that -d --trace keeps -d.
2021-09-06 20:36:15 -04:00
Dmitry Goncharov
e7eb8b5962 [SV 57778] Don't ignore included makefiles that can't be read
If we find an included makefile but it's not readable, stop
immediately with an error rather than continuing to look in other
directories.

* src/read.c (eval_makefile): Only keep searching if the fopen error
is ENOENT, else stop and fail.
* tests/scripts/features/include: Add tests to verify this behavior.
2021-09-06 20:20:28 -04:00
Paul Smith
0c2fc00544 [SV 60795] Don't remake phony included makefiles and show errors
Change the handling of included makefiles which are phony targets to
be similar to double-colon rules with no prerequisites: simply don't
build them at all during the remake a makefile phase.

Ensure that any included makefile which is needed but not built
results in an error.

Update the documentation to make this clear.
Add tests to verify this behavior.

* doc/make.texi (Remaking Makefiles): Clarify double-colon exception.
Document that phony targets are handled the same way.
(Phony Targets): Ditto.
* src/main.c (main): Check for phony targets when skipping goals.
Rather than throwing out skipped but failed goals keep them
separately then report them as errors.
* src/read.c (eval): Set the file location on included makefiles even
when there's no error.
* tests/scripts/features/include: Add tests for handling included
makefiles with both phony and double-colon rules to rebuild them.
2021-09-06 18:49:08 -04:00
Paul Smith
214df0e92a * doc/make.texi (Environment): [SV 60841] Clarify variable exporting. 2021-09-06 10:57:43 -04:00
Paul Smith
b2e898d0bf * doc/make.texi (Chained Rules): [SV 60904] Clarify intermediate files. 2021-09-06 10:46:52 -04:00
Paul Smith
abb1e8d10b Remove UBSAN issues discovered via fuzzing tests.
The arithmetic conversions in C say that if a binary operator has an
unsigned and signed type as operands and the unsigned type has a greater
rank then the signed value is converted to unsigned.  This is bad if the
signed value is negative.

There are a few places in the code which have this situation; convert
the signed value to positive and add instead of subtracting.

Reported by He Jingxuan <jingxuan.he@inf.ethz.ch>

* src/read.c (find_map_unquote): Use a positive int in memmove().
(find_char_unquote): Ditto.
(find_percent_cached): Ditto.
2021-09-06 00:14:57 -04:00
Paul Smith
cc6dc70b16 * doc/make.texi (Prerequisite Types): [SV 61069] Mention PHONY prereqs 2021-09-05 23:29:33 -04:00
Paul Smith
2638552859 * doc/make.1: Clean up man page text. 2021-09-05 23:17:26 -04:00
Paul Smith
de48d6a4f7 * README.git: Add a section on ways to test. 2021-09-05 22:28:36 -04:00
Paul Smith
55f06bdc3f * src/main.c (decode_switches): Fix memory leak. 2021-09-05 22:28:10 -04:00
Paul Smith
0d367bbe6e Clean up a few Windows build warnings (not all!)
* build_w32.bat: Quote uses of %VSWHERE% so it can contain spaces
* src/hash.c (hash_init): Avoid use of an undefined struct.
(hash_rehash): Ditto.
* src/vpath.c (construct_vpath_list): Cast explicitly to void*.
2021-09-05 21:09:27 -04:00
Paul Smith
f4b8ddf260 [SV 45211] Parse MAKEFLAGS immediately when it's reset
When MAKEFLAGS is set in a makefile, reparse it immediately rather
than waiting until after all makefiles have been read and parsed.
This change doesn't actually fix the SV bug referenced because, even
though we do reparse MAKEFLAGS, we don't handle the -r or -R options
immediately.  Doing this will require more effort.

* NEWS: Announce the change.
* src/makeint.h: Publish reset_switches() and decode_env_switches()
from main.c
* src/main.c (main): Don't call construct_include_path(); it will be
invoked decode_switches().
Preserve the old values of builtin_rules, builtin_variables, and
job_slots before we read makefiles since they can be changed now.
(reset_switches): Publish (remove static).  Set the initial value of
the stringlist list to NULL.
(decode_switches): Call construct_include_path() after decoding.
(decode_env_switches): Publish (remove static).
(define_makeflags): Set the MAKEFLAGS variable for special handling.
* src/read.c (eval_makefile): Check for empty include_directories.
(construct_include_path): Clear any old value of .INCLUDE_DIRS before
appending new values.  Free the previous include_directories.
* src/variable.c (lookup_special_var): When MAKEFLAGS is set, first
reset the switches then re-parse the variable.
* tests/run_make_tests.pl: Memo-ize some default variable values.
* tests/scripts/options/dash-r: Create tests for setting -r and -R.
* tests/scripts/variables/MAKEFLAGS: Test that resetting -I from
within the makefile takes effect immediately.
2021-09-05 21:08:59 -04:00
Paul Smith
e13fd5c83d * make-gdb.py: Add pretty-printers and clean up.
Create a pretty-printer for next-pointer lists.
Create a pretty-printer for stringlists.
Change showargv from a function to a command (easier to use).

Clean up some Python PEP violations.  Add support for testing null
pointers and caching gdb.Types.
2021-09-05 20:05:02 -04:00
Paul Smith
7c4e6b0299 [SV 60595] Restart whenever any makefile is rebuilt
Previously if an included makefile was rebuilt as a prerequisite of
another included makefile which didn't need to be rebuilt, make would
not realize that it needed to re-exec itself.

Ensure that if any included makefile target is rebuilt we re-exec.
Also ensure that if an included makefile is not readable, and our rule
for rebuilding it doesn't actually change it, we will still fail.

* src/remake.c (update_goal_chain): If a goal's update was successful
then check its status, even if no actual commands were run because it
was already up to date.
(show_goal_error): Remove superfluous cast.
* src/main.c (main): If the makefile remake did nothing, check that we
were able to successfully include all the makefiles we care about; if
not fail.  When generating error messages about included makefiles be
sure to show the filename/linenumber information.
* test/scripts/features/reinvoke: Add tests for this behavior.
* test/scripts/options/dash-k: Update error messages.
2021-09-03 12:08:11 -04:00
Paul Smith
b9c4fc441b [SV 60412] Allow -I- to throw out the current directory path
Accept a "-" directory value to the -I option to clear the set of
directories to be searched up to that point, including the default
directories.

* NEWS: Announce the change.
* doc/make.texi (Summary of Options): Add documentation.
* src/read.c (construct_include_path): Check for '-' and if found,
clear the list of directories to be searched.
* tests/scripts/options/dash-I: Add tests for -I-.
* tests/scripts/variables/INCLUDE_DIRS: Add tests for -I-.
2021-09-03 12:08:11 -04:00
Dmitry Goncharov
65b73ce434 [SV 60699] Avoid calling strlen() repeatedly in a loop
* src/variable.c (lookup_pattern_var): Accept target length parameter.
(initialize_file_variables): Pass computed target length to lookup.
2021-07-25 17:15:38 -04:00
Paul Smith
2d73c9bf25 * NEWS: Add a few missing attributions
* AUTHORS: Add some missing attributions
2021-07-25 17:15:38 -04:00
Dmitry Goncharov
33468b3f31 [SV 60297] Add .NOTINTERMEDIATE special target
Support a new special target, .NOTINTERMEDIATE.  Any file or pattern
prerequisite of this target will never be considered intermediate.
This differs from .SECONDARY in that .SECONDARY files won't be deleted
but they will still not be built if they are missing.

.NOTINTERMEDIATE files are treated the same way as a target which is
explicitly mentioned in the makefile.  This is mostly useful with
patterns; obviously mentioning a target explicitly here is enough in
and of itself to make something not intermediate.

Some adjustments made by psmith@gnu.org

* NEWS: Announce the new feature.
* doc/make.texi (Special Targets): Document .NOTINTERMEDIATE.
(Chained Rules): Describe how to use .NOTINTERMEDIATE.
* src/main.c (main): Add "notintermediate" to the .FEATURES variable.
* src/filedef.h (struct file): Add "notintermediate" flag.
* src/file.c (no_intermediates): Mark global .NOTINTERMEDIATE.
(snap_file): Support .NOTINTERMEDIATE special target.  Throw an error
if the same target is marked both .NOTINTERMEDIATE and .SECONDARY or
.INTERMEDIATE.
(rehash_file): Merge intermediate, notintermediate, secondary flags.
(remove_intermediates): Check notintermediate flag before removing.
(print_file):
* src/implicit.c (pattern_search): Set notintermediate based on the
pattern.
* tests/scripts/targets/NOTINTERMEDIATE: Add a new test suite.
2021-07-25 17:15:38 -04:00
Paul Smith
1cffd0a203 * make.texi (Reading Makefiles): != creates recursive variables.
Reported by Ronald Hoogenboom <RHoogenboom@irdeto.com>.
2021-05-30 15:53:51 -04:00
Dmitry Goncharov
b580949ae0 [SV 60659] Set $$< properly in second expansion
Set the $$< automatic variable as best we can during secondary
expansion of prerequisites.

* src/commands.c (set_file_variables): Don't break without setting
'less' if secondary expansion is enabled.
* tests/scripts/features/se_explicit: Test secondary expansion results.
* tests/scripts/features/se_implicit: Test secondary expansion results.
2021-05-30 15:53:41 -04:00
Paul Smith
f2771aa614 [SV 58341] Add non-trivial options to $(MAKEFLAGS)
Previously only trivial (single-letter) options were available in
$(MAKEFLAGS) when it is examined from inside a makefile (the full
value was set before expanding recipes).

Ensure that all options (but, not command line variable overrides!)
are visible in the $(MAKEFLAGS) variable.  In order to do this
reset the default values of options, particularly options which are
lists, before re-reading MAKEFLAGS after makefiles have been read.
Otherwise we'll get duplicate values for options such as -I.

Unfortunately there are complications here as well: sometimes (for
jobserver options in particular) we modify the values of these
options while running: we must not reset these modifications.

* NEWS: Announce this change
* src/main.c (main): Call new reset_switches() before re-parsing
MAKEFLAGS.
(reset_switches): Reset the value of non-special options to their
defaults.
(define_makeflags): Add non-special options into MAKEFLAGS even
if 'all' is not set.
2021-05-30 15:11:30 -04:00
Dmitry Goncharov
5e829188d3 [SV 60378] Don't add duplicate default search directories
Depending on how make was configured it may add duplicate
directories in the default include search path: avoid this.

(Tweaked by psmith@gnu.org)

* configure.ac: Set AM variable KNOWN_PREFIX if --prefix is known
* Makefile.am: Only set INCLUDEDIR if prefix is not known
* read.c [default_include_directories]: Only add INCLUDEDIR if set
2021-05-30 15:11:30 -04:00
Dmitry Goncharov
297cb5adb7 * tests/scripts/targets/INTERMEDIATE: [SV 60188] Add one more test 2021-05-30 15:11:14 -04:00
Eli Zaretskii
012918bf11 [SV 58656] Fix mtime for large files on MS-Windows
In MSVC builds, 'stat' fails when called on files larger than
2GB.  Call '_stat64' instead to work around this.

* src/remake.c (STAT): Define to '_stat64' for MSVC builds.
(name_mtime) [WINDOWS32]: Use STAT instead of 'stat'.
Suggested by Makoto Kato <m_kato@ga2.so-net.ne.jp>.
2021-05-29 11:37:09 +03:00
Paul Smith
1ae90c030d Fix build and test issues on Windows
* src/dep.h (DEP): Remove extraneous semicolon.
* src/dir.c (find_directory) [W32]: Replace removed variable.
* tests/scripts/features/include: Allow the extra default makefile
searched for on Windows.
* tests/scripts/functions/file: Use $(info ...) to avoid "command
too long" errors on Windows.
2021-03-28 16:25:52 -04:00
Tobias Stoeckmann
0fb6f2d985 * src/remake.c (name_mtime): Reserve space for nul in readlink result
Copyright-paperwork-exempt: yes
2021-03-28 14:45:16 -04:00
Cao jin
97a8d9b45a * doc/make.texi (Call Function): Apply consistent formatting
Copyright-paperwork-exempt: yes
2021-03-25 14:38:58 -04:00
Pete Dietl
c5c02accb7 * src/job.c (child_execute_job): Update gnulib find_in_given_path()
Copyright-paperwork-exempt: yes
2021-03-25 14:25:26 -04:00
Mike Frysinger
76a099997b * doc/make.texi (Automatic Variables): Relocate the $? example
Copyright-paperwork-exempt: yes
2021-03-25 13:10:29 -04:00
Paul Smith
c5319e75f5 [SV 58497] Ensure $(file <) newline removal succeeds
Keep a count of bytes read rather than comparing pointers since the
variable_buffer might get reallocated.

Bug and patch by Ken Tossell <ken@tossell.net>
Regression tests by Dmitry Goncharov <dgoncharov@users.sf.net>
Tweaked by Paul Smith <psmith@gnu.org>

* src/function.c (func_file): Use bytes read rather than a pointer.
* tests/scripts/functions/file: Provide various tests for reading
empty files, files with/without newlines, and large files.
2021-03-15 03:28:11 -04:00
Dmitry Goncharov
510e5ce801 [SV 60188] Explicit prereqs cannot be intermediate files
If a prereq of a pattern is an explicit target, it should not be
considered an intermediate file.

(Minor tweaks by Paul Smith <psmith@gnu.org>)

* src/dep.h (struct nameseq): Add is_explicit flag.
* src/implicit.c (struct patdeps): Ditto.
(pattern_search): Set the is_explicit flag appropriately for each
prerequisite, based on whether it contained a pattern or not.
Update the help output to note implicit vs. explicit prereqs.
* tests/scripts/features/double_colon: Add tests.
* tests/scripts/features/grouped_targets: Ditto.
* tests/scripts/features/patternrules: Ditto.
* tests/scripts/features/se_implicit: Ditto.
* tests/scripts/features/statipattrules: Ditto.
2021-03-15 02:10:49 -04:00
Paul Smith
144f436c4b * tests/scripts/features/exec: Small cleanup 2021-03-15 01:17:06 -04:00
Paul Smith
52056d7b2c Ensure variable_buffer is always set.
Initialize the global variable_buffer in main() so that it is never
a null pointer.  Then invoking variable_expand("") is never needed:
simply use the variable_buffer pointer when we want to restart the
variable buffer.  The main point of this simplification is not to
keep a separate pointer to the beginning of the buffer: this is
dangerous because the buffer may be re-allocated.  Instead always
use the variable_buffer pointer itself.

* src/variable.h (initialize_variable_output): Publish.
* src/expand.c (initialize_variable_output): Remove static.
* src/main.c (main): Initialize variable_buffer.
* src/file.c (enter_prereqs): Don't call variable_expand("") and
don't save a separate buffer pointer than might be outdated.
(expand_deps): Ditto.
* src/read.c (record_files): Ditto.
* src/remake.c (library_search): Ditto.
2021-03-15 01:17:06 -04:00
Paul Smith
c66ec5fa20 [SV 59881] Handle vertical TAB consistently
While parsing makefiles get_next_mword() was treating VTAB as a word
character rather than a word separator.  However, when using
find_next_token(), for example in patsubst_expand_pat(), we treated
VTAB as a word separator causing multiple words to appear where we
didn't expect them.

* src/makeint.h (END_OF_TOKEN): Change from a loop to a boolean check.
* src/misc.c (end_of_token): Move the loop here.
* src/read.c (get_next_mword): Skip whitespace, not just blank, to
find the start of the word and use END_OF_TOKEN() to decide when the
current word is finished.
2021-03-15 01:16:32 -04:00
Paul Smith
da6fc6aae2 [SV 59870] define/undefine prerequisites are not target-specific vars
* 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.
2021-03-14 16:35:38 -04:00
Paul Smith
d9aff6b817 * maintMakefile: Don't make .check-git-HEAD .PHONY 2021-03-14 15:53:45 -04:00
Jouke Witteveen
e5f6dc54b9 More correctly describe the scope of variables
* NEWS: Use "local" instead of the incorrect "lexically-scoped".
* doc/make.texi: Refer to let/foreach variables as local variables.
2021-03-07 19:06:59 -05:00
Paul Smith
88732a29f2 * doc/make.text: Clarify that patsubst doesn't touch unmatched words 2021-03-07 19:05:20 -05:00
Paul Smith
7b0a741857 * .dir-locals.el: Update for newer LSP config 2021-03-07 19:04:48 -05:00
Paul Smith
74bd8b3aa5 * file.c (remove_intermediates): Restart "rm ..." on error 2021-03-07 19:04:22 -05:00
Paul Smith
9043b28250 * doc/make.texi (How Patterns Match): [SV 58639] Fix chaining info. 2020-12-07 01:03:11 -05:00
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
94d9077691 * configure.ac: [SV 58836] Copy build.sh to the build directory 2020-12-05 15:11:52 -05:00
Paul Smith
c4cc2e9595 [SV 57676] Support included files being built after failing
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.
2020-12-05 15:06:25 -05:00
Paul Smith
5e234e4048 * src/makeint.h (free_alloca): Check for builtin alloca 2020-12-02 17:29:16 -05:00
Paul Smith
950f3d305f * src/main.c (main): [SV 59601] Check for malformed env. variables 2020-12-02 17:27:55 -05:00
Paul Smith
58a37927e6 * maintMakefile: [SV 58794] Check for file existence in the release 2020-11-29 17:59:40 -05:00
Paul Smith
ec272f3a9c * Makefile.am (HAVE_GUILE): Only use Guile options if HAVE_GUILE. 2020-11-29 17:59:40 -05:00
Paul Smith
ef6aca5a38 * tests/scripts/features/vpathgpath: Avoid duplicate function name. 2020-11-29 17:59:40 -05:00
Paul Smith
b262ea5d8f Resolve unused-result warnings for alloca(0)
* src/makeint.h (free_alloca): New macro to defeat warn_unused_result.
* src/read.c (eval_makefile): Call it.
(eval_buffer): Ditto.
* src/remake.c (update_file): Ditto.
2020-11-29 17:59:40 -05:00
Paul Smith
cc20f90507 Avoid some valgrind warnings
Using sscanf() to parse archive header values (struct ar_hdr) can lead
to valgrind warnings which are probably bogus but are annoying.
To be safer, create a local method to convert the ASCII integer
strings into integers.

* src/arscan.c (parse_int): Turn integer strings into integers.
(ar_scan): Initialize struct ar_hdr memory.
Call parse_int() rather than sscanf/atol.
2020-11-29 17:59:40 -05:00
Paul Smith
9e2fa24649 [SV 41273] Allow the directory cache to be invalidated
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.
2020-11-29 17:59:16 -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
Dmitry Goncharov
90959b8b70 [SV 59230] Preserve export settings for target-specific vars
* src/read.c (record_target_var): Don't overwrite pre-existing export
flag unless we're changing it.
* tests/scripts/features/targetvars: Add a test.
2020-11-29 17:55:32 -05:00
Paul Smith
19ae6fe72a [SV 59230] Ensure environment variables are exportable
When checking for invalid environment variable names we searched the
entire name string instead of just the first LENGTH chars; this could
cause us to incorrectly decide the variable was not exportable.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Patch provided by 0xef967c36@gmail.com

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

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

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

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

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

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

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

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

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

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

* configure.ac: Test whether posix_spawn fails asynchronously.  In a
cross-compilation environment, assume that it does not.  If we detect
that it does, fall back to fork/exec.
* tests/scripts/features/exec: Add regression tests for different
shebang invocation methods.
2019-12-27 01:37:17 -05:00
Paul Smith
564fb212a7 [SV 56655] Allow pattern expansion to contain spaces
* src/dep.h: Add a new flag PARSEFS_ONEWORD
* src/read.c (parse_file_seq): If PARSEFS_ONEWORD is given, treat the
entire incoming string as a single pattern.
* src/implicit.c (pattern_search): Pass PARSEFS_ONEWORD when parsing
patterns for wildcards.
* tests/scripts/features/patternrules: Add a new test.
2019-12-26 18:39:56 -05:00
Ben Wijen
30cc10093b * src/misc.c (spin): On WINDOWS32 use Sleep() instead of sleep() 2019-12-18 09:05:40 -05:00
Ben Wijen
69c5a2128b * bootstrap.bat: Fix typo in batch file name 2019-12-18 09:05:40 -05:00
Paul Smith
577dd1ff6d * src/config.h.W32.template: [SV 57152] MinGW32 doesn't support d_type 2019-12-18 09:05:40 -05:00
Jouke Witteveen
86f2f8bcb5 [SV 54161] Fix second expansion of $* for paths
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
2019-12-18 09:05:17 -05:00
Jouke Witteveen
c72205b28b * src/implicit.c (pattern_search): Set lastslash correctly
If filename contained multiple slashes lastslash is wrongly set to 0.
* configure.ac: Check for the GNU memrchr() extension function.
* src/misc.c (memrchr): Supply memrchr() if not available.
2019-12-17 15:06:28 -05:00
Jouke Witteveen
057e33d6b5 * src/implicit.c (pattern-search): Remove unneeded 'dir' variable 2019-12-17 15:06:28 -05:00
Paul Smith
e4499a1fb5 * Makefile.am: Build lzip package instead of bzip2
* README.git: Mention changed requirements.
2019-12-17 15:06:28 -05:00
Paul Smith
57b043c7fb * src/job.c (load_too_high): Disable Linux /proc/loadavg for now
This new feature has a problem: if you provide a load which is
larger than the number of cores then it will always run every job.
Before we can enable it we need to at the least learn how to clamp
this value to the number of cores.  To experiment with it, set
PROC_FD_INIT to -2 in job.c to re-enable the feature.
2019-12-17 15:06:28 -05:00
Paul Smith
f389aabde6 * tests/run_make_tests.pl (set_more_defaults): Fix typo 2019-12-17 15:06:28 -05:00
Paul Smith
acbef3f612 * tests/run_make_tests.pl (subst_make_string): Force use of /
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.
2019-12-16 16:18:58 -05:00
Paul Smith
3822f77c1d Rename jhelp.pl to thelp.pl and make it a generic test helper.
* 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
2019-12-16 09:31:31 -05:00
Paul Eggert
1cf3932a39 Port functions/shell test to Solaris 10
* tests/scripts/functions/shell: Port exit-status calculation
to Solaris 10 with Perl 5.8.4.
2019-10-10 18:31:50 -04:00
Paul Smith
33bda40086 Release GNU make 4.2.92
* NEWS: Update the release and date
* configure.ac: Update the release number
2019-10-08 08:35:39 -04:00
Paul Smith
e666a6a021 * doc/make.text (Reading Makefiles): Rewrite to be more clear. 2019-10-06 15:48:53 -04:00
Paul Smith
5920d6d2b3 * Makefile.am (check-regression): Use PERLFLAGS when running Perl
* maintMakefile: Set PERLFLAGS to enable warnings.
* tests/run_make_tests.pl: Clean up issues pointed out by perl -w.
2019-10-05 17:48:19 -04:00
Paul Smith
2e6468c811 * tests/scripts/functions/wildcard: Skip slash tests for local glob. 2019-10-05 17:48:19 -04:00
Paul Smith
393d2a2d4a tests: Convert %CONFIG_FLAGS to get_config()
* 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.
2019-10-05 17:47:52 -04:00
Paul Smith
bd7d03f8cd * src/hash.c (jhash_string): Don't read past end of string.
Original patch from Dmitry Goncharov <dgoncharov@users.sf.net>.
2019-10-05 11:23:31 -04:00
Paul Smith
a4a173928f * tests/run_make_tests.pl (valid_option): Add missing File::Spec 2019-10-05 07:43:52 -04:00
Paul Smith
0e113897f7 * src/function.c (func_realpath) [AIX]: Remove trailing slashes. 2019-09-23 00:34:12 -04:00
Paul Smith
b0eab8ecb9 * tests/scripts/features/vpathplus: Fix output for big-endian systems.
Our hashing algorithm gives different ordering on LE vs BE systems.
Patch from Dmitry Goncharov <dgoncharov@users.sf.net>.
2019-09-22 17:35:51 -04:00
Florian Weimer
f84821b249 * configure.ac (HAVE_GETTIMEOFDAY): Avoid undeclared exit function.
Copyright-paperwork-exempt: yes
2019-09-22 17:32:29 -04:00
Paul Smith
99d1423059 * test/test_driver.el (_run_with_timeout): Show error message. 2019-09-22 17:03:05 -04:00
Paul Smith
7fbd58cd6b * job.c (child_error): Modify error message string.
This reverts commit 6264deece3bb77798240a906ceed79097adbcf48.
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.
2019-09-22 17:02:57 -04:00
Paul Smith
3ede0b96ac * tests: Convert from File::Spec::Functions to File::Spec.
Users report the Functions version doesn't work correctly for some
older versions of Perl.
2019-09-21 16:37:56 -04:00
Paul Smith
1d289b424a * tests/scripts/function/guile: Valgrind doesn't work with Guile. 2019-09-21 15:38:52 -04:00
Paul Smith
96285f875b * src/job.c (child_execute_job): Allocate space for argv NULL. 2019-09-21 15:38:52 -04:00
Paul Smith
bd4ce86785 [SV 56918] Compute job slots properly on failing command
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.
2019-09-21 15:38:48 -04:00
Paul Smith
e1c072aa7e * src/arscan.c (ar_scan): Restrict length for sscanf of ar_mode. 2019-09-21 15:13:32 -04:00
Paul Smith
af0074547d * tests/scripts/functions/shell: Detect correct SHELLSTATUS code. 2019-09-21 15:13:32 -04:00
Paul Smith
4a7a8278e8 * tests/run_make_test.pl: Fix support for valgrind.
Change the variable holding the make command to be a list that can
hold extra commands and options, not just a string.
2019-09-21 15:13:24 -04:00
Paul Smith
00fa3ca3a5 * tests/run_make_tests.pl (find_prog): Fix syntax error. 2019-09-21 12:39:07 -04:00
256 changed files with 25583 additions and 12704 deletions

3
.ccls
View File

@ -4,7 +4,6 @@ clang
-Isrc
-Ilib
-DLIBDIR="/usr/local/lib"
-DINCLUDEDIR="/usr/local/include"
-DLOCALEDIR="/usr/local/share/locale"
-DMAKE_MAINTAINER_MODE
-pthread
@ -25,3 +24,5 @@ clang
-Wignored-qualifiers
-Wformat-signedness
-Wduplicated-cond
-Wno-address
-Wno-string-compare

14
.clangd Normal file
View File

@ -0,0 +1,14 @@
CompileFlags:
Add: [-xc, -DHAVE_CONFIG_H, -DMAKE_MAINTAINER_MODE, -DLIBDIR="/usr/local/lib", -DLOCALEDIR="/usr/local/share/locale", -I../src, -Isrc, -I../lib, -Ilib, -Wall, -Wextra, -Wwrite-strings, -Wshadow, -Wdeclaration-after-statement, -Wbad-function-cast, -Wformat-security, -Wtype-limits, -Wunused-but-set-parameter, -Wlogical-op, -Wpointer-arith, -Wignored-qualifiers, -Wformat-signedness, -Wduplicated-cond, -Wno-string-compare, -Wno-unused-includes]
---
If:
PathMatch: .*\.h
CompileFlags:
Add: [-xc-header, --include=makeint.h]
---
If:
PathMatch: .*/makeint\.h
Diagnostics:
UnusedIncludes: None

View File

@ -1,18 +1,21 @@
(
(nil . ((bug-reference-bug-regexp . "\\(\\)\\bSV[- ]\\([0-9]+\\)")
(nil . ((bug-reference-bug-regexp . "\\(\\bSV[- ]\\([0-9]+\\)\\)")
(bug-reference-url-format . "https://savannah.gnu.org/bugs/?%s")
(ccls-initialization-options . (:index (:threads 6
:initialBlacklist ("/make-[0-9]" "tests/work/" "/\\.deps" "/\\..*cache" "/\\.git"))))
(lsp-file-watch-ignored . ("/\\.git$"
"/\\..*cache$"
;; autotools content
"/\\.deps$"
"/autom4te\\.cache$"
"/build-aux$"
;; make-specific content
"/doc/manual$"
"/tests/work$"
"/make-[0-9]"))
(ccls-initialization-options
. (:index (:threads 6
:initialBlacklist ["/make-[0-9]" "tests/work/" "/\\.deps"
"/\\..*cache" "/\\.git"])))
(lsp-file-watch-ignored-directories
. ("[/\\\\]\\.git$"
"[/\\\\]\\..*cache$"
;; autotools content
"[/\\\\]\\.deps$"
"[/\\\\]autom4te\\.cache$"
"[/\\\\]build-aux$"
;; make-specific content
"[/\\\\]doc[/\\\\]manual$"
"[/\\\\]tests[/\\\\]work$"
"[/\\\\]make-[0-9]"))
))
(c-mode . ((c-file-style . "gnu")))
)

24
.gitignore vendored
View File

@ -11,8 +11,14 @@ GTAGS
*~
#*
.#*
*.diff
*.patch
*.orig
*.rej
# Configure artifacts
/lib/
/m4/
ABOUT-NLS
INSTALL
Makefile
@ -28,8 +34,10 @@ config.log
config.status
configure
/mk/Posix.mk
stamp-h1
stamp-*
.dirstamp
gnulib
*.sed
# Build artifacts
.deps/
@ -51,20 +59,20 @@ WinDebug/
WinRel/
GccDebug/
GccRel/
TccDebug/
TccRel/
# Test artifacts
makeerror-*
test-suite.log
# Distribution artifacts
.dep_segment
.check-git-HEAD
ChangeLog
README
README.DOS
README.OS2
README.W32
build.cfg
config.ami
config.h-vms
config.h.W32
configh.dos
mkconfig.h
make-[0-9]*/
make-[0-9]*.tar.*
checkcfg.*.log

71
AUTHORS
View File

@ -1,15 +1,16 @@
-----------------------------------
GNU make development up to version 3.75 by:
Roland McGrath <roland@gnu.org>
Development starting with GNU make 3.76 by:
GNU Make development starting with GNU Make 3.76 by:
Paul D. Smith <psmith@gnu.org>
Additional development starting with GNU make 3.81 by:
Additional development starting with GNU Make 4.3 by:
Dmitry Goncharov <dgoncharov@users.sf.net>
Additional development starting with GNU Make 3.81 by:
Boris Kolpackov <boris@kolpackov.net>
GNU Make development up to version 3.75 by:
Roland McGrath <roland@gnu.org>
GNU Make User's Manual
Written by:
@ -22,7 +23,7 @@ GNU Make User's Manual
Paul D. Smith <psmith@gnu.org>
-----------------------------------
GNU make porting efforts:
GNU Make porting efforts:
Port to VMS by:
Klaus Kaempf <kkaempf@progis.de>
@ -31,8 +32,8 @@ GNU make porting efforts:
John W. Eaton <jwe@bevo.che.wisc.edu>
Martin Zinser <zinser@decus.decus.de>
Port to Amiga by:
Aaron Digulla <digulla@fh-konstanz.de>
Port to MS-Windows (native/MinGW) maintained by:
Eli Zaretskii <eliz@gnu.org>
Port to MS-DOS (DJGPP), OS/2, and MS-Windows (native/MinGW) by:
DJ Delorie <dj@delorie.com>
@ -42,38 +43,76 @@ GNU make porting efforts:
Andreas Beuning <andreas.buening@nexgo.de>
Earnie Boyd <earnie@uses.sf.net>
Troy Runkel <Troy.Runkel@mathworks.com>
Juan M. Guerrero <juan.guerrero@gmx.de>
KO Myung-Hun <komh78@gmail.com>
Port to z/OS by:
Igor Todorovski <itodorov@ca.ibm.com>
-----------------------------------
Other contributors:
Luke Allardyce <lukeallardyce@gmail.com>
Costas Argyris <costas.argyris@gmail.com>
Aron Barath <baratharon@caesar.elte.hu>
David Boyce <dsb@boyski.com>
Kevin Buettner <kevinb@redhat.com>
Janet Carson <janet_carson@tivoli.com>
Howard Chu <hyc@highlandsun.com>
Ludovic Courtès <ludo@gnu.org>
Joe Crayne <oh.hello.joe@gmail.com>
Jeremy Devenport <jeremy.devenport@gmail.com>
Pete Dietl <petedietl@gmail.com>
Aaron Digulla <digulla@fh-konstanz.de>
Hannes Domani <ssbssa@yahoo.de>
Martin Dorey <martin.dorey@hds.com>
Christian Eggers <ceggers@arri.de>
Paul Eggert <eggert@twinsun.com>
Mike Frysinger <vapier@gentoo.org>
Ramon Garcia Fernandez <ramon.garcia.f@gmail.com>
Noah Goldstein <goldstein.w.n@gmail.com>
Mike Haboustak <haboustak@gmail.com>
Frank Heckenbach <f.heckenbach@fh-soft.de>
Klaus Heinz <kamar@ease.rhein-main.de>
Ben Hutchings <ben@decadent.org.uk>
Cao jin <caoj.fnst@cn.fujitsu.com>
Michael Joosten
Christian Jullien <eligis@orange.fr>
Jim Kelton <jim_kelton@tivoli.com>
Kaz Kylheku <kaz@kylheku.com>
David Lubbren <uhay@rz.uni-karlsruhe.de>
Tim Magill <tim.magill@telops.gte.com>
Markus Mauhart <qwe123@chello.at>
Greg McGary <greg@mcgary.org>
Thien-Thi Nguyen <ttn@gnuvola.org>
Thomas Riedl <thomas.riedl@siemens.com>
Han-Wen Nienhuys <hanwen@cs.uu.nl>
Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
Enrique Olaizola <enrique_olaizola16@hotmail.com>
Ola Olsson <ola1olsson@gmail.com>
Jens Rehsack <sno@netbsd.org>
Thomas Riedl <thomas.riedl@siemens.com>
Jaak Ristioja <jaak@ristioja.ee>
Christoph Schulz <develop@kristov.de>
Andreas Schwab <schwab@suse.de>
spagoveanu <spagoveanu@gmail.com>
Carl Staelin (Princeton University)
Ian Stewartson (Data Logic Limited)
Tobias Stoeckmann <tobias@stoeckmann.org>
Torbjörn Svensson <torbjorn.svensson@foss.st.com>
Sergei Trofimovich <siarheit@google.com>
Justine Tunney <jtunney@gmail.com>
Marc Ullman <marc@mathworks.com>
Christof Warlich <cwarlich@gmx.de>
Florian Weimer <fweimer@redhat.com>
David A. Wheeler <dwheeler@dwheeler.com>
David Boyce <dsb@boyski.com>
Frank Heckenbach <f.heckenbach@fh-soft.de>
Kaz Kylheku <kaz@kylheku.com>
Bernhard M. Wiedemann <bwiedemann@suse.de>
Ben Wijen <ben@wijen.net>
Jouke Witteveen <j.witteveen@gmail.com>
With suggestions/comments/bug reports from a cast of ... well ...
hundreds, anyway :)
-------------------------------------------------------------------------------
Copyright (C) 1997-2019 Free Software Foundation, Inc.
Copyright (C) 1997-2024 Free Software Foundation, Inc.
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify it under the
@ -86,4 +125,4 @@ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
this program. If not, see <https://www.gnu.org/licenses/>.

View File

@ -1,16 +1,16 @@
# Basic GNU -*-Makefile-*- to build GNU make
# Basic GNU -*-Makefile-*- to build GNU Make
#
# NOTE:
# If you have no 'make' program at all to process this makefile:
# * On Windows, run ".\buildw32.bat" to bootstrap one.
# * On Windows, run ".\build_w32.bat" to bootstrap one.
# * On MS-DOS, run ".\builddos.bat" to bootstrap one.
#
# Once you have a GNU make program created, you can use it with this makefile
# Once you have a GNU Make program created, you can use it with this makefile
# to keep it up to date if you make changes, as:
#
# make.exe -f Basic.mk
#
# Copyright (C) 2017-2019 Free Software Foundation, Inc.
# Copyright (C) 2017-2024 Free Software Foundation, Inc.
# This file is part of GNU Make.
#
# GNU Make is free software; you can redistribute it and/or modify it under
@ -24,7 +24,7 @@
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
# this program. If not, see <https://www.gnu.org/licenses/>.
all:
@ -37,9 +37,7 @@ loadavg_SOURCES = %loadavg_SOURCES%
alloca_SOURCES = %alloca_SOURCES%
w32_SOURCES = %w32_SOURCES%
vms_SOURCES = %vms_SOURCES%
amiga_SOURCES = %amiga_SOURCES%
posix_SOURCES = $(src)posixos.c
remote_SOURCES = $(src)remote-stub.c
OUTDIR =
@ -61,6 +59,8 @@ BUILT_SOURCES =
OBJECTS = $(patsubst %.c,$(OUTDIR)%.$(OBJEXT),$(prog_SOURCES))
RESOURCE_OBJECTS =
OBJDIRS = $(addsuffix .,$(sort $(dir $(OBJECTS))))
# Use the default value of CC
@ -88,8 +88,9 @@ COMPILE.cmd = $(CC) $(extra_CFLAGS) $(CFLAGS) $(extra_CPPFLAGS) $(CPPFLAGS) $(TA
# $(call LINK.cmd,<objectlist>)
LINK.cmd = $(LD) $(extra_LDFLAGS) $(LDFLAGS) $(TARGET_ARCH) $1 $(LDLIBS) $(LINK_OUTPUT)
# $(CHECK.cmd)
# $(CHECK.cmd) $(CHECK.args)
CHECK.cmd = cd $(SRCDIR)/tests && ./run_make_tests -make $(shell cd $(<D) && pwd)/$(<F)
CHECK.args ?=
# $(call MKDIR.cmd,<dirlist>)
MKDIR.cmd = mkdir -p $1
@ -100,18 +101,16 @@ RM.cmd = rm -f $1
# $(call CP.cmd,<from>,<to>)
CP.cmd = cp $1 $2
CLEANSPACE = $(call RM.cmd,$(OBJECTS) $(PROG) $(BUILT_SOURCES))
CLEANSPACE = $(call RM.cmd,$(OBJECTS) $(RESOURCE_OBJECTS) $(PROG) $(BUILT_SOURCES))
# Load overrides for the above variables.
include $(firstword $(wildcard $(SRCDIR)/mk/$(lastword $(subst -, ,$(MAKE_HOST)).mk) $(OUTDIR)mk/Posix.mk $(SRCDIR)/mk/Posix.mk))
VERSION = %VERSION%
include $(firstword $(wildcard $(SRCDIR)/mk/$(lastword $(subst -, ,$(MAKE_HOST)).mk)))
VPATH = $(SRCDIR)
all: $(PROG)
$(PROG): $(OBJECTS)
$(PROG): $(OBJECTS) $(RESOURCE_OBJECTS)
$(call LINK.cmd,$^)
$(OBJECTS): $(OUTDIR)%.$(OBJEXT): %.c
@ -123,7 +122,7 @@ $(OBJDIRS):
$(call MKDIR.cmd,$@)
check:
$(CHECK.cmd)
$(CHECK.cmd) $(CHECK.args)
clean:
$(CLEANSPACE)

View File

@ -1,7 +1,7 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@ -645,7 +645,7 @@ the "copyright" line and a pointer to where the full notice is found.
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
@ -664,11 +664,11 @@ might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
<https://www.gnu.org/philosophy/why-not-lgpl.html>.

View File

@ -4994,4 +4994,4 @@ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
this program. If not, see <https://www.gnu.org/licenses/>.

View File

@ -1322,7 +1322,7 @@
non-standard versions of free() don't like it.
* configure.in (--enable-dmalloc): Install some support for using
dmalloc (http://www.dmalloc.com/) with make. Use --enable-dmalloc
dmalloc (https://www.dmalloc.com/) with make. Use --enable-dmalloc
with configure to enable it.
* function.c (function_table_entry): Whoops! The function.c
@ -6632,7 +6632,7 @@ Fri Nov 1 19:34:28 1991 Roland McGrath (roland@churchy.gnu.ai.mit.edu)
See ChangeLog.1, available in the Git repository at:
http://git.savannah.gnu.org/cgit/make.git/tree/
https://git.savannah.gnu.org/cgit/make.git/tree/
for earlier changes.
@ -6650,4 +6650,4 @@ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
this program. If not, see <https://www.gnu.org/licenses/>.

View File

@ -664,7 +664,7 @@
characters in its name, pass NULL as the first argument to
CreateProcess. This avoids weird failures due to buggy quoting by
CreateProcess. For the details, see the discussion starting at
http://lists.gnu.org/archive/html/make-w32/2013-04/msg00008.html.
https://lists.gnu.org/archive/html/make-w32/2013-04/msg00008.html.
* load.c (load_object, load_file): Accept an additional argument
DLP and return in it a pointer that can be used to unload the
@ -706,7 +706,7 @@
(construct_command_argv_internal): Don't treat a backslash as an
escape character before whitespace, if the shell is not a Posix
shell. For the description of the problem, see
http://lists.gnu.org/archive/html/make-w32/2013-04/msg00014.html.
https://lists.gnu.org/archive/html/make-w32/2013-04/msg00014.html.
2013-05-01 Paul Smith <psmith@gnu.org>
@ -1392,7 +1392,7 @@
2011-09-16 Paul Smith <psmith@gnu.org>
* maintMakefile (do-po-update): Apparently we have to avoid
certificate checks on the http://translationproject.org site now.
certificate checks on the https://translationproject.org site now.
2011-09-12 Paul Smith <psmith@gnu.org>
@ -5612,7 +5612,7 @@
See ChangeLog.2, available in the Git repository at:
http://git.savannah.gnu.org/cgit/make.git/tree/
https://git.savannah.gnu.org/cgit/make.git/tree/
for earlier changes.
@ -5630,4 +5630,4 @@ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
this program. If not, see <https://www.gnu.org/licenses/>.

View File

@ -1,6 +1,6 @@
# This is a -*-Makefile-*-, or close enough
#
# Copyright (C) 1997-2019 Free Software Foundation, Inc.
# Copyright (C) 1997-2024 Free Software Foundation, Inc.
# This file is part of GNU Make.
#
# GNU Make is free software; you can redistribute it and/or modify it under
@ -14,9 +14,9 @@
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
# this program. If not, see <https://www.gnu.org/licenses/>.
AUTOMAKE_OPTIONS = dist-bzip2 silent-rules std-options subdir-objects nostdinc
AUTOMAKE_OPTIONS = dist-lzip silent-rules std-options subdir-objects nostdinc
ACLOCAL_AMFLAGS = -I m4
MAKE_HOST = @MAKE_HOST@
@ -34,9 +34,10 @@ make_SRCS = src/ar.c src/arscan.c src/commands.c src/commands.h \
src/getopt.h src/getopt1.c src/gettext.h src/guile.c \
src/hash.c src/hash.h src/implicit.c src/job.c src/job.h \
src/load.c src/loadapi.c src/main.c src/makeint.h src/misc.c \
src/os.h src/output.c src/output.h src/read.c src/remake.c \
src/rule.c src/rule.h src/signame.c src/strcache.c \
src/variable.c src/variable.h src/version.c src/vpath.c
src/mkcustom.h src/os.h src/output.c src/output.h src/read.c \
src/remake.c src/rule.c src/rule.h src/shuffle.h src/shuffle.c \
src/signame.c src/strcache.c src/variable.c src/variable.h \
src/version.c src/vpath.c src/warning.c src/warning.h
w32_SRCS = src/w32/pathstuff.c src/w32/w32os.c src/w32/compat/dirent.c \
src/w32/compat/posixfcn.c src/w32/include/dirent.h \
@ -45,11 +46,11 @@ w32_SRCS = src/w32/pathstuff.c src/w32/w32os.c src/w32/compat/dirent.c \
src/w32/subproc/misc.c src/w32/subproc/proc.h \
src/w32/subproc/sub_proc.c src/w32/subproc/w32err.c
w32_utf8_SRCS = src/w32/utf8.rc src/w32/utf8.manifest
vms_SRCS = src/vms_exit.c src/vms_export_symbol.c src/vms_progname.c \
src/vmsdir.h src/vmsfunctions.c src/vmsify.c
amiga_SRCS = src/amiga.c src/amiga.h
glob_SRCS = lib/fnmatch.c lib/fnmatch.h lib/glob.c lib/glob.h
alloca_SRCS = lib/alloca.c
@ -57,18 +58,30 @@ alloca_SRCS = lib/alloca.c
loadavg_SRCS = lib/getloadavg.c
make_SOURCES = $(make_SRCS)
EXTRA_make_SOURCES = $(amiga_SRCS) $(vms_SRCS)
EXTRA_make_SOURCES = $(vms_SRCS)
make_LDADD = $(LIBOBJS) $(GUILE_LIBS) lib/libgnu.a $(GETLOADAVG_LIBS) \
if HAVE_GUILE
_GUILE_CFLAGS = $(GUILE_CFLAGS)
_GUILE_LIBS = $(GUILE_LIBS)
else
_GUILE_CFLAGS =
_GUILE_LIBS =
endif
make_LDADD = $(LIBOBJS) $(_GUILE_LIBS) lib/libgnu.a $(GETLOADAVG_LIBS) \
@LIBINTL@
localedir = $(datadir)/locale
AM_CPPFLAGS = -Isrc -I$(top_srcdir)/src -Ilib -I$(top_srcdir)/lib \
-DLIBDIR=\"$(libdir)\" -DINCLUDEDIR=\"$(includedir)\" \
-DLOCALEDIR=\"$(localedir)\"
-DLIBDIR=\"$(libdir)\" -DLOCALEDIR=\"$(localedir)\"
AM_CFLAGS = $(GUILE_CFLAGS)
# If prefix is not a standard location, look in prefix as well
if !KNOWN_PREFIX
AM_CPPFLAGS += -DINCLUDEDIR=\"$(includedir)\"
endif
AM_CFLAGS = $(_GUILE_CFLAGS)
if WINDOWSENV
make_SOURCES += $(w32_SRCS)
@ -77,6 +90,15 @@ else
make_SOURCES += src/posixos.c
endif
UTF8OBJ = src/w32/utf8.$(OBJEXT)
if HAVE_WINDRES
make_LDADD += $(UTF8OBJ)
endif
$(UTF8OBJ) : $(w32_utf8_SRCS)
$(WINDRES) -o $@ -i $<
if USE_CUSTOMS
make_SOURCES += src/remote-cstms.c
else
@ -85,7 +107,7 @@ endif
# Extra stuff to include in the distribution.
mk_FILES = Basic.mk mk/msdosdjgpp.mk mk/Amiga.mk mk/VMS.mk mk/Windows32.mk
mk_FILES = Basic.mk mk/msdosdjgpp.mk mk/VMS.mk mk/Windows32.mk
# We don't need this, since the standard automake output will do.
#mk/Posix.mk.in
@ -94,18 +116,18 @@ m4_FILES = m4/gnulib-cache.m4
test_FILES = tests/run_make_tests tests/run_make_tests.bat \
tests/run_make_tests.pl tests/test_driver.pl \
tests/config-flags.pm.in tests/config_flags_pm.com \
tests/mkshadow tests/jhelp.pl tests/guile.supp tests/README
tests/config-flags.pm.W32 \
tests/mkshadow tests/thelp.pl tests/guile.supp tests/README
# test/scripts are added via dist-hook below.
EXTRA_DIST = ChangeLog README build.sh build.cfg.in $(man_MANS) \
README.customs README.OS2 \
README.Amiga SCOPTIONS src/config.ami \
EXTRA_DIST = ChangeLog INSTALL README build.sh build.cfg.in $(man_MANS) \
src/mkconfig.h README.customs README.OS2 README.zOS \
README.DOS builddos.bat src/configh.dos \
README.W32 build_w32.bat src/config.h.W32 \
README.VMS makefile.com src/config.h-vms src/vmsjobs.c \
vms_export_symbol_test.com \
src/gmk-default.scm src/gmk-default.h \
$(mk_FILES) $(m4_FILES) $(test_FILES)
$(mk_FILES) $(m4_FILES) $(test_FILES) $(w32_utf8_SRCS)
# --------------- Generate the Guile default module content
@ -123,14 +145,14 @@ src/gmk-default.h: $(top_srcdir)/src/gmk-default.scm
dist-hook:
(cd $(top_srcdir); \
sub=`find tests/scripts -follow \( -name .git -o -name .deps -o -name work -o -name .gitignore -o -name \*.orig -o -name \*.rej -o -name \*~ -o -name \*.out -o -name Makefile \) -prune -o -type f -print`; \
tar chf - $$sub) \
| (cd $(distdir); tar xfBp -)
$(AMTAR) chf - $$sub) \
| (cd $(distdir); $(AMTAR) xfBp -)
# --------------- Local CHECK Section
check-local: check-regression
@banner=" Regression PASSED: GNU Make $(VERSION) ($(MAKE_HOST)) built with $(CC) "; \
@banner=" Regression PASSED: $(PACKAGE_STRING) ($(MAKE_HOST)) built with $(CC) "; \
dashes=`echo "$$banner" | sed s/./=/g`; \
echo; \
echo "$$dashes"; \
@ -141,32 +163,50 @@ check-local: check-regression
# > check-regression
#
# Look for the make test suite, and run it if found and we can find perl.
# If we're building outside the tree, we use symlinks to make a local copy of
# the test suite. Unfortunately the test suite itself isn't localizable yet.
#
MAKETESTFLAGS =
.PHONY: check-regression
GMK_OUTDIR = ..
testlog = test-suite.log
testresult = tests/.test-result
errorpre = makeerror-$(PACKAGE_VERSION)-$(host_triplet)
testfiles = $(testlog) $(testresult) $(errorfile)
MOSTLYCLEANFILES = $(testfiles)
errordetails = config.status config.log src/config.h src/mkconfig.h \
$(testlog) tests/work
# Create a 4-letter random sequence
rand_value = c = "abcdefghijklmnopqrstuvwxyz0123456789"
rand_char = substr(c,int(rand()*36),1)
rand_string = $(AWK) 'BEGIN{srand(); $(rand_value); print $(rand_char) "" $(rand_char) "" $(rand_char) "" $(rand_char);}'
check-regression: tests/config-flags.pm
@if test -f '$(top_srcdir)/tests/run_make_tests'; then \
$(AM_V_at) rm -f $(testfiles)
$(AM_V_at) if test -f '$(top_srcdir)/tests/run_make_tests.pl'; then \
ulimit -n 128; \
if $(PERL) -v >/dev/null 2>&1; then \
case `cd '$(top_srcdir)'; pwd` in `pwd`) : ;; \
*) test -d tests || mkdir tests; \
rm -f srctests; \
if ln -s '$(top_srcdir)/tests' srctests; then \
for f in run_make_tests run_make_tests.pl test_driver.pl scripts jhelp.pl; do \
rm -f tests/$$f; ln -s ../srctests/$$f tests; \
done; fi ;; \
esac; \
echo "cd tests && $(PERL) ./run_make_tests.pl -srcdir $(abs_top_srcdir) -make ../make$(EXEEXT) $(MAKETESTFLAGS)"; \
cd tests && $(PERL) ./run_make_tests.pl -srcdir '$(abs_top_srcdir)' -make '../make$(EXEEXT)' $(MAKETESTFLAGS); \
echo "cd tests && $(PERL) $(PERLFLAGS) $(abs_top_srcdir)/tests/run_make_tests.pl -make $(GMK_OUTDIR)/make$(EXEEXT) $(MAKETESTFLAGS)"; \
(cd tests && $(PERL) $(PERLFLAGS) '$(abs_top_srcdir)/tests/run_make_tests.pl' -make '$(GMK_OUTDIR)/make$(EXEEXT)' $(MAKETESTFLAGS); echo $$? >.test-result) 2>&1 | tee $(testlog); \
export TAR_OPTIONS='$(filter-out --sort%,$(TAR_OPTIONS))'; \
er=$$(cat $(testresult)); if test "$$er" -ne 0; then \
dirnm="$(errorpre)-$$($(rand_string))"; fnm="$$dirnm.tar.gz"; \
rm -rf "$$dirnm"; mkdir "$$dirnm"; \
$(AMTAR) chf - $(errordetails) | (cd "$$dirnm"; $(AMTAR) xf -); \
$(AMTAR) chf - "$$dirnm" | eval GZIP= gzip $(GZIP_ENV) -c >"$$fnm"; \
echo "*** Testing FAILED! Details: $$fnm"; \
echo '*** Please report to <$(PACKAGE_BUGREPORT)>'; echo; \
exit $$er; \
fi; \
else \
echo "Can't find a working Perl ($(PERL)); the test suite requires Perl."; \
fi; \
else \
echo "Can't find the GNU Make test suite ($(top_srcdir)/tests)."; \
echo "Can't find the $(PACKAGE_NAME) test suite ($(top_srcdir)/tests)."; \
fi

507
NEWS
View File

@ -1,19 +1,341 @@
GNU make NEWS -*-indented-text-*-
GNU Make NEWS -*-indented-text-*-
History of user-visible changes.
16 September 2019
26 February 2023
See the end of this file for copyrights and conditions.
All user-visible changes are more fully described in the GNU make manual,
All user-visible changes are more fully described in the GNU Make manual,
which is contained in this distribution as the file doc/make.texi.
See the README file and the GNU make manual for instructions for
See the README file and the GNU Make manual for instructions for
reporting bugs.
Version 4.2.91 (16 Sep 2019)
Version 4.4.90 (26 Feb 2023)
A complete list of bugs fixed in this version is available here:
http://sv.gnu.org/bugs/index.php?group=make&report_id=111&fix_release_id=108&set=custom
https://sv.gnu.org/bugs/index.php?group=make&report_id=111&fix_release_id=111&set=custom
* WARNING: Removed AmigaOS support!
This version of GNU Make no longer supports AmigaOS. If you need support
for AmigaOS please use one of the older versions of GNU Make.
* WARNING: Loaded Object ABI incompatibility!
This release changes the loaded object feature from "technology preview" to
fully-supported feature. However, it introduces an ABI incompatibility with
previous releases: the setup function now takes an ABI version as its first
argument. At compile time you can test the GMK_ABI_VERSION constant to
detect which ABI should be used. At runtime your initialization function
can check the provided ABI version to verify it's being loaded correctly.
* WARNING: Backward-incompatibility!
Parsing of the first argument in ifeq/ifneq with () has been cleaned up.
When locating the separating "," any variable reference (single char as well
as using $() or ${}) is skipped. However parentheses that are not part of
or contained in variable references will not be counted. This means that
things like "ifeq ((foo,bar),)" are now syntax errors. Use a variable to
hide the comma if needed: "COMMA = ," / "ifeq ((foo$(COMMA)bar),)".
See https://savannah.gnu.org/bugs/index.php?64402
* WARNING: Backward-incompatibility!
If -e is given all environment variables will now have an origin of
"environment override" even if they are not otherwise set in the makefile.
See https://savannah.gnu.org/bugs/index.php?64803
* WARNING: Backward-incompatibility!
The behavior of appending to pattern-specific variables has been clarified
when combined with command-line settings or -e overrides.
See https://savannah.gnu.org/bugs/index.php?64822
* NOTE: Deprecated behavior.
The check in GNU Make 4.3 for suffix rules with prerequisites didn't check
single-suffix rules, only double-suffix rules. Add the missing check.
* New feature: Any assignment operator can be made conditional
GNU Make has long supported the conditional operator "?=" which creates a
recursive variable set to a value if and only if the variable is not already
defined. In this release, the "?" can precede any assignment operator to
make it conditional. For example, "?:=" creates a simply-expanded variable
and expands the right-hand side if and only if the variable is not already
defined. The constructs "?::=", "?:::=", and "?!=" also behave as expected.
* New feature: Unload function for loaded objects
When a loaded object needs to be unloaded by GNU Make, it will invoke an
unload function (if one is defined) beforehand that allows the object to
perform cleanup operations.
Original idea and implementation: Dmitry Goncharov <dgoncharov@users.sf.net>
* New feature: Makefile warning reporting control
A new option "--warn" controls reporting of warnings for makefiles. Actions
can be set to "ignore", "warn", or "error". Two new warnings are reported:
assigning to invalid variable names, and referencing invalid variable names
(both set to "warn" by default), in addition to the existing warning for
undefined variables (defaults to "ignore"). "--warn-undefined-variables" is
deprecated, and is translated to "--warn=undefined-vars" internally.
* New feature: Control warnings with the .WARNINGS variable
In addition to --warn from the command line, which takes effect for make
invoked recursively, warnings can be controlled only for the current
instance of make using the .WARNINGS variable.
* New feature: Printing targets defined by the makefile
A new option "--print-targets" will print all explicit, non-special targets
defined in the makefiles, one per line, then exit with success. No recipes
are invoked and no makefiles are re-built.
* Warnings for detecting circular dependencies are controllable via warning
reporting, with the name "circular-dep".
* 'make --print-data-base' (or 'make -p') now outputs time of day
using the same form as for file timestamps, e.g., "2023-05-10
10:43:57.570558743". Previously it used the form "Wed May 10
10:43:57 2023", which has less detail and is harder to compare.
* Conditional statements starting with the recipe prefix were sometimes
interpreted in previous versions. As per the documentation, lines starting
with the recipe prefix are now never considered conditional statements.
* Tests in the regression test suite now are run in their own directory to
avoid cross-contamination and allow cleanup if the tests are interrupted.
More information is printed about failing tests.
Version 4.4.1 (26 Feb 2023)
This release is primarily a bug-fix release.
A complete list of bugs fixed in this version is available here:
https://sv.gnu.org/bugs/index.php?group=make&report_id=111&fix_release_id=110&set=custom
* WARNING: Backward-incompatibility!
In previous releases it was not well-defined when updates to MAKEFLAGS made
inside a makefile would be visible. This release ensures they are visible
immediately, even when invoking $(shell ...) functions. Also, command line
variable assignments are now always present in MAKEFLAGS, even when parsing
makefiles.
Implementation provided by Dmitry Goncharov <dgoncharov@users.sf.net>
* New feature: Parallel builds of archives
Previously it was not possible to use parallel builds with archives. It is
still not possible using the built-in rules, however you can now override
the built-in rules with a slightly different set of rules and use parallel
builds with archive creation. See the "Dangers When Using Archives" section
of the GNU Make manual, and https://savannah.gnu.org/bugs/index.php?14927
* Previously target-specific variables would inherit their "export" capability
from parent target-specific variables even if they were marked private. Now
private parent target-specific variables have no affect. For more details
see https://savannah.gnu.org/bugs/index.php?61463
* Disable FIFO jobserver on GNU/Hurd and Cygwin
Experimentation shows that the new FIFO-based jobserver doesn't work well on
GNU/Hurd or Cygwin: revert these systems to use the pipe-based jobserver.
* Updates to allow building on OS/2
Provided by KO Myung-Hun <komh78@gmail.com>
* New platform: GNU Make is supported on z/OS
Thanks to Igor Todorovski <itodorov@ca.ibm.com> for the patches and testing
assistance.
Version 4.4 (31 Oct 2022)
A complete list of bugs fixed in this version is available here:
https://sv.gnu.org/bugs/index.php?group=make&report_id=111&fix_release_id=109&set=custom
* WARNING: Deprecation!
The following systems are deprecated in this release:
- OS/2 (EMX)
- AmigaOS
- Xenix
- Cray
In the NEXT release of GNU Make, support for these systems will be removed.
If you want to see them continue to be supported, contact <bug-make@gnu.org>.
* WARNING: Future backward-incompatibility!
In the NEXT release of GNU Make, pattern rules will implement the same
behavior change for multiple targets as explicit grouped targets, below: if
any target of the rule is needed by the build, the recipe will be invoked if
any target of the rule is missing or out of date. During testing some
makefiles were found to contain pattern rules that do not build all targets;
this can cause issues so we are delaying this change for one release cycle
to allow these makefiles to be updated. GNU Make shows a warning if it
detects this situation: "pattern recipe did not update peer target".
* WARNING: Backward-incompatibility!
GNU Make now uses temporary files in more situations than previous releases.
If your build system sets TMPDIR (or TMP or TEMP on Windows) and deletes the
contents during the build, or uses restrictive permissions, this may cause
problems. You can choose an alternative temporary directory only for use by
GNU Make by setting the new MAKE_TMPDIR environment variable before invoking
make. Note that this value CANNOT be set inside the makefile, since make
needs to find its temporary directory before the makefiles are parsed.
* WARNING: Backward-incompatibility!
Previously each target in a explicit grouped target rule was considered
individually: if the targets needed by the build were not out of date the
recipe was not run even if other targets in the group were out of date. Now
if any of the grouped targets are needed by the build, then if any of the
grouped targets are out of date the recipe is run and all targets in the
group are considered updated.
* WARNING: Backward-incompatibility!
Previously if --no-print-directory was seen anywhere in the environment or
command line it would take precedence over any --print-directory. Now, the
last setting of directory printing options seen will be used, so a command
line such as "--no-print-directory -w" _will_ show directory entry/exits.
* WARNING: Backward-incompatibility!
Previously the order in which makefiles were remade was not explicitly
stated, but it was (roughly) the inverse of the order in which they were
processed by make. In this release, the order in which makefiles are
rebuilt is the same order in which make processed them, and this is defined
to be true in the GNU Make manual.
* WARNING: Backward-incompatibility!
Previously only simple (one-letter) options were added to the MAKEFLAGS
variable that was visible while parsing makefiles. Now, all options are
available in MAKEFLAGS. If you want to check MAKEFLAGS for a one-letter
option, expanding "$(firstword -$(MAKEFLAGS))" is a reliable way to return
the set of one-letter options which can be examined via findstring, etc.
* WARNING: Backward-incompatibility!
Previously makefile variables marked as export were not exported to commands
started by the $(shell ...) function. Now, all exported variables are
exported to $(shell ...). If this leads to recursion during expansion, then
for backward-compatibility the value from the original environment is used.
To detect this change search for 'shell-export' in the .FEATURES variable.
* WARNING: New build requirement
GNU Make utilizes facilities from GNU Gnulib: Gnulib requires certain C99
features in the C compiler and so these features are required by GNU Make:
https://www.gnu.org/software/gnulib/manual/html_node/C99-features-assumed.html
The configure script should verify the compiler has these features.
* New feature: The .WAIT special target
If the .WAIT target appears between two prerequisites of a target, then
GNU Make will wait for all of the targets to the left of .WAIT in the list
to complete before starting any of the targets to the right of .WAIT.
This feature is available in some other versions of make, and it will be
required by an upcoming version of the POSIX standard for make.
Different patches were made by Alexey Neyman <alex.neyman@auriga.ru> (2005)
and Steffen Nurpmeso <steffen@sdaoden.eu> (2020) that were useful but the
result is a different implementation (closer to Alexey's idea).
* New feature: .NOTPARALLEL accepts prerequisites
If the .NOTPARALLEL special target has prerequisites then all prerequisites
of those targets will be run serially (as if .WAIT was specified between
each prerequisite).
* New feature: The .NOTINTERMEDIATE special target
.NOTINTERMEDIATE disables intermediate behavior for specific files, for all
files built using a pattern, or for the entire makefile.
Implementation provided by Dmitry Goncharov <dgoncharov@users.sf.net>
* New feature: The $(let ...) function
This function allows user-defined functions to define a set of local
variables: values can be assigned to these variables from within the
user-defined function and they will not impact global variable assignments.
Implementation provided by Jouke Witteveen <j.witteveen@gmail.com>
* New feature: The $(intcmp ...) function
This function allows conditional evaluation controlled by a numerical
comparison.
Implementation provided by Jouke Witteveen <j.witteveen@gmail.com>
* New feature: Improved support for -l / --load-average
On systems that provide /proc/loadavg (Linux), GNU Make will use it to
determine the number of runnable jobs and use this as the current load,
avoiding the need for heuristics.
Implementation provided by Sven C. Dack <sdack@gmx.com>
* New feature: The --shuffle command line option
This option reorders goals and prerequisites to simulate non-determinism
that may be seen using parallel build. Shuffle mode allows a form of "fuzz
testing" of parallel builds to verify that all prerequisites are correctly
described in the makefile.
Implementation provided by Sergei Trofimovich <siarheit@google.com>
* New feature: The --jobserver-style command line option and named pipes
A new jobserver method is used on systems where mkfifo(3) is supported.
This solves a number of obscure issues related to using the jobserver
and recursive invocations of GNU Make. This change means that sub-makes
will connect to the jobserver even if they are not marked as recursive.
It also means that other tools that want to participate in the jobserver
will need to be enhanced as described in the GNU Make manual.
You can force GNU Make to use the simple pipe-based jobserver (perhaps if
you are integrating with other tools or older versions of GNU Make) by
adding the '--jobserver-style=pipe' option to the command line of the
top-level invocation of GNU Make, or via MAKEFLAGS or GNUMAKEFLAGS.
To detect this change search for 'jobserver-fifo' in the .FEATURES variable.
* Some POSIX systems (*BSD) do not allow locks to be taken on pipes, which
caused the output sync feature to not work properly there. Also multiple
invocations of make redirecting to the same output file (e.g., /dev/null)
would cause hangs. Instead of locking stdout (which does have some useful
performance characteristics, but is not portable) create a temporary file
and lock that. Windows continues to use a mutex as before.
* GNU Make has sometimes chosen unexpected, and sub-optimal, chains of
implicit rules due to the definition of "ought to exist" in the implicit
rule search algorithm, which considered any prerequisite mentioned in the
makefile as "ought to exist". This algorithm has been modified to prefer
prerequisites mentioned explicitly in the target being built and only if
that results in no matching rule, will GNU Make consider prerequisites
mentioned in other targets as "ought to exist".
Implementation provided by Dmitry Goncharov <dgoncharov@users.sf.net>
* GNU Make was performing secondary expansion of all targets, even targets
which didn't need to be considered during the build. In this release
only targets which are considered will be secondarily expanded.
Implementation provided by Dmitry Goncharov <dgoncharov@users.sf.net>
* If the MAKEFLAGS variable is modified in a makefile, it will be re-parsed
immediately rather than after all makefiles have been read. Note that
although all options are parsed immediately, some special effects won't
appear until after all makefiles are read.
* The -I option accepts an argument "-" (e.g., "-I-") which means "reset the
list of search directories to empty". Among other things this can be used
to prevent GNU Make from searching in its default list of directories.
* New debug option "print" will show the recipe to be run, even when silent
mode is set, and new debug option "why" will show why a target is rebuilt
(which prerequisites caused the target to be considered out of date).
Implementation provided by David Boyce <David.S.Boyce@gmail.com>
* The existing --trace option is made equivalent to --debug=print,why
* Target-specific variables can now be marked "unexport".
* Exporting / unexporting target-specific variables is handled correctly, so
that the attribute of the most specific variable setting is used.
* Special targets like .POSIX are detected upon definition, ensuring that any
change in behavior takes effect immediately, before the next line is parsed.
* When the pipe-based jobserver is enabled and GNU Make decides it is invoking
a non-make sub-process and closes the jobserver pipes, it will now add a new
option to the MAKEFLAGS environment variable that disables the jobserver.
This prevents sub-processes that invoke make from accidentally using other
open file descriptors as jobserver pipes. For more information see
https://savannah.gnu.org/bugs/?57242 and https://savannah.gnu.org/bugs/?62397
* A long-standing issue with the directory cache has been resolved: changes
made as a side-effect of some other target's recipe are now noticed as
expected.
* GNU Make can now be built for MS-Windows using the Tiny C tcc compiler.
Port provided by Christian Jullien <eligis@orange.fr>
Version 4.3 (19 Jan 2020)
A complete list of bugs fixed in this version is available here:
https://sv.gnu.org/bugs/index.php?group=make&report_id=111&fix_release_id=108&set=custom
* WARNING: Backward-incompatibility!
Number signs (#) appearing inside a macro reference or function invocation
@ -36,17 +358,24 @@ http://sv.gnu.org/bugs/index.php?group=make&report_id=111&fix_release_id=108&set
add a trailing space.
* WARNING: Backward-incompatibility!
On Linux, and any other systems that provide a /proc/loadavg with similar
syntax, the -l/--load-average option will consult that file to determine how
many CPUs are busy at that moment and compare that value to the load value
requested. This allows usage such as "-j -lN" for N-processor systems
without fear of overload during initial startup.
Patch provided by Sven C. Dack <sven.c.dack@sky.com>
Previously using the .SILENT pseudo-target in a makefile would force all
sub-makes to be invoked with the '-s' option, effectively making all
sub-makes silent as well. In this release .SILENT only affects the current
invocation of make. A side-effect of this is that .SILENT will no longer
enable the --no-print-directory option, which using -s will do.
* WARNING: Backward-incompatibility!
Contrary to the documentation, suffix rules with prerequisites were being
treated BOTH as simple targets AND as pattern rules. Behavior now matches
the documentation, and pattern rules are no longer created in this case.
* NOTE: Deprecated behavior.
Contrary to the documentation, suffix rules with prerequisites are being
treated BOTH as simple targets AND as pattern rules. Further, the
prerequisites are ignored by the pattern rules. POSIX specifies that in
order to be a suffix rule there can be no prerequisites defined. In this
release if POSIX mode is enabled then rules with prerequisites cannot be
suffix rules. If POSIX mode is not enabled then the previous behavior is
preserved (a pattern rule with no extra prerequisites is created) AND a
warning about this behavior is generated:
warning: ignoring prerequisites on suffix rule definition
The POSIX behavior will be adopted as the only behavior in a future release
of GNU Make so please resolve any warnings.
* New feature: Grouped explicit targets
Pattern rules have always had the ability to generate multiple targets with
@ -56,13 +385,21 @@ http://sv.gnu.org/bugs/index.php?group=make&report_id=111&fix_release_id=108&set
search for 'grouped-target' in the .FEATURES special variable.
Implementation contributed by Kaz Kylheku <kaz@kylheku.com>
* New feature: .EXTRA_PREREQS variable
Words in this variable are considered prerequisites of targets but they are
not added to any of the automatic variable values when expanding the
recipe. This variable can either be global (applies to all targets) or
a target-specific variable. To detect this feature search for 'extra-prereqs'
in the .FEATURES special variable.
Implementation contributed by Christof Warlich <cwarlich@gmx.de>
* Makefiles can now specify the '-j' option in their MAKEFLAGS variable and
this will cause make to enable that parallelism mode.
* GNU make will now use posix_spawn() on systems where it is available.
* GNU Make will now use posix_spawn() on systems where it is available.
If you prefer to use fork/exec even on systems where posix_spawn() is
present, you can use the --disable-posix-spawn option to configure. Aron
Barath <baratharon@caesar.elte.hu> provided the basic implementation.
present, you can use the --disable-posix-spawn option to configure.
Implementation contributed by Aron Barath <baratharon@caesar.elte.hu>
* Error messages printed when invoking non-existent commands have been cleaned
up and made consistent.
@ -76,17 +413,17 @@ http://sv.gnu.org/bugs/index.php?group=make&report_id=111&fix_release_id=108&set
* A new option -E has been added as a short alias for --eval.
* All wildcard expansion within GNU make, including $(wildcard ...), will sort
* All wildcard expansion within GNU Make, including $(wildcard ...), will sort
the results. See https://savannah.gnu.org/bugs/index.php?52076
* Interoperate with newer GNU libc and musl C runtime libraries.
* Performance improvements provided by Paolo Bonzini <pbonzini@redhat.com>
GNU make Developer News
GNU Make Developer News
* Import the GNU standard bootstrap script to replace the hand-rolled
"make update" method for building code from a GNU make Git repository.
"make update" method for building code from a GNU Make Git repository.
* Rework the source distribution to move source files into the src/*
subdirectory. This aligns with modern best practices in GNU.
@ -100,7 +437,7 @@ Version 4.2.1 (10 Jun 2016)
A complete list of bugs fixed in this version is available here:
http://sv.gnu.org/bugs/index.php?group=make&report_id=111&fix_release_id=107&set=custom
https://sv.gnu.org/bugs/index.php?group=make&report_id=111&fix_release_id=107&set=custom
This release is a bug-fix release.
@ -109,7 +446,7 @@ Version 4.2 (22 May 2016)
A complete list of bugs fixed in this version is available here:
http://sv.gnu.org/bugs/index.php?group=make&report_id=111&fix_release_id=106&set=custom
https://sv.gnu.org/bugs/index.php?group=make&report_id=111&fix_release_id=106&set=custom
* New variable: $(.SHELLSTATUS) is set to the exit status of the last != or
$(shell ...) function invoked in this instance of make. This will be "0" if
@ -120,11 +457,11 @@ http://sv.gnu.org/bugs/index.php?group=make&report_id=111&fix_release_id=106&set
The function is expanded to the contents of the file. The contents are
expanded verbatim except that the final newline, if any, is stripped.
* The makefile line numbers shown by GNU make now point directly to the
* The makefile line numbers shown by GNU Make now point directly to the
specific line in the recipe where the failure or warning occurred.
Sample changes suggested by Brian Vandenberg <phantall@gmail.com>
* The interface to GNU make's "jobserver" is stable as documented in the
* The interface to GNU Make's "jobserver" is stable as documented in the
manual, for tools which may want to access it.
WARNING: Backward-incompatibility! The internal-only command line option
@ -148,7 +485,7 @@ Version 4.1 (05 Oct 2014)
A complete list of bugs fixed in this version is available here:
http://sv.gnu.org/bugs/index.php?group=make&report_id=111&fix_release_id=105&set=custom
https://sv.gnu.org/bugs/index.php?group=make&report_id=111&fix_release_id=105&set=custom
* New variables: $(MAKE_TERMOUT) and $(MAKE_TERMERR) are set to non-empty
values if stdout or stderr, respectively, are believed to be writing to a
@ -159,7 +496,7 @@ http://sv.gnu.org/bugs/index.php?group=make&report_id=111&fix_release_id=105&set
requested mode, then closed again.
* Change the fatal error for mixed explicit and implicit rules, that was
introduced in GNU make 3.82, to a non-fatal error. However, this syntax is
introduced in GNU Make 3.82, to a non-fatal error. However, this syntax is
still deprecated and may return to being illegal in a future version of GNU
make. Makefiles that rely on this syntax should be fixed.
See https://savannah.gnu.org/bugs/?33034
@ -196,7 +533,7 @@ Version 4.0 (09 Oct 2013)
A complete list of bugs fixed in this version is available here:
http://sv.gnu.org/bugs/index.php?group=make&report_id=111&fix_release_id=101&set=custom
https://sv.gnu.org/bugs/index.php?group=make&report_id=111&fix_release_id=101&set=custom
* WARNING: Backward-incompatibility!
If .POSIX is specified, then make adheres to the POSIX backslash/newline
@ -207,7 +544,7 @@ http://sv.gnu.org/bugs/index.php?group=make&report_id=111&fix_release_id=101&set
single space
* New feature: GNU Guile integration
This version of GNU make can be compiled with GNU Guile integration.
This version of GNU Make can be compiled with GNU Guile integration.
GNU Guile serves as an embedded extension language for make.
See the "Guile Function" section in the GNU Make manual for details.
Currently GNU Guile 1.8 and 2.0+ are supported. In Guile 1.8 there is no
@ -239,20 +576,20 @@ http://sv.gnu.org/bugs/index.php?group=make&report_id=111&fix_release_id=101&set
* New feature: "!=" shell assignment operator as an alternative to the
$(shell ...) function. Implemented for compatibility with BSD makefiles.
Note there are subtle differences between "!=" and $(shell ...). See the
description in the GNU make manual.
description in the GNU Make manual.
WARNING: Backward-incompatibility!
Variables ending in "!" previously defined as "variable!= value" will now be
interpreted as shell assignment. Change your assignment to add whitespace
between the "!" and "=": "variable! = value"
* New feature: "::=" simple assignment operator as defined by POSIX in 2012.
This operator has identical functionality to ":=" in GNU make, but will be
This operator has identical functionality to ":=" in GNU Make, but will be
portable to any implementation of make conforming to a sufficiently new
version of POSIX (see http://austingroupbugs.net/view.php?id=330). It is
version of POSIX (see https://austingroupbugs.net/view.php?id=330). It is
not necessary to define the .POSIX target to access this operator.
* New feature: Loadable objects
This version of GNU make contains a "technology preview": the ability to
This version of GNU Make contains a "technology preview": the ability to
load dynamic objects into the make runtime. These objects can be created by
the user and can add extended functionality, usable by makefiles.
@ -260,8 +597,8 @@ http://sv.gnu.org/bugs/index.php?group=make&report_id=111&fix_release_id=101&set
* New variable: $(GNUMAKEFLAGS) will be parsed for make flags, just like
MAKEFLAGS is. It can be set in the environment or the makefile, containing
GNU make-specific flags to allow your makefile to be portable to other
versions of make. Once this variable is parsed, GNU make will set it to the
GNU Make-specific flags to allow your makefile to be portable to other
versions of make. Once this variable is parsed, GNU Make will set it to the
empty string so that flags will not be duplicated on recursion.
* New variable: `MAKE_HOST' gives the name of the host architecture
@ -300,9 +637,9 @@ Version 3.82 (28 Jul 2010)
A complete list of bugs fixed in this version is available here:
http://sv.gnu.org/bugs/index.php?group=make&report_id=111&fix_release_id=104&set=custom
https://sv.gnu.org/bugs/index.php?group=make&report_id=111&fix_release_id=104&set=custom
* Compiling GNU make now requires a conforming ISO C 1989 compiler and
* Compiling GNU Make now requires a conforming ISO C 1989 compiler and
standard runtime library.
* WARNING: Backward-incompatibility!
@ -310,7 +647,7 @@ http://sv.gnu.org/bugs/index.php?group=make&report_id=111&fix_release_id=104&set
fundamentally incompatible way: make is required to invoke the shell as if
the '-e' flag were provided. Because this would break many makefiles that
have been written to conform to the original text of the standard, the
default behavior of GNU make remains to invoke the shell with simply '-c'.
default behavior of GNU Make remains to invoke the shell with simply '-c'.
However, any makefile specifying the .POSIX special target will follow the
new POSIX standard and pass '-e' to the shell. See also .SHELLFLAGS
below.
@ -419,9 +756,9 @@ http://sv.gnu.org/bugs/index.php?group=make&report_id=111&fix_release_id=104&set
* A note on appending the redirected output. With this change, a simple
mechanism is implemented to make ">>" work in action lines. In VMS
there is no simple feature like ">>" to have DCL command or program
output redirected and appended to a file. GNU make for VMS already
output redirected and appended to a file. GNU Make for VMS already
implements the redirection of output. If such a redirection is detected,
an ">" on the action line, GNU make creates a DCL command procedure to
an ">" on the action line, GNU Make creates a DCL command procedure to
execute the action and to redirect its output. Based on that, now ">>"
is also recognized and a similar but different command procedure is
created to implement the append. The main idea here is to create a
@ -430,7 +767,7 @@ http://sv.gnu.org/bugs/index.php?group=make&report_id=111&fix_release_id=104&set
in the command procedure to keep changes in make small and simple. This
obviously has some limitations but it seems good enough compared with
the current ">" implementation. (And in my opinion, redirection is not
really what GNU make has to do.) With this approach, it may happen that
really what GNU Make has to do.) With this approach, it may happen that
the temporary file is not yet appended and is left in SYS$SCRATCH.
The temporary file names look like "CMDxxxxx.". Any time the created
command procedure can not complete, this happens. Pressing Ctrl+Y to
@ -453,9 +790,9 @@ http://sv.gnu.org/bugs/index.php?group=make&report_id=111&fix_release_id=104&set
Version 3.81 (01 Apr 2006)
* GNU make is ported to OS/2.
* GNU Make is ported to OS/2.
* GNU make is ported to MinGW. The MinGW build is only supported by
* GNU Make is ported to MinGW. The MinGW build is only supported by
the build_w32.bat batch file; see the file README.W32 for more
details.
@ -463,12 +800,12 @@ Version 3.81 (01 Apr 2006)
Up to and including this release, the '$?' variable does not contain
any prerequisite that does not exist, even though that prerequisite
might have caused the target to rebuild. Starting with the _next_
release of GNU make, '$?' will contain all prerequisites that caused
release of GNU Make, '$?' will contain all prerequisites that caused
the target to be considered out of date.
See http://savannah.gnu.org/bugs/?16051
See https://savannah.gnu.org/bugs/?16051
* WARNING: Backward-incompatibility!
GNU make now implements a generic "second expansion" feature on the
GNU Make now implements a generic "second expansion" feature on the
prerequisites of both explicit and implicit (pattern) rules. In order
to enable this feature, the special target '.SECONDEXPANSION' must be
defined before the first target which takes advantage of it. If this
@ -486,23 +823,23 @@ Version 3.81 (01 Apr 2006)
of this SysV feature you will need to update them.
* WARNING: Backward-incompatibility!
In order to comply with POSIX, the way in which GNU make processes
In order to comply with POSIX, the way in which GNU Make processes
backslash-newline sequences in recipes has changed. If your makefiles
use backslash-newline sequences inside of single-quoted strings in
recipes you will be impacted by this change. See the GNU make manual
recipes you will be impacted by this change. See the GNU Make manual
subsection "Splitting Recipe Lines" (node "Splitting Lines"), in
section "Recipe Syntax", chapter "Writing Recipe in Rules", for
details.
* WARNING: Backward-incompatibility!
Some previous versions of GNU make had a bug where "#" in a function
Some previous versions of GNU Make had a bug where "#" in a function
invocation such as $(shell ...) was treated as a make comment. A
workaround was to escape these with backslashes. This bug has been
fixed: if your makefile uses "\#" in a function invocation the
backslash is now preserved, so you'll need to remove it.
* New command line option: -L (--check-symlink-times). On systems that
support symbolic links, if this option is given then GNU make will
support symbolic links, if this option is given then GNU Make will
use the most recent modification time of any symbolic links that are
used to resolve target files. The default behavior remains as it
always has: use the modification time of the actual target file only.
@ -522,16 +859,16 @@ Version 3.81 (01 Apr 2006)
call are now masked in the context of the inner call.
* Implemented a solution for the "thundering herd" problem with "-j -l".
This version of GNU make uses an algorithm suggested by Thomas Riedl
This version of GNU Make uses an algorithm suggested by Thomas Riedl
<thomas.riedl@siemens.com> to track the number of jobs started in the
last second and artificially adjust GNU make's view of the system's
last second and artificially adjust GNU Make's view of the system's
load average accordingly.
* New special variables available in this release:
- .INCLUDE_DIRS: Expands to a list of directories that make searches
for included makefiles.
- .FEATURES: Contains a list of special features available in this
version of GNU make.
version of GNU Make.
- .DEFAULT_GOAL: Set the name of the default goal make will
use if no goals are provided on the command line.
- MAKE_RESTARTS: If set, then this is the number of times this
@ -569,7 +906,7 @@ Version 3.81 (01 Apr 2006)
it will be set in the environment, just as before.
* On MS Windows systems, explicitly setting SHELL to a pathname ending
in "cmd" or "cmd.exe" (case-insensitive) will force GNU make to use
in "cmd" or "cmd.exe" (case-insensitive) will force GNU Make to use
the DOS command interpreter in batch mode even if a UNIX-like shell
could be found on the system.
@ -589,7 +926,7 @@ Version 3.81 (01 Apr 2006)
A complete list of bugs fixed in this version is available here:
http://savannah.gnu.org/bugs/index.php?group=make&report_id=111&fix_release_id=103
https://savannah.gnu.org/bugs/index.php?group=make&report_id=111&fix_release_id=103
Version 3.80 (03 Oct 2002)
@ -601,7 +938,7 @@ Version 3.80 (03 Oct 2002)
requiring that target A will always be rebuilt if target B is updated.
Patch for this feature provided by Greg McGary <greg@mcgary.org>.
* For compatibility with SysV make, GNU make now supports the peculiar
* For compatibility with SysV make, GNU Make now supports the peculiar
syntax $$@, $$(@D), and $$(@F) in the prerequisites list of a rule.
This syntax is only valid within explicit and static pattern rules: it
cannot be used in implicit (suffix or pattern) rules. Edouard G. Parmelan
@ -626,7 +963,7 @@ Version 3.80 (03 Oct 2002)
useful here.
* A new built-in variable is defined, $(MAKEFILE_LIST). It contains a
list of each makefile GNU make has read, or started to read, in the
list of each makefile GNU Make has read, or started to read, in the
order in which they were encountered. So, the last filename in the
list when a makefile is just being read (before any includes) is the
name of the current makefile.
@ -636,7 +973,7 @@ Version 3.80 (03 Oct 2002)
makefiles at that moment.
* A new command line option is defined, -B or --always-make. If
specified GNU make will consider all targets out-of-date even if they
specified GNU Make will consider all targets out-of-date even if they
would otherwise not be.
* The arguments to $(call ...) functions were being stored in $1, $2,
@ -661,7 +998,7 @@ Version 3.80 (03 Oct 2002)
Turkish.
* Updated internationalization support to Gettext 0.11.5.
GNU make now uses Gettext's "external" feature, and does not include
GNU Make now uses Gettext's "external" feature, and does not include
any internationalization code itself. Configure will search your
system for an existing implementation of GNU Gettext (only GNU Gettext
is acceptable) and use it if it exists. If not, NLS will be disabled.
@ -678,7 +1015,7 @@ Version 3.80 (03 Oct 2002)
* This is the VMS port of GNU Make done by Hartmut.Becker@compaq.com.
It is based on the specific version 3.77k and on 3.78.1. 3.77k was done
by Klaus Kämpf <kkaempf@rmi.de>, the code was based on the VMS port of
by Klaus Kämpf <kkaempf@rmi.de>, the code was based on the VMS port of
GNU Make 3.60 by Mike Moretti.
It was ported on OpenVMS/Alpha V7.1, DECC V5.7-006. It was re-build and
@ -693,7 +1030,7 @@ Version 3.80 (03 Oct 2002)
available ECOs for VMS V7.1 and newer versions. It is fixed in versions
shipped with newer VMS versions and all ECO kits after October 1999. It
only shows up during the daylight saving time period (DST): stat()
returns a modification time 1 hour ahead. This results in GNU make
returns a modification time 1 hour ahead. This results in GNU Make
warning messages. For a just created source you will see:
$ gmake x.exe
@ -707,7 +1044,7 @@ Version 3.80 (03 Oct 2002)
A complete list of bugs fixed in this version is available here:
http://savannah.gnu.org/bugs/index.php?group=make&report_id=111&fix_release_id=102
https://savannah.gnu.org/bugs/index.php?group=make&report_id=111&fix_release_id=102
Version 3.79.1 (23 Jun 2000)
@ -721,11 +1058,11 @@ Version 3.79.1 (23 Jun 2000)
Version 3.79 (04 Apr 2000)
* GNU make optionally supports internationalization and locales via the
* GNU Make optionally supports internationalization and locales via the
GNU gettext (or local gettext if suitable) package. See the ABOUT-NLS
file for more information on configuring GNU make for NLS.
file for more information on configuring GNU Make for NLS.
* Previously, GNU make quoted variables such as MAKEFLAGS and
* Previously, GNU Make quoted variables such as MAKEFLAGS and
MAKEOVERRIDES for proper parsing by the shell. This allowed them to
be used within make build scripts. However, using them there is not
proper behavior: they are meant to be passed to subshells via the
@ -759,12 +1096,12 @@ Version 3.79 (04 Apr 2000)
value is greater than the "end" value. If that's true, nothing is
returned.
* Hartmut Becker provided many updates for the VMS port of GNU make.
* Hartmut Becker provided many updates for the VMS port of GNU Make.
See the README.VMS file for more details.
* VMS-specific changes:
* Fix a problem with automatically remaking makefiles. GNU make uses an
* Fix a problem with automatically remaking makefiles. GNU Make uses an
execve to restart itself after a successful remake of the makefile. On
UNIX systems execve replaces the running program with a new one and
resets all signal handling to the default. On VMS execve creates a child
@ -842,7 +1179,7 @@ Version 3.78 (22 Sep 1999)
* A "job server" feature, suggested by Howard Chu <hyc@highlandsun.com>.
On systems that support POSIX pipe(2) semantics, GNU make can now pass
On systems that support POSIX pipe(2) semantics, GNU Make can now pass
-jN options to submakes rather than forcing them all to use -j1. The
top make and all its sub-make processes use a pipe to communicate with
each other to ensure that no more than N jobs are started across all
@ -850,20 +1187,20 @@ Version 3.78 (22 Sep 1999)
with the --disable-job-server option.
* The confusing term "dependency" has been replaced by the more accurate
and standard term "prerequisite", both in the manual and in all GNU make
and standard term "prerequisite", both in the manual and in all GNU Make
output.
* GNU make supports the "big archive" library format introduced in AIX 4.3.
* GNU Make supports the "big archive" library format introduced in AIX 4.3.
* GNU make supports large files on AIX, HP-UX, and IRIX. These changes
* GNU Make supports large files on AIX, HP-UX, and IRIX. These changes
were provided by Paul Eggert <eggert@twinsun.com>. (Large file
support for Solaris and Linux was introduced in 3.77, but the
configuration had issues: these have also been resolved).
* The Windows 95/98/NT (W32) version of GNU make now has native support
* The Windows 95/98/NT (W32) version of GNU Make now has native support
for the Cygnus Cygwin release B20.1 shell (bash).
* The GNU make regression test suite, long available separately "under
* The GNU Make regression test suite, long available separately "under
the table", has been integrated into the release. You can invoke it
by running "make check" in the distribution. Note that it requires
Perl (either Perl 4 or Perl 5) to run.
@ -906,10 +1243,10 @@ Version 3.77 (28 Jul 1998)
you'll have to escape both of them: "foo : bar\\\=baz".
* A new appendix listing the most common error and warning messages
generated by GNU make, with some explanation, has been added to the
GNU make User's Manual.
generated by GNU Make, with some explanation, has been added to the
GNU Make User's Manual.
* Updates to the GNU make Customs library support (see README.customs).
* Updates to the GNU Make Customs library support (see README.customs).
* Updates to the Windows 95/NT port from Rob Tulloh (see README.W32),
and to the DOS port from Eli Zaretski (see README.DOS).
@ -918,10 +1255,10 @@ Version 3.77 (28 Jul 1998)
* This is the VMS port of GNU Make.
It is based on the VMS port of GNU Make 3.60 by Mike Moretti.
This port was done by Klaus Kämpf <kkaempf@rmi.de>
This port was done by Klaus Kämpf <kkaempf@rmi.de>
* There is first-level support available from proGIS Software, Germany.
Visit their web-site at http://www.progis.de to get information
Visit their web-site at https://www.progis.de to get information
about other vms software and forthcoming updates to gnu make.
* /bin/sh style I/O redirection is supported. You can now write lines like
@ -959,7 +1296,7 @@ Version 3.76.1 (19 Sep 1997)
Version 3.76 (16 Sep 1997)
* GNU make now uses automake to control Makefile.in generation. This
* GNU Make now uses automake to control Makefile.in generation. This
should make it more consistent with the GNU standards.
* VPATH functionality has been changed to incorporate the VPATH+ patch,
@ -974,7 +1311,7 @@ Version 3.76 (16 Sep 1997)
list of words from number S to number E (inclusive) of TEXT.
* Instead of an error, detection of future modification times gives a
warning and continues. The warning is repeated just before GNU make
warning and continues. The warning is repeated just before GNU Make
exits, so it is less likely to be lost.
* Fix the $(basename) and $(suffix) functions so they only operate on
@ -1129,9 +1466,9 @@ Version 3.71 (21 May 1994)
There is no longer a separate distribution containing Info and DVI files.
* You can now set the variables `binprefix' and/or `manprefix' in
Makefile.in (or on the command line when installing) to install GNU make
Makefile.in (or on the command line when installing) to install GNU Make
under a name other than `make' (i.e., ``make binprefix=g install''
installs GNU make as `gmake').
installs GNU Make as `gmake').
* The built-in Texinfo rules use the new variables `TEXI2DVI_FLAGS' for
flags to the `texi2dvi' script, and `MAKEINFO_FLAGS' for flags to the
@ -1611,7 +1948,7 @@ Version 3.05
(Changes from versions 1 through 3.05 were never recorded. Sorry.)
-------------------------------------------------------------------------------
Copyright (C) 1988-2019 Free Software Foundation, Inc.
Copyright (C) 1988-2024 Free Software Foundation, Inc.
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify it under the
@ -1624,4 +1961,4 @@ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
this program. If not, see <https://www.gnu.org/licenses/>.

View File

@ -1,80 +0,0 @@
Short: Port of GNU make with SAS/C (no ixemul.library required)
Author: GNU, Amiga port by Aaron "Optimizer" Digulla
Uploader: Aaron "Optimizer" Digulla (digulla@fh-konstanz.de)
Type: dev/c
This is a pure Amiga port of GNU make. It needs no extra libraries or
anything. It has the following features (in addition to any features of
GNU make):
- Runs Amiga-Commands with SystemTags() (Execute)
- Can run multi-line statements
- Allows to use Device-Names in targets:
c:make : make.o
is ok. To distinguish between device-names and target : or ::, MAKE
looks for spaces. If there are any around :, it's taken as a target
delimiter, if there are none, it's taken as the name of a device. Note
that "make:make.o" tries to create "make.o" on the device "make:".
- Replaces @@ by a newline in any command line:
if exists make @@\
delete make.bak quiet @@\
rename make make.bak @@\
endif @@\
$(CC) Link Make.o To make
works. Note that the @@ must stand alone (i.e., "make@@\" is illegal).
Also be careful that there is a space after the "\" (i.e., at the
beginning of the next line).
- Can be made resident to save space and time
- Amiga specific wildcards can be used in $(wildcard ...)
BUGS:
- The line
dummy.h : src/*.c
tries to make dummy.h from "src/*.c" (i.e., no wildcard-expansion takes
place). You have to use "$(wildcard src/*.c)" instead.
COMPILING FROM SCRATCH
----------------------
To recompile, you need SAS/C 6.51.
As of GNU make 4.3, the build environment has been cleaned up and alternate
make files (including smakefiles) have been removed. If you have an existing
version of GNU make available you _should_ be able to run:
make -f Basic.mk
However this is untested.
If you have an Amiga system and would like to collaborate on getting
bootstrapping to work properly please contact bug-make@gnu.org.
INSTALLATION
Copy make somewhere in your search path (e.g., sc:c or sc:bin).
If you plan to use recursive makes, install make resident:
Resident make Add
-------------------------------------------------------------------------------
Copyright (C) 1995-2019 Free Software Foundation, Inc.
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation; either version 3 of the License, or (at your option) any later
version.
GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.

View File

@ -79,7 +79,7 @@ To build from sources:
6. To install copy make.exe to the preferred location.
Since GNU make 4.3, support for customized platform installations
Since GNU Make 4.3, support for customized platform installations
has been removed. If you'd like to collaborate on reinstating
these capabilities, contact bug-make@gnu.org.
@ -280,7 +280,7 @@ Bug reports:
-------------------------------------------------------------------------------
Copyright (C) 1996-2019 Free Software Foundation, Inc.
Copyright (C) 1996-2024 Free Software Foundation, Inc.
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify it under the
@ -293,4 +293,4 @@ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
this program. If not, see <https://www.gnu.org/licenses/>.

View File

@ -1,6 +1,6 @@
Port of GNU make to OS/2.
Port of GNU Make to OS/2.
Features of GNU make that do not work under OS/2:
Features of GNU Make that do not work under OS/2:
- remote job execution
- dynamic load balancing
@ -9,7 +9,7 @@ Special features of the OS/2 version:
Due to the fact that some people might want to use sh syntax in
Makefiles while others might want to use OS/2's native shell cmd.exe,
GNU make supports both shell types. The following list defines the order
GNU Make supports both shell types. The following list defines the order
that is used to determine the shell:
1. The shell specified by the environment variable MAKESHELL.
@ -37,7 +37,7 @@ I. ***** SPECIAL OPTIONS *****
cmd or by specifying SHELL=cmd in your Makefile.
- At compile time you can set CPPFLAGS="-DNO_CHDIR2" to turn off that
GNU make prints drive letters. This is necessary if you want to run
GNU Make prints drive letters. This is necessary if you want to run
the testsuite.
@ -49,7 +49,7 @@ A standard Unix like build environment:
release 2)
If you use pdksh it is recommended to update to 5.2.14 release 2. Older
versions may not work! You can get this version at
http://www.math.ohio-state.edu/~ilya/software/os2/pdksh-5.2.14-bin-2.zip
https://www.math.ohio-state.edu/~ilya/software/os2/pdksh-5.2.14-bin-2.zip
- GNU file utilities (make sure that install.exe from the file utilities
is in front of your PATH before X:\OS2\INSTALL\INSTALL.EXE. I recommend
also to change the filename to ginstall.exe instead of install.exe
@ -59,7 +59,7 @@ A standard Unix like build environment:
- gawk
- grep
- sed
- GNU make 3.79.1 (special OS/2 patched version) or higher
- GNU Make 3.79.1 (special OS/2 patched version) or higher
- perl 5.005 or higher
- GNU texinfo (you can use 3.1 (gnuinfo.zip), but I recommend 4.0)
@ -73,7 +73,7 @@ III. ***** COMPILATION AND INSTALLATION *****
To recreate the configuration files use:
export EMXSHELL=ksh
aclocal -I config
aclocal -I m4
automake
autoconf
autoheader
@ -93,7 +93,7 @@ Recommended environment variables and installation options:
export CFLAGS="-O2 -Zomf -Zmt"
export LDFLAGS="-Zcrtdll -Zlinker /exepack:2 -Zlinker /pm:vio -Zstack 0x6000"
export RANLIB="echo"
./configure --prefix=x:/usr --infodir=x:/usr/share/info --mandir=x:/usr/share/man --without-included-gettext
./configure --prefix=x:/usr --infodir=x:/usr/share/info --mandir=x:/usr/share/man
make AR=emxomfar
make install
@ -102,18 +102,21 @@ Note: If you use gcc 2.9.x I recommend to set also LIBS="-lgcc"
Note: You can add -DNO_CMD_DEFAULT and -DNO_CHDIR2 to CPPFLAGS.
See section I. for details.
Note: If you use Open Watcom Linker instead of IBM Linker, remove
'-Zlinker /exepack:2' from LDFLAGS.
IV. ***** NLS support *****
GNU make has NLS (National Language Support), with the following
GNU Make has NLS (National Language Support), with the following
caveats:
a) It will only work with GNU gettext, and
b) GNU gettext support is not included in the GNU make package.
b) GNU gettext support is not included in the GNU Make package.
Therefore, if you wish to enable the internationalization features of
GNU make you must install GNU gettext on your system before configuring
GNU make.
GNU Make you must install GNU gettext on your system before configuring
GNU Make.
You can choose the languages to be installed. To install support for
English, German and French only enter:
@ -138,7 +141,7 @@ testsuite itself. -DNO_CMD_DEFAULT causes make to use /bin/sh as default
shell in every case. Normally you could simply set MAKESHELL="/bin/sh"
to do this but the testsuite ignores the environment. -DNO_CHDIR2 causes
make not to use drive letters for directory names (i.e. _chdir2() and
_getcwd2() are NOT used). The testsuite interpretes the whole output of
_getcwd2() are NOT used). The testsuite interprets the whole output of
make, especially statements like make[1]: Entering directory
'C:/somewhere/make-3.79.1/tests' where the testsuite does not expect the
drive letter. This would be interpreted as an error even if there is
@ -160,7 +163,7 @@ from the make source tree.
-------------------------------------------------------------------------------
Copyright (C) 2003-2019 Free Software Foundation, Inc.
Copyright (C) 2003-2024 Free Software Foundation, Inc.
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify it under the
@ -173,4 +176,4 @@ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
this program. If not, see <https://www.gnu.org/licenses/>.

View File

@ -1,7 +1,7 @@
Overview: -*-text-mode-*-
---------
This version of GNU make has been tested on:
This version of GNU Make has been tested on:
OpenVMS V8.3/V8.4 (Alpha) and V8.4 (Integrity) AND V7.3 (VAX)
This version of GNU Make is intended to be run from DCL to run
@ -11,10 +11,10 @@ Overview: -*-text-mode-*-
There is an older implementation of GNU Make that was ported to GNV.
Work is now in progress to merge that port to get a single version
of GNU Make available. When that merge is done, GNU Make will auto
detect that it is running under a Posix shell and then operate as close to
detect that it is running under a POSIX shell and then operate as close to
GNU Make on Unix as possible.
The descriptions below are for running GNU make from DCL or equivalent.
The descriptions below are for running GNU Make from DCL or equivalent.
Recipe differences:
-------------------
@ -62,15 +62,15 @@ Recipe differences:
enabled if the GNU Make is set to the older behavior.
The name GNV$MAKE_SHELL_SIM when enabled will cause GNU Make to try to
simulate a Posix shell more closely. The following behaviors occur:
simulate a POSIX shell more closely. The following behaviors occur:
* Single quotes are converted to double quotes and any double
quotes inside of them are doubled. No environment variable expansion
is simulated.
* A exit command status will be converted to a Posix Exit
* A exit command status will be converted to a POSIX Exit
where 0 is success and non-zero is failure.
* The $ character will cause environment variable expansion.
* Environent variables can be set on the command line before a command.
* Environment variables can be set on the command line before a command.
VMS generally uses logical name search lists instead of path variables
where the resolution is handled by VMS independent of the program. Which
@ -84,11 +84,11 @@ Recipe differences:
The format for recipes are a combination of Unix macros, a subset of
simulated UNIX commands, some shell emulation, and OpenVMS commands.
This makes the resulting makefiles unique to the OpenVMS port of GNU make.
This makes the resulting makefiles unique to the OpenVMS port of GNU Make.
If you are creating a OpenVMS specific makefile from scratch, you should also
look at MMK (Madgoat Make) available at https://github.com/endlesssoftware/mmk
MMK uses full OpenVMS syntax and a persistent subprocess is used for the
MMK uses full OpenVMS syntax and a persistent sub-process is used for the
recipe lines, allowing multiple line rules.
The default makefile search order is "makefile.vms", "gnumakefile",
@ -177,7 +177,7 @@ Recipe differences:
Since the OpenVMS utilities generally expect OpenVMS format paths, you will
usually have to use OpenVMS format paths for rules and targets.
BUG: Relative OpenVMS paths may not work in targets, especially combined
with vpaths. This is because GNU make will just concatenate the directories
with vpaths. This is because GNU Make will just concatenate the directories
as it does on Unix.
The variables $^ and $@ separate files with commas instead of spaces.
@ -207,15 +207,15 @@ foo: $(addsuffix .3,$(subs $(comma),$(space),$^)
override OpenVMS symbols/logicals.
OpenVMS logical and symbols names show up as "environment" using the
origin function. when the "-e" option is specified, the origion function
shows them as "environment override". On Posix the test scripts indicate
origin function. when the "-e" option is specified, the origin function
shows them as "environment override". On POSIX the test scripts indicate
that they should show up just as "environment".
When GNU make reads in a symbol or logical name into the environment, it
When GNU Make reads in a symbol or logical name into the environment, it
converts any dollar signs found to double dollar signs for convenience in
using DCL symbols and logical names in recipes. When GNU make exports a
using DCL symbols and logical names in recipes. When GNU Make exports a
DCL symbol for a child process, if the first dollar sign found is followed
by second dollar sign, then all double dollar signs will be convirted to
by second dollar sign, then all double dollar signs will be converted to
single dollar signs.
The variable $(ARCH) is predefined as IA64, ALPHA or VAX respectively.
@ -233,17 +233,17 @@ endif
Empty commands are handled correctly and don't end in a new DCL process.
The exit command needs to have OpenVMS exit codes. To pass a Posix code
The exit command needs to have OpenVMS exit codes. To pass a POSIX code
back to the make script, you need to encode it by multiplying it by 8
and then adding %x1035a002 for a failure code and %x1035a001 for a
success. Make will interpret any posix code other than 0 as a failure.
TODO: Add an option have simulate Posix exit commands in recipes.
success. Make will interpret any POSIX code other than 0 as a failure.
TODO: Add an option have simulate POSIX exit commands in recipes.
Lexical functions can be used in pipes to simulate shell file test rules.
Example:
Posix:
POSIX:
b : c ; [ -f $@ ] || echo >> $@
OpenVMS:
@ -261,16 +261,16 @@ x = %x1035a00a
Runtime issues:
The OpenVMS C Runtime has a convention for encoding a Posix exit status into
The OpenVMS C Runtime has a convention for encoding a POSIX exit status into
to OpenVMS exit codes. These status codes will have the hex value of
0x35a000. OpenVMS exit code may also have a hex value of %x10000000 set on
them. This is a flag to tell DCL not to write out the exit code.
To convert an OpenVMS encoded Posix exit status code to the original code
To convert an OpenVMS encoded POSIX exit status code to the original code
You subtract %x35a000 and any flags from the OpenVMS code and divide it by 8.
WARNING: Backward-incompatibility!
The make program exit now returns the same encoded Posix exit code as on
The make program exit now returns the same encoded POSIX exit code as on
Unix. Previous versions returned the OpenVMS exit status code if that is what
caused the recipe to fail.
TODO: Provide a way for scripts calling make to obtain that OpenVMS status
@ -280,11 +280,11 @@ Runtime issues:
will have the error "-E-" severity set on exit.
MAKE_TROUBLE is returned only if the option "-q" or "--question" is used and
has a Posix value of 1 and an OpenVMS status of %x1035a00a.
has a POSIX value of 1 and an OpenVMS status of %x1035a00a.
MAKE_FAILURE has a Posix value of 2 and an OpenVMS status of %x1035a012.
MAKE_FAILURE has a POSIX value of 2 and an OpenVMS status of %x1035a012.
Output from GNU make may have single quotes around some values where on
Output from GNU Make may have single quotes around some values where on
other platforms it does not. Also output that would be in double quotes
on some platforms may show up as single quotes on VMS.
@ -294,10 +294,10 @@ Runtime issues:
There may be a "Waiting for unfinished jobs..." show up in the output.
Error messages generated by Make or Unix utilities may slightly vary from
Posix platforms. Typically the case may be different.
POSIX platforms. Typically the case may be different.
When make deletes files, on posix platforms it writes out 'rm' and the list
of files. On VMS, only the files are writen out, one per line.
When make deletes files, on POSIX platforms it writes out 'rm' and the list
of files. On VMS, only the files are written out, one per line.
TODO: VMS
There may be extra leading white space or additional or missing whitespace
@ -323,15 +323,15 @@ Runtime issues:
to override this in your makefile, or whatever).
Unix compatibilty features:
---------------------------
Unix compatibility features:
----------------------------
If the command 'echo' is seen, any single quotes on the line will be
converted to double quotes.
The variable $(CD) is implemented as a built in Change Directory
command. This invokes the 'builtin_cd' Executing a 'set default'
recipe doesn't do the trick, since it only affects the subprocess
recipe doesn't do the trick, since it only affects the sub-process
spawned for that command.
The 'builtin_cd' is generally expected to be on its own line.
@ -347,13 +347,13 @@ Unix compatibilty features:
Unix shell style I/O redirection is supported. You can now write lines like:
"<tab>mcr sys$disk:[]program.exe < input.txt > output.txt &> error.txt"
Posix shells have ":" as a null command. These are now handled.
POSIX shells have ":" as a null command. These are now handled.
https://savannah.gnu.org/bugs/index.php?41761
A note on appending the redirected output. A simple mechanism is
implemented to make ">>" work in action lines. In OpenVMS there is no simple
feature like ">>" to have DCL command or program output redirected and
appended to a file. GNU make for OpenVMS implements the redirection
appended to a file. GNU Make for OpenVMS implements the redirection
of ">>" by using a command procedure.
The current algorithm creates the output file if it does not exist and
@ -367,10 +367,10 @@ Unix compatibilty features:
The older implementation wrote the output to a temporary file in
in sys$scratch: and then attempted to append the file to the existing file.
The temporary file names looked like "CMDxxxxx.". Any time the created
command procedure can not complete, this happens. Pressing Ctrl+Y to
command procedure can not complete, this happens. Pressing CTRL+Y to
abort make is one case.
In case of Ctrl+Y the associated command procedure is left in SYS$SCRATCH:.
In case of CTRL+Y the associated command procedure is left in SYS$SCRATCH:.
The command procedures will be named gnv$make_cmd*.com.
The CtrlY handler now uses $delprc to delete all children. This way also
@ -378,12 +378,12 @@ Unix compatibilty features:
then sends SIGQUIT to itself, which is handled in common code.
Temporary command files are now deleted in the OpenVMS child termination
handler. That deletes them even if a Ctrl+C was pressed.
handler. That deletes them even if a CTRL+C was pressed.
TODO: Does the previous section about >> leaving files still apply?
The behavior of pressing Ctrl+C is not changed. It still has only an effect,
The behavior of pressing CTRL+C is not changed. It still has only an effect,
after the current action is terminated. If that doesn't happen or takes too
long, Ctrl+Y should be used instead.
long, CTRL+Y should be used instead.
Build Options:
@ -409,7 +409,7 @@ Unimplemented functionality:
The new feature "Loadable objects" is not yet supported. If you need it,
please send a change request or submit a bug report.
The new option --output-sync (-O) is accepted but has no effect: GNU make
The new option --output-sync (-O) is accepted but has no effect: GNU Make
for OpenVMS does not support running multiple commands simultaneously.
@ -421,8 +421,8 @@ Self test failures and todos:
Need to find a way to set the VMS features before running make as a
child.
GNU make was not currently translating the OpenVMS encoded POSIX values
returned to it back to the Posix values. I have temporarily modified the
GNU Make was not currently translating the OpenVMS encoded POSIX values
returned to it back to the POSIX values. I have temporarily modified the
Perl test script to compensate for it. This should be being handled
internally to Make.
TODO: Verify and update the Perl test script.
@ -435,7 +435,7 @@ Self test failures and todos:
Symlink support is not present. Symlinks are supported by OpenVMS 8.3 and
later.
Error messages should be supressed with the "-" at the beginning of a line.
Error messages should be suppressed with the "-" at the beginning of a line.
On openVMS they were showing up. TODO: Is this still an issue?
The internal vmsify and unixify OpenVMS to/from UNIX are not handling logical
@ -443,7 +443,7 @@ Self test failures and todos:
Build instructions:
------------------
-------------------
Don't use the HP C V7.2-001 compiler, which has an incompatible change
how __STDC__ is defined. This results at least in compile time warnings.
@ -478,7 +478,7 @@ Running the tests:
https://sourceforge.net/projects/gnv/files/
As the test scripts need to create some foreign commands that persist
after the test is run, it is recommend that either you use a subprocess or
after the test is run, it is recommend that either you use a sub-process or
a dedicated login to run the tests.
To get detailed information for running the tests:
@ -499,12 +499,12 @@ Running the tests:
$ perl run_make_tests.pl
Acknowlegements:
Acknowledgments:
----------------
See NEWS. for details of past changes.
These are the currently known contributers to this port.
These are the currently known contributors to this port.
Hartmut Becker
John Malmberg

View File

@ -1,5 +1,5 @@
This version of GNU make has been tested on:
Microsoft Windows 2000/XP/2003/Vista/7/8/10
This version of GNU Make has been tested on:
Microsoft Windows 2000/XP/2003/Vista/7/8/10/11
It has also been used on Windows 95/98/NT, and on OS/2.
It builds with the MinGW port of GCC (tested with GCC 3.4.2, 4.8.1,
@ -15,7 +15,7 @@ which compilation and link switches and libraries need to be mentioned
on the compiler command lines to correctly link with Guile. A Windows
port of pkg-config can be found on ezwinports site:
http://sourceforge.net/projects/ezwinports/
https://sourceforge.net/projects/ezwinports/
The libraries on which Guile depends can vary depending on your
version and build of Guile. At the very least, the Boehm's GC library
@ -25,7 +25,7 @@ also provide you with these dependencies or a URL where to download
them. A precompiled 32-bit Windows build of Guile is available from
the ezwinports site mentioned above.
The Windows port of GNU make is maintained jointly by various people.
The Windows port of GNU Make is maintained jointly by various people.
It was originally made by Rob Tulloh.
It is currently maintained by Eli Zaretskii.
@ -33,12 +33,14 @@ It is currently maintained by Eli Zaretskii.
Do this first, regardless of the build method you choose:
---------------------------------------------------------
1. Edit config.h.W32 to your liking (especially the few shell-related
defines near the end, or HAVE_CASE_INSENSITIVE_FS which corresponds
to './configure --enable-case-insensitive-file-system'). (We don't
recommend to define HAVE_CASE_INSENSITIVE_FS, but you may wish to
consider that if you have a lot of files whose names are in upper
case, while Makefile rules are written for lower-case versions.)
1. If you have special requirements, edit config.h.W32 to your liking
(especially the shell-related defines, or HAVE_CASE_INSENSITIVE_FS which
corresponds to './configure --enable-case-insensitive-file-system'). We
don't recommend to define HAVE_CASE_INSENSITIVE_FS, but you may wish to
consider that if you have a lot of files whose names are in upper case,
while Makefile rules are written for lower-case versions.
If you don't have special requirements no changes are needed.
Building with (MinGW-)GCC using build_w32.bat
@ -51,7 +53,7 @@ Building with (MinGW-)GCC using build_w32.bat
This produces gnumake.exe in the GccRel directory.
If you want a version of GNU make built with debugging enabled,
If you want a version of GNU Make built with debugging enabled,
add the --debug option. Output goes into the GccDebug directory.
The batch file will probe for Guile installation, and will build
@ -73,21 +75,21 @@ Building with (MSVC++-)cl using build_w32.bat
file will probe your system and choose the newest MSVC version it can
find.
If you want a 32bit version of GNU make, add the --x86 option.
If you want a 32bit version of GNU Make, add the --x86 option.
If you want a Debug build of GNU make, add the --debug option. Output
If you want a Debug build of GNU Make, add the --debug option. Output
will go into the .\WinDebug directory.
The batch file will probe for Guile installation, and will build
gnumake.exe with Guile if it finds it. If Guile is installed,
but you prefer to build GNU make without Guile support, add the
but you prefer to build GNU Make without Guile support, add the
--without-guile option.
Building with (MinGW-)GCC using GNU make
Building with (MinGW-)GCC using GNU Make
----------------------------------------
2. If you already have a version of GNU make available you can use it
2. If you already have a version of GNU Make available you can use it
to build this version. Open a W32 command prompt for your installed
(MinGW-)GCC, setup a correct PATH and other environment variables
for it, then execute ...
@ -95,7 +97,7 @@ Building with (MinGW-)GCC using GNU make
make -f Basic.mk TOOLCHAIN=gcc
This produces GccRel\gnumake.exe.
If you want a version of GNU make built with debugging enabled,
If you want a version of GNU Make built with debugging enabled,
add the TARGET_TYPE=debug option:
make -f Basic.mk TOOLCHAIN=gcc TARGET_TYPE=debug
@ -104,10 +106,10 @@ Building with (MinGW-)GCC using GNU make
if you want to build with Guile support.
Building with (MSVC++-)cl using GNU make
Building with (MSVC++-)cl using GNU Make
----------------------------------------
2. If you already have a version of GNU make available you can use it
2. If you already have a version of GNU Make available you can use it
to build this version. Open a W32 command prompt for your installed
(MSVC++-)cl, setup a correct PATH and other environment variables
for it (usually via executing vcvars32.bat or vsvars32.bat from the
@ -117,7 +119,7 @@ Building with (MSVC++-)cl using GNU make
make -f Basic.mk
This produces an optimized WinRel/gnumake.exe.
If you want a version of GNU make built with debugging enabled,
If you want a version of GNU Make built with debugging enabled,
add the TARGET_TYPE=debug option:
make -f Basic.mk TARGET_TYPE=debug
@ -132,7 +134,7 @@ Running the test suite
3. You will need an installation of Perl. Be sure to use a relatively
modern version: older versions will sometimes throw spurious errors.
To run the suite after building using GNU make, use:
To run the suite after building using GNU Make, use:
make -f Basic.mk check
@ -156,7 +158,7 @@ Running the test suite
-- Notes/Caveats --
-------------------
GNU make on Windows 32-bit platforms:
GNU Make on Windows 32-bit platforms:
This version of make is ported natively to Windows32 platforms
(Windows NT 3.51, Windows NT 4.0, Windows 2000, Windows XP,
@ -166,11 +168,11 @@ GNU make on Windows 32-bit platforms:
officially are the MinGW port of GNU GCC, and the various
versions of the Microsoft C compiler.
Do not confuse this port of GNU make with other Windows32 projects
which provide a GNU make binary. These are separate projects
Do not confuse this port of GNU Make with other Windows32 projects
which provide a GNU Make binary. These are separate projects
and are not connected to this port effort.
GNU make and sh.exe:
GNU Make and sh.exe:
This port prefers if you have a working sh.exe somewhere on
your system. If you don't have sh.exe, the port falls back to
@ -180,12 +182,12 @@ GNU make and sh.exe:
There are very few true ports of Bourne shell for NT right now.
There is a version of GNU bash available from Cygnus "Cygwin"
porting effort (http://www.cygwin.com/).
porting effort (https://www.cygwin.com/).
Other possibilities are the MKS version of sh.exe, or building
your own with a package like NutCracker (DataFocus) or Portage
(Consensys). Also MinGW includes sh (http://mingw.org/).
(Consensys). Also MinGW includes sh.
GNU make and brain-dead shells (BATCH_MODE_ONLY_SHELL):
GNU Make and brain-dead shells (BATCH_MODE_ONLY_SHELL):
Some versions of Bourne shell do not behave well when invoked
as 'sh -c' from CreateProcess(). The main problem is they seem
@ -211,21 +213,21 @@ Support for parallel builds
Parallel builds (-jN) are supported in this port. The number of
concurrent processes has a hard limit of 4095.
GNU make and Cygnus GNU Windows32 tools:
GNU Make and Cygnus GNU Windows32 tools:
Good news! Make now has native support for Cygwin sh. To enable,
define the HAVE_CYGWIN_SHELL in config.h and rebuild make
from scratch. This version of make tested with B20.1 of Cygwin.
Do not define BATCH_MODE_ONLY_SHELL if you use HAVE_CYGWIN_SHELL.
GNU make and the MKS shell:
GNU Make and the MKS shell:
There is now semi-official support for the MKS shell. To turn this
support on, define HAVE_MKS_SHELL in the config.h.W32 before you
build make. Do not define BATCH_MODE_ONLY_SHELL if you turn
on HAVE_MKS_SHELL.
GNU make handling of drive letters in pathnames (PATH, vpath, VPATH):
GNU Make handling of drive letters in pathnames (PATH, vpath, VPATH):
There is a caveat that should be noted with respect to handling
single character pathnames on Windows systems. When colon is
@ -291,7 +293,7 @@ Pathnames and Case insensitivity:
the file with other case permutations will succeed (i.e. opening a
file named "target" or "TARGET" will open the file "Target").
By default, GNU make retains its case sensitivity when comparing
By default, GNU Make retains its case sensitivity when comparing
target names and existing files or directories. It can be
configured, however, into a case preserving and case insensitive
mode by adding a define for HAVE_CASE_INSENSITIVE_FS to
@ -309,10 +311,10 @@ Pathnames and Case insensitivity:
SUBDIR/DepTarget: SubDir/TARGET
cp $^ $@
Reliance on this behavior also eliminates the ability of GNU make
Reliance on this behavior also eliminates the ability of GNU Make
to use case in comparison of matching rules. For example, it is
not possible to set up a C++ rule using %.C that is different
than a C rule using %.c. GNU make will consider these to be the
than a C rule using %.c. GNU Make will consider these to be the
same rule and will issue a warning.
SAMBA/NTFS/VFAT:
@ -342,10 +344,10 @@ FAT:
Bug reports:
Please submit bugs via the normal bug reporting mechanism which
is described in the GNU make manual and the base README.
is described in the GNU Make manual and the base README.
-------------------------------------------------------------------------------
Copyright (C) 1996-2019 Free Software Foundation, Inc.
Copyright (C) 1996-2024 Free Software Foundation, Inc.
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify it under the
@ -358,4 +360,4 @@ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
this program. If not, see <https://www.gnu.org/licenses/>.

View File

@ -1,6 +1,6 @@
-*-indented-text-*-
GNU make can utilize the Customs library, distributed with Pmake, to
GNU Make can utilize the Customs library, distributed with Pmake, to
provide builds distributed across multiple hosts.
In order to utilize this capability, you must first download and build
@ -21,11 +21,11 @@ please see the pmake and Customs documentation for details. The best
place to look for instructions is in the pmake-2.1.33/INSTALL file.
Note that the 2.1.33 Pmake distribution comes with a set of patches to
GNU make, distributed in the pmake-2.1.33/etc/gnumake/ directory. These
patches are based on GNU make 3.75 (there are patches for earlier
versions of GNU make, also). The parts of this patchfile which relate
GNU Make, distributed in the pmake-2.1.33/etc/gnumake/ directory. These
patches are based on GNU Make 3.75 (there are patches for earlier
versions of GNU Make, also). The parts of this patchfile which relate
directly to Customs support have already been incorporated into this
version of GNU make, so you should _NOT_ apply the patch file.
version of GNU Make, so you should _NOT_ apply the patch file.
However, there are a few non-Customs specific (as far as I could tell)
changes here which are not incorporated (for example, the modification
@ -42,14 +42,14 @@ install' there directly).
BUILDING GNU MAKE
-----------------
Once you've installed Customs, you can build GNU make to use it. When
configuring GNU make, merely use the '--with-customs=DIR' option.
Once you've installed Customs, you can build GNU Make to use it. When
configuring GNU Make, merely use the '--with-customs=DIR' option.
Provide the directory containing the 'lib' and 'include/customs'
subdirectories as DIR. For example, if you installed the customs
library in /usr/local/lib and the headers in /usr/local/include/customs,
then you'd pass '--with-customs=/usr/local' as an option to configure.
Run make (or use build.sh) normally to build GNU make as described in
Run make (or use build.sh) normally to build GNU Make as described in
the INSTALL file.
See the documentation for Customs for information on starting and
@ -83,7 +83,7 @@ PROBLEMS
SunOS 4.1.x:
The customs/sprite.h header file #includes the <malloc.h> header
files; this conflicts with GNU make's configuration so you'll get a
files; this conflicts with GNU Make's configuration so you'll get a
compile error if you use GCC (or any other ANSI-capable C compiler).
I commented out the #include in sprite.h:107:
@ -96,7 +96,7 @@ SunOS 4.1.x:
-------------------------------------------------------------------------------
Copyright (C) 1998-2019 Free Software Foundation, Inc.
Copyright (C) 1998-2024 Free Software Foundation, Inc.
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify it under the
@ -109,4 +109,4 @@ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
this program. If not, see <https://www.gnu.org/licenses/>.

View File

@ -1,7 +1,7 @@
-*-text-*-
-------------------------------------------------------------------------------
Copyright (C) 2002-2019 Free Software Foundation, Inc.
Copyright (C) 2002-2024 Free Software Foundation, Inc.
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify it under the
@ -14,7 +14,7 @@ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
this program. If not, see <https://www.gnu.org/licenses/>.
-------------------------------------------------------------------------------
Obtaining Git Code
@ -23,7 +23,7 @@ Obtaining Git Code
This seems redundant, since if you're reading this you most likely have
already performed this step; however, for completeness, you can obtain the GNU
make source code via Git from the FSF's Savannah project
<http://savannah.gnu.org/projects/make/>:
<https://savannah.gnu.org/projects/make/>:
$ git clone git://git.savannah.gnu.org/make.git
@ -31,10 +31,13 @@ make source code via Git from the FSF's Savannah project
Changes using Git
-----------------
For non-developers, you can continue to provide patches as before, or if you
make a public repository I can pull from that if you prefer.
If you do not have push privileges to the GNU Make Git repository, see the
README file section "Submitting Patches" for information.
Starting with GNU make 4.0 we no longer keep a separate ChangeLog file in
If you have push privileges to the GNU Make Git repository keep this
information in mind:
Starting with GNU Make 4.0 we no longer keep a separate ChangeLog file in
source control. We use the Gnulib git-to-changelog conversion script to
convert the Git comments into ChangeLog-style entries for release. As a
result, please format your Git comments carefully so they will look clean
@ -43,61 +46,72 @@ added before it so be sure your comment lines are not longer than 72
characters; prefer 70 or less. Please use standard ChangeLog formats for
your commit messages (sans the leading TAB of course).
Rule #1: Don't rewrite pushed history (don't use "git push --force").
Rule #1: Don't rewrite pushed history on master (no "git push --force").
Rule #2: Feel free to rewrite pushed history on personal branches.
Rule #3: Squash-merge or rebase + merge --ff-only, rather than merging from
personal branches into master.
Typical simple workflow might be:
* Edit files
* Edit files / make / make check
* Use "git status" and "git diff" to verify your changes
* Use "git add" to stage the changes you want to make
* Use "git commit" to commit the staged changes to your local repository
* Use "git pull" to accept & merge new changes from the Savannah repository
* Use "git push" to push your commits back to the Savannah repository
* Use "git pull -r" to accept new changes from the upstream repository
* Use "git push" to push your commits back to the upstream repository
For Emacs users, there are many options for Git integration but I strongly
recommend the Magit package: http://www.emacswiki.org/emacs/Magit
It makes the workflow much clearer, and has advanced features such as
constructing multiple commits from various files and even from different
diff chunks in the same file. There is a video available which helps a lot.
recommend Magit: https://magit.vc/ It makes the workflow much clearer, and
has advanced features such as constructing multiple commits from various files
and even from different diff chunks in the same file. There is a video
available which helps a lot.
Coding Standards
----------------
GNU make code adheres to the GNU Coding Standards. Please use only spaces and
GNU Make code adheres to the GNU Coding Standards. Please use only spaces and
no TAB characters in source code.
Additionally, GNU make is a foundational bootstrap package for the GNU
project; as such it is very conservative about language features it expects.
It should build with any C compiler conforming to the ANSI C89 / ISO C90
standard.
Additionally, GNU Make is a foundational bootstrap package for the GNU
project; as such it is conservative about language features it expects.
However, GNU Make does rely on the Gnulib portability library, and Gnulib
currently requires a ISO C99 compiler. So features in ISO C99 can be
assumed.
Building From Git for POSIX
---------------------------
To build GNU make from Git on POSIX systems such as GNU/Linux, you will
To build GNU Make from Git on POSIX systems such as GNU/Linux, you will
need to install the following extra software:
* autoconf
* autoconf >= 2.69
* automake >= 1.16.1
* gettext
* autopoint
* pkg-config
* texinfo (for makeinfo)
* GCC (Clang's GCC emulation is not sufficient)
* GNU make (POSIX make is not sufficient)
* gettext
* pkg-config
* GCC
* GNU Make (POSIX make is not sufficient)
And any tools that those utilities require (GNU m4, Perl, etc.)
And any tools that those utilities require (GNU m4, etc.)
GNU make requires gnulib to provide some facilities. If you want to maintain
To run the tests you must install Perl.
To create dist files you will additionally need:
* lzip (to create tar.lz dist files)
* texlive (or some other TeX package)
GNU Make requires Gnulib to provide some facilities. If you want to maintain
a local installation of gnulib you can set GNULIB_SRCDIR to point to it.
Otherwise, ./bootstrap will obtain a clone for you.
Unfortunately due to issues with gnulib's getloadavg, you must have automake
1.16.1 or above. This version may not yet be available through GNU/Linux
package managers. If you need to install from source be sure to set
ACLOCAL_PATH to point to the pkg-config location (e.g., /usr/share/aclocal).
Due to issues with gnulib's getloadavg, you must have automake 1.16.1 or
above. This version may not yet be available through GNU/Linux package
managers. If you need to install from source be sure to set ACLOCAL_PATH to
point to the pkg-config location (e.g., /usr/share/aclocal).
If you want to build from Git with a non-GCC compiler, add "MAKE_CFLAGS=" to
your make command line (or at least remove any flags your compiler does not
@ -112,6 +126,16 @@ After checking out the code, you will need to run the bootstrap script:
$ ./bootstrap
Alternatively you can just pull content from remote locations with:
$ ./bootstrap --pull
And/or just re-generate auto-generatable files with:
$ ./bootstrap --gen
(Running ./bootstrap does both in one step.)
At this point you have successfully brought your Git copy of the GNU
make source directory up to the point where it can be treated
more-or-less like the official package you would get from ftp.gnu.org.
@ -120,10 +144,10 @@ That is, you can just run:
$ ./configure
$ make check
to build and test GNU make.
to build and test GNU Make.
NOTE! This method builds GNU make in "maintainer mode". Make programs built
in this mode it will be slower, possibly MUCH slower: there are various
NOTE! This method builds GNU Make in "maintainer mode". Make programs built
in this mode will be slower, possibly MUCH slower: there are various
sanity checks enabled. Further this mode assumes a modern GCC, GNU
libc, and well-formed system headers and enables a high level of
warnings AND enables -Werror to turn warnings into failures.
@ -131,7 +155,8 @@ NOTE! This method builds GNU make in "maintainer mode". Make programs built
If you want to build from Git with "maintainer mode" disabled, add
"MAKE_MAINTAINER_MODE=" to the make command line. If you want to turn
off the extra warning flags, add "MAKE_CFLAGS=" to the make command
line.
line. If you want to keep the warnings but not fail, add
"EXTRA_CFLAGS=-Wno-error" to the make command line.
For example:
$ ./configure
@ -142,40 +167,83 @@ NOTE! This method builds GNU make in "maintainer mode". Make programs built
Building From Git for Windows
-----------------------------
If you have a UNIX emulation like CYGWIN you can opt to run the general
build procedure above; it will work. Consult README.W32.template for
information on options you might want to use when running ./configure.
If you have a UNIX emulation like CYGWIN you can opt to run the general build
procedure above; it will work. Consult README.W32 for information on options
you might want to use when running ./configure.
If you can't or don't want to do that, then first run the .\bootstrap.bat
script to prime your Git workspace:
script to "prime" your Git workspace:
> .\bootstrap.bat
Next, rename the file README.W32.template to README.W32 and follow those
instructions.
Next, follow the instructions in the README.W32 file.
Note, neither of these methods are tested regularly by the GNU Make
maintainers. Building for Windows from a distribution tarball IS tested
regularly.
NOTE! "Maintainer mode" (see above) IS ENABLED when building from Git using
the build_w32.bat file.
Debugging and Testing
---------------------
These instructions have been tested on GNU systems. I have no idea if they
work on non-GNU systems (Windows, MacOS, etc.)
* Alternate Configurations:
The maintMakefile has a rule for running configure with various different
options, with and without packages. Run:
make check-alt-config
* Valgrind:
You can run all tests under valgrind by passing the -memcheck option:
(cd tests && ./run_make_tests -make ../make -memcheck)
Note, this is slow! Also some tests will fail because of invoking valgrind.
* ASAN:
You can build with ASAN and run tests, like this:
make clean
make -j8 CFLAGS='-ggdb3 -fsanitize=address' LDFLAGS='-ggdb3 -fsanitize=address'
Then to check for corruption only but not memory leaks run:
ASAN_OPTIONS='detect_stack_after_use_return=true:detect_leaks=false' make check
To check for leaks too run:
make check
Note that ASAN is reporting many more errors than valgrind. I don't know
which one is wrong: I haven't looked at them closely.
Creating a Package
------------------
Once you have performed the above steps (including the configuration and
build) you can create a GNU make package. This is very simple, just
build) you can create a GNU Make package. This is very simple, just
run:
$ make dist-gzip
and, if you like:
$ make dist-bzip2
$ make dist-lzip
Even better, you should run this:
$ make distcheck
Which will build both .gz and .bz2 package files, then unpack them into
a temporary location, try to build them, and repack them, verifying that
everything works, you get the same results, _and_ no extraneous files
are left over after the "distclean" rule.
Which will build both .gz and .lz package files, then unpack one into a
temporary location, try to build it and repack it, then verifying that
everything works, you get the same results, _and_ no extraneous files are
left over after the "distclean" rule.
This package can be unpacked and built to give a "normal" (non-maintainer
mode) result.
@ -191,38 +259,128 @@ consistent (that's why we don't finalize the Git tag, etc. until the end).
* Update the configure.ac file with the new release number.
* Update the EDITION value in the doc/make.texi file.
* Update the doc/make.1 file with the release date.
* Update the NEWS file with the release number and date.
* Ensure the Savannah bug list URL in the NEWS file uses the correct
"Fixed Release" ID number.
* Run "make distcheck" to be sure it all works.
* Run "make check-alt-config" to be sure alternative configurations work
* Run "make update-makeweb" to get a copy of the GNU make web pages
* Run "make update-gnuweb" to get a copy of the GNU website boilerplate pages
* Update the web page boilerplate if necessary:
../gnu-www/www/server/standards/patch-from-parent ../make-web/make.html \
../gnu-www/www/server/standards/boilerplate.html
* Run "make gendocs" (requires gnulib) to generate the manual files for
the GNU make web pages.
* Follow the directions from gendocs for the web page repository
* run "make tag-release" to create a Git tag for the release
* Push everything:
git push --tags origin master
Manage the Savannah project for GNU make:
The safest thing is to create an entirely new repository and build the final
package from there:
>>> This is only for real releases, not release candidate builds <<<
git clone git://git.savannah.gnu.org/make.git make-release
cd make-release
* In Savannah modify the "Value", "Rank", and "Description" values for the
current "SCM" entry in both "Component Version" and "Fix Release" fields
to refer to the new release. The "Rank" field should be 10 less than the
previous release so it orders properly.
* In Savannah create a new entry for the "Component Version" and "Fix
Release" fields:
If you don't want to create a new repository then run "git clean -fdx".
Then:
./bootstrap
./configure
make distcheck
Perform test builds on whichever systems you have access to.
Use a previous announcement as a template to create an announcement in a text
file then sign it with GPG:
gpg --clearsign <announcement.txt>
Or, use your mail client's PGP/GPG signing capabilities.
NOTE! In order to publish a package on the FSF FTP site you need to have my
GPG private key, and my passphrase to unlock it.
Depending on your distribution (whether GnuPG is integrated with your
keyring etc.) the upload operation will either pop up a window asking
for the GPG key passphrase one time, or else it will use the CLI to ask
for the GPG passphrase _THREE_ times. Sigh.
Publishing a Release Candidate
------------------------------
Usually I publish one or two release candidates for people to test before
making an official release. Release candidates use a GNU numbering scheme,
which add a ".9x" release number to the PREVIOUS major release. So the first
release candidate for GNU Make 4.4 would be GNU Make 4.3.90, the second
release candidate would be 4.3.91, etc.
Upload a release candidate using:
make upload-alpha
Announce a release candidate to these mailing lists:
To: bug-make@gnu.org
BCC: help-make@gnu.org, make-w32@gnu.org, make-alpha@gnu.org
You will have to approve the BCC's on the mailing list admin sites. Send
separate copies to (don't use CC as replies will go to these lists):
* coordinator@translationproject.org
* platform-testers@gnu.org
Publishing a Release
--------------------
When publishing a final release there are extra steps that need to be taken:
* Run "make update-makeweb" to get a copy of the GNU Make web pages
* Run "make update-gnuweb" to get a copy of the GNU website boilerplate pages
* Update the web page boilerplate if necessary:
( cd ~/src/make/make-web \
&& ~/src/gnu-www/www/server/standards/patch-from-parent \
make.html \
~/src/gnu-www/www/server/standards/boilerplate.html )
* Run "make gendocs" (requires gnulib) to generate the manual files for
the GNU Make web pages.
* Follow the directions from gendocs for the web page repository
Manage the Savannah project for GNU Make:
* In Savannah edit the "Component Version" field and choose the "SCM" entry.
Modify the "Value", "Rank", and "Description" values for the to refer to
the new release. The "Rank" field should be 10 less than the previous
release so it orders properly.
* In Savannah edit the "Fixed Release" field and choose the "SCM" entry.
Modify the "Value", "Rank", and "Description" values for the to refer to
the new release. The "Rank" field should be 10 less than the previous
release so it orders properly.
* In Savannah create a new entry for the "Component Version" field:
- Value: SCM
- Rank: 20
- Descr: Issues found in code retrieved from Source Code Management (Git), rather than a distributed version. Please include the SHA you are working with.
- Descr: Fixed in Source Code Management (Git). The fix will be included in the next release of GNU make.
* In Savannah create a new entry for the "Fix Release" field:
- Value: SCM
- Rank: 20
- Descr: Fixed in Source Code Management (Git). The fix will be included in the next release of GNU Make.
Upload a release using:
make upload-ftp
Announce a release to these mailing lists:
To: info-gnu@gnu.org, bug-make@gnu.org
BCC: help-make@gnu.org, make-w32@gnu.org, make-alpha@gnu.org
You will have to approve the BCC's on the mailing list admin sites. Send
separate copies to (don't use CC as replies will go to these lists):
* coordinator@translationproject.org
* platform-testers@gnu.org
Announce on Savannah:
* Add a news item to the Savannah project site.
Start the next release:
@ -231,71 +389,11 @@ Start the next release:
* Update the Savannah URL for the bugs fixed in the NEWS section.
Publishing a Package
--------------------
In order to publish a package on the FSF FTP site, either the release
site ftp://ftp.gnu.org, or the prerelease site ftp://alpha.gnu.org, you
first need to have my GPG private key and my passphrase to unlock it.
And, you can't have them! So there! But, just so I remember here's
what to do:
Make sure the "Steps to Release" are complete and committed and tagged.
git clone git://git.savannah.gnu.org/make.git make-release
cd make-release
<run the commands above to build the release>
make upload-alpha # for alpha.gnu.org (pre-releases)
-OR-
make upload-ftp # for ftp.gnu.org (official releases)
Depending on your distribution (whether GnuPG is integrated with your keyring
etc.) it will either pop up a window asking for your GPG key passphrase one
time, or else it will use the CLI to ask for the GPG passphrase _THREE_ times.
Sigh.
For both final releases and pre-releases, send an email with the URL of
the package to the GNU translation robot to allow the translators to
work on it:
<coordinator@translationproject.org>
Where to Announce
-----------------
Create the announcement in a text file, using 'git shortlog',
then sign it with GPG:
gpg --clearsign <announcement.txt>
Or, use your mail client's PGP/GPG signing capabilities.
Announce the release:
* For release candidate builds:
To: bug-make@gnu.org
CC: coordinator@translationproject.org
BCC: help-make@gnu.org, make-w32@gnu.org, make-alpha@gnu.org
* For release builds
To: info-gnu@gnu.org, bug-make@gnu.org
CC: coordinator@translationproject.org
BCC: help-make@gnu.org, make-w32@gnu.org, make-alpha@gnu.org
* Add a news item to the Savannah project site.
* Add an update to freecode.com (nee freshmeat.net)
Appendix A - For The Brave
--------------------------
For those of you who trust me implicitly, or are just brave (or
foolhardy), here is a canned sequence of commands to build a GNU make
foolhardy), here is a canned sequence of commands to build a GNU Make
distribution package from a virgin Git source checkout (assuming all the
prerequisites are available of course).
@ -306,6 +404,6 @@ For a debugging version:
./bootstrap && ./configure CFLAGS=-g && make check
For a release version
For an optimized version
./bootstrap && ./configure && make check

View File

@ -1,13 +1,17 @@
This directory contains the %VERSION% release of GNU Make.
This directory contains the @PACKAGE_VERSION@ release of @PACKAGE_NAME@.
See the file NEWS for the user-visible changes from previous releases.
In addition, there have been bugs fixed.
>> If you are trying to build GNU Make from a Git clone rather than a
>> downloaded source distribution, see the README.git file for instructions.
Please check the system-specific notes below for any caveats related to your
operating system.
If you are trying to build GNU make from a Git clone rather than a downloaded
source distribution, see the README.git file for instructions.
This README assumes you are building on a POSIX-based operating system.
For ports to other operating systems please see the system-specific README
files, as described in the "Ports" section below.
For source distribution building and installation instructions, see the file
INSTALL.
@ -15,12 +19,12 @@ INSTALL.
If you need to build GNU Make and have no other 'make' program to use, you can
use the shell script 'build.sh' instead. To do this, first run 'configure' as
described in INSTALL. Then, instead of typing 'make' to build the program,
type 'sh build.sh'. This should compile the program in the current directory.
Then you will have a Make program that you can use for './make install', or
type 'sh build.sh'. This will compile the program in the current directory.
Then you will have a 'make' program that you can use for './make install', or
whatever else.
Some systems' Make programs cannot process the Makefile for GNU Make. If you
get errors from your system's Make when building GNU Make, try using
Some systems' 'make' programs cannot process the Makefile for GNU Make.
If you get errors from your system's 'make' when building GNU Make, try using
'build.sh' instead.
@ -29,25 +33,26 @@ GNU Make is copyright by the Free Software Foundation. Copyright notices
condense sequential years into a range; e.g. "1987-1994" means all years
from 1987 to 1994 inclusive.
Downloading
-----------
GNU Make can be obtained in many different ways. See a description here:
http://www.gnu.org/software/software.html
https://www.gnu.org/software/software.html
Documentation
-------------
GNU make is fully documented in the GNU Make manual, which is contained
in this distribution as the file make.texinfo. You can also find
on-line and preformatted (PostScript and DVI) versions at the FSF's web
site. There is information there about ordering hardcopy documentation.
GNU Make is fully documented in the GNU Make manual, which is contained in
this distribution as the file make.texi. You can also find on-line and
preformatted (PostScript and DVI) versions at the FSF's web site. There is
information there about ordering hardcopy documentation.
http://www.gnu.org/
http://www.gnu.org/doc/doc.html
http://www.gnu.org/manual/manual.html
https://www.gnu.org/
https://www.gnu.org/doc/doc.html
https://www.gnu.org/manual/manual.html
Development
@ -56,49 +61,82 @@ Development
GNU Make development is hosted by Savannah, the FSF's online development
management tool. Savannah is here:
http://savannah.gnu.org
https://savannah.gnu.org
And the GNU Make development page is here:
http://savannah.gnu.org/projects/make/
https://savannah.gnu.org/projects/make/
You can find most information concerning the development of GNU Make at
this site.
Regression Tests
----------------
GNU Make contains a suite of regression tests. To run them use "make check"
after building GNU Make. If they fail a tar package will be created
containing useful information, which can be emailed (as an attachment) to
the <bug-make@gnu.org> mailing list.
Please note that since these tests rely on known-good-output comparisons,
they can show spurious failures on some systems (particularly non-POSIX systems
such as Windows).
Bug Reporting
-------------
You can send GNU make bug reports to <bug-make@gnu.org>. Please see the
section of the GNU make manual entitled 'Problems and Bugs' for
information on submitting useful and complete bug reports.
If you need help using GNU Make, try asking on <help-make@gnu.org>.
If you found a bug, you can send a bug reports to <bug-make@gnu.org>.
Please see the section of the GNU Make manual entitled 'Problems and Bugs'
for information on submitting useful and complete bug reports.
You do not need to subscribe to these lists first.
You can also use the online bug tracking system in the Savannah GNU Make
project to submit new problem reports or search for existing ones:
http://savannah.gnu.org/bugs/?group=make
https://savannah.gnu.org/bugs/?group=make
If you need help using GNU make, try these forums:
We prefer to use the bug tracking system ONLY for bugs or enhancements,
not for help requests: please use the mailing lists to get help.
help-make@gnu.org
help-utils@gnu.org
news:gnu.utils.help
news:gnu.utils.bug
Submitting Patches
------------------
If you'd like to propose a change to GNU Make, you can provide a patch with
your changes. If you are making your changes in a Git workspace you can run
"git format-patch" to create a patch file. If not, you can use the diff(1)
utility to create a patch file; please use "diff -u".
Once you have a patch you can submit it in any of these ways:
* Create a bug on Savannah and add the patch as an attachment:
https://savannah.gnu.org/bugs/?group=make&func=additem
* Send the patch via email to <bug-make@gnu.org>: be sure to add it as an
attachment to avoid interference by email processors.
All non-trivial changes require FSF copyright paperwork to be completed
before they can be accepted. Contact <bug-make@gnu.org> for help.
Git Access
----------
The GNU make source repository is available via Git from the GNU Savannah Git
The GNU Make source repository is available via Git from the GNU Savannah Git
server; look here for details:
http://savannah.gnu.org/git/?group=make
https://savannah.gnu.org/git/?group=make
Please note: you won't be able to build GNU make from Git without installing
Please note: you won't be able to build GNU Make from Git without installing
appropriate maintainer's tools, such as GNU m4, automake, autoconf, Perl, GNU
make, and GCC.
See the README.git file for instructions on how to build GNU make once these
See the README.git file for instructions on how to build GNU Make once these
tools are available. We make no guarantees about the contents or quality of
the latest code in the Git repository: it is not unheard of for code that is
known to be broken to be checked in. Use at your own risk.
@ -107,21 +145,11 @@ known to be broken to be checked in. Use at your own risk.
System-specific Notes
---------------------
It has been reported that the XLC 1.2 compiler on AIX 3.2 is buggy such
that if you compile make with 'cc -O' on AIX 3.2, it will not work
correctly. It is said that using 'cc' without '-O' does work.
The standard /bin/sh on SunOS 4.1.3_U1 and 4.1.4 is broken and cannot be
used to configure GNU make. Please install a different shell such as
bash or pdksh in order to run "configure". See this message for more
information:
http://mail.gnu.org/archive/html/bug-autoconf/2003-10/msg00190.html
One area that is often a problem in configuration and porting is the code
to check the system's current load average. To make it easier to test and
debug this code, you can do 'make check-loadavg' to see if it works
properly on your system. (You must run 'configure' beforehand, but you
need not build Make itself to run this test.)
need not build 'make' itself to run this test.)
Another potential source of porting problems is the support for large
files (LFS) in configure for those operating systems that provide it.
@ -130,7 +158,7 @@ difficulties, then as a workaround you should be able to disable LFS by
adding the '--disable-largefile' option to the 'configure' script.
On systems that support micro- and nano-second timestamp values and
where stat(2) provides this information, GNU make will use it when
where stat(2) provides this information, GNU Make will use it when
comparing timestamps to get the most accurate possible result. However,
note that many current implementations of tools that *set* timestamps do
not preserve micro- or nano-second granularity. This means that "cp -p"
@ -144,12 +172,12 @@ force make to treat them properly. See the manual for details.
Ports
-----
- See README.customs for details on integrating GNU make with the
- See README.customs for details on integrating GNU Make with the
Customs distributed build environment from the Pmake distribution.
- See README.VMS for details about GNU Make on OpenVMS.
- See README.Amiga for details about GNU Make on AmigaDOS.
- See README.zOS for details about GNU Make on z/OS.
- See README.W32 for details about GNU Make on Windows NT, 95, or 98.
@ -157,22 +185,22 @@ Ports
using DJGPP tools.
A precompiled binary of the MSDOS port of GNU Make is available as part
of DJGPP; see the WWW page http://www.delorie.com/djgpp/ for more
of DJGPP; see the WWW page https://www.delorie.com/djgpp/ for more
information.
The Cygwin project maintains its own port of GNU make. That port may have
The Cygwin project maintains its own port of GNU Make. That port may have
patches which are not present in this version. If you are using Cygwin
you should use their version of GNU make, and if you have questions about
you should use their version of GNU Make, and if you have questions about
it you should start by asking on those mailing lists and forums.
Please note there are two _separate_ ports of GNU make for Microsoft
systems: a native Windows tool built with (for example) MSVC or Cygwin,
and a DOS-based tool built with DJGPP. Please be sure you are looking
Please note there are two _separate_ ports of GNU Make for Microsoft
systems: a native Windows port built with (for example) MSVC or MinGW,
and a DOS-based port built with DJGPP. Please be sure you are looking
at the right README!
-------------------------------------------------------------------------------
Copyright (C) 1988-2019 Free Software Foundation, Inc.
Copyright (C) 1988-2024 Free Software Foundation, Inc.
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify it under the
@ -185,4 +213,4 @@ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
this program. If not, see <https://www.gnu.org/licenses/>.

83
README.zOS Normal file
View File

@ -0,0 +1,83 @@
-*-text-*-
GNU Make has been ported to z/OS, tested on z/OS V2R4.
PREREQUISITES
-------------
Building GNU Make requires certain tools be installed on your z/OS system.
These tools can be downloaded from: https://github.com/ZOSOpenTools
For detailed instructions on how to set up these tools, visit
https://zosopentools.github.io/meta/#/Guides/Pre-req
You will need curl, tar, and gzip to download and unpack the GNU Make release
package, but presumably you've already worked this out if you're reading this
document!
You will need the IBM C/C++ compiler. You can download a web deliverable
add-on feature to your XL C/C++ compiler here:
https://www-40.ibm.com/servers/resourcelink/svc00100.nsf/pages/xlCC++V241ForZOsV24
Alternatively, you can install and manage C/C++ for Open Enterprise Languages
on z/OS using RedHat OpenShift Container Platform and IBM Z and Cloud
Modernization Stack.
GNU Make has a dependency on the ZOSLIB library, which is documented here:
https://zosopentools.github.io/meta/#/Guides/Zoslib.
To obtain the latest release of zoslib, you can download it from here:
https://github.com/ZOSOpenTools/zoslibport/releases.
BUILDING
--------
If you are trying to build from a checked-out Git workspace, see README.git.
Before building GNU Make, you will need to ensure that the following
environment variables are set, to turn on z/OS enhanced ASCII support:
export _BPXK_AUTOCVT=ON
export _CEE_RUNOPTS="$_CEE_RUNOPTS FILETAG(AUTOCVT,AUTOTAG) POSIX(ON)"
export _TAG_REDIR_ERR=txt
export _TAG_REDIR_IN=txt
export _TAG_REDIR_OUT=txt
To ensure proper functioning of xlclang, set the following environment
variables before building:
export _CC_CCMODE=1
export _C89_CCMODE=1
export _CXX_CCMODE=1
Set PATH_TO_ZOSLIB to the location of your zoslib installation; e.g.:
PATH_TO_ZOSLIB=$HOME/zopen/prod/zoslib
Invoke ./configure as follows:
./configure \
CC=xlclang \
CPPFLAGS="-DNSIG=42 -D_XOPEN_SOURCE=600 -D_ALL_SOURCE -D_OPEN_SYS_FILE_EXT=1 -D_AE_BIMODAL=1 -D_ENHANCED_ASCII_EXT=0xFFFFFFF -DZOSLIB_OVERRIDE_CLIB=1" \
CFLAGS="-qascii -std=gnu11 -qnocsect -qenum=int -I$PATH_TO_ZOSLIB/include" \
LDFLAGS="-L$PATH_TO_ZOSLIB/lib" \
LIBS="-lzoslib $PATH_TO_ZOSLIB/lib/CXXRT64.x"
If you have an instance of make already available you can build with:
make
If not, you can build with:
./build.sh
TESTING
-------
To run the regression tests you'll need to install Perl and enable it.
Then you can run:
./make check
INSTALLING
----------
Copy the "make" program to wherever you want it to be installed, on your PATH.

View File

@ -1,13 +0,0 @@
ERRORREXX
OPTIMIZE
NOVERSION
OPTIMIZERTIME
OPTIMIZERALIAS
DEFINE HAVE_CONFIG_H
DEFINE INCLUDEDIR="include:"
DEFINE LIBDIR="lib:"
DEFINE NO_ALLOCA
DEFINE NO_ARCHIVES
IGNORE=161
IGNORE=100
STARTUP=cres

View File

@ -101,7 +101,7 @@ The Rest of the List
-------------------------------------------------------------------------------
Copyright (C) 1997-2019 Free Software Foundation, Inc.
Copyright (C) 1997-2024 Free Software Foundation, Inc.
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify it under the
@ -114,4 +114,4 @@ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
this program. If not, see <https://www.gnu.org/licenses/>.

39
autogen.sh Executable file
View File

@ -0,0 +1,39 @@
#!/bin/sh
# Convenience script for regenerating all autogeneratable files that are
# omitted from the version control repository. In particular, this script
# also regenerates all aclocal.m4, config.h.in, Makefile.in, configure files
# with new versions of autoconf or automake.
# Copyright (C) 2003-2024 Free Software Foundation, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# Originally written by Paul Eggert. The canonical version of this
# script is maintained as top/autogen.sh in gnulib. However, to be
# useful to your package, you should place a copy of it under version
# control in the top-level directory of your package. The intent is
# that all customization can be done with a bootstrap.conf file also
# maintained in your version control; gnulib comes with a template
# build-aux/bootstrap.conf to get you started.
#
# Alternatively, you can use an autogen.sh script that is specific
# to your package.
me="$0"
medir=`dirname "$me"`
# Read the function library and the configuration.
. "$medir"/bootstrap-funclib.sh
autogen "$@"

37
autopull.sh Executable file
View File

@ -0,0 +1,37 @@
#!/bin/sh
# Convenience script for fetching auxiliary files that are omitted from
# the version control repository of this package.
# Copyright (C) 2003-2024 Free Software Foundation, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# Originally written by Paul Eggert. The canonical version of this
# script is maintained as top/autopull.sh in gnulib. However, to be
# useful to your package, you should place a copy of it under version
# control in the top-level directory of your package. The intent is
# that all customization can be done with a bootstrap.conf file also
# maintained in your version control; gnulib comes with a template
# build-aux/bootstrap.conf to get you started.
#
# Alternatively, you can use an autopull.sh script that is specific
# to your package.
me="$0"
medir=`dirname "$me"`
# Read the function library and the configuration.
. "$medir"/bootstrap-funclib.sh
autopull "$@"

1111
bootstrap

File diff suppressed because it is too large Load Diff

1285
bootstrap-funclib.sh Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
@echo off
:: Copyright (C) 2018-2019 Free Software Foundation, Inc.
:: Copyright (C) 2018-2024 Free Software Foundation, Inc.
:: This file is part of GNU Make.
::
:: GNU Make is free software; you can redistribute it and/or modify it under
@ -13,22 +13,104 @@
:: more details.
::
:: You should have received a copy of the GNU General Public License along
:: with this program. If not, see <http://www.gnu.org/licenses/>.
:: with this program. If not, see <https://www.gnu.org/licenses/>.
setlocal
set "svurl=https://git.savannah.gnu.org/cgit"
set "gnuliburl=%svurl%/gnulib.git/plain"
where curl >nul 2>&1
if ERRORLEVEL 1 (
echo Cannot find curl: it must be installed for bootstrap
exit /b 1
)
where sed >nul 2>&1
if ERRORLEVEL 1 (
echo Cannot find sed: it must be installed for bootstrap
echo Hint: you can use the sed provided in the Git for Windows install
exit /b 1
)
if exist lib goto Downloads
mkdir lib
if ERRORLEVEL 1 exit /b 1
:Downloads
echo -- Downloading Gnulib modules
call :Download lib getloadavg.c
call :Download lib intprops.h
goto :Done
call :Download lib intprops-internal.h
echo -- Configuring the workspace
copy /Y gl\lib\*.* lib > nul
:: In general it's tricky to use special characters as arguments to a program
:: in Windows batch files; the quoting rules are obscure and have changed over
:: time which means older systems may behave differently. However, Windows
:: echo is a dumb program that just writes out its command line without much
:: interpreting: all we have to be careful of is ^ quoting. So, use echo
:: to create script files to use with sed -f rather than using sed -e.
:: Create a sed script to convert templates
if exist convert.sed del /Q convert.sed
echo s,@PACKAGE@,make,g > convert.sed
if ERRORLEVEL 1 goto Failed
echo s,@PACKAGE_BUGREPORT@,bug-make@gnu.org,g >> convert.sed
if ERRORLEVEL 1 goto Failed
echo s,@PACKAGE_NAME@,GNU Make,g >> convert.sed
if ERRORLEVEL 1 goto Failed
echo s,@PACKAGE_TARNAME@,make,g >> convert.sed
if ERRORLEVEL 1 goto Failed
echo s,@PACKAGE_URL@,https://www.gnu.org/software/make/,g >> convert.sed
echo s/^^AC_INIT^(\[GNU.Make\],\[\^([0-9.]*\^)\].*/s,@PACKAGE_VERSION@,\1,g/p > cac.sed
sed -n -f cac.sed configure.ac >> convert.sed
if ERRORLEVEL 1 goto Failed
:: Get the list of sources from Makefile.am
echo s,\\\n,,g > mam.sed
echo s,[ \t][ \t]*, ,g >> mam.sed
echo s, [^^ ]*\.h,,g >> mam.sed
echo s,src/,$^(src^),g >> mam.sed
echo s,lib/,$^(lib^),g >> mam.sed
echo s/^^\^([A-Za-z0-9]*\^)_SRCS *= *\^(.*\^)/s,%%\1_SOURCES%%,\2,/p > mam2.sed
sed -z -f mam.sed Makefile.am | sed -n -f mam2.sed >> convert.sed
if ERRORLEVEL 1 goto Failed
echo - Creating Basic.mk
sed -f convert.sed Basic.mk.template > Basic.mk
if ERRORLEVEL 1 goto Failed
echo - Creating src\mkconfig.h
sed -f convert.sed src\mkconfig.h.in > src\mkconfig.h
if ERRORLEVEL 1 goto Failed
echo - Creating src\gmk-default.h
echo static const char *const GUILE_module_defn = ^" \ > src\gmk-default.h
echo s/;.*// > gmk.sed
echo /^^[ \t]*$/d >> gmk.sed
echo s/"/\\"/g >> gmk.sed
echo s/$/ \\/ >> gmk.sed
sed -f gmk.sed src\gmk-default.scm >> src\gmk-default.h
if ERRORLEVEL 1 goto Failed
echo ^";>> src\gmk-default.h
:: These files would be created by bootstrap; they are not needed on Windows
:: but our makefile depends on them
echo >> lib\alloca.in.h
del /Q convert.sed cac.sed mam.sed mam2.sed gmk.sed
echo.
echo Done. Run build_w32.bat to build GNU Make.
goto :EOF
:Download
echo Downloading %1\%2
curl -sS -o %1\%2 "%gnuliburl%/%1/%2"
if exist "%1\%2" goto :EOF
echo - Downloading %1\%2
curl -sS -o "%1\%2" "%gnuliburl%/%1/%2"
if ERRORLEVEL 1 exit /b 1
goto :EOF
:Done
echo Done. Run buld_w32.bat to build GNU make.
goto :EOF
:Failed
echo *** Bootstrap failed.
echo Resolve the issue, or use the configured source in the release tarball
exit /b 1

View File

@ -1,6 +1,6 @@
# Bootstrap configuration. -*-shell-script-*-
# Copyright (C) 2018-2019 Free Software Foundation, Inc.
# Copyright (C) 2018-2024 Free Software Foundation, Inc.
# GNU Make is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
@ -18,6 +18,12 @@
# Allow bootstrap to know that this is not a package
checkout_only_file=README.git
# Choose a specific version of gnulib, when checking out
GNULIB_REVISION=stable-202407
# Always copy files rather than symlink
copy=true
# Additional xgettext options to use. Use "\\\newline" to break lines.
# Ensure that all our magical output macros are correctly marked as
# C (printf) format strings.
@ -36,12 +42,17 @@ vc_ignore=
# Build prerequisites
buildreq="\
autoconf 2.69
automake 1.16.1
autoconf 2.72
automake 1.16.5
"
gnulib_name=libgnu
gnulib_files=doc/make-stds.texi
gnulib_files="doc/make-stds.texi m4/sig_atomic_t.m4"
# Using the full strtoll module pulls in a lot of stuff. But, it's pretty
# simple to use just the base source file, so pull that. We'll use it in
# src/misc.c if strtoll() is not found.
gnulib_files="$gnulib_files lib/strtol.c"
gnulib_modules="\
alloca
@ -49,5 +60,6 @@ fdl
findprog-in
getloadavg
host-cpu-c-abi
strerror
make-glob"
largefile
make-glob
make-macros"

View File

@ -1,7 +1,7 @@
# Configuration for building GNU Make in the absence of any 'make' program.
# @configure_input@
# Copyright (C) 1993-2019 Free Software Foundation, Inc.
# Copyright (C) 1993-2024 Free Software Foundation, Inc.
# This file is part of GNU Make.
#
# GNU Make is free software; you can redistribute it and/or modify it under
@ -15,7 +15,7 @@
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
# this program. If not, see <https://www.gnu.org/licenses/>.
# See Makefile.in for comments describing these variables.

View File

@ -1,7 +1,7 @@
#!/bin/sh
# Shell script to build GNU Make in the absence of any 'make' program.
# Copyright (C) 1993-2019 Free Software Foundation, Inc.
# Copyright (C) 1993-2024 Free Software Foundation, Inc.
# This file is part of GNU Make.
#
# GNU Make is free software; you can redistribute it and/or modify it under
@ -15,11 +15,16 @@
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
# this program. If not, see <https://www.gnu.org/licenses/>.
# Get configure-generated values
. ./build.cfg
die () { echo "$*" 1>&2; exit 1; }
usage () { echo "$0 [-k]"; exit $1; }
keep_going=false
: ${OUTDIR:=.}
OUTLIB="$OUTDIR/lib"
@ -37,33 +42,41 @@ defines="-DLOCALEDIR=\"$localedir\" -DLIBDIR=\"$libdir\" -DINCLUDEDIR=\"$include
# Print the value to stdout.
get_mk_var ()
{
file=$1
var=$2
val=
v=$(sed -e :a -e '/\\$/N; s/\\\n//; ta' "$file" | sed -n "s=^ *$var *\= *==p")
v=$(sed -e :a -e '/\\$/N; s/\\\n//; ta' "$1" | sed -n "s=^ *$2 *\= *==p")
for w in $v; do
case $w in
(\$[\(\{]*[\)\}]) w=${w#\$[\(\{]}; w=$(get_mk_var "$file" "${w%[\)\}]}") ;;
(\$[\(\{]*[\)\}]) w=${w#\$[\(\{]}; (get_mk_var "$1" "${w%[\)\}]}") ;;
(*) echo "$w" ;;
esac
val="${val:+$val }$w"
done
printf '%s\n' "$val"
}
# Compile source files. Object files are put into $objs.
compile ()
{
success=true
objs=
for ofile in "$@"; do
# We should try to use a Makefile variable like libgnu_a_SOURCES or
# something but just hardcode it.
file="${ofile%.$OBJEXT}.c"
case $file in
(lib/libgnu_a-*.c) file="lib/${file#lib/libgnu_a-}" ;;
esac
echo "compiling $file..."
of="$OUTDIR/$ofile"
mkdir -p "${of%/*}"
$CC $cflags $CPPFLAGS $CFLAGS -c -o "$of" "$top_srcdir/$file"
mkdir -p "${of%/*}" || exit 1
if $CC $cflags $CPPFLAGS $CFLAGS -c -o "$of" "$top_srcdir/$file"; then
: worked
else
$keep_going || die "Compilation failed."
success=false
fi
objs="${objs:+$objs }$of"
done
$success
}
# Use config.status to convert a .in file. Output file is put into $out.
@ -75,10 +88,13 @@ convert ()
var="GENERATE_$(echo $base | tr 'a-z./+' A-Z__X)"
# Is this file disabled?
grep "${var}_FALSE\"]=\"\"" config.status >/dev/null && return
grep "${var}_FALSE\"]=\"\"" config.status >/dev/null && return 0
# If there's no .in file then no conversion needed
in="$top_srcdir/lib/$(echo ${base%.*}.in.${base##*.} | tr / _)"
test -f "$in" || return 0
# Not disabled, so create it
in="$top_srcdir/lib/$(echo ${base%.*}.in.${base##*.} | tr / _)"
out="$OUTLIB/$base"
mkdir -p "${out%/*}"
@ -103,7 +119,7 @@ convert ()
esac
fn="$top_srcdir/lib/${fn##*/}"
[ -f "$fn" ] || { echo "Missing file: $fn"; exit 1; }
test -f "$fn" || { echo "Missing file: $fn"; exit 1; }
sed "/definitions* of $inc/r $fn" "$int" > "${int}_"
int=${int}_
@ -122,28 +138,39 @@ done
# Get object files from the Makefile
OBJS=$(get_mk_var Makefile make_OBJECTS | sed "s=\$[\(\{]OBJEXT[\)\}]=$OBJEXT=g")
# Exit as soon as any command fails.
set -e
while test -n "$1"; do
case $1 in
(-k) keep_going=true; shift ;;
(--) shift; break ;;
(-[h?]) usage 0 ;;
(-*) echo "Unknown option: $1"; usage 1 ;;
esac
done
test -z "$1" || die "Unknown argument: $*"
# Generate gnulib header files that would normally be created by make
set -e
for b in $(get_mk_var lib/Makefile BUILT_SOURCES); do
convert $b
done
set +e
# Build the gnulib library
cflags="$DEFS -I$OUTLIB -Ilib -I$top_srcdir/lib -I$OUTDIR/src -Isrc -I$top_srcdir/src"
compile $LIBOBJS
compile $LIBOBJS || die "Compilation failed."
echo "creating libgnu.a..."
$AR $ARFLAGS "$OUTLIB"/libgnu.a $objs
$AR $ARFLAGS "$OUTLIB"/libgnu.a $objs || die "Archive of libgnu failed."
# Compile the source files into those objects.
cflags="$DEFS $defines -I$OUTDIR/src -Isrc -I$top_srcdir/src -I$OUTLIB -Ilib -I$top_srcdir/lib"
compile $OBJS
compile $OBJS || die "Compilation failed."
# Link all the objects together.
echo "linking make..."
$CC $CFLAGS $LDFLAGS -L"$OUTLIB" $objs -lgnu $LOADLIBES -o "$OUTDIR/makenew$EXEEXT"
mv -f "$OUTDIR/makenew$EXEEXT" "$OUTDIR/make$EXEEXT"
$CC $CFLAGS $LDFLAGS -L"$OUTLIB" -o "$OUTDIR/makenew$EXEEXT" $objs -lgnu $LOADLIBES || die "Link failed."
mv -f "$OUTDIR/makenew$EXEEXT" "$OUTDIR/make$EXEEXT" || exit 1
echo done.

183
build_w32.bat Executable file → Normal file
View File

@ -1,5 +1,5 @@
@echo off
:: Copyright (C) 1996-2019 Free Software Foundation, Inc.
:: Copyright (C) 1996-2024 Free Software Foundation, Inc.
:: This file is part of GNU Make.
::
:: GNU Make is free software; you can redistribute it and/or modify it under
@ -13,7 +13,7 @@
:: more details.
::
:: You should have received a copy of the GNU General Public License along
:: with this program. If not, see <http://www.gnu.org/licenses/>.
:: with this program. If not, see <https://www.gnu.org/licenses/>.
setlocal
if not "%RECURSEME%"=="%~0" (
@ -28,15 +28,18 @@ if "%1" == "-h" goto Usage
if "%1" == "--help" goto Usage
echo.
echo Creating GNU Make for Windows 9X/NT/2K/XP/Vista/7/8/10
echo Creating GNU Make for Windows 9X/NT/2K/XP/Vista/7/8/10/11
echo.
set MAKE=gnumake
set GUILE=Y
set COMPILER=cl.exe
set RC=rc.exe
set O=obj
set ARCH=x64
set DEBUG=N
set DIRENT=Y
set VERBOSE=N
if exist maintMakefile (
set MAINT=Y
@ -45,13 +48,20 @@ if exist maintMakefile (
)
:ParseSW
if "%1" == "--verbose" goto SetVerbose
if "%1" == "--debug" goto SetDebug
if "%1" == "--without-guile" goto NoGuile
if "%1" == "--x86" goto Set32Bit
if "%1" == "gcc" goto SetCC
if "%1" == "tcc" goto SetTCC
if "%1" == "" goto DoneSW
goto Usage
:SetVerbose
set VERBOSE=Y
shift
goto ParseSW
:SetDebug
set DEBUG=Y
echo - Building without compiler optimizations
@ -72,25 +82,35 @@ goto ParseSW
:SetCC
set COMPILER=gcc
set RC=windres
set O=o
echo - Building with GCC
shift
goto ParseSW
:SetTCC
set COMPILER=tcc
set RC=windres
set O=o
echo - Building with TinyC
shift
goto ParseSW
:DoneSW
if "%MAINT%" == "Y" echo - Enabling maintainer mode
if "%COMPILER%" == "gcc" goto FindGcc
if "%COMPILER%" == "tcc" goto FindTcc
:: Find a compiler. Visual Studio requires a lot of effort to locate :-/.
%COMPILER% >nul 2>&1
call %COMPILER% >nul 2>&1
if not ERRORLEVEL 1 goto FoundMSVC
:: Visual Studio 17 and above provides the "vswhere" tool
:: Visual Studio 15 2017 and above provides the "vswhere" tool
call :FindVswhere
if ERRORLEVEL 1 goto LegacyVS
for /f "tokens=* usebackq" %%i in (`%VSWHERE% -latest -property installationPath`) do (
for /f "tokens=* usebackq" %%i in (`"%VSWHERE%" -latest -property installationPath`) do (
set InstallPath=%%i
)
set "VSVARS=%InstallPath%\VC\Auxiliary\Build\vcvarsall.bat"
@ -165,25 +185,50 @@ if "%MAINT%" == "Y" set "OPTS=%OPTS% /D MAKE_MAINTAINER_MODE"
:: Show the compiler version that we found
:: Unfortunately this also shows a "usage" note; I can't find anything better.
echo.
%COMPILER%
goto Build
call %COMPILER%
goto FindRC
:FindGcc
set OUTDIR=.\GccRel
set LNKOUT=./GccRel
set OPTS=-O2
set DIRENT=N
if "%DEBUG%" == "Y" set OPTS=-O0
if "%DEBUG%" == "Y" set OUTDIR=.\GccDebug
if "%DEBUG%" == "Y" set LNKOUT=./GccDebug
if "%MAINT%" == "Y" set "OPTS=%OPTS% -DMAKE_MAINTAINER_MODE"
:: Show the compiler version that we found
echo.
%COMPILER% --version
if not ERRORLEVEL 1 goto Build
call %COMPILER% --version
if not ERRORLEVEL 1 goto FindRC
echo No %COMPILER% found.
exit 1
:FindTcc
set OUTDIR=.\TccRel
set LNKOUT=./TccRel
set OPTS=-O2
if "%DEBUG%" == "Y" set OPTS=-O0
if "%DEBUG%" == "Y" set OUTDIR=.\TccDebug
if "%DEBUG%" == "Y" set LNKOUT=./TccDebug
if "%MAINT%" == "Y" set "OPTS=%OPTS% -DMAKE_MAINTAINER_MODE"
:: Show the compiler version that we found
echo.
call %COMPILER% -v
if not ERRORLEVEL 1 goto FindRC
echo No %COMPILER% found.
exit 1
:FindRC
set HAVE_RC=Y
call where %RC% >nul 2>&1
if not ERRORLEVEL 1 goto Build
echo.
echo %RC% was not found. Building without UTF-8 resource.
set HAVE_RC=N
:Build
echo.
:: Clean the directory if it exists
if exist %OUTDIR%\nul rmdir /S /Q %OUTDIR%
@ -197,10 +242,11 @@ mkdir %OUTDIR%\lib
if "%GUILE%" == "Y" call :ChkGuile
if not exist src\config.h.W32 goto NotConfig
echo.
echo Compiling %OUTDIR% version
if exist src\config.h.W32.template call :ConfigSCM
copy src\config.h.W32 %OUTDIR%\src\config.h
copy lib\glob.in.h %OUTDIR%\lib\glob.h
@ -231,11 +277,13 @@ call :Compile src/read
call :Compile src/remake
call :Compile src/remote-stub
call :Compile src/rule
call :Compile src/shuffle
call :Compile src/signame
call :Compile src/strcache
call :Compile src/variable
call :Compile src/version
call :Compile src/vpath
call :Compile src/warning
call :Compile src/w32/pathstuff
call :Compile src/w32/w32os
call :Compile src/w32/compat/posixfcn
@ -246,7 +294,11 @@ call :Compile lib/fnmatch
call :Compile lib/glob
call :Compile lib/getloadavg
if not "%COMPILER%" == "gcc" call :Compile src\w32\compat\dirent
:: Compile dirent unless it is supported by compiler library (like with gcc).
if "%DIRENT%" == "Y" call :Compile src\w32\compat\dirent
:: Compile UTF-8 resource if a resource compiler is available.
if "%HAVE_RC%" == "Y" call :ResourceCompile src/w32/utf8
call :Link
@ -258,6 +310,7 @@ exit 1
:Success
echo %OUTDIR% build succeeded.
if exist Basic.mk copy /Y Basic.mk Makefile
if not exist tests\config-flags.pm copy /Y tests\config-flags.pm.W32 tests\config-flags.pm
call :Reset
goto :EOF
@ -266,23 +319,57 @@ goto :EOF
::
:Compile
if "%VERBOSE%" == "N" echo - Compiling %1.c
echo %LNKOUT%/%1.%O% >>%OUTDIR%\link.sc
set EXTRAS=
if "%2" == "GUILE" set "EXTRAS=%GUILECFLAGS%"
if exist "%OUTDIR%\%1.%O%" del "%OUTDIR%\%1.%O%"
if "%COMPILER%" == "gcc" goto GccCompile
if "%COMPILER%" == "tcc" goto TccCompile
:: MSVC Compile
echo on
%COMPILER% /nologo /MT /W4 /EHsc %OPTS% /I %OUTDIR%/src /I src /I %OUTDIR%/lib /I lib /I src/w32/include /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR%OUTDIR% /Fp%OUTDIR%\%MAKE%.pch /Fo%OUTDIR%\%1.%O% /Fd%OUTDIR%\%MAKE%.pdb %EXTRAS% /c %1.c
if "%VERBOSE%" == "Y" echo on
call %COMPILER% /nologo /MT /W4 /EHsc %OPTS% /I %OUTDIR%/src /I src /I %OUTDIR%/lib /I lib /I src/w32/include /D _CONSOLE /D HAVE_CONFIG_H /FR%OUTDIR% /Fp%OUTDIR%\%MAKE%.pch /Fo%OUTDIR%\%1.%O% /Fd%OUTDIR%\%MAKE%.pdb %EXTRAS% /c %1.c
@echo off
goto CompileDone
:GccCompile
:: GCC Compile
echo on
%COMPILER% -mthreads -Wall -std=gnu99 -gdwarf-2 -g3 %OPTS% -I%OUTDIR%/src -I./src -I%OUTDIR%/lib -I./lib -I./src/w32/include -DWINDOWS32 -DHAVE_CONFIG_H %EXTRAS% -o %OUTDIR%/%1.%O% -c %1.c
if "%VERBOSE%" == "Y" echo on
call %COMPILER% -mthreads -Wall -std=gnu99 -gdwarf-2 -g3 %OPTS% -I%OUTDIR%/src -I./src -I%OUTDIR%/lib -I./lib -I./src/w32/include -DHAVE_CONFIG_H %EXTRAS% -o %OUTDIR%/%1.%O% -c %1.c
@echo off
goto CompileDone
:TccCompile
:: TCC Compile
if "%VERBOSE%" == "Y" echo on
call %COMPILER% -mthreads -Wall -std=c11 %OPTS% -I%OUTDIR%/src -I./src -I%OUTDIR%/lib -I./lib -I./src/w32/include -D_cdecl= -D_MSC_VER -DHAVE_CONFIG_H %EXTRAS% -o %OUTDIR%/%1.%O% -c %1.c
@echo off
goto CompileDone
:ResourceCompile
if "%VERBOSE%" == "N" echo - Compiling %1.rc
echo %LNKOUT%/%1.%O% >>%OUTDIR%\link.sc
if exist "%OUTDIR%\%1.%O%" del "%OUTDIR%\%1.%O%"
if "%COMPILER%" == "gcc" goto GccResourceCompile
if "%COMPILER%" == "tcc" goto TccResourceCompile
:: MSVC Resource Compile
if "%VERBOSE%" == "Y" echo on
call %RC% /fo %OUTDIR%\%1.%O% %1.rc
@echo off
goto CompileDone
:GccResourceCompile
:: GCC Resource Compile
if "%VERBOSE%" == "Y" echo on
call %RC% -o %OUTDIR%/%1.%O% -i %1.rc
@echo off
goto CompileDone
:TccResourceCompile
:: TCC Resource Compile
goto GccResourceCompile
:CompileDone
if not exist "%OUTDIR%\%1.%O%" exit 1
@ -290,56 +377,57 @@ goto :EOF
:Link
echo.
echo Linking %LNKOUT%/%MAKE%.exe
echo - Linking %LNKOUT%/%MAKE%.exe
if "%COMPILER%" == "gcc" goto GccLink
if "%COMPILER%" == "tcc" goto TccLink
:: MSVC Link
echo %GUILELIBS% kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib >>%OUTDIR%\link.sc
echo on
link.exe /NOLOGO /SUBSYSTEM:console /PDB:%LNKOUT%\%MAKE%.pdb %LINKOPTS% /OUT:%LNKOUT%\%MAKE%.exe @%LNKOUT%\link.sc
if "%VERBOSE%" == "Y" echo on
call link.exe /NOLOGO /SUBSYSTEM:console /PDB:%LNKOUT%\%MAKE%.pdb %LINKOPTS% /OUT:%LNKOUT%\%MAKE%.exe @%LNKOUT%\link.sc
@echo off
goto :EOF
:GccLink
:: GCC Link
echo on
if "%VERBOSE%" == "Y" echo on
echo %GUILELIBS% -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32 >>%OUTDIR%\link.sc
%COMPILER% -mthreads -gdwarf-2 -g3 %OPTS% -o %LNKOUT%/%MAKE%.exe @%LNKOUT%/link.sc -Wl,--out-implib=%LNKOUT%/libgnumake-1.dll.a
call %COMPILER% -mthreads -gdwarf-2 -g3 %OPTS% -o %LNKOUT%/%MAKE%.exe @%LNKOUT%/link.sc -Wl,--out-implib=%LNKOUT%/libgnumake-1.dll.a
@echo off
goto :EOF
:ConfigSCM
echo Generating config from SCM templates
sed -n "s/^AC_INIT(\[GNU make\],\[\([^]]\+\)\].*/s,%%VERSION%%,\1,g/p" configure.ac > %OUTDIR%\src\config.h.W32.sed
echo s,%%PACKAGE%%,make,g >> %OUTDIR%\src\config.h.W32.sed
sed -f %OUTDIR%\src\config.h.W32.sed src\config.h.W32.template > src\config.h.W32
echo static const char *const GUILE_module_defn = ^" \ > src\gmk-default.h
sed -e "s/;.*//" -e "/^[ \t]*$/d" -e "s/\"/\\\\\"/g" -e "s/$/ \\\/" src\gmk-default.scm >> src\gmk-default.h
echo ^";>> src\gmk-default.h
:TccLink
:: TCC Link
if "%VERBOSE%" == "Y" echo on
echo %GUILELIBS% -lkernel32 -luser32 -lgdi32 -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lodbc32 -lodbccp32 >>%OUTDIR%\link.sc
call %COMPILER% -mthreads %OPTS% -o %LNKOUT%/%MAKE%.exe @%LNKOUT%/link.sc
@echo off
goto :EOF
:ChkGuile
:: Build with Guile is supported only on NT and later versions
if not "%OS%" == "Windows_NT" goto NoGuile
pkg-config --help > %OUTDIR%\guile.tmp 2> NUL
call pkg-config --help > %OUTDIR%\guile.tmp 2> NUL
if ERRORLEVEL 1 goto NoPkgCfg
echo Checking for Guile 2.0
set PKGMSC=
if not "%COMPILER%" == "gcc" set PKGMSC=--msvc-syntax
pkg-config --cflags --short-errors "guile-2.0" > %OUTDIR%\guile.tmp
if not ERRORLEVEL 1 set /P GUILECFLAGS= < %OUTDIR%\guile.tmp
pkg-config --libs --static --short-errors %PKGMSC% "guile-2.0" > %OUTDIR%\guile.tmp
if not ERRORLEVEL 1 set /P GUILELIBS= < %OUTDIR%\guile.tmp
echo Checking for Guile 2.0
call pkg-config --cflags --short-errors "guile-2.0" > %OUTDIR%\gl-c2.tmp 2> NUL
if not ERRORLEVEL 1 set /P GUILECFLAGS= < %OUTDIR%\gl-c2.tmp
call pkg-config --libs --static --short-errors %PKGMSC% "guile-2.0" > %OUTDIR%\gl-l2.tmp 2> NUL
if not ERRORLEVEL 1 set /P GUILELIBS= < %OUTDIR%\gl-l2.tmp
if not "%GUILECFLAGS%" == "" goto GuileDone
echo Checking for Guile 1.8
pkg-config --cflags --short-errors "guile-1.8" > %OUTDIR%\guile.tmp
if not ERRORLEVEL 1 set /P GUILECFLAGS= < %OUTDIR%\guile.tmp
call pkg-config --cflags --short-errors "guile-1.8" > %OUTDIR%\gl-c18.tmp 2> NUL
if not ERRORLEVEL 1 set /P GUILECFLAGS= < %OUTDIR%\gl-c18.tmp
pkg-config --libs --static --short-errors %PKGMSC% "guile-1.8" > %OUTDIR%\guile.tmp
if not ERRORLEVEL 1 set /P GUILELIBS= < %OUTDIR%\guile.tmp
call pkg-config --libs --static --short-errors %PKGMSC% "guile-1.8" > %OUTDIR%\gl-l18.tmp 2> NUL
if not ERRORLEVEL 1 set /P GUILELIBS= < %OUTDIR%\gl-l18.tmp
if not "%GUILECFLAGS%" == "" goto GuileDone
@ -358,10 +446,10 @@ goto :EOF
:FindVswhere
set VSWHERE=vswhere
%VSWHERE% -help >nul 2>&1
call "%VSWHERE%" -help >nul 2>&1
if not ERRORLEVEL 1 exit /b 0
set "VSWHERE=C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere"
%VSWHERE% -help >nul 2>&1
call "%VSWHERE%" -help >nul 2>&1
if ERRORLEVEL 1 exit /b 1
goto :EOF
@ -369,17 +457,26 @@ goto :EOF
if not exist "%VSVARS%" exit /b 1
call "%VSVARS%" %ARCH%
if ERRORLEVEL 1 exit /b 1
%COMPILER% >nul 2>&1
call %COMPILER% >nul 2>&1
if ERRORLEVEL 1 exit /b 1
goto :EOF
:NotConfig
echo.
echo *** This workspace is not configured.
echo Either retrieve the configured source in the release tarball
echo or, if building from Git, run the .\bootstrap.bat script first.
exit /b 1
:Usage
echo Usage: %0 [options] [gcc]
echo Usage: %0 [options] [gcc] OR [tcc]
echo Options:
echo. --without-guile Do not compile Guile support even if found
echo. --debug Make a Debug build--default is Release
echo. --x86 Make a 32bit binary--default is 64bit
echo. --help Display these instructions and exit
echo.
echo. "gcc" means compile with GCC, "tcc" means compile with Tiny C's TCC
goto :EOF
:Reset

View File

@ -1,5 +1,5 @@
@echo off
rem Copyright (C) 1998-2019 Free Software Foundation, Inc.
rem Copyright (C) 1998-2024 Free Software Foundation, Inc.
rem This file is part of GNU Make.
rem
rem GNU Make is free software; you can redistribute it and/or modify it under
@ -13,7 +13,7 @@ rem FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for.
rem more details.
rem
rem You should have received a copy of the GNU General Public License along
rem with this program. If not, see <http://www.gnu.org/licenses/>.
rem with this program. If not, see <https://www.gnu.org/licenses/>.
echo Building Make for MSDOS with DJGPP
@ -49,14 +49,15 @@ gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -O2 -g %XSRC%/s
gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -O2 -g %XSRC%/src/dir.c -o dir.o
gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -O2 -g %XSRC%/src/file.c -o file.o
gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -O2 -g %XSRC%/src/misc.c -o misc.o
gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -O2 -g %XSRC%/src/main.c -o main.o
gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -DINCLUDEDIR=\"c:/djgpp/include\" -O2 -g %XSRC%/src/read.c -o read.o
gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -DLIBDIR=\"c:/djgpp/lib\" -O2 -g %XSRC%/src/remake.c -o remake.o
gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -DLOCALEDIR=\"/dev/env/DJDIR/share/locale\" -O2 -g %XSRC%/src/main.c -o main.o
gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -DINCLUDEDIR=\"/dev/env/DJDIR/include\" -O2 -g %XSRC%/src/read.c -o read.o
gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -DLIBDIR=\"/dev/env/DJDIR/lib\" -O2 -g %XSRC%/src/remake.c -o remake.o
gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -O2 -g %XSRC%/src/rule.c -o rule.o
gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -O2 -g %XSRC%/src/implicit.c -o implicit.o
gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -O2 -g %XSRC%/src/default.c -o default.o
gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -O2 -g %XSRC%/src/variable.c -o variable.o
gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -O2 -g %XSRC%/src/expand.c -o eyxpand.o
gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -O2 -g %XSRC%/src/warning.c -o warning.o
gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -O2 -g %XSRC%/src/expand.c -o expand.o
gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -O2 -g %XSRC%/src/function.c -o function.o
gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -O2 -g %XSRC%/src/vpath.c -o vpath.o
gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -O2 -g %XSRC%/src/hash.c -o hash.o
@ -68,15 +69,17 @@ gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -O2 -g %XSRC%/s
gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -O2 -g %XSRC%/src/remote-stub.c -o remote-stub.o
gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -O2 -g %XSRC%/src/getopt.c -o getopt.o
gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -O2 -g %XSRC%/src/getopt1.c -o getopt1.o
gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -O2 -g %XSRC%/src/shuffle.c -o shuffle.o
gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -O2 -g %XSRC%/src/load.c -o load.o
gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -O2 -g %XSRC%/lib/glob.c -o lib/glob.o
gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -O2 -g %XSRC%/lib/fnmatch.c -o lib/fnmatch.o
@echo off
echo commands.o > respf.$$$
for %%f in (job output dir file misc main read remake rule implicit default variable) do echo %%f.o >> respf.$$$
for %%f in (expand function vpath hash strcache version ar arscan signame remote-stub getopt getopt1) do echo %%f.o >> respf.$$$
for %%f in (job output dir file misc main read remake rule implicit default variable warning load) do echo %%f.o >> respf.$$$
for %%f in (expand function vpath hash strcache version ar arscan signame remote-stub getopt getopt1 shuffle) do echo %%f.o >> respf.$$$
for %%f in (lib\glob lib\fnmatch) do echo %%f.o >> respf.$$$
rem gcc -c -I./src -I%XSRC% -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -O2 -g %XSRC%/guile.c -o guile.o
rem echo guile.o >> respf.$$$
gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -O2 -g %XSRC%/src/guile.c -o guile.o
echo guile.o >> respf.$$$
@echo Linking...
@echo on
gcc -o make.exe @respf.$$$
@ -84,7 +87,7 @@ gcc -o make.exe @respf.$$$
if not exist make.exe echo Make.exe build failed...
if exist make.exe echo make.exe is now built!
if exist make.exe del respf.$$$
if exist make.exe copy /Y Basic.mk Makefile
if exist make.exe copy /Y %XSRC%\Basic.mk Makefile
goto End
:SmallEnv

View File

@ -1,6 +1,6 @@
# Process this file with autoconf to produce a configure script.
#
# Copyright (C) 1993-2019 Free Software Foundation, Inc.
# Copyright (C) 1993-2024 Free Software Foundation, Inc.
# This file is part of GNU Make.
#
# GNU Make is free software; you can redistribute it and/or modify it under
@ -14,9 +14,9 @@
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
# this program. If not, see <https://www.gnu.org/licenses/>.
AC_INIT([GNU make],[4.2.91],[bug-make@gnu.org])
AC_INIT([GNU Make],[4.4.90],[bug-make@gnu.org])
AC_PREREQ([2.69])
@ -31,12 +31,14 @@ AC_CONFIG_LIBOBJ_DIR([lib])
# We have to enable "foreign" because ChangeLog is auto-generated
# Automake 1.15 and gnulib don't get along: gnulib has some strange error
# in the way it handles getloadavg.c which causes make distcheck to fail.
# http://lists.gnu.org/archive/html/bug-gnulib/2018-06/msg00024.html
# https://lists.gnu.org/archive/html/bug-gnulib/2018-06/msg00024.html
AM_INIT_AUTOMAKE([1.16.1 foreign -Werror -Wall])
# Checks for programs.
AC_USE_SYSTEM_EXTENSIONS
AC_PROG_CC
AC_PROG_CXX
AC_DEFINE_UNQUOTED(MAKE_CXX, ["$CXX"], [Default C++ compiler.])
# Configure gnulib
gl_EARLY
@ -51,42 +53,36 @@ AC_CHECK_PROG([PERL], [perl], [perl], [perl])
# Specialized system macros
AC_CANONICAL_HOST
AC_AIX
AC_ISC_POSIX
AC_MINIX
AC_C_BIGENDIAN
# Enable gettext, in "external" mode.
AM_GNU_GETTEXT_VERSION([0.19.4])
AM_GNU_GETTEXT([external])
# This test must come as early as possible after the compiler configuration
# tests, because the choice of the file model can (in principle) affect
# whether functions and headers are available, whether they work, etc.
AC_SYS_LARGEFILE
# Checks for libraries.
AC_SEARCH_LIBS([strerror],[cposix])
AC_SEARCH_LIBS([getpwnam], [sun])
# Checks for header files.
AC_HEADER_STDC
AC_HEADER_DIRENT
AC_HEADER_STAT
AC_HEADER_TIME
AC_CHECK_HEADERS([stdlib.h locale.h unistd.h limits.h fcntl.h string.h \
memory.h sys/param.h sys/resource.h sys/time.h sys/timeb.h \
sys/select.h sys/file.h spawn.h])
AC_CHECK_HEADERS([stdlib.h string.h strings.h locale.h unistd.h limits.h \
memory.h sys/param.h sys/resource.h sys/time.h sys/select.h \
sys/file.h fcntl.h spawn.h])
AM_PROG_CC_C_O
AC_C_CONST
AC_TYPE_SIGNAL
AC_TYPE_UID_T
AC_TYPE_PID_T
AC_TYPE_OFF_T
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_TYPE_INTMAX_T
AC_TYPE_UINTMAX_T
# Check for sig_atomic_t
gt_TYPE_SIG_ATOMIC_T
# Find out whether our struct stat returns nanosecond resolution timestamps.
AC_STRUCT_ST_MTIM_NSEC
@ -115,9 +111,6 @@ AS_IF([test "$make_cv_file_timestamp_hi_res" = yes],
])
])
# Check for DOS-style pathnames.
pds_AC_DOS_PATHS
# See if we have a standard version of gettimeofday(). Since actual
# implementations can differ, just make sure we have the most common
# one.
@ -127,8 +120,8 @@ AC_CACHE_CHECK([for standard gettimeofday], [ac_cv_func_gettimeofday],
int main ()
{
struct timeval t; t.tv_sec = -1; t.tv_usec = -1;
exit (gettimeofday (&t, 0) != 0
|| t.tv_sec < 0 || t.tv_usec < 0);
return gettimeofday (&t, 0) != 0
|| t.tv_sec < 0 || t.tv_usec < 0;
}]])],
[ac_cv_func_gettimeofday=yes],
[ac_cv_func_gettimeofday=no],
@ -138,10 +131,10 @@ AS_IF([test "$ac_cv_func_gettimeofday" = yes],
[Define to 1 if you have a standard gettimeofday function])
])
AC_CHECK_FUNCS([strdup strndup umask mkstemp mktemp fdopen \
dup dup2 getcwd realpath sigsetmask sigaction \
AC_CHECK_FUNCS([strtoll strdup strndup stpcpy memrchr mempcpy umask mkstemp \
mktemp fdopen dup dup2 getcwd realpath sigsetmask sigaction \
getgroups seteuid setegid setlinebuf setreuid setregid \
getrlimit setrlimit setvbuf pipe strsignal \
mkfifo getrlimit setrlimit setvbuf pipe strerror strsignal \
lstat readlink atexit isatty ttyname pselect posix_spawn \
posix_spawnattr_setsigmask])
@ -153,8 +146,6 @@ AC_CHECK_DECLS([bsd_signal], [], [], [[#define _GNU_SOURCE 1
AC_FUNC_FORK
AC_FUNC_SETVBUF_REVERSED
# Rumor has it that strcasecmp lives in -lresolv on some odd systems.
# It doesn't hurt much to use our own if we can't find it so I don't
# make the effort here.
@ -176,7 +167,7 @@ AC_ARG_WITH([guile], [AS_HELP_STRING([--with-guile],
PKG_PROG_PKG_CONFIG
AS_IF([test "x$with_guile" != xno],
[ guile_versions="2.2 2.0 1.8"
[ guile_versions="3.0 2.2 2.0 1.8"
guile_version=no
have_guile=no
AC_MSG_CHECKING([for GNU Guile])
@ -184,13 +175,43 @@ AS_IF([test "x$with_guile" != xno],
PKG_CHECK_EXISTS([guile-$v], [guile_version=$v; have_guile=yes; break], [])
done
AC_MSG_RESULT([$guile_version])
if test "$have_guile" = yes; then
PKG_CHECK_MODULES(GUILE, [guile-$guile_version])
AC_DEFINE([HAVE_GUILE], [1], [Embed GNU Guile support])
fi
AS_IF([test "$have_guile" = yes],
[ PKG_CHECK_MODULES(GUILE, [guile-$guile_version])
# Unfortunately pkg doesn't help in multi-arch environments where the
# package is installed for some architectures but not others; we need
# to try to link.
keep_CPPFLAGS="$CPPFLAGS"
keep_LIBS="$LIBS"
CPPFLAGS="$CPPFLAGS $GUILE_CFLAGS"
LIBS="$LIBS $GUILE_LIBS"
AC_CHECK_HEADER([libguile.h],
[have_guile=yes],
[have_guile=no],
[/* Avoid configuration error warnings. */])
AS_IF([test "$have_guile" = yes],
[ AC_MSG_CHECKING([whether we can link GNU Guile])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <libguile.h>
static void *
guile_init (void *arg)
{
(void) arg;
return 0;
}
]], [[
scm_with_guile (guile_init, 0);
]])],
[have_guile=yes],
[have_guile=no])
AC_MSG_RESULT([$have_guile])])
CPPFLAGS="$keep_CPPFLAGS"
LIBS="$keep_LIBS"
])
])
AM_CONDITIONAL([HAVE_GUILE], [test "$have_guile" = yes])
AS_IF([test "$have_guile" = yes],
[AC_DEFINE([HAVE_GUILE], [1], [Embed GNU Guile support])])
AM_CONDITIONAL([HAVE_GUILE], [test "$have_guile" = "yes"])
AC_CHECK_DECLS([sys_siglist, _sys_siglist, __sys_siglist], , ,
[AC_INCLUDES_DEFAULT
@ -243,8 +264,7 @@ AS_IF([test "$PATH_SEPARATOR" = ';'],
AC_SUBST([REMOTE]) REMOTE=stub
use_customs=false
AC_ARG_WITH([customs],
[AC_HELP_STRING([--with-customs=DIR],
[enable remote jobs via Customs--see README.customs])],
[AS_HELP_STRING([--with-customs=DIR],[enable remote jobs via Customs--see README.customs])],
[ AS_CASE([$withval], [n|no], [:],
[make_cppflags="$CPPFLAGS"
AS_CASE([$withval],
@ -267,14 +287,12 @@ AM_CONDITIONAL([USE_CUSTOMS], [test "$use_customs" = true])
# See if the user asked to handle case insensitive file systems.
AH_TEMPLATE([HAVE_CASE_INSENSITIVE_FS], [Use case insensitive file names])
AC_ARG_ENABLE([case-insensitive-file-system],
AC_HELP_STRING([--enable-case-insensitive-file-system],
[assume file systems are case insensitive]),
AS_HELP_STRING([--enable-case-insensitive-file-system],[assume file systems are case insensitive]),
[AS_IF([test "$enableval" = yes], [AC_DEFINE([HAVE_CASE_INSENSITIVE_FS])])])
# See if we can handle the job server feature, and if the user wants it.
AC_ARG_ENABLE([job-server],
AC_HELP_STRING([--disable-job-server],
[disallow recursive make communication during -jN]),
AS_HELP_STRING([--disable-job-server],[disallow recursive make communication during -jN]),
[make_cv_job_server="$enableval" user_job_server="$enableval"],
[make_cv_job_server="yes"])
@ -304,7 +322,7 @@ AS_CASE([$host_os], [os2*|mingw*], [make_cv_job_server=yes])
AS_CASE([/$make_cv_job_server/$user_job_server/],
[*/no/*], [: no jobserver],
[AC_DEFINE(MAKE_JOBSERVER, 1,
[Define to 1 to enable job server support in GNU make.])
[Define to 1 to enable job server support in GNU Make.])
])
# If dl*() functions are supported we can enable the load operation
@ -312,8 +330,7 @@ AC_CHECK_DECLS([dlopen, dlsym, dlerror], [], [],
[[#include <dlfcn.h>]])
AC_ARG_ENABLE([load],
AC_HELP_STRING([--disable-load],
[disable support for the 'load' operation]),
AS_HELP_STRING([--disable-load],[disable support for the 'load' operation]),
[make_cv_load="$enableval" user_load="$enableval"],
[make_cv_load="yes"])
@ -328,7 +345,7 @@ AS_IF([test "$make_cv_load" = yes], [
AS_CASE([/$make_cv_load/$user_load/],
[*/no/*], [make_cv_load=no],
[AC_DEFINE(MAKE_LOAD, 1,
[Define to 1 to enable 'load' support in GNU make.])
[Define to 1 to enable 'load' support in GNU Make.])
])
# If we want load support, we might need to link with export-dynamic.
@ -336,14 +353,14 @@ AS_CASE([/$make_cv_load/$user_load/],
# For example passing -rdynamic to the SunPRO linker gives a warning
# but succeeds and creates a shared object, not an executable!
AS_IF([test "$make_cv_load" = yes], [
AC_MSG_CHECKING([If the linker accepts -Wl,--export-dynamic])
AC_MSG_CHECKING([if the linker accepts -Wl,--export-dynamic])
old_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS -Wl,--export-dynamic"
AC_LINK_IFELSE([AC_LANG_SOURCE([int main(){}])],
[AC_MSG_RESULT([yes])
AC_SUBST([AM_LDFLAGS], [-Wl,--export-dynamic])],
[AC_MSG_RESULT([no])
AC_MSG_CHECKING([If the linker accepts -rdynamic])
AC_MSG_CHECKING([if the linker accepts -rdynamic])
LDFLAGS="$old_LDFLAGS -rdynamic"
AC_LINK_IFELSE([AC_LANG_SOURCE([int main(){}])],
[AC_MSG_RESULT([yes])
@ -363,15 +380,31 @@ AS_IF([test "$ac_cv_func_lstat" = yes && test "$ac_cv_func_readlink" = yes],
# Use posix_spawn if we have support and the user didn't disable it
AC_ARG_ENABLE([posix-spawn],
AC_HELP_STRING([--disable-posix-spawn],
[disable support for posix_spawn()]),
AS_HELP_STRING([--disable-posix-spawn],[disable support for posix_spawn()]),
[make_cv_posix_spawn="$enableval" user_posix_spawn="$enableval"],
[make_cv_posix_spawn="yes"])
AS_CASE([/$ac_cv_header_spawn/$ac_cv_func_posix_spawn/],
[*/no/*], [make_cv_posix_spawn=no])
AS_CASE([/$make_cv_posix_spawn/$user_posix_spawn/],
AS_IF([test "$make_cv_posix_spawn" = yes],
AC_CACHE_CHECK([for posix_spawn that fails synchronously],
[make_cv_synchronous_posix_spawn],
[make_cv_synchronous_posix_spawn=no
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <errno.h>
#include <spawn.h>
extern char **environ;
int main () {
char path[[]] = "./xxx-non-existent";
char *argv[[]] = {path, 0};
return posix_spawn (0, path, 0, 0, argv, environ) == ENOENT ? 0 : 1;
}]])],
[make_cv_synchronous_posix_spawn=yes],
[make_cv_synchronous_posix_spawn=no],
[make_cv_synchronous_posix_spawn="no (cross-compiling)"])]))
AS_CASE([/$user_posix_spawn/$make_cv_posix_spawn/$make_cv_synchronous_posix_spawn/],
[*/no/*], [make_cv_posix_spawn=no],
[AC_DEFINE(USE_POSIX_SPAWN, 1, [Define to 1 to use posix_spawn().])
])
@ -411,18 +444,31 @@ AC_SUBST([MAKE_HOST])
w32_target_env=no
AM_CONDITIONAL([WINDOWSENV], [false])
AM_CONDITIONAL([HAVE_WINDRES], [false])
AS_CASE([$host],
[*-*-mingw32],
[AM_CONDITIONAL([WINDOWSENV], [true])
w32_target_env=yes
AC_DEFINE([WINDOWS32], [1], [Use platform specific coding])
AC_DEFINE([HAVE_DOS_PATHS], [1], [Use platform specific coding])
AC_DEFINE([MK_OS_W32], [1], [Build for the Windows32 API.])
AC_DEFINE([HAVE_DOS_PATHS], [1], [Support DOS-style pathnames.])
# Windows host tools.
# If windres is available, make will use UTF-8.
AC_CHECK_TOOL([WINDRES], [windres], [:])
AM_CONDITIONAL([HAVE_WINDRES], [test "$WINDRES" != ':'])
])
AC_DEFINE_UNQUOTED([PATH_SEPARATOR_CHAR],['$PATH_SEPARATOR'],
[Define to the character that separates directories in PATH.])
AC_DEFINE_UNQUOTED([HAVE_DECL_GETLOADAVG],[$HAVE_DECL_GETLOADAVG],
[Define to 1 if you have the declaration of 'getloadavg'.])
# Remember that we ran configure to generate config.h
AC_DEFINE([MK_CONFIGURE], [1],
[Define to 1 if config.h is generated by running the configure script.])
# Include the Maintainer's Makefile section, if it's here.
MAINT_MAKEFILE=/dev/null
@ -434,6 +480,10 @@ AC_SUBST_FILE([MAINT_MAKEFILE])
# Allow building with dmalloc
AM_WITH_DMALLOC
# Add custom header to config.h
AH_BOTTOM([/* Include customized declarations. */
#include "../src/mkcustom.h"])
# Forcibly disable SET_MAKE. If it's set it breaks things like the test
# scripts, etc.
SET_MAKE=
@ -453,7 +503,7 @@ AS_CASE([$with_customs],
[ echo
echo "WARNING: '$with_customs/lib' does not appear to contain the"
echo " Customs library. You must build and install Customs"
echo " before compiling GNU make."
echo " before compiling GNU Make."
echo
])])
@ -461,7 +511,7 @@ AS_IF([test "x$has_wait_nohang" = xno],
[ echo
echo "WARNING: Your system has neither waitpid() nor wait3()."
echo " Without one of these, signal handling is unreliable."
echo " You should be aware that running GNU make with -j"
echo " You should be aware that running GNU Make with -j"
echo " could result in erratic behavior."
echo
])
@ -491,12 +541,20 @@ AS_IF([test "x$make_cv_posix_spawn" = xno && test "x$user_posix_spawn" = xyes],
echo
])
# autoconf initializes $prefix to NONE.
AM_CONDITIONAL([KNOWN_PREFIX],
[test "x$prefix" = xNONE -o "x$prefix" = x/usr/local \
-o "x$prefix" = x/usr/gnu -o "x$prefix" = x/usr])
# Specify what files are to be created.
AC_CONFIG_FILES([Makefile build.cfg lib/Makefile po/Makefile.in doc/Makefile \
tests/config-flags.pm])
AC_CONFIG_FILES([build.cfg tests/config-flags.pm \
Makefile lib/Makefile doc/Makefile po/Makefile.in])
# We don't need this: the standard automake output suffices for POSIX systems.
#mk/Posix.mk
# Put build.sh in the build directory so it's easy to find
AC_CONFIG_LINKS([build.sh:build.sh])
# OK, do it!
AC_OUTPUT

1
doc/.gitignore vendored
View File

@ -1,4 +1,5 @@
manual/
make.t2d/
make.t2p/
gendocs_template
fdl.texi

View File

@ -1,5 +1,5 @@
# -*-Makefile-*-, or close enough
# Copyright (C) 2000-2019 Free Software Foundation, Inc.
# Copyright (C) 2000-2024 Free Software Foundation, Inc.
# This file is part of GNU Make.
#
# GNU Make is free software; you can redistribute it and/or modify it under
@ -13,7 +13,7 @@
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
# this program. If not, see <https://www.gnu.org/licenses/>.
TEXI2HTML = texi2html
TEXI2HTML_FLAGS = -split_chapter

View File

@ -1,6 +1,6 @@
.TH MAKE 1 "28 February 2016" "GNU" "User Commands"
.TH MAKE 1 "26 May 2023" "GNU" "User Commands"
.SH NAME
make \- GNU make utility to maintain groups of programs
make \- GNU Make utility to maintain groups of programs
.SH SYNOPSIS
.B make
[\fIOPTION\fR]... [\fITARGET\fR]...
@ -26,9 +26,9 @@ To prepare to use
.BR make ,
you must write a file called the
.I makefile
that describes the relationships among files in your program, and the states
the commands for updating each file. In a program, typically the executable
file is updated from object files, which are in turn made by compiling source
that describes the relationships among files in your program, and provides
commands for updating each file. In a program, typically the executable file
is updated from object files, which are in turn made by compiling source
files.
.LP
Once a suitable makefile exists, each time you change some source files,
@ -48,10 +48,10 @@ files, it issues the commands recorded in the makefile.
.B make
executes commands in the
.I makefile
to update one or more target
.IR names ,
to update one or more
.IR targets ,
where
.I name
.I target
is typically a program.
If no
.B \-f
@ -76,9 +76,8 @@ listing, right near other important files such as
The first name checked,
.IR GNUmakefile ,
is not recommended for most makefiles. You should use this name if you have a
makefile that is specific to GNU
.BR make ,
and will not be understood by other versions of
makefile that is specific to GNU Make, and will not be understood by other
versions of
.BR make .
If
.I makefile
@ -130,21 +129,28 @@ are omitted, then the behavior is the same as if
.B \-d
was specified.
.I FLAGS
may be
.I a
may be any or all of the following names, comma- or space-separated. Only the
first character is significant: the rest may be omitted:
.I all
for all debugging output (same as using
.BR \-d ),
.I b
.I basic
for basic debugging,
.I v
.I verbose
for more verbose basic debugging,
.I i
for showing implicit rules,
.I j
for details on invocation of commands, and
.I m
for debugging while remaking makefiles. Use
.I n
.I implicit
for showing implicit rule search operations,
.I jobs
for details on invocation of commands,
.I makefile
for debugging while remaking makefiles,
.I print
shows all recipes that are run even if they are silent, and
.I why
shows the reason
.BR make
decided to rebuild each target. Use
.I none
to disable all previous debugging flags.
.TP 0.5i
\fB\-e\fR, \fB\-\-environment\-overrides\fR
@ -198,6 +204,16 @@ option is given without an argument,
.BR make
will not limit the number of jobs that can run simultaneously.
.TP 0.5i
\fB\--jobserver-style=\fR\fIstyle\fR
The style of jobserver to use. The
.I style
may be one of
.BR fifo ,
.BR pipe ,
or
.B sem
(Windows only).
.TP 0.5i
\fB\-k\fR, \fB\-\-keep\-going\fR
Continue as much as possible after an error.
While the target that failed, and those that depend on it, cannot
@ -254,10 +270,15 @@ reading the makefiles; then execute as usual or as otherwise
specified.
This also prints the version information given by the
.B \-v
switch (see below).
To print the data base without trying to remake any files, use
switch (see below). To print the built-in data base only, use
.IR "make \-p \-f/dev/null" .
.TP 0.5i
\fB\-\-print\-targets\fR
Print each target defined as a result of reading the makefiles, one target per
line, then exit with success. Implicit rule targets are not printed, nor are
special targets (target names that consist of "." followed by all upper-case
letters). No recipe commands are invoked and no makefiles are rebuilt.
.TP 0.5i
\fB\-q\fR, \fB\-\-question\fR
``Question mode''.
Do not run any commands, or print anything; just return an exit status
@ -312,6 +333,26 @@ Turn off
.BR \-w ,
even if it was turned on implicitly.
.TP 0.5i
.BI \-\-shuffle "[=MODE]"
Enable shuffling of goal and prerequisite ordering.
.I MODE
is one of
.I none
to disable shuffle mode,
.I random
to shuffle prerequisites in random order,
.I reverse
to consider prerequisites in reverse order, or an integer
.I <seed>
which enables
.I random
mode with a specific
.I seed
value. If
.I MODE
is omitted the default is
.IR random .
.TP 0.5i
\fB\-W\fR \fIfile\fR, \fB\-\-what\-if\fR=\fIfile\fR, \fB\-\-new\-file\fR=\fIfile\fR, \fB\-\-assume\-new\fR=\fIfile\fR
Pretend that the target
.I file
@ -328,12 +369,59 @@ command on the given file before running
except that the modification time is changed only in the imagination of
.BR make .
.TP 0.5i
\fB\-\-warn\fR[=\fIARG[\fR,\fIARG\fR]]
Control warning reporting for makefiles. This option can appear multiple times.
In case of conflicts, later settings override earlier settings.
.I ARG
can be an action; one of
.IR ignore ,
.IR warn ,
or
.I error
to set the default action for all warnings, or it can be a specific warning:
.I circular-dep
(finding a circular dependency),
.I invalid-ref
(referencing an invalid variable name),
.I invalid-var
(assigning to an invalid variable name),
or
.I undefined-var
(referencing an undefined variable). The behavior of each warning can be set
by adding
.BI : action
after the warning name. If an action is not specified the default is
.IR warn .
If no
.I ARG
is provided the action for all warnings is
.IR warn .
If no
.B \-\-warn
option is provided the default action for
.I invalid-var
and
.I invalid-ref
is
.I warn
and the default action for
.I undefined-var
is
.IR ignore .
.TP 0.5i
.B \-\-warn\-undefined\-variables
Warn when an undefined variable is referenced.
A deprecated alternative for
.BR \-\-warn=undefined-var .
.TP 0.5i
.B \-
This option alone (not as an argument to the
.B \-f
option) is ignored, unless a target named
.B \-
is defined in the makefile, in which case that target is added to the makefile
goals.
.SH "EXIT STATUS"
GNU
.B make
exits with a status of zero if all makefiles were successfully parsed
GNU Make exits with a status of zero if all makefiles were successfully parsed
and no targets that were built failed. A status of one will be returned
if the
.B \-q
@ -361,9 +449,9 @@ This manual page contributed by Dennis Morse of Stanford University.
Further updates contributed by Mike Frysinger. It has been reworked by Roland
McGrath. Maintained by Paul Smith.
.SH "COPYRIGHT"
Copyright \(co 1992-1993, 1996-2019 Free Software Foundation, Inc.
Copyright \(co 1992\(en1993, 1996\(en2024 Free Software Foundation, Inc.
This file is part of
.IR "GNU make" .
.IR "GNU Make" .
.LP
GNU Make is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
@ -376,4 +464,4 @@ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
.LP
You should have received a copy of the GNU General Public License along with
this program. If not, see
.IR http://www.gnu.org/licenses/ .
.IR https://www.gnu.org/licenses/ .

File diff suppressed because it is too large Load Diff

10
gl/.gitignore vendored Normal file
View File

@ -0,0 +1,10 @@
*~
#*
.#*
.*cache
*.diff
*.patch
*.orig
*.rej
*.out
*.log

65
gl/README Normal file
View File

@ -0,0 +1,65 @@
04 July 2022 -*-text-*-
The gnulib project provides a fantastic array of modules that can support both
POSIX and also extended features for GNU software.
Unfortunately using it in GNU make is problematic: GNU make is a foundational
utility (if you don't have a "make" program you pretty much can't build any
software), one of our goals in GNU make is to provide scripts (e.g.,
"build.sh") that will build GNU make without needing an instance of make.
Instead of running "./configure && make", you should be able to run
"./configure && ./build.sh" and get a build of GNU make as a result.
However, more and more gnulib modules are relying not on M4 macros and
the configure script to manage their configuration, but in addition special
makefile recipes that perform various post-configure operations. Since we
don't have an instance of "make", we cannot use these modules as-is.
There are various options we could choose for solving this:
- Avoid gnulib modules and write our own portability interfaces.
I really am not too excited about this.
- Give up on "build.sh" and require users to already have "make".
The argument here is that you must already have a compiler, and it couldn't
have been built without "make", and/or if you build it with a cross-compiler
then you should be able to use that cross-development environment to build
GNU make as well.
- Provide a "mini-make" with just enough functionality to support the gnulib
makefiles but no extra features, that didn't need any complex gnulib
modules. As with the first option, I'm not too excited about this.
Although arguably the second option is the sane one, I'm not really excited
about any of them for the time being. So I elected to try something between
the first and second options:
The gnulib-port Git branch will contain unmodified copies of gnulib modules
that we want to use with GNU make. From there, we merge them into the main
Git branch then modify / simplify them to avoid unnecessary extra modules and
allow "build.sh" to be used.
By keeping the unmodified versions on the gnulib-port branch, we enable Git
merge facilities to merge in new versions as follows:
* Check out the gnulib-port branch
* Update its content with any updates to gnulib modules. Something like:
(
cd gl \
&& find */. -type f \
| while read fn; do
test -f "$GNULIB_SRCDIR/$fn" && cp "$GNULIB_SRCDIR/$fn" "$fn"
done
)
* Commit the changes _without modification_
* Check out the main branch
* Run "git merge --no-ff gnulib-port" to merge in the changes
* Resolve any conflicts and commit the merge.
-- pds

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1991, 1992, 1993, 1996, 1997, 1998, 1999 Free Software
/* Copyright (C) 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2023 Free Software
Foundation, Inc.
This file is part of the GNU C Library.
@ -13,9 +13,8 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the Free
Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
USA. */
along with this library; see the file COPYING.LIB.
If not, see <https://www.gnu.org/licenses/>. */
#if HAVE_CONFIG_H
# include <config.h>
@ -128,48 +127,20 @@ extern char *getenv ();
extern int errno;
# endif
/* This function doesn't exist on most systems. */
# if !defined HAVE___STRCHRNUL && !defined _LIBC
static char *
__strchrnul (s, c)
const char *s;
int c;
{
char *result = strchr (s, c);
if (result == NULL)
result = strchr (s, '\0');
return result;
}
# endif
# ifndef internal_function
/* Inside GNU libc we mark some function in a special way. In other
environments simply ignore the marking. */
# define internal_function
# endif
/* Match STRING against the filename pattern PATTERN, returning zero if
it matches, nonzero if not. */
static int internal_fnmatch __P ((const char *pattern, const char *string,
int no_leading_period, int flags))
internal_function;
static int
internal_function
internal_fnmatch (pattern, string, no_leading_period, flags)
const char *pattern;
const char *string;
int no_leading_period;
int flags;
internal_fnmatch (const char *pattern, const char *string,
int no_leading_period, int flags)
{
register const char *p = pattern, *n = string;
register unsigned char c;
const char *p = pattern, *n = string;
unsigned char c;
/* Note that this evaluates C many times. */
# ifdef _LIBC
# define FOLD(c) ((flags & FNM_CASEFOLD) ? tolower (c) : (c))
# define FOLD(c) (unsigned char)((flags & FNM_CASEFOLD) ? tolower (c) : (c))
# else
# define FOLD(c) ((flags & FNM_CASEFOLD) && ISUPPER (c) ? tolower (c) : (c))
# define FOLD(c) (unsigned char)((flags & FNM_CASEFOLD) && ISUPPER (c) ? tolower (c) : (c))
# endif
while ((c = *p++) != '\0')
@ -237,7 +208,9 @@ internal_fnmatch (pattern, string, no_leading_period, flags)
{
const char *endp;
endp = __strchrnul (n, (flags & FNM_FILE_NAME) ? '/' : '\0');
endp = strchr (n, (flags & FNM_FILE_NAME) ? '/' : '\0');
if (endp == NULL)
endp = n + strlen (n);
if (c == '[')
{
@ -292,7 +265,7 @@ internal_fnmatch (pattern, string, no_leading_period, flags)
{
/* Nonzero if the sense of the character class is inverted. */
static int posixly_correct;
register int not;
int not;
char cold;
if (posixly_correct == 0)
@ -478,10 +451,7 @@ internal_fnmatch (pattern, string, no_leading_period, flags)
int
fnmatch (pattern, string, flags)
const char *pattern;
const char *string;
int flags;
fnmatch (const char *pattern, const char *string, int flags)
{
return internal_fnmatch (pattern, string, flags & FNM_PERIOD, flags);
}

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1991, 1992, 1993, 1996, 1997, 1998, 1999 Free Software
/* Copyright (C) 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2023 Free Software
Foundation, Inc.
This file is part of the GNU C Library.
@ -13,9 +13,8 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the Free
Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
USA. */
along with this library; see the file COPYING.LIB.
If not, see <https://www.gnu.org/licenses/>. */
#ifndef _FNMATCH_H
#define _FNMATCH_H 1
@ -24,27 +23,6 @@ USA. */
extern "C" {
#endif
#if defined __cplusplus || (defined __STDC__ && __STDC__) || defined WINDOWS32
# if !defined __GLIBC__
# undef __P
# define __P(protos) protos
# endif
#else /* Not C++ or ANSI C. */
# undef __P
# define __P(protos) ()
/* We can get away without defining `const' here only because in this file
it is used only inside the prototype for `fnmatch', which is elided in
non-ANSI C where `const' is problematical. */
#endif /* C++ or ANSI C. */
#ifndef const
# if (defined __STDC__ && __STDC__) || defined __cplusplus || defined WINDOWS32
# define __const const
# else
# define __const
# endif
#endif
/* We #undef these before defining them because some losing systems
(HP-UX A.08.07 for example) define these in <unistd.h>. */
#undef FNM_PATHNAME
@ -75,8 +53,7 @@ extern "C" {
/* Match NAME against the filename pattern PATTERN,
returning zero if it matches, FNM_NOMATCH if not. */
extern int fnmatch __P ((__const char *__pattern, __const char *__name,
int __flags));
extern int fnmatch (const char *pattern, const char *name, int flags);
#ifdef __cplusplus
}

View File

@ -1,5 +1,5 @@
/* Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999 Free
Software Foundation, Inc.
/* Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
2023 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
@ -12,9 +12,8 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the Free
Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
USA. */
along with this library; see the file COPYING.LIB.
If not, see <https://www.gnu.org/licenses/>. */
/* AIX requires this to be the first thing in the file. */
#if defined _AIX && !defined __GNUC__
@ -38,9 +37,6 @@ USA. */
/* #define NDEBUG 1 */
#include <assert.h>
#include <stdio.h> /* Needed on stupid SunOS for assert. */
/* Comment out all this code if we are using the GNU C Library, and are not
actually compiling the library itself. This code is part of the GNU C
Library, but also included in many other GNU distributions. Compiling
@ -50,7 +46,9 @@ USA. */
it is simpler to just do this in the source for each such file. */
#define GLOB_INTERFACE_VERSION 1
#if !defined _LIBC && defined __GNU_LIBRARY__ && __GNU_LIBRARY__ > 1
#if defined _LIBC
# define ELIDE_CODE
#elif defined __GNU_LIBRARY__ && __GNU_LIBRARY__ > 1
# include <gnu-versions.h>
# if _GNU_GLOB_INTERFACE_VERSION == GLOB_INTERFACE_VERSION
# define ELIDE_CODE
@ -63,7 +61,7 @@ USA. */
# include <stddef.h>
#endif
#if defined HAVE_UNISTD_H || defined _LIBC
#if defined HAVE_UNISTD_H
# include <unistd.h>
# ifndef POSIX
# ifdef _POSIX_VERSION
@ -72,7 +70,7 @@ USA. */
# endif
#endif
#if !defined _AMIGA && !defined VMS && !defined WINDOWS32
#if !defined _AMIGA && !MK_OS_VMS && !MK_OS_W32
# include <pwd.h>
#endif
@ -83,11 +81,6 @@ extern int errno;
# define __set_errno(val) errno = (val)
#endif
#ifndef NULL
# define NULL 0
#endif
#if defined HAVE_DIRENT_H || defined __GNU_LIBRARY__
# include <dirent.h>
# define NAMLEN(dirent) strlen((dirent)->d_name)
@ -108,7 +101,6 @@ extern int errno;
# endif /* HAVE_VMSDIR_H */
#endif
/* In GNU systems, <dirent.h> defines this macro for us. */
#ifdef _D_NAMLEN
# undef NAMLEN
@ -122,7 +114,7 @@ extern int errno;
#endif
#if (defined POSIX || defined WINDOWS32) && !defined __GNU_LIBRARY__
#if (defined POSIX || MK_OS_W32) && !defined __GNU_LIBRARY__
/* Posix does not require that the d_ino field be present, and some
systems do not provide it. */
# define REAL_DIR_ENTRY(dp) 1
@ -130,49 +122,10 @@ extern int errno;
# define REAL_DIR_ENTRY(dp) (dp->d_ino != 0)
#endif /* POSIX */
#if defined STDC_HEADERS || defined __GNU_LIBRARY__
# include <stdlib.h>
# include <string.h>
# define ANSI_STRING
#else /* No standard headers. */
#include <stdlib.h>
#include <string.h>
extern char *getenv ();
# ifdef HAVE_STRING_H
# include <string.h>
# define ANSI_STRING
# else
# include <strings.h>
# endif
# ifdef HAVE_MEMORY_H
# include <memory.h>
# endif
extern char *malloc (), *realloc ();
extern void free ();
extern void qsort ();
extern void abort (), exit ();
#endif /* Standard headers. */
#ifndef ANSI_STRING
# ifndef bzero
extern void bzero ();
# endif
# ifndef bcopy
extern void bcopy ();
# endif
# define memcpy(d, s, n) bcopy ((s), (d), (n))
# define strrchr rindex
/* memset is only used for zero here, but let's be paranoid. */
# define memset(s, better_be_zero, n) \
((void) ((better_be_zero) == 0 ? (bzero((s), (n)), 0) : (abort(), 0)))
#endif /* Not ANSI_STRING. */
#if !defined HAVE_STRCOLL && !defined _LIBC
#if !defined HAVE_STRCOLL
# define strcoll strcmp
#endif
@ -182,32 +135,6 @@ extern void bcopy ();
# define mempcpy(Dest, Src, Len) __mempcpy (Dest, Src, Len)
#endif
#if !defined __GNU_LIBRARY__ && !defined __DJGPP__
# ifdef __GNUC__
__inline
# endif
# ifndef __SASC
# ifdef WINDOWS32
static void *
my_realloc (void *p, unsigned int n)
# else
static char *
my_realloc (p, n)
char *p;
unsigned int n;
# endif
{
/* These casts are the for sake of the broken Ultrix compiler,
which warns of illegal pointer combinations otherwise. */
if (p == NULL)
return (char *) malloc (n);
return (char *) realloc (p, n);
}
# define realloc my_realloc
# endif /* __SASC */
#endif /* __GNU_LIBRARY__ || __DJGPP__ */
#if !defined __alloca && !defined __GNU_LIBRARY__
# ifdef __GNUC__
@ -218,18 +145,17 @@ my_realloc (p, n)
# include <alloca.h>
# else /* Not HAVE_ALLOCA_H. */
# ifndef _AIX
# ifdef WINDOWS32
# if MK_OS_W32
# include <malloc.h>
# else
extern char *alloca ();
# endif /* WINDOWS32 */
# endif /* MK_OS_W32 */
# endif /* Not _AIX. */
# endif /* sparc or HAVE_ALLOCA_H. */
# endif /* GCC. */
#endif
#ifndef __GNU_LIBRARY__
# define __stat stat
# ifdef STAT_MACROS_BROKEN
# undef S_ISDIR
# endif
@ -238,25 +164,6 @@ extern char *alloca ();
# endif
#endif
#ifdef _LIBC
# undef strdup
# define strdup(str) __strdup (str)
# define sysconf(id) __sysconf (id)
# define closedir(dir) __closedir (dir)
# define opendir(name) __opendir (name)
# define readdir(str) __readdir (str)
# define getpwnam_r(name, bufp, buf, len, res) \
__getpwnam_r (name, bufp, buf, len, res)
# ifndef __stat
# define __stat(fname, buf) __xstat (_STAT_VER, fname, buf)
# endif
#endif
#if !(defined STDC_HEADERS || defined __GNU_LIBRARY__)
# undef size_t
# define size_t unsigned int
#endif
/* Some system header files erroneously define these.
We want our own definitions from <fnmatch.h> to take precedence. */
#ifndef __GNU_LIBRARY__
@ -284,30 +191,26 @@ extern char *alloca ();
# define __alloca alloca
#endif
#if !defined __stat
# define __stat stat
#endif
#ifdef HAVE_GETLOGIN_R
extern int getlogin_r __P ((char *, size_t));
extern int getlogin_r (char *, size_t);
#else
extern char *getlogin __P ((void));
extern char *getlogin (void);
#endif
static
#if __GNUC__ - 0 >= 2
inline
#endif
const char *next_brace_sub __P ((const char *begin));
static int glob_in_dir __P ((const char *pattern, const char *directory,
int flags,
int (*errfunc) (const char *, int),
glob_t *pglob));
static int prefix_array __P ((const char *prefix, char **array, size_t n));
static int collated_compare __P ((const __ptr_t, const __ptr_t));
const char *next_brace_sub (const char *begin);
static int glob_in_dir (const char *pattern, const char *directory,
int flags,
int (*errfunc) (const char *, int),
glob_t *pglob);
static int prefix_array (const char *prefix, char **array, size_t n);
static int collated_compare (const void *, const void *);
#if !defined _LIBC || !defined NO_GLOB_PATTERN_P
int __glob_pattern_p __P ((const char *pattern, int quote));
#if !defined NO_GLOB_PATTERN_P
int __glob_pattern_p (const char *pattern, int quote);
#endif
/* Find the end of the sub-pattern in a brace expression. We define
@ -317,8 +220,7 @@ static
inline
#endif
const char *
next_brace_sub (begin)
const char *begin;
next_brace_sub (const char *begin)
{
unsigned int depth = 0;
const char *cp = begin;
@ -364,11 +266,8 @@ next_brace_sub (begin)
If memory cannot be allocated for PGLOB, GLOB_NOSPACE is returned.
Otherwise, `glob' returns zero. */
int
glob (pattern, flags, errfunc, pglob)
const char *pattern;
int flags;
int (*errfunc) __P ((const char *, int));
glob_t *pglob;
glob (const char *pattern, int flags,
int (*errfunc) (const char *, int), glob_t *pglob)
{
const char *filename;
const char *dirname;
@ -516,14 +415,14 @@ glob (pattern, flags, errfunc, pglob)
/* Find the filename. */
filename = strrchr (pattern, '/');
#if defined __MSDOS__ || defined WINDOWS32
#if MK_OS_DOS || MK_OS_W32
/* The case of "d:pattern". Since `:' is not allowed in
file names, we can safely assume that wherever it
happens in pattern, it signals the filename part. This
is so we could some day support patterns like "[a-z]:foo". */
if (filename == NULL)
filename = strchr (pattern, ':');
#endif /* __MSDOS__ || WINDOWS32 */
#endif /* MK_OS_DOS || MK_OS_W32 */
if (filename == NULL)
{
/* This can mean two things: a simple name or "~name". The later
@ -560,7 +459,7 @@ glob (pattern, flags, errfunc, pglob)
{
char *newp;
dirlen = filename - pattern;
#if defined __MSDOS__ || defined WINDOWS32
#if MK_OS_DOS || MK_OS_W32
if (*filename == ':'
|| (filename > pattern + 1 && filename[-1] == ':'))
{
@ -594,7 +493,7 @@ glob (pattern, flags, errfunc, pglob)
++filename;
if (filename[0] == '\0'
#if defined __MSDOS__ || defined WINDOWS32
#if MK_OS_DOS || MK_OS_W32
&& dirname[dirlen - 1] != ':'
&& (dirlen < 3 || dirname[dirlen - 2] != ':'
|| dirname[dirlen - 1] != '/')
@ -618,13 +517,13 @@ glob (pattern, flags, errfunc, pglob)
oldcount = pglob->gl_pathc;
#ifndef VMS
#if !MK_OS_VMS
if ((flags & (GLOB_TILDE|GLOB_TILDE_CHECK)) && dirname[0] == '~')
{
if (dirname[1] == '\0' || dirname[1] == '/')
{
/* Look up home directory. */
#ifdef VMS
#if MK_OS_VMS
/* This isn't obvious, RTLs of DECC and VAXC know about "HOME" */
const char *home_dir = getenv ("SYS$LOGIN");
#else
@ -634,11 +533,11 @@ glob (pattern, flags, errfunc, pglob)
if (home_dir == NULL || home_dir[0] == '\0')
home_dir = "SYS:";
# else
# ifdef WINDOWS32
# if MK_OS_W32
if (home_dir == NULL || home_dir[0] == '\0')
home_dir = "c:/users/default"; /* poor default */
# else
# ifdef VMS
# if MK_OS_VMS
/* Again, this isn't obvious, if "HOME" isn't known "SYS$LOGIN" should be set */
if (home_dir == NULL || home_dir[0] == '\0')
home_dir = "SYS$DISK:[]";
@ -647,7 +546,7 @@ glob (pattern, flags, errfunc, pglob)
{
int success;
char *name;
# if defined HAVE_GETLOGIN_R || defined _LIBC
# if defined HAVE_GETLOGIN_R
size_t buflen = sysconf (_SC_LOGIN_NAME_MAX) + 1;
if (buflen == 0)
@ -663,7 +562,7 @@ glob (pattern, flags, errfunc, pglob)
if (success)
{
struct passwd *p;
# if defined HAVE_GETPWNAM_R || defined _LIBC
# if defined HAVE_GETPWNAM_R
size_t pwbuflen = sysconf (_SC_GETPW_R_SIZE_MAX);
char *pwtmpbuf;
struct passwd pwbuf;
@ -701,8 +600,8 @@ glob (pattern, flags, errfunc, pglob)
else
home_dir = "~"; /* No luck. */
}
# endif /* VMS */
# endif /* WINDOWS32 */
# endif /* MK_OS_VMS */
# endif /* MK_OS_W32 */
# endif
/* Now construct the full directory. */
if (dirname[1] == '\0')
@ -722,7 +621,7 @@ glob (pattern, flags, errfunc, pglob)
dirname = newp;
}
}
# if !defined _AMIGA && !defined WINDOWS32 && !defined VMS
# if !defined _AMIGA && !MK_OS_W32 && !MK_OS_VMS
else
{
char *end_name = strchr (dirname, '/');
@ -748,7 +647,7 @@ glob (pattern, flags, errfunc, pglob)
/* Look up specific user's home directory. */
{
struct passwd *p;
# if defined HAVE_GETPWNAM_R || defined _LIBC
# if defined HAVE_GETPWNAM_R
size_t buflen = sysconf (_SC_GETPW_R_SIZE_MAX);
char *pwtmpbuf;
struct passwd pwbuf;
@ -802,9 +701,9 @@ glob (pattern, flags, errfunc, pglob)
home directory. */
return GLOB_NOMATCH;
}
# endif /* Not Amiga && not WINDOWS32 && not VMS. */
# endif /* Not Amiga && not MK_OS_W32 && not MK_OS_VMS. */
}
#endif /* Not VMS. */
#endif /* Not MK_OS_VMS. */
/* Now test whether we looked for "~" or "~NAME". In this case we
can give the answer now. */
@ -816,7 +715,7 @@ glob (pattern, flags, errfunc, pglob)
if ((flags & GLOB_NOCHECK)
|| (((flags & GLOB_ALTDIRFUNC)
? (*pglob->gl_stat) (dirname, &st)
: __stat (dirname, &st)) == 0
: stat (dirname, &st)) == 0
&& S_ISDIR (st.st_mode)))
{
pglob->gl_pathv
@ -833,7 +732,7 @@ glob (pattern, flags, errfunc, pglob)
while (pglob->gl_pathc < pglob->gl_offs)
pglob->gl_pathv[pglob->gl_pathc++] = NULL;
#if defined HAVE_STRDUP || defined _LIBC
#if defined HAVE_STRDUP
pglob->gl_pathv[pglob->gl_pathc] = strdup (dirname);
#else
{
@ -865,7 +764,7 @@ glob (pattern, flags, errfunc, pglob)
have to glob for the directory, and then glob for
the pattern in each directory found. */
glob_t dirs;
register size_t i;
size_t i;
status = glob (dirname,
((flags & (GLOB_ERR | GLOB_NOCHECK | GLOB_NOESCAPE))
@ -879,7 +778,7 @@ glob (pattern, flags, errfunc, pglob)
appending the results to PGLOB. */
for (i = 0; i < dirs.gl_pathc; ++i)
{
int old_pathc;
size_t old_pathc;
#ifdef SHELL
{
@ -962,7 +861,7 @@ glob (pattern, flags, errfunc, pglob)
/* First check whether this really is a directory. */
if (((flags & GLOB_ALTDIRFUNC)
? (*pglob->gl_stat) (dir, &st) : __stat (dir, &st)) != 0
? (*pglob->gl_stat) (dir, &st) : stat (dir, &st)) != 0
|| !S_ISDIR (st.st_mode))
/* No directory, ignore this entry. */
continue;
@ -1038,7 +937,7 @@ glob (pattern, flags, errfunc, pglob)
for (i = oldcount; i < pglob->gl_pathc; ++i)
if (((flags & GLOB_ALTDIRFUNC)
? (*pglob->gl_stat) (pglob->gl_pathv[i], &st)
: __stat (pglob->gl_pathv[i], &st)) == 0
: stat (pglob->gl_pathv[i], &st)) == 0
&& S_ISDIR (st.st_mode))
{
size_t len = strlen (pglob->gl_pathv[i]) + 2;
@ -1056,12 +955,12 @@ glob (pattern, flags, errfunc, pglob)
if (!(flags & GLOB_NOSORT))
{
/* Sort the vector. */
int non_sort = oldcount;
size_t non_sort = oldcount;
if ((flags & GLOB_DOOFFS) && pglob->gl_offs > oldcount)
non_sort = pglob->gl_offs;
qsort ((__ptr_t) &pglob->gl_pathv[non_sort],
qsort ((void *) &pglob->gl_pathv[non_sort],
pglob->gl_pathc - non_sort,
sizeof (char *), collated_compare);
}
@ -1072,25 +971,22 @@ glob (pattern, flags, errfunc, pglob)
/* Free storage allocated in PGLOB by a previous `glob' call. */
void
globfree (pglob)
register glob_t *pglob;
globfree (glob_t *pglob)
{
if (pglob->gl_pathv != NULL)
{
register size_t i;
size_t i;
for (i = 0; i < pglob->gl_pathc; ++i)
if (pglob->gl_pathv[i] != NULL)
free ((__ptr_t) pglob->gl_pathv[i]);
free ((__ptr_t) pglob->gl_pathv);
free (pglob->gl_pathv[i]);
free (pglob->gl_pathv);
}
}
/* Do a collated comparison of A and B. */
static int
collated_compare (a, b)
const __ptr_t a;
const __ptr_t b;
collated_compare (const void *a, const void *b)
{
const char *const s1 = *(const char *const * const) a;
const char *const s2 = *(const char *const * const) b;
@ -1110,15 +1006,12 @@ collated_compare (a, b)
A slash is inserted between DIRNAME and each elt of ARRAY,
unless DIRNAME is just "/". Each old element of ARRAY is freed. */
static int
prefix_array (dirname, array, n)
const char *dirname;
char **array;
size_t n;
prefix_array (const char *dirname, char **array, size_t n)
{
register size_t i;
size_t i;
size_t dirlen = strlen (dirname);
#if defined __MSDOS__ || defined WINDOWS32
int sep_char = '/';
#if MK_OS_DOS || MK_OS_W32
char sep_char = '/';
# define DIRSEP_CHAR sep_char
#else
# define DIRSEP_CHAR '/'
@ -1128,7 +1021,7 @@ prefix_array (dirname, array, n)
/* DIRNAME is just "/", so normal prepending would get us "//foo".
We want "/foo" instead, so don't prepend any chars from DIRNAME. */
dirlen = 0;
#if defined __MSDOS__ || defined WINDOWS32
#if MK_OS_DOS || MK_OS_W32
else if (dirlen > 1)
{
if (dirname[dirlen - 1] == '/' && dirname[dirlen - 2] == ':')
@ -1150,7 +1043,7 @@ prefix_array (dirname, array, n)
if (new == NULL)
{
while (i > 0)
free ((__ptr_t) array[--i]);
free (array[--i]);
return 1;
}
@ -1165,7 +1058,7 @@ prefix_array (dirname, array, n)
new[dirlen] = DIRSEP_CHAR;
memcpy (&new[dirlen + 1], array[i], eltlen);
#endif
free ((__ptr_t) array[i]);
free (array[i]);
array[i] = new;
}
@ -1174,15 +1067,13 @@ prefix_array (dirname, array, n)
/* We must not compile this function twice. */
#if !defined _LIBC || !defined NO_GLOB_PATTERN_P
#if !defined NO_GLOB_PATTERN_P
/* Return nonzero if PATTERN contains any metacharacters.
Metacharacters can be quoted with backslashes if QUOTE is nonzero. */
int
__glob_pattern_p (pattern, quote)
const char *pattern;
int quote;
__glob_pattern_p (const char *pattern, int quote)
{
register const char *p;
const char *p;
int open = 0;
for (p = pattern; *p != '\0'; ++p)
@ -1209,9 +1100,6 @@ __glob_pattern_p (pattern, quote)
return 0;
}
# ifdef _LIBC
weak_alias (__glob_pattern_p, glob_pattern_p)
# endif
#endif
@ -1220,14 +1108,10 @@ weak_alias (__glob_pattern_p, glob_pattern_p)
The GLOB_NOSORT bit in FLAGS is ignored. No sorting is ever done.
The GLOB_APPEND flag is assumed to be set (always appends). */
static int
glob_in_dir (pattern, directory, flags, errfunc, pglob)
const char *pattern;
const char *directory;
int flags;
int (*errfunc) __P ((const char *, int));
glob_t *pglob;
glob_in_dir (const char *pattern, const char *directory, int flags,
int (*errfunc) (const char *, int), glob_t *pglob)
{
__ptr_t stream = NULL;
void *stream = NULL;
struct globlink
{
@ -1239,7 +1123,7 @@ glob_in_dir (pattern, directory, flags, errfunc, pglob)
int meta;
int save;
#ifdef VMS
#if MK_OS_VMS
if (*directory == 0)
directory = "[]";
#endif
@ -1271,7 +1155,7 @@ glob_in_dir (pattern, directory, flags, errfunc, pglob)
# endif
if (((flags & GLOB_ALTDIRFUNC)
? (*pglob->gl_stat) (fullname, &st)
: __stat (fullname, &st)) == 0)
: stat (fullname, &st)) == 0)
/* We found this file to be existing. Now tell the rest
of the function to copy this name into the result. */
flags |= GLOB_NOCHECK;
@ -1298,7 +1182,7 @@ glob_in_dir (pattern, directory, flags, errfunc, pglob)
{
stream = ((flags & GLOB_ALTDIRFUNC)
? (*pglob->gl_opendir) (directory)
: (__ptr_t) opendir (directory));
: (void *) opendir (directory));
if (stream == NULL)
{
if (errno != ENOTDIR
@ -1350,10 +1234,9 @@ glob_in_dir (pattern, directory, flags, errfunc, pglob)
if (new->name == NULL)
goto memory_error;
#ifdef HAVE_MEMPCPY
*((char *) mempcpy ((__ptr_t) new->name, name, len))
= '\0';
*((char *) mempcpy (new->name, name, len)) = '\0';
#else
memcpy ((__ptr_t) new->name, name, len);
memcpy (new->name, name, len);
new->name[len] = '\0';
#endif
new->next = names;
@ -1428,7 +1311,7 @@ glob_in_dir (pattern, directory, flags, errfunc, pglob)
while (names != NULL)
{
if (names->name != NULL)
free ((__ptr_t) names->name);
free (names->name);
names = names->next;
}
return GLOB_NOSPACE;

View File

@ -1,5 +1,5 @@
/* Copyright (C) 1991, 1992, 1995, 1996, 1997, 1998 Free Software Foundation,
Inc.
/* Copyright (C) 1991, 1992, 1995, 1996, 1997, 1998, 2023 Free Software
Foundation, Inc.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
@ -12,67 +12,18 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the Free
Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
USA. */
along with this library; see the file COPYING.LIB.
If not, see <https://www.gnu.org/licenses/>. */
#ifndef _GLOB_H
#define _GLOB_H 1
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
#undef __ptr_t
#if defined __cplusplus || (defined __STDC__ && __STDC__) || defined WINDOWS32
# if !defined __GLIBC__
# undef __P
# undef __PMT
# define __P(protos) protos
# define __PMT(protos) protos
# if !defined __GNUC__ || __GNUC__ < 2
# undef __const
# define __const const
# endif
# endif
# define __ptr_t void *
#else /* Not C++ or ANSI C. */
# undef __P
# undef __PMT
# define __P(protos) ()
# define __PMT(protos) ()
# undef __const
# define __const
# define __ptr_t char *
#endif /* C++ or ANSI C. */
/* We need `size_t' for the following definitions. */
#ifndef __size_t
# if defined __FreeBSD__
# define __size_t size_t
# else
# if defined __GNUC__ && __GNUC__ >= 2
typedef __SIZE_TYPE__ __size_t;
# else
/* This is a guess. */
/*hb
* Conflicts with DECCs already defined type __size_t.
* Defining an own type with a name beginning with '__' is no good.
* Anyway if DECC is used and __SIZE_T is defined then __size_t is
* already defined (and I hope it's exactly the one we need here).
*/
# if !(defined __DECC && defined __SIZE_T)
typedef unsigned long int __size_t;
# endif
# endif
# endif
#else
/* The GNU CC stddef.h version defines __size_t as empty. We need a real
definition. */
# undef __size_t
# define __size_t size_t
#endif
/* Bits set in the FLAGS argument to `glob'. */
#define GLOB_ERR (1 << 0)/* Return on read errors. */
#define GLOB_MARK (1 << 1)/* Append a slash to each name. */
@ -115,26 +66,26 @@ typedef unsigned long int __size_t;
#endif
/* Structure describing a globbing run. */
#if !defined _AMIGA && !defined VMS /* Buggy compiler. */
#if !defined _AMIGA && !MK_OS_VMS /* Buggy compiler. */
struct stat;
#endif
typedef struct
{
__size_t gl_pathc; /* Count of paths matched by the pattern. */
size_t gl_pathc; /* Count of paths matched by the pattern. */
char **gl_pathv; /* List of matched pathnames. */
__size_t gl_offs; /* Slots to reserve in `gl_pathv'. */
size_t gl_offs; /* Slots to reserve in `gl_pathv'. */
int gl_flags; /* Set to FLAGS, maybe | GLOB_MAGCHAR. */
/* If the GLOB_ALTDIRFUNC flag is set, the following functions
are used instead of the normal file access functions. */
void (*gl_closedir) __PMT ((void *));
struct dirent *(*gl_readdir) __PMT ((void *));
__ptr_t (*gl_opendir) __PMT ((__const char *));
int (*gl_lstat) __PMT ((__const char *, struct stat *));
#if defined(VMS) && defined(__DECC) && !defined(_POSIX_C_SOURCE)
int (*gl_stat) __PMT ((__const char *, struct stat *, ...));
void (*gl_closedir) (void *);
struct dirent *(*gl_readdir) (void *);
void * (*gl_opendir) (const char *);
int (*gl_lstat) (const char *, struct stat *);
#if MK_OS_VMS && defined(__DECC) && !defined(_POSIX_C_SOURCE)
int (*gl_stat) (const char *, struct stat *, ...);
#else
int (*gl_stat) __PMT ((__const char *, struct stat *));
int (*gl_stat) (const char *, struct stat *);
#endif
} glob_t;
@ -142,18 +93,18 @@ typedef struct
struct stat64;
typedef struct
{
__size_t gl_pathc;
size_t gl_pathc;
char **gl_pathv;
__size_t gl_offs;
size_t gl_offs;
int gl_flags;
/* If the GLOB_ALTDIRFUNC flag is set, the following functions
are used instead of the normal file access functions. */
void (*gl_closedir) __PMT ((void *));
struct dirent64 *(*gl_readdir) __PMT ((void *));
__ptr_t (*gl_opendir) __PMT ((__const char *));
int (*gl_lstat) __PMT ((__const char *, struct stat64 *));
int (*gl_stat) __PMT ((__const char *, struct stat64 *));
void (*gl_closedir) (void *);
struct dirent64 *(*gl_readdir) (void *);
void * (*gl_opendir) (const char *);
int (*gl_lstat) (const char *, struct stat64 *);
int (*gl_stat) (const char *, struct stat64 *);
} glob64_t;
#endif
@ -162,11 +113,11 @@ typedef struct
# define globfree globfree64
#else
# ifdef _LARGEFILE64_SOURCE
extern int glob64 __P ((__const char *__pattern, int __flags,
int (*__errfunc) (__const char *, int),
glob64_t *__pglob));
extern int glob64 (const char *pattern, int flags,
int (*errfunc) (const char *, int),
glob64_t *pglob);
extern void globfree64 __P ((glob64_t *__pglob));
extern void globfree64 (glob64_t *pglob);
# endif
#endif
@ -179,18 +130,18 @@ extern void globfree64 __P ((glob64_t *__pglob));
If memory cannot be allocated for PGLOB, GLOB_NOSPACE is returned.
Otherwise, `glob' returns zero. */
#if _FILE_OFFSET_BITS != 64 || __GNUC__ < 2
extern int glob __P ((__const char *__pattern, int __flags,
int (*__errfunc) (__const char *, int),
glob_t *__pglob));
extern int glob (const char *pattern, int flags,
int (*errfunc) (const char *, int),
glob_t *pglob);
/* Free storage allocated in PGLOB by a previous `glob' call. */
extern void globfree __P ((glob_t *__pglob));
extern void globfree (glob_t *pglob);
#else
extern int glob __P ((__const char *__pattern, int __flags,
int (*__errfunc) (__const char *, int),
glob_t *__pglob)) __asm__ ("glob64");
extern int glob (const char *pattern, int flags,
int (*errfunc) (const char *, int),
glob_t *pglob) __asm__ ("glob64");
extern void globfree __P ((glob_t *__pglob)) __asm__ ("globfree64");
extern void globfree (glob_t *pglob) __asm__ ("globfree64");
#endif
@ -200,7 +151,7 @@ extern void globfree __P ((glob_t *__pglob)) __asm__ ("globfree64");
This function is not part of the interface specified by POSIX.2
but several programs want to use it. */
extern int glob_pattern_p __P ((__const char *__pattern, int __quote));
extern int glob_pattern_p (const char *pattern, int quote);
#endif
#ifdef __cplusplus

View File

@ -1,7 +1,7 @@
dnl acinclude.m4 -- Extra macros needed for GNU make.
dnl acinclude.m4 -- Extra macros needed for GNU Make.
dnl
dnl Automake will incorporate this into its generated aclocal.m4.
dnl Copyright (C) 1998-2019 Free Software Foundation, Inc.
dnl Copyright (C) 1998-2024 Free Software Foundation, Inc.
dnl This file is part of GNU Make.
dnl
dnl GNU Make is free software; you can redistribute it and/or modify it under
@ -15,7 +15,7 @@ dnl FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for.
dnl more details.
dnl
dnl You should have received a copy of the GNU General Public License along
dnl with this program. If not, see <http://www.gnu.org/licenses/>.
dnl with this program. If not, see <https://www.gnu.org/licenses/>.
dnl ---------------------------------------------------------------------------
dnl Got this from the lynx 2.8 distribution.
@ -43,8 +43,8 @@ AC_MSG_RESULT(working...)
cf_cv_netlibs=""
cf_test_netlibs=yes
AC_CHECK_FUNCS(gethostname,,[
CF_RECHECK_FUNC(gethostname,nsl,cf_cv_netlibs,[
CF_RECHECK_FUNC(gethostname,socket,cf_cv_netlibs)])])
CF_RECHECK_FUNC(gethostname,nsl,cf_cv_netlibs,[
CF_RECHECK_FUNC(gethostname,socket,cf_cv_netlibs)])])
#
# FIXME: sequent needs this library (i.e., -lsocket -linet -lnsl), but
# I don't know the entrypoints - 97/7/22 TD
@ -52,12 +52,12 @@ AC_CHECK_LIB(inet,main,cf_cv_netlibs="-linet $cf_cv_netlibs")
#
if test "$ac_cv_func_lsocket" != no ; then
AC_CHECK_FUNCS(socket,,[
CF_RECHECK_FUNC(socket,socket,cf_cv_netlibs,[
CF_RECHECK_FUNC(socket,bsd,cf_cv_netlibs)])])
CF_RECHECK_FUNC(socket,socket,cf_cv_netlibs,[
CF_RECHECK_FUNC(socket,bsd,cf_cv_netlibs)])])
fi
#
AC_CHECK_FUNCS(gethostbyname,,[
CF_RECHECK_FUNC(gethostbyname,nsl,cf_cv_netlibs)])
CF_RECHECK_FUNC(gethostbyname,nsl,cf_cv_netlibs)])
])
LIBS="$LIBS $cf_cv_netlibs"
test $cf_test_netlibs = no && echo "$cf_cv_netlibs" >&AC_FD_MSG
@ -77,14 +77,14 @@ dnl used (autoconf does not distinguish between a null token and one that is
dnl set to 'no').
AC_DEFUN([CF_RECHECK_FUNC],[
AC_CHECK_LIB($2,$1,[
CF_UPPER(cf_tr_func,$1)
AC_DEFINE_UNQUOTED(HAVE_$cf_tr_func,1,[Define if you have function $1])
ac_cv_func_$1=yes
$3="-l$2 [$]$3"],[
ac_cv_func_$1=unknown
unset ac_cv_func_$1 2>/dev/null
$4],
[[$]$3])
CF_UPPER(cf_tr_func,$1)
AC_DEFINE_UNQUOTED(HAVE_$cf_tr_func,1,[Define if you have function $1])
ac_cv_func_$1=yes
$3="-l$2 [$]$3"],[
ac_cv_func_$1=unknown
unset ac_cv_func_$1 2>/dev/null
$4],
[[$]$3])
])dnl
dnl ---------------------------------------------------------------------------
dnl Make an uppercase version of a variable
@ -118,7 +118,7 @@ AC_DEFUN([AC_STRUCT_ST_MTIM_NSEC],
CPPFLAGS="$ac_save_CPPFLAGS -DST_MTIM_NSEC=$ac_val"
AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/stat.h>
], [struct stat s; s.ST_MTIM_NSEC;],
], [struct stat s; s.ST_MTIM_NSEC;],
[ac_cv_struct_st_mtim_nsec=$ac_val; break])
done
CPPFLAGS="$ac_save_CPPFLAGS"
@ -126,7 +126,7 @@ AC_DEFUN([AC_STRUCT_ST_MTIM_NSEC],
if test $ac_cv_struct_st_mtim_nsec != no; then
AC_DEFINE_UNQUOTED([ST_MTIM_NSEC], [$ac_cv_struct_st_mtim_nsec],
[Define if struct stat contains a nanoseconds field])
[Define if struct stat contains a nanoseconds field])
fi
]
)

View File

@ -1,7 +1,7 @@
# Test if the system uses DOS-style pathnames (drive specs and backslashes)
# By Paul Smith <psmith@gnu.org>. Based on dos.m4 by Jim Meyering.
#
# Copyright (C) 1993-2019 Free Software Foundation, Inc.
# Copyright (C) 1993-2024 Free Software Foundation, Inc.
# This file is part of GNU Make.
#
# GNU Make is free software; you can redistribute it and/or modify it under
@ -15,7 +15,7 @@
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
# this program. If not, see <https://www.gnu.org/licenses/>.
AC_DEFUN([pds_AC_DOS_PATHS], [
AC_CACHE_CHECK([whether system uses MSDOS-style paths], [ac_cv_dos_paths], [

216
gl/m4/getloadavg.m4 Normal file
View File

@ -0,0 +1,216 @@
# Check for getloadavg.
# Copyright (C) 1992-1996, 1999-2000, 2002-2003, 2006, 2008-2024 Free
# Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
#serial 10
# Autoconf defines AC_FUNC_GETLOADAVG, but that is obsolescent.
# New applications should use gl_GETLOADAVG instead.
# gl_GETLOADAVG
# -------------
AC_DEFUN([gl_GETLOADAVG],
[AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
# Persuade glibc <stdlib.h> to declare getloadavg().
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
gl_save_LIBS=$LIBS
# getloadavg is present in libc on glibc >= 2.2, Mac OS X, FreeBSD >= 2.0,
# NetBSD >= 0.9, OpenBSD >= 2.0, Solaris >= 7.
HAVE_GETLOADAVG=1
AC_CHECK_FUNC([getloadavg], [],
[gl_func_getloadavg_done=no
# Some systems with -lutil have (and need) -lkvm as well, some do not.
# On Solaris, -lkvm requires nlist from -lelf, so check that first
# to get the right answer into the cache.
# For kstat on solaris, we need to test for libelf and libkvm to force the
# definition of SVR4 below.
if test $gl_func_getloadavg_done = no; then
AC_CHECK_LIB([elf], [elf_begin], [LIBS="-lelf $LIBS"])
AC_CHECK_LIB([kvm], [kvm_open], [LIBS="-lkvm $LIBS"])
# Check for the 4.4BSD definition of getloadavg.
AC_CHECK_LIB([util], [getloadavg],
[LIBS="-lutil $LIBS" gl_func_getloadavg_done=yes])
fi
if test $gl_func_getloadavg_done = no; then
# There is a commonly available library for RS/6000 AIX.
# Since it is not a standard part of AIX, it might be installed locally.
gl_getloadavg_LIBS=$LIBS
if test $cross_compiling != yes; then
LIBS="-L/usr/local/lib $LIBS"
fi
AC_CHECK_LIB([getloadavg], [getloadavg],
[LIBS="-lgetloadavg $LIBS" gl_func_getloadavg_done=yes],
[LIBS=$gl_getloadavg_LIBS])
fi
# Set up the replacement function if necessary.
if test $gl_func_getloadavg_done = no; then
HAVE_GETLOADAVG=0
# Solaris has libkstat which does not require root.
AC_CHECK_LIB([kstat], [kstat_open])
test $ac_cv_lib_kstat_kstat_open = yes && gl_func_getloadavg_done=yes
# AIX has libperfstat which does not require root
if test $gl_func_getloadavg_done = no; then
AC_CHECK_LIB([perfstat], [perfstat_cpu_total])
test $ac_cv_lib_perfstat_perfstat_cpu_total = yes && gl_func_getloadavg_done=yes
fi
if test $gl_func_getloadavg_done = no; then
AC_CHECK_HEADER([sys/dg_sys_info.h],
[gl_func_getloadavg_done=yes
AC_DEFINE([DGUX], [1], [Define to 1 for DGUX with <sys/dg_sys_info.h>.])
AC_CHECK_LIB([dgc], [dg_sys_info])])
fi
fi])
if test "x$gl_save_LIBS" = x; then
GETLOADAVG_LIBS=$LIBS
else
GETLOADAVG_LIBS=`echo "$LIBS" | sed "s!$gl_save_LIBS!!"`
fi
LIBS=$gl_save_LIBS
AC_SUBST([GETLOADAVG_LIBS])dnl
# Test whether the system declares getloadavg. Solaris has the function
# but declares it in <sys/loadavg.h>, not <stdlib.h>.
AC_CHECK_HEADERS([sys/loadavg.h])
if test $ac_cv_header_sys_loadavg_h = yes; then
HAVE_SYS_LOADAVG_H=1
else
HAVE_SYS_LOADAVG_H=0
fi
AC_CHECK_DECL([getloadavg], [], [HAVE_DECL_GETLOADAVG=0],
[[#if HAVE_SYS_LOADAVG_H
/* OpenIndiana has a bug: <sys/time.h> must be included before
<sys/loadavg.h>. */
# include <sys/time.h>
# include <sys/loadavg.h>
#endif
#include <stdlib.h>]])
])# gl_GETLOADAVG
# gl_PREREQ_GETLOADAVG
# --------------------
# Set up the AC_LIBOBJ replacement of 'getloadavg'.
AC_DEFUN([gl_PREREQ_GETLOADAVG],
[
# Figure out what our getloadavg.c needs.
AC_CHECK_HEADERS_ONCE([sys/param.h unistd.h])
# On HPUX9, an unprivileged user can get load averages this way.
if test $gl_func_getloadavg_done = no; then
AC_CHECK_FUNCS([pstat_getdynamic], [gl_func_getloadavg_done=yes])
fi
# We cannot check for <dwarf.h>, because Solaris 2 does not use dwarf (it
# uses stabs), but it is still SVR4. We cannot check for <elf.h> because
# Irix 4.0.5F has the header but not the library.
if test $gl_func_getloadavg_done = no && test "$ac_cv_lib_elf_elf_begin" = yes \
&& test "$ac_cv_lib_kvm_kvm_open" = yes; then
gl_func_getloadavg_done=yes
AC_DEFINE([SVR4], [1], [Define to 1 on System V Release 4.])
fi
if test $gl_func_getloadavg_done = no; then
AC_CHECK_HEADER([inq_stats/cpustats.h],
[gl_func_getloadavg_done=yes
AC_DEFINE([UMAX], [1], [Define to 1 for Encore UMAX.])
AC_DEFINE([UMAX4_3], [1],
[Define to 1 for Encore UMAX 4.3 that has <inq_status/cpustats.h>
instead of <sys/cpustats.h>.])])
fi
if test $gl_func_getloadavg_done = no; then
AC_CHECK_HEADER([sys/cpustats.h],
[gl_func_getloadavg_done=yes; AC_DEFINE([UMAX])])
fi
if test $gl_func_getloadavg_done = no; then
AC_CHECK_HEADERS([mach/mach.h])
fi
AC_CHECK_HEADERS([nlist.h],
[AC_CHECK_MEMBERS([struct nlist.n_un.n_name],
[], [],
[#include <nlist.h>])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <nlist.h>]],
[[struct nlist x;
#ifdef HAVE_STRUCT_NLIST_N_UN_N_NAME
x.n_un.n_name = "";
#else
x.n_name = "";
#endif]])],
[AC_DEFINE([N_NAME_POINTER], [1],
[Define to 1 if the nlist n_name member is a pointer])])
])dnl
])# gl_PREREQ_GETLOADAVG
# ---- GNU Make
# These macros are imported from stdlib which we don't want to include
# Only the getloadavg content is imported.
AC_DEFUN_ONCE([gl_STDLIB_H],
[
AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
dnl Check for declarations of anything we want to poison if the
dnl corresponding gnulib module is not in use, and which is not
dnl guaranteed by C89.
gl_WARN_ON_USE_PREPARE([[#include <stdlib.h>
#if HAVE_SYS_LOADAVG_H
/* OpenIndiana has a bug: <sys/time.h> must be included before
<sys/loadavg.h>. */
# include <sys/time.h>
# include <sys/loadavg.h>
#endif
#if HAVE_RANDOM_H
# include <random.h>
#endif
]], [getloadavg])
])
# gl_STDLIB_MODULE_INDICATOR([modulename])
# sets the shell variable that indicates the presence of the given module
# to a C preprocessor expression that will evaluate to 1.
# This macro invocation must not occur in macros that are AC_REQUIREd.
AC_DEFUN([gl_STDLIB_MODULE_INDICATOR],
[
dnl Ensure to expand the default settings once only.
gl_STDLIB_H_REQUIRE_DEFAULTS
gl_MODULE_INDICATOR_SET_VARIABLE([$1])
dnl Define it also as a C macro, for the benefit of the unit tests.
gl_MODULE_INDICATOR_FOR_TESTS([$1])
])
# Initializes the default values for AC_SUBSTed shell variables.
# This macro must not be AC_REQUIREd. It must only be invoked, and only
# outside of macros or in macros that are not AC_REQUIREd.
AC_DEFUN([gl_STDLIB_H_REQUIRE_DEFAULTS],
[
m4_defun(GL_MODULE_INDICATOR_PREFIX[_STDLIB_H_MODULE_INDICATOR_DEFAULTS], [
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETLOADAVG])
])
m4_require(GL_MODULE_INDICATOR_PREFIX[_STDLIB_H_MODULE_INDICATOR_DEFAULTS])
AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
])
AC_DEFUN([gl_STDLIB_H_DEFAULTS],
[
dnl Assume proper GNU behavior unless another module says otherwise.
HAVE_DECL_GETLOADAVG=1; AC_SUBST([HAVE_DECL_GETLOADAVG])
])

View File

@ -0,0 +1,24 @@
Description:
Construct a full filename by concatenating a directory name, a relative
filename, and a suffix.
Files:
lib/concat-filename.h
lib/concat-filename.c
Depends-on:
filename
configure.ac:
Makefile.am:
lib_SOURCES += concat-filename.c
Include:
"concat-filename.h"
License:
LGPLv2+
Maintainer:
all

28
gl/modules/findprog-in Normal file
View File

@ -0,0 +1,28 @@
Description:
Locating a program in a given path.
Files:
lib/findprog.h
lib/findprog-in.c
m4/findprog-in.m4
m4/eaccess.m4
Depends-on:
stdbool
filename
concat-filename
configure.ac:
gl_FINDPROG_IN
Makefile.am:
lib_SOURCES += findprog.h findprog-in.c
Include:
"findprog.h"
License:
LGPLv2+
Maintainer:
all

40
gl/modules/getloadavg Normal file
View File

@ -0,0 +1,40 @@
Description:
Return the current system load averages.
Files:
lib/getloadavg.c
m4/getloadavg.m4
Depends-on:
snippet/warn-on-use
extensions
intprops [test $HAVE_GETLOADAVG = 0]
stdbool [test $HAVE_GETLOADAVG = 0]
configure.ac:
gl_STDLIB_H
gl_STDLIB_H_REQUIRE_DEFAULTS
AC_REQUIRE([AC_CANONICAL_HOST])
gl_GETLOADAVG
gl_CONDITIONAL([GL_COND_OBJ_GETLOADAVG], [test $HAVE_GETLOADAVG = 0])
AM_COND_IF([GL_COND_OBJ_GETLOADAVG], [
gl_PREREQ_GETLOADAVG
])
gl_STDLIB_MODULE_INDICATOR([getloadavg])
Makefile.am:
if GL_COND_OBJ_GETLOADAVG
lib_SOURCES += getloadavg.c
endif
Include:
<stdlib.h>
Link:
$(GETLOADAVG_LIBS)
License:
GPL
Maintainer:
Jim Meyering

View File

@ -1,25 +1,68 @@
Description:
GNU make version of fnmatch()/glob() functions. This is a holdover from
GNU Make version of fnmatch()/glob() functions. This is a holdover from
a very old version of the globbing library.
Files:
lib/fnmatch.c
lib/fnmatch.in.h
lib/glob.c
lib/glob.in.h
configure.ac:
# Check the system to see if it provides GNU glob. If not, use our
# local version.
AC_CACHE_CHECK([if system libc has GNU glob], [make_cv_sys_gnu_glob],
[ AC_EGREP_CPP([gnu glob],[
#include <features.h>
#include <glob.h>
#include <fnmatch.h>
#if !defined _LIBC && defined __GNU_LIBRARY__ && __GNU_LIBRARY__ > 1
# include <gnu-versions.h>
# if _GNU_GLOB_INTERFACE_VERSION == 1 || _GNU_GLOB_INTERFACE_VERSION == 2
gnu glob
# endif
#endif],
[make_cv_sys_gnu_glob=yes],
[make_cv_sys_gnu_glob=no])])
# local version. Also avoid versions of glibc which have symlink bug
# https://sourceware.org/bugzilla/show_bug.cgi?id=866 (test from gnulib)
AC_CACHE_CHECK([if system libc has working GNU glob], [make_cv_sys_gnu_glob],[
if ln -s conf-doesntexist conf$$-globtest 2>/dev/null; then
make_check_symlink=yes
else
make_check_symlink=no
fi
if test $cross_compiling = yes || test $make_check_symlink = no; then
# When cross-compiling or without symlink support, check the version
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[[#include <features.h>
#include <gnu-versions.h>
#include <glob.h>
#include <fnmatch.h>
]],
[[
#if _GNU_GLOB_INTERFACE_VERSION == 0
GNU glob not available in libc
#elif __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 27)
GNU glob in libc has dangling symlink bug
#endif
]])],
[make_cv_sys_gnu_glob=yes],
[make_cv_sys_gnu_glob=no])
else
# Check for GNU glob, and that it handles dangling symlinks properly
AC_RUN_IFELSE(
[AC_LANG_PROGRAM(
[[#include <features.h>
#include <gnu-versions.h>
#include <glob.h>
#include <fnmatch.h>
]],
[[
#if _GNU_GLOB_INTERFACE_VERSION == 0
return 1;
#else
glob_t found;
if (glob ("conf*-globtest", 0, 0, &found) == GLOB_NOMATCH)
return 1;
globfree (&found);
#endif
]])],
[make_cv_sys_gnu_glob=yes],
[make_cv_sys_gnu_glob=no],
[dnl We don't get here.
:
])
fi
test $make_check_symlink = no || rm -f conf$$-globtest
])
# Tell automake about this, so it can build the right .c files.
AM_CONDITIONAL([USE_SYSTEM_GLOB], [test "$make_cv_sys_gnu_glob" = yes])
@ -28,7 +71,6 @@ AM_CONDITIONAL([USE_SYSTEM_GLOB], [test "$make_cv_sys_gnu_glob" = yes])
USE_SYSTEM_GLOB="$make_cv_sys_gnu_glob"
AC_SUBST([USE_SYSTEM_GLOB])
Makefile.am:
if !USE_SYSTEM_GLOB
libgnu_a_SOURCES += fnmatch.c
@ -60,7 +102,6 @@ endif
EXTRA_DIST += fnmatch.in.h glob.in.h
Include:
<glob.h>

16
gl/modules/make-macros Normal file
View File

@ -0,0 +1,16 @@
Description:
Install m4 macros for GNU Make.
Files:
m4/acinclude.m4
m4/dospaths.m4
configure.ac:
# Check for DOS-style pathnames.
pds_AC_DOS_PATHS
License:
GPLv3+
Maintainer:
gnumake

11
lib/.gitignore vendored
View File

@ -1,11 +0,0 @@
*
!/.gitignore
!/fnmatch.c
!/fnmatch.in.h
/fnmatch.h
!/glob.c
!/glob.in.h
/glob.h

5
m4/.gitignore vendored
View File

@ -1,5 +0,0 @@
*
!/.gitignore
!/aclocal.m4
!/dospaths.m4

View File

@ -1,5 +1,5 @@
# Maintainer-only makefile segment. This contains things that are relevant
# only if you have the full copy of the GNU make sources from the Git
# only if you have the full copy of the GNU Make sources from the Git
# tree, not a dist copy.
# --------------------- #
@ -17,15 +17,15 @@ GPG_KEYID := 80CB727A20C79BB2
# SRCROOTDIR is just a handy location to keep source files in
SRCROOTDIR ?= $(HOME)/src
# Where the gnulib project has been locally cloned
GNULIBDIR ?= $(SRCROOTDIR)/gnulib
# Where to put the CVS checkout of the GNU web repository
GNUWEBDIR ?= $(SRCROOTDIR)/gnu-www
# Where to put the CVS checkout of the GNU make web repository
# Where to put the CVS checkout of the GNU Make web repository
MAKEWEBDIR ?= $(SRCROOTDIR)/make/make-web
# Enable Perl warnings for the test suite
PERLFLAGS := -w
# We like mondo-warnings!
# Also force comments to be preserved. This helps when using ccache, in
# combination with GCC 7's implicit-fallthrough warning.
@ -34,7 +34,10 @@ MAKE_CFLAGS := -C -Wall -Wextra -Werror -Wwrite-strings -Wshadow \
-Wtype-limits -Wunused-but-set-parameter -Wlogical-op -Wpointer-arith \
-Wignored-qualifiers -Wformat-signedness -Wduplicated-cond
AM_CFLAGS += $(MAKE_CFLAGS)
# Allow extra options without overriding MAKE_CFLAGS
EXTRA_CFLAGS :=
AM_CFLAGS += $(MAKE_CFLAGS) $(EXTRA_CFLAGS)
# Unfortunately the Guile headers are sometimes broken. Convince GCC
# to treat them as system headers so warnings are ignored.
@ -43,45 +46,41 @@ GUILE_CFLAGS := $(patsubst -I%,-isystem %,$(GUILE_CFLAGS))
MAKE_MAINTAINER_MODE := -DMAKE_MAINTAINER_MODE
AM_CPPFLAGS += $(MAKE_MAINTAINER_MODE)
TEMPLATES = README README.DOS README.W32 README.OS2 \
src/config.ami src/configh.dos src/config.h.W32 src/config.h-vms
all: $(TEMPLATES)
# Create preprocessor output files--GCC specific!
%.i : %.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) -E -dD -o $@ $<
# General rule for turning a .template into a regular file.
#
$(TEMPLATES) : % : %.template Makefile
rm -f $@
sed -e 's@%VERSION%@$(VERSION)@g' \
-e 's@%PACKAGE%@$(PACKAGE)@g' \
$< > $@
chmod a-w $@
# Create the mkconfig.h file for non-POSIX config headers
all: src/mkconfig.h
src/mkconfig.h: src/mkconfig.h.in config.status
./config.status --header=$@
# Build the README
all: README
README : README.in config.status
./config.status --file=$@
# Construct Makefiles by adding on dependencies, etc.
#
cvt = $(patsubst $1/%,$$($1)%,$(filter %.c,$2))
Basic.mk: Basic.mk.template .dep_segment Makefile
rm -f $@
sed -e 's@%VERSION%@$(VERSION)@g' \
-e 's@%make_SOURCES%@$(call cvt,src,$(make_SRCS))@g' \
sed -e 's@%make_SOURCES%@$(call cvt,src,$(make_SRCS))@g' \
-e 's@%w32_SOURCES%@$(call cvt,src,$(w32_SRCS))@g' \
-e 's@%vms_SOURCES%@$(call cvt,src,$(vms_SRCS))@g' \
-e 's@%amiga_SOURCES%@$(call cvt,src,$(amiga_SRCS))@g' \
-e 's@%loadavg_SOURCES%@$(call cvt,lib,$(loadavg_SRCS))@g' \
-e 's@%alloca_SOURCES%@$(call cvt,lib,$(alloca_SRCS))@g' \
-e 's@%glob_SOURCES%@$(call cvt,lib,$(glob_SRCS))@g' \
$< > $@
echo >>$@; echo '# --------------- DEPENDENCIES' >>$@; echo '#' >>$@; \
echo >>$@; echo '$$(OBJECTS): $$(SRCDIR)/src/mkconfig.h' >>$@; \
sed -e 's@^\([^ ]*\)\.o:@$$(OUTDIR)\1.$$(OBJEXT):@' \
-e 's@\([^ ]*\.[ch]\)@$$(SRCDIR)/\1@g' \
-e 's@$$(SRCDIR)/src/config.h@$$(OUTDIR)src/config.h@g' \
-e 's@$$(SRCDIR)/lib/stdlib.h@@g' \
-e 's@$$(SRCDIR)/lib/sys/types.h@@g' \
-e 's@$$(SRCDIR)/lib/unistd.h@@g' \
-e 's@$$(SRCDIR)/lib/alloca.h@@g' \
-e 's@$$(SRCDIR)/lib/stdbool.h@@g' \
$(word 2,$^) >>$@
chmod a-w $@
@ -116,13 +115,16 @@ GIT := git
git-clean:
-$(GIT) clean -fdX
git-very-clean: git-clean
-$(GIT) clean -fd
-$(GIT) clean -fdx
## ---------------------- ##
## Generating ChangeLog. ##
## ---------------------- ##
# Where the gnulib project has been locally cloned
GNULIBDIR ?= $(or $(wildcard $(GNULIB_SRCDIR)),./gnulib)
gl2cl-date := 2013-10-10
gl2cl := $(GNULIBDIR)/build-aux/gitlog-to-changelog
@ -134,12 +136,13 @@ ChangeLog: .check-git-HEAD
echo "WARNING: $(gl2cl) is not available. No $@ generated."; \
fi
.PHONY: .check-git-HEAD
.check-git-HEAD:
.check-git-HEAD: FORCE
sha="`git rev-parse HEAD`"; \
[ -f '$@' ] && [ "`cat '$@' 2>/dev/null`" = "$$sha" ] \
test -f '$@' && [ "`cat '$@' 2>/dev/null`" = "$$sha" ] \
|| echo "$$sha" > '$@'
.PHONY: FORCE
FORCE:;@:
## ---------------- ##
## Updating files. ##
@ -165,16 +168,15 @@ update: po-check
# PO archive mirrors --- Be careful; some might not be fully populated!
# ftp://ftp.unex.es/pub/gnu-i18n/po/maint/
# http://translation.sf.net/maint/
# ftp://tiger.informatik.hu-berlin.de/pub/po/maint/
po_wget_flags = --recursive --level=1 --no-directories --no-check-certificate
po_wget_flags = --recursive --level=1 --no-directories --no-check-certificate
po_repo = https://translationproject.org/latest/$(PACKAGE)
po_sync = translationproject.org::tp/latest/$(PACKAGE)/
.PHONY: do-po-update po-update
do-po-update:
tmppo="/tmp/po-$(PACKAGE)-$(VERSION).$$$$" \
tmppo="/tmp/po-$(PACKAGE)-$(PACKAGE_VERSION).$$$$" \
&& rm -rf "$$tmppo" \
&& mkdir "$$tmppo" \
&& $(RSYNC) $(po_sync) "$$tmppo" \
@ -184,7 +186,7 @@ do-po-update:
$(MAKE) po-check
po-update:
[ -d "po" ] && $(MAKE) do-po-update
test -d "po" && $(MAKE) do-po-update
# -------------------------- #
# Updating GNU build files. #
@ -207,63 +209,130 @@ target = $(patsubst get-%,%,$@)
config-url = $(git-url)/config.git/plain/$(patsubst get-build-aux/%,%,$@)
get-build-aux/config.guess get-build-aux/config.sub:
@echo $(WGET) $(config-url) -O $(target) \
&& $(WGET) $(config-url) -O $(target).t \
@echo Retrieving $(target) from $(config-url)
$(WGET) $(config-url) -O $(target).t \
&& $(move_if_change)
gnulib-url = $(git-url)/gnulib.git/plain/build-aux/$(patsubst get-build-aux/%,%,$@)
get-build-aux/texinfo.tex:
@echo $(WGET) $(gnulib-url) -O $(target) \
&& $(WGET) $(gnulib-url) -O $(target).t \
@echo Retrieving $(target) from $(gnulib-url)
$(WGET) $(gnulib-url) -O $(target).t \
&& $(move_if_change)
gnustandards-url = $(cvs-url)/gnustandards/gnustandards/$(patsubst get-doc/%,%,$@)
get-doc/make-stds.texi get-doc/fdl.texi:
@echo $(WGET) $(gnustandards-url) -O $(target) \
&& $(WGET) $(gnustandards-url) -O $(target).t \
@echo Retrieving $(target) from $(gnustandards-url)
$(WGET) $(gnustandards-url) -O $(target).t \
&& $(move_if_change)
# ---------------------------- #
# Extra configuration checks. #
# ---------------------------- #
# Make the dist file contents more regular, if we're using GNU tar.
# Suggested by Tzvetelin Katchov <katchov@gnu.org>
export TAR_OPTIONS := --mode=u+w,go-w --owner=0 --group=0 --numeric-owner --sort=name
# When I released 4.3 somehow the INSTALL file was missing.
# When I tried to build it again, it was there. I have no idea what happened
# but add a new check to be sure it doesn't happen again.
mk_dist_files = AUTHORS ChangeLog COPYING INSTALL README src/mkconfig.h
dist: mk-dist mk-distcheck
.PHONY: mk-distcheck
mk-distcheck: distdir
@echo "Checking for extra installed files..."
@for fn in $(mk_dist_files); do \
test -f '$(distdir)'/"$$fn" \
|| { echo "Missing dist file: $$fn"; exit 1; }; \
done; true
# Make sure that the files in lib/ have been updated from the files in gl/lib/
GL_LIB_FILES := $(wildcard gl/lib/*)
mk-dist:
@echo "Checking gl/lib files..."
@for fn in $(GL_LIB_FILES); do \
cmp $$fn $${fn##gl/} \
|| { echo "Run ./bootstrap --gen ?"; exit 1; }; \
done; true
# ---------------------------------- #
# Alternative configuration checks. #
# ---------------------------------- #
CFGCHECK_CONFIGFLAGS =
CFGCHECK_BUILDFLAGS =
# We can't use our mondo warnings as these are used to compile gnulib modules
# as well, and that will fail.
CFGCHECK_MAKEFLAGS = # CFLAGS='$(AM_CFLAGS)'
# We don't support C90 anymore, strictly, but this test still works (with lots
# of warnings) and it helps us avoid egregious incompatibilities.
checkcfg.strict-c90: CFGCHECK_CONFIGFLAGS = CFLAGS='-std=c90 -pedantic'
checkcfg.strict-c90: CFGCHECK_MAKEFLAGS =
checkcfg.job-pipe: CFGCHECK_CONFIGFLAGS = CPPFLAGS=-DJOBSERVER_USE_FIFO=0
checkcfg.no-jobserver:CFGCHECK_CONFIGFLAGS = --disable-job-server
checkcfg.no-load: CFGCHECK_CONFIGFLAGS = --disable-load
checkcfg.no-guile: CFGCHECK_CONFIGFLAGS = --without-guile
checkcfg.no-spawn: CFGCHECK_CONFIGFLAGS = --disable-posix-spawn
checkcfg.no-sysglob: CFGCHECK_CONFIGFLAGS = make_cv_sys_gnu_glob=no
checkcfg.no-loadavg: CFGCHECK_CONFIGFLAGS = ac_cv_func_getloadavg=no \
ac_cv_have_decl_getloadavg=no \
gl_cv_have_raw_decl_getloadavg=no \
ac_cv_lib_util_getloadavg=no \
ac_cv_lib_getloadavg_getloadavg=no
checkcfg.no-sync: CFGCHECK_CONFIGFLAGS = CPPFLAGS=-DNO_OUTPUT_SYNC
checkcfg.no-archives: CFGCHECK_CONFIGFLAGS = CPPFLAGS=-DNO_ARCHIVES
CONFIG_CHECKS := \
checkcfg.--disable-job-server \
checkcfg.--disable-load \
checkcfg.--without-guile \
checkcfg.--disable-posix-spawn \
checkcfg.make_cv_sys_gnu_glob^no \
checkcfg.ac_cv_func_getloadavg^no+ac_cv_have_decl_getloadavg^no+gl_cv_have_raw_decl_getloadavg^no+ac_cv_lib_util_getloadavg^no+ac_cv_lib_getloadavg_getloadavg^no \
checkcfg.CPPFLAGS^-DNO_OUTPUT_SYNC \
checkcfg.CPPFLAGS^-DNO_ARCHIVES
checkcfg.strict-c90 \
checkcfg.job-pipe \
checkcfg.no-jobserver \
checkcfg.no-load \
checkcfg.no-guile \
checkcfg.no-spawn \
checkcfg.no-sysglob \
checkcfg.no-loadavg \
checkcfg.no-sync \
checkcfg.no-archives
.PHONY: check-alt-config
check-alt-config: $(CONFIG_CHECKS)
@echo --- $@ SUCCESS
# Trick GNU make so it doesn't run the submake as a recursive make.
# Trick GNU Make so it doesn't run the submake as a recursive make.
NR_MAKE = $(MAKE)
# Check builds both with build.sh and with make
build.sh_SCRIPT = exec >>'checkcfg.$*.log' 2>&1; set -x; \
cd $(distdir)/_build \
&& OUTDIR=_bld ../build.sh -k $(CFGCHECK_BUILD_FLAGS) \
&& _bld/make GMK_OUTDIR=../_bld $(AM_MAKEFLAGS) check-local \
&& _bld/make GMK_OUTDIR=../_bld $(AM_MAKEFLAGS) clean
nrmake_SCRIPT = exec >>'checkcfg.$*.log' 2>&1; set -x; \
cd $(distdir)/_build \
&& $(NR_MAKE) $(AM_MAKEFLAGS) $(CFGCHECK_MAKEFLAGS) \
&& ./make $(AM_MAKEFLAGS) check \
&& ./make $(AM_MAKEFLAGS) clean
$(CONFIG_CHECKS): checkcfg.%: distdir
@echo "Building $@ (output in checkcfg.$*.log)"
exec >'checkcfg.$*.log' 2>&1; \
echo "Testing configure with $(subst ^,=,$(subst +, ,$*))"; set -x; \
echo "Testing configure with $(CFGCHECK_CONFIGFLAGS)"; set -x; \
rm -rf $(distdir)/_build \
&& mkdir $(distdir)/_build \
&& cd $(distdir)/_build \
&& ../configure --srcdir=.. $(subst ^,=,$(subst +, ,$*)) \
$(AM_DISTCHECK_CONFIGURE_FLAGS) $(DISTCHECK_CONFIGURE_FLAGS)
exec >>'checkcfg.$*.log' 2>&1; set -x; \
cd $(distdir)/_build \
&& OUTDIR=_bld ../build.sh \
&& _bld/make $(AM_MAKEFLAGS) check-local \
&& _bld/make $(AM_MAKEFLAGS) clean
exec >>'checkcfg.$*.log' 2>&1; set -x; \
cd $(distdir)/_build \
&& $(NR_MAKE) $(AM_MAKEFLAGS) CFLAGS='$(AM_CFLAGS)' \
&& ./make $(AM_MAKEFLAGS) check \
&& ./make $(AM_MAKEFLAGS) clean
&& ../configure --srcdir=.. $(CFGCHECK_CONFIGFLAGS) \
$(AM_DISTCHECK_CONFIGURE_FLAGS) $(DISTCHECK_CONFIGURE_FLAGS)
$(build.sh_SCRIPT)
$(nrmake_SCRIPT)
# Try using Basic.mk. I can't test this on POSIX systems because it is only
# used for non-POSIX systems; POSIX systems can just use normal
@ -276,10 +345,10 @@ checkcfg.basicmk: checkcfg.% : distdir
&& mkdir $(distdir)/_build \
&& cd $(distdir)/_build \
&& ../configure --srcdir=.. \
$(AM_DISTCHECK_CONFIGURE_FLAGS) $(DISTCHECK_CONFIGURE_FLAGS)
$(AM_DISTCHECK_CONFIGURE_FLAGS) $(DISTCHECK_CONFIGURE_FLAGS)
exec >>'checkcfg.$*.log' 2>&1; set -x; \
cd $(distdir)/_build \
&& $(NR_MAKE) $(AM_MAKEFLAGS) -f ../Basic.mk SRCDIR=.. CFLAGS='$(AM_CFLAGS)' \
&& $(NR_MAKE) $(AM_MAKEFLAGS) -f ../Basic.mk SRCDIR=.. $(CFGCHECK_MAKEFLAGS)
&& ./make $(AM_MAKEFLAGS) -f ../Basic.mk SRCDIR=.. check \
&& ./make $(AM_MAKEFLAGS) -f ../Basic.mk SRCDIR=.. clean
exec >>'checkcfg.$*.log' 2>&1; \
@ -287,8 +356,8 @@ checkcfg.basicmk: checkcfg.% : distdir
&& rm -rf $(distdir)/_build \
&& cd $(distdir) \
&& ./configure \
$(AM_DISTCHECK_CONFIGURE_FLAGS) $(DISTCHECK_CONFIGURE_FLAGS) \
&& $(NR_MAKE) $(AM_MAKEFLAGS) -f Basic.mk CFLAGS='$(AM_CFLAGS)' \
$(AM_DISTCHECK_CONFIGURE_FLAGS) $(DISTCHECK_CONFIGURE_FLAGS) \
&& $(NR_MAKE) $(AM_MAKEFLAGS) -f Basic.mk '$(CFGCHECK_MAKEFLAGS)' \
&& ./make $(AM_MAKEFLAGS) -f Basic.mk check \
&& ./make $(AM_MAKEFLAGS) -f Basic.mk clean
@ -309,10 +378,10 @@ local-check: po-check changelog-check
# copyright-check writable-files
changelog-check:
if head $(top_srcdir)/ChangeLog | grep 'Version $(VERSION)' >/dev/null; then \
if head $(top_srcdir)/ChangeLog | grep 'Version $(PACKAGE_VERSION)' >/dev/null; then \
:; \
else \
echo "$(VERSION) not in ChangeLog" 1>&2; \
echo "$(PACKAGE_VERSION) not in ChangeLog" 1>&2; \
exit 1; \
fi
@ -339,18 +408,18 @@ makeweb-repo = $(USER)@cvs.sv.gnu.org:/web/make
gnuweb-repo = :pserver:anonymous@cvs.sv.gnu.org:/web/www
gnuweb-dir = www/server/standards
# Get the GNU make web page boilerplate etc.
# Get the GNU Make web page boilerplate etc.
update-makeweb:
[ -d '$(MAKEWEBDIR)' ] || mkdir -p '$(MAKEWEBDIR)'
[ -d '$(MAKEWEBDIR)'/CVS ] \
test -d '$(MAKEWEBDIR)' || mkdir -p '$(MAKEWEBDIR)'
test -d '$(MAKEWEBDIR)'/CVS \
&& { cd '$(MAKEWEBDIR)' && $(CVS) update; } \
|| { mkdir -p '$(dir $(MAKEWEBDIR))' && cd '$(dir $(MAKEWEBDIR))' \
&& $(CVS) -d $(makeweb-repo) co -d '$(notdir $(MAKEWEBDIR))' make; }
# Get the GNU web page boilerplate etc.
update-gnuweb:
[ -d '$(GNUWEBDIR)' ] || mkdir -p '$(GNUWEBDIR)'
[ -d '$(GNUWEBDIR)/$(gnuweb-dir)'/CVS ] \
test -d '$(GNUWEBDIR)' || mkdir -p '$(GNUWEBDIR)'
test -d '$(GNUWEBDIR)/$(gnuweb-dir)'/CVS \
&& { cd '$(GNUWEBDIR)/$(gnuweb-dir)' && $(CVS) update; } \
|| { cd '$(GNUWEBDIR)' && $(CVS) -d $(gnuweb-repo) co '$(gnuweb-dir)'; }
@ -359,7 +428,7 @@ gendocs: update-gnuweb update-makeweb
cd doc \
&& rm -rf doc/manual \
&& $(GNULIBDIR)/build-aux/gendocs.sh --email '$(BUGLIST)' \
make 'GNU Make Manual'
make '$(PACKAGE_NAME) Manual'
find '$(MAKEWEBDIR)'/manual \( -name CVS -prune \) -o \( -name '[!.]*' -type f -exec rm -f '{}' \; \)
cp -r doc/manual '$(MAKEWEBDIR)'
@echo 'Status of $(MAKEWEBDIR) repo:' && cd '$(MAKEWEBDIR)' \
@ -367,7 +436,7 @@ gendocs: update-gnuweb update-makeweb
@echo '- cvs add <new files>' \
&& echo '- cvs remove <deleted files>' \
&& echo '- cvs commit' \
&& echo '- cvs tag make-$(subst .,-,$(VERSION))'
&& echo '- cvs tag make-$(subst .,-,$(PACKAGE_VERSION))'
## --------------------------------------------- ##
@ -392,7 +461,7 @@ $(COV_BUILD_FILE): $(filter %.c %.h,$(DISTFILES))
cd '$(distdir)'/_build \
&& ../configure --srcdir=.. \
$(AM_DISTCHECK_CONFIGURE_FLAGS) $(DISTCHECK_CONFIGURE_FLAGS) \
CFLAGS='$(AM_CFLAGS)'
$(CFGCHECK_MAKEFLAGS)
PATH="$${COVERITY_PATH:+$$COVERITY_PATH/bin:}$$PATH"; \
cd '$(distdir)'/_build \
&& cov-build --dir cov-int ../build.sh
@ -402,18 +471,18 @@ $(COV_BUILD_FILE): $(filter %.c %.h,$(DISTFILES))
cov-submit: $(COV_BUILD_FILE)-submitted
$(COV_BUILD_FILE)-submitted: $(COV_BUILD_FILE)
@[ -n "$(COVERITY_TOKEN)" ] || { echo 'COVERITY_TOKEN not set'; exit 1; }
@[ -n "$(COVERITY_EMAIL)" ] || { echo 'COVERITY_EMAIL not set'; exit 1; }
@test -n "$(COVERITY_TOKEN)" || { echo 'COVERITY_TOKEN not set'; exit 1; }
@test -n "$(COVERITY_EMAIL)" || { echo 'COVERITY_EMAIL not set'; exit 1; }
rm -f '$@'
case '$(VERSION)' in \
case '$(PACKAGE_VERSION)' in \
(*.*.9*) type="daily build"; ext=".$$(date +%Y%m%d)" ;; \
(*) type="release"; ext= ;; \
esac; \
curl --form token='$(COVERITY_TOKEN)' \
--form email='$(COVERITY_EMAIL)' \
--form file='@$<' \
--form version="$(VERSION)$$ext" \
--form description="GNU make $$type" \
--form version="$(PACKAGE_VERSION)$$ext" \
--form description="$(PACKAGE_NAME) $$type" \
'https://scan.coverity.com/builds?project=gmake'
cp '$<' '$@'
@ -424,11 +493,11 @@ $(COV_BUILD_FILE)-submitted: $(COV_BUILD_FILE)
.PHONY: tag-release
tag-release:
case '$(VERSION)' in \
case '$(PACKAGE_VERSION)' in \
(*.*.9*) message=" candidate" ;; \
(*) message= ;; \
esac; \
$(GIT) tag -m "GNU Make release$$message $(VERSION)" -u '$(GPG_KEYID)' '$(VERSION)'
$(GIT) tag -m "$(PACKAGE_NAME) release$$message $(PACKAGE_VERSION)" -u '$(GPG_KEYID)' '$(PACKAGE_VERSION)'
## ------------------------- ##
@ -439,48 +508,18 @@ tag-release:
# Sign it with my key. If you don't have my key/passphrase then sorry,
# you're SOL! :)
GPG = gpg
GPGFLAGS = -u $(GPG_KEYID)
DIST_ARCHIVES_SIG = $(addsuffix .sig,$(DIST_ARCHIVES))
DIST_ARCHIVES_DIRECTIVE = $(addsuffix .directive.asc,$(DIST_ARCHIVES))
# A simple rule to test signing, etc.
.PHONY: distsign
distsign: $(DIST_ARCHIVES_SIG) $(DIST_ARCHIVES_DIRECTIVE)
%.sig : %
@echo "Signing file '$<':"
$(GPG) $(GPGFLAGS) -o "$@" -b "$<"
%.directive.asc: %
@echo "Creating signed directive file '$@':"
@( \
echo 'version: 1.2'; \
echo 'directory: make'; \
echo 'filename: $*'; \
echo 'comment: Official upload of GNU make version $(VERSION)'; \
) > "$*.directive"
$(GPG) $(GPGFLAGS) -o "$@" --clearsign "$*.directive"
@rm -f "$*.directive"
# Upload the artifacts
FTPPUT = ncftpput
gnu-upload-host = ftp-upload.gnu.org
gnu-upload-dir = /incoming
GNUPLOAD := $(GNULIBDIR)/build-aux/gnupload
UPLOADS = upload-alpha upload-ftp
.PHONY: $(UPLOADS)
$(UPLOADS): $(DIST_ARCHIVES) $(DIST_ARCHIVES_SIG) $(DIST_ARCHIVES_DIRECTIVE)
$(FTPPUT) "$(gnu-upload-host)" "$(gnu-upload-dir)/$(@:upload-%=%)" $^
$(UPLOADS): upload-%: $(DIST_ARCHIVES)
$(GNUPLOAD) --user "$(GPG_KEYID)" --to "$*.gnu.org:make" -- $^
# Rebuild Makefile.in if this file is modifed.
# Rebuild Makefile.in if this file is modified.
Makefile.in: maintMakefile
# Copyright (C) 1997-2019 Free Software Foundation, Inc.
# Copyright (C) 1997-2024 Free Software Foundation, Inc.
# This file is part of GNU Make.
#
# GNU Make is free software; you can redistribute it and/or modify it under
@ -494,4 +533,4 @@ Makefile.in: maintMakefile
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
# this program. If not, see <https://www.gnu.org/licenses/>.

View File

@ -1,11 +1,15 @@
import re
"""GDB pretty-printer macros for GNU Make."""
import gdb # pylint: disable=import-error
import gdb.printing # pylint: disable=import-error
import gdb #pylint: disable=import-error
import gdb.printing #pylint: disable=import-error
# Memoize types we commonly use
_TYPES = {}
def getType(tname):
"""Given a type name return a GDB type."""
global _TYPES
if tname not in _TYPES:
tn = tname.rstrip('*')
@ -18,48 +22,129 @@ def getType(tname):
_TYPES[tn] = _TYPES[t].pointer()
return _TYPES[tname]
class ShowArgv(gdb.Function):
"""Return the pretty-print of a null-terminated array of strings
def isNullptr(val):
"""Return True if the value is a null pointer."""
return int(val.cast(getType('unsigned long long'))) == 0
class ShowArgv(gdb.Command):
"""Print a null-terminated array of strings.
Argument:
A char** where the last one is NULL (e.g., argv)
"""
def __init__(self):
gdb.Function.__init__(self, "showargv")
"""Create the showargv function."""
gdb.Command.__init__(self, "showargv", gdb.COMMAND_USER)
def invoke(self, arg, from_tty):
"""Show the argv."""
args = gdb.string_to_argv(arg)
if len(args) != 1:
raise gdb.GdbError(self._usage)
val = gdb.parse_and_eval(args[0])
if val is None:
raise gdb.GdbError('%s is not a valid expression' % (args[0]))
strs = []
while not isNullptr(val.dereference()):
strs.append('"'+val.dereference().string()+'"')
val += 1
gdb.write("[%d] = [%s]\n" % (len(strs), ', '.join(strs)))
gdb.flush()
def invoke(self, argv):
str = '['
i = 0
while argv[i] != 0:
if i > 0:
str += ', '
str += argv[i].string()
i += 1
str += ']'
return str
ShowArgv()
class ShowNextList(gdb.Command):
"""Print a structure that has a "next" pointer.
Argument:
A pointer to a struct which contains a "next" member.
"""
_usage = 'usage: showlist <listptr>'
def __init__(self):
"""Create a "showlist" function."""
gdb.Command.__init__(self, "showlist", gdb.COMMAND_USER)
def invoke(self, arg, from_tty):
"""Show the elements in the provided list."""
args = gdb.string_to_argv(arg)
if len(args) != 1:
raise gdb.GdbError(self._usage)
val = gdb.parse_and_eval(args[0])
if val is None:
raise gdb.GdbError('%s is not a valid expression' % (args[0]))
i = 0
while not isNullptr(val):
gdb.write("%s : %s\n" % (val, val.dereference()))
gdb.flush()
i += 1
val = val['next']
gdb.write("%s contains %d elements\n" % (args[0], i))
gdb.flush()
ShowNextList()
class FileLocation(object):
"""Print a file location"""
"""Print a file location."""
def __init__(self, val):
"""Create a FileLocation object."""
self.val = val
def to_string(self):
if long(self.val['filenm']):
"""Convert a FileLocation to a string."""
if int(self.val['filenm']):
return "%s:%d" % (str(self.val['filenm']), self.val['lineno'])
return ''
return 'NILF'
class StringListPrinter(object):
"""Print a stringlist."""
def __init__(self, val):
"""Create a StringListPrinter object."""
self.val = val
def to_string(self):
"""Convert a HashTable into a string."""
return "size=%d, capacity=%d" % (self.val['idx'], self.val['max'])
def children(self):
"""Yield each string in the list."""
i = 0
elts = self.val['list']
while i < self.val['idx']:
nm = '[%d] ' % i
yield (nm, elts.dereference())
i += 1
elts += 1
def display_hint(self):
"""Show the display hint for the pretty-printer."""
return 'array'
class VariablePrinter(object):
"""Print a struct variable"""
"""Print a struct variable."""
def __init__(self, val):
"""Create a VariablePrinter object."""
self.val = val
def to_string(self):
"""Convert a VariablePrinter object into a string."""
if self.val['append']:
a = '+='
elif self.val['conditional']:
@ -80,48 +165,58 @@ class VariablePrinter(object):
self.val['fileinfo'], ','.join(flags),
self.val['name'].string(), a, self.val['value'].string())
class HashTablePrinter(object):
"""Manage a hash table."""
"""Pretty-print a hash table."""
DELITEM = None
def __init__(self, val):
"""Create a HashTablePrinter object."""
self.val = val
def to_string(self):
"""Convert a HashTable into a string."""
return "size=%d, capacity=%d, empty=%d, collisions=%d, rehashes=%d" % (
self.val['ht_size'], self.val['ht_capacity'],
self.val['ht_empty_slots'], self.val['ht_collisions'],
self.val['ht_rehashes'])
def children(self):
"""Yield each ID and value."""
for (i, v) in self.iterator():
nm = '[%d] ' % i
yield (nm, i)
yield (nm, v)
def iterator(self):
"""Provide an iterator for HashTable."""
if HashTablePrinter.DELITEM is None:
HashTablePrinter.DELITEM = gdb.lookup_global_symbol('hash_deleted_item').value()
lst = self.val['ht_vec']
for i in xrange(0, self.val['ht_size']):
for i in range(0, self.val['ht_size']):
v = lst[i]
if long(v) != 0 and v != HashTablePrinter.DELITEM:
if int(v) != 0 and v != HashTablePrinter.DELITEM:
yield (i, v)
def display_hint(self):
"""Show the display hint for the pretty-printer."""
return 'map'
class VariableSetPrinter(object):
"""Print a variable_set"""
"""Print a variable_set."""
def __init__(self, val):
"""Create a variable_set pretty-printer."""
self.tbl = HashTablePrinter(val['table'])
def to_string(self):
"""Convert a variable_set to string."""
return self.tbl.to_string()
def children(self):
"""Iterate through variables and values."""
for (i, v) in self.tbl.iterator():
ptr = v.cast(getType('struct variable*'))
nm = '[%d] ' % (i)
@ -129,29 +224,35 @@ class VariableSetPrinter(object):
yield (nm, str(ptr.dereference()))
def display_hint(self):
"""Show the display hint for the pretty-printer."""
return 'map'
class VariableSetListPrinter(object):
"""Print a variable_set_list"""
"""Print a variable_set_list."""
GLOBALSET = None
def __init__(self, val):
"""Create a variable_set_list pretty-printer."""
self.val = val
def to_string(self):
"""Convert a variable_set_list to string."""
return str(self.val.address)
def children(self):
"""Iterate through variables and values."""
if VariableSetListPrinter.GLOBALSET is None:
block = gdb.lookup_global_symbol('init_hash_global_variable_set').symtab.static_block()
VariableSetListPrinter.GLOBALSET = gdb.lookup_symbol('global_variable_set', block)[0].value().address
VariableSetListPrinter.GLOBALSET = gdb.lookup_symbol(
'global_variable_set', block)[0].value().address
ptr = self.val.address
i = 0
while long(ptr) != 0:
while not isNullptr(ptr):
nm = '[%d] ' % (i)
yield (nm, ptr['set'])
if long(ptr['set']) == long(VariableSetListPrinter.GLOBALSET):
if int(ptr['set']) == int(VariableSetListPrinter.GLOBALSET):
yield (nm, "global_variable_set")
else:
yield (nm, str(ptr['set'].dereference()))
@ -159,17 +260,22 @@ class VariableSetListPrinter(object):
ptr = ptr['next']
def display_hint(self):
"""Show the display hint for the pretty-printer."""
return 'map'
def build_pretty_printer():
"""Install all the pretty-printers."""
pp = gdb.printing.RegexpCollectionPrettyPrinter("gnumake")
pp.add_printer('floc', r'^floc$', FileLocation)
pp.add_printer('stringlist', r'^stringlist$', StringListPrinter)
pp.add_printer('variable', r'^variable$', VariablePrinter)
pp.add_printer('hashtable', r'^hash_table$', HashTablePrinter)
pp.add_printer('variableset', r'^variable_set$', VariableSetPrinter)
pp.add_printer('variablesetlist', r'^variable_set_list$', VariableSetListPrinter)
return pp
# Use replace=True so we can re-source this file
gdb.printing.register_pretty_printer(gdb.current_objfile(),
build_pretty_printer(), replace=True)

View File

@ -76,7 +76,7 @@ $ filelist = "[.src]ar [.src]arscan [.src]commands [.src]default [.src]dir " + -
"[.src]hash [.src]implicit [.src]job [.src]load [.src]main " + -
"[.src]misc [.src]read [.src]remake [.src]remote-stub " + -
"[.src]rule [.src]output [.src]signame [.src]variable " + -
"[.src]version [.src]strcache [.src]vpath " + -
"[.src]version [.src]shuffle [.src]strcache [.src]vpath " + -
"[.src]vmsfunctions [.src]vmsify [.src]vms_progname " + -
"[.src]vms_exit [.src]vms_export_symbol " + -
"[.lib]alloca [.lib]fnmatch [.lib]glob [.src]getopt1 [.src]getopt"
@ -154,7 +154,7 @@ $ exit
$ endsubroutine : compileit
$!
$!-----------------------------------------------------------------------------
$!Copyright (C) 1996-2019 Free Software Foundation, Inc.
$!Copyright (C) 1996-2024 Free Software Foundation, Inc.
$!This file is part of GNU Make.
$!
$!GNU Make is free software; you can redistribute it and/or modify it under
@ -168,4 +168,4 @@ $!FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
$!details.
$!
$!You should have received a copy of the GNU General Public License along with
$!this program. If not, see <http://www.gnu.org/licenses/>.
$!this program. If not, see <https://www.gnu.org/licenses/>.

View File

@ -1,45 +0,0 @@
# GNU -*-Makefile-*- to build GNU make on Amiga
#
# Amiga overrides for use with Basic.mk.
#
# Copyright (C) 2017-2019 Free Software Foundation, Inc.
# This file is part of GNU Make.
#
# GNU Make is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 3 of the License, or (at your option) any later
# version.
#
# GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
CC = sc
LD = $(CC) Link
MKDIR.cmd = makedir $1
RM.cmd = delete $1
CP.cmd = copy $1 To $2
CPPFLAGS =
CFLAGS =
LDFLAGS =
prog_SOURCES += $(alloca_SOURCES) $(loadavg_SOURCES) $(glob_SOURCES) $(amiga_SOURCES)
BUILT_SOURCES += $(lib)alloca.h $(lib)fnmatch.h $(lib)glob.h
extra_CPPFLAGS = IDir $(OUTDIR)src IDir $(SRCDIR)/src IDir $(OUTDIR)lib IDir $(SRCDIR)/lib
C_SOURCE =
OUTPUT_OPTION =
LDFLAGS = From LIB:cres.o
LDLIBS = Lib LIB:sc.lib LIB:amiga.lib
LINK_OUTPUT = To $@
$(OUTDIR)src/config.h: $(SRCDIR)/src/config.ami
$(call CP.cmd,$<,$@)

View File

@ -1,8 +1,8 @@
# GNU -*-Makefile-*- to build GNU make on POSIX systems
# GNU -*-Makefile-*- to build GNU Make on POSIX systems
#
# POSIX overrides for use with Basic.mk.
#
# Copyright (C) 2017-2019 Free Software Foundation, Inc.
# Copyright (C) 2017-2024 Free Software Foundation, Inc.
# This file is part of GNU Make.
#
# GNU Make is free software; you can redistribute it and/or modify it under
@ -16,11 +16,11 @@
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
# this program. If not, see <https://www.gnu.org/licenses/>.
# Very little is needed here since the default Basic.mk assumes POSIX
prog_SOURCES += $(posix_SOURCES)
prog_SOURCES += $(src)/posixos.c
extra_CPPFLAGS += @GUILE_CFLAGS@
extra_LDFLAGS += @AM_LDFLAGS@

View File

@ -1,8 +1,8 @@
# GNU -*-Makefile-*- to build GNU make on VMS
# GNU -*-Makefile-*- to build GNU Make on VMS
#
# VMS overrides for use with Basic.mk.
#
# Copyright (C) 2017-2019 Free Software Foundation, Inc.
# Copyright (C) 2017-2024 Free Software Foundation, Inc.
# This file is part of GNU Make.
#
# GNU Make is free software; you can redistribute it and/or modify it under
@ -16,7 +16,7 @@
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
# this program. If not, see <https://www.gnu.org/licenses/>.
src = [.src]
lib = [.lib]
@ -93,5 +93,5 @@ define CLEANSPACE
endef
$(OUTDIR)$(src)config.h: $(SRCDIR)$(src)config.h.W32
$(OUTDIR)$(src)config.h: $(SRCDIR)$(src)config.h-vms
$(call CP.cmd,$<,$@)

View File

@ -1,8 +1,8 @@
# GNU -*-Makefile-*- to build GNU make on Windows
# GNU -*-Makefile-*- to build GNU Make on Windows
#
# Windows overrides for use with Basic.mk.
#
# Copyright (C) 2017-2019 Free Software Foundation, Inc.
# Copyright (C) 2017-2024 Free Software Foundation, Inc.
# This file is part of GNU Make.
#
# GNU Make is free software; you can redistribute it and/or modify it under
@ -16,7 +16,7 @@
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
# this program. If not, see <https://www.gnu.org/licenses/>.
# TARGET_TYPE can be either "release" or "debug"
TARGET_TYPE = release
@ -30,6 +30,8 @@ P2W = $(subst /,\,$1)
prog_SOURCES += $(loadavg_SOURCES) $(glob_SOURCES) $(w32_SOURCES)
utf8_SOURCES = $(src)w32/utf8.rc $(src)w32/utf8.manifest
BUILT_SOURCES += $(lib)alloca.h $(lib)fnmatch.h $(lib)glob.h
w32_LIBS = kernel32 user32 gdi32 winspool comdlg32 advapi32 shell32 ole32 \
@ -41,9 +43,10 @@ LDFLAGS =
# --- Visual Studio
msvc_CC = cl.exe
msvc_RC = rc.exe
msvc_LD = link.exe
msvc_CPPFLAGS = /DHAVE_CONFIG_H /DWINDOWS32 /DWIN32 /D_CONSOLE
msvc_CPPFLAGS = /DHAVE_CONFIG_H /DMK_OS_W32=1 /DWIN32 /D_CONSOLE
msvc_CPPFLAGS += /I$(OUTDIR)src /I$(SRCDIR)/src /I$(SRCDIR)/src/w32/include /I$(OUTDIR)lib /I$(SRCDIR)/lib
msvc_CFLAGS = /nologo /MT /W4 /EHsc
@ -54,6 +57,7 @@ msvc_LDFLAGS = /nologo /SUBSYSTEM:console /PDB:$(BASE_PROG).pdb
msvc_LDLIBS = $(addsuffix .lib,$(w32_LIBS))
msvc_C_SOURCE = /c
msvc_RC_SOURCE =
msvc_OUTPUT_OPTION = /Fo$@
msvc_LINK_OUTPUT = /OUT:$@
@ -68,6 +72,7 @@ debug_msvc_LDFLAGS = /DEBUG
# --- GCC
gcc_CC = gcc
gcc_RC = windres
gcc_LD = $(gcc_CC)
release_gcc_OUTDIR = ./GccRel/
@ -79,6 +84,7 @@ gcc_LDFLAGS = -mthreads -gdwarf-2 -g3
gcc_LDLIBS = $(addprefix -l,$(w32_libs))
gcc_C_SOURCE = -c
gcc_RC_SOURCE = -i
gcc_OUTPUT_OPTION = -o $@
gcc_LINK_OUTPUT = -o $@
@ -87,6 +93,7 @@ release_gcc_CFLAGS = -O2
# ---
RES_COMPILE.cmd = $(RC) $(OUTPUT_OPTION) $(RC_SOURCE) $1
LINK.cmd = $(LD) $(extra_LDFLAGS) $(LDFLAGS) $(TARGET_ARCH) $1 $(LDLIBS) $(LINK_OUTPUT)
CHECK.cmd = cmd /c cd tests \& .\run_make_tests.bat -make ../$(PROG)
@ -96,9 +103,11 @@ RM.cmd = cmd /c del /F /Q $(call P2W,$1)
CP.cmd = cmd /c copy /Y $(call P2W,$1 $2)
CC = $($(TOOLCHAIN)_CC)
RC = $($(TOOLCHAIN)_RC)
LD = $($(TOOLCHAIN)_LD)
C_SOURCE = $($(TOOLCHAIN)_C_SOURCE)
RC_SOURCE = $($(TOOLCHAIN)_RC_SOURCE)
OUTPUT_OPTION = $($(TOOLCHAIN)_OUTPUT_OPTION)
LINK_OUTPUT = $($(TOOLCHAIN)_LINK_OUTPUT)
@ -120,3 +129,11 @@ LDLIBS = $(call _CUSTOM,LDLIBS)
$(OUTDIR)src/config.h: $(SRCDIR)/src/config.h.W32
$(call CP.cmd,$<,$@)
w32_UTF8OBJ = $(OUTDIR)src/w32/utf8.$(OBJEXT)
$(w32_UTF8OBJ): $(utf8_SOURCES)
$(call RES_COMPILE.cmd,$<)
ifneq (, $(shell where $(RC) 2>nul))
RESOURCE_OBJECTS = $(w32_UTF8OBJ)
endif

View File

@ -1,8 +1,8 @@
# GNU -*-Makefile-*- to build GNU make on MS-DOS with DJGPP
# GNU -*-Makefile-*- to build GNU Make on MS-DOS with DJGPP
#
# MS-DOS overrides for use with Basic.mk.
#
# Copyright (C) 2017-2019 Free Software Foundation, Inc.
# Copyright (C) 2017-2024 Free Software Foundation, Inc.
# This file is part of GNU Make.
#
# GNU Make is free software; you can redistribute it and/or modify it under
@ -16,7 +16,7 @@
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
# this program. If not, see <https://www.gnu.org/licenses/>.
OBJEXT = o
EXEEXT = .exe

View File

@ -13,12 +13,14 @@ hr
id
it
ja
ka
ko
lt
nl
pl
pt
pt_BR
ro
ru
sr
sv

View File

@ -1,5 +1,5 @@
# List of source files containing translatable strings.
# Copyright (C) 2000-2019 Free Software Foundation, Inc.
# Copyright (C) 2000-2024 Free Software Foundation, Inc.
# This file is part of GNU Make.
#
# GNU Make is free software; you can redistribute it and/or modify it under
@ -13,7 +13,7 @@
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
# this program. If not, see <https://www.gnu.org/licenses/>.
src/ar.c
src/arscan.c
@ -31,17 +31,18 @@ src/load.c
src/main.c
src/misc.c
src/output.c
src/output.h
src/posixos.c
src/read.c
src/remake.c
src/remote-cstms.c
src/rule.c
src/shuffle.c
src/signame.c
src/strcache.c
src/variable.c
src/variable.h
src/vmsfunctions.c
src/vmsjobs.c
src/vpath.c
src/warning.c
src/warning.h
src/w32/w32os.c

View File

@ -4,28 +4,27 @@ $!
$! This is used for building off the master instead of a release tarball.
$!
$!
$!
$! First try ODS-5, Pathworks V6 or UNZIP name.
$!
$ config_template = f$search("sys$disk:[]config*h-vms.template")
$ config_template = f$search("sys$disk:[.src]mkconfig*h.in")
$ if config_template .eqs. ""
$ then
$!
$! Try NFS, VMStar, or Pathworks V5 ODS-2 encoded name.
$!
$ config_template = f$search("sys$disk:[]config.h-vms*template")
$ config_template = f$search("sys$disk:[.src]mkconfig.h*in")
$ if config_template .eqs. ""
$ then
$ write sys$output "Could not find config.h-vms*template!"
$ write sys$output "Could not find mkconfig.h.in!"
$ exit 44
$ endif
$ endif
$ config_template_file = f$parse(config_template,,,"name")
$ config_template_type = f$parse(config_template,,,"type")
$ config_template = "sys$disk:[]" + config_template_file + config_template_type
$ config_template = "sys$disk:[.src]" + config_template_file + config_template_type
$!
$!
$! Pull the package and version from configure.ac
$! Pull the version from configure.ac
$!
$ open/read ac_file sys$disk:[]configure.ac
$ac_read_loop:
@ -39,21 +38,26 @@ $ version = f$element (0,"]",version)
$ac_read_loop_end:
$ close ac_file
$!
$ if (package .eqs. "") .or. (version .eqs. "")
$ if (version .eqs. "")
$ then
$ write sys$output "Unable to determine package and/or version!"
$ write sys$output "Unable to determine version!"
$ exit 44
$ endif
$!
$!
$ outfile = "sys$disk:[]config.h-vms"
$ outfile = "sys$disk:[.src]mkconfig.h"
$!
$! Note the pipe command is close to the length of 255, which is the
$! maximum token length prior to VMS V8.2:
$! %DCL-W-TKNOVF, command element is too long - shorten
$ pipe (write sys$output "sub/%PACKAGE%/''package'/WHOLE/NOTYPE" ;-
write sys$output "sub/%VERSION%/''version'/WHOLE/NOTYPE" ;-
$! PDS: Blown out; someone else will have to figure this out
$ pipe (write sys$output "sub,@PACKAGE@,make,WHOLE/NOTYPE" ;-
write sys$output "sub,@PACKAGE_BUGREPORT@,bug-make@gnu.org,WHOLE/NOTYPE" ;-
write sys$output "sub,@PACKAGE_NAME@,GNU Make,WHOLE/NOTYPE" ;-
write sys$output "sub,@PACKAGE_TARNAME@,make,WHOLE/NOTYPE" ;-
write sys$output "sub,@PACKAGE_URL@,https://www.gnu.org/software/make/,WHOLE/NOTYPE" ;-
write sys$output "sub,@PACKAGE_VERSION@,''version',WHOLE/NOTYPE" ;-
write sys$output "exit") |-
edit/edt 'config_template'/out='outfile'/command=sys$pipe >nla0:
$!
$ write sys$output package, ", version: ", version, " prepared for VMS"
$ write sys$output "GNU Make version: ", version, " prepared for VMS"

View File

@ -1,9 +1,9 @@
#!/bin/sh
#
# Copyright (C) 2014-2019 Free Software Foundation, Inc.
# Copyright (C) 2014-2024 Free Software Foundation, Inc.
# This file is part of GNU Make.
#
# Update GNU make copyrights using gnulib update-copyright
# Update GNU Make copyrights using gnulib update-copyright
EXCLUDE='^\(\.[a-z].*\|.*/\.[a-z].*\|.*COPYING\|src/hash\.[ch]\|ChangeLog.*\|.*/ChangeLog.*\|INSTALL\|doc/make\.texi\|bootstrap\)$'
@ -17,7 +17,7 @@ getfiles () {
run () {
cmd=$(command -v "$update") || die "Cannot locate update-copyright ($update)"
[ -x "$cmd" ] || die "Cannot locate update-copyright ($update)"
test -x "$cmd" || die "Cannot locate update-copyright ($update)"
force=false
@ -30,9 +30,9 @@ run () {
if $force; then
: just do it
elif [ ! -f src/makeint.h ]; then
die "Run in the root of the GNU make workspace"
elif [ -f configure ]; then
elif test ! -f src/makeint.h; then
die "Run in the root of the GNU Make workspace"
elif test -f configure; then
die "Run in a clean workspace (git clean -fdX)"
fi
@ -60,4 +60,4 @@ run "$@"
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
# this program. If not, see <https://www.gnu.org/licenses/>.

View File

@ -1,117 +0,0 @@
/* Running commands on Amiga
Copyright (C) 1995-2019 Free Software Foundation, Inc.
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation; either version 3 of the License, or (at your option) any later
version.
GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. */
#include "makeint.h"
#include "variable.h"
#include "amiga.h"
#include <assert.h>
#include <exec/memory.h>
#include <dos/dostags.h>
#include <proto/exec.h>
#include <proto/dos.h>
static const char Amiga_version[] = "$VER: Make 3.74.3 (12.05.96) \n"
"Amiga Port by A. Digulla (digulla@home.lake.de)";
int
MyExecute (char **argv)
{
char * buffer, * ptr;
char ** aptr;
int len = 0;
int status;
for (aptr=argv; *aptr; aptr++)
{
len += strlen (*aptr) + 4;
}
buffer = AllocMem (len, MEMF_ANY);
if (!buffer)
O (fatal, NILF, "MyExecute: Cannot allocate space for calling a command\n");
ptr = buffer;
for (aptr=argv; *aptr; aptr++)
{
if (((*aptr)[0] == ';' && !(*aptr)[1]))
{
*ptr ++ = '"';
strcpy (ptr, *aptr);
ptr += strlen (ptr);
*ptr ++ = '"';
}
else if ((*aptr)[0] == '@' && (*aptr)[1] == '@' && !(*aptr)[2])
{
*ptr ++ = '\n';
continue;
}
else
{
strcpy (ptr, *aptr);
ptr += strlen (ptr);
}
*ptr ++ = ' ';
*ptr = 0;
}
ptr[-1] = '\n';
status = SystemTags (buffer,
SYS_UserShell, TRUE,
TAG_END);
FreeMem (buffer, len);
if (SetSignal (0L,0L) & SIGBREAKF_CTRL_C)
status = 20;
/* Warnings don't count */
if (status == 5)
status = 0;
return status;
}
char *
wildcard_expansion (char *wc, char *o)
{
# define PATH_SIZE 1024
struct AnchorPath * apath;
if ( (apath = AllocMem (sizeof (struct AnchorPath) + PATH_SIZE,
MEMF_CLEAR))
)
{
apath->ap_Strlen = PATH_SIZE;
if (MatchFirst (wc, apath) == 0)
{
do
{
o = variable_buffer_output (o, apath->ap_Buf,
strlen (apath->ap_Buf));
o = variable_buffer_output (o, " ",1);
} while (MatchNext (apath) == 0);
}
MatchEnd (apath);
FreeMem (apath, sizeof (struct AnchorPath) + PATH_SIZE);
}
return o;
}

View File

@ -1,5 +1,5 @@
/* Interface to 'ar' archives for GNU Make.
Copyright (C) 1988-2019 Free Software Foundation, Inc.
Copyright (C) 1988-2024 Free Software Foundation, Inc.
This file is part of GNU Make.
@ -13,7 +13,7 @@ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. */
this program. If not, see <https://www.gnu.org/licenses/>. */
#include "makeint.h"
@ -22,6 +22,7 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
#include "filedef.h"
#include "dep.h"
#include <fnmatch.h>
#include <intprops.h>
/* Return nonzero if NAME is an archive-member reference, zero if not. An
archive-member reference is a name like 'lib(member)' where member is a
@ -35,7 +36,7 @@ ar_name (const char *name)
const char *p = strchr (name, '(');
const char *end;
if (p == 0 || p == name)
if (p == NULL || p == name)
return 0;
end = p + strlen (p) - 1;
@ -60,6 +61,9 @@ ar_parse_name (const char *name, char **arname_p, char **memname_p)
*arname_p = xstrdup (name);
p = strchr (*arname_p, '(');
/* This is never called unless ar_name() is true so p cannot be NULL. */
if (!p)
OS (fatal, NILF, "INTERNAL: ar_parse_name: bad name '%s'", *arname_p);
*(p++) = '\0';
p[strlen (p) - 1] = '\0';
*memname_p = p;
@ -69,10 +73,10 @@ ar_parse_name (const char *name, char **arname_p, char **memname_p)
/* This function is called by 'ar_scan' to find which member to look at. */
/* ARGSUSED */
static long int
static intmax_t
ar_member_date_1 (int desc UNUSED, const char *mem, int truncated,
long int hdrpos UNUSED, long int datapos UNUSED,
long int size UNUSED, long int date,
long int size UNUSED, intmax_t date,
int uid UNUSED, int gid UNUSED, unsigned int mode UNUSED,
const void *name)
{
@ -86,7 +90,7 @@ ar_member_date (const char *name)
{
char *arname;
char *memname;
long int val;
intmax_t val;
ar_parse_name (name, &arname, &memname);
@ -111,12 +115,12 @@ ar_member_date (const char *name)
free (arname);
return (val <= 0 ? (time_t) -1 : (time_t) val);
return 0 < val && val <= TYPE_MAXIMUM (time_t) ? val : -1;
}
/* Set the archive-member NAME's modtime to now. */
#ifdef VMS
#if MK_OS_VMS
int
ar_touch (const char *name)
{
@ -144,7 +148,7 @@ ar_touch (const char *name)
switch (ar_member_touch (arname, memname))
{
case -1:
OS (error, NILF, _("touch: Archive '%s' does not exist"), arname);
OS (error, NILF, _("touch: archive '%s' does not exist"), arname);
break;
case -2:
OS (error, NILF, _("touch: '%s' is not a valid archive"), arname);
@ -154,21 +158,21 @@ ar_touch (const char *name)
break;
case 1:
OSS (error, NILF,
_("touch: Member '%s' does not exist in '%s'"), memname, arname);
_("touch: member '%s' does not exist in '%s'"), memname, arname);
break;
case 0:
val = 0;
break;
default:
OS (error, NILF,
_("touch: Bad return code from ar_member_touch on '%s'"), name);
_("touch: bad return code from ar_member_touch on '%s'"), name);
}
free (arname);
return val;
}
#endif /* !VMS */
#endif /* !MK_OS_VMS */
/* State of an 'ar_glob' run, passed to 'ar_glob_match'. */
@ -183,7 +187,7 @@ struct ar_glob_state
{
const char *arname;
const char *pattern;
#ifdef VMS
#if MK_OS_VMS
char *suffix;
#endif
size_t size;
@ -194,10 +198,10 @@ struct ar_glob_state
/* This function is called by 'ar_scan' to match one archive
element against the pattern in STATE. */
static long int
static intmax_t
ar_glob_match (int desc UNUSED, const char *mem, int truncated UNUSED,
long int hdrpos UNUSED, long int datapos UNUSED,
long int size UNUSED, long int date UNUSED, int uid UNUSED,
long int size UNUSED, intmax_t date UNUSED, int uid UNUSED,
int gid UNUSED, unsigned int mode UNUSED, const void *arg)
{
struct ar_glob_state *state = (struct ar_glob_state *)arg;
@ -206,7 +210,7 @@ ar_glob_match (int desc UNUSED, const char *mem, int truncated UNUSED,
{
/* We have a match. Add it to the chain. */
struct nameseq *new = xcalloc (state->size);
#ifdef VMS
#if MK_OS_VMS
if (state->suffix)
new->name = strcache_add(
concat(5, state->arname, "(", mem, state->suffix, ")"));
@ -218,7 +222,7 @@ ar_glob_match (int desc UNUSED, const char *mem, int truncated UNUSED,
++state->n;
}
return 0L;
return 0;
}
/* Return nonzero if PATTERN contains any metacharacters.
@ -264,7 +268,7 @@ ar_glob (const char *arname, const char *member_pattern, size_t size)
struct nameseq *n;
const char **names;
unsigned int i;
#ifdef VMS
#if MK_OS_VMS
char *vms_member_pattern;
#endif
if (! ar_glob_pattern_p (member_pattern, 1))
@ -274,7 +278,7 @@ ar_glob (const char *arname, const char *member_pattern, size_t size)
ar_glob_match will accumulate them in STATE.chain. */
state.arname = arname;
state.pattern = member_pattern;
#ifdef VMS
#if MK_OS_VMS
{
/* In a copy of the pattern, find the suffix, save it and remove it from
the pattern */
@ -295,7 +299,7 @@ ar_glob (const char *arname, const char *member_pattern, size_t size)
state.n = 0;
ar_scan (arname, ar_glob_match, &state);
#ifdef VMS
#if MK_OS_VMS
/* Deallocate any duplicated string */
free(vms_member_pattern);
if (state.suffix)

View File

@ -1,5 +1,5 @@
/* Library function for scanning an archive file.
Copyright (C) 1987-2019 Free Software Foundation, Inc.
Copyright (C) 1987-2024 Free Software Foundation, Inc.
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify it under the
@ -12,7 +12,7 @@ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. */
this program. If not, see <https://www.gnu.org/licenses/>. */
#include "makeint.h"
@ -29,7 +29,7 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef NO_ARCHIVES
#ifdef VMS
#if MK_OS_VMS
#include <lbrdef.h>
#include <mhddef.h>
#include <credef.h>
@ -75,9 +75,9 @@ static void *VMS_lib_idx;
static const void *VMS_saved_arg;
static long int (*VMS_function) ();
static intmax_t (*VMS_function) ();
static long int VMS_function_ret;
static intmax_t VMS_function_ret;
/* This is a callback procedure for lib$get_index */
@ -203,7 +203,7 @@ VMS_get_member_info(struct dsc$descriptor_s *module, unsigned long *rfa)
Returns -2 if archive has invalid format.
Returns 0 if have scanned successfully. */
long int
intmax_t
ar_scan (const char *archive, ar_member_func_t function, const void *varg)
{
char *vms_archive;
@ -289,11 +289,11 @@ ar_scan (const char *archive, ar_member_func_t function, const void *varg)
return -2;
}
#else /* !VMS */
#else /* !MK_OS_VMS */
/* SCO Unix's compiler defines both of these. */
#ifdef M_UNIX
#undef M_XENIX
#ifdef M_UNIX
#undef M_XENIX
#endif
/* On the sun386i and in System V rel 3, ar.h defines two different archive
@ -302,7 +302,7 @@ ar_scan (const char *archive, ar_member_func_t function, const void *varg)
to have a nonzero value. */
#if (!defined (PORTAR) || PORTAR == 0) && (!defined (PORT5AR) || PORT5AR == 0)
#undef PORTAR
#undef PORTAR
#ifdef M_XENIX
/* According to Jim Sievert <jas1@rsvl.unisys.com>, for SCO XENIX defining
PORTAR to 1 gets the wrong archive format, and defining it to 0 gets the
@ -330,8 +330,8 @@ ar_scan (const char *archive, ar_member_func_t function, const void *varg)
# define __AR_BIG__
#endif
#ifndef WINDOWS32
# if !defined (__ANDROID__) && !defined (__BEOS__)
#if !MK_OS_W32
# if !defined (__ANDROID__) && !defined (__BEOS__) && !defined(MK_OS_ZOS)
# include <ar.h>
# else
/* These platforms don't have <ar.h> but have archives in the same format
@ -376,8 +376,37 @@ struct ar_hdr
# define AR_HDR_SIZE (sizeof (struct ar_hdr))
#endif
#include "intprops.h"
#include "output.h"
static uintmax_t
parse_int (const char *ptr, const size_t len, const int base, uintmax_t max,
const char *type, const char *archive, const char *name)
{
const char *const ep = ptr + len;
const int maxchar = '0' + base - 1;
uintmax_t val = 0;
/* In all the versions I know of the spaces come last, but be safe. */
while (ptr < ep && *ptr == ' ')
++ptr;
while (ptr < ep && *ptr != ' ')
{
if (*ptr < '0' || *ptr > maxchar
|| INT_MULTIPLY_WRAPV (val, base, &val)
|| INT_ADD_WRAPV (val, *ptr - '0', &val)
|| val > max)
OSSS (fatal, NILF,
_("invalid %s for archive %s member %s"), type, archive, name);
++ptr;
}
return val;
}
/* Takes three arguments ARCHIVE, FUNCTION and ARG.
Open the archive named ARCHIVE, find its members one by one,
@ -405,7 +434,7 @@ struct ar_hdr
Returns -2 if archive has invalid format.
Returns 0 if have scanned successfully. */
long int
intmax_t
ar_scan (const char *archive, ar_member_func_t function, const void *arg)
{
#ifdef AIAMAG
@ -416,7 +445,7 @@ ar_scan (const char *archive, ar_member_func_t function, const void *arg)
# endif
#endif
char *namemap = 0;
int namemap_size = 0;
unsigned int namemap_size = 0;
int desc = open (archive, O_RDONLY, 0);
if (desc < 0)
return -1;
@ -516,7 +545,7 @@ ar_scan (const char *archive, ar_member_func_t function, const void *arg)
while (1)
{
int nread;
ssize_t nread;
struct ar_hdr member_header;
#ifdef AIAMAGBIG
struct ar_hdr_big member_header_big;
@ -525,7 +554,7 @@ ar_scan (const char *archive, ar_member_func_t function, const void *arg)
# define ARNAME_MAX 255
char name[ARNAME_MAX + 1];
int name_len;
long int dateval;
intmax_t dateval;
int uidval, gidval;
long int data_offset;
#else
@ -537,9 +566,13 @@ ar_scan (const char *archive, ar_member_func_t function, const void *arg)
#endif
long int eltsize;
unsigned int eltmode;
long int fnval;
intmax_t eltdate;
int eltuid, eltgid;
intmax_t fnval;
off_t o;
memset(&member_header, '\0', sizeof (member_header));
EINTRLOOP (o, lseek (desc, member_offset, 0));
if (o < 0)
goto invalid;
@ -566,7 +599,7 @@ ar_scan (const char *archive, ar_member_func_t function, const void *arg)
name[name_len] = '\0';
sscanf (member_header_big.ar_date, "%12ld", &dateval);
sscanf (member_header_big.ar_date, "%12" SCNdMAX, &dateval);
sscanf (member_header_big.ar_uid, "%12d", &uidval);
sscanf (member_header_big.ar_gid, "%12d", &gidval);
sscanf (member_header_big.ar_mode, "%12o", &eltmode);
@ -594,7 +627,7 @@ ar_scan (const char *archive, ar_member_func_t function, const void *arg)
name[name_len] = '\0';
sscanf (member_header.ar_date, "%12ld", &dateval);
sscanf (member_header.ar_date, "%12" SCNdMAX, &dateval);
sscanf (member_header.ar_uid, "%12d", &uidval);
sscanf (member_header.ar_gid, "%12d", &gidval);
sscanf (member_header.ar_mode, "%12o", &eltmode);
@ -669,10 +702,11 @@ ar_scan (const char *archive, ar_member_func_t function, const void *arg)
&& (name[0] == ' ' || name[0] == '/')
&& namemap != 0)
{
int name_off = atoi (name + 1);
int name_len;
const char* err;
unsigned int name_off = make_toui (name + 1, &err);
size_t name_len;
if (name_off < 0 || name_off >= namemap_size)
if (err|| name_off >= namemap_size)
goto invalid;
name = namemap + name_off;
@ -685,14 +719,15 @@ ar_scan (const char *archive, ar_member_func_t function, const void *arg)
&& name[1] == '1'
&& name[2] == '/')
{
int name_len = atoi (name + 3);
const char* err;
unsigned int name_len = make_toui (name + 3, &err);
if (name_len < 1)
if (err || name_len == 0 || name_len >= MIN (PATH_MAX, INT_MAX))
goto invalid;
name = alloca (name_len + 1);
nread = readbuf (desc, name, name_len);
if (nread != name_len)
if (nread < 0 || (unsigned int) nread != name_len)
goto invalid;
name[name_len] = '\0';
@ -703,8 +738,16 @@ ar_scan (const char *archive, ar_member_func_t function, const void *arg)
}
#ifndef M_XENIX
sscanf (TOCHAR (member_header.ar_mode), "%o", &eltmode);
eltsize = atol (TOCHAR (member_header.ar_size));
#define PARSE_INT(_m, _t, _b, _n) \
(_t) parse_int (TOCHAR (member_header._m), sizeof (member_header._m), \
_b, TYPE_MAXIMUM (_t), _n, archive, name)
eltmode = PARSE_INT (ar_mode, unsigned int, 8, "mode");
eltsize = PARSE_INT (ar_size, long, 10, "size");
eltdate = PARSE_INT (ar_date, intmax_t, 10, "date");
eltuid = PARSE_INT (ar_uid, int, 10, "uid");
eltgid = PARSE_INT (ar_gid, int, 10, "gid");
#undef PARSE_INT
#else /* Xenix. */
eltmode = (unsigned short int) member_header.ar_mode;
eltsize = member_header.ar_size;
@ -714,9 +757,7 @@ ar_scan (const char *archive, ar_member_func_t function, const void *arg)
(*function) (desc, name, ! long_name, member_offset,
member_offset + AR_HDR_SIZE, eltsize,
#ifndef M_XENIX
atol (TOCHAR (member_header.ar_date)),
atoi (TOCHAR (member_header.ar_uid)),
atoi (TOCHAR (member_header.ar_gid)),
eltdate, eltuid, eltgid,
#else /* Xenix. */
member_header.ar_date,
member_header.ar_uid,
@ -796,7 +837,7 @@ ar_scan (const char *archive, ar_member_func_t function, const void *arg)
close (desc);
return -2;
}
#endif /* !VMS */
#endif /* !MK_OS_VMS */
/* Return nonzero iff NAME matches MEM.
If TRUNCATED is nonzero, MEM may be truncated to
@ -807,11 +848,16 @@ ar_name_equal (const char *name, const char *mem, int truncated)
{
const char *p;
/* GNU ar allows -P to preserve parent paths, so test the literal name
before stripping off the directory. */
if (streq (name, mem))
return 1;
p = strrchr (name, '/');
if (p != 0)
name = p + 1;
#ifndef VMS
#if !MK_OS_VMS
if (truncated)
{
#ifdef AIAMAG
@ -851,15 +897,15 @@ ar_name_equal (const char *name, const char *mem, int truncated)
match = !strcasecmp (name, mem);
return match;
}
#endif /* !VMS */
#endif /* !MK_OS_VMS */
}
#ifndef VMS
#if !MK_OS_VMS
/* ARGSUSED */
static long int
static intmax_t
ar_member_pos (int desc UNUSED, const char *mem, int truncated,
long int hdrpos, long int datapos UNUSED, long int size UNUSED,
long int date UNUSED, int uid UNUSED, int gid UNUSED,
intmax_t date UNUSED, int uid UNUSED, int gid UNUSED,
unsigned int mode UNUSED, const void *name)
{
if (!ar_name_equal (name, mem, truncated))
@ -877,12 +923,13 @@ ar_member_pos (int desc UNUSED, const char *mem, int truncated,
int
ar_member_touch (const char *arname, const char *memname)
{
long int pos = ar_scan (arname, ar_member_pos, memname);
intmax_t pos = ar_scan (arname, ar_member_pos, memname);
off_t opos;
int fd;
struct ar_hdr ar_hdr;
off_t o;
int r;
unsigned int ui;
int datelen;
struct stat statbuf;
if (pos < 0)
@ -890,11 +937,13 @@ ar_member_touch (const char *arname, const char *memname)
if (!pos)
return 1;
opos = (off_t) pos;
EINTRLOOP (fd, open (arname, O_RDWR, 0666));
if (fd < 0)
return -3;
/* Read in this member's header */
EINTRLOOP (o, lseek (fd, pos, 0));
EINTRLOOP (o, lseek (fd, opos, 0));
if (o < 0)
goto lose;
r = readbuf (fd, &ar_hdr, AR_HDR_SIZE);
@ -905,16 +954,17 @@ ar_member_touch (const char *arname, const char *memname)
if (r < 0)
goto lose;
/* Advance member's time to that time */
#if defined(ARFMAG) || defined(ARFZMAG) || defined(AIAMAG) || defined(WINDOWS32)
for (ui = 0; ui < sizeof ar_hdr.ar_date; ui++)
ar_hdr.ar_date[ui] = ' ';
sprintf (TOCHAR (ar_hdr.ar_date), "%lu", (long unsigned) statbuf.st_mtime);
ar_hdr.ar_date[strlen ((char *) ar_hdr.ar_date)] = ' ';
#if defined(ARFMAG) || defined(ARFZMAG) || defined(AIAMAG) || MK_OS_W32
datelen = snprintf (TOCHAR (ar_hdr.ar_date), sizeof ar_hdr.ar_date,
"%" PRIdMAX, (intmax_t) statbuf.st_mtime);
if (! (0 <= datelen && datelen < (int) sizeof ar_hdr.ar_date))
goto lose;
memset (ar_hdr.ar_date + datelen, ' ', sizeof ar_hdr.ar_date - datelen);
#else
ar_hdr.ar_date = statbuf.st_mtime;
#endif
/* Write back this member's header */
EINTRLOOP (o, lseek (fd, pos, 0));
EINTRLOOP (o, lseek (fd, opos, 0));
if (o < 0)
goto lose;
r = writebuf (fd, &ar_hdr, AR_HDR_SIZE);
@ -933,18 +983,21 @@ ar_member_touch (const char *arname, const char *memname)
#ifdef TEST
long int
intmax_t
describe_member (int desc, const char *name, int truncated,
long int hdrpos, long int datapos, long int size,
long int date, int uid, int gid, unsigned int mode,
intmax_t date, int uid, int gid, unsigned int mode,
const void *arg)
{
extern char *ctime ();
time_t d = date;
char const *ds;
printf (_("Member '%s'%s: %ld bytes at %ld (%ld).\n"),
name, truncated ? _(" (name might be truncated)") : "",
size, hdrpos, datapos);
printf (_(" Date %s"), ctime (&date));
ds = ctime (&d);
printf (_(" Date %s"), ds ? ds : "?");
printf (_(" uid = %d, gid = %d, mode = 0%o.\n"), uid, gid, mode);
return 0;

View File

@ -1,5 +1,5 @@
/* Command processing for GNU Make.
Copyright (C) 1988-2019 Free Software Foundation, Inc.
Copyright (C) 1988-2024 Free Software Foundation, Inc.
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify it under the
@ -12,28 +12,25 @@ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. */
this program. If not, see <https://www.gnu.org/licenses/>. */
#include "makeint.h"
#include "filedef.h"
#include "os.h"
#include "dep.h"
#include "variable.h"
#include "job.h"
#include "commands.h"
#ifdef WINDOWS32
#if MK_OS_W32
#include <windows.h>
#include "w32err.h"
#endif
#if VMS
#if MK_OS_VMS
# define FILE_LIST_SEPARATOR (vms_comma_separator ? ',' : ' ')
#else
# define FILE_LIST_SEPARATOR ' '
#endif
#ifndef HAVE_UNISTD_H
pid_t getpid ();
#endif
static unsigned long
@ -58,10 +55,13 @@ dep_hash_cmp (const void *x, const void *y)
return strcmp (dep_name (dx), dep_name (dy));
}
/* Set FILE's automatic variables up. */
/* Set FILE's automatic variables up.
* Use STEM to set $*.
* If STEM is 0, then set FILE->STEM and $* to the target name with any
* suffix in the .SUFFIXES list stripped off. */
void
set_file_variables (struct file *file)
set_file_variables (struct file *file, const char *stem)
{
struct dep *d;
const char *at, *percent, *star, *less;
@ -95,7 +95,7 @@ set_file_variables (struct file *file)
}
/* $* is the stem from an implicit or static pattern rule. */
if (file->stem == 0)
if (stem == 0)
{
/* In Unix make, $* is set to the target name with
any suffix in the .SUFFIXES list stripped off for
@ -118,25 +118,25 @@ set_file_variables (struct file *file)
for (d = enter_file (strcache_add (".SUFFIXES"))->deps; d ; d = d->next)
{
size_t slen = strlen (dep_name (d));
if (len > slen && strneq (dep_name (d), name + (len - slen), slen))
const char *dn = dep_name (d);
size_t slen = strlen (dn);
if (len > slen && memcmp (dn, name + (len - slen), slen) == 0)
{
file->stem = strcache_add_len (name, len - slen);
file->stem = stem = strcache_add_len (name, len - slen);
break;
}
}
if (d == 0)
file->stem = "";
file->stem = stem = "";
}
star = file->stem;
star = stem;
/* $< is the first not order-only dependency. */
less = "";
for (d = file->deps; d != 0; d = d->next)
if (!d->ignore_mtime)
if (!d->ignore_mtime && !d->ignore_automatic_vars && !d->need_2nd_expansion)
{
if (!d->need_2nd_expansion)
less = dep_name (d);
less = dep_name (d);
break;
}
@ -178,7 +178,7 @@ set_file_variables (struct file *file)
bar_len = 0;
for (d = file->deps; d != 0; d = d->next)
{
if (!d->need_2nd_expansion)
if (!d->need_2nd_expansion && !d->ignore_automatic_vars)
{
if (d->ignore_mtime)
bar_len += strlen (dep_name (d)) + 1;
@ -200,7 +200,7 @@ set_file_variables (struct file *file)
qmark_len = plus_len + 1; /* Will be this or less. */
for (d = file->deps; d != 0; d = d->next)
if (! d->ignore_mtime && ! d->need_2nd_expansion)
if (! d->ignore_mtime && ! d->need_2nd_expansion && ! d->ignore_automatic_vars)
{
const char *c = dep_name (d);
@ -214,8 +214,7 @@ set_file_variables (struct file *file)
#endif
len = strlen (c);
memcpy (cp, c, len);
cp += len;
cp = mempcpy (cp, c, len);
*cp++ = FILE_LIST_SEPARATOR;
if (! (d->changed || always_make_flag))
qmark_len -= len + 1; /* Don't space in $? for this one. */
@ -247,7 +246,7 @@ set_file_variables (struct file *file)
for (d = file->deps; d != 0; d = d->next)
{
if (d->need_2nd_expansion)
if (d->need_2nd_expansion || d->ignore_automatic_vars)
continue;
slot = hash_find_slot (&dep_hash, d);
@ -269,7 +268,7 @@ set_file_variables (struct file *file)
{
const char *c;
if (d->need_2nd_expansion || hash_find_item (&dep_hash, d) != d)
if (d->need_2nd_expansion || d->ignore_automatic_vars || hash_find_item (&dep_hash, d) != d)
continue;
c = dep_name (d);
@ -285,19 +284,16 @@ set_file_variables (struct file *file)
if (d->ignore_mtime)
{
memcpy (bp, c, len);
bp += len;
bp = mempcpy (bp, c, len);
*bp++ = FILE_LIST_SEPARATOR;
}
else
{
memcpy (cp, c, len);
cp += len;
cp = mempcpy (cp, c, len);
*cp++ = FILE_LIST_SEPARATOR;
if (d->changed || always_make_flag)
{
memcpy (qp, c, len);
qp += len;
qp = mempcpy (qp, c, len);
*qp++ = FILE_LIST_SEPARATOR;
}
}
@ -317,7 +313,7 @@ set_file_variables (struct file *file)
DEFINE_VARIABLE ("|", 1, bar_value);
}
#undef DEFINE_VARIABLE
#undef DEFINE_VARIABLE
}
/* Chop CMDS up into individual command lines if necessary.
@ -326,14 +322,12 @@ set_file_variables (struct file *file)
void
chop_commands (struct commands *cmds)
{
unsigned int nlines;
unsigned short idx;
unsigned short nlines;
unsigned short i;
char **lines;
/* If we don't have any commands,
or we already parsed them, never mind. */
if (!cmds || cmds->command_lines != 0)
/* If we don't have any commands, or we already parsed them, never mind. */
if (!cmds || cmds->command_lines != NULL)
return;
/* Chop CMDS->commands up into lines in CMDS->command_lines. */
@ -352,25 +346,27 @@ chop_commands (struct commands *cmds)
}
else
{
const char *p;
const char *p = cmds->commands;
size_t max = 5;
nlines = 5;
lines = xmalloc (nlines * sizeof (char *));
idx = 0;
p = cmds->commands;
nlines = 0;
lines = xmalloc (max * sizeof (char *));
while (*p != '\0')
{
const char *end = p;
find_end:;
end = strchr (end, '\n');
if (end == 0)
if (end == NULL)
end = p + strlen (p);
else if (end > p && end[-1] == '\\')
{
int backslash = 1;
const char *b;
for (b = end - 2; b >= p && *b == '\\'; --b)
backslash = !backslash;
if (end > p + 1)
{
const char *b;
for (b = end - 2; b >= p && *b == '\\'; --b)
backslash = !backslash;
}
if (backslash)
{
++end;
@ -378,40 +374,36 @@ chop_commands (struct commands *cmds)
}
}
if (idx == nlines)
if (nlines == USHRT_MAX)
ON (fatal, &cmds->fileinfo,
_("recipe has too many lines (limit %hu)"), nlines);
if (nlines == max)
{
nlines += 2;
lines = xrealloc (lines, nlines * sizeof (char *));
max += 2;
lines = xrealloc (lines, max * sizeof (char *));
}
lines[idx++] = xstrndup (p, (size_t) (end - p));
lines[nlines++] = xstrndup (p, (size_t) (end - p));
p = end;
if (*p != '\0')
++p;
}
if (idx != nlines)
{
nlines = idx;
lines = xrealloc (lines, nlines * sizeof (char *));
}
}
/* Finally, set the corresponding CMDS->lines_flags elements and the
CMDS->any_recurse flag. */
if (nlines > USHRT_MAX)
ON (fatal, &cmds->fileinfo, _("Recipe has too many lines (%ud)"), nlines);
cmds->ncommand_lines = (unsigned short)nlines;
cmds->ncommand_lines = nlines;
cmds->command_lines = lines;
cmds->any_recurse = 0;
cmds->lines_flags = xmalloc (nlines);
for (idx = 0; idx < nlines; ++idx)
for (i = 0; i < nlines; ++i)
{
unsigned char flags = 0;
const char *p = lines[idx];
const char *p = lines[i];
while (ISBLANK (*p) || *p == '-' || *p == '@' || *p == '+')
switch (*(p++))
@ -428,12 +420,12 @@ chop_commands (struct commands *cmds)
}
/* If no explicit '+' was given, look for MAKE variable references. */
if (!(flags & COMMANDS_RECURSE)
if (! ANY_SET (flags, COMMANDS_RECURSE)
&& (strstr (p, "$(MAKE)") != 0 || strstr (p, "${MAKE}") != 0))
flags |= COMMANDS_RECURSE;
cmds->lines_flags[idx] = flags;
cmds->any_recurse |= flags & COMMANDS_RECURSE ? 1 : 0;
cmds->lines_flags[i] = flags;
cmds->any_recurse |= ANY_SET (flags, COMMANDS_RECURSE) ? 1 : 0;
}
}
@ -465,12 +457,17 @@ execute_file_commands (struct file *file)
initialize_file_variables (file, 0);
set_file_variables (file);
set_file_variables (file, file->stem);
/* If this is a loaded dynamic object, unload it before remaking.
Some systems don't support overwriting a loaded object. */
if (file->loaded)
unload_file (file->name);
/* Some systems don't support overwriting a loaded object so if this one
unload it before remaking. Keep its name in .LOADED: it will be rebuilt
and loaded again. If rebuilding or loading again fail, then we'll exit
anyway and it won't matter. */
if (file->loaded && unload_file (file->name) == 0)
{
file->loaded = 0;
file->unloaded = 1;
}
/* Start the commands running. */
new_job (file);
@ -479,14 +476,14 @@ execute_file_commands (struct file *file)
/* This is set while we are inside fatal_error_signal,
so things can avoid nonreentrant operations. */
int handling_fatal_signal = 0;
volatile sig_atomic_t handling_fatal_signal = 0;
/* Handle fatal signals. */
RETSIGTYPE
void
fatal_error_signal (int sig)
{
#ifdef __MSDOS__
#if MK_OS_DOS
extern int dos_status, dos_command_running;
if (dos_command_running)
@ -497,18 +494,11 @@ fatal_error_signal (int sig)
}
remove_intermediates (1);
exit (EXIT_FAILURE);
#else /* not __MSDOS__ */
#ifdef _AMIGA
remove_intermediates (1);
if (sig == SIGINT)
fputs (_("*** Break.\n"), stderr);
exit (10);
#else /* not Amiga */
#ifdef WINDOWS32
#else /* not MK_OS_DOS */
#if MK_OS_W32
extern HANDLE main_thread;
/* Windows creates a sperate thread for handling Ctrl+C, so we need
/* Windows creates a separate thread for handling Ctrl+C, so we need
to suspend the main thread, or else we will have race conditions
when both threads call reap_children. */
if (main_thread)
@ -516,12 +506,12 @@ fatal_error_signal (int sig)
DWORD susp_count = SuspendThread (main_thread);
if (susp_count != 0)
fprintf (stderr, "SuspendThread: suspend count = %ld\n", susp_count);
fprintf (stderr, "SuspendThread: suspend count = %lu\n", susp_count);
else if (susp_count == (DWORD)-1)
{
DWORD ierr = GetLastError ();
fprintf (stderr, "SuspendThread: error %ld: %s\n",
fprintf (stderr, "SuspendThread: error %lu: %s\n",
ierr, map_windows32_error_to_string (ierr));
}
}
@ -532,6 +522,10 @@ fatal_error_signal (int sig)
It is blocked now while we run this handler. */
signal (sig, SIG_DFL);
temp_stdin_unlink ();
osync_clear ();
jobserver_clear ();
/* A termination signal won't be sent to the entire
process group, but it means we want to kill the children. */
@ -587,7 +581,7 @@ fatal_error_signal (int sig)
exit (MAKE_TROUBLE);
#endif
#ifdef WINDOWS32
#if MK_OS_W32
if (main_thread)
CloseHandle (main_thread);
/* Cannot call W32_kill with a pid (it needs a handle). The exit
@ -596,11 +590,10 @@ fatal_error_signal (int sig)
#else
/* Signal the same code; this time it will really be fatal. The signal
will be unblocked when we return and arrive then to kill us. */
if (kill (getpid (), sig) < 0)
if (kill (make_pid (), sig) < 0)
pfatal_with_name ("kill");
#endif /* not WINDOWS32 */
#endif /* not Amiga */
#endif /* not __MSDOS__ */
#endif /* not MK_OS_W32 */
#endif /* not MK_OS_DOS */
}
/* Delete FILE unless it's precious or not actually a file (phony),
@ -625,11 +618,11 @@ delete_target (struct file *file, const char *on_behalf_of)
{
if (on_behalf_of)
OSS (error, NILF,
_("*** [%s] Archive member '%s' may be bogus; not deleted"),
_("*** [%s] archive member '%s' may be bogus; not deleted"),
on_behalf_of, file->name);
else
OS (error, NILF,
_("*** Archive member '%s' may be bogus; not deleted"),
_("*** archive member '%s' may be bogus; not deleted"),
file->name);
}
return;
@ -643,9 +636,9 @@ delete_target (struct file *file, const char *on_behalf_of)
{
if (on_behalf_of)
OSS (error, NILF,
_("*** [%s] Deleting file '%s'"), on_behalf_of, file->name);
_("*** [%s] deleting file '%s'"), on_behalf_of, file->name);
else
OS (error, NILF, _("*** Deleting file '%s'"), file->name);
OS (error, NILF, _("*** deleting file '%s'"), file->name);
if (unlink (file->name) < 0
&& errno != ENOENT) /* It disappeared; so what. */
perror_with_name ("unlink: ", file->name);

View File

@ -1,5 +1,5 @@
/* Definition of data structures describing shell commands for GNU Make.
Copyright (C) 1988-2019 Free Software Foundation, Inc.
Copyright (C) 1988-2024 Free Software Foundation, Inc.
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify it under the
@ -12,7 +12,7 @@ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. */
this program. If not, see <https://www.gnu.org/licenses/>. */
/* Structure that gives the commands to make a file
and information about where these commands came from. */
@ -34,9 +34,12 @@ struct commands
#define COMMANDS_SILENT 2 /* Silent: @. */
#define COMMANDS_NOERROR 4 /* No errors: -. */
RETSIGTYPE fatal_error_signal (int sig);
struct file;
struct child;
void fatal_error_signal (int sig);
void execute_file_commands (struct file *file);
void print_commands (const struct commands *cmds);
void delete_child_targets (struct child *child);
void chop_commands (struct commands *cmds);
void set_file_variables (struct file *file);
void set_file_variables (struct file *file, const char *stem);

View File

@ -1,337 +0,0 @@
/* config.h -- hand-massaged for Amiga -*-C-*-
Copyright (C) 1995-2019 Free Software Foundation, Inc.
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation; either version 3 of the License, or (at your option) any later
version.
GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. */
/* Define if on AIX 3.
System headers sometimes define this.
We just want to avoid a redefinition error message. */
#ifndef _ALL_SOURCE
/* #undef _ALL_SOURCE */
#endif
/* Define if using alloca.c. */
#define C_ALLOCA
/* Define if the closedir function returns void instead of int. */
/* #undef CLOSEDIR_VOID */
/* Define to empty if the keyword does not work. */
/* #undef const */
/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems.
This function is required for alloca.c support on those systems. */
/* #undef CRAY_STACKSEG_END */
/* Define for DGUX with <sys/dg_sys_info.h>. */
/* #undef DGUX */
/* Define if the 'getloadavg' function needs to be run setuid or setgid. */
/* #undef GETLOADAVG_PRIVILEGED */
/* Define to 'unsigned long' or 'unsigned long long'
if <inttypes.h> doesn't define. */
#define uintmax_t unsigned long
/* Define to 'int' if <sys/types.h> doesn't define. */
#define gid_t int
/* Define if you have alloca, as a function or macro. */
/* #undef HAVE_ALLOCA */
/* Define if you have <alloca.h> and it should be used (not on Ultrix). */
/* #undef HAVE_ALLOCA_H */
/* Define if your system has a working fnmatch function. */
/* #undef HAVE_FNMATCH */
/* Define if your system has its own 'getloadavg' function. */
/* #undef HAVE_GETLOADAVG */
/* Define if you have the getmntent function. */
/* #undef HAVE_GETMNTENT */
/* Embed GNU Guile support */
/* #undef HAVE_GUILE */
/* Define if the 'long double' type works. */
/* #undef HAVE_LONG_DOUBLE */
/* Define if you support file names longer than 14 characters. */
#define HAVE_LONG_FILE_NAMES 1
/* Define if you have a working 'mmap' system call. */
/* #undef HAVE_MMAP */
/* Define if system calls automatically restart after interruption
by a signal. */
/* #undef HAVE_RESTARTABLE_SYSCALLS */
/* Define if your struct stat has st_blksize. */
/* #undef HAVE_ST_BLKSIZE */
/* Define if your struct stat has st_blocks. */
/* #undef HAVE_ST_BLOCKS */
/* Define if you have the strcoll function and it is properly defined. */
#define HAVE_STRCOLL 1
/* Define if your struct stat has st_rdev. */
#define HAVE_ST_RDEV 1
/* Define if you have the strftime function. */
#define HAVE_STRFTIME 1
/* Define if you have <sys/wait.h> that is POSIX.1 compatible. */
/* #undef HAVE_SYS_WAIT_H */
/* Define if your struct tm has tm_zone. */
/* #undef HAVE_TM_ZONE */
/* Define if you don't have tm_zone but do have the external array
tzname. */
#define HAVE_TZNAME 1
/* Define if you have <unistd.h>. */
#define HAVE_UNISTD_H 1
/* Define if utime(file, NULL) sets file's timestamp to the present. */
/* #undef HAVE_UTIME_NULL */
/* Define if you have the wait3 system call. */
/* #undef HAVE_WAIT3 */
/* Define if on MINIX. */
/* #undef _MINIX */
/* Define if your struct nlist has an n_un member. */
/* #undef NLIST_NAME_UNION */
/* Define if you have <nlist.h>. */
/* #undef NLIST_STRUCT */
/* Define if your C compiler doesn't accept -c and -o together. */
/* #undef NO_MINUS_C_MINUS_O */
/* Define to 'int' if <sys/types.h> doesn't define. */
#define pid_t int
/* Define if the system does not provide POSIX.1 features except
with this defined. */
/* #undef _POSIX_1_SOURCE */
/* Define if you need to in order for stat and other things to work. */
/* #undef _POSIX_SOURCE */
/* Define as the return type of signal handlers (int or void). */
#define RETSIGTYPE void
/* Define if the setvbuf function takes the buffering type as its second
argument and the buffer pointer as the third, as on System V
before release 3. */
/* #undef SETVBUF_REVERSED */
/* If using the C implementation of alloca, define if you know the
direction of stack growth for your system; otherwise it will be
automatically deduced at run-time.
STACK_DIRECTION > 0 => grows toward higher addresses
STACK_DIRECTION < 0 => grows toward lower addresses
STACK_DIRECTION = 0 => direction of growth unknown
*/
#define STACK_DIRECTION -1
/* Define if the 'S_IS*' macros in <sys/stat.h> do not work properly. */
/* #undef STAT_MACROS_BROKEN */
/* Define if you have the ANSI C header files. */
#define STDC_HEADERS
/* Define on System V Release 4. */
/* #undef SVR4 */
/* Define if 'sys_siglist' is declared by <signal.h>. */
/* #undef SYS_SIGLIST_DECLARED */
/* Define to 'int' if <sys/types.h> doesn't define. */
#define uid_t int
/* Define for Encore UMAX. */
/* #undef UMAX */
/* Define for Encore UMAX 4.3 that has <inq_status/cpustats.h>
instead of <sys/cpustats.h>. */
/* #undef UMAX4_3 */
/* Name of this package (needed by automake) */
#define PACKAGE "%PACKAGE%"
/* Version of this package (needed by automake) */
#define VERSION "%VERSION%"
/* Define to the name of the SCCS 'get' command. */
#define SCCS_GET "get"
/* Define this if the SCCS 'get' command understands the '-G<file>' option. */
/* #undef SCCS_GET_MINUS_G */
/* Define this to enable job server support in GNU make. */
/* #undef MAKE_JOBSERVER */
/* Define to be the nanoseconds member of struct stat's st_mtim,
if it exists. */
/* #undef ST_MTIM_NSEC */
/* Define this if the C library defines the variable 'sys_siglist'. */
/* #undef HAVE_SYS_SIGLIST */
/* Define this if the C library defines the variable '_sys_siglist'. */
/* #undef HAVE__SYS_SIGLIST */
/* Define this if you have the 'union wait' type in <sys/wait.h>. */
/* #undef HAVE_UNION_WAIT */
/* Define if you have the dup2 function. */
/* #undef HAVE_DUP2 */
/* Define if you have the getcwd function. */
#define HAVE_GETCWD 1
/* Define if you have the getgroups function. */
/* #undef HAVE_GETGROUPS */
/* Define if you have the gethostbyname function. */
/* #undef HAVE_GETHOSTBYNAME */
/* Define if you have the gethostname function. */
/* #undef HAVE_GETHOSTNAME */
/* Define if you have the memmove function. */
#define HAVE_MEMMOVE 1
/* Define if you have the mktemp function. */
#define HAVE_MKTEMP 1
/* Define if you have the psignal function. */
/* #undef HAVE_PSIGNAL */
/* Define if you have the pstat_getdynamic function. */
/* #undef HAVE_PSTAT_GETDYNAMIC */
/* Define if you have the setegid function. */
/* #undef HAVE_SETEGID */
/* Define if you have the seteuid function. */
/* #undef HAVE_SETEUID */
/* Define if you have the setlinebuf function. */
/* #undef HAVE_SETLINEBUF */
/* Define if you have the setregid function. */
/* #undef HAVE_SETREGID */
/* Define if you have the setreuid function. */
/* #undef HAVE_SETREUID */
/* Define if you have the sigsetmask function. */
/* #undef HAVE_SIGSETMASK */
/* Define if you have the socket function. */
/* #undef HAVE_SOCKET */
/* Define to 1 if you have the strcasecmp function. */
/* #undef HAVE_STRCASECMP */
/* Define to 1 if you have the strcmpi function. */
/* #undef HAVE_STRCMPI */
/* Define to 1 if you have the stricmp function. */
/* #undef HAVE_STRICMP */
/* Define if you have the strsignal function. */
/* #undef HAVE_STRSIGNAL */
/* Define if you have the wait3 function. */
/* #undef HAVE_WAIT3 */
/* Define if you have the waitpid function. */
/* #undef HAVE_WAITPID */
/* Define if you have the <dirent.h> header file. */
#define HAVE_DIRENT_H 1
/* Define if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
/* Define if you have the <limits.h> header file. */
#define HAVE_LIMITS_H 1
/* Define if you have the <mach/mach.h> header file. */
/* #undef HAVE_MACH_MACH_H */
/* Define if you have the <memory.h> header file. */
/* #undef HAVE_MEMORY_H */
/* Define if you have the <ndir.h> header file. */
/* #undef HAVE_NDIR_H */
/* Define if you have the <stdlib.h> header file. */
/* #undef HAVE_STDLIB_H */
/* Define if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define if you have the <sys/dir.h> header file. */
#define HAVE_SYS_DIR_H 1
/* Define if you have the <sys/ndir.h> header file. */
/* #undef HAVE_SYS_NDIR_H */
/* Define if you have the <sys/param.h> header file. */
/* #undef HAVE_SYS_PARAM_H */
/* Define if you have the <sys/timeb.h> header file. */
/* #undef HAVE_SYS_TIMEB_H */
/* Define if you have the <sys/wait.h> header file. */
/* #undef HAVE_SYS_WAIT_H */
/* Define if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define if you have the dgc library (-ldgc). */
/* #undef HAVE_LIBDGC */
/* Define if you have the kstat library (-lkstat). */
/* #undef HAVE_LIBKSTAT */
/* Define to 1 if you have the `isatty' function. */
/* #undef HAVE_ISATTY */
/* Define to 1 if you have the `ttyname' function. */
/* #undef HAVE_TTYNAME */
/* Define if you have the sun library (-lsun). */
/* #undef HAVE_LIBSUN */
/* Output sync sypport */
#define NO_OUTPUT_SYNC
/* Define for Case Insensitve behavior */
#define HAVE_CASE_INSENSITIVE_FS
/* Build host information. */
#define MAKE_HOST "Amiga"
/* Define to `int' if <sys/types.h> does not define. */
#define ssize_t int

View File

@ -1,6 +1,6 @@
/* config.h-vms. Generated by hand by Klaus Kämpf <kkaempf@rmi.de> -*-C-*-
Copyright (C) 1996-2019 Free Software Foundation, Inc.
Copyright (C) 1996-2024 Free Software Foundation, Inc.
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify it under the
@ -13,10 +13,11 @@ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. */
this program. If not, see <https://www.gnu.org/licenses/>. */
/* config.h. Generated automatically by configure. */
/* config.h.in. Generated automatically from configure.ac by autoheader. */
#include "mkconfig.h"
#define MK_OS_VMS 1
/* Pull in types.h here to get __CRTL_VER defined for old versions of the
compiler which don't define it. */
@ -65,8 +66,9 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
/* Define for DGUX with <sys/dg_sys_info.h>. */
/* #undef DGUX */
/* Define to 1 if the 'getloadavg' function needs to be run setuid or setgid. */
/* #undef GETLOADAVG_PRIVILEGED */
/* Define to the widest signed integer type if <stdint.h> and <inttypes.h> do
not define. */
#define intmax_t unsigned long
/* Define to 'unsigned long' or 'unsigned long long'
if <inttypes.h> doesn't define. */
@ -81,15 +83,15 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix). */
/* #undef HAVE_ALLOCA_H */
/* Define to 1 if you have the declaration of 'getloadavg'. */
/* #undef HAVE_DECL_GETLOADAVG */
/* Define to 1 if you have the fdopen function. */
#define HAVE_FDOPEN 1
/* Define to 1 if your system has a working fnmatch function. */
/* #undef HAVE_FNMATCH */
/* Define to 1 if your system has its own 'getloadavg' function. */
/* #undef HAVE_GETLOADAVG */
/* Define to 1 if you have the getmntent function. */
/* #undef HAVE_GETMNTENT */
@ -172,14 +174,6 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
/* Define to 1 if you need to in order for stat and other things to work. */
/* #undef _POSIX_SOURCE */
/* Define as the return type of signal handlers (int or void). */
#define RETSIGTYPE void
/* Define to 1 if the setvbuf function takes the buffering type as its second
argument and the buffer pointer as the third, as on System V
before release 3. */
/* #undef SETVBUF_REVERSED */
/* If using the C implementation of alloca, define if you know the
direction of stack growth for your system; otherwise it will be
automatically deduced at run-time.
@ -213,19 +207,13 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
instead of <sys/cpustats.h>. */
/* #undef UMAX4_3 */
/* Name of this package (needed by automake) */
#define PACKAGE "%PACKAGE%"
/* Version of this package (needed by automake) */
#define VERSION "%VERSION%"
/* Define to the name of the SCCS 'get' command. */
/* #undef SCCS_GET */
/* Define this if the SCCS 'get' command understands the '-G<file>' option. */
/* #undef SCCS_GET_MINUS_G */
/* Define this to enable job server support in GNU make. */
/* Define this to enable job server support in GNU Make. */
/* #undef MAKE_JOBSERVER */
/* Define to be the nanoseconds member of struct stat's st_mtim,
@ -259,6 +247,9 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
/* Define to 1 if you have the memmove function. */
#define HAVE_MEMMOVE 1
/* Define to 1 if you have the 'mkfifo' function. */
/* #undef HAVE_MKFIFO */
/* Define to 1 if you have the mktemp function. */
#define HAVE_MKTEMP 1
@ -301,6 +292,9 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
/* Define to 1 if you have the strsignal function. */
/* #undef HAVE_STRSIGNAL */
/* Define to 1 if you have the `strtoll' function. */
#define HAVE_STRTOLL 1
/* Define to 1 if you have the wait3 function. */
/* #undef HAVE_WAIT3 */
@ -324,6 +318,9 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
/* Define to 1 if you have the <memory.h> header file. */
/* #undef HAVE_MEMORY_H */
/* Define to 1 if you have the `mempcpy' function. */
/* #undef HAVE_MEMPCPY */
/* Define to 1 if you have the <ndir.h> header file. */
/* #undef HAVE_NDIR_H */
@ -342,11 +339,6 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
/* Define to 1 if you have the <sys/param.h> header file. */
/* #undef HAVE_SYS_PARAM_H */
/* Define to 1 if you have the <sys/timeb.h> header file. */
#ifndef __GNUC__
#define HAVE_SYS_TIMEB_H 1
#endif
/* Define to 1 if you have the <sys/wait.h> header file. */
/* #undef HAVE_SYS_WAIT_H */
@ -431,3 +423,6 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
/* Build host information. */
#define MAKE_HOST "VMS"
/* Include customized declarations. */
#include "../src/mkcustom.h"

View File

@ -1,6 +1,6 @@
/* config.h.W32 -- hand-massaged config.h file for Windows builds -*-C-*-
Copyright (C) 1996-2019 Free Software Foundation, Inc.
Copyright (C) 1996-2024 Free Software Foundation, Inc.
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify it under the
@ -13,34 +13,30 @@ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. */
this program. If not, see <https://www.gnu.org/licenses/>. */
#include "mkconfig.h"
/* Build for the Windows32 API. */
#define MK_OS_W32 1
/* Suppress some Visual C++ warnings.
Maybe after the code cleanup for ISO C we can remove some/all of these. */
#if _MSC_VER > 1000
# pragma warning(disable:4100) /* unreferenced formal parameter */
# pragma warning(disable:4102) /* unreferenced label */
# pragma warning(disable:4127) /* conditional expression is constant */
# pragma warning(disable:4130) /* logical operation on address of string constant */
# pragma warning(disable:4131) /* uses old-style declarator */
# pragma warning(disable:4702) /* unreachable code */
# define _CRT_SECURE_NO_WARNINGS /* function or variable may be unsafe */
# define _CRT_NONSTDC_NO_WARNINGS /* functions w/o a leading underscore */
# define _CRT_SECURE_NO_WARNINGS 1 /* function or variable may be unsafe */
# define _CRT_NONSTDC_NO_WARNINGS 1 /* functions w/o a leading underscore */
#endif
/* Define to 1 if the 'closedir' function returns void instead of 'int'. */
/* #undef CLOSEDIR_VOID */
/* Define to one of '_getb67', 'GETB67', 'getb67' for Cray-2 and Cray-YMP
systems. This function is required for 'alloca.c' support on those systems.
*/
/* #undef CRAY_STACKSEG_END */
/* Define to 1 if using 'alloca.c'. */
/* #undef C_ALLOCA */
/* Define to 1 if using 'getloadavg.c'. */
#define C_GETLOADAVG 1
/* Define to 1 for DGUX with <sys/dg_sys_info.h>. */
/* #undef DGUX */
@ -51,15 +47,11 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
/* Use high resolution file timestamps if nonzero. */
#define FILE_TIMESTAMP_HI_RES 0
/* Define to 1 if the 'getloadavg' function needs to be run setuid or setgid.
*/
/* #undef GETLOADAVG_PRIVILEGED */
/* Define to 1 if you have 'alloca', as a function or macro. */
/* Define to 1 if you have 'alloca' after including <alloca.h>, a header that
may be supplied by this distribution. */
#define HAVE_ALLOCA 1
/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
*/
/* Define to 1 if <alloca.h> works. */
/* #undef HAVE_ALLOCA_H */
/* Define to 1 if you have the 'atexit' function. */
@ -71,10 +63,6 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
/* Define to 1 if you have the clock_gettime function. */
/* #undef HAVE_CLOCK_GETTIME */
/* Embed GNU Guile support. Windows build sets this on the
compilation command line. */
/* #undef HAVE_GUILE */
/* Define if the GNU dcgettext() function is already present or preinstalled.
*/
/* #undef HAVE_DCGETTEXT */
@ -83,6 +71,21 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
don't. */
#define HAVE_DECL_BSD_SIGNAL 0
/* Define to 1 if you have the declaration of `dlerror', and to 0 if you
don't. */
#define HAVE_DECL_DLERROR 0
/* Define to 1 if you have the declaration of `dlopen', and to 0 if you don't.
*/
#define HAVE_DECL_DLOPEN 0
/* Define to 1 if you have the declaration of `dlsym', and to 0 if you don't.
*/
#define HAVE_DECL_DLSYM 0
/* Define to 1 if you have the declaration of 'getloadavg'. */
/* #undef HAVE_DECL_GETLOADAVG */
/* Define to 1 if you have the declaration of 'sys_siglist', and to 0 if you
don't. */
#define HAVE_DECL_SYS_SIGLIST 0
@ -102,13 +105,16 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
/* Define to 1 if you have the <direct.h> header file, and it defines getcwd()
and chdir().
*/
#if (defined(_MSC_VER) || defined(__BORLANDC__)) && !defined(__INTERIX)
#if (defined(_MSC_VER) || defined(__BORLANDC__) || defined(__TINYC__)) && !defined(__INTERIX)
# define HAVE_DIRECT_H 1
#endif
/* Use platform specific coding */
/* Support DOS-style pathnames. */
#define HAVE_DOS_PATHS 1
/* Define to 1 if you have the 'dup' function. */
#define HAVE_DUP 1
/* Define to 1 if you have the 'dup2' function. */
#define HAVE_DUP2 1
@ -120,8 +126,8 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
#define HAVE_FDOPEN 1
#endif
/* Define to 1 if you have the 'fileno' function. */
#define HAVE_FILENO 1
/* Define to 1 if you have the `fork' function. */
/* #undef HAVE_FORK */
/* Define to 1 if you have the 'getcwd' function. */
#define HAVE_GETCWD 1
@ -135,9 +141,6 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
/* Define to 1 if you have the 'gethostname' function. */
/* #undef HAVE_GETHOSTNAME */
/* Define to 1 if you have the 'getloadavg' function. */
/* #undef HAVE_GETLOADAVG */
/* Define to 1 if you have the 'getrlimit' function. */
/* #undef HAVE_GETRLIMIT */
@ -149,6 +152,10 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
#define HAVE_GETTIMEOFDAY 1
#endif
/* Embed GNU Guile support. Windows build sets this on the
compilation command line. */
/* #undef HAVE_GUILE */
/* Define if you have the iconv() function. */
/* #undef HAVE_ICONV */
@ -157,17 +164,26 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
#define HAVE_INTTYPES_H 1
#endif
/* Define to 1 if you have the `isatty' function. */
#define HAVE_ISATTY 1
/* Define to 1 if you have the 'dgc' library (-ldgc). */
/* #undef HAVE_LIBDGC */
/* Define to 1 if you have the 'kstat' library (-lkstat). */
/* #undef HAVE_LIBKSTAT */
/* Define to 1 if you have the `perfstat' library (-lperfstat). */
/* #undef HAVE_LIBPERFSTAT */
/* Define to 1 if you have the <limits.h> header file. */
#define HAVE_LIMITS_H 1
/* Define to 1 if you have the <locale.h> header file. */
/*#define HAVE_LOCALE_H 1*/
/* #undef HAVE_LOCALE_H */
/* Define to 1 if the system has the type 'long long int'. */
#define HAVE_LONG_LONG_INT 1
/* Define to 1 if you have the 'lstat' function. */
/* #undef HAVE_LSTAT */
@ -178,9 +194,24 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define to 1 if you have the `mempcpy' function. */
/* #undef HAVE_MEMPCPY */
/* Define to 1 if you have the `memrchr' function. */
/* #undef HAVE_MEMRCHR */
/* Define to 1 if you have the <minix/config.h> header file. */
/* #undef HAVE_MINIX_CONFIG_H */
/* Define to 1 if you have the 'mkfifo' function. */
/* #undef HAVE_MKFIFO */
/* Define to 1 if you have the 'mkstemp' function. */
/* #undef HAVE_MKSTEMP */
/* Define to 1 if you have the `mkstemp' function. */
/* #undef HAVE_MKSTEMP */
/* Define to 1 if you have the 'mktemp' function. */
#define HAVE_MKTEMP 1
@ -193,6 +224,15 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
/* Define to 1 if you have the 'pipe' function. */
/* #undef HAVE_PIPE */
/* Define to 1 if you have the `posix_spawn' function. */
/* #undef HAVE_POSIX_SPAWN */
/* Define to 1 if you have the `posix_spawnattr_setsigmask' function. */
/* #undef HAVE_POSIX_SPAWNATTR_SETSIGMASK */
/* Define to 1 if you have the `pselect' function. */
/* #undef HAVE_PSELECT */
/* Define to 1 if you have the 'pstat_getdynamic' function. */
/* #undef HAVE_PSTAT_GETDYNAMIC */
@ -214,9 +254,6 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
/* Define to 1 if you have the 'setlinebuf' function. */
/* #undef HAVE_SETLINEBUF */
/* Define to 1 if you have the 'setlocale' function. */
/*#define HAVE_SETLOCALE 1*/
/* Define to 1 if you have the 'setregid' function. */
/* #undef HAVE_SETREGID */
@ -238,16 +275,25 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
/* Define to 1 if you have the 'socket' function. */
/* #undef HAVE_SOCKET */
/* Define to 1 if you have the <spawn.h> header file. */
/* #undef HAVE_SPAWN_H */
/* Define to 1 if you have the <stdint.h> header file. */
#ifdef __MINGW32__
#define HAVE_STDINT_H 1
#endif
/* Define to 1 if you have the <stdio.h> header file. */
#define HAVE_STDIO_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the `stpcpy' function. */
/* #undef HAVE_STPCPY */
/* Define to 1 if you have the 'strcasecmp' function. */
#ifdef __MINGW32__
#if defined(__MINGW32__) || defined(__TINYC__)
#define HAVE_STRCASECMP 1
#endif
@ -261,6 +307,9 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
/* Define to 1 if you have the 'strdup' function. */
#define HAVE_STRDUP 1
/* Define to 1 if you have the `strerror' function. */
#define HAVE_STRERROR 1
/* Define to 1 if you have the 'stricmp' function. */
#define HAVE_STRICMP 1
@ -273,7 +322,7 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the 'strncasecmp' function. */
#ifdef __MINGW32__
#if defined(__MINGW32__) || defined(__TINYC__)
#define HAVE_STRNCASECMP 1
#endif
@ -291,19 +340,21 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
/* Define to 1 if you have the 'strsignal' function. */
/* #undef HAVE_STRSIGNAL */
/* Define to 1 if you have the `strtoll' function. */
#define HAVE_STRTOLL 1
#ifdef __TINYC__
# ifndef strtoll
# define strtoll _strtoi64
# endif
# ifndef strtoull
# define strtoull _strtoui64
# endif
#endif
/* Define to 1 if `d_type' is a member of `struct dirent'. */
#define HAVE_STRUCT_DIRENT_D_TYPE 1
/* Define to 1 if you have the `isatty' function. */
#define HAVE_ISATTY 1
/* Define to 1 if you have the `ttyname' function. */
#define HAVE_TTYNAME 1
char *ttyname (int);
/* Define to 1 if you have the `umask' function. */
#ifdef __MINGW32__
# define HAVE_UMASK 1
/* SV 57152: MinGW64 version of dirent doesn't support d_type. */
#ifndef __MINGW64__
# define HAVE_STRUCT_DIRENT_D_TYPE 1
#endif
/* Define to 1 if 'n_un.n_name' is a member of 'struct nlist'. */
@ -313,6 +364,12 @@ char *ttyname (int);
*/
/* #undef HAVE_SYS_DIR_H */
/* Define to 1 if you have the <sys/file.h> header file. */
/* #undef HAVE_SYS_FILE_H */
/* Define to 1 if you have the <sys/loadavg.h> header file. */
/* #undef HAVE_SYS_LOADAVG_H */
/* Define to 1 if you have the <sys/ndir.h> header file, and it defines 'DIR'.
*/
/* #undef HAVE_SYS_NDIR_H */
@ -325,12 +382,12 @@ char *ttyname (int);
/* Define to 1 if you have the <sys/resource.h> header file. */
/* #undef HAVE_SYS_RESOURCE_H */
/* Define to 1 if you have the <sys/select.h> header file. */
/* #undef HAVE_SYS_SELECT_H */
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/timeb.h> header file. */
#define HAVE_SYS_TIMEB_H 1
/* Define to 1 if you have the <sys/time.h> header file. */
#ifdef __MINGW32__
#define HAVE_SYS_TIME_H 1
@ -342,6 +399,21 @@ char *ttyname (int);
/* Define to 1 if you have the <sys/wait.h> header file. */
/* #undef HAVE_SYS_WAIT_H */
/* Define to 1 if you have the `ttyname' function. */
#define HAVE_TTYNAME 1
char *ttyname (int);
/* Define to 1 if the system has the type `intmax_t'. */
#define HAVE_INTMAX_T 1
/* Define to 1 if the system has the type `uintmax_t'. */
#define HAVE_UINTMAX_T 1
/* Define to 1 if you have the `umask' function. */
#if defined(__MINGW32__) || defined(__TINYC__)
# define HAVE_UMASK 1
#endif
/* Define to 1 if you have the \'union wait' type in <sys/wait.h>. */
/* #undef HAVE_UNION_WAIT */
@ -350,19 +422,40 @@ char *ttyname (int);
#define HAVE_UNISTD_H 1
#endif
/* Define to 1 if the system has the type 'unsigned long long int'. */
#define HAVE_UNSIGNED_LONG_LONG_INT 1
/* Define to 1 if you have the `vfork' function. */
/* #undef HAVE_VFORK */
/* Define to 1 if you have the <vfork.h> header file. */
/* #undef HAVE_VFORK_H */
/* Define to 1 if you have the 'wait3' function. */
/* #undef HAVE_WAIT3 */
/* Define to 1 if you have the 'waitpid' function. */
/* #undef HAVE_WAITPID */
/* Define to 1 if you have the <wchar.h> header file. */
/* #undef HAVE_WCHAR_H */
/* Define to 1 if `fork' works. */
/* #undef HAVE_WORKING_FORK */
/* Define to 1 if `vfork' works. */
/* #undef HAVE_WORKING_VFORK */
/* Define to 1 if the system has the type `_Bool'. */
/* #undef HAVE__BOOL */
/* Build host information. */
#define MAKE_HOST "Windows32"
/* Define to 1 to enable job server support in GNU make. */
/* Define to 1 to enable job server support in GNU Make. */
#define MAKE_JOBSERVER 1
/* Define to 1 to enable 'load' support in GNU make. */
/* Define to 1 to enable 'load' support in GNU Make. */
#define MAKE_LOAD 1
/* Define to 1 to enable symbolic link timestamp checking. */
@ -378,38 +471,15 @@ char *ttyname (int);
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
/* #undef NO_MINUS_C_MINUS_O */
/* Name of this package (needed by automake) */
#define PACKAGE "%PACKAGE%"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "bug-make@gnu.org"
/* Define to the full name of this package. */
#define PACKAGE_NAME "GNU make"
/* Define to the home page for this package. */
#define PACKAGE_URL "http://www.gnu.org/software/make/"
/* Define to the version of this package. */
#define PACKAGE_VERSION "%VERSION%"
/* Define to the character that separates directories in PATH. */
#define PATH_SEPARATOR_CHAR ';'
/* Define as the return type of signal handlers ('int' or 'void'). */
#define RETSIGTYPE void
/* Define to the name of the SCCS 'get' command. */
#define SCCS_GET "echo no sccs get"
/* Define this if the SCCS 'get' command understands the '-G<file>' option. */
/* #undef SCCS_GET_MINUS_G */
/* Define to 1 if the 'setvbuf' function takes the buffering type as its
second argument and the buffer pointer as the third, as on System V before
release 3. */
/* #undef SETVBUF_REVERSED */
/* If using the C implementation of alloca, define if you know the
direction of stack growth for your system; otherwise it will be
automatically deduced at run time.
@ -430,11 +500,6 @@ char *ttyname (int);
/* Define to 1 on System V Release 4. */
/* #undef SVR4 */
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#ifdef __MINGW32__
#define TIME_WITH_SYS_TIME 1
#endif
/* Define to 1 for Encore UMAX. */
/* #undef UMAX */
@ -442,9 +507,6 @@ char *ttyname (int);
<sys/cpustats.h>. */
/* #undef UMAX4_3 */
/* Version number of package */
#define VERSION "%VERSION%"
/* Define if using the dmalloc debugging malloc package */
/* #undef WITH_DMALLOC */
@ -483,6 +545,14 @@ char *ttyname (int);
# define __USE_MINGW_ANSI_STDIO 1
#endif
/* Number of bits in a timestamp, on hosts where this is settable. */
/* #undef _TIME_BITS */
/* For 64-bit time_t on 32-bit mingw. */
#ifdef __MINGW32__
# define __MINGW_USE_VC2005_COMPAT 1
#endif
#include <sys/types.h>
/* Define to 'int' if <sys/types.h> doesn't define. */
@ -504,9 +574,10 @@ char *ttyname (int);
/* Define to 'int' if <sys/types.h> doesn't define. */
#define uid_t int
/* Define uintmax_t if not defined in <stdint.h> or <inttypes.h>. */
/* Define {u,}intmax_t if not defined in <stdint.h> or <inttypes.h>. */
#if !HAVE_STDINT_H && !HAVE_INTTYPES_H
#define uintmax_t unsigned long
#define intmax_t long long
#define uintmax_t unsigned long long
#endif
/* Define if you have <sys/wait.h> that is POSIX.1 compatible. */
@ -522,10 +593,14 @@ char *ttyname (int);
/*
* If you have a shell that does not grok 'sh -c quoted-command-line'
* correctly, you need this setting. Please see below for specific
* shell support.
* correctly, you need this setting; it is the default for tcc.
* Please see below for specific shell support.
*/
#if defined(__TINYC__)
#define BATCH_MODE_ONLY_SHELL 1
#else
/*#define BATCH_MODE_ONLY_SHELL 1 */
#endif
/*
* Define if you have the Cygnus "Cygwin" GNU Windows32 tool set.
@ -549,3 +624,6 @@ char *ttyname (int);
#ifdef HAVE_CYGWIN_SHELL
#undef BATCH_MODE_ONLY_SHELL
#endif
/* Include customized declarations. */
#include "../src/mkcustom.h"

View File

@ -1,6 +1,6 @@
/* configh.dos -- hand-massaged config.h file for MS-DOS builds -*-C-*-
Copyright (C) 1994-2019 Free Software Foundation, Inc.
Copyright (C) 1994-2024 Free Software Foundation, Inc.
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify it under the
@ -13,7 +13,11 @@ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. */
this program. If not, see <https://www.gnu.org/licenses/>. */
#include "mkconfig.h"
#define MK_OS_DOS 1
/* Include this header to make __DJGPP_MINOR__ available because DJGPP ports
of GCC 4.3.0 and later no longer do it automatically. */
@ -49,6 +53,9 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
/* Define to 1 if you have the 'getgroups' function. */
#define HAVE_GETGROUPS 1
/* Define to 1 if the system has the type 'long long int'. */
#define HAVE_LONG_LONG_INT 1
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
@ -66,13 +73,6 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
#define SCCS_GET "get"
/* Define to 'unsigned long' or 'unsigned long long'
if <inttypes.h> doesn't define. */
#define uintmax_t unsigned long long
/* Define the type of the first arg to select(). */
#define fd_set_size_t int
/* Define to 1 if you have the select function. */
#define HAVE_SELECT 1
@ -82,35 +82,33 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
/* Define to 1 if you have the 'strncasecmp' function. */
#define HAVE_STRNCASECMP 1
/* Name of the package */
#define PACKAGE "%PACKAGE%"
/* Define to 1 if you have the `strtoll' function. */
#define HAVE_STRTOLL 1
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "bug-%PACKAGE%@gnu.org"
/* Define to the full name of this package. */
#define PACKAGE_NAME "GNU %PACKAGE%"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "GNU %PACKAGE% %VERSION%"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "%PACKAGE%"
/* Define to the version of this package. */
#define PACKAGE_VERSION "%VERSION%"
/* Output sync sypport */
#define NO_OUTPUT_SYNC
/* Version number of package */
#define VERSION "%VERSION%"
/* Output sync support */
#define NO_OUTPUT_SYNC 1
/* Build host information. */
#define MAKE_HOST "i386-pc-msdosdjgpp"
/* Grok DOS paths (drive specs and backslash path element separators) */
#define HAVE_DOS_PATHS
#define HAVE_DOS_PATHS 1
/* Define the type of the first arg to select(). */
#define fd_set_size_t int
/* Define to the widest signed integer type if <stdint.h> and <inttypes.h> do
not define. */
#define intmax_t long long
/* Define to `int' if <sys/types.h> does not define. */
#if __DJGPP__ == 2 && __DJGPP_MINOR__ < 5
#define ssize_t int
#endif
/* Define to 'unsigned long' or 'unsigned long long'
if <inttypes.h> doesn't define. */
#define uintmax_t unsigned long long
/* Include customized declarations. */
#include "../src/mkcustom.h"

View File

@ -1,5 +1,5 @@
/* Debugging macros and interface.
Copyright (C) 1999-2019 Free Software Foundation, Inc.
Copyright (C) 1999-2024 Free Software Foundation, Inc.
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify it under the
@ -12,13 +12,15 @@ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. */
this program. If not, see <https://www.gnu.org/licenses/>. */
#define DB_NONE (0x000)
#define DB_BASIC (0x001)
#define DB_VERBOSE (0x002)
#define DB_JOBS (0x004)
#define DB_IMPLICIT (0x008)
#define DB_PRINT (0x010)
#define DB_WHY (0x020)
#define DB_MAKEFILES (0x100)
#define DB_ALL (0xfff)

View File

@ -1,5 +1,5 @@
/* Data base of default implicit rules for GNU Make.
Copyright (C) 1988-2019 Free Software Foundation, Inc.
Copyright (C) 1988-2024 Free Software Foundation, Inc.
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify it under the
@ -12,7 +12,7 @@ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. */
this program. If not, see <https://www.gnu.org/licenses/>. */
#include "makeint.h"
@ -27,7 +27,7 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
/* Define GCC_IS_NATIVE if gcc is the native development environment on
your system (gcc/bison/flex vs cc/yacc/lex). */
#if defined(__MSDOS__) || defined(__EMX__)
#if MK_OS_DOS || MK_OS_OS2
# define GCC_IS_NATIVE
#endif
@ -36,14 +36,14 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
'.s' must come last, so that a '.o' file will be made from
a '.c' or '.p' or ... file rather than from a .s file. */
static char default_suffixes[]
#ifdef VMS
static const char default_suffixes[]
#if MK_OS_VMS
/* VMS should include all UNIX/POSIX + some VMS extensions */
= ".out .exe .a .olb .hlb .tlb .mlb .ln .o .obj .c .cxx .cc .cpp .pas .p \
.for .f .r .y .l .ym .yl .mar .s .ss .i .ii .mod .sym .def .h .info .dvi \
.tex .texinfo .texi .txinfo .mem .hlp .brn .rnh .rno .rnt .rnx .w .ch .cweb \
.web .com .sh .elc .el";
#elif defined(__EMX__)
#elif MK_OS_OS2
= ".out .a .ln .o .c .cc .C .cpp .p .f .F .m .r .y .l .ym .yl .s .S \
.mod .sym .def .h .info .dvi .tex .texinfo .texi .txinfo \
.w .ch .web .sh .elc .el .obj .exe .dll .lib";
@ -53,9 +53,9 @@ static char default_suffixes[]
.w .ch .web .sh .elc .el";
#endif
static struct pspec default_pattern_rules[] =
static const struct pspec default_pattern_rules[] =
{
#ifdef VMS
#if MK_OS_VMS
{ "(%)", "%",
"@if f$$search(\"$@\") .eqs. \"\" then $(LIBRARY)/CREATE/"
"$(or "
@ -76,7 +76,7 @@ static struct pspec default_pattern_rules[] =
/* The X.out rules are only in BSD's default set because
BSD Make has no null-suffix rules, so 'foo.out' and
'foo' are the same thing. */
#ifdef VMS
#if MK_OS_VMS
{ "%.exe", "%",
"$(CP) $< $@" },
@ -93,9 +93,9 @@ static struct pspec default_pattern_rules[] =
{ 0, 0, 0 }
};
static struct pspec default_terminal_rules[] =
static const struct pspec default_terminal_rules[] =
{
#ifdef VMS
#if MK_OS_VMS
/* RCS. */
{ "%", "%$$5lv", /* Multinet style */
@ -124,13 +124,13 @@ static struct pspec default_terminal_rules[] =
"$(GET) $(GFLAGS) $(SCCS_OUTPUT_OPTION) $<" },
{ "%", "SCCS/s.%",
"$(GET) $(GFLAGS) $(SCCS_OUTPUT_OPTION) $<" },
#endif /* !VMS */
#endif /* !MK_OS_VMS */
{ 0, 0, 0 }
};
static const char *default_suffix_rules[] =
static const char *const default_suffix_rules[] =
{
#ifdef VMS
#if MK_OS_VMS
".o",
"$(LINK.obj) $^ $(LOADLIBES) $(LDLIBS) -o $@",
".obj",
@ -263,7 +263,7 @@ static const char *default_suffix_rules[] =
".l.ln",
"@$(RM) $*.c\n $(LEX.l) $< > $*.c\n$(LINT.c) -i $*.c -o $@\n $(RM) $*.c",
#else /* ! VMS */
#else /* ! MK_OS_VMS */
".o",
"$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@",
@ -326,19 +326,19 @@ static const char *default_suffix_rules[] =
".c.ln",
"$(LINT.c) -C$* $<",
".y.ln",
#ifndef __MSDOS__
"$(YACC.y) $< \n $(LINT.c) -C$* y.tab.c \n $(RM) y.tab.c",
#else
#if MK_OS_DOS
"$(YACC.y) $< \n $(LINT.c) -C$* y_tab.c \n $(RM) y_tab.c",
#else
"$(YACC.y) $< \n $(LINT.c) -C$* y.tab.c \n $(RM) y.tab.c",
#endif
".l.ln",
"@$(RM) $*.c\n $(LEX.l) $< > $*.c\n$(LINT.c) -i $*.c -o $@\n $(RM) $*.c",
".y.c",
#ifndef __MSDOS__
"$(YACC.y) $< \n mv -f y.tab.c $@",
#else
#if MK_OS_DOS
"$(YACC.y) $< \n mv -f y_tab.c $@",
#else
"$(YACC.y) $< \n mv -f y.tab.c $@",
#endif
".l.c",
"@$(RM) $@ \n $(LEX.l) $< > $@",
@ -393,14 +393,14 @@ static const char *default_suffix_rules[] =
".web.tex",
"$(WEAVE) $<",
#endif /* !VMS */
#endif /* !MK_OS_VMS */
0, 0,
};
static const char *default_variables[] =
static const char *const default_variables[] =
{
#ifdef VMS
#if MK_OS_VMS
#ifdef __ALPHA
"ARCH", "ALPHA",
#endif
@ -506,7 +506,7 @@ static const char *default_variables[] =
"COMPILE.s", "$(AS) $(ASFLAGS) $(TARGET_MACH)",
"LINK.S", "$(CC) $(ASFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_MACH)",
"COMPILE.S", "$(CC) $(ASFLAGS) $(CPPFLAGS) $(TARGET_MACH) -c",
"PREPROCESS.S", "$(CC) -E $(CPPFLAGS)",
"PREPROCESS.S", "$(CPP) $(CPPFLAGS)",
"PREPROCESS.F", "$(FC) $(FFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -F",
"PREPROCESS.r", "$(FC) $(FFLAGS) $(RFLAGS) $(TARGET_ARCH) -F",
"LINT.c", "$(LINT) $(LINTFLAGS) $(CPPFLAGS) $(TARGET_ARCH)",
@ -515,25 +515,36 @@ static const char *default_variables[] =
"CP", "copy",
".LIBPATTERNS", "%.olb lib%.a",
#else /* !VMS */
#else /* !MK_OS_VMS */
"AR", "ar",
"ARFLAGS", "rv",
#ifdef _AIX
/* AIX requires object file format specification: choose -Xany. */
"ARFLAGS", "-Xany -rv",
#else
"ARFLAGS", "-rv",
#endif
"AS", "as",
#ifdef GCC_IS_NATIVE
"CC", "gcc",
# ifdef __MSDOS__
"CXX", "gpp", /* g++ is an invalid name on MSDOS */
# else
"CXX", "gcc",
# endif /* __MSDOS__ */
"OBJC", "gcc",
#else
"CC", "cc",
"CXX", "g++",
"OBJC", "cc",
#endif
#ifdef MAKE_CXX
"CXX", MAKE_CXX,
#else
# ifdef GCC_IS_NATIVE
# ifdef MK_OS_DOS
"CXX", "gpp", /* g++ is an invalid name on MSDOS */
# else
"CXX", "gcc",
# endif /* __MSDOS__ */
# else
"CXX", "g++",
# endif
#endif
/* This expands to $(CO) $(COFLAGS) $< $@ if $@ does not exist,
and to the empty string if $@ does exist. */
"CHECKOUT,v", "+$(if $(wildcard $@),,$(CO) $(COFLAGS) $< $@)",
@ -541,17 +552,17 @@ static const char *default_variables[] =
"COFLAGS", "",
"CPP", "$(CC) -E",
#ifdef CRAY
#ifdef CRAY
"CF77PPFLAGS", "-P",
"CF77PP", "/lib/cpp",
"CFT", "cft77",
"CF", "cf77",
"FC", "$(CF)",
#else /* Not CRAY. */
#ifdef _IBMR2
#else /* Not CRAY. */
#ifdef _IBMR2
"FC", "xlf",
#else
#ifdef __convex__
#ifdef __convex__
"FC", "fc",
#else
"FC", "f77",
@ -571,10 +582,10 @@ static const char *default_variables[] =
#endif
"LINT", "lint",
"M2C", "m2c",
#ifdef pyr
#ifdef pyr
"PC", "pascal",
#else
#ifdef CRAY
#ifdef CRAY
"PC", "PASCAL",
"SEGLDR", "segldr",
#else
@ -636,7 +647,7 @@ static const char *default_variables[] =
"COMPILE.s", "$(AS) $(ASFLAGS) $(TARGET_MACH)",
"LINK.S", "$(CC) $(ASFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_MACH)",
"COMPILE.S", "$(CC) $(ASFLAGS) $(CPPFLAGS) $(TARGET_MACH) -c",
"PREPROCESS.S", "$(CC) -E $(CPPFLAGS)",
"PREPROCESS.S", "$(CPP) $(CPPFLAGS)",
"PREPROCESS.F", "$(FC) $(FFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -F",
"PREPROCESS.r", "$(FC) $(FFLAGS) $(RFLAGS) $(TARGET_ARCH) -F",
"LINT.c", "$(LINT) $(LINTFLAGS) $(CPPFLAGS) $(TARGET_ARCH)",
@ -645,25 +656,23 @@ static const char *default_variables[] =
"OUTPUT_OPTION", "-o $@",
#endif
#ifdef SCCS_GET_MINUS_G
#ifdef SCCS_GET_MINUS_G
"SCCS_OUTPUT_OPTION", "-G$@",
#endif
#if defined(_AMIGA)
".LIBPATTERNS", "%.lib",
#elif defined(__MSDOS__)
#if MK_OS_DOS
".LIBPATTERNS", "lib%.a $(DJDIR)/lib/lib%.a",
#elif defined(__APPLE__)
".LIBPATTERNS", "lib%.dylib lib%.a",
#elif defined(__CYGWIN__) || defined(WINDOWS32)
#elif defined(__CYGWIN__) || MK_OS_W32
".LIBPATTERNS", "lib%.dll.a %.dll.a lib%.a %.lib lib%.dll %.dll",
#else
".LIBPATTERNS", "lib%.so lib%.a",
#endif
#endif /* !VMS */
#endif /* !MK_OS_VMS */
/* Make this assignment to avoid undefined variable warnings. */
"GNUMAKEFLAGS", "",
GNUMAKEFLAGS_NAME, "",
0, 0
};
@ -696,9 +705,9 @@ set_default_suffixes (void)
installed after. */
void
install_default_suffix_rules (void)
install_default_suffix_rules ()
{
const char **s;
const char *const *s;
if (no_builtin_rules_flag)
return;
@ -706,14 +715,16 @@ install_default_suffix_rules (void)
for (s = default_suffix_rules; *s != 0; s += 2)
{
struct file *f = enter_file (strcache_add (s[0]));
/* This function should run before any makefile is parsed. */
assert (f->cmds == 0);
f->cmds = xmalloc (sizeof (struct commands));
f->cmds->fileinfo.filenm = 0;
f->cmds->commands = xstrdup (s[1]);
f->cmds->command_lines = 0;
f->cmds->recipe_prefix = RECIPEPREFIX_DEFAULT;
f->builtin = 1;
/* Install the default rule only if there is no user defined rule. */
if (!f->cmds)
{
f->cmds = xmalloc (sizeof (struct commands));
f->cmds->fileinfo.filenm = NULL;
f->cmds->commands = xstrdup (s[1]);
f->cmds->command_lines = NULL;
f->cmds->recipe_prefix = RECIPEPREFIX_DEFAULT;
f->builtin = 1;
}
}
}
@ -723,7 +734,7 @@ install_default_suffix_rules (void)
void
install_default_implicit_rules (void)
{
struct pspec *p;
const struct pspec *p;
if (no_builtin_rules_flag)
return;
@ -738,7 +749,7 @@ install_default_implicit_rules (void)
void
define_default_variables (void)
{
const char **s;
const char *const *s;
if (no_builtin_variables_flag)
return;
@ -750,8 +761,8 @@ define_default_variables (void)
void
undefine_default_variables (void)
{
const char **s;
const char *const *s;
for (s = default_variables; *s != 0; s += 2)
undefine_variable_global (s[0], strlen (s[0]), o_default);
undefine_variable_global (NILF, s[0], strlen (s[0]), o_default);
}

View File

@ -1,5 +1,5 @@
/* Definitions of dependency data structures for GNU Make.
Copyright (C) 1988-2019 Free Software Foundation, Inc.
Copyright (C) 1988-2024 Free Software Foundation, Inc.
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify it under the
@ -12,7 +12,7 @@ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. */
this program. If not, see <https://www.gnu.org/licenses/>. */
/* Structure used in chains of names, for parsing and globbing. */
@ -30,25 +30,31 @@ struct nameseq
These flags are saved in the 'flags' field of each
'struct goaldep' in the chain returned by 'read_all_makefiles'. */
#define RM_NOFLAG 0
#define RM_NO_DEFAULT_GOAL (1 << 0) /* Do not set default goal. */
#define RM_INCLUDED (1 << 1) /* Search makefile search path. */
#define RM_DONTCARE (1 << 2) /* No error if it doesn't exist. */
#define RM_NO_TILDE (1 << 3) /* Don't expand ~ in file name. */
#define RM_NOFLAG 0
/* Structure representing one dependency of a file.
Each struct file's 'deps' points to a chain of these, through 'next'.
'stem' is the stem for this dep line of static pattern rule or NULL. */
'stem' is the stem for this dep line of static pattern rule or NULL.
explicit is set when implicit rule search is performed and the prerequisite
does not contain %. When explicit is set the file is not intermediate. */
#define DEP(_t) \
NAMESEQ (_t); \
struct file *file; \
_t *shuf; \
const char *stem; \
unsigned int flags : 8; \
unsigned int changed : 1; \
unsigned int ignore_mtime : 1; \
unsigned int staticpattern : 1; \
unsigned int need_2nd_expansion : 1
unsigned int need_2nd_expansion : 1; \
unsigned int ignore_automatic_vars : 1; \
unsigned int is_explicit : 1; \
unsigned int wait_here : 1
struct dep
{
@ -74,13 +80,15 @@ struct goaldep
#define PARSEFS_NOGLOB 0x0004
#define PARSEFS_EXISTS 0x0008
#define PARSEFS_NOCACHE 0x0010
#define PARSEFS_ONEWORD 0x0020
#define PARSEFS_WAIT 0x0040
#define PARSE_FILE_SEQ(_s,_t,_c,_p,_f) \
(_t *)parse_file_seq ((_s),sizeof (_t),(_c),(_p),(_f))
#define PARSE_SIMPLE_SEQ(_s,_t) \
(_t *)parse_file_seq ((_s),sizeof (_t),MAP_NUL,NULL,PARSEFS_NONE)
#ifdef VMS
#if MK_OS_VMS
void *parse_file_seq ();
#else
void *parse_file_seq (char **stringp, size_t size,
@ -93,24 +101,23 @@ char *tilde_expand (const char *name);
struct nameseq *ar_glob (const char *arname, const char *member_pattern, size_t size);
#endif
#define dep_name(d) ((d)->name ? (d)->name : (d)->file->name)
#define dep_name(d) ((d)->name ? (d)->name : (d)->file->name)
#define alloc_seq_elt(_t) xcalloc (sizeof (_t))
#define alloc_seq_elt(_t) xcalloc (sizeof (_t))
void free_ns_chain (struct nameseq *n);
#if defined(MAKE_MAINTAINER_MODE) && defined(__GNUC__)
#if defined(MAKE_MAINTAINER_MODE) && defined(__GNUC__) && !defined(__STRICT_ANSI__)
/* Use inline to get real type-checking. */
#define SI static inline
SI struct nameseq *alloc_ns() { return alloc_seq_elt (struct nameseq); }
SI struct dep *alloc_dep() { return alloc_seq_elt (struct dep); }
SI struct goaldep *alloc_goaldep() { return alloc_seq_elt (struct goaldep); }
SI struct nameseq *alloc_ns (void) { return alloc_seq_elt (struct nameseq); }
SI struct dep *alloc_dep (void) { return alloc_seq_elt (struct dep); }
SI struct goaldep *alloc_goaldep (void) { return alloc_seq_elt (struct goaldep); }
SI void free_ns(struct nameseq *n) { free (n); }
SI void free_dep(struct dep *d) { free_ns ((struct nameseq *)d); }
SI void free_goaldep(struct goaldep *g) { free_dep ((struct dep *)g); }
SI void free_dep_chain(struct dep *d) { free_ns_chain((struct nameseq *)d); }
SI void free_goal_chain(struct goaldep *g) { free_dep_chain((struct dep *)g); }
SI void free_ns (struct nameseq *n) { free (n); }
SI void free_dep (struct dep *d) { free_ns ((struct nameseq *)d); }
SI void free_goaldep (struct goaldep *g) { free_dep ((struct dep *)g); }
SI void free_dep_chain (struct dep *d) { free_ns_chain((struct nameseq *)d); }
SI void free_goal_chain (struct goaldep *g) { free_dep_chain((struct dep *)g); }
#else
# define alloc_ns() alloc_seq_elt (struct nameseq)
# define alloc_dep() alloc_seq_elt (struct dep)
@ -124,6 +131,7 @@ SI void free_goal_chain(struct goaldep *g) { free_dep_chain((struct dep *)g); }
# define free_goal_chain(_g) free_ns_chain ((struct nameseq *)(_g))
#endif
struct dep *copy_dep (const struct dep *d);
struct dep *copy_dep_chain (const struct dep *d);
struct goaldep *read_all_makefiles (const char **makefiles);

586
src/dir.c

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/* Variable expansion functions for GNU Make.
Copyright (C) 1988-2019 Free Software Foundation, Inc.
Copyright (C) 1988-2024 Free Software Foundation, Inc.
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify it under the
@ -12,17 +12,19 @@ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. */
this program. If not, see <https://www.gnu.org/licenses/>. */
#include "makeint.h"
#include <assert.h>
#include "commands.h"
#include "debug.h"
#include "filedef.h"
#include "job.h"
#include "commands.h"
#include "variable.h"
#include "rule.h"
#include "warning.h"
/* Initially, any errors reported when expanding strings will be reported
against the file where the error appears. */
@ -45,49 +47,95 @@ const floc **expanding_var = &reading_file;
static size_t variable_buffer_length;
char *variable_buffer;
/* Subroutine of variable_expand and friends:
The text to add is LENGTH chars starting at STRING to the variable_buffer.
The text is added to the buffer at PTR, and the updated pointer into
the buffer is returned as the value. Thus, the value returned by
each call to variable_buffer_output should be the first argument to
the following call. */
/* Append LENGTH chars of STRING at PTR which must point into variable_buffer.
The buffer will always be kept nul-terminated.
The updated pointer into the buffer is returned as the value. Thus, the
value returned by each call to variable_buffer_output should be the first
argument to the following call. */
char *
variable_buffer_output (char *ptr, const char *string, size_t length)
{
size_t newlen = length + (ptr - variable_buffer);
if ((newlen + VARIABLE_BUFFER_ZONE) > variable_buffer_length)
assert (ptr >= variable_buffer);
assert (ptr < variable_buffer + variable_buffer_length);
if (newlen + VARIABLE_BUFFER_ZONE + 1 > variable_buffer_length)
{
size_t offset = ptr - variable_buffer;
variable_buffer_length = (newlen + 100 > 2 * variable_buffer_length
? newlen + 100
: 2 * variable_buffer_length);
variable_buffer = xrealloc (variable_buffer, variable_buffer_length);
variable_buffer = xrealloc (variable_buffer, variable_buffer_length + 1);
ptr = variable_buffer + offset;
}
memcpy (ptr, string, length);
return ptr + length;
ptr = mempcpy (ptr, string, length);
*ptr = '\0';
return ptr;
}
/* Return a pointer to the beginning of the variable buffer. */
/* Return a pointer to the beginning of the variable buffer.
This is called from main() and it should never be null afterward. */
static char *
initialize_variable_output (void)
char *
initialize_variable_output ()
{
/* If we don't have a variable output buffer yet, get one. */
if (variable_buffer == 0)
if (!variable_buffer)
{
variable_buffer_length = 200;
variable_buffer = xmalloc (variable_buffer_length);
variable_buffer[0] = '\0';
}
variable_buffer[0] = '\0';
return variable_buffer;
}
/* Install a new variable_buffer context, returning the current one for
safe-keeping. */
void
install_variable_buffer (char **bufp, size_t *lenp)
{
*bufp = variable_buffer;
*lenp = variable_buffer_length;
variable_buffer = NULL;
initialize_variable_output ();
}
/* Free the current variable_buffer and restore a previously-saved one.
*/
void
restore_variable_buffer (char *buf, size_t len)
{
free (variable_buffer);
variable_buffer = buf;
variable_buffer_length = len;
}
/* Restore a previously-saved variable_buffer context, and return the
current one.
*/
char *
swap_variable_buffer (char *buf, size_t len)
{
char *p = variable_buffer;
variable_buffer = buf;
variable_buffer_length = len;
return p;
}
/* Recursively expand V. The returned string is malloc'd. */
static char *allocated_variable_append (const struct variable *v);
@ -98,8 +146,32 @@ recursively_expand_for_file (struct variable *v, struct file *file)
char *value;
const floc *this_var;
const floc **saved_varp;
struct variable_set_list *save = 0;
struct variable_set_list *savev = 0;
int set_reading = 0;
size_t nl = strlen (v->name);
struct variable *parent = NULL;
/* If we're expanding to put into the environment of a shell function then
ignore any recursion issues: for backward-compatibility we will use
the value of the environment variable we were started with. */
if (v->expanding && env_recursion)
{
char **ep;
DB (DB_VERBOSE,
(_("%s:%lu: not recursively expanding %s to export to shell function\n"),
v->fileinfo.filenm, v->fileinfo.lineno, v->name));
/* We could create a hash for the original environment for speed, but a
reasonably written makefile shouldn't hit this situation... */
for (ep = environ; *ep != 0; ++ep)
if (strncmp (*ep, v->name, nl) == 0 && (*ep)[nl] == '=')
return xstrdup ((*ep) + nl + 1);
/* If there's nothing in the parent environment, use the empty string.
This isn't quite correct since the variable should not exist at all,
but getting that to work would be involved. */
return xstrdup ("");
}
/* Don't install a new location if this location is empty.
This can happen for command-line variables, builtin variables, etc. */
@ -122,76 +194,184 @@ recursively_expand_for_file (struct variable *v, struct file *file)
if (!v->exp_count)
/* Expanding V causes infinite recursion. Lose. */
OS (fatal, *expanding_var,
_("Recursive variable '%s' references itself (eventually)"),
_("recursive variable '%s' references itself (eventually)"),
v->name);
--v->exp_count;
}
if (file)
{
save = current_variable_set_list;
current_variable_set_list = file->variables;
}
install_file_context (file, &savev, NULL);
v->expanding = 1;
if (v->append)
{
/* Find a parent definition which is marked override. */
struct variable_set_list *sl;
for (sl = current_variable_set_list; sl && !parent; sl = sl->next)
{
struct variable *vp = lookup_variable_in_set (v->name, nl, sl->set);
if (vp && vp != v && vp->origin == o_override)
parent = vp;
}
}
if (parent)
/* PARENT is an override, V is appending. If V is also an override:
override hello := first
al%: override hello += second
Then construct the value from its appended parts in the parent sets.
Else if V is not an override:
override hello := first
al%: hello += second
Then ignore the value of V and use the value of PARENT. */
value = v->origin == o_override
? allocated_variable_append (v)
: xstrdup (parent->value);
else if (v->origin == o_command || v->origin == o_env_override)
/* Avoid appending to a pattern-specific variable, unless the origin of this
pattern-specific variable beats or equals the origin of one of the parent
definitions of this variable.
This is needed, because if there is a command line definition or an env
override, then the value defined in the makefile should only be appended
in the case of a file override.
In the presence of command line definition or env override and absence of
makefile override, the value should be expanded, rather than appended. In
this case, at parse time record_target_var already set the value of this
pattern-specific variable to the value defined on the command line or to
the env override value.
User provided a command line definition or an env override.
PARENT does not have an override directive, so ignore it. */
value = allocated_expand_string (v->value);
else if (v->append)
/* Construct the value from its appended parts in the parent sets. */
value = allocated_variable_append (v);
else
value = allocated_variable_expand (v->value);
/* A definition without appending. */
value = allocated_expand_string (v->value);
v->expanding = 0;
if (set_reading)
reading_file = 0;
if (file)
current_variable_set_list = save;
restore_file_context (savev, NULL);
expanding_var = saved_varp;
return value;
}
/* Expand a simple reference to variable NAME, which is LENGTH chars long. */
/* Expand a simple reference to variable NAME, which is LENGTH chars long.
The result is written to PTR which must point into the variable_buffer.
Returns a pointer to the new end of the variable_buffer. */
#ifdef __GNUC__
__inline
#endif
static char *
reference_variable (char *o, const char *name, size_t length)
char *
expand_variable_output (char *ptr, const char *name, size_t length)
{
struct variable *v;
unsigned int recursive;
char *value;
v = lookup_variable (name, length);
if (v == 0)
if (!v)
warn_undefined (name, length);
/* If there's no variable by that name or it has no value, stop now. */
if (v == 0 || (*v->value == '\0' && !v->append))
return o;
if (!v || (v->value[0] == '\0' && !v->append))
return ptr;
value = (v->recursive ? recursively_expand (v) : v->value);
/* Remember this since expansion could change it. */
recursive = v->recursive;
o = variable_buffer_output (o, value, strlen (value));
value = recursive ? recursively_expand (v) : v->value;
if (v->recursive)
ptr = variable_buffer_output (ptr, value, strlen (value));
if (recursive)
free (value);
return o;
return ptr;
}
/* Expand a simple reference to variable NAME, which is LENGTH chars long.
The result is written to BUF which must point into the variable_buffer.
If BUF is NULL, start at the beginning of the current variable_buffer.
Returns a pointer to the START of the expanded value of the variable.
The returned value is located inside variable_buffer.
The returned value is valid until the next call to one of the functions
which use variable_buffer. expand_variable_buf may reallocate
variable_buffer and render the passed-in BUF invalid. */
char *
expand_variable_buf (char *buf, const char *name, size_t length)
{
size_t offs;
if (!buf)
buf = initialize_variable_output ();
assert (buf >= variable_buffer);
assert (buf < variable_buffer + variable_buffer_length);
offs = buf - variable_buffer;
expand_variable_output (buf, name, length);
return variable_buffer + offs;
}
/* Expand a simple reference to variable NAME, which is LENGTH chars long.
Returns an allocated buffer containing the value. */
char *
allocated_expand_variable (const char *name, size_t length)
{
char *obuf;
size_t olen;
install_variable_buffer (&obuf, &olen);
expand_variable_output (variable_buffer, name, length);
return swap_variable_buffer (obuf, olen);
}
/* Expand a simple reference to variable NAME, which is LENGTH chars long.
Error messages refer to the file and line where FILE's commands were found.
Expansion uses FILE's variable set list.
Returns an allocated buffer containing the value. */
char *
allocated_expand_variable_for_file (const char *name, size_t length, struct file *file)
{
char *result;
struct variable_set_list *savev;
const floc *savef;
if (!file)
return allocated_expand_variable (name, length);
install_file_context (file, &savev, &savef);
result = allocated_expand_variable (name, length);
restore_file_context (savev, savef);
return result;
}
/* Scan STRING for variable references and expansion-function calls. Only
LENGTH bytes of STRING are actually scanned. If LENGTH is -1, scan until
a null byte is found.
LENGTH bytes of STRING are actually scanned.
If LENGTH is SIZE_MAX, scan until a null byte is found.
Write the results to LINE, which must point into 'variable_buffer'. If
LINE is NULL, start at the beginning of the buffer.
Return a pointer to LINE, or to the beginning of the buffer if LINE is
Write the results to BUF, which must point into variable_buffer. If
BUF is NULL, start at the beginning of the current variable_buffer.
Return a pointer to BUF, or to the beginning of the new buffer if BUF is
NULL.
*/
char *
variable_expand_string (char *line, const char *string, size_t length)
expand_string_buf (char *buf, const char *string, size_t length)
{
struct variable *v;
const char *p, *p1;
@ -199,16 +379,13 @@ variable_expand_string (char *line, const char *string, size_t length)
char *o;
size_t line_offset;
if (!line)
line = initialize_variable_output ();
o = line;
line_offset = line - variable_buffer;
if (!buf)
buf = initialize_variable_output ();
o = buf;
line_offset = buf - variable_buffer;
if (length == 0)
{
variable_buffer_output (o, "", 1);
return (variable_buffer);
}
return variable_buffer;
/* We need a copy of STRING: due to eval, it's possible that it will get
freed as we process it (it might be the value of a variable that's reset
@ -247,47 +424,40 @@ variable_expand_string (char *line, const char *string, size_t length)
{
char openparen = *p;
char closeparen = (openparen == '(') ? ')' : '}';
const char *begp;
const char *beg = p + 1;
char *op;
char *abeg = NULL;
const char *end, *colon;
op = o;
begp = p;
if (handle_function (&op, &begp))
{
o = op;
p = begp;
break;
}
if (handle_function (&o, &p))
break;
/* Is there a variable reference inside the parens or braces?
If so, expand it before expanding the entire reference. */
end = strchr (beg, closeparen);
if (end == 0)
if (end == NULL)
/* Unterminated variable reference. */
O (fatal, *expanding_var, _("unterminated variable reference"));
p1 = lindex (beg, end, '$');
if (p1 != 0)
if (p1 != NULL)
{
/* BEG now points past the opening paren or brace.
Count parens or braces until it is matched. */
int count = 0;
int count = 1;
for (p = beg; *p != '\0'; ++p)
{
if (*p == openparen)
++count;
else if (*p == closeparen && --count < 0)
else if (*p == closeparen && --count == 0)
break;
}
/* If COUNT is >= 0, there were unmatched opening parens
/* If COUNT is > 0, there were unmatched opening parens
or braces, so we go to the simple case of a variable name
such as '$($(a)'. */
if (count < 0)
if (count == 0)
{
abeg = expand_argument (beg, p); /* Expand the name. */
/* Expand the name. */
abeg = expand_argument (beg, p);
beg = abeg;
end = strchr (beg, '\0');
}
@ -377,7 +547,7 @@ variable_expand_string (char *line, const char *string, size_t length)
if (colon == 0)
/* This is an ordinary variable reference.
Look up the value of the variable. */
o = reference_variable (o, beg, end - beg);
o = expand_variable_output (o, beg, end - beg);
free (abeg);
}
@ -389,7 +559,7 @@ variable_expand_string (char *line, const char *string, size_t length)
/* A $ followed by a random char is a variable reference:
$a is equivalent to $(a). */
o = reference_variable (o, p, 1);
o = expand_variable_output (o, p, 1);
break;
}
@ -402,21 +572,10 @@ variable_expand_string (char *line, const char *string, size_t length)
free (save);
variable_buffer_output (o, "", 1);
return (variable_buffer + line_offset);
}
/* Scan LINE for variable references and expansion-function calls.
Build in 'variable_buffer' the result of expanding the references and calls.
Return the address of the resulting string, which is null-terminated
and is valid only until the next time this function is called. */
char *
variable_expand (const char *line)
{
return variable_expand_string (NULL, line, SIZE_MAX);
}
/* Expand an argument for an expansion function.
The text starting at STR and ending at END is variable-expanded
into a null-terminated string that is returned as the value.
@ -433,7 +592,7 @@ expand_argument (const char *str, const char *end)
return xstrdup ("");
if (!end || *end == '\0')
return allocated_variable_expand (str);
return allocated_expand_string (str);
if (end - str + 1 > 1000)
tmp = alloc = xmalloc (end - str + 1);
@ -443,44 +602,53 @@ expand_argument (const char *str, const char *end)
memcpy (tmp, str, end - str);
tmp[end - str] = '\0';
r = allocated_variable_expand (tmp);
r = allocated_expand_string (tmp);
free (alloc);
return r;
}
/* Expand LINE for FILE. Error messages refer to the file and line where
FILE's commands were found. Expansion uses FILE's variable set list. */
/* Expand STRING for FILE, into the current variable_buffer.
Error messages refer to the file and line where FILE's commands were found.
Expansion uses FILE's variable set list. */
char *
variable_expand_for_file (const char *line, struct file *file)
expand_string_for_file (const char *string, struct file *file)
{
char *result;
struct variable_set_list *savev;
const floc *savef;
if (file == 0)
return variable_expand (line);
if (!file)
return expand_string (string);
savev = current_variable_set_list;
current_variable_set_list = file->variables;
install_file_context (file, &savev, &savef);
savef = reading_file;
if (file->cmds && file->cmds->fileinfo.filenm)
reading_file = &file->cmds->fileinfo;
else
reading_file = 0;
result = expand_string (string);
result = variable_expand (line);
current_variable_set_list = savev;
reading_file = savef;
restore_file_context (savev, savef);
return result;
}
/* Like expand_string_for_file, but the returned string is malloc'd. */
char *
allocated_expand_string_for_file (const char *string, struct file *file)
{
char *obuf;
size_t olen;
install_variable_buffer (&obuf, &olen);
expand_string_for_file (string, file);
return swap_variable_buffer (obuf, olen);
}
/* Like allocated_variable_expand, but for += target-specific variables.
/* Like allocated_expand_string, but for += target-specific variables.
First recursively construct the variable value from its appended parts in
any upper variable sets. Then expand the resulting value. */
@ -522,7 +690,7 @@ variable_append (const char *name, size_t length,
if (! v->recursive)
return variable_buffer_output (buf, v->value, strlen (v->value));
buf = variable_expand_string (buf, v->value, strlen (v->value));
buf = expand_string_buf (buf, v->value, strlen (v->value));
return (buf + strlen (buf));
}
@ -530,68 +698,13 @@ variable_append (const char *name, size_t length,
static char *
allocated_variable_append (const struct variable *v)
{
char *val;
/* Construct the appended variable value. */
char *obuf;
size_t olen;
char *obuf = variable_buffer;
size_t olen = variable_buffer_length;
install_variable_buffer (&obuf, &olen);
variable_buffer = 0;
variable_append (v->name, strlen (v->name), current_variable_set_list, 1);
val = variable_append (v->name, strlen (v->name),
current_variable_set_list, 1);
variable_buffer_output (val, "", 1);
val = variable_buffer;
variable_buffer = obuf;
variable_buffer_length = olen;
return val;
}
/* Like variable_expand_for_file, but the returned string is malloc'd.
This function is called a lot. It wants to be efficient. */
char *
allocated_variable_expand_for_file (const char *line, struct file *file)
{
char *value;
char *obuf = variable_buffer;
size_t olen = variable_buffer_length;
variable_buffer = 0;
value = variable_expand_for_file (line, file);
variable_buffer = obuf;
variable_buffer_length = olen;
return value;
}
/* Install a new variable_buffer context, returning the current one for
safe-keeping. */
void
install_variable_buffer (char **bufp, size_t *lenp)
{
*bufp = variable_buffer;
*lenp = variable_buffer_length;
variable_buffer = 0;
initialize_variable_output ();
}
/* Restore a previously-saved variable_buffer setting (free the current one).
*/
void
restore_variable_buffer (char *buf, size_t len)
{
free (variable_buffer);
variable_buffer = buf;
variable_buffer_length = len;
return swap_variable_buffer (obuf, olen);
}

View File

@ -1,5 +1,5 @@
/* Target file management for GNU Make.
Copyright (C) 1988-2019 Free Software Foundation, Inc.
Copyright (C) 1988-2024 Free Software Foundation, Inc.
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify it under the
@ -12,7 +12,7 @@ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. */
this program. If not, see <https://www.gnu.org/licenses/>. */
#include "makeint.h"
@ -25,6 +25,8 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
#include "variable.h"
#include "debug.h"
#include "hash.h"
#include "shuffle.h"
#include "rule.h"
/* Remember whether snap_deps has been invoked: we need this to be sure we
@ -59,6 +61,14 @@ file_hash_cmp (const void *x, const void *y)
static struct hash_table files;
/* We can't free files we take out of the hash table, because they are still
likely pointed to in various places. The check_renamed() will be used if
we come across these, to find the new correct file. This is mainly to
prevent leak checkers from complaining. */
static struct file **rehashed_files = NULL;
static size_t rehashed_files_len = 0;
#define REHASHED_FILES_INCR 5
/* Whether or not .SECONDARY with no prerequisites was given. */
static int all_secondary = 0;
@ -72,7 +82,7 @@ lookup_file (const char *name)
{
struct file *f;
struct file file_key;
#ifdef VMS
#if MK_OS_VMS
int want_vmsify;
#ifndef WANT_CASE_SENSITIVE_TARGETS
char *lname;
@ -84,7 +94,7 @@ lookup_file (const char *name)
/* This is also done in parse_file_seq, so this is redundant
for names read from makefiles. It is here for names passed
on the command line. */
#ifdef VMS
#if MK_OS_VMS
want_vmsify = (strpbrk (name, "]>:^") != NULL);
# ifndef WANT_CASE_SENSITIVE_TARGETS
if (*name != '.')
@ -104,20 +114,10 @@ lookup_file (const char *name)
while (name[0] == '<' && name[1] == '>' && name[2] != '\0')
name += 2;
#endif
while (name[0] == '.'
#ifdef HAVE_DOS_PATHS
&& (name[1] == '/' || name[1] == '\\')
#else
&& name[1] == '/'
#endif
&& name[2] != '\0')
while (name[0] == '.' && ISDIRSEP (name[1]) && name[2] != '\0')
{
name += 2;
while (*name == '/'
#ifdef HAVE_DOS_PATHS
|| *name == '\\'
#endif
)
while (ISDIRSEP (*name))
/* Skip following slashes: ".//foo" is "foo", not "/foo". */
++name;
}
@ -125,12 +125,8 @@ lookup_file (const char *name)
if (*name == '\0')
{
/* It was all slashes after a dot. */
#if defined(_AMIGA)
name = "";
#else
name = "./";
#endif
#if defined(VMS)
#if MK_OS_VMS
/* TODO - This section is probably not needed. */
if (want_vmsify)
name = "[]";
@ -138,7 +134,7 @@ lookup_file (const char *name)
}
file_key.hname = name;
f = hash_find_item (&files, &file_key);
#if defined(VMS) && !defined(WANT_CASE_SENSITIVE_TARGETS)
#if MK_OS_VMS && !defined(WANT_CASE_SENSITIVE_TARGETS)
if (*name != '.')
free (lname);
#endif
@ -162,7 +158,7 @@ enter_file (const char *name)
assert (*name != '\0');
assert (! verify_flag || strcache_iscached (name));
#if defined(VMS) && !defined(WANT_CASE_SENSITIVE_TARGETS)
#if MK_OS_VMS && !defined(WANT_CASE_SENSITIVE_TARGETS)
if (*name != '.')
{
const char *n;
@ -230,8 +226,7 @@ rehash_file (struct file *from_file, const char *to_hname)
/* Find the end of the renamed list for the "from" file. */
file_key.hname = from_file->hname;
while (from_file->renamed != 0)
from_file = from_file->renamed;
check_renamed (from_file);
if (file_hash_cmp (from_file, &file_key))
/* hname changed unexpectedly!! */
abort ();
@ -270,25 +265,25 @@ rehash_file (struct file *from_file, const char *to_hname)
{
size_t l = strlen (from_file->name);
/* We have two sets of commands. We will go with the
one given in the rule explicitly mentioning this name,
one given in the rule found through directory search,
but give a message to let the user know what's going on. */
if (to_file->cmds->fileinfo.filenm != 0)
error (&from_file->cmds->fileinfo,
l + strlen (to_file->cmds->fileinfo.filenm) + INTSTR_LENGTH,
_("Recipe was specified for file '%s' at %s:%lu,"),
from_file->name, to_file->cmds->fileinfo.filenm,
to_file->cmds->fileinfo.lineno);
_("recipe was specified for file '%s' at %s:%lu,"),
from_file->name, from_file->cmds->fileinfo.filenm,
from_file->cmds->fileinfo.lineno);
else
error (&from_file->cmds->fileinfo, l,
_("Recipe for file '%s' was found by implicit rule search,"),
_("recipe for file '%s' was found by implicit rule search,"),
from_file->name);
l += strlen (to_hname);
error (&from_file->cmds->fileinfo, l,
_("but '%s' is now considered the same file as '%s'."),
_("but '%s' is now considered the same file as '%s'"),
from_file->name, to_hname);
error (&from_file->cmds->fileinfo, l,
_("Recipe for '%s' will be ignored in favor of the one for '%s'."),
to_hname, from_file->name);
_("recipe for '%s' will be ignored in favor of the one for '%s'"),
from_file->name, to_hname);
}
}
@ -327,18 +322,30 @@ rehash_file (struct file *from_file, const char *to_hname)
#define MERGE(field) to_file->field |= from_file->field
MERGE (precious);
MERGE (loaded);
MERGE (tried_implicit);
MERGE (updating);
MERGE (updated);
MERGE (is_target);
MERGE (cmd_target);
MERGE (phony);
MERGE (loaded);
/* Don't merge intermediate because this file might be pre-existing */
MERGE (is_explicit);
MERGE (secondary);
MERGE (notintermediate);
MERGE (ignore_vpath);
MERGE (snapped);
MERGE (suffix);
#undef MERGE
to_file->builtin = 0;
from_file->renamed = to_file;
if (rehashed_files_len % REHASHED_FILES_INCR == 0)
rehashed_files = xrealloc (rehashed_files,
sizeof (struct file *) * (rehashed_files_len + REHASHED_FILES_INCR));
rehashed_files[rehashed_files_len++] = from_file;
}
/* Rename FILE to NAME. This is not as simple as resetting
@ -369,7 +376,7 @@ remove_intermediates (int sig)
int doneany = 0;
/* If there's no way we will ever remove anything anyway, punt early. */
if (question_flag || touch_flag || all_secondary)
if (question_flag || touch_flag || all_secondary || no_intermediates)
return;
if (sig && just_print_flag)
@ -386,7 +393,7 @@ remove_intermediates (int sig)
given on the command line, and it's either a -include makefile or
it's not precious. */
if (f->intermediate && (f->dontcare || !f->precious)
&& !f->secondary && !f->cmd_target)
&& !f->secondary && !f->notintermediate && !f->cmd_target)
{
int status;
if (f->update_status == us_none)
@ -405,7 +412,7 @@ remove_intermediates (int sig)
{
if (sig)
OS (error, NILF,
_("*** Deleting intermediate file '%s'"), f->name);
_("*** deleting intermediate file '%s'"), f->name);
else
{
if (! doneany)
@ -424,7 +431,14 @@ remove_intermediates (int sig)
}
}
if (status < 0)
perror_with_name ("unlink: ", f->name);
{
if (doneany)
fputs ("\n", stdout);
fflush (stdout);
perror_with_name ("unlink: ", f->name);
/* Start printing over. */
doneany = 0;
}
}
}
}
@ -442,8 +456,7 @@ remove_intermediates (int sig)
struct dep *
split_prereqs (char *p)
{
struct dep *new = PARSE_FILE_SEQ (&p, struct dep, MAP_PIPE, NULL,
PARSEFS_NONE);
struct dep *new = PARSE_FILE_SEQ (&p, struct dep, MAP_PIPE, NULL, PARSEFS_WAIT);
if (*p)
{
@ -452,7 +465,7 @@ split_prereqs (char *p)
struct dep *ood;
++p;
ood = PARSE_SIMPLE_SEQ (&p, struct dep);
ood = PARSE_FILE_SEQ (&p, struct dep, MAP_NUL, NULL, PARSEFS_WAIT);
if (! new)
new = ood;
@ -486,7 +499,6 @@ enter_prereqs (struct dep *deps, const char *stem)
if (stem)
{
const char *pattern = "%";
char *buffer = variable_expand ("");
struct dep *dp = deps, *dl = 0;
while (dp != 0)
@ -506,14 +518,15 @@ enter_prereqs (struct dep *deps, const char *stem)
if (stem[0] == '\0')
{
memmove (percent, percent+1, strlen (percent));
o = variable_buffer_output (buffer, nm, strlen (nm) + 1);
o = variable_buffer_output (variable_buffer, nm,
strlen (nm) + 1);
}
else
o = patsubst_expand_pat (buffer, stem, pattern, nm,
o = patsubst_expand_pat (variable_buffer, stem, pattern, nm,
pattern+1, percent+1);
/* If the name expanded to the empty string, ignore it. */
if (buffer[0] == '\0')
if (variable_buffer[0] == '\0')
{
struct dep *df = dp;
if (dp == deps)
@ -525,7 +538,8 @@ enter_prereqs (struct dep *deps, const char *stem)
}
/* Save the name. */
dp->name = strcache_add_len (buffer, o - buffer);
dp->name = strcache_add_len (variable_buffer,
o - variable_buffer);
}
dp->stem = stem;
dp->staticpattern = 1;
@ -545,30 +559,29 @@ enter_prereqs (struct dep *deps, const char *stem)
d1->file = enter_file (d1->name);
d1->staticpattern = 0;
d1->name = 0;
if (!stem)
/* This file is explicitly mentioned as a prereq. */
d1->file->is_explicit = 1;
}
return deps;
}
/* Set the intermediate flag. */
static void
set_intermediate (const void *item)
{
struct file *f = (struct file *) item;
f->intermediate = 1;
}
/* Expand and parse each dependency line. */
static void
/* Expand and parse each dependency line.
For each dependency of the file, make the 'struct dep' point
at the appropriate 'struct file' (which may have to be created). */
void
expand_deps (struct file *f)
{
struct dep *d;
struct dep **dp;
const char *file_stem = f->stem;
const char *fstem;
int initialized = 0;
int changed_dep = 0;
f->updating = 0;
if (f->snapped)
return;
f->snapped = 1;
/* Walk through the dependencies. For any dependency that needs 2nd
expansion, expand it then insert the result into the list. */
@ -578,7 +591,6 @@ expand_deps (struct file *f)
{
char *p;
struct dep *new, *next;
char *name = (char *)d->name;
if (! d->name || ! d->need_2nd_expansion)
{
@ -588,16 +600,46 @@ expand_deps (struct file *f)
continue;
}
/* If it's from a static pattern rule, convert the patterns into
"$*" so they'll expand properly. */
/* If it's from a static pattern rule, convert the initial pattern in
each word to "$*" so they'll expand properly. */
if (d->staticpattern)
{
char *o = variable_expand ("");
o = subst_expand (o, name, "%", "$*", 1, 2, 0);
*o = '\0';
free (name);
d->name = name = xstrdup (variable_buffer);
d->staticpattern = 0;
const char *cs = d->name;
size_t nperc = 0;
/* Count the number of % in the string. */
while ((cs = strchr (cs, '%')) != NULL)
{
++nperc;
++cs;
}
if (nperc)
{
/* Allocate enough space to replace all % with $*. */
size_t slen = strlen (d->name) + nperc + 1;
const char *pcs = d->name;
char *name = xmalloc (slen);
char *s = name;
/* Substitute the first % in each word. */
cs = strchr (pcs, '%');
while (cs)
{
s = mempcpy (s, pcs, cs - pcs);
*(s++) = '$';
*(s++) = '*';
pcs = ++cs;
/* Find the first % after the next whitespace. */
cs = strchr (end_of_token (cs), '%');
}
strcpy (s, pcs);
free ((char*)d->name);
d->name = name;
}
}
/* We're going to do second expansion so initialize file variables for
@ -609,54 +651,139 @@ expand_deps (struct file *f)
initialized = 1;
}
if (d->stem != 0)
f->stem = d->stem;
set_file_variables (f, d->stem ? d->stem : f->stem);
set_file_variables (f);
/* Perform second expansion. */
p = expand_string_for_file (d->name, f);
p = variable_expand_for_file (d->name, f);
if (d->stem != 0)
f->stem = file_stem;
/* At this point we don't need the name anymore: free it. */
free (name);
/* Free the un-expanded name. */
free ((char*)d->name);
/* Parse the prerequisites and enter them into the file database. */
new = enter_prereqs (split_prereqs (p), d->stem);
new = split_prereqs (p);
/* If there were no prereqs here (blank!) then throw this one out. */
if (new == 0)
{
*dp = d->next;
changed_dep = 1;
free_dep (d);
d = *dp;
continue;
}
/* Add newly parsed prerequisites. */
fstem = d->stem;
next = d->next;
changed_dep = 1;
free_dep (d);
*dp = new;
for (dp = &new->next, d = new->next; d != 0; dp = &d->next, d = d->next)
;
for (dp = &new, d = new; d != 0; dp = &d->next, d = d->next)
{
d->file = lookup_file (d->name);
if (d->file == 0)
d->file = enter_file (d->name);
d->name = 0;
d->stem = fstem;
if (!fstem)
/* This file is explicitly mentioned as a prereq. */
d->file->is_explicit = 1;
}
*dp = next;
d = *dp;
}
/* Shuffle mode assumes '->next' and '->shuf' links both traverse the same
dependencies (in different sequences). Regenerate '->shuf' so we don't
refer to stale data. */
if (changed_dep)
shuffle_deps_recursive (f->deps);
}
/* Reset the updating flag. */
/* Add extra prereqs to the file in question. */
struct dep *
expand_extra_prereqs (const struct variable *extra)
{
struct dep *d;
struct dep *prereqs = extra ? split_prereqs (expand_string (extra->value)) : NULL;
for (d = prereqs; d; d = d->next)
{
d->file = lookup_file (d->name);
if (!d->file)
d->file = enter_file (d->name);
d->name = NULL;
d->ignore_automatic_vars = 1;
}
return prereqs;
}
/* Perform per-file snap operations. */
static void
reset_updating (const void *item)
snap_file (const void *item, void *arg)
{
struct file *f = (struct file *) item;
f->updating = 0;
struct file *f = (struct file*)item;
struct dep *prereqs = NULL;
struct dep *d;
/* If we're not doing second expansion then reset updating. */
if (!second_expansion)
f->updating = 0;
/* More specific setting has priority. */
/* If .SECONDARY is set with no deps, mark all targets as intermediate,
unless the target is a prereq of .NOTINTERMEDIATE. */
if (all_secondary && !f->notintermediate)
f->intermediate = 1;
/* If .NOTINTERMEDIATE is set with no deps, mark all targets as
notintermediate, unless the target is a prereq of .INTERMEDIATE. */
if (no_intermediates && !f->intermediate && !f->secondary)
f->notintermediate = 1;
/* If .EXTRA_PREREQS is set, add them as ignored by automatic variables. */
if (f->variables)
{
prereqs = expand_extra_prereqs (lookup_variable_in_set (
STRING_SIZE_TUPLE(".EXTRA_PREREQS"), f->variables->set));
if (second_expansion)
for (d = prereqs; d; d = d->next)
{
if (!d->name)
d->name = xstrdup (d->file->name);
d->need_2nd_expansion = 1;
}
}
else if (f->is_target)
prereqs = copy_dep_chain (arg);
if (prereqs)
{
for (d = prereqs; d; d = d->next)
if (streq (f->name, dep_name (d)))
/* Skip circular dependencies. */
break;
if (d)
/* We broke early: must have found a circular dependency. */
free_dep_chain (prereqs);
else if (!f->deps)
f->deps = prereqs;
else
{
d = f->deps;
while (d->next)
d = d->next;
d->next = prereqs;
}
}
}
/* For each dependency of each file, make the 'struct dep' point
at the appropriate 'struct file' (which may have to be created).
Also mark the files depended on by .PRECIOUS, .PHONY, .SILENT,
/* Mark the files depended on by .PRECIOUS, .PHONY, .SILENT,
and various other special targets. */
void
@ -670,40 +797,6 @@ snap_deps (void)
longer define new targets. */
snapped_deps = 1;
/* Perform second expansion and enter each dependency name as a file. We
must use hash_dump() here because within these loops we likely add new
files to the table, possibly causing an in-situ table expansion.
We only need to do this if second_expansion has been defined; if it
hasn't then all deps were expanded as the makefile was read in. If we
ever change make to be able to unset .SECONDARY_EXPANSION this will have
to change. */
if (second_expansion)
{
struct file **file_slot_0 = (struct file **) hash_dump (&files, 0, 0);
struct file **file_end = file_slot_0 + files.ht_fill;
struct file **file_slot;
const char *suffixes;
/* Expand .SUFFIXES: its prerequisites are used for $$* calc. */
f = lookup_file (".SUFFIXES");
suffixes = f ? f->name : 0;
for (; f != 0; f = f->prev)
expand_deps (f);
/* For every target that's not .SUFFIXES, expand its prerequisites. */
for (file_slot = file_slot_0; file_slot < file_end; file_slot++)
for (f = *file_slot; f != 0; f = f->prev)
if (f->name != suffixes)
expand_deps (f);
free (file_slot_0);
}
else
/* We're not doing second expansion, so reset updating. */
hash_map (&files, reset_updating);
/* Now manage all the special targets. */
for (f = lookup_file (".PRECIOUS"); f != 0; f = f->prev)
@ -727,11 +820,32 @@ snap_deps (void)
f2->mtime_before_update = NONEXISTENT_MTIME;
}
for (f = lookup_file (".NOTINTERMEDIATE"); f != 0; f = f->prev)
/* Mark .NOTINTERMEDIATE deps as notintermediate files. */
if (f->deps)
for (d = f->deps; d != 0; d = d->next)
for (f2 = d->file; f2 != 0; f2 = f2->prev)
f2->notintermediate = 1;
/* .NOTINTERMEDIATE with no deps marks all files as notintermediate. */
else
no_intermediates = 1;
/* The same file cannot be both .INTERMEDIATE and .NOTINTERMEDIATE.
However, it is possible for a file to be .INTERMEDIATE and also match a
.NOTINTERMEDIATE pattern. In that case, the intermediate file has
priority over the notintermediate pattern. This priority is enforced by
pattern_search. */
for (f = lookup_file (".INTERMEDIATE"); f != 0; f = f->prev)
/* Mark .INTERMEDIATE deps as intermediate files. */
for (d = f->deps; d != 0; d = d->next)
for (f2 = d->file; f2 != 0; f2 = f2->prev)
f2->intermediate = 1;
if (f2->notintermediate)
OS (fatal, NILF,
_("%s cannot be both .NOTINTERMEDIATE and .INTERMEDIATE"),
f2->name);
else
f2->intermediate = 1;
/* .INTERMEDIATE with no deps does nothing.
Marking all files as intermediates is useless since the goal targets
would be deleted after they are built. */
@ -741,13 +855,19 @@ snap_deps (void)
if (f->deps)
for (d = f->deps; d != 0; d = d->next)
for (f2 = d->file; f2 != 0; f2 = f2->prev)
if (f2->notintermediate)
OS (fatal, NILF,
_("%s cannot be both .NOTINTERMEDIATE and .SECONDARY"),
f2->name);
else
f2->intermediate = f2->secondary = 1;
/* .SECONDARY with no deps listed marks *all* files that way. */
else
{
all_secondary = 1;
hash_map (&files, set_intermediate);
}
all_secondary = 1;
if (no_intermediates && all_secondary)
O (fatal, NILF,
_(".NOTINTERMEDIATE and .SECONDARY are mutually exclusive"));
f = lookup_file (".EXPORT_ALL_VARIABLES");
if (f != 0 && f->is_target)
@ -777,7 +897,28 @@ snap_deps (void)
f = lookup_file (".NOTPARALLEL");
if (f != 0 && f->is_target)
not_parallel = 1;
{
struct dep *d2;
if (!f->deps)
not_parallel = 1;
else
/* Set a wait point between every prerequisite of each target. */
for (d = f->deps; d != NULL; d = d->next)
for (f2 = d->file; f2 != NULL; f2 = f2->prev)
if (f2->deps)
for (d2 = f2->deps->next; d2 != NULL; d2 = d2->next)
d2->wait_here = 1;
}
{
struct dep *prereqs = expand_extra_prereqs (lookup_variable (STRING_SIZE_TUPLE(".EXTRA_PREREQS")));
/* Perform per-file snap operations. */
hash_map_arg(&files, snap_file, prereqs);
free_dep_chain (prereqs);
}
#ifndef NO_MINUS_C_MINUS_O
/* If .POSIX was defined, remove OUTPUT_OPTION to comply. */
@ -822,7 +963,7 @@ file_timestamp_cons (const char *fname, time_t stamp, long int ns)
ts = s <= OLD_MTIME ? ORDINARY_MTIME_MIN : ORDINARY_MTIME_MAX;
file_timestamp_sprintf (buf, ts);
OSS (error, NILF,
_("%s: Timestamp out of range; substituting %s"), f, buf);
_("%s: timestamp out of range: substituting %s"), f, buf);
}
return ts;
@ -887,21 +1028,22 @@ file_timestamp_sprintf (char *p, FILE_TIMESTAMP ts)
struct tm *tm = localtime (&t);
if (tm)
sprintf (p, "%04d-%02d-%02d %02d:%02d:%02d",
tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec);
{
intmax_t year = tm->tm_year;
p += sprintf (p, "%04" PRIdMAX "-%02d-%02d %02d:%02d:%02d",
year + 1900, tm->tm_mon + 1, tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec);
}
else if (t < 0)
sprintf (p, "%ld", (long) t);
p += sprintf (p, "%" PRIdMAX, (intmax_t) t);
else
sprintf (p, "%lu", (unsigned long) t);
p += strlen (p);
p += sprintf (p, "%" PRIuMAX, (uintmax_t) t);
/* Append nanoseconds as a fraction, but remove trailing zeros. We don't
know the actual timestamp resolution, since clock_getres applies only to
local times, whereas this timestamp might come from a remote filesystem.
So removing trailing zeros is the best guess that we can do. */
sprintf (p, ".%09d", FILE_TIMESTAMP_NS (ts));
p += strlen (p) - 1;
p += sprintf (p, ".%09d", FILE_TIMESTAMP_NS (ts)) - 1;
while (*p == '0')
p--;
p += *p != '.';
@ -911,7 +1053,7 @@ file_timestamp_sprintf (char *p, FILE_TIMESTAMP ts)
/* Print the data base of files. */
void
static void
print_prereqs (const struct dep *deps)
{
const struct dep *ood = 0;
@ -919,17 +1061,17 @@ print_prereqs (const struct dep *deps)
/* Print all normal dependencies; note any order-only deps. */
for (; deps != 0; deps = deps->next)
if (! deps->ignore_mtime)
printf (" %s", dep_name (deps));
printf (" %s%s", deps->wait_here ? ".WAIT " : "", dep_name (deps));
else if (! ood)
ood = deps;
/* Print order-only deps, if we have any. */
if (ood)
{
printf (" | %s", dep_name (ood));
printf (" | %s%s", ood->wait_here ? ".WAIT " : "", dep_name (ood));
for (ood = ood->next; ood != 0; ood = ood->next)
if (ood->ignore_mtime)
printf (" %s", dep_name (ood));
printf (" %s%s", ood->wait_here ? ".WAIT " : "", dep_name (ood));
}
putchar ('\n');
@ -983,6 +1125,13 @@ print_file (const void *item)
printf (_("# Implicit/static pattern stem: '%s'\n"), f->stem);
if (f->intermediate)
puts (_("# File is an intermediate prerequisite."));
if (f->notintermediate)
puts (_("# File is a prerequisite of .NOTINTERMEDIATE."));
if (f->secondary)
puts (_("# File is secondary (prerequisite of .SECONDARY)."));
if (f->is_explicit)
puts (_("# File is explicitly mentioned."));
if (f->also_make != 0)
{
const struct dep *d;
@ -1058,6 +1207,34 @@ print_file_data_base (void)
fputs (_("\n# files hash-table stats:\n# "), stdout);
hash_print_stats (&files, stdout);
}
static void
print_target (const void *item)
{
const struct file *f = item;
if (!f->is_target || f->suffix)
return;
/* Ignore any special targets, as defined by POSIX. */
if (f->name[0] == '.' && isupper ((unsigned char)f->name[1]))
{
const char *cp = f->name + 1;
while (*(++cp) != '\0')
if (!isupper ((unsigned char)*cp))
break;
if (*cp == '\0')
return;
}
puts (f->name);
}
void
print_targets (void)
{
hash_map (&files, print_target);
}
/* Verify the integrity of the data base of files. */
@ -1065,7 +1242,7 @@ print_file_data_base (void)
do{ \
if (_p->_n && _p->_n[0] && !strcache_iscached (_p->_n)) \
error (NULL, strlen (_p->name) + CSTRLEN (# _n) + strlen (_p->_n), \
_("%s: Field '%s' not cached: %s"), _p->name, # _n, _p->_n); \
_("%s: field '%s' not cached: %s"), _p->name, # _n, _p->_n); \
}while(0)
static void
@ -1130,8 +1307,7 @@ build_target_list (char *value)
p = &value[off];
}
memcpy (p, f->name, l);
p += l;
p = mempcpy (p, f->name, l);
*(p++) = ' ';
}
*(p-1) = '\0';

View File

@ -1,5 +1,5 @@
/* Definition of target file data structures for GNU Make.
Copyright (C) 1988-2019 Free Software Foundation, Inc.
Copyright (C) 1988-2024 Free Software Foundation, Inc.
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify it under the
@ -12,7 +12,7 @@ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. */
this program. If not, see <https://www.gnu.org/licenses/>. */
/* Structure that represents the info on one file
@ -21,6 +21,11 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
#include "hash.h"
struct commands;
struct dep;
struct variable;
struct variable_set_list;
struct file
{
const char *name;
@ -79,6 +84,7 @@ struct file
unsigned int builtin:1; /* True if the file is a builtin rule. */
unsigned int precious:1; /* Non-0 means don't delete file on quit */
unsigned int loaded:1; /* True if the file is a loaded object. */
unsigned int unloaded:1; /* True if this loaded object was unloaded. */
unsigned int low_resolution_time:1; /* Nonzero if this file's time stamp
has only one-second resolution. */
unsigned int tried_implicit:1; /* Nonzero if have searched
@ -91,8 +97,11 @@ struct file
unsigned int phony:1; /* Nonzero if this is a phony file
i.e., a prerequisite of .PHONY. */
unsigned int intermediate:1;/* Nonzero if this is an intermediate file. */
unsigned int is_explicit:1; /* Nonzero if explicitly mentioned. */
unsigned int secondary:1; /* Nonzero means remove_intermediates should
not delete it. */
unsigned int notintermediate:1; /* Nonzero means a file is a prereq to
.NOTINTERMEDIATE. */
unsigned int dontcare:1; /* Nonzero if no complaint is to be made if
this target cannot be remade. */
unsigned int ignore_vpath:1;/* Nonzero if we threw out VPATH name. */
@ -100,6 +109,11 @@ struct file
pattern-specific variables. */
unsigned int no_diag:1; /* True if the file failed to update and no
diagnostics has been issued (dontcare). */
unsigned int was_shuffled:1; /* Did we already shuffle 'deps'? used when
--shuffle passes through the graph. */
unsigned int snapped:1; /* True if the deps of this file have been
secondary expanded. */
unsigned int suffix:1; /* True if this is a suffix rule. */
};
@ -110,6 +124,8 @@ struct file *lookup_file (const char *name);
struct file *enter_file (const char *name);
struct dep *split_prereqs (char *prereqstr);
struct dep *enter_prereqs (struct dep *prereqs, const char *stem);
void expand_deps (struct file *f);
struct dep *expand_extra_prereqs (const struct variable *extra);
void remove_intermediates (int sig);
void snap_deps (void);
void rename_file (struct file *file, const char *name);
@ -119,8 +135,8 @@ void notice_finished_file (struct file *file);
void init_hash_files (void);
void verify_file_data_base (void);
char *build_target_list (char *old_list);
void print_prereqs (const struct dep *deps);
void print_file_data_base (void);
void print_targets (void);
int try_implicit_rule (struct file *file, unsigned int depth);
int stemlen_compare (const void *v1, const void *v2);
@ -197,6 +213,8 @@ FILE_TIMESTAMP f_mtime (struct file *file, int search);
<< FILE_TIMESTAMP_LO_BITS) \
+ ORDINARY_MTIME_MIN + FILE_TIMESTAMPS_PER_S - 1)
#define is_ordinary_mtime(_t) ((_t) >= ORDINARY_MTIME_MIN && (_t) <= ORDINARY_MTIME_MAX)
/* Modtime value to use for 'infinitely new'. We used to get the current time
from the system and use that whenever we wanted 'new'. But that causes
trouble when the machine running make and the machine holding a file have

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@ NOTE: getopt is now part of the C library, so if you don't know what
"Keep this file name-space clean" means, talk to drepper@gnu.org
before changing it!
Copyright (C) 1987-2019 Free Software Foundation, Inc.
Copyright (C) 1987-2024 Free Software Foundation, Inc.
NOTE: The canonical source of this file is maintained with the GNU C Library.
Bugs can be reported to bug-glibc@gnu.org.
@ -18,7 +18,7 @@ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. */
this program. If not, see <https://www.gnu.org/licenses/>. */
/* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>.
Ditto for AIX 3.2 and <stdlib.h>. */
@ -68,7 +68,7 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
# include <unistd.h>
#endif /* GNU C library. */
#ifdef VMS
#if MK_OS_VMS
# include <unixlib.h>
# if HAVE_STRING_H - 0
# include <string.h>
@ -436,6 +436,10 @@ _getopt_initialize (int argc, char *const *argv, const char *optstring)
nonoption_flags_len = 0;
#endif
/* Make the compiler happy. */
(void)argc;
(void)argv;
return optstring;
}
@ -677,17 +681,18 @@ _getopt_internal (int argc, char *const *argv, const char *optstring,
else
{
if (opterr)
if (argv[optind - 1][1] == '-')
/* --option */
fprintf (stderr,
_("%s: option '--%s' doesn't allow an argument\n"),
argv[0], pfound->name);
else
/* +option or -option */
fprintf (stderr,
_("%s: option '%c%s' doesn't allow an argument\n"),
argv[0], argv[optind - 1][0], pfound->name);
{
if (argv[optind - 1][1] == '-')
/* --option */
fprintf (stderr,
_("%s: option '--%s' doesn't allow an argument\n"),
argv[0], pfound->name);
else
/* +option or -option */
fprintf (stderr,
_("%s: option '%c%s' doesn't allow an argument\n"),
argv[0], argv[optind - 1][0], pfound->name);
}
nextchar += strlen (nextchar);
optopt = pfound->val;

View File

@ -1,5 +1,5 @@
/* Declarations for getopt.
Copyright (C) 1989-2019 Free Software Foundation, Inc.
Copyright (C) 1989-2024 Free Software Foundation, Inc.
NOTE: The canonical source of this file is maintained with the GNU C Library.
Bugs can be reported to bug-glibc@gnu.org.
@ -14,7 +14,7 @@ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. */
this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef _GETOPT_H
#define _GETOPT_H 1

View File

@ -1,5 +1,5 @@
/* getopt_long and getopt_long_only entry points for GNU getopt.
Copyright (C) 1987-1994, 1996-2019 Free Software Foundation, Inc.
Copyright (C) 1987-1994, 1996-2024 Free Software Foundation, Inc.
NOTE: The canonical source of this file is maintained with the GNU C Library.
Bugs can be reported to bug-glibc@gnu.org.
@ -14,7 +14,7 @@ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. */
this program. If not, see <https://www.gnu.org/licenses/>. */
#ifdef HAVE_CONFIG_H
#include <config.h>

View File

@ -1,5 +1,5 @@
/* Convenience header for conditional use of GNU <libintl.h>.
Copyright (C) 1995-2019 Free Software Foundation, Inc.
Copyright (C) 1995-2024 Free Software Foundation, Inc.
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify it under the
@ -12,7 +12,7 @@ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. */
this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef _LIBGETTEXT_H
#define _LIBGETTEXT_H 1

View File

@ -1,5 +1,5 @@
;; Contents of the (gnu make) Guile module
;; Copyright (C) 2011-2019 Free Software Foundation, Inc.
;; Contents of the (GNU Make) Guile module
;; Copyright (C) 2011-2024 Free Software Foundation, Inc.
;; This file is part of GNU Make.
;;
;; GNU Make is free software; you can redistribute it and/or modify it under
@ -13,11 +13,11 @@
;; details.
;;
;; You should have received a copy of the GNU General Public License along
;; with this program. If not, see <http://www.gnu.org/licenses/>.
;; with this program. If not, see <https://www.gnu.org/licenses/>.
(define (to-string-maybe x)
(cond
;; In GNU make, "false" is the empty string
;; In GNU Make, "false" is the empty string
((or (not x)
(unspecified? x)
(variable? x)
@ -45,7 +45,7 @@
(walk x)
(string-join (reverse! acc))))
;; Return the value of the GNU make variable V
;; Return the value of the GNU Make variable V
(define (gmk-var v)
(gmk-expand (format #f "$(~a)" (obj-to-str v))))

View File

@ -1,7 +1,6 @@
/* External interfaces usable by dynamic objects loaded into GNU Make.
--THIS API IS A "TECHNOLOGY PREVIEW" ONLY. IT IS NOT A STABLE INTERFACE--
Copyright (C) 2013-2019 Free Software Foundation, Inc.
Copyright (C) 2013-2024 Free Software Foundation, Inc.
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify it under the
@ -14,11 +13,13 @@ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. */
this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef _GNUMAKE_H_
#define _GNUMAKE_H_
#define GMK_ABI_VERSION 1
/* Specify the location of elements read from makefiles. */
typedef struct
{
@ -28,6 +29,23 @@ typedef struct
typedef char *(*gmk_func_ptr)(const char *nm, unsigned int argc, char **argv);
/* When an object is loaded by GNU Make, a setup method will be invoked.
The name of the method is either derived from the filename of the object,
or specified explicitly in the makefile. It has the signature:
int <setup_fn> (unsigned int abi_version, const gmk_floc *flocp);
The abi_version will be set to GMK_ABI_VERSION.
When an object is unloaded by GNU Make, an unload method will be invoked.
The name of the method is derived from the filename of the object, with
_gmk_unload appended. It has the signature:
void <object>_gmk_unload (void);
There will only be one unload method invoked regardless of the number of
setup methods within the object. */
#ifdef _WIN32
# ifdef GMK_BUILDING_MAKE
# define GMK_EXPORT __declspec(dllexport)
@ -38,26 +56,26 @@ typedef char *(*gmk_func_ptr)(const char *nm, unsigned int argc, char **argv);
# define GMK_EXPORT
#endif
/* Free memory returned by the gmk_expand() function. */
/* Free memory returned by the gmk_expand() and gmk_free() functions. */
GMK_EXPORT void gmk_free (char *str);
/* Allocate memory in GNU make's context. */
/* Allocate memory in GNU Make's context. */
GMK_EXPORT char *gmk_alloc (unsigned int len);
/* Run $(eval ...) on the provided string BUFFER. */
GMK_EXPORT void gmk_eval (const char *buffer, const gmk_floc *floc);
/* Run GNU make expansion on the provided string STR.
/* Run GNU Make expansion on the provided string STR.
Returns an allocated buffer that the caller must free with gmk_free(). */
GMK_EXPORT char *gmk_expand (const char *str);
/* Register a new GNU make function NAME (maximum of 255 chars long).
/* Register a new GNU Make function NAME (maximum of 255 chars long).
When the function is expanded in the makefile, FUNC will be invoked with
the appropriate arguments.
The return value of FUNC must be either NULL, in which case it expands to
the empty string, or a pointer to the result of the expansion in a string
created by gmk_alloc(). GNU make will free the memory when it's done.
created by gmk_alloc(). GNU Make will free the memory when it's done.
MIN_ARGS is the minimum number of arguments the function requires.
MAX_ARGS is the maximum number of arguments (or 0 if there's no maximum).

View File

@ -1,5 +1,5 @@
/* GNU Guile interface for GNU Make.
Copyright (C) 2011-2019 Free Software Foundation, Inc.
Copyright (C) 2011-2024 Free Software Foundation, Inc.
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify it under the
@ -12,7 +12,7 @@ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. */
this program. If not, see <https://www.gnu.org/licenses/>. */
#include "makeint.h"
@ -47,7 +47,7 @@ cvt_scm_to_str (SCM obj)
return scm_to_locale_string (scm_call_1 (obj_to_str, obj));
}
/* Perform the GNU make expansion function. */
/* Perform the GNU Make expansion function. */
static SCM
guile_expand_wrapper (SCM obj)
{
@ -65,7 +65,7 @@ guile_expand_wrapper (SCM obj)
return ret;
}
/* Perform the GNU make eval function. */
/* Perform the GNU Make eval function. */
static SCM
guile_eval_wrapper (SCM obj)
{
@ -77,24 +77,24 @@ guile_eval_wrapper (SCM obj)
return SCM_BOOL_F;
}
/* Invoked by scm_c_define_module(), in the context of the GNU make module. */
/* Invoked by scm_c_define_module(), in the context of the GNU Make module. */
static void
guile_define_module (void *data UNUSED)
{
/* Ingest the predefined Guile module for GNU make. */
/* Ingest the predefined Guile module for GNU Make. */
#include "gmk-default.h"
/* Register a subr for GNU make's eval capability. */
/* Register a subr for GNU Make's eval capability. */
scm_c_define_gsubr ("gmk-expand", 1, 0, 0, (GSUBR_TYPE) guile_expand_wrapper);
/* Register a subr for GNU make's eval capability. */
/* Register a subr for GNU Make's eval capability. */
scm_c_define_gsubr ("gmk-eval", 1, 0, 0, (GSUBR_TYPE) guile_eval_wrapper);
/* Define the rest of the module. */
scm_c_eval_string (GUILE_module_defn);
}
/* Initialize the GNU make Guile module. */
/* Initialize the GNU Make Guile module. */
static void *
guile_init (void *arg UNUSED)
{
@ -104,7 +104,7 @@ guile_init (void *arg UNUSED)
/* Get a reference to the object-to-string translator, for later. */
obj_to_str = scm_variable_ref (scm_c_module_lookup (make_mod, "obj-to-str"));
/* Import the GNU make module exports into the generic space. */
/* Import the GNU Make module exports into the generic space. */
scm_c_eval_string ("(use-modules (gnu make))");
return NULL;

View File

@ -12,10 +12,11 @@ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. */
this program. If not, see <https://www.gnu.org/licenses/>. */
#include "makeint.h"
#include "hash.h"
#include <assert.h>
#define CALLOC(t, n) ((t *) xcalloc (sizeof (t) * (n)))
#define MALLOC(t, n) ((t *) xmalloc (sizeof (t) * (n)))
@ -32,7 +33,7 @@ static unsigned long round_up_2 __P((unsigned long rough));
potentially hit every slot in the table during collision
resolution. */
void *hash_deleted_item = &hash_deleted_item;
const void *hash_deleted_item = &hash_deleted_item;
/* Force the table size to be a power of two, possibly rounding up the
given size. */
@ -43,11 +44,11 @@ hash_init (struct hash_table *ht, unsigned long size,
{
ht->ht_size = round_up_2 (size);
ht->ht_empty_slots = ht->ht_size;
ht->ht_vec = (void**) CALLOC (struct token *, ht->ht_size);
ht->ht_vec = CALLOC (void *, ht->ht_size);
if (ht->ht_vec == 0)
{
fprintf (stderr, _("can't allocate %lu bytes for hash table: memory exhausted"),
ht->ht_size * (unsigned long) sizeof (struct token *));
ht->ht_size * (unsigned long) sizeof (void *));
exit (MAKE_TROUBLE);
}
@ -64,10 +65,10 @@ hash_init (struct hash_table *ht, unsigned long size,
/* Load an array of items into 'ht'. */
void
hash_load (struct hash_table *ht, void *item_table,
hash_load (struct hash_table *ht, const void *item_table,
unsigned long cardinality, unsigned long size)
{
char *items = (char *) item_table;
const char *items = (const char *) item_table;
while (cardinality--)
{
hash_insert (ht, items);
@ -259,7 +260,7 @@ hash_rehash (struct hash_table *ht)
ht->ht_capacity = ht->ht_size - (ht->ht_size >> 4);
}
ht->ht_rehashes++;
ht->ht_vec = (void **) CALLOC (struct token *, ht->ht_size);
ht->ht_vec = CALLOC (void *, ht->ht_size);
for (ovp = old_vec; ovp < &old_vec[old_ht_size]; ovp++)
{
@ -360,11 +361,12 @@ round_up_2 (unsigned long n)
#define sum_get_unaligned_32(r, p) \
do { \
unsigned int val; \
memcpy(&val, (p), 4); \
memcpy (&val, (p), 4); \
r += val; \
} while(0);
unsigned jhash(unsigned const char *k, int length)
unsigned int
jhash(unsigned const char *k, int length)
{
unsigned int a, b, c;
@ -408,12 +410,19 @@ unsigned jhash(unsigned const char *k, int length)
return c;
}
#define UINTSZ sizeof (unsigned int)
#ifdef WORDS_BIGENDIAN
/* The ifs are ordered from the first byte in memory to the last. */
#define sum_up_to_nul(r, p, flag) \
/* The ifs are ordered from the first byte in memory to the last.
Help the compiler optimize by using static memcpy length. */
#define sum_up_to_nul(r, p, plen, flag) \
do { \
unsigned int val; \
memcpy(&val, (p), 4); \
unsigned int val = 0; \
size_t pn = (plen); \
if (pn >= UINTSZ) \
memcpy (&val, (p), UINTSZ); \
else \
memcpy (&val, (p), pn); \
if ((val & 0xFF000000) == 0) \
flag = 1; \
else if ((val & 0xFF0000) == 0) \
@ -426,52 +435,64 @@ unsigned jhash(unsigned const char *k, int length)
#else
/* First detect the presence of zeroes. If there is none, we can
sum the 4 bytes directly. Otherwise, the ifs are ordered as in the
big endian case, from the first byte in memory to the last. */
#define sum_up_to_nul(r, p, flag) \
do { \
unsigned int val; \
unsigned int zeroes; \
memcpy(&val, (p), 4); \
zeroes = ((val - 0x01010101) & ~val); \
if (!(zeroes & 0x80808080)) \
r += val; \
else if ((val & 0xFF) == 0) \
flag = 1; \
else if ((val & 0xFF00) == 0) \
r += val & 0xFF, flag = 1; \
else if ((val & 0xFF0000) == 0) \
r += val & 0xFFFF, flag = 1; \
else \
r += val, flag = 1; \
big endian case, from the first byte in memory to the last.
Help the compiler optimize by using static memcpy length. */
#define sum_up_to_nul(r, p, plen, flag) \
do { \
unsigned int val = 0; \
size_t pn = (plen); \
if (pn >= UINTSZ) \
memcpy (&val, (p), UINTSZ); \
else \
memcpy (&val, (p), pn); \
flag = ((val - 0x01010101) & ~val) & 0x80808080; \
if (!flag) \
r += val; \
else if (val & 0xFF) \
{ \
if ((val & 0xFF00) == 0) \
r += val & 0xFF; \
else if ((val & 0xFF0000) == 0) \
r += val & 0xFFFF; \
else \
r += val; \
} \
} while (0)
#endif
/* This function performs magic which is correct but causes ASAN heartburn
when we pass in a global constant string (at least). */
__attribute__((no_sanitize_address))
unsigned jhash_string(unsigned const char *k)
unsigned int
jhash_string(unsigned const char *k)
{
unsigned int a, b, c;
unsigned int have_nul = 0;
unsigned const char *start = k;
size_t klen = strlen ((const char*)k);
/* Set up the internal state */
a = b = c = JHASH_INITVAL;
/* All but the last block: affect some 32 bits of (a,b,c) */
for (;;) {
sum_up_to_nul(a, k, have_nul);
sum_up_to_nul(a, k, klen, have_nul);
if (have_nul)
break;
k += 4;
sum_up_to_nul(b, k, have_nul);
k += UINTSZ;
assert (klen >= UINTSZ);
klen -= UINTSZ;
sum_up_to_nul(b, k, klen, have_nul);
if (have_nul)
break;
k += 4;
sum_up_to_nul(c, k, have_nul);
k += UINTSZ;
assert (klen >= UINTSZ);
klen -= UINTSZ;
sum_up_to_nul(c, k, klen, have_nul);
if (have_nul)
break;
k += 4;
k += UINTSZ;
assert (klen >= UINTSZ);
klen -= UINTSZ;
jhash_mix(a, b, c);
}

View File

@ -12,7 +12,7 @@ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. */
this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef _hash_h_
#define _hash_h_
@ -20,7 +20,7 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
#include <stdio.h>
#include <ctype.h>
#if defined __cplusplus || (defined __STDC__ && __STDC__) || defined WINDOWS32
#if defined __cplusplus || (defined __STDC__ && __STDC__) || MK_OS_W32
# if !defined __GLIBC__ || !defined __P
# undef __P
# define __P(protos) protos
@ -56,9 +56,9 @@ struct hash_table
typedef int (*qsort_cmp_t) __P((void const *, void const *));
void hash_init __P((struct hash_table *ht, unsigned long size,
hash_func_t hash_1, hash_func_t hash_2, hash_cmp_func_t hash_cmp));
void hash_load __P((struct hash_table *ht, void *item_table,
unsigned long cardinality, unsigned long size));
hash_func_t hash_1, hash_func_t hash_2, hash_cmp_func_t hash_cmp));
void hash_load __P((struct hash_table *ht, const void *item_table,
unsigned long cardinality, unsigned long size));
void **hash_find_slot __P((struct hash_table *ht, void const *key));
void *hash_find_item __P((struct hash_table *ht, void const *key));
void *hash_insert __P((struct hash_table *ht, const void *item));
@ -76,7 +76,7 @@ void **hash_dump __P((struct hash_table *ht, void **vector_0, qsort_cmp_t compar
extern unsigned jhash(unsigned char const *key, int n);
extern unsigned jhash_string(unsigned char const *key);
extern void *hash_deleted_item;
extern const void *hash_deleted_item;
#define HASH_VACANT(item) ((item) == 0 || (void *) (item) == hash_deleted_item)
@ -154,7 +154,7 @@ extern void *hash_deleted_item;
#define ISTRING_HASH_1(KEY, RESULT) do { \
unsigned char const *_key_ = (unsigned char const *) (KEY) - 1; \
while (*++_key_) \
(RESULT) += ((isupper (*_key_) ? tolower (*_key_) : *_key_) << (_key_[1] & 0xf)); \
(RESULT) += (tolower (*_key_) << (_key_[1] & 0xf)); \
} while (0)
#define return_ISTRING_HASH_1(KEY) do { \
unsigned long _result_ = 0; \
@ -165,7 +165,7 @@ extern void *hash_deleted_item;
#define ISTRING_HASH_2(KEY, RESULT) do { \
unsigned char const *_key_ = (unsigned char const *) (KEY) - 1; \
while (*++_key_) \
(RESULT) += ((isupper (*_key_) ? tolower (*_key_) : *_key_) << (_key_[1] & 0x7)); \
(RESULT) += (tolower (*_key_) << (_key_[1] & 0x7)); \
} while (0)
#define return_ISTRING_HASH_2(KEY) do { \
unsigned long _result_ = 0; \

View File

@ -1,5 +1,5 @@
/* Implicit rule searching for GNU Make.
Copyright (C) 1988-2019 Free Software Foundation, Inc.
Copyright (C) 1988-2024 Free Software Foundation, Inc.
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify it under the
@ -12,7 +12,7 @@ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. */
this program. If not, see <https://www.gnu.org/licenses/>. */
#include "makeint.h"
#include "filedef.h"
@ -22,9 +22,12 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
#include "variable.h"
#include "job.h" /* struct child, used inside commands.h */
#include "commands.h" /* set_file_variables */
#include "shuffle.h"
#include <assert.h>
static int pattern_search (struct file *file, int archive,
unsigned int depth, unsigned int recursions);
unsigned int depth, unsigned int recursions,
int allow_compat_rules);
/* For a FILE which has no commands specified, try to figure out some
from the implicit pattern rules.
@ -42,7 +45,7 @@ try_implicit_rule (struct file *file, unsigned int depth)
(the archive search omits the archive name), it is more specific and
should come first. */
if (pattern_search (file, 0, depth, 0))
if (pattern_search (file, 0, depth, 0, 0))
return 1;
#ifndef NO_ARCHIVES
@ -52,8 +55,11 @@ try_implicit_rule (struct file *file, unsigned int depth)
{
DBF (DB_IMPLICIT,
_("Looking for archive-member implicit rule for '%s'.\n"));
if (pattern_search (file, 1, depth, 0))
if (pattern_search (file, 1, depth, 0, 0))
return 1;
DBS (DB_IMPLICIT,
(_("No archive-member implicit rule found for '%s'.\n"),
file->name));
}
#endif
@ -81,12 +87,10 @@ get_next_word (const char *buffer, size_t *length)
return 0;
/* We already found the first value of "c", above. */
while (1)
{
char closeparen;
int count;
/* Each time through the loop, "c" has the current char
and "p" points to the next char. */
switch (c)
{
case '\0':
@ -95,31 +99,8 @@ get_next_word (const char *buffer, size_t *length)
goto done_word;
case '$':
c = *(p++);
if (c == '$')
break;
/* This is a variable reference, so read it to the matching
close paren. */
if (c == '(')
closeparen = ')';
else if (c == '{')
closeparen = '}';
else
/* This is a single-letter variable reference. */
break;
for (count = 0; *p != '\0'; ++p)
{
if (*p == c)
++count;
else if (*p == closeparen && --count < 0)
{
++p;
break;
}
}
/* This is a variable reference, so skip it. */
p = skip_reference (p);
break;
case '|':
@ -152,6 +133,9 @@ struct patdeps
const char *pattern;
struct file *file;
unsigned int ignore_mtime : 1;
unsigned int ignore_automatic_vars : 1;
unsigned int is_explicit : 1;
unsigned int wait_here : 1;
};
/* This structure stores information about pattern rules that we need
@ -199,7 +183,8 @@ stemlen_compare (const void *v1, const void *v2)
static int
pattern_search (struct file *file, int archive,
unsigned int depth, unsigned int recursions)
unsigned int depth, unsigned int recursions,
int allow_compat_rules)
{
/* Filename we are searching for a rule for. */
const char *filename = archive ? strchr (file->name, '(') : file->name;
@ -220,8 +205,13 @@ pattern_search (struct file *file, int archive,
struct patdeps *deplist = xmalloc (max_deps * sizeof (struct patdeps));
struct patdeps *pat = deplist;
/* Names of possible dependencies are constructed in this buffer. */
char *depname = alloca (namelen + max_pattern_dep_length);
/* Names of possible dependencies are constructed in this buffer.
We may replace % by $(*F) for second expansion, increasing the length. */
size_t deplen = namelen + max_pattern_dep_length + 4;
char *depname = alloca (deplen);
#ifndef NDEBUG
char *dend = depname + deplen;
#endif
/* The start and length of the stem of FILENAME for the current rule. */
const char *stem = 0;
@ -249,6 +239,7 @@ pattern_search (struct file *file, int archive,
int specific_rule_matched = 0;
unsigned int ri; /* uninit checks OK */
int found_compat_rule = 0;
struct rule *rule;
char *pathdir = NULL;
@ -256,6 +247,8 @@ pattern_search (struct file *file, int archive,
PATH_VAR (stem_str); /* @@ Need to get rid of stem, stemlen, etc. */
++depth;
#ifndef NO_ARCHIVES
if (archive || ar_name (filename))
lastslash = 0;
@ -265,8 +258,8 @@ pattern_search (struct file *file, int archive,
/* Set LASTSLASH to point at the last slash in FILENAME
but not counting any slash at the end. (foo/bar/ counts as
bar/ in directory foo/, not empty in directory foo/bar/.) */
lastslash = strrchr (filename, '/');
#ifdef VMS
lastslash = memrchr (filename, '/', namelen - 1);
#if MK_OS_VMS
if (lastslash == NULL)
lastslash = strrchr (filename, ']');
if (lastslash == NULL)
@ -278,18 +271,16 @@ pattern_search (struct file *file, int archive,
/* Handle backslashes (possibly mixed with forward slashes)
and the case of "d:file". */
{
char *bslash = strrchr (filename, '\\');
char *bslash = memrchr (filename, '\\', namelen - 1);
if (lastslash == 0 || bslash > lastslash)
lastslash = bslash;
if (lastslash == 0 && filename[0] && filename[1] == ':')
lastslash = filename + 1;
}
#endif
if (lastslash != 0 && lastslash[1] == '\0')
lastslash = 0;
}
pathlen = lastslash - filename + 1;
pathlen = lastslash ? lastslash - filename + 1 : 0;
/* First see which pattern rules match this target and may be considered.
Put them in TRYRULES. */
@ -308,7 +299,9 @@ pattern_search (struct file *file, int archive,
don't use it here. */
if (rule->in_use)
{
DBS (DB_IMPLICIT, (_("Avoiding implicit rule recursion.\n")));
DBS (DB_IMPLICIT,
(_("Avoiding implicit rule recursion for rule '%s'.\n"),
get_rule_defn (rule)));
continue;
}
@ -339,7 +332,7 @@ pattern_search (struct file *file, int archive,
check_lastslash = 0;
if (lastslash)
{
#ifdef VMS
#if MK_OS_VMS
check_lastslash = strpbrk (target, "/]>:") == NULL;
#else
check_lastslash = strchr (target, '/') == 0;
@ -431,6 +424,8 @@ pattern_search (struct file *file, int archive,
for (intermed_ok = 0; intermed_ok < 2; ++intermed_ok)
{
pat = deplist;
if (intermed_ok)
DBS (DB_IMPLICIT, (_("Trying harder.\n")));
/* Try each pattern rule till we find one that applies. If it does,
expand its dependencies (as substituted) and chain them in DEPS. */
@ -443,7 +438,6 @@ pattern_search (struct file *file, int archive,
unsigned int deps_found = 0;
/* NPTR points to the part of the prereq we haven't processed. */
const char *nptr = 0;
const char *dir = NULL;
int order_only = 0;
unsigned int matches;
@ -478,30 +472,38 @@ pattern_search (struct file *file, int archive,
memcpy (pathdir, filename, pathlen);
pathdir[pathlen] = '\0';
}
dir = pathdir;
}
if (stemlen > GET_PATH_MAX)
DBS (DB_IMPLICIT,
(_("Trying pattern rule '%s' with stem '%.*s'.\n"),
get_rule_defn (rule), (int) stemlen, stem));
if (stemlen + (check_lastslash ? pathlen : 0) > GET_PATH_MAX)
{
DBS (DB_IMPLICIT, (_("Stem too long: '%.*s'.\n"),
DBS (DB_IMPLICIT, (_("Stem too long: '%s%.*s'.\n"),
check_lastslash ? pathdir : "",
(int) stemlen, stem));
continue;
}
DBS (DB_IMPLICIT, (_("Trying pattern rule with stem '%.*s'.\n"),
(int) stemlen, stem));
strncpy (stem_str, stem, stemlen);
stem_str[stemlen] = '\0';
if (!check_lastslash)
{
memcpy (stem_str, stem, stemlen);
stem_str[stemlen] = '\0';
}
else
{
/* We want to prepend the directory from
the original FILENAME onto the stem. */
memcpy (stem_str, filename, pathlen);
memcpy (stem_str + pathlen, stem, stemlen);
stem_str[pathlen + stemlen] = '\0';
}
/* If there are no prerequisites, then this rule matches. */
if (rule->deps == 0)
break;
/* Temporary assign STEM to file->stem (needed to set file
variables below). */
file->stem = stem_str;
/* Mark this rule as in use so a recursive pattern_search won't try
to use it. */
rule->in_use = 1;
@ -516,7 +518,6 @@ pattern_search (struct file *file, int archive,
while (1)
{
struct dep *dl, *d;
char *p;
/* If we're out of name to parse, start the next prereq. */
if (! nptr)
@ -530,31 +531,33 @@ pattern_search (struct file *file, int archive,
/* If we don't need a second expansion, just replace the %. */
if (! dep->need_2nd_expansion)
{
p = strchr (nptr, '%');
if (p == 0)
char *p;
int is_explicit = 1;
const char *cp = strchr (nptr, '%');
if (cp == 0)
strcpy (depname, nptr);
else
{
char *o = depname;
if (check_lastslash)
{
memcpy (o, filename, pathlen);
o += pathlen;
}
memcpy (o, nptr, p - nptr);
o += p - nptr;
memcpy (o, stem_str, stemlen);
o += stemlen;
strcpy (o, p + 1);
o = mempcpy (o, filename, pathlen);
o = mempcpy (o, nptr, cp - nptr);
o = mempcpy (o, stem, stemlen);
strcpy (o, cp + 1);
is_explicit = 0;
}
/* Parse the expanded string. It might have wildcards. */
p = depname;
dl = PARSE_SIMPLE_SEQ (&p, struct dep);
dl = PARSE_FILE_SEQ (&p, struct dep, MAP_NUL, NULL,
PARSEFS_ONEWORD|PARSEFS_WAIT);
for (d = dl; d != NULL; d = d->next)
{
++deps_found;
d->ignore_mtime = dep->ignore_mtime;
d->ignore_automatic_vars = dep->ignore_automatic_vars;
d->wait_here |= dep->wait_here;
d->is_explicit = is_explicit;
}
/* We've used up this dep, so next time get a new one. */
@ -574,17 +577,22 @@ pattern_search (struct file *file, int archive,
{
int add_dir = 0;
size_t len;
const char *end;
struct dep **dptr;
int is_explicit;
const char *cp;
char *p;
nptr = get_next_word (nptr, &len);
if (nptr == 0)
continue;
end = nptr + len;
/* See this is a transition to order-only prereqs. */
/* See if this is a transition to order-only prereqs. */
if (! order_only && len == 1 && nptr[0] == '|')
{
order_only = 1;
nptr += len;
nptr = end;
continue;
}
@ -594,50 +602,86 @@ pattern_search (struct file *file, int archive,
again. This is not good if you have certain characters
in your stem (like $).
Instead, we will replace % with $* and allow the second
expansion to take care of it for us. This way (since $*
is a simple variable) there won't be additional
re-expansion of the stem. */
Instead, we will replace % with $* or $(*F) and allow the
second expansion to take care of it for us. This way
(since $* and $(*F) are simple variables) there won't be
additional re-expansion of the stem. */
p = lindex (nptr, nptr + len, '%');
if (p == 0)
cp = lindex (nptr, end, '%');
if (cp == 0)
{
memcpy (depname, nptr, len);
depname[len] = '\0';
is_explicit = 1;
}
else
{
size_t i = p - nptr;
memcpy (depname, nptr, i);
memcpy (depname + i, "$*", 2);
memcpy (depname + i + 2, p + 1, len - i - 1);
depname[len + 2 - 1] = '\0';
/* Go through all % between NPTR and END.
Copy contents of [NPTR, END) to depname, with the
first % after NPTR and then each first % after white
space replaced with $* or $(*F). depname has enough
room to substitute each % with $(*F). */
char *o = depname;
if (check_lastslash)
add_dir = 1;
is_explicit = 0;
for (;;)
{
size_t i = cp - nptr;
assert (o + i < dend);
o = mempcpy (o, nptr, i);
if (check_lastslash)
{
add_dir = 1;
assert (o + 5 < dend);
o = mempcpy (o, "$(*F)", 5);
}
else
{
assert (o + 2 < dend);
o = mempcpy (o, "$*", 2);
}
assert (o < dend);
++cp;
assert (cp <= end);
nptr = cp;
if (nptr == end)
break;
/* Skip the rest of this word then find the next %.
No need to worry about order-only, or nested
functions: NPTR went though get_next_word. */
while (cp < end && ! END_OF_TOKEN (*cp))
++cp;
cp = lindex (cp, end, '%');
if (cp == 0)
break;
}
len = end - nptr;
memcpy (o, nptr, len);
o[len] = '\0';
}
/* Set up for the next word. */
nptr += len;
nptr = end;
/* Initialize and set file variables if we haven't already
done so. */
if (!file_vars_initialized)
{
initialize_file_variables (file, 0);
set_file_variables (file);
set_file_variables (file, stem_str);
file_vars_initialized = 1;
}
/* Update the stem value in $* for this rule. */
else if (!file_variables_set)
{
define_variable_for_file (
"*", 1, file->stem, o_automatic, 0, file);
"*", 1, stem_str, o_automatic, 0, file);
file_variables_set = 1;
}
/* Perform the 2nd expansion. */
p = variable_expand_for_file (depname, file);
p = expand_string_for_file (depname, file);
dptr = &dl;
/* Parse the results into a deps list. */
@ -646,7 +690,8 @@ pattern_search (struct file *file, int archive,
/* Parse the expanded string. */
struct dep *dp = PARSE_FILE_SEQ (&p, struct dep,
order_only ? MAP_NUL : MAP_PIPE,
add_dir ? dir : NULL, PARSEFS_NONE);
add_dir ? pathdir : NULL,
PARSEFS_WAIT);
*dptr = dp;
for (d = dp; d != NULL; d = d->next)
@ -654,6 +699,7 @@ pattern_search (struct file *file, int archive,
++deps_found;
if (order_only)
d->ignore_mtime = 1;
d->is_explicit = is_explicit;
dptr = &d->next;
}
@ -684,8 +730,10 @@ pattern_search (struct file *file, int archive,
/* Go through the nameseq and handle each as a prereq name. */
for (d = dl; d != 0; d = d->next)
{
struct dep *expl_d;
struct file *df;
int is_rule = d->name == dep_name (dep);
int explicit = 0;
struct dep *dp = 0;
if (file_impossible_p (d->name))
{
@ -694,9 +742,11 @@ pattern_search (struct file *file, int archive,
second pass either since we know that will fail. */
DBS (DB_IMPLICIT,
(is_rule
? _("Rejecting impossible rule prerequisite '%s'.\n")
: _("Rejecting impossible implicit prerequisite '%s'.\n"),
d->name));
? _("Rejecting rule '%s' due to impossible rule"
" prerequisite '%s'.\n")
: _("Rejecting rule '%s' due to impossible implicit"
" prerequisite '%s'.\n"),
get_rule_defn (rule), d->name));
tryrules[ri].rule = 0;
failed = 1;
@ -705,41 +755,87 @@ pattern_search (struct file *file, int archive,
memset (pat, '\0', sizeof (struct patdeps));
pat->ignore_mtime = d->ignore_mtime;
pat->ignore_automatic_vars = d->ignore_automatic_vars;
pat->wait_here = d->wait_here;
pat->is_explicit = d->is_explicit;
DBS (DB_IMPLICIT,
(is_rule
? _("Trying rule prerequisite '%s'.\n")
: _("Trying implicit prerequisite '%s'.\n"), d->name));
/* If this prereq is also explicitly mentioned for FILE,
skip all tests below since it must be built no matter
which implicit rule we choose. */
df = lookup_file (d->name);
for (expl_d = file->deps; expl_d != 0; expl_d = expl_d->next)
if (streq (dep_name (expl_d), d->name))
break;
if (expl_d != 0)
if (df && df->is_explicit)
pat->is_explicit = 1;
/* If we found a file for the dep, set its intermediate flag.
df->is_explicit is set when the dep file is mentioned
explicitly on some other rule. d->is_explicit is set when
the dep file is mentioned explicitly on this rule. E.g.:
%.x : %.y ; ...
then:
one.x:
one.y: # df->is_explicit
vs.
one.x: one.y # d->is_explicit
*/
if (df && !df->is_explicit && !d->is_explicit)
df->intermediate = 1;
/* If the pattern prereq is also explicitly mentioned for
FILE, skip all tests below since it must be built no
matter which implicit rule we choose. */
if (df && df->is_target)
/* This prerequisite is mentioned explicitly as a target of
some rule. */
explicit = 1;
else
for (dp = file->deps; dp != 0; dp = dp->next)
if (streq (d->name, dep_name (dp)))
break;
/* If dp is set, this prerequisite is mentioned explicitly as
a prerequisite of the current target. */
if (explicit || dp)
{
(pat++)->name = d->name;
DBS (DB_IMPLICIT, (_("'%s' ought to exist.\n"), d->name));
continue;
}
/* The DEP->changed flag says that this dependency resides
in a nonexistent directory. So we normally can skip
looking for the file. However, if CHECK_LASTSLASH is
set, then the dependency file we are actually looking for
is in a different directory (the one gotten by prepending
FILENAME's directory), so it might actually exist. */
/* @@ dep->changed check is disabled. */
if (lookup_file (d->name) != 0
/*|| ((!dep->changed || check_lastslash) && */
|| file_exists_p (d->name))
if (file_exists_p (d->name))
{
(pat++)->name = d->name;
DBS (DB_IMPLICIT, (_("Found '%s'.\n"), d->name));
continue;
}
if (df && allow_compat_rules)
{
(pat++)->name = d->name;
DBS (DB_IMPLICIT,
(_("Using compatibility rule '%s' due to '%s'.\n"),
get_rule_defn (rule), d->name));
continue;
}
if (df)
{
/* This prerequisite is mentioned explicitly as a
prerequisite on some rule, but it is not a
prerequisite of the current target. Therefore, this
prerequisite does not qualify as ought-to-exist. Keep
note of this rule and continue the search. If a more
suitable rule is not found, then use this rule. */
DBS (DB_IMPLICIT,
(_("Prerequisite '%s' of rule '%s' does not qualify"
" as ought to exist.\n"),
d->name, get_rule_defn (rule)));
found_compat_rule = 1;
}
/* This code, given FILENAME = "lib/foo.o", dependency name
"lib/foo.c", and VPATH=src, searches for
"src/lib/foo.c". */
@ -748,7 +844,7 @@ pattern_search (struct file *file, int archive,
if (vname)
{
DBS (DB_IMPLICIT,
(_("Found prerequisite '%s' as VPATH '%s'\n"),
(_("Found prerequisite '%s' as VPATH '%s'.\n"),
d->name, vname));
(pat++)->name = d->name;
continue;
@ -756,13 +852,15 @@ pattern_search (struct file *file, int archive,
}
/* We could not find the file in any place we should look.
Try to make this dependency as an intermediate file, but
Look for an implicit rule to make this dependency, but
only on the second pass. */
if (intermed_ok)
{
DBS (DB_IMPLICIT,
(_("Looking for a rule with intermediate file '%s'.\n"),
(d->is_explicit || (df && df->is_explicit)
? _("Looking for a rule with explicit file '%s'.\n")
: _("Looking for a rule with intermediate file '%s'.\n"),
d->name));
if (int_file == 0)
@ -772,8 +870,9 @@ pattern_search (struct file *file, int archive,
if (pattern_search (int_file,
0,
depth + 1,
recursions + 1))
depth,
recursions + 1,
allow_compat_rules))
{
pat->pattern = int_file->name;
int_file->name = d->name;
@ -790,11 +889,24 @@ pattern_search (struct file *file, int archive,
free_variable_set (int_file->variables);
if (int_file->pat_variables)
free_variable_set (int_file->pat_variables);
file_impossible (d->name);
/* Keep prerequisites explicitly mentioned on unrelated
rules as "possible" to let compatibility search find
such prerequisites. */
if (df == 0)
file_impossible (d->name);
}
/* A dependency of this rule does not exist. Therefore, this
rule fails. */
if (intermed_ok)
DBS (DB_IMPLICIT,
(_("Rejecting rule '%s' "
"due to impossible prerequisite '%s'.\n"),
get_rule_defn (rule), d->name));
else
DBS (DB_IMPLICIT, (_("Not found '%s'.\n"), d->name));
failed = 1;
break;
}
@ -806,10 +918,6 @@ pattern_search (struct file *file, int archive,
break;
}
/* Reset the stem in FILE. */
file->stem = 0;
/* This rule is no longer 'in use' for recursive searches. */
rule->in_use = 0;
@ -861,24 +969,24 @@ pattern_search (struct file *file, int archive,
struct file *imf = pat->file;
struct file *f = lookup_file (imf->name);
/* We don't want to delete an intermediate file that happened
to be a prerequisite of some (other) target. Mark it as
secondary. We don't want it to be precious as that disables
DELETE_ON_ERROR etc. */
if (f != 0)
f->secondary = 1;
else
if (!f)
f = enter_file (imf->name);
f->deps = imf->deps;
f->cmds = imf->cmds;
f->stem = imf->stem;
f->variables = imf->variables;
/* Setting target specific variables for a file causes the file to be
entered to the database as a prerequisite. Implicit search then
treats this file as explicitly mentioned. Preserve target specific
variables of this file. */
merge_variable_set_lists(&f->variables, imf->variables);
f->pat_variables = imf->pat_variables;
f->pat_searched = imf->pat_searched;
f->also_make = imf->also_make;
f->is_target = 1;
f->intermediate = 1;
f->is_explicit |= imf->is_explicit || pat->is_explicit;
f->notintermediate |= imf->notintermediate || no_intermediates;
f->intermediate |= !f->is_explicit && !f->notintermediate;
f->tried_implicit = 1;
imf = lookup_file (pat->pattern);
@ -895,6 +1003,9 @@ pattern_search (struct file *file, int archive,
dep = alloc_dep ();
dep->ignore_mtime = pat->ignore_mtime;
dep->is_explicit = pat->is_explicit;
dep->ignore_automatic_vars = pat->ignore_automatic_vars;
dep->wait_here = pat->wait_here;
s = strcache_add (pat->name);
if (recursions)
dep->name = s;
@ -920,8 +1031,14 @@ pattern_search (struct file *file, int archive,
dep->next = file->deps;
file->deps = dep;
/* The file changed its dependencies; schedule the shuffle. */
file->was_shuffled = 0;
}
if (!file->was_shuffled)
shuffle_deps_recursive (file->deps);
if (!tryrules[foundrule].checked_lastslash)
{
/* Always allocate new storage, since STEM might be on the stack for an
@ -931,27 +1048,28 @@ pattern_search (struct file *file, int archive,
}
else
{
size_t dirlen = (lastslash + 1) - filename;
char *sp;
/* We want to prepend the directory from
the original FILENAME onto the stem. */
fullstemlen = dirlen + stemlen;
sp = alloca (fullstemlen + 1);
memcpy (sp, filename, dirlen);
memcpy (sp + dirlen, stem, stemlen);
sp[fullstemlen] = '\0';
file->stem = strcache_add (sp);
fullstemlen = pathlen + stemlen;
memcpy (stem_str, filename, pathlen);
memcpy (stem_str + pathlen, stem, stemlen);
stem_str[fullstemlen] = '\0';
file->stem = strcache_add (stem_str);
}
file->cmds = rule->cmds;
file->is_target = 1;
/* Set precious flag. */
/* Set precious and notintermediate flags. */
{
struct file *f = lookup_file (rule->targets[tryrules[foundrule].matches]);
if (f && f->precious)
file->precious = 1;
if (f)
{
if (f->precious)
file->precious = 1;
if (f->notintermediate || no_intermediates)
file->notintermediate = 1;
}
}
/* If this rule builds other targets, too, put the others into FILE's
@ -967,11 +1085,9 @@ pattern_search (struct file *file, int archive,
struct dep *new = alloc_dep ();
/* GKM FIMXE: handle '|' here too */
memcpy (p, rule->targets[ri],
rule->suffixes[ri] - rule->targets[ri] - 1);
p += rule->suffixes[ri] - rule->targets[ri] - 1;
memcpy (p, file->stem, fullstemlen);
p += fullstemlen;
p = mempcpy (p, rule->targets[ri],
rule->suffixes[ri] - rule->targets[ri] - 1);
p = mempcpy (p, file->stem, fullstemlen);
memcpy (p, rule->suffixes[ri],
rule->lens[ri] - (rule->suffixes[ri] - rule->targets[ri])+1);
new->name = strcache_add (nm);
@ -980,8 +1096,13 @@ pattern_search (struct file *file, int archive,
/* Set precious flag. */
f = lookup_file (rule->targets[ri]);
if (f && f->precious)
new->file->precious = 1;
if (f)
{
if (f->precious)
new->file->precious = 1;
if (f->notintermediate || no_intermediates)
new->file->notintermediate = 1;
}
/* Set the is_target flag so that this file is not treated as
intermediate by the pattern rule search algorithm and
@ -995,5 +1116,23 @@ pattern_search (struct file *file, int archive,
free (tryrules);
free (deplist);
return rule != 0;
--depth;
if (rule)
{
DBS (DB_IMPLICIT, (_("Found implicit rule '%s' for '%s'.\n"),
get_rule_defn (rule), filename));
return 1;
}
if (found_compat_rule)
{
DBS (DB_IMPLICIT, (_("Searching for a compatibility rule for '%s'.\n"),
filename));
assert (allow_compat_rules == 0);
return pattern_search (file, archive, depth, recursions, 1);
}
DBS (DB_IMPLICIT, (_("No implicit rule found for '%s'.\n"), filename));
return 0;
}

902
src/job.c

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/* Definitions for managing subprocesses in GNU Make.
Copyright (C) 1992-2019 Free Software Foundation, Inc.
Copyright (C) 1992-2024 Free Software Foundation, Inc.
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify it under the
@ -12,13 +12,13 @@ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. */
this program. If not, see <https://www.gnu.org/licenses/>. */
#include "output.h"
/* Structure describing a running or dead child process. */
#ifdef VMS
#if MK_OS_VMS
#define VMSCHILD \
char *comname; /* Temporary command file name */ \
int efn; /* Completion event flag number */ \
@ -29,7 +29,7 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
#endif
#define CHILDBASE \
char *cmd_name; /* Alloced copy of command run. */ \
char *cmd_name; /* Allocated copy of command run. */ \
char **environment; /* Environment for commands. */ \
VMSCHILD \
struct output output /* Output for this child. */
@ -61,30 +61,26 @@ struct child
unsigned int good_stdin:1; /* Nonzero if this child has a good stdin. */
unsigned int deleted:1; /* Nonzero if targets have been deleted. */
unsigned int recursive:1; /* Nonzero for recursive command ('+' etc.) */
unsigned int jobslot:1; /* Nonzero if it's reserved a job slot. */
unsigned int dontcare:1; /* Saved dontcare flag. */
};
extern struct child *children;
/* A signal handler for SIGCHLD, if needed. */
RETSIGTYPE child_handler (int sig);
void child_handler (int sig);
int is_bourne_compatible_shell(const char *path);
void new_job (struct file *file);
void reap_children (int block, int err);
void start_waiting_jobs (void);
void free_childbase (struct childbase* child);
char **construct_command_argv (char *line, char **restp, struct file *file,
int cmd_flags, char** batch_file);
pid_t child_execute_job (struct childbase *child, int good_stdin, char **argv);
#ifdef _AMIGA
void exec_command (char **argv) __attribute__ ((noreturn));
#elif defined(__EMX__)
int exec_command (char **argv, char **envp);
#else
void exec_command (char **argv, char **envp) __attribute__ ((noreturn));
#endif
pid_t exec_command (char **argv, char **envp);
void unblock_all_sigs (void);

View File

@ -1,5 +1,5 @@
/* Loading dynamic objects for GNU Make.
Copyright (C) 2012-2019 Free Software Foundation, Inc.
Copyright (C) 2012-2024 Free Software Foundation, Inc.
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify it under the
@ -12,7 +12,7 @@ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. */
this program. If not, see <https://www.gnu.org/licenses/>. */
#include "makeint.h"
@ -24,8 +24,6 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
#include <dlfcn.h>
#include <errno.h>
#define SYMBOL_EXTENSION "_gmk_setup"
#include "debug.h"
#include "filedef.h"
#include "variable.h"
@ -35,21 +33,33 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
# define RTLD_GLOBAL 0
#endif
#define GMK_SETUP "_gmk_setup"
#define GMK_UNLOAD "_gmk_unload"
typedef int (*setup_func_t)(unsigned int abi, const floc *flocp);
typedef void (*unload_func_t)(void);
struct load_list
{
struct load_list *next;
const char *name;
void *dlp;
unload_func_t unload;
};
static struct load_list *loaded_syms = NULL;
static load_func_t
static setup_func_t
load_object (const floc *flocp, int noerror, const char *ldname,
const char *symname)
const char *setupnm)
{
static void *global_dl = NULL;
load_func_t symp;
char *buf;
const char *fp;
char *endp;
void *dlp;
struct load_list *new;
setup_func_t symp;
if (! global_dl)
{
@ -57,81 +67,117 @@ load_object (const floc *flocp, int noerror, const char *ldname,
if (! global_dl)
{
const char *err = dlerror ();
OS (fatal, flocp, _("Failed to open global symbol table: %s"), err);
OS (fatal, flocp, _("failed to open global symbol table: %s"), err);
}
}
symp = (load_func_t) dlsym (global_dl, symname);
/* Find the prefix of the ldname. */
fp = strrchr (ldname, '/');
#ifdef HAVE_DOS_PATHS
if (fp)
{
const char *fp2 = strchr (fp, '\\');
if (fp2 > fp)
fp = fp2;
}
else
fp = strrchr (ldname, '\\');
/* The (improbable) case of d:foo. */
if (fp && *fp && fp[1] == ':')
fp++;
#endif
if (!fp)
fp = ldname;
else
++fp;
endp = buf = alloca (strlen (fp) + CSTRLEN (GMK_UNLOAD) + 1);
while (isalnum ((unsigned char) *fp) || *fp == '_')
*(endp++) = *(fp++);
/* If we didn't find a symbol name yet, construct it from the prefix. */
if (! setupnm)
{
memcpy (endp, GMK_SETUP, CSTRLEN (GMK_SETUP) + 1);
setupnm = buf;
}
DB (DB_VERBOSE, (_("Loading symbol %s from %s\n"), setupnm, ldname));
symp = (setup_func_t) dlsym (global_dl, setupnm);
if (symp)
return symp;
/* If the path has no "/", try the current directory first. */
dlp = NULL;
if (! strchr (ldname, '/')
#ifdef HAVE_DOS_PATHS
&& ! strchr (ldname, '\\')
#endif
)
dlp = dlopen (concat (2, "./", ldname), RTLD_LAZY|RTLD_GLOBAL);
/* If we haven't opened it yet, try the default search path. */
if (! dlp)
dlp = dlopen (ldname, RTLD_LAZY|RTLD_GLOBAL);
/* Still no? Then fail. */
if (! dlp)
{
const char *err = dlerror ();
if (noerror)
DB (DB_BASIC, ("%s\n", err));
else
OS (error, flocp, "%s", err);
return NULL;
}
DB (DB_VERBOSE, (_("Loaded shared object %s\n"), ldname));
/* Assert that the GPL license symbol is defined. */
symp = (setup_func_t) dlsym (dlp, "plugin_is_GPL_compatible");
if (! symp)
OS (fatal, flocp,
_("loaded object %s is not declared to be GPL compatible"), ldname);
symp = (setup_func_t) dlsym (dlp, setupnm);
if (! symp)
{
struct load_list *new;
void *dlp = NULL;
/* If the path has no "/", try the current directory first. */
if (! strchr (ldname, '/')
#ifdef HAVE_DOS_PATHS
&& ! strchr (ldname, '\\')
#endif
)
dlp = dlopen (concat (2, "./", ldname), RTLD_LAZY|RTLD_GLOBAL);
/* If we haven't opened it yet, try the default search path. */
if (! dlp)
dlp = dlopen (ldname, RTLD_LAZY|RTLD_GLOBAL);
/* Still no? Then fail. */
if (! dlp)
{
const char *err = dlerror ();
if (noerror)
DB (DB_BASIC, ("%s", err));
else
OS (error, flocp, "%s", err);
return NULL;
}
/* Assert that the GPL license symbol is defined. */
symp = (load_func_t) dlsym (dlp, "plugin_is_GPL_compatible");
if (! symp)
OS (fatal, flocp,
_("Loaded object %s is not declared to be GPL compatible"),
ldname);
symp = (load_func_t) dlsym (dlp, symname);
if (! symp)
{
const char *err = dlerror ();
OSSS (fatal, flocp, _("Failed to load symbol %s from %s: %s"),
symname, ldname, err);
}
/* Add this symbol to a trivial lookup table. This is not efficient but
it's highly unlikely we'll be loading lots of objects, and we only
need it to look them up on unload, if we rebuild them. */
new = xmalloc (sizeof (struct load_list));
new->name = xstrdup (ldname);
new->dlp = dlp;
new->next = loaded_syms;
loaded_syms = new;
const char *err = dlerror ();
OSSS (fatal, flocp, _("failed to load symbol %s from %s: %s"),
setupnm, ldname, err);
}
new = xcalloc (sizeof (struct load_list));
new->next = loaded_syms;
loaded_syms = new;
new->name = ldname;
new->dlp = dlp;
/* Compute the name of the unload function and look it up. */
memcpy (endp, GMK_UNLOAD, CSTRLEN (GMK_UNLOAD) + 1);
new->unload = (unload_func_t) dlsym (dlp, buf);
if (new->unload)
DB (DB_VERBOSE, (_("Detected symbol %s in %s\n"), buf, ldname));
return symp;
}
int
load_file (const floc *flocp, const char **ldname, int noerror)
load_file (const floc *flocp, struct file *file, int noerror)
{
size_t nmlen = strlen (*ldname);
char *new = alloca (nmlen + CSTRLEN (SYMBOL_EXTENSION) + 1);
char *symname = NULL;
char *loaded;
const char *ldname = file->name;
char *buf;
char *setupnm = NULL;
const char *fp;
int r;
load_func_t symp;
setup_func_t symp;
/* Break the input into an object file name and a symbol name. If no symbol
name was provided, compute one from the object file name. */
fp = strchr (*ldname, '(');
fp = strchr (ldname, '(');
if (fp)
{
const char *ep;
@ -142,126 +188,127 @@ load_file (const floc *flocp, const char **ldname, int noerror)
ep = strchr (fp+1, ')');
if (ep && ep[1] == '\0')
{
size_t l = fp - *ldname;;
size_t l = fp - ldname;
++fp;
if (fp == ep)
OS (fatal, flocp, _("Empty symbol name for load: %s"), *ldname);
OS (fatal, flocp, _("empty symbol name for load: %s"), ldname);
/* Make a copy of the ldname part. */
memcpy (new, *ldname, l);
new[l] = '\0';
*ldname = new;
nmlen = l;
buf = alloca (strlen (ldname) + 1);
memcpy (buf, ldname, l);
buf[l] = '\0';
ldname = buf;
/* Make a copy of the symbol name part. */
symname = new + l + 1;
memcpy (symname, fp, ep - fp);
symname[ep - fp] = '\0';
setupnm = buf + l + 1;
memcpy (setupnm, fp, ep - fp);
setupnm[ep - fp] = '\0';
}
}
/* Add this name to the string cache so it can be reused later. */
*ldname = strcache_add (*ldname);
/* Make sure this name is in the string cache. */
ldname = file->name = strcache_add (ldname);
/* If this object has been loaded, we're done. */
loaded = allocated_variable_expand ("$(.LOADED)");
fp = strstr (loaded, *ldname);
r = fp && (fp==loaded || fp[-1]==' ') && (fp[nmlen]=='\0' || fp[nmlen]==' ');
if (r)
goto exit;
/* If we didn't find a symbol name yet, construct it from the ldname. */
if (! symname)
{
char *p = new;
fp = strrchr (*ldname, '/');
#ifdef HAVE_DOS_PATHS
if (fp)
{
const char *fp2 = strchr (fp, '\\');
if (fp2 > fp)
fp = fp2;
}
else
fp = strrchr (*ldname, '\\');
/* The (improbable) case of d:foo. */
if (fp && *fp && fp[1] == ':')
fp++;
#endif
if (!fp)
fp = *ldname;
else
++fp;
while (isalnum (*fp) || *fp == '_')
*(p++) = *(fp++);
strcpy (p, SYMBOL_EXTENSION);
symname = new;
}
DB (DB_VERBOSE, (_("Loading symbol %s from %s\n"), symname, *ldname));
/* If this object has been loaded, we're done: return -1 to ensure make does
not rebuild again. If a rebuild is allowed it was set up when this
object was initially loaded. */
file = lookup_file (ldname);
if (file && file->loaded)
return -1;
/* Load it! */
symp = load_object (flocp, noerror, *ldname, symname);
symp = load_object (flocp, noerror, ldname, setupnm);
if (! symp)
return 0;
/* Invoke the symbol. */
r = (*symp) (flocp);
/* Invoke the setup function. */
{
unsigned int abi = GMK_ABI_VERSION;
r = (*symp) (abi, flocp);
}
/* If it succeeded, add the load file to the loaded variable. */
if (r > 0)
{
size_t loadlen = strlen (loaded);
char *newval = alloca (loadlen + strlen (*ldname) + 2);
/* Don't add a space if it's empty. */
if (loadlen)
{
memcpy (newval, loaded, loadlen);
newval[loadlen++] = ' ';
}
strcpy (&newval[loadlen], *ldname);
do_variable_definition (flocp, ".LOADED", newval, o_default, f_simple, 0);
}
/* If the load didn't fail, add the file to the .LOADED variable. */
if (r)
do_variable_definition(flocp, ".LOADED", ldname, o_file, f_append_value, 0,
s_global);
exit:
free (loaded);
return r;
}
void
int
unload_file (const char *name)
{
struct load_list *d;
struct load_list **dp = &loaded_syms;
for (d = loaded_syms; d != NULL; d = d->next)
if (streq (d->name, name) && d->dlp)
{
if (dlclose (d->dlp))
perror_with_name ("dlclose: ", d->name);
d->dlp = NULL;
break;
}
}
/* Unload and remove the entry for this file. */
while (*dp != NULL)
{
struct load_list *d = *dp;
#else
if (streq (d->name, name))
{
int rc;
int
load_file (const floc *flocp, const char **ldname UNUSED, int noerror)
{
if (! noerror)
O (fatal, flocp,
_("The 'load' operation is not supported on this platform."));
DB (DB_VERBOSE, (_("Unloading shared object %s\n"), name));
if (d->unload)
(*d->unload) ();
rc = dlclose (d->dlp);
if (rc)
perror_with_name ("dlclose: ", d->name);
*dp = d->next;
free (d);
return rc;
}
dp = &d->next;
}
return 0;
}
void
unload_all ()
{
while (loaded_syms)
{
struct load_list *d = loaded_syms;
loaded_syms = loaded_syms->next;
if (d->unload)
(*d->unload) ();
if (dlclose (d->dlp))
perror_with_name ("dlclose: ", d->name);
free (d);
}
}
#else
int
load_file (const floc *flocp, struct file *file UNUSED, int noerror)
{
if (! noerror)
O (fatal, flocp,
_("'load' is not supported on this platform"));
return 0;
}
int
unload_file (const char *name UNUSED)
{
O (fatal, NILF, "INTERNAL: Cannot unload when load is not supported!");
O (fatal, NILF, "INTERNAL: cannot unload when load is not supported");
}
void
unload_all ()
{
}
#endif /* MAKE_LOAD */

View File

@ -1,5 +1,5 @@
/* API for GNU Make dynamic objects.
Copyright (C) 2013-2019 Free Software Foundation, Inc.
Copyright (C) 2013-2024 Free Software Foundation, Inc.
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify it under the
@ -12,7 +12,7 @@ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. */
this program. If not, see <https://www.gnu.org/licenses/>. */
#include "makeint.h"
@ -70,7 +70,7 @@ gmk_eval (const char *buffer, const gmk_floc *gfloc)
char *
gmk_expand (const char *ref)
{
return allocated_variable_expand (ref);
return allocated_expand_string (ref);
}
/* Register a function to be called from makefiles. */

2118
src/main.c

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/* Miscellaneous global declarations and portability cruft for GNU Make.
Copyright (C) 1988-2019 Free Software Foundation, Inc.
Copyright (C) 1988-2024 Free Software Foundation, Inc.
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify it under the
@ -12,33 +12,26 @@ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. */
this program. If not, see <https://www.gnu.org/licenses/>. */
/* We use <config.h> instead of "config.h" so that a compilation
using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
(which it would do because makeint.h was found in $srcdir). */
#include <config.h>
#undef HAVE_CONFIG_H
#define HAVE_CONFIG_H 1
/* Specify we want GNU source code. This must be defined before any
system headers are included. */
/* Some versions of GCC (e.g., 10.x) set the warn_unused_result attribute on
__builtin_alloca. This causes alloca(0) to fail and is not easily worked
around so avoid it via the preprocessor.
See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98055 */
#define _GNU_SOURCE 1
/* AIX requires this to be the first thing in the file. */
#if HAVE_ALLOCA_H
# include <alloca.h>
#else
# ifdef _AIX
#pragma alloca
#if defined (__has_builtin)
# if __has_builtin (__builtin_alloca)
# define free_alloca()
# else
# if !defined(__GNUC__) && !defined(WINDOWS32)
# ifndef alloca /* predefined by HP cc +Olibcalls */
char *alloca ();
# endif
# endif
# define free_alloca() alloca (0)
# endif
#else
# define free_alloca() alloca (0)
#endif
/* Disable assert() unless we're a maintainer.
@ -51,12 +44,12 @@ char *alloca ();
Be sure to use the local one, and not one installed on the system.
Define GMK_BUILDING_MAKE for proper selection of dllexport/dllimport
declarations for MS-Windows. */
#ifdef WINDOWS32
#if MK_OS_W32
# define GMK_BUILDING_MAKE
#endif
#include "gnumake.h"
#ifdef CRAY
#ifdef CRAY
/* This must happen before #include <signal.h> so
that the declaration therein is changed. */
# define signal bsdsignal
@ -67,28 +60,16 @@ char *alloca ();
# define __NO_STRING_INLINES
#endif
#include <stddef.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <signal.h>
#include <stdio.h>
#include <ctype.h>
#ifdef HAVE_SYS_TIMEB_H
/* SCO 3.2 "devsys 4.2" has a prototype for 'ftime' in <time.h> that bombs
unless <sys/timeb.h> has been included first. */
# include <sys/timeb.h>
#endif
#if TIME_WITH_SYS_TIME
#if HAVE_SYS_TIME_H
# include <sys/time.h>
# include <time.h>
#else
# if HAVE_SYS_TIME_H
# include <sys/time.h>
# else
# include <time.h>
# endif
#endif
#include <time.h>
#include <errno.h>
@ -96,7 +77,23 @@ char *alloca ();
extern int errno;
#endif
/* Define macros specifying which OS we are building for. */
#if __gnu_hurd__
# define MK_OS_HURD 1
#endif
#if __CYGWIN__
# define MK_OS_CYGWIN 1
#endif
#if defined(__MVS__)
# define MK_OS_ZOS 1
#endif
#if defined(__EMX__)
# define MK_OS_OS2 1
#endif
#ifdef __VMS
# define MK_OS_VMS 1
/* In strict ANSI mode, VMS compilers should not be defining the
VMS macro. Define it here instead of a bulk edit for the correct code.
*/
@ -105,17 +102,17 @@ extern int errno;
# endif
#endif
#ifdef HAVE_UNISTD_H
#ifdef HAVE_UNISTD_H
# include <unistd.h>
/* Ultrix's unistd.h always defines _POSIX_VERSION, but you only get
POSIX.1 behavior with 'cc -YPOSIX', which predefines POSIX itself! */
# if defined (_POSIX_VERSION) && !defined (ultrix) && !defined (VMS)
# if defined (_POSIX_VERSION) && !defined (ultrix) && !MK_OS_VMS
# define POSIX 1
# endif
#endif
/* Some systems define _POSIX_VERSION but are not really POSIX.1. */
#if (defined (butterfly) || defined (__arm) || (defined (__mips) && defined (_SYSTYPE_SVR3)) || (defined (sequent) && defined (i386)))
#if (defined (butterfly) || (defined (__mips) && defined (_SYSTYPE_SVR3)) || (defined (sequent) && defined (i386)))
# undef POSIX
#endif
@ -123,10 +120,6 @@ extern int errno;
# define POSIX 1
#endif
#ifndef RETSIGTYPE
# define RETSIGTYPE void
#endif
#ifndef sigmask
# define sigmask(sig) (1 << ((sig) - 1))
#endif
@ -139,31 +132,25 @@ extern int errno;
# include <vfork.h>
#endif
#ifdef HAVE_LIMITS_H
#ifdef HAVE_LIMITS_H
# include <limits.h>
#endif
#ifdef HAVE_SYS_PARAM_H
#ifdef HAVE_SYS_PARAM_H
# include <sys/param.h>
#endif
#ifndef PATH_MAX
# ifndef POSIX
# ifdef MAXPATHLEN
# define PATH_MAX MAXPATHLEN
# else
/* Some systems (HURD) have fully dynamic pathnames with no maximum.
Ideally we'd support this but it will take some work. */
# define PATH_MAX 4096
# endif
#endif
#ifndef MAXPATHLEN
# define MAXPATHLEN 1024
#endif
#ifdef PATH_MAX
# define GET_PATH_MAX PATH_MAX
# define PATH_VAR(var) char var[PATH_MAX+1]
#else
# define NEED_GET_PATH_MAX 1
# define GET_PATH_MAX (get_path_max ())
# define PATH_VAR(var) char *var = alloca (GET_PATH_MAX+1)
unsigned int get_path_max (void);
#endif
#define GET_PATH_MAX PATH_MAX
#define PATH_VAR(var) char var[PATH_MAX+1]
#ifndef CHAR_BIT
# define CHAR_BIT 8
@ -173,6 +160,10 @@ unsigned int get_path_max (void);
# define USHRT_MAX 65535
#endif
#ifndef SIZE_MAX
# define SIZE_MAX ((size_t)~(size_t)0)
#endif
/* Nonzero if the integer type T is signed.
Use <= to avoid GCC warnings about always-false expressions. */
#define INTEGER_TYPE_SIGNED(t) ((t) -1 <= 0)
@ -203,7 +194,7 @@ unsigned int get_path_max (void);
# define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
#endif
#ifdef VMS
#if MK_OS_VMS
# include <fcntl.h>
# include <types.h>
# include <unixlib.h>
@ -220,19 +211,22 @@ extern int vms_legacy_behavior;
extern int vms_unix_simulation;
#endif
#ifndef __attribute__
/* This feature is available in gcc versions 2.5 and later. */
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
# define __attribute__(x)
# endif
#if !defined(__attribute__) && (__GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__)
/* Don't use __attribute__ if it's not supported. */
# define ATTRIBUTE(x)
#else
# define ATTRIBUTE(x) __attribute__ (x)
#endif
/* The __-protected variants of 'format' and 'printf' attributes
are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
# define __format__ format
# define __printf__ printf
# endif
#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
# define __format__ format
# define __printf__ printf
#endif
#define UNUSED __attribute__ ((unused))
#define UNUSED ATTRIBUTE ((unused))
#define NORETURN ATTRIBUTE ((noreturn))
#if defined (STDC_HEADERS) || defined (__GNU_LIBRARY__)
# include <stdlib.h>
@ -242,8 +236,6 @@ extern int vms_unix_simulation;
# ifdef HAVE_STRING_H
# include <string.h>
# define ANSI_STRING 1
# else
# include <strings.h>
# endif
# ifdef HAVE_MEMORY_H
# include <memory.h>
@ -255,8 +247,8 @@ void *malloc (int);
void *realloc (void *, int);
void free (void *);
void abort (void) __attribute__ ((noreturn));
void exit (int) __attribute__ ((noreturn));
void abort (void) NORETURN;
void exit (int) NORETURN;
# endif /* HAVE_STDLIB_H. */
#endif /* Standard headers. */
@ -269,16 +261,16 @@ void exit (int) __attribute__ ((noreturn));
# define EXIT_FAILURE 1
#endif
#ifndef ANSI_STRING
#ifndef ANSI_STRING
/* SCO Xenix has a buggy macro definition in <string.h>. */
#undef strerror
#undef strerror
#if !defined(__DECC)
char *strerror (int errnum);
#endif
#endif /* !ANSI_STRING. */
#undef ANSI_STRING
#undef ANSI_STRING
#if HAVE_INTTYPES_H
# include <inttypes.h>
@ -286,6 +278,25 @@ char *strerror (int errnum);
#if HAVE_STDINT_H
# include <stdint.h>
#endif
#if HAVE_STRINGS_H
# include <strings.h> /* Needed for strcasecmp / strncasecmp. */
#endif
#if defined _MSC_VER || defined __MINGW32__
# define MK_PRI64_PREFIX "I64"
#else
# define MK_PRI64_PREFIX "ll"
#endif
#ifndef PRIdMAX
# define PRIdMAX MK_PRI64_PREFIX "d"
#endif
#ifndef PRIuMAX
# define PRIuMAX MK_PRI64_PREFIX "u"
#endif
#ifndef SCNdMAX
# define SCNdMAX PRIdMAX
#endif
#define FILE_TIMESTAMP uintmax_t
#if !defined(HAVE_STRSIGNAL)
@ -327,7 +338,7 @@ extern mode_t umask (mode_t);
#define strneq(a, b, l) (strncmp ((a), (b), (l)) == 0)
#if defined(__GNUC__) || defined(ENUM_BITFIELDS)
#if defined(ENUM_BITFIELDS) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
# define ENUM_BITFIELD(bits) :bits
#else
# define ENUM_BITFIELD(bits)
@ -352,7 +363,7 @@ extern mode_t umask (mode_t);
# include <direct.h>
#endif
#ifdef WINDOWS32
#if MK_OS_W32
# include <fcntl.h>
# include <malloc.h>
# define pipe(_p) _pipe((_p), 512, O_BINARY)
@ -382,14 +393,19 @@ extern int unixy_shell;
# endif
/* Include only the minimal stuff from windows.h. */
# define WIN32_LEAN_AND_MEAN
#endif /* WINDOWS32 */
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
# endif
#endif /* MK_OS_W32 */
/* ALL_SET() evaluates the second argument twice. */
#define ANY_SET(_v,_m) (((_v)&(_m)) != 0)
#define NONE_SET(_v,_m) (! ANY_SET ((_v),(_m)))
#define ALL_SET(_v,_m) (((_v)&(_m)) == (_m))
/* Bitmasks for the STOPCHAR array. */
#define MAP_NUL 0x0001
#define MAP_BLANK 0x0002
#define MAP_BLANK 0x0002 /* space, TAB */
#define MAP_NEWLINE 0x0004
#define MAP_COMMENT 0x0008
#define MAP_SEMI 0x0010
@ -407,7 +423,7 @@ extern int unixy_shell;
/* The set of characters which are directory separators is OS-specific. */
#define MAP_DIRSEP 0x8000
#ifdef VMS
#if MK_OS_VMS
# define MAP_VMSCOMMA MAP_COMMA
#else
# define MAP_VMSCOMMA 0x0000
@ -424,7 +440,7 @@ extern int unixy_shell;
# define PATH_SEPARATOR_CHAR ';'
# define MAP_PATHSEP MAP_SEMI
#elif !defined(PATH_SEPARATOR_CHAR)
# if defined (VMS)
# if MK_OS_VMS
# define PATH_SEPARATOR_CHAR (vms_comma_separator ? ',' : ':')
# define MAP_PATHSEP (vms_comma_separator ? MAP_COMMA : MAP_SEMI)
# else
@ -437,16 +453,33 @@ extern int unixy_shell;
# define MAP_PATHSEP MAP_SEMI
#elif PATH_SEPARATOR_CHAR == ','
# define MAP_PATHSEP MAP_COMMA
#else
# error "Unknown PATH_SEPARATOR_CHAR"
#endif
#define STOP_SET(_v,_m) ANY_SET(stopchar_map[(unsigned char)(_v)],(_m))
/* True if C is whitespace but not newline. */
#define ISBLANK(c) STOP_SET((c),MAP_BLANK)
/* True if C is whitespace including newlines. */
#define ISSPACE(c) STOP_SET((c),MAP_SPACE)
/* True if C is nul or whitespace (including newline). */
#define END_OF_TOKEN(c) STOP_SET((c),MAP_SPACE|MAP_NUL)
/* Move S past all whitespace (including newlines). */
#define NEXT_TOKEN(s) while (ISSPACE (*(s))) ++(s)
#define END_OF_TOKEN(s) while (! STOP_SET (*(s), MAP_SPACE|MAP_NUL)) ++(s)
/* True if C is a directory separator on the current system. */
#define ISDIRSEP(c) STOP_SET((c),MAP_DIRSEP)
/* True if S starts with a drive specifier. */
#if defined(HAVE_DOS_PATHS)
# define HAS_DRIVESPEC(_s) ((((_s)[0] >= 'a' && (_s)[0] <= 'z') \
|| ((_s)[0] >= 'A' && (_s)[0] <= 'Z')) \
&& (_s)[1] == ':')
#else
# define HAS_DRIVESPEC(_s) 0
#endif
/* We can't run setrlimit when using posix_spawn. */
#if defined(HAVE_SYS_RESOURCE_H) && defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT) && !defined(USE_POSIX_SPAWN)
@ -461,11 +494,20 @@ extern struct rlimit stack_limit;
#define NILF ((floc *)0)
/* Number of elements in an array. */
#define ARRAYLEN(_a) (sizeof (_a) / sizeof ((_a)[0]))
/* Number of characters in a string constant. Does NOT include the \0 byte. */
#define CSTRLEN(_s) (sizeof (_s)-1)
/* Only usable when NOT calling a macro: only use it for local functions. */
#define STRING_SIZE_TUPLE(_s) (_s), CSTRLEN(_s)
/* The number of bytes needed to represent the largest integer as a string. */
#define INTSTR_LENGTH CSTRLEN ("18446744073709551616")
/* The number of bytes needed to represent the largest signed and unsigned
integers as a string.
Does NOT include space for \0 so be sure to add it if needed.
Math suggested by Edward Welbourne <edward.welbourne@qt.io> */
#define INTSTR_LENGTH (53 * sizeof(uintmax_t) / 22 + 3)
#define DEFAULT_TTYNAME "true"
#ifdef HAVE_TTYNAME
@ -474,8 +516,19 @@ extern struct rlimit stack_limit;
# define TTYNAME(_f) DEFAULT_TTYNAME
#endif
#if MK_OS_VMS
# define DEFAULT_TMPDIR "/sys$scratch/"
#elif defined(P_tmpdir)
# define DEFAULT_TMPDIR P_tmpdir
#else
# define DEFAULT_TMPDIR "/tmp"
#endif
struct file;
/* Specify the location of elements read from makefiles. */
typedef struct
{
@ -486,12 +539,14 @@ typedef struct
const char *concat (unsigned int, ...);
void message (int prefix, size_t length, const char *fmt, ...)
__attribute__ ((__format__ (__printf__, 3, 4)));
ATTRIBUTE ((__format__ (__printf__, 3, 4)));
void error (const floc *flocp, size_t length, const char *fmt, ...)
__attribute__ ((__format__ (__printf__, 3, 4)));
ATTRIBUTE ((__format__ (__printf__, 3, 4)));
void fatal (const floc *flocp, size_t length, const char *fmt, ...)
__attribute__ ((noreturn, __format__ (__printf__, 3, 4)));
void out_of_memory () __attribute__((noreturn));
ATTRIBUTE ((noreturn, __format__ (__printf__, 3, 4)));
char *format (const char *prefix, size_t length, const char *fmt, ...)
ATTRIBUTE ((__format__ (__printf__, 3, 4)));
void out_of_memory (void) NORETURN;
/* When adding macros to this list be sure to update the value of
XGETTEXT_OPTIONS in the po/Makevars file. */
@ -509,10 +564,23 @@ void out_of_memory () __attribute__((noreturn));
#define ONS(_t,_a,_f,_n,_s) _t((_a), INTSTR_LENGTH + strlen (_s), \
(_f), (_n), (_s))
void die (int) __attribute__ ((noreturn));
void pfatal_with_name (const char *) __attribute__ ((noreturn));
enum variable_origin;
struct variable;
void reset_makeflags (enum variable_origin origin);
struct variable *define_makeflags (int makefile);
int should_print_dir (void);
void temp_stdin_unlink (void);
void die (int) NORETURN;
void pfatal_with_name (const char *) NORETURN;
void perror_with_name (const char *, const char *);
#define xstrlen(_s) ((_s)==NULL ? 0 : strlen (_s))
unsigned int make_toui (const char*, const char**);
char *make_lltoa (long long, char *);
char *make_ulltoa (unsigned long long, char *);
void make_seed (unsigned int);
unsigned int make_rand (void);
pid_t make_pid (void);
void *xmalloc (size_t);
void *xcalloc (size_t);
void *xrealloc (void *, size_t);
@ -521,15 +589,22 @@ char *xstrndup (const char *, size_t);
char *find_next_token (const char **, size_t *);
char *next_token (const char *);
char *end_of_token (const char *);
char *skip_reference (const char *);
void collapse_continuations (char *);
char *lindex (const char *, const char *, int);
int alpha_compare (const void *, const void *);
void print_spaces (unsigned int);
char *find_percent (char *);
const char *find_percent_cached (const char **);
FILE *get_tmpfile (char **, const char *);
ssize_t writebuf (int, const void*, size_t);
ssize_t readbuf (int, void*, size_t);
const char *get_tmpdir (void);
int get_tmpfd (char **);
FILE *get_tmpfile (char **);
ssize_t writebuf (int, const void *, size_t);
ssize_t readbuf (int, void *, size_t);
#ifndef HAVE_MEMRCHR
void *memrchr(const void *, int, size_t);
#endif
#ifndef NO_ARCHIVES
int ar_name (const char *);
@ -537,15 +612,16 @@ void ar_parse_name (const char *, char **, char **);
int ar_touch (const char *);
time_t ar_member_date (const char *);
typedef long int (*ar_member_func_t) (int desc, const char *mem, int truncated,
typedef intmax_t (*ar_member_func_t) (int desc, const char *mem, int truncated,
long int hdrpos, long int datapos,
long int size, long int date, int uid,
long int size, intmax_t date, int uid,
int gid, unsigned int mode,
const void *arg);
long int ar_scan (const char *archive, ar_member_func_t function, const void *arg);
intmax_t ar_scan (const char *archive, ar_member_func_t function,
const void *arg);
int ar_name_equal (const char *name, const char *mem, int truncated);
#ifndef VMS
#if !MK_OS_VMS
int ar_member_touch (const char *arname, const char *memname);
#endif
#endif
@ -573,10 +649,6 @@ int gpath_search (const char *file, size_t len);
void construct_include_path (const char **arg_dirs);
void user_access (void);
void make_access (void);
void child_access (void);
char *strip_whitespace (const char **begpp, const char **endpp);
void show_goal_error (void);
@ -592,34 +664,37 @@ const char *strcache_add_len (const char *str, size_t len);
int guile_gmake_setup (const floc *flocp);
/* Loadable object support. Sets to the strcached name of the loaded file. */
typedef int (*load_func_t)(const floc *flocp);
int load_file (const floc *flocp, const char **filename, int noerror);
void unload_file (const char *name);
int load_file (const floc *flocp, struct file *file, int noerror);
int unload_file (const char *name);
void unload_all (void);
/* Maintainer mode support */
#ifdef MAKE_MAINTAINER_MODE
# define SPIN(_s) spin (_s)
void spin (const char* suffix);
# define DBG(_f) dbg _f
void dbg (const char *fmt, ...);
#else
# define SPIN(_s)
/* Never put this code into Git or a release. */
# define DBG(_f) compile-error
#endif
/* We omit these declarations on non-POSIX systems which define _POSIX_VERSION,
because such systems often declare them in header files anyway. */
#if !defined (__GNU_LIBRARY__) && !defined (POSIX) && !defined (_POSIX_VERSION) && !defined(WINDOWS32)
#if !defined (__GNU_LIBRARY__) && !defined (POSIX) && !defined (_POSIX_VERSION) && !MK_OS_W32
long int atol ();
# ifndef VMS
# if !MK_OS_VMS
long int lseek ();
# endif
# ifdef HAVE_GETCWD
# if !defined(VMS) && !defined(__DECC)
char *getcwd ();
# ifdef HAVE_GETCWD
# if !MK_OS_VMS && !defined(__DECC)
char *getcwd (void);
# endif
# else
char *getwd ();
char *getwd (void);
# define getcwd(buf, len) getwd (buf)
# endif
@ -630,9 +705,6 @@ char *getwd ();
# define strcasecmp stricmp
# elif HAVE_STRCMPI
# define strcasecmp strcmpi
# else
/* Create our own, in misc.c */
int strcasecmp (const char *s1, const char *s2);
# endif
#endif
@ -641,9 +713,6 @@ int strcasecmp (const char *s1, const char *s2);
# define strncasecmp strnicmp
# elif HAVE_STRNCMPI
# define strncasecmp strncmpi
# else
/* Create our own, in misc.c */
int strncasecmp (const char *s1, const char *s2, int n);
# endif
#endif
@ -663,27 +732,50 @@ extern unsigned short stopchar_map[];
extern int just_print_flag, run_silent, ignore_errors_flag, keep_going_flag;
extern int print_data_base_flag, question_flag, touch_flag, always_make_flag;
extern int env_overrides, no_builtin_rules_flag, no_builtin_variables_flag;
extern int print_version_flag, print_directory_flag, check_symlink_flag;
extern int warn_undefined_variables_flag, trace_flag, posix_pedantic;
extern int print_version_flag, check_symlink_flag, posix_pedantic;
extern int not_parallel, second_expansion, clock_skew_detected;
extern int rebuilding_makefiles, one_shell, output_sync, verify_flag;
extern int export_all_variables;
extern unsigned long command_count;
extern const char *default_shell;
/* can we run commands via 'sh -c xxx' or must we use batch files? */
extern int batch_mode_shell;
#define GNUMAKEFLAGS_NAME "GNUMAKEFLAGS"
#define MAKEFLAGS_NAME "MAKEFLAGS"
#define MAKELEVEL_NAME "MAKELEVEL"
#define MAKELEVEL_LENGTH (CSTRLEN (MAKELEVEL_NAME))
/* Resetting the command script introduction prefix character. */
#define RECIPEPREFIX_NAME ".RECIPEPREFIX"
#define RECIPEPREFIX_DEFAULT '\t'
#define RECIPEPREFIX_NAME ".RECIPEPREFIX"
#define RECIPEPREFIX_DEFAULT '\t'
extern char cmd_prefix;
/* Setting warning actions. */
#define WARNINGS_NAME ".WARNINGS"
extern unsigned int no_intermediates;
#if HAVE_MKFIFO
/* It seems that mkfifo() is not working correctly, or at least not the way
GNU make wants it to work, on: GNU/Hurd, Cygwin, OS2; don't use it there. */
# if !defined(JOBSERVER_USE_FIFO) && !MK_OS_HURD && !MK_OS_CYGWIN && !MK_OS_OS2
# define JOBSERVER_USE_FIFO 1
# endif
#endif
#define JOBSERVER_AUTH_OPT "jobserver-auth"
extern char *jobserver_auth;
extern unsigned int job_slots;
extern double max_load_average;
extern const char *program;
#ifdef VMS
#if MK_OS_VMS
const char *vms_command (const char *argv0);
const char *vms_progname (const char *argv0);
@ -730,7 +822,7 @@ extern char *version_string, *remote_description, *make_host;
extern unsigned int commands_started;
extern int handling_fatal_signal;
extern volatile sig_atomic_t handling_fatal_signal;
#ifndef MIN
#define MIN(_a,_b) ((_a)<(_b)?(_a):(_b))
@ -750,7 +842,7 @@ extern int handling_fatal_signal;
#endif
#ifndef initialize_main
# ifdef __EMX__
# if MK_OS_OS2
# define initialize_main(pargc, pargv) \
{ _wildcard(pargc, pargv); _response(pargc, pargv); }
# else
@ -758,7 +850,7 @@ extern int handling_fatal_signal;
# endif
#endif
#ifdef __EMX__
#if MK_OS_OS2
# if !defined chdir
# define chdir _chdir2
# endif

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More