forked from chirp-language/chirpc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
37 lines (26 loc) · 768 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
CXX = g++
APP_NAME = chirpc
CXX_FLAGS =-std=c++17 $(FLAGS)
SRC_ROOT =src
DEST_DIR =bin
.PHONY : all setup
#Create the include dirs in a list with -I in front of each item
INCLUDES = $(patsubst %, -I%, $(shell find $(SRC_ROOT) -type d))
#Set VPATH to find the source files
VPATH = $(shell find $(SRC_ROOT) -type d)
#Just get the filenames
SOURCE_FILES=$(notdir $(shell find $(SRC_ROOT) -name *.cpp))
#Turn the file names into object filenames
OBJECTS = $(SOURCE_FILES:%.cpp=$(DEST_DIR)/%.o)
.ONESHELL:
all: $(APP_NAME)
$(APP_NAME) : $(OBJECTS)
$(CXX) -o $(APP_NAME) $^ $(CXX_FLAGS)
setup:
@echo "Making a build folder"
@mkdir -p $(DEST_DIR)
$(DEST_DIR)/%.o: %.cpp
$(CXX) -g -c $< -o $@ $(CXX_FLAGS) $(INCLUDES)
clean:
rm $(APP_NAME)
rm $(DEST_DIR)/*.o