-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
79 lines (49 loc) · 1.91 KB
/
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
CXX = g++
CC = gcc
CFLAGS = -Wall
CXXFLAGS = -Wall
CXXFLAGS += --std=c++11
PKG_FLAGS = $(shell pkg-config --cflags glib-2.0)
INC_PATHS += -I.
INC_PATHS += -I./include/
LDFLAGS = -lglib-2.0 -lpthread
MKDIR = mkdir -p
# C Source Files
CSOURCES =
# C++ Source Files
CXXSOURCES = QnPacket.cpp qn_programmer.cpp serial.cpp print.cpp QnPacket.cpp
CXXSOURCES += timing.cpp bb_gpio.cpp helper.cpp
DEPS_H_FILE =
OBJECTC = $(CSOURCES:.c=.o)
OBJECTCXX = $(CXXSOURCES:.cpp=.o)
OBJECT_DIRECTORY = ./bin
OUTPUT_BINARY_DIRECTORY = $(OBJECT_DIRECTORY)
EXE_DIRECTORY = ./exe
EXE_FILES = qntool pin_ctrl
OBJC = $(patsubst %,$(OUTPUT_BINARY_DIRECTORY)/%,$(OBJECTC))
OBJCXX = $(patsubst %,$(OUTPUT_BINARY_DIRECTORY)/%,$(OBJECTCXX))
EXE = $(patsubst %,$(EXE_DIRECTORY)/%,$(EXE_FILES))
VPATH =./main:./drivers:./helper
# Sorting removes duplicates
BUILD_DIRECTORIES := $(sort $(OBJECT_DIRECTORY) $(OUTPUT_BINARY_DIRECTORY))
## Rules start from here
.PHONY: all cleanall clean cleanobj
.DEFAULT_GOAL = all
all: $(EXE_FILES) | $(BUILD_DIRECTORIES)
qntool: $(OBJC) $(OBJCXX) qntool.cpp | $(BUILD_DIRECTORIES)
@$(CXX) -g -o $@ $^ $(PKG_FLAGS) $(CXXFLAGS) $(LDFLAGS) $(INC_PATHS)
@echo "********************************** qntool done **********************************"
pin_ctrl: $(OBJC) $(OBJCXX) pin_ctrl.cpp | $(BUILD_DIRECTORIES)
@$(CXX) -g -o $@ $^ $(PKG_FLAGS) $(CXXFLAGS) $(LDFLAGS) $(INC_PATHS)
@echo "********************************** pin_ctrl done **********************************"
$(OUTPUT_BINARY_DIRECTORY)/%.o: %.c $(DEPS_H_FILE) | $(BUILD_DIRECTORIES)
@$(CXX) -g -c -o $@ $< $(PKG_FLAGS) $(CXXFLAGS) $(INC_PATHS)
$(OUTPUT_BINARY_DIRECTORY)/%.o: %.cpp $(DEPS_H_FILE) | $(BUILD_DIRECTORIES)
@$(CXX) -g -c -o $@ $< $(PKG_FLAGS) $(CXXFLAGS) $(INC_PATHS)
## Create build directories
$(BUILD_DIRECTORIES):
$(MKDIR) $@
clean: cleanall
cleanall:
$(RM) -r $(BUILD_DIRECTORIES)
$(RM) -r $(EXE_FILES)