-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
157 lines (140 loc) · 4.07 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
SRC_DIR := ./src
OBJ_DIR := $(SRC_DIR)/obj
SRC_DIRS := $(shell find $(SRC_DIR) -type d | grep -v "/obj")
OBJ_DIRS := $(patsubst $(SRC_DIR)/%,$(OBJ_DIR)/%,$(SRC_DIRS))
NODE_FILES := $(shell find $(SRC_DIR)/nodes -name "*.cpp")
NODE_FILES += $(shell find $(SRC_DIR)/nodes -name "*.c")
LIB_FILES := $(shell find $(SRC_DIR)/lib -name "*.cpp")
LIB_FILES += $(shell find $(SRC_DIR)/lib -name "*.c")
LIB_FILES += $(shell find $(SRC_DIR)/host -name "*.cpp")
LIB_FILES += $(shell find $(SRC_DIR)/host -name "*.c")
NODE_OBJ_FILES := $(patsubst $(SRC_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(NODE_FILES))
NODE_OBJ_FILES := $(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.o,$(NODE_OBJ_FILES))
LIB_OBJ_FILES := $(patsubst $(SRC_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(LIB_FILES))
LIB_OBJ_FILES := $(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.o,$(LIB_OBJ_FILES))
OBJ_FILES := $(NODE_OBJ_FILES)
OBJ_FILES += $(LIB_OBJ_FILES)
OS := $(shell uname)
CPPFLAGS := -std=c++17
CFLAGS += -MMD -D ASIO_STANDALONE
HGUI := $(shell echo $(GUI) | tr '[:upper:]' '[:lower:]')
HOST_GUI := 0
ifeq ($(HGUI),sdl)
HOST_GUI := 0
endif
ifeq ($(HGUI),fb)
HOST_GUI := 1
endif
ifeq ($(HGUI),raw)
HOST_GUI := 2
endif
all: CFLAGS += -O2
all: hostenv hub_node gui_node files_node
debug: CFLAGS += -DDEBUG -g -O2
debug: hostenv hub_node gui_node files_node
debugo2: CFLAGS += -g -O2
debugo2: hostenv hub_node gui_node files_node
hostenv:
ifeq ($(HOST_GUI),0)
@echo Building sdl GUI driver.
endif
ifeq ($(HOST_GUI),1)
@echo Building fb GUI driver.
endif
ifeq ($(HOST_GUI),2)
@echo Building raw GUI driver.
endif
@mkdir -p $(OBJ_DIRS)
hub_node: $(LIB_OBJ_FILES) $(OBJ_DIR)/nodes/hub/hub.o
ifeq ($(OS),Darwin)
c++ -o $@ $^ \
-F/Library/Frameworks \
-framework CoreFoundation \
-framework IOKit \
-framework Security \
$(shell sdl2-config --libs) \
$(shell brew --prefix libusb)/lib/libusb-1.0.a
else
c++ -o $@ $^ \
-pthread \
$(shell sdl2-config --libs) \
-L/usr/local/lib -lusb-1.0
endif
gui_node: $(LIB_OBJ_FILES) $(OBJ_DIR)/nodes/gui/gui.o
ifeq ($(OS),Darwin)
c++ -o $@ $^ \
-F/Library/Frameworks \
-framework CoreFoundation \
-framework IOKit \
-framework Security \
$(shell sdl2-config --libs) \
$(shell brew --prefix libusb)/lib/libusb-1.0.a
else
c++ -o $@ $^ \
-pthread \
$(shell sdl2-config --libs) \
-L/usr/local/lib -lusb-1.0
endif
files_node: $(LIB_OBJ_FILES) $(OBJ_DIR)/nodes/files/files.o
ifeq ($(OS),Darwin)
c++ -o $@ $^ \
-F/Library/Frameworks \
-framework CoreFoundation \
-framework IOKit \
-framework Security \
$(shell sdl2-config --libs) \
$(shell brew --prefix libusb)/lib/libusb-1.0.a
else
c++ -o $@ $^ \
-pthread \
$(shell sdl2-config --libs) \
-L/usr/local/lib -lusb-1.0
endif
$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cpp
ifeq ($(OS),Darwin)
ifeq ($(GUI),fb)
c++ -c -o $@ $< $(CFLAGS) $(CPPFLAGS) -D_HOST_GUI=$(HOST_GUI) \
-I$(shell brew --prefix asio)/include/ \
-I$(shell brew --prefix libusb)/include/libusb-1.0/
else
c++ -c -o $@ $< $(CFLAGS) $(CPPFLAGS) -D_HOST_GUI=$(HOST_GUI) \
-I$(shell brew --prefix asio)/include/ \
-I$(shell brew --prefix libusb)/include/libusb-1.0/ \
$(shell sdl2-config --cflags)
endif
else
ifeq ($(GUI),fb)
c++ -c -o $@ $< $(CFLAGS) $(CPPFLAGS) -D_HOST_GUI=$(HOST_GUI) \
-I/usr/local/include/libusb-1.0/
else
c++ -c -o $@ $< $(CFLAGS) $(CPPFLAGS) -D_HOST_GUI=$(HOST_GUI) \
-I/usr/local/include/libusb-1.0/ \
$(shell sdl2-config --cflags)
endif
endif
$(OBJ_DIR)/%.o : $(SRC_DIR)/%.c
ifeq ($(OS),Darwin)
ifeq ($(GUI),fb)
cc -c -o $@ $< $(CFLAGS) -D_HOST_GUI=$(HOST_GUI) \
-I$(shell brew --prefix asio)/include/ \
-I$(shell brew --prefix libusb)/include/libusb-1.0/
else
cc -c -o $@ $< $(CFLAGS) -D_HOST_GUI=$(HOST_GUI) \
-I$(shell brew --prefix asio)/include/ \
-I$(shell brew --prefix libusb)/include/libusb-1.0/ \
$(shell sdl2-config --cflags)
endif
else
ifeq ($(GUI),fb)
cc -c -o $@ $< $(CFLAGS) -D_HOST_GUI=$(HOST_GUI) \
-I/usr/local/include/libusb-1.0/
else
cc -c -o $@ $< $(CFLAGS) -D_HOST_GUI=$(HOST_GUI) \
-I/usr/local/include/libusb-1.0/ \
$(shell sdl2-config --cflags)
endif
endif
clean:
@rm -f hub_node gui_node files_node
@rm -rf $(OBJ_DIR)/
-include $(OBJ_FILES:.o=.d)