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.
This commit is contained in:
16
Makefile
16
Makefile
@@ -1,5 +1,8 @@
|
|||||||
CC=gcc
|
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=
|
LIBS=
|
||||||
ARGS=
|
ARGS=
|
||||||
OUT=ovm.out
|
OUT=ovm.out
|
||||||
@@ -12,18 +15,19 @@ OBJECTS=$(CODE:$(SRC)/%.c=$(DIST)/%.o)
|
|||||||
DEPS=$(OBJECTS:%.o=%.d)
|
DEPS=$(OBJECTS:%.o=%.d)
|
||||||
|
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
all: $(OUT)
|
all: $(OUT) $(DIST)
|
||||||
|
|
||||||
|
$(DIST):
|
||||||
|
mkdir -p $(DIST)
|
||||||
|
|
||||||
$(OUT): $(DIST)/$(OUT)
|
$(OUT): $(DIST)/$(OUT)
|
||||||
|
|
||||||
$(DIST)/$(OUT): $(OBJECTS)
|
$(DIST)/$(OUT): $(DIST) $(OBJECTS)
|
||||||
mkdir -p $(DIST)
|
$(CC) $(CFLAGS) $(OBJECTS) -o $@ $(LIBS)
|
||||||
$(CC) $(CFLAGS) $^ -o $@ $(LIBS)
|
|
||||||
|
|
||||||
-include $(DEPS)
|
-include $(DEPS)
|
||||||
|
|
||||||
$(DIST)/%.o: $(SRC)/%.c
|
$(DIST)/%.o: $(SRC)/%.c
|
||||||
mkdir -p $(DIST)
|
|
||||||
$(CC) $(CFLAGS) -MMD -c $< -o $@ $(LIBS)
|
$(CC) $(CFLAGS) -MMD -c $< -o $@ $(LIBS)
|
||||||
|
|
||||||
.PHONY: run
|
.PHONY: run
|
||||||
|
|||||||
Reference in New Issue
Block a user