The shrinking role of ETXTBSY
The shrinking role of ETXTBSY
Posted Aug 20, 2021 6:26 UTC (Fri) by nybble41 (subscriber, #55106)In reply to: The shrinking role of ETXTBSY by NYKevin
Parent article: The shrinking role of ETXTBSY
That isn't strictly true, at least with respect to GNU make. There are a number of built-in patterns. For example, in a directory containing only a source file "test.c" (and no makefile) if you run "make 'libtest.a(test.o)'" the GNU make will invoke the following commands automatically:
cc -c -o test.o test.c
ar rv libtest.a test.o
rm test.o
So without being told it knows at least how to compile .c files into .o files, add .o files to a static library, and remove the temporary .o files afterward. There is also at least one built-in implicit rule (%.out: %) which involves copying files: if you run "make test.c.out" it will invoke "cp test.c test.c.out". And if you have a file "script.sh" and run "make script" it will copy "script.sh" to "script"—using cat(1) and redirection rather than cp(1)—and then mark the resulting file as executable.
Besides the built-in rules, GNU make also removes any intermediate files generated when multiple implicit rules are chained to build a target: <https://www.gnu.org/software/make/manual/html_node/Chaine...>.
You can list all the built-in rules available on your system with "make -f /dev/null -p". There is also a partial list in the manual: <https://www.gnu.org/software/make/manual/html_node/Catalo...>.
Posted Aug 23, 2021 1:02 UTC (Mon)
by NYKevin (subscriber, #129325)
[Link]
Make doesn't have any code which directly calls rename(2), unlink(2), etc. for the purposes of executing a recipe.* Recipes are (effectively) very small shell scripts, and it is rm(1) or cp(1) (or in the case of open(2) for a redirection, the shell) which actually makes those syscalls on make's behalf. Make doesn't "know" anything about how to copy a file, it just "knows" to run cp(1) and check the exit code.
* I have not looked, but I suppose it is theoretically possible that there is some code path where make creates a temporary file or something like that. That's not what I'm talking about here. I'm talking about the files that the user cares about, i.e. the ones that actually appear on the command line or in a recipe, whether explicit or implicit.
Posted Aug 23, 2021 14:11 UTC (Mon)
by skitt (subscriber, #5367)
[Link]
The shrinking role of ETXTBSY
The shrinking role of ETXTBSY
