-
Notifications
You must be signed in to change notification settings - Fork 98
/
Makefile
117 lines (97 loc) · 2.63 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
SRC_DIR := ./src
OBJ_DIR_GUI := ./src/obj/gui
OBJ_DIR_TUI := ./src/obj/tui
SRC_DIRS := $(shell find $(SRC_DIR) -type d | grep -v "/obj")
OBJ_DIRS := $(patsubst $(SRC_DIR)/%,$(OBJ_DIR_GUI)/%,$(SRC_DIRS))
OBJ_DIRS += $(patsubst $(SRC_DIR)/%,$(OBJ_DIR_TUI)/%,$(SRC_DIRS))
SRC_FILES := $(shell find $(SRC_DIR) -name "*.cpp")
SRC_FILES += $(shell find $(SRC_DIR) -name "*.c")
OBJ_FILES_GUI := $(patsubst $(SRC_DIR)/%.cpp,$(OBJ_DIR_GUI)/%.o,$(SRC_FILES))
OBJ_FILES_GUI := $(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR_GUI)/%.o,$(OBJ_FILES_GUI))
OBJ_FILES_TUI := $(patsubst $(SRC_DIR)/%.cpp,$(OBJ_DIR_TUI)/%.o,$(SRC_FILES))
OBJ_FILES_TUI := $(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR_TUI)/%.o,$(OBJ_FILES_TUI))
OBJ_FILES := $(OBJ_FILES_GUI)
OBJ_FILES += $(OBJ_FILES_TUI)
CFLAGS := -O3 -nostdlib -fno-exceptions -MMD
CPPFLAGS := -std=c++14
HGUI := $(shell echo $(GUI) | tr '[:upper:]' '[:lower:]')
OS := $(shell uname)
CPU := $(shell uname -m)
ifeq ($(CPU),x86_64)
ABI := AMD64
else
ifeq ($(CPU),riscv64)
ABI := RISCV64
else
CPU := arm64
ABI := ARM64
endif
endif
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: hostenv tui gui
gui: hostenv obj/$(CPU)/$(ABI)/$(OS)/main_gui
tui: hostenv obj/$(CPU)/$(ABI)/$(OS)/main_tui
install: clean hostenv tui gui inst
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
@echo $(CPU) > cpu
@echo $(OS) > os
@echo $(ABI) > abi
@mkdir -p obj/$(CPU)/$(ABI)/$(OS) $(OBJ_DIRS)
snapshot:
@rm -f snapshot.zip
@zip -9q snapshot.zip \
obj/vp64/VP64/sys/boot_image \
`find obj -name "main_gui.exe"` \
`find obj -name "main_tui.exe"`
inst:
@./run_tui.sh -n 8 -i -e -f
obj/$(CPU)/$(ABI)/$(OS)/main_gui: $(OBJ_FILES_GUI)
ifeq ($(GUI),fb)
c++ -o $@ $^
else
c++ -o $@ $^ \
$(shell sdl2-config --libs)
endif
obj/$(CPU)/$(ABI)/$(OS)/main_tui: $(OBJ_FILES_TUI)
c++ -o $@ $^
$(OBJ_DIR_GUI)/%.o: $(SRC_DIR)/%.cpp
ifeq ($(GUI),fb)
c++ -c -o $@ $< $(CFLAGS) $(CPPFLAGS) -D_HOST_GUI=$(HOST_GUI)
else
c++ -c -o $@ $< $(CFLAGS) $(CPPFLAGS) -D_HOST_GUI=$(HOST_GUI) \
$(shell sdl2-config --cflags)
endif
$(OBJ_DIR_GUI)/%.o: $(SRC_DIR)/%.c
ifeq ($(GUI),fb)
cc -c -o $@ $< $(CFLAGS) -D_HOST_GUI=$(HOST_GUI)
else
cc -c -o $@ $< $(CFLAGS) -D_HOST_GUI=$(HOST_GUI) \
$(shell sdl2-config --cflags)
endif
$(OBJ_DIR_TUI)/%.o: $(SRC_DIR)/%.cpp
c++ -c -o $@ $< $(CFLAGS) $(CPPFLAGS)
$(OBJ_DIR_TUI)/%.o: $(SRC_DIR)/%.c
cc -c -o $@ $< $(CFLAGS)
clean:
@rm -rf ./obj
@rm -rf ./src/obj
@unzip -oq snapshot.zip
-include $(OBJ_FILES:.o=.d)