-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
54 lines (39 loc) · 974 Bytes
/
Makefile
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
43
44
45
46
47
48
49
50
51
52
53
54
# Makefile
# Project: Rubel Language
# Derek Tan
# compiler vars
CC := clang -std=c11
CFLAGS := -g -Wall -Werror -O0
# executable dir
BIN_DIR := ./bin
# build files dir
BUILD_DIR := ./build
# implementation code dir
SRC_DIR := ./src
# header include dir
HEADER_DIR := ./headers
# auto generate object file target names
SRCS := $(shell find $(SRC_DIR) -name '*.c')
OBJS := $(patsubst $(SRC_DIR)/%.c,$(BUILD_DIR)/%.o,$(SRCS))
# executable generate path
EXE := $(BIN_DIR)/rubel
vpath %.c $(SRC_DIR)
.PHONY: tell all clean
# utility rule: show SLOC
sloc:
@wc -l headers/**/*.h headers/**/**/*.h src/*.c
# debug rule: show all targets and deps
tell:
@echo "Code:"
@echo $(SRCS)
@echo "Objs:"
@echo $(OBJS)
# build rules: compiles code and links object files into executable
all: $(EXE)
$(EXE): $(OBJS)
$(CC) $(CFLAGS) $^ -o $@
$(BUILD_DIR)/%.o: %.c
$(CC) $(CFLAGS) -c $< -I$(HEADER_DIR) -o $@
# clean rule: only remove old executables!
clean:
rm -f $(EXE)