aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2023-10-22 18:06:41 +0100
committerAryadev Chavali <aryadev@aryadevchavali.com>2023-10-22 18:07:41 +0100
commitcf23a620089155caf2a1c7227c6c52f9f8a74a3c (patch)
tree2ff328463b567bdb01cb56b21fbaf85df620d8e1
parent36bcd90c81f7dc0d7ab268a30768c80ff53eb93d (diff)
downloadovm-cf23a620089155caf2a1c7227c6c52f9f8a74a3c.tar.gz
ovm-cf23a620089155caf2a1c7227c6c52f9f8a74a3c.tar.bz2
ovm-cf23a620089155caf2a1c7227c6c52f9f8a74a3c.zip
Made a debug and release configuration via flags
Also split out the check for whether $(DIST) exists by making it its own recipe. Removes the repeated checks in each object compilation.
-rw-r--r--Makefile16
1 files changed, 10 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index a0106b3..6ac5145 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,8 @@
CC=gcc
-CFLAGS=-Wall -Wextra -Werror -Wswitch-enum -ggdb -fsanitize=address -std=c11
+GENERAL-FLAGS=-Wall -Wextra -Werror -Wswitch-enum -std=c11
+DEBUG-FLAGS=-ggdb -fsanitize=address
+RELEASE-FLAGS=-O3
+CFLAGS=$(GENERAL-FLAGS) $(DEBUG-FLAGS)
LIBS=
ARGS=
OUT=ovm.out
@@ -12,18 +15,19 @@ OBJECTS=$(CODE:$(SRC)/%.c=$(DIST)/%.o)
DEPS=$(OBJECTS:%.o=%.d)
.PHONY: all
-all: $(OUT)
+all: $(OUT) $(DIST)
+
+$(DIST):
+ mkdir -p $(DIST)
$(OUT): $(DIST)/$(OUT)
-$(DIST)/$(OUT): $(OBJECTS)
- mkdir -p $(DIST)
- $(CC) $(CFLAGS) $^ -o $@ $(LIBS)
+$(DIST)/$(OUT): $(DIST) $(OBJECTS)
+ $(CC) $(CFLAGS) $(OBJECTS) -o $@ $(LIBS)
-include $(DEPS)
$(DIST)/%.o: $(SRC)/%.c
- mkdir -p $(DIST)
$(CC) $(CFLAGS) -MMD -c $< -o $@ $(LIBS)
.PHONY: run