diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-09-29 17:07:21 +0100 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-09-29 17:07:21 +0100 |
commit | 7c09c2c22c13be3ac33ae2b6c868e62b29cffee6 (patch) | |
tree | c1027ecad827ac457a245413bf489ca53f1c0f89 /Emacs/.config/emacs | |
parent | b23acc3bbe050574c4ce43f500f263c7df31b880 (diff) | |
download | dotfiles-7c09c2c22c13be3ac33ae2b6c868e62b29cffee6.tar.gz dotfiles-7c09c2c22c13be3ac33ae2b6c868e62b29cffee6.tar.bz2 dotfiles-7c09c2c22c13be3ac33ae2b6c868e62b29cffee6.zip |
(Emacs)~Makefile autoinsert now does dependency tracking
Figured this out during stack-vm.c development: a way for Makefiles to
do proper dependency tracking using gcc's option -MMD.
Diffstat (limited to 'Emacs/.config/emacs')
-rw-r--r-- | Emacs/.config/emacs/config.org | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/Emacs/.config/emacs/config.org b/Emacs/.config/emacs/config.org index 9ad7acc..6f05038 100644 --- a/Emacs/.config/emacs/config.org +++ b/Emacs/.config/emacs/config.org @@ -2520,25 +2520,41 @@ change it for C++. (("[mM]akefile\\'" . "Makefile skeleton") "" "CC=gcc -CFLAGS=-Wall -Wextra -Wpedantic -ggdb -fsanitize=address -std=c11 +CFLAGS=-Wall -Wextra -Werror -Wswitch-enum -ggdb -fsanitize=address -std=c11 LIBS= -OBJECTS=main.o -OUT=main ARGS= +OUT=main.out -%.o: %.c - $(CC) $(CFLAGS) -c $^ -o $@ $(LIBS) +SRC=src +DIST=build -$(OUT): $(OBJECTS) +CODE=$(addprefix $(SRC)/, main.c) +OBJECTS=$(CODE:$(SRC)/%.c=$(DIST)/%.o) +DEPS=$(OBJECTS:%.o=%.d) + +.PHONY: all +all: $(OUT) + +$(OUT): $(DIST)/$(OUT) + +$(DIST)/$(OUT): $(OBJECTS) + mkdir -p $(DIST) $(CC) $(CFLAGS) $^ -o $@ $(LIBS) -.PHONY: -clean: - rm -rfv $(OUT) $(OBJECTS) +-include $(DEPS) + +$(DIST)/%.o: $(SRC)/%.c + mkdir -p $(DIST) + $(CC) $(CFLAGS) -MMD -c $< -o $@ $(LIBS) .PHONY: run -run: $(OUT) - ./$^ $(ARGS)" +run: $(DIST)/$(OUT) + ./$^ $(ARGS) + +.PHONY: +clean: + rm -rfv $(DIST)/* +" _)) #+end_src * Org mode |