Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
123 lines (97 loc) · 5.61 KB
/
Copy pathMakefile
File metadata and controls
123 lines (97 loc) · 5.61 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
123
# Toolchain and project settings
CXX ?= g++
CXXFLAGS ?= -std=c++23 -O2 -Wall -Wextra -Wpedantic -pipe
PKG_CONFIG ?= pkg-config
VERSION ?= 0.7.4
GTK_PKG ?= gtkmm-4.0
QT_PKG ?= Qt6Core Qt6Gui
# Optional dependency flags (empty if pkg-config is missing)
MAGIC_CFLAGS := $(shell $(PKG_CONFIG) --cflags libmagic 2>/dev/null)
MAGIC_LIBS := $(shell $(PKG_CONFIG) --libs libmagic 2>/dev/null)
EXIV2_CFLAGS := $(shell $(PKG_CONFIG) --cflags exiv2 2>/dev/null)
EXIV2_LIBS := $(shell $(PKG_CONFIG) --libs exiv2 2>/dev/null)
TEXTCAT_CFLAGS := $(shell $(PKG_CONFIG) --cflags libexttextcat 2>/dev/null)
TEXTCAT_LIBS := $(shell $(PKG_CONFIG) --libs libexttextcat 2>/dev/null)
TESSERACT_CFLAGS := $(shell $(PKG_CONFIG) --cflags tesseract 2>/dev/null)
TESSERACT_LIBS := $(shell $(PKG_CONFIG) --libs tesseract 2>/dev/null)
LEPT_CFLAGS := $(shell $(PKG_CONFIG) --cflags lept 2>/dev/null)
LEPT_LIBS := $(shell $(PKG_CONFIG) --libs lept 2>/dev/null)
SQLITE3_LIBS := $(shell $(PKG_CONFIG) --libs sqlite3 2>/dev/null)
SQLITE3_CFLAGS := $(shell $(PKG_CONFIG) --cflags sqlite3 2>/dev/null)
GTK_CFLAGS := $(shell $(PKG_CONFIG) --cflags $(GTK_PKG) 2>/dev/null)
GTK_LIBS := $(shell $(PKG_CONFIG) --libs $(GTK_PKG) 2>/dev/null)
QT_CFLAGS := $(shell $(PKG_CONFIG) --cflags $(QT_PKG) 2>/dev/null)
QT_LIBS := $(shell $(PKG_CONFIG) --libs $(QT_PKG) 2>/dev/null)
RAYLIB_CFLAGS := $(shell $(PKG_CONFIG) --cflags raylib 2>/dev/null)
RAYLIB_LIBS := $(shell $(PKG_CONFIG) --libs raylib 2>/dev/null)
# Fallback for sqlite3 when pkg-config is unavailable
ifeq ($(strip $(SQLITE3_LIBS)),)
SQLITE3_LIBS := -lsqlite3
endif
# Combined flags used across targets
CPPFLAGS += $(MAGIC_CFLAGS) $(EXIV2_CFLAGS) $(TEXTCAT_CFLAGS) $(TESSERACT_CFLAGS) $(LEPT_CFLAGS) $(SQLITE3_CFLAGS) -DAPP_VERSION=\"$(VERSION)\"
LDLIBS += $(MAGIC_LIBS) $(EXIV2_LIBS) $(TEXTCAT_LIBS) $(TESSERACT_LIBS) $(LEPT_LIBS) $(SQLITE3_LIBS) -pthread
# Output paths
BUILD_DIR := build
BINARY := $(BUILD_DIR)/main
DMENU_BIN := $(BUILD_DIR)/dmenuCompatibility
DBINIT_BIN := $(BUILD_DIR)/dbInit
GTK_BIN := $(BUILD_DIR)/clisperGTK
PLASMA_BIN := $(BUILD_DIR)/plasmaClipboardWatcher
RAYLIB_BIN := rayLibMenu
RAYLIB_IMAGE_EDIT_BIN := rayLibMenuImageEdit
# Core sources
MAIN_SRC := src/core/main.cpp
TEXT_MIME_REFINEMENT_SRC := src/core/textMIMErefinement.cpp
MAIN_OBJ := $(BUILD_DIR)/core/main.o
TEXT_MIME_REFINEMENT_OBJ := $(BUILD_DIR)/core/textMIMErefinement.o
CORE_OBJS := $(MAIN_OBJ) $(TEXT_MIME_REFINEMENT_OBJ)
# Standard targets
.PHONY: all clean database gtk plasma raylib raylib-image-edit
all: $(BINARY) $(DMENU_BIN)
# Core CLI build
$(BINARY): $(CORE_OBJS)
@mkdir -p $(dir $@)
$(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS)
$(MAIN_OBJ): src/core/textMIMErefinement.h
$(TEXT_MIME_REFINEMENT_OBJ): src/core/textMIMErefinement.h
$(BUILD_DIR)/core/%.o: src/core/%.cpp
@mkdir -p $(dir $@)
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@
# dmenu compatibility build
$(DMENU_BIN): src/compat/dmenuCompatibility.cpp
@mkdir -p $(dir $@)
$(CXX) $(CXXFLAGS) $(CPPFLAGS) src/compat/dmenuCompatibility.cpp -o $@ $(LDLIBS)
# DB init helper build
$(DBINIT_BIN): src/core/dbInit.cpp
@mkdir -p $(dir $@)
$(CXX) $(CXXFLAGS) $(CPPFLAGS) src/core/dbInit.cpp -o $@ $(LDLIBS)
# GTK frontend build
$(GTK_BIN): src/gui/main.cpp src/gui/clisperGTK.cpp
@mkdir -p $(dir $@)
$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(GTK_CFLAGS) $^ -o $@ $(GTK_LIBS) $(SQLITE3_LIBS)
# Convenience alias for GTK build
gtk: $(GTK_BIN)
# Plasma clipboard watcher build
$(PLASMA_BIN): src/platform/plasmaClipboardWatcher.cpp
@mkdir -p $(dir $@)
$(CXX) $(CXXFLAGS) -fPIC $(QT_CFLAGS) $< -o $@ $(QT_LIBS)
plasma: $(PLASMA_BIN)
# Raylib UI build
$(RAYLIB_BIN): src/compat/rayLibMenu.cpp
$(CXX) $(CXXFLAGS) $(RAYLIB_CFLAGS) $< -o $@ $(RAYLIB_LIBS) $(SQLITE3_LIBS)
raylib: $(RAYLIB_BIN)
$(RAYLIB_IMAGE_EDIT_BIN): src/compat/rayLibMenuImageEdit.cpp
$(CXX) $(CXXFLAGS) $(RAYLIB_CFLAGS) $< -o $@ $(RAYLIB_LIBS) $(SQLITE3_LIBS)
raylib-image-edit: $(RAYLIB_IMAGE_EDIT_BIN)
# Basic smoke test via stdin
test: $(BINARY)
make all
@echo "Where lies the strangling fruit that came from the hand of the sinner I shall bring forth the seeds of the dead to share with the worms that gather in the darkness and surround the world with the power of their lives while from the dimlit halls of other places forms that never were and never could be writhe for the impatience of the few who never saw what could have been. In the black water with the sun shining at midnight, those fruit shall come ripe and in the darkness of that which is golden shall split open to reveal the revelation of the fatal softness in the earth. The shadows of the abyss are like the petals of a monstrous flower that shall blossom within the skull and expand the mind beyond what any man can bear, but whether it decays under the earth or above on green fields, or out to sea or in the very air, all shall come to revelation, and to revel, in the knowledge of the strangling fruit—and the hand of the sinner shall rejoice, for there is no sin in shadow or in light that the seeds of the dead cannot forgive. And there shall be in the planting in the shadows a grace and a mercy from which shall blossom dark flowers, and their teeth shall devour and sustain and herald the passing of an age. That which dies shall still know life in death for all that decays is not forgotten and reanimated it shall walk the world in the bliss of not-knowing. And then there shall be a fire that knows the naming of you, and in the presence of the strangling fruit, its dark flame shall acquire every part of you that remains." | $(BINARY)
# Cleans
clean:
$(RM) $(RAYLIB_BIN) $(RAYLIB_IMAGE_EDIT_BIN)
$(RM) -r $(BUILD_DIR)
# Initialize database
database: $(DBINIT_BIN)
$(DBINIT_BIN)