forked from edubart/sokol_gp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
104 lines (94 loc) · 2.15 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
CFLAGS=-std=c99
CFLAGS+=-Wall -Wextra -Wshadow -Wno-unused-function
DEFS=
CC=gcc
INCS=-I. -Ithirdparty -Ishaders
OUTDIR=build
OUTEXT=
SHDC=sokol-shdc
SHDCFLAGS=--format sokol_impl --slang glsl330:glsl100:glsl300es:hlsl4:metal_macos:wgpu
SAMPLES=\
sample-rectangle\
sample-primitives\
sample-blend\
sample-framebuffer\
sample-bench\
sample-sdf\
sample-effect
SHADERS=\
shaders/sample-effect.glsl.h\
shaders/sample-sdf.glsl.h\
shaders/sokol_gp.glsl.h
# platform
ifndef platform
platform=linux
endif
ifeq ($(platform), windows)
CC=x86_64-w64-mingw32-gcc
LIBS+=-lkernel32 -luser32 -lshell32 -lgdi32 -ld3d11 -ldxgi
OUTEXT=.exe
else ifeq ($(platform), linux)
DEFS+=-D_GNU_SOURCE
CFLAGS+=-pthread
LIBS+=-lX11 -lXi -lXcursor -lGL -ldl -lm
else ifeq ($(platform), macos)
LIBS+=-framework Cocoa -framework QuartzCore -framework Metal -framework MetalKit
CFLAGS+=-ObjC -x objective-c
else ifeq ($(platform), web)
LIBS+=-sUSE_WEBGL2=1
CC=emcc
OUTEXT=.html
CFLAGS+=--shell-file=samples/sample-shell.html --embed-file images
endif
# build type
ifndef build
build=debug
endif
ifeq ($(platform), web)
ifeq ($(build), debug)
CFLAGS+=-O1 -fno-inline -g
else
CFLAGS+=-Oz -g0 -flto
CFLAGS+=-Wl,--strip-all,--gc-sections,--lto-O3
endif
else ifeq ($(build), debug)
CFLAGS+=-Og -g
else ifeq ($(build), release)
CFLAGS+=-O3 -g -ffast-math -fno-plt -flto
DEFS+=-DNDEBUG
endif
# backend
ifndef backend
ifeq ($(platform), windows)
backend=d3d11
else ifeq ($(platform), macos)
backend=metal
else ifeq ($(platform), web)
backend=gles3
else
backend=glcore33
endif
endif
ifeq ($(backend), glcore33)
DEFS+=-DSOKOL_GLCORE33
else ifeq ($(backend), gles2)
DEFS+=-DSOKOL_GLES2
else ifeq ($(backend), gles3)
DEFS+=-DSOKOL_GLES3
else ifeq ($(backend), d3d11)
DEFS+=-DSOKOL_D3D11
else ifeq ($(backend), metal)
DEFS+=-DSOKOL_METAL
else ifeq ($(backend), dummy)
DEFS+=-DSOKOL_DUMMY_BACKEND
endif
.PHONY: all clean shaders
all: $(SAMPLES)
shaders: $(SHADERS)
clean:
rm -rf $(OUTDIR)
$(SAMPLES): %:
@mkdir -p $(OUTDIR)
$(CC) -o $(OUTDIR)/$@$(OUTEXT) samples/[email protected] $(INCS) $(DEFS) $(CFLAGS) $(LIBS)
shaders/%.glsl.h: shaders/%.glsl
$(SHDC) $(SHDCFLAGS) -i $^ -o $@