summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* make -p now uses consistent timestamp formatHEADmasterPaul Eggert2023-05-142-45/+11
| | | | | | * NEWS: mention this. * src/main.c (safer_ctime, time_now): Remove. (print_data_base): Use file_timestamp_sprintf to format timestamps.
* make -p buffer overrun fix with outlandish current timePaul Eggert2023-05-141-2/+14
| | | | | * src/main.c (safer_ctime): New function. (print_data_base): Use it.
* make -p uses same clock as rest of 'make'Paul Eggert2023-05-141-2/+31
| | | | | | | 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.
* [SV 63219] Support an "unload" function for loaded objectsPaul Smith2023-05-147-118/+337
| | | | | | | | | | | | | | | | | | | | 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.
* Remove the "preview" status from the loaded object featurePaul Smith2023-05-077-205/+236
| | | | | | | | | | | | | | | | 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.
* * src/read.c (eval): [SV 40942] Allow targets named "load"Paul Smith2023-05-072-3/+24
| | | | | | | 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.
* * tests/test_driver.pl: Show info about failed testsPaul Smith2023-05-072-26/+37
| | | | | Remove working directories for skipped tests. We use different directories per test so don't keep rmfiles.
* * tests/scripts/features/comments: Add missing "1;"Paul Smith2023-05-061-1/+3
|
* [SV 64124] Avoid use-after-free in expand_variable_buf()Dmitry Goncharov2023-04-302-3/+39
| | | | | | | | | | | 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.
* [SV 64115] Suppress warnings about undefined GNUMAKEFLAGSDmitry Goncharov2023-04-302-0/+12
| | | | | * src/variable.c (defined_vars): Add GNUMAKEFLAGS to defined variables. * tests/scripts/options/warn: Add a test.
* [SV 64107] Disable builtins immediately on -R or -rDmitry Goncharov2023-04-303-23/+100
| | | | | | | | | | | 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.
* * tests/scripts/features/double_colon: Test parallel double-colon rulesPaul Smith2023-04-301-1/+10
| | | | Original test proposed by Dmitry Goncharov <dgoncharov@users.sf.net>
* * src/remake.c (update_goal_chain): [SV 64016] Avoid double negationDmitry Goncharov2023-04-301-9/+6
|
* * NEWS: Note the change to the tests suitePaul Smith2023-04-231-0/+3
|
* * src/warnings.c (decode_warn_actions): [SV 63990] Handle errorsPaul Smith2023-04-031-20/+24
|
* Move local headers after system headersPaul Smith2023-04-033-30/+31
| | | | | | | | | 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.
* tests: Run each file in a separate directoryPaul Smith2023-04-0211-185/+126
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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).
* * tests/scripts/targets/WAIT: Add whitespace to avoid W32 issuesPaul Smith2023-04-021-72/+72
| | | | | On Windows systems, "X:" for any "X" is considered a drive letter so add whitespace.
* [SV 63856] Fix pruning of double-colon rulesDmitry Goncharov2023-04-022-2/+347
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* [SV 63856] Implement .WAIT on the command lineDmitry Goncharov2023-04-023-18/+168
| | | | | | | | | * 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.
* [SV 63981] Don't warn on explicit -j1Paul Smith2023-04-022-3/+15
| | | | | | | 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.
* * NEWS: Mention the new .WARNINGS variablePaul Smith2023-04-021-0/+5
|
* * doc/make.texi: Clean up function and variable referencesPaul Smith2023-04-021-41/+19
| | | | Avoid unnecessary extra remarks in the index and remove duplicates.
* Adjust output strings to be alignedPaul Smith2023-04-0227-100/+105
| | | | | | | | 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.
* Add support for .WARNINGS special variablePaul Smith2023-04-0217-249/+629
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Add new warnings invalid-var and invalid-refPaul Smith2023-04-0110-17/+158
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Introduce a --warn command line optionPaul Smith2023-04-0113-98/+462
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Clean up memory leak warnings from ASAN and ValgrindPaul Smith2023-04-0111-36/+89
| | | | | | | | | | | | | | | | | | | | | | | | * 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.
* Create helper functions for pushing file contextsPaul Smith2023-04-013-30/+45
| | | | | | | | | | | * 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.
* Add functions to directly expand variables by namePaul Smith2023-04-019-46/+103
| | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Clean up expand.cPaul Smith2023-03-2614-105/+97
| | | | | | | | | | | | | | | | | | | | | | | | | 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.
* * src/expand.c (swap_variable_buffer): Swap two variable buffersPaul Smith2023-03-264-64/+64
| | | | | | | | 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.
* Ensure variable_buffer is always nul-terminatedPaul Smith2023-03-263-22/+24
| | | | | | | | * 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.
* [SV 63867] Don't use --sort to generate error report tar filesPaul Smith2023-03-251-0/+1
| | | | | | | | | 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
* Directly handle $\ line endingsPaul Smith2023-02-263-38/+52
| | | | | | | | | | | | | | 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 "$"
* * src/main.c (define_makefiles): Simplify by using variable_bufferPaul Smith2023-02-261-122/+94
| | | | | | | | 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.
* Clean up some preprocessor operationsPaul Smith2023-01-167-32/+30
|
* Use MK_OS_OS2 macro instead of __EMX__Paul Smith2023-01-1610-49/+53
| | | | | * src/makeint.h: Set MK_OS_OS2 to 1 if __EMX__ is set. * src/*: Convert #if refs to __EMX__, to use MK_OS_OS2.
* Use MK_OS_DOS macro instead of __MSDOS__Paul Smith2023-01-1614-88/+88
| | | | | | * src/configh.dos: Set MK_OS_DOS to 1 * src/*: Convert #if refs to __MSDOS__, to use MK_OS_DOS. * gl/lib/*: Ditto.
* Rename WINDOWS32 macro to MK_OS_W32Paul Smith2023-01-1524-167/+165
| | | | | | | | | | * 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.
* Rename VMS macro to MK_OS_VMSPaul Smith2023-01-1525-151/+152
| | | | | | * 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.
* Remove support for AmigaOSPaul Smith2023-01-1523-956/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* * README.git: Clarify some release stepsPaul Smith2023-02-262-18/+18
| | | | * README.in: Update some info and remove some obsolete notes.
* * NEWS: Update for the next releasePaul Smith2023-02-262-1/+8
| | | | * configure.ac: Set the version for the next release.
* GNU Make release 4.4.14.4.1Paul Smith2023-02-265-18/+16
| | | | | | | | * 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.
* * tests/scripts/options/dash-l: Simplify the test via the helperPaul Smith2023-02-262-22/+31
| | | | * tests/thelp.pl: Add "exist" and "noexist" operators.
* * README.W32: Add Windows 11Paul Smith2023-02-212-2/+2
| | | | * build_w32.bat: Ditto.
* Use a recursive environment if any command needs itPaul Smith2023-02-212-2/+45
| | | | | | | | | 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.
* * src/main.c (main): Install suffix rules near pattern updatesDmitry Goncharov2023-02-211-5/+5
|
* * Makefile.am: Add mkconfig.h to the test error filePaul Smith2023-02-201-1/+2
|