Fix makefile dependency, again

I guess I have no idea how to write makefile.
This commit is contained in:
Yuxuan Shui 2018-09-06 17:57:10 +01:00
parent 0d6b1627f2
commit a8e29b92c9
1 changed files with 6 additions and 6 deletions

View File

@ -136,13 +136,13 @@ src/.clang_complete: Makefile
.deps:
mkdir -p $@
%.o: src/%.c | .deps
$(eval DEP=$(addprefix .deps/,$(@:.o=.d)))
@set -e; rm -f $(DEP); \
.deps/%.d: src/%.c | .deps
@set -e; rm -f $@; \
$(CC) -M $(CPPFLAGS) $< > $@.$$$$; \
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $(DEP); \
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
rm -f $@.$$$$
$(CC) $(CFG) $(CPPFLAGS) $(INCS) -c src/$*.c
%.o: src/%.c
$(CC) $(CFG) $(CPPFLAGS) $(INCS) -c src/$*.c -o $@
compton: $(OBJS)
$(CC) $(CFG) $(CPPFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
@ -189,4 +189,4 @@ version:
@echo "$(COMPTON_VERSION)"
.PHONY: uninstall clean docs version
include $(addprefix .deps/,$(sources:.c=.d))
include $(addprefix .deps/,$(OBJS:.o=.d))