1
0

make: Fix clean rules, change intermediary dir

- Fix the clean and deepclean rules to actually make sense: clean
  removes the intermediary, deepclean removes the outputs
- Change the intermediary directory from `out/` to `build/` to better
  reflect how it is used
This commit is contained in:
2026-05-31 14:18:29 +02:00
parent b1a97d45d1
commit 103c50b71b
2 changed files with 9 additions and 10 deletions

2
.gitignore vendored
View File

@ -1,5 +1,5 @@
/compile_commands.json /compile_commands.json
/out /build
/docs/*.pdf /docs/*.pdf
/ain48 /ain48

View File

@ -18,8 +18,8 @@ LDFLAGS += $(shell pkg-config --libs $(LIBS))
# FILES # FILES
SRCS=$(wildcard src/*.c) SRCS=$(wildcard src/*.c)
DEPS=$(patsubst src/%.c, out/%.d, $(SRCS)) DEPS=$(patsubst src/%.c, build/%.d, $(SRCS))
OBJS=$(patsubst src/%.c, out/%.o, $(SRCS)) OBJS=$(patsubst src/%.c, build/%.o, $(SRCS))
DOCSRC=$(wildcard docs/*.typ) DOCSRC=$(wildcard docs/*.typ)
DOCS=$(patsubst docs/%.typ, docs/%.pdf, $(DOCSRC)) DOCS=$(patsubst docs/%.typ, docs/%.pdf, $(DOCSRC))
@ -37,25 +37,24 @@ docs/%.pdf: docs/%.typ
$(TYPST) c $< $@ $(TYPST) c $< $@
clean: clean:
$(RM) $(PROGRAM)
$(RM) $(DOCS)
deepclean: clean
$(RM) $(OBJS) $(RM) $(OBJS)
$(RM) $(DEPS) $(RM) $(DEPS)
$(RM) compile_commands.json $(RM) compile_commands.json
deepclean: clean
$(RM) $(PROGRAM)
$(RM) $(DOCS)
$(PROGRAM): $(OBJS) $(PROGRAM): $(OBJS)
$(LD) $(LDFLAGS) $(OBJS) -o $@ $(LD) $(LDFLAGS) $(OBJS) -o $@
build/%.d: src/%.c
out/%.d: src/%.c
@mkdir -p $(@D) @mkdir -p $(@D)
@set -e ; $(RM) $@; \ @set -e ; $(RM) $@; \
$(CC) -M $(CFLAGS) $< > $@.$$$$; \ $(CC) -M $(CFLAGS) $< > $@.$$$$; \
sed 's,\($*\)\.o[ :]*,out/\1.o $@ : ,g' < $@.$$$$ > $@; \ sed 's,\($*\)\.o[ :]*,build/\1.o $@ : ,g' < $@.$$$$ > $@; \
$(RM) $@.$$$$ $(RM) $@.$$$$
out/%.o: src/%.c build/%.o: src/%.c
@mkdir -p $(@D) @mkdir -p $(@D)
$(CC) $(CFLAGS) -c $< -o $@ $(CC) $(CFLAGS) -c $< -o $@