aboutsummaryrefslogtreecommitdiff
path: root/Emacs/.config
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2024-04-16 22:03:52 +0630
committerAryadev Chavali <aryadev@aryadevchavali.com>2024-04-16 22:03:52 +0630
commitf735120b97f74e44c7339068cfe256abc2879f86 (patch)
treed9e84bbfab1f7f19e13ea609ef962a73bd3acdaa /Emacs/.config
parent98626cf2a8af51ea8e6ada03956c2c990d48074b (diff)
downloaddotfiles-f735120b97f74e44c7339068cfe256abc2879f86.tar.gz
dotfiles-f735120b97f74e44c7339068cfe256abc2879f86.tar.bz2
dotfiles-f735120b97f74e44c7339068cfe256abc2879f86.zip
(Emacs/config)~Makefile auto insert now generates dependencies
Using -M* options in gcc and clang we can generate dependencies for C files which can be used by make to rebuild files based on other files.
Diffstat (limited to 'Emacs/.config')
-rw-r--r--Emacs/.config/emacs/config.org26
1 files changed, 16 insertions, 10 deletions
diff --git a/Emacs/.config/emacs/config.org b/Emacs/.config/emacs/config.org
index f46344d..7f9e924 100644
--- a/Emacs/.config/emacs/config.org
+++ b/Emacs/.config/emacs/config.org
@@ -1081,30 +1081,28 @@ change it for C++.
"CC=gcc
CFLAGS=-Wall -Wextra -Werror -Wswitch-enum -ggdb -fsanitize=address -std=c11
LIBS=
+
ARGS=
OUT=main.out
SRC=src
DIST=build
-
-CODE=$(addprefix $(SRC)/, main.c)
+CODE=$(addprefix $(SRC)/, ) # add source files here
OBJECTS=$(CODE:$(SRC)/%.c=$(DIST)/%.o)
-DEPS=$(OBJECTS:%.o=%.d)
+DEPDIR:=$(DIST)/dependencies
+DEPFLAGS=-MT $@ -MMD -MP -MF
+DEPS:=$(CODE:$(SRC)/%.c=$(DEPDIR):%.d) $(DEPDIR)/main.d
.PHONY: all
all: $(OUT)
$(OUT): $(DIST)/$(OUT)
-$(DIST)/$(OUT): $(OBJECTS)
- mkdir -p $(DIST)
+$(DIST)/$(OUT): $(OBJECTS) $(SRC)/main.o | $(DIST)
$(CC) $(CFLAGS) $^ -o $@ $(LIBS)
--include $(DEPS)
-
-$(DIST)/%.o: $(SRC)/%.c
- mkdir -p $(DIST)
- $(CC) $(CFLAGS) -MMD -c $< -o $@ $(LIBS)
+$(DIST)/%.o: $(SRC)/%.c | $(DIST) $(DEPDIR)
+ $(CC) $(CFLAGS) $(DEPFLAGS) $(DEPDIR)/$*.d -c $< -o $@ $(LIBS)
.PHONY: run
run: $(DIST)/$(OUT)
@@ -1113,6 +1111,14 @@ run: $(DIST)/$(OUT)
.PHONY:
clean:
rm -rfv $(DIST)/*
+
+$(DIST):
+ mkdir -p $(DIST)
+
+$(DEPDIR):
+ mkdir -p $(DEPDIR)
+
+-include $(DEPS)
"
_))
#+end_src