-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
123 lines (96 loc) · 4.16 KB
/
Copy pathMakefile
File metadata and controls
123 lines (96 loc) · 4.16 KB
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
CXX = g++
# Third-party headers under include/ (PDFWriter, FreeType, etc.): treat as system so
# libc++ deprecation noise (e.g. char_traits<unsigned char> in ByteList.h) is suppressed
# until upstream fixes it. Project code stays under -I./src and is not affected.
CXXFLAGS = -std=c++20 -Wall -Wextra -MMD -MP -I./src -isystem ./include
LDFLAGS = -L./lib
LIBS = -lPDFWriter -lFreeType -lLibJpeg -lLibPng -lLibTiff -lZlib -lLibAesgm -lz -lm
SRC_DIR = src
ASSETS_DIR = assets
BUILD_DIR = build
OBJ_DIR = $(BUILD_DIR)/obj
TARGET = $(BUILD_DIR)/pdf_app
EDITOR_TARGET = $(BUILD_DIR)/char_editor
SOURCES = $(shell find $(SRC_DIR) -name '*.cpp')
OBJECTS = $(patsubst $(SRC_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(SOURCES))
DEPS = $(OBJECTS:.o=.d)
.PHONY: all clean run editor run_editor check-character-json sync-webrender-cfg serve-webrender webrender
PARAM ?=
all: $(TARGET)
# Runtime loads paths like assets/... relative to cwd; make run uses $(BUILD_DIR).
$(BUILD_DIR)/assets: | $(BUILD_DIR)
@if [ -e "$(BUILD_DIR)/assets" ] && [ ! -L "$(BUILD_DIR)/assets" ]; then \
echo "error: $(BUILD_DIR)/assets exists and is not a symlink; remove or merge with $(ASSETS_DIR)" >&2; exit 1; \
fi
ln -snf ../$(ASSETS_DIR) "$(BUILD_DIR)/assets"
$(TARGET): $(OBJECTS) | $(BUILD_DIR) $(BUILD_DIR)/assets
$(CXX) $(OBJECTS) $(LDFLAGS) $(LIBS) -o $@
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp | $(OBJ_DIR)
@mkdir -p $(dir $@)
$(CXX) $(CXXFLAGS) -c $< -o $@
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
$(OBJ_DIR):
mkdir -p $(OBJ_DIR)
run: $(TARGET)
@cd $(BUILD_DIR) && ./$(notdir $(TARGET)) $(PARAM)
check-character-json: $(TARGET) | $(BUILD_DIR)/assets
@cd $(BUILD_DIR) && ./$(notdir $(TARGET)) $(PARAM)
# Character JSON editor (Qt6 Widgets, optional)
QT_CFLAGS := $(shell pkg-config --cflags Qt6Widgets 2>/dev/null)
QT_LIBS := $(shell pkg-config --libs Qt6Widgets 2>/dev/null)
EDITOR_SRC_DIR = tools/char_editor/src
EDITOR_SOURCES = $(shell find $(EDITOR_SRC_DIR) -name '*.cpp')
EDITOR_SHARED_SOURCES = src/syshelpers/AcCalculation.cpp src/syshelpers/Utilities.cpp
EDITOR_OBJECTS = $(patsubst $(EDITOR_SRC_DIR)/%.cpp,$(OBJ_DIR)/char_editor/%.o,$(EDITOR_SOURCES)) \
$(OBJ_DIR)/char_editor/shared/AcCalculation.o $(OBJ_DIR)/char_editor/shared/Utilities.o
EDITOR_DEPS = $(EDITOR_OBJECTS:.o=.d)
.PHONY: editor
editor: $(EDITOR_TARGET)
$(EDITOR_TARGET): $(EDITOR_OBJECTS) | $(BUILD_DIR)
@if [ -z "$(QT_CFLAGS)" ] || [ -z "$(QT_LIBS)" ]; then \
echo "error: Qt6Widgets not found via pkg-config. Install Qt6 + pkg-config and ensure Qt6Widgets.pc is visible." >&2; \
exit 1; \
fi
$(CXX) $(EDITOR_OBJECTS) $(LDFLAGS) $(QT_LIBS) -o $@
$(OBJ_DIR)/char_editor/%.o: $(EDITOR_SRC_DIR)/%.cpp | $(OBJ_DIR)
@if [ -z "$(QT_CFLAGS)" ]; then \
echo "error: Qt6Widgets not found via pkg-config. Install Qt6 + pkg-config and ensure Qt6Widgets.pc is visible." >&2; \
exit 1; \
fi
@mkdir -p $(dir $@)
$(CXX) $(CXXFLAGS) $(QT_CFLAGS) -I./$(EDITOR_SRC_DIR) -c $< -o $@
$(OBJ_DIR)/char_editor/shared/AcCalculation.o: src/syshelpers/AcCalculation.cpp | $(OBJ_DIR)
@if [ -z "$(QT_CFLAGS)" ]; then \
echo "error: Qt6Widgets not found via pkg-config. Install Qt6 + pkg-config and ensure Qt6Widgets.pc is visible." >&2; \
exit 1; \
fi
@mkdir -p $(dir $@)
$(CXX) $(CXXFLAGS) $(QT_CFLAGS) -c $< -o $@
$(OBJ_DIR)/char_editor/shared/Utilities.o: src/syshelpers/Utilities.cpp | $(OBJ_DIR)
@if [ -z "$(QT_CFLAGS)" ]; then \
echo "error: Qt6Widgets not found via pkg-config. Install Qt6 + pkg-config and ensure Qt6Widgets.pc is visible." >&2; \
exit 1; \
fi
@mkdir -p $(dir $@)
$(CXX) $(CXXFLAGS) $(QT_CFLAGS) -c $< -o $@
run_editor: $(EDITOR_TARGET) | $(BUILD_DIR)/assets
@cd $(BUILD_DIR) && ./$(notdir $(EDITOR_TARGET))
-include $(DEPS)
-include $(EDITOR_DEPS)
clean:
rm -rf $(OBJ_DIR) $(TARGET) $(EDITOR_TARGET) $(BUILD_DIR)/chars $(BUILD_DIR)/*.pdf
WEBRENDER_DIR = tools/webrender
SYNC_WEBRENDER = $(WEBRENDER_DIR)/scripts/sync-webrender.sh
sync-webrender-cfg:
@$(SYNC_WEBRENDER)
serve-webrender: sync-webrender-cfg
@cd $(WEBRENDER_DIR) && python3 -m http.server 8765
webrender: serve-webrender
info:
@echo "Compiler: $(CXX)"
@echo "Flags: $(CXXFLAGS)"
@echo "Libraries: $(LIBS)"
@echo "Sources: $(SOURCES)"
@echo "Objects: $(OBJECTS)"
@echo "Target: $(TARGET)"