-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
44 lines (35 loc) · 930 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
#
# makefile for the avalon compiler
#
# :author Ntwali Bashige
# :year 2018-2019
# :email [email protected]
#
CC := gcc
CFLAGS := -std=c11 -g -Wall -Wextra -pedantic -DDEBUG
SRC_DIR := src
INC := -Isrc
BUILD_DIR := build
BIN_DIR := bin
TARGET := $(BIN_DIR)/avalonc
SRC_EXT := .c
SOURCES := $(shell find $(SRC_DIR) -type f -name *$(SRC_EXT))
OBJECTS := $(patsubst $(SRC_DIR)/%,$(BUILD_DIR)/%,$(SOURCES:$(SRC_EXT)=.o))
.PHONY: all
all: setup $(TARGET)
$(TARGET): $(OBJECTS)
$(CC) $^ -o $(TARGET)
$(BUILD_DIR)/%.o: $(SRC_DIR)/%$(SRC_EXT)
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) $(INC) -c -o $@ $<
.PHONY: setup
setup:
@mkdir -p $(BIN_DIR)
@mkdir -p $(BUILD_DIR)
.PHONY: clean
clean:
@find . -exec touch {} \;
@rm -rf $(BUILD_DIR) $(BIN_DIR)
.PHONY: grind
grind:
@valgrind --leak-check=full --leak-resolution=high --track-origins=yes $(TARGET) $(program)