Commit Graph

3053 Commits

Author SHA1 Message Date
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