-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathmakefile
More file actions
90 lines (85 loc) · 2.5 KB
/
makefile
File metadata and controls
90 lines (85 loc) · 2.5 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
.PHONY: debug release run prepare
CC = gcc
BUILDDIR = build
OUT = $(BUILDDIR)/WinWidgets
SRC = main.c \
src/filesystem.c \
src/utils.c \
src/parser.c \
src/sysinfo.c \
lib/minimal-json-c-parser/src/json.c
RELEASE = -Werror \
-Wextra \
-Wall
# -------
# Building for Windows platform
# --------
ifeq ($(OS), Windows_NT)
ARGS := -Iinclude \
-Iinclude/windows \
-Ilib/minimal-json-c-parser/include \
-isystem lib/WebView2/build/native/include \
-O3 \
-xc \
-std=c23 \
-mwindows
LDFLAGS := -lole32 \
-loleaut32 \
-luuid \
-lddraw \
-ldxguid \
-ldwmapi \
-lshlwapi \
-Llib/WebView2/build/native/x64 \
-lWebView2Loader \
-static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread -Wl,-Bdynamic
SRC := $(SRC) \
src/windows/widget.c
RESRC = "$(CURDIR)/src/windows/resources.o"
WEBVIEWURL = "https://www.nuget.org/api/v2/package/Microsoft.Web.WebView2"
prepare:
@if not exist "$(CURDIR)/lib/WebView2" ( \
mkdir "$(CURDIR)/lib/WebView2" && \
curl.exe -L -o "$(CURDIR)/lib/WebView2.zip" "$(WEBVIEWURL)" && \
powershell -command "Expand-Archive -Force -Path '$(CURDIR)/lib/WebView2.zip' -DestinationPath '$(CURDIR)/lib/WebView2'" && \
powershell -command "Remove-Item -Force '$(CURDIR)/lib/WebView2.zip'" \
)
windres "$(CURDIR)/src/windows/resources.rc" "$(CURDIR)/src/windows/resources.o"
@if not exist $(BUILDDIR) mkdir $(BUILDDIR)
- robocopy "$(CURDIR)/assets" "$(BUILDDIR)/assets" /E
copy "$(CURDIR)\lib\WebView2\build\native\x64\WebView2Loader.dll" "$(CURDIR)\$(BUILDDIR)\"
clang-format -i "$(CURDIR)/src/*.c" "$(CURDIR)/include/*.h" "$(CURDIR)/main.c"
debug: prepare
$(CC) $(RESRC) $(SRC) $(ARGS) $(LDFLAGS) -o $(OUT)
release: prepare
$(CC) $(RESRC) $(SRC) $(ARGS) $(RELEASE) $(LDFLAGS) -o $(OUT)
run:
./$(OUT)
# -------
# Building for Linux platform
# --------
else ifeq($(UNAME), Linux)
GTKFLAGS = -export-dynamic `pkg-config --cflags --libs gtk+-3.0 appindicator3-0.1 x11 webkit2gtk-4.1`
ARGS := -Iinclude \
-Ilib/minimal-json-c-parser/include \
-O2 \
-xc \
-std=c23 \
-D_POSIX_C_SOURCE=200809L
LDFLAGS = -ldl
SRC := $(SRC) \
src/linux/widget.c
prepare:
rm -rf "$(BUILDDIR)"
mkdir -p "$(BUILDDIR)"
cp -r "$(CURDIR)/assets" "$(BUILDDIR)/assets"
clang-format -i $(CURDIR)/src/*.c \
$(CURDIR)/include/*.h \
$(CURDIR)/main.c
debug: prepare
$(CC) $(SRC) $(ARGS) $(GTKFLAGS) $(LDFLAGS) -o $(OUT)
release: prepare
$(CC) $(SRC) $(ARGS) $(RELEASE) $(GTKFLAGS) $(LDFLAGS) -o $(OUT)
run:
./$(OUT)
endif