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:
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,5 +1,5 @@
|
||||
/compile_commands.json
|
||||
/out
|
||||
/build
|
||||
/docs/*.pdf
|
||||
/ain48
|
||||
|
||||
|
||||
17
Makefile
17
Makefile
@ -18,8 +18,8 @@ LDFLAGS += $(shell pkg-config --libs $(LIBS))
|
||||
|
||||
# FILES
|
||||
SRCS=$(wildcard src/*.c)
|
||||
DEPS=$(patsubst src/%.c, out/%.d, $(SRCS))
|
||||
OBJS=$(patsubst src/%.c, out/%.o, $(SRCS))
|
||||
DEPS=$(patsubst src/%.c, build/%.d, $(SRCS))
|
||||
OBJS=$(patsubst src/%.c, build/%.o, $(SRCS))
|
||||
|
||||
DOCSRC=$(wildcard docs/*.typ)
|
||||
DOCS=$(patsubst docs/%.typ, docs/%.pdf, $(DOCSRC))
|
||||
@ -37,25 +37,24 @@ docs/%.pdf: docs/%.typ
|
||||
$(TYPST) c $< $@
|
||||
|
||||
clean:
|
||||
$(RM) $(PROGRAM)
|
||||
$(RM) $(DOCS)
|
||||
deepclean: clean
|
||||
$(RM) $(OBJS)
|
||||
$(RM) $(DEPS)
|
||||
$(RM) compile_commands.json
|
||||
deepclean: clean
|
||||
$(RM) $(PROGRAM)
|
||||
$(RM) $(DOCS)
|
||||
|
||||
$(PROGRAM): $(OBJS)
|
||||
$(LD) $(LDFLAGS) $(OBJS) -o $@
|
||||
|
||||
|
||||
out/%.d: src/%.c
|
||||
build/%.d: src/%.c
|
||||
@mkdir -p $(@D)
|
||||
@set -e ; $(RM) $@; \
|
||||
$(CC) -M $(CFLAGS) $< > $@.$$$$; \
|
||||
sed 's,\($*\)\.o[ :]*,out/\1.o $@ : ,g' < $@.$$$$ > $@; \
|
||||
sed 's,\($*\)\.o[ :]*,build/\1.o $@ : ,g' < $@.$$$$ > $@; \
|
||||
$(RM) $@.$$$$
|
||||
|
||||
out/%.o: src/%.c
|
||||
build/%.o: src/%.c
|
||||
@mkdir -p $(@D)
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
|
||||
Reference in New Issue
Block a user