aboutsummaryrefslogtreecommitdiff
path: root/miscutils (follow)
Commit message (Collapse)AuthorAgeFilesLines
* make: limit changes to pragmasRon Yorston2024-06-101-5/+4
| | | | | | | | | | | | | | | | | The special target .PRAGMA could be used to set or reset pragmas. Doing anything other than setting pragmas very early in execution is likely to be problematic. Limit the abilities of .PRAGMA: - Specifying .PRAGMA with no prerequisites now does nothing: pragmas are not reset. - The posix_2017 and posix_202x pragmas can only be used to change the enforced POSIX level from the default. Any further attempt to change POSIX level results in a warning. Adds 16-32 bytes.
* make: allow := macro assignment on command lineRon Yorston2024-06-081-14/+22
| | | | | | | | | Only the forms of macro assignment required by POSIX were allowed on the command line. Add support for the non-POSIX := form too. Adds 16-24 bytes.
* make: more changes for c:/path targetRon Yorston2024-06-051-4/+5
| | | | | | | | | | The previous commit failed to change an instance of find_char() to find_colon(). It isn't necessary to use find_char() to replace find_colon() in the non-Windows case: strchr(3) is sufficient. Adds 16-48 bytes.
* make: restore check for c:/path targetRon Yorston2024-06-051-1/+23
| | | | | | | | | | Commit f9d10b2b6 (make: fix detection of target rules (take 2)) failed to include the function find_colon() which is used to skip targets of the form c:/path when checking for a target rule. Restore the function so Windows paths can be used as targets. Adds 48 bytes.
* make: explicitly verify order of argumentsRon Yorston2024-06-041-7/+16
| | | | | | | | | | | | | | | | | | | | POSIX requires macro assignments to precede targets on the command line. This requirement has been relaxed as a non-POSIX extension. Verify the constraint has been applied in POSIX mode. This ensures that the command: make --posix target A=1 fails before it tries to update the target. It also catches the case where POSIX mode had not been set with the --posix option or PDPMAKE_POSIXLY_CORRECT environment but was then set by the .POSIX special target in the makefile. In this case the command line was scanned for macro assignments without enforcing POSIX mode while targets were processed with POSIX mode enabled. Adds 96 bytes.
* make: only reset getopt(3) if necessaryRon Yorston2024-06-031-2/+2
| | | | Only invoke GETOPT_RESET() if getopt(3) has actually been called.
* make: ensure sufficient space in line bufferRon Yorston2024-06-021-7/+8
| | | | | | | | | | | When using fgets(3) to read a line into a buffer it's necessary to ensure at least two characters are available in the buffer. Otherwise the read fails. (At least, it did when pdpmake was built using MSYS2 on Windows.) Adds 16 bytes to the 32-bit build. (GitHub pdpmake issue 44)
* make: report POSIX 202X issue with includeRon Yorston2024-06-021-6/+12
| | | | | | | | | | | Synchronising with upstream pdpmake showed that a test was missing from the BusyBox port. POSIX 202X doesn't specify what should happen if an include statement has no arguments. When the POSIX 202X standard is being enforced this is reported as an error. Adds 32 bytes.
* make: restore warning about invalid macro nameRon Yorston2024-06-021-7/+9
| | | | | | | | | | | | Commit 90c5352a9 (make: change how macros are read from the environment) was intended to ignore environment variables with invalid names. It had the unintended consequence of also ignoring macros with invalid names defined in makefiles. This was because such macros can have the same level (3) as those imported from the environment. Rather than use the level to detect importing from the environment add a flag to indicate this circumstance.
* make: fix detection of target rules (take 2)Ron Yorston2024-05-311-184/+154
| | | | | | | | | | | | | | | | | | Commit d6b764116 (make: fix detection of target rules) checked for target rules before macro assignments. This failed for some Makefiles generated by autotools because partially defined macros were expanded while testing for a target rule. Revert to checking for macro assignments first, but try to detect if the proposed left hand side of the assignment might form part of a target rule with an inline command. Also handle the case where the ';' separator of the inline command has been obfuscated by putting it in a macro. Saves 128-160 bytes. (GitHub pdpmake issues 31, 44)
* make: allow :::= macro assignment on command lineRon Yorston2024-05-291-16/+28
| | | | | | | | | | | | GNU make and bmake have different implementations for := macro assignment. In POSIX 202X these are supported by the forms ::= and :::= respectively. Only the former was supported on the pdpmake command line. Add the required support in process_macros() and update the usage message. Adds 48-64 bytes.
* make: fixes to -q optionRon Yorston2024-05-281-36/+36
| | | | | | | | | | | | The -q option returns an exit status to indicate if targets are up-to-date (0) or in need of updating (1) but without updating them. As an exception (imported from GNU make) build commands with a '+' prefix are executed. pdpmake didn't implement the exception. Doing so required moving handling of the -q option down into docmds(). Saves 48 bytes.
* make: fixes to -t optionRon Yorston2024-05-281-33/+34
| | | | | | | | | | | | | | | | | | | | | The -t option (in general) causes targets to be touched instead of having build commands run to create them. There were two problems. The flag variable 'ssilent' in docmds was too small (uint8_t) to contain the value of 'dotouch' (uint32_t). Truncation of the value resulted in build commands being echoed when they shouldn't have been. The POSIX specification is unclear as to how build commands with a '+' prefix interact with touch. The rationale indicates that this feature was imported from GNU make, so the behaviour has been made to match what it does: if a '+' build command is run the target is not touched. The code has been rearranged to move the call to touch() up into docmds(). Adds 48 bytes.
* make: improved support for POSIX levelsRon Yorston2024-05-271-1/+25
| | | | | | | | | The default POSIX level to be enforced in strict mode is now a configuration option. Print details of supported POSIX levels in the usage message. Adds 56-64 bytes.
* make: add posix_2017 pragmaRon Yorston2024-05-251-9/+40
| | | | | | | | | | | | The pragma 'posix_202x' causes the 202X POSIX standard to be enforced in POSIX mode. Add an equivalent 'posix_2017' for the 2017 standard. There's now a DEFAULT_POSIX_LEVEL preprocessor symbol to configure the default standard. This is hardcoded to the 2017 standard but it can also be set to 202X. Adds 48 bytes.
* make: add support for ifeq/ifneqRon Yorston2024-05-221-16/+82
| | | | | | | | | | | | | | | | Add support for the conditional directives ifeq and ifneq. These follow GNU make in allowing things like: ifeq (arg1,arg2) ifeq 'arg1' 'arg2' In the second case single or double quotes may be used. Macros are expanded in the two arguments and the resulting strings are compared. Adds 240-248 bytes.
* make: set $< and $* for target rulesRon Yorston2024-05-221-6/+27
| | | | | | | | | | | | | | | | POSIX only requires $< and $* to be set for inference rules, not target rules. As an extension allow them to be set for target rules, as in GNU make. This may or may not be useful. In POSIX mode, when $< and $* are only set for inference rules, they're set to an empty string for target rules. This avoids the possibility of stale values being used. Adds 64-80 bytes. (GitHub issue #407)
* make: add support for CURDIR macroRon Yorston2024-05-221-5/+28
| | | | | | | | | | | Austin Group defect report 1626 introduced support for the CURDIR macro: https://www.austingroupbugs.net/view.php?id=1626 Implement this as a POSIX 202X feature. Adds 160-176 bytes.
* make: code shrinkRon Yorston2024-04-231-1/+1
| | | | | | The 'quick fix' in the previous commit unnecessarily checks the fractional timestamp value to determine if a target exists. This isn't how it's done elsewhere in the code.
* make: better determine that a file is up-to-dateRon Yorston2024-04-221-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | POSIX says: A target shall be considered up-to-date... if it has already been made up-to-date by the current invocation of make (regardless of the target's existence or age). If the target does not exist after the target has been successfully made up-to-date, the target shall be treated as being newer than any target for which it is a prerequisite. Previously 'make' assumed that if a rule had succeeded the modification time of the target would be the current time. This isn't necessarily the case. Instead: - If the file exists use the modification time of the file as the the time of the target. - If it doesn't exist use the current time, which should be more recent than the time of any file for which it's a prerequisite. Adds 16 bytes. (GitHub issue #410)
* make: allow mixed macros and targets on command lineRon Yorston2024-04-211-8/+30
| | | | | | | | | | | | POSIX requires macro definitions to appear before targets on the command line. Allow mixed macros and targets as an extension. All macros on the command line are read first, then the targets are processed. Costs 64-80 bytes. (GitHub issue #406)
* make: change how macros are read from the environmentRon Yorston2024-04-211-2/+6
| | | | | | | | | | | | | | Originally there was no validation of macro names imported from the environment. However, process_macros() failed to account for the additional flag bit at this level. Thus, for example, SHELL was imported when it shouldn't have been. The problem the lack of validation was supposed to address was that of environment variables with invalid names, which the user may not have control over, causing a fatal error. As an alternative, silently ignore variables with invalid names on import from the environment.
* make: skip shell -e option when running commandsRon Yorston2024-04-201-2/+1
| | | | | | | | | | | | | | POSIX says, regarding execution of commands: The execution line shall then be executed by a shell as if it were passed as the argument to the system() interface, except that if errors are not being ignored then the shell -e option shall also be in effect. As a non-POSIX extension, skip the use of the -e option. This is how GNU make and BSD make behave. (GitHub issue #409)
* time: code shrinkRon Yorston2024-04-091-4/+1
| | | | | | | | | | | | Commit 54dbf0fa5 (time: mitigation for interleaved output) added buffering to stderr in the 'time' applet. @avih pointed out that it isn't necessary to provide an explicit buffer. Saves 16 bytes in the 64-bit build. (GitHub issue #396)
* time: mitigation for interleaved outputRon Yorston2024-04-061-0/+6
| | | | | | | | | | | | | | | | When the 'time' applet is run in a pipeline, like so: time seq 1 10 | tail -2 stdout from 'tail' and stderr from 'time' can be interleaved. This is particularly the case with the ConEmu terminal emulator. The interleaving can be reduced, though not eliminated, by buffering the output of 'time'. Adds 40-44 bytes. (GitHub issue #396)
* make: allow '#' to be escaped with a backslashRon Yorston2024-03-111-3/+11
| | | | | | | | | | | | | | | | POSIX doesn't allow the '#' comment marker to be escaped, though some implementations do. As a non-POSIX extension allow '#' to be escaped with a preceding backslash. It isn't necessary to escape '#' in macro expansions or command lines: these cases are covered by an existing extension. Commit 0aceca867 (make: comments in macro expansions and command lines) Adds 16-32 bytes. (pdpmake GitHub issue 38)
* build system: avoid full rebuild when EXTRAVERSION changesRon Yorston2024-02-161-0/+3
| | | | | | | | | | The last two commits allow EXTRAVERSION to track the current state of a git repository. The build system was unable to determine which files were affected by changes to EXTRAVERSION and caused a full rebuild when it changed. Alter how the version information is passed to the code so only a handful of files need to be rebuilt when it changes.
* time: enable '-f' optionRon Yorston2024-01-051-17/+6
| | | | | | | The '-f' option allows the user to specify a format string to control which data is reported. Adds 224-240 bytes.
* Merge branch 'busybox' into mergeRon Yorston2024-01-051-31/+42
|\
| * time: implement %% and \escapes in -f FMTDenys Vlasenko2024-01-011-21/+18
| | | | | | | | | | | | | | function old new delta time_main 1217 1316 +99 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * time: fix max resident set size unitNatanael Copa2023-12-311-9/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The ru_maxrss is already in Kbytes and not pages. function old new delta ptok 21 - -21 time_main 1261 1217 -44 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 0/1 up/down: 0/-65) Total: -65 bytes fixes: https://bugs.busybox.net/show_bug.cgi?id=15751 Signed-off-by: Natanael Copa <ncopa@alpinelinux.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | make: proper handling of build failure with '-k'Ron Yorston2023-12-221-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | When a build command fails and the '-k' option (continue on error) is in effect, no further commands should be executed for the current target. Also, the resulting diagnostic should be reported to stderr. As should the final 'not built due to errors' diagnostic. Adds 80 bytes. (pdpmake GitHub issue 35)
* | make: flush stdout after writing command stringRon Yorston2023-12-111-1/+3
| | | | | | | | | | | | | | If stdout is fully buffered (e.g. because the output is redirected to a file or pipe) the command string may appear after its output. (pdpmake GitHub PR 34)
* | iconv: fix incorrect fixRon Yorston2023-11-081-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | Part of commit 412c2cab62 (iconv: minor fixes) was intended to avoid having to enter ^Z twice to signal EOF when input was coming from the console. Unfortunately there were unintended consequences. Use a different method to detect EOF. Costs 32-48 bytes. (GitHuv issue #374)
* | make: stricter checks for c:/path filenamesRon Yorston2023-10-241-6/+9
| | | | | | | | | | | | | | | | | | | | When checking target names or looking for a target rule be more strict about the form of Windows paths allowed. Alter the error message when neither a target rule or macro assignment has been detected. Adds 88-96 bytes.
* | make: fix detection of target rulesRon Yorston2023-10-231-152/+183
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The presence of an equal sign in an inline command on a target rule caused the line to be detected as a macro assignment. For example: target:; @echo a = $(a) Rearrange input parsing so target rules are detected before macro assignments. This is made more complex by having to allow for the ':=', '::=' and ':::=' assignment operators. (And for targets containing colons on Windows.) Costs 240-248 bytes.
* | make: permit Unix-style paths when setting MAKERon Yorston2023-10-061-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The 'make' applet follows POSIX requirements when setting the MAKE variable. However, it doesn't allow for the case where argv[0] is of a form like '/bin/make' but no corresponding executable exists. This can happen in busybox-w32 when '/bin/make' is interpreted as a reference to the 'make' applet. In this case set the MAKE variable to argv[0] and avoid issuing a warning. Setting MAKE to something that isn't a real executable is fine so long as it's only used by busybox-w32 applets. If it's used by external applications they may get confused. Adds 16-32 bytes. (GitHub issue #354)
* | win32: convert exit codesRon Yorston2023-09-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add two utility functions to convert Windows process exit codes. - exit_code_to_wait_status() converts to a POSIX wait status. This is used in ash and the implementations of system(3) and mingw_wait3(). - exit_code_to_posix() converts to a POSIX exit code. (Not that POSIX has much to say about them.) As a result it's possible for more applets to report when child processes are killed as if by a signal. 'time', 'drop' and 'su -W', for example. Adds 64-80 bytes.
* | make: return non-zero exit status when a command failsRon Yorston2023-09-121-10/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a build command returned a non-zero exit status 'make' reported a warning and returned an exit code of zero. This was due to the misuse of the status returned by system(3). As the man page says: the return value is a "wait status" that can be examined using the macros described in waitpid(2). (i.e., WIFEXITED(), WEXITSTATUS(), and so on). Use the error() function to correctly report the problem on stderr and return an exit status of 2. Some additional changes in the same area: - When a target is removed report the diagnostic on stderr, as required by POSIX. - When a build command receives a signal GNU make removes the target. bmake doesn't and it isn't required by POSIX. Implement this as an extension. - Expand the error message when a build command fails so it includes the exit status or signal number, as obtained from the value returned by system(3). - Alter the WIN32 implementation of system(3) to handle exit codes which represent termination as if by a signal. Adds 200-240 bytes. (GitHub issue #354)
* | make: avoid more warningsRon Yorston2023-09-121-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The tracking of progress introduced in commit fb4be267c (make: fixes to warning messages) failed to account for runs with the '-t' or '-n' options. Without this the following makefile: dummy_target: dummy_rule dummy_rule: @: issues the warning 'make: nothing to be done for dummy_target' when run with '-t' or '-n' and no 'dummy_rule' file present. (GitHub issue #354)
* | make: fixes to warning messagesRon Yorston2023-08-251-28/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | According to POSIX only fatal diagnostic messages should be written to stderr. Arrange for warning() to write to stdout. pdpmake was rather too prolific in generating 'nothing to be done for XXX' messages. GNU make only issues the equivalent message for top-level targets and only if nothing at all was (or would have been) done. bmake doesn't seem to have such a message. Follow the practice of GNU make. This requires more intensive tracking of the actions taken while the make is in progress. Costs 16 bytes. (GitHub issue #354)
* | make: fix .DEFAULT for prerequisiteRon Yorston2023-08-241-1/+0
| | | | | | | | | | | | | | | | | | | | Commit 4b65e7d9 (Fixes to inference rules) set the N_TARGET flag for prerequisites being built recursively. That wasn't necessary for the issue at hand and it lead to other problems. Undo that part of commit 4b65e7d9. (GitHub issue #354)
* | make: fix POSIX buildRon Yorston2023-08-241-0/+15
| | | | | | | | | | | | | | | | If upstream BusyBox had a 'make' applet a native build with it enabled should match the corresponding build from the busybox-w32 source. Make it so.
* | make: allow targets of the form c:/pathRon Yorston2023-08-231-2/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Parsing of target rules was too simplistic to allow targets of the form c:/path. Allow such targets as a non-POSIX extension. Also add a 'windows' pragma to allow such targets in POSIX mode. This additionally requires the use of the 'target_name' pragma to permit slashes in target names. This change *doesn't* allow targets of the form c:path, but it's probably not wise to use them anyway. Costs 40-80 bytes. (GitHub issue #353)
* | Merge branch 'busybox' into mergeRon Yorston2023-08-104-3/+140
|\|
| * introduce and use exitcode_tDenys Vlasenko2023-07-174-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta strings_main 422 420 -2 setfattr_main 175 173 -2 brctl_main 1548 1546 -2 makedevs_main 979 975 -4 rev_main 337 332 -5 getfattr_main 307 302 -5 cut_main 1201 1196 -5 cksum_main 398 393 -5 umount_main 573 565 -8 ln_main 516 508 -8 expand_main 660 652 -8 df_main 1068 1060 -8 renice_main 346 332 -14 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/13 up/down: 0/-76) Total: -76 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * getfattr: fix "getfattr NOTEXIST" - now prints error msgDenys Vlasenko2023-07-171-4/+9
| | | | | | | | | | | | | | | | | | | | function old new delta getfattr_main 309 307 -2 .rodata 105395 105391 -4 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-6) Total: -6 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * getfattr: new appletYU Jincheng2023-07-161-0/+131
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta getfattr_main - 309 +309 print_attr - 115 +115 packed_usage 34576 34631 +55 .rodata 105349 105395 +46 lgetxattr - 41 +41 getxattr - 41 +41 llistxattr - 35 +35 listxattr - 35 +35 applet_names 2806 2815 +9 applet_main 1620 1624 +4 ------------------------------------------------------------------------------ (add/remove: 7/0 grow/shrink: 4/0 up/down: 690/0) Total: 690 bytes Signed-off-by: YU Jincheng <shana@zju.edu.cn> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2023-07-1332-47/+47
|\|
| * i2ctransfer: fix build warningDenys Vlasenko2023-07-101-1/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>