-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
86 lines (71 loc) · 2.92 KB
/
Makefile
File metadata and controls
86 lines (71 loc) · 2.92 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
# Makefile — Quick Paint (native + Emscripten)
# Usage:
# make # native build -> ./qpaint
# make run # run native
# make web # emscripten build -> index.html (+ .js/.wasm)
# make serve # simple local web server at http://localhost:8000
# make clean # remove build outputs
# make ENABLE_SCRIPTING=0 # build WITHOUT QuickJS scripting support
# make web ENABLE_SCRIPTING=0 # web build without scripting support
# ---- configuration ----
ENABLE_SCRIPTING ?= 1
# ---- sources / targets ----
SRC := src/main.c src/qpaint.c src/tools.c src/list.c src/scripting.c src/scripting_dialog.c src/clipboard_web.c src/file_web.c src/icon_atlas.c src/font.c src/gradient_tool.c src/color_dialog.c
NATIVE := qpaint
WEB := index.html
# ---- scripting sources (when enabled) ----
SCRIPTING_SRC := src/scripting/quickjs/quickjs.c \
src/scripting/quickjs/cutils.c \
src/scripting/quickjs/dtoa.c \
src/scripting/quickjs/libregexp.c \
src/scripting/quickjs/libunicode.c
# Add scripting sources if enabled
ifeq ($(ENABLE_SCRIPTING),1)
SRC += $(SCRIPTING_SRC)
endif
# ---- native toolchain (SDL2) ----
CC ?= cc
CFLAGS ?= -O2 -Wall -Wextra $(shell sdl2-config --cflags 2>/dev/null) $(shell sdl2-config --cflags SDL2_ttf 2>/dev/null)
LDFLAGS ?= $(shell sdl2-config --libs 2>/dev/null) -lSDL2_ttf -lm
# Scripting-specific flags (suppress warnings from QuickJS)
SCRIPTING_CFLAGS = -Wno-unused-parameter -Wno-sign-compare -Wno-unused-function -DCONFIG_VERSION=\"2025-09-13\" -DENABLE_SCRIPTING
# ---- emscripten toolchain (Web) ----
EMCC ?= emcc
EMFLAGS ?= -O2 \
-s USE_SDL=2 \
-s USE_SDL_TTF=2 \
-s WASM=1 \
-s MIN_WEBGL_VERSION=2 -s MAX_WEBGL_VERSION=2 \
-s ALLOW_MEMORY_GROWTH=1 \
-s ASSERTIONS=0 \
-s EXPORTED_RUNTIME_METHODS=['UTF8ToString','stringToUTF8','lengthBytesUTF8'] \
-s EXPORTED_FUNCTIONS=['_main','_malloc','_free'] \
--shell-file src/shell.html
# Note: we use SDL_SaveBMP in the app; for file downloads you can add:
# -s FORCE_FILESYSTEM=1
# and then implement a JS-side download if needed.
# ---- phony rules ----
.PHONY: all run web serve clean
all: $(NATIVE)
# ---- native build ----
$(NATIVE): $(SRC)
ifeq ($(ENABLE_SCRIPTING),1)
$(CC) $(CFLAGS) $(SCRIPTING_CFLAGS) $(SRC) -o $(NATIVE) $(LDFLAGS)
else
$(CC) $(CFLAGS) $(SRC) -o $(NATIVE) $(LDFLAGS)
endif
run: $(NATIVE)
./$(NATIVE)
# ---- web build (emscripten) ----
web: $(WEB)
$(WEB): $(SRC)
ifeq ($(ENABLE_SCRIPTING),1)
$(EMCC) $(EMFLAGS) $(SCRIPTING_CFLAGS) $(SRC) -o $(WEB)
else
$(EMCC) $(EMFLAGS) $(SRC) -o $(WEB)
endif
# quick local server for testing the web build
serve: web
python3 -m http.server
clean:
rm -f $(NATIVE) $(WEB) index.js index.wasm qpaint.html qpaint.js qpaint.wasm