CC=clang
MODULES=gtk+-3.0 json-glib-1.0
CFLAGS=-Wall -pedantic --std=gnu17 `pkg-config --cflags $(MODULES)`
LDLIBS=`pkg-config --libs $(MODULES)`
HEADERS=*.h
EXE=app
ALL: $(EXE)
$(EXE): application.o jsonstuff.o otherstuff.o
application.o: application.c $(HEADERS)
jsonstuff.o: jsonstuff.c $(HEADERS)
otherstuff.o: otherstuff.c $(HEADERS)
clean:
rm -f $(EXE) *.o
This isn't perfect as it causes a full project rebuild whenever a header is updated, but I've found it's easier to do this than to try to track header usage in files. Also, failing to rebuild something when a header updates is a quick way to drive yourself crazy in C, it's better to be conservative. It's easy enough that you can write it from memory in a minute or two and pretty flexible. There are no unit tests, no downloading and building of external resources, or anything fancy like that. Just basic make. It does parallelize if you pass -j to make.That's sort essential to serving its purpose, after all.
I haven't yet run into a scenario where there was a clean task that couldn't be accomplished by using flags to git clean, usually -dfx[0]. If someone has an example of something complex enough to require a separate target in the build system, I'm all ears.
[0] git is my Makefile effect program. I do not know it well, and have not invested the time to learn it. This says something about me, got, or both.
If there is a Makefile with a clean target, usually the first thing I do when I start is make it an alias for `git clean -X`.
Usually, you want to keep your untracked files (they are usually experiments, debugging hooks, or whatever).
All I can think of are things like periodically copying them to another folder, or give them a different ownership needed for edit/delete, etc.
Unless there's some kind of .gitpreserve feature...
make clean makes lots of sense but is not even strictly necessary. In the world where all it does is find all the *.o files and deletes them it’s not a bad thing at all.