summaryrefslogtreecommitdiff
path: root/makefile
blob: 667f693753720b123037811c84b802071ffec450 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
CC := g++
BUILD_DIR := build
CCOPTS := -Wall -Wextra -ggdb -pedantic-errors 
SRC_DIR := ./
OUTPUT := $(shell basename $(CURDIR)).elf

SRCFILES := $(wildcard ./$(SRC_DIR)/*.cpp)
OBJFILES := $(patsubst ./$(SRC_DIR)/%.cpp,$(BUILD_DIR)/%.o,$(SRCFILES))

make: BUILD_DIR $(OBJFILES)
	$(CC) $(CCOPTS) -o $(OUTPUT) $(OBJFILES) 

debug: 
	gdb -x debug.gdb $(OUTPUT)

$(BUILD_DIR)/%.o: $(SRC_DIR)/%.cpp
	$(CC) $(CCOPTS) -c $< -o $@

BUILD_DIR:
	mkdir -p $(BUILD_DIR)

clean:
	rm -rf build/ $(OUTPUT)