-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
42 lines (34 loc) · 886 Bytes
/
Makefile
File metadata and controls
42 lines (34 loc) · 886 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# tool macros
CC = gcc
CLIBS = -lm -lSDL2
CERROR = -Wall
CFLAGS = $(CERROR) $(CLIBS) $(addprefix -I, $(HDR_PATH))
LFLAGS = $(CFLAGS) -c
# path macros
LIB_PATH := libs
HDR_PATH := include $(LIB_PATH)
BIN_PATH := bin
SRC_PATH := src
SRC_PATH += src/engine
SRC_PATH += src/project
# compile macros
TARGET := $(BIN_PATH)/runtime
# src files & obj files
SRC := $(shell find $(SRC_PATH) -type f -name '*.c')
OBJ := $(patsubst %.c, $(BIN_PATH)/%.o, $(SRC))
# default rule
all: $(TARGET)
# non-phony targets
$(TARGET): $(OBJ)
@if [ ! -d $(BIN_PATH) ]; then mkdir $(BIN_PATH); fi;
@printf "%s:\n\t" $(notdir $(TARGET))
@$(CC) $^ $(CFLAGS) -o $@
@printf "Compiled Successfully!\n"
$(BIN_PATH)/%.o: %.c
@if [ ! -d $(dir $@) ]; then mkdir -p $(dir $@); fi;
@printf "\t%-15s %-30s " $(notdir $^) $@
@echo $(CLIBS)
@$(CC) $(LFLAGS) -o $@ $^
.PHONY: clean
clean:
@rm -rf $(BIN_PATH)