streamline make clean list maintenance

When creating a new `Makefile` target to build,
it's also necessary to update the `clean` target,
which purpose is to remove built targets when they are present.

This process is simple, but it's also easy to forget :
since there is a large distance between the position in the `Makefile` where the new built target is added,
and the place where the list of files to `clean` is defined.
Moreover, the list of files becomes pretty long over time,
hence it's difficult to visually ensure that all built targets are present there,
or that no old target (no longer produced) is no longer in the list

This PR tries to improve this process by adding a CLEAN variable.
Now, when a new built target is added to the `Makefile`,
it should preceded by :
```
CLEAN += newTarget
newTarget:
<TAB> ...recipe...
```

This new requirement is somewhat similar to `.PHONY: newTarget` for non-built targets.

This new method offers the advantage of locality :
there is no separate place in the file to maintain a list of files to clean.
This makes maintenance of `make clean` easier.
This commit is contained in:
Yann Collet
2022-09-07 16:36:03 -07:00
parent 155d6a58a2
commit c0b46738b4
5 changed files with 49 additions and 30 deletions
+1 -1
View File
@@ -157,7 +157,7 @@ jobs:
run: |
sudo apt-get -qqq update
make valgrindinstall
make -C tests valgrindTest
make -C tests test-valgrind
make clean
make -C tests test-fuzzer-stackmode
+1 -1
View File
@@ -127,7 +127,7 @@ jobs:
sudo apt-get -qqq update
make valgrindinstall
make -C zlibWrapper test
make -C zlibWrapper valgrindTest
make -C zlibWrapper test-valgrind
lz4-threadpool-libs:
runs-on: ubuntu-latest