-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
202 lines (153 loc) · 4.74 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
#setup
SHADER = slimebox.frag
WIDTH = 2560
HEIGHT = 1440
HIDECURSOR = false
BENCHMARK = false
DEBUG = false
SCISSORS = false
SHADERDIR = shaders
GLVERSION = '\#version 400'
I_X = 'float i_X=$(WIDTH).;'
I_Y = 'float i_Y=$(HEIGHT).;'
VNDH_FLAGS := -DNO_CHEATING #-DNO_UBUNTU_COMPAT -DNO_FILE_MANAGER_COMPAT
AVNDH_FLAGS :=-l -v --vndh vondehi
OBJDIR := obj
BINDIR := bin
RTDIR := rt
SRCDIR := src
GENDIR := gen
TEMPLATES := template
NASM ?= nasm
OBJCOPY ?= objcopy
PYTHON ?= python3
CC = gcc
MINIFY = mono ./tools/shader_minifier.exe -v #--preserve-externals
USELTO = true
ALIGNSTACK = true
SECTIONORDER = td
VSHADER = vshader.vert
ITIMECNT=0
#dlfixup, dnload or default
SMOLLOADER = dnload
COPTFLAGS = -Oz -march=nocona -I gen/
COPTFLAGS += -fno-plt -fno-stack-protector -fno-stack-check -fno-unwind-tables \
-fno-asynchronous-unwind-tables -fomit-frame-pointer -ffast-math -no-pie \
-fno-pic -fno-PIE -ffunction-sections -fdata-sections -fmerge-all-constants \
-funsafe-math-optimizations -malign-data=cacheline -fsingle-precision-constant \
-fwhole-program -fno-exceptions -fvisibility=hidden -nostartfiles -nostdlib\
-mno-fancy-math-387 -mno-ieee-fp -fno-builtin
COPTFLAGS += `pkg-config --cflags-only-I gtk+-3.0` #-mincoming-stack-boundary=3
COPTFLAGS += -DWIDTH=$(WIDTH) -DHEIGHT=$(HEIGHT)
LIBS = -lGL `pkg-config --libs-only-l gtk+-3.0`
SMOLFLAGS = --smolrt "$(PWD)/smol/rt" --smolld "$(PWD)/smol/ld" \
--det -fno-start-arg -fno-ifunc-support --section-order=$(SECTIONORDER)\
-funsafe-dynamic
ifeq ($(HIDECURSOR),true)
COPTFLAGS+=-DHIDECURSOR
endif
ifeq ($(BENCHMARK),true)
COPTFLAGS+=-DBENCHMARK
endif
ifeq ($(SCISSORS),true)
COPTFLAGS+=-DSCISSORS
endif
ifeq ($(USELTO),true)
COPTFLAGS+=-flto
endif
ifeq ($(DEBUG),true)
COPTFLAGS+=-DDEBUG
LIBS+=-lc
endif
ifeq ($(BENCHMARK),true)
LIBS+=-lc
endif
CFLAGS = -std=gnu99 -nodefaultlibs $(COPTFLAGS)
CFLAGS += #-Wall -Wextra #-Wpedantic
ifeq ($(ALIGNSTACK),true)
SMOLFLAGS+=-falign-stack
else
SMOLFLAGS+=-fno-align-stack
endif
ifeq ($(SMOLLOADER),dlfixup)
SMOLFLAGS+= -fuse-$(SMOLLOADER)-loader
endif
ifeq ($(SMOLLOADER),dnload)
SMOLFLAGS+= -fuse-$(SMOLLOADER)-loader -c
endif
$(GENDIR)/shaders.h: $(GENDIR)/ $(TEMPLATES)/$(VSHADER) $(SHADERDIR)/$(SHADER)
cp $(TEMPLATES)/$(VSHADER) $(GENDIR)/vshader.vert
echo $(GLVERSION) > /tmp/shader.frag
echo $(UVLINE)>> /tmp/shader.frag
echo $(I_X) >> /tmp/shader.frag
echo $(I_Y) >> /tmp/shader.frag
cat /tmp/shader.frag $(SHADERDIR)/$(SHADER) > $(GENDIR)/shader.frag
ifeq ($(DEBUG),true)
$(MINIFY) $(GENDIR)/shader.frag --no-renaming --format indented --no-sequence --no-inlining -o $(GENDIR)/min_shader.frag
$(MINIFY) $(GENDIR)/vshader.vert $(GENDIR)/shader.frag -v --no-renaming --no-sequence --no-inlining -o $@
else
$(MINIFY) $(GENDIR)/shader.frag --format indented --move-declarations -o $(GENDIR)/min_shader.frag
$(MINIFY) $(GENDIR)/vshader.vert $(GENDIR)/shader.frag -v --move-declarations -o $@
endif
./tools/replace.py $@
$(BINDIR)/%.vndh: $(GENDIR)/main.lzma
nasm -fbin $(VNDH_FLAGS) -o $(GENDIR)/vondehi vondehi/vondehi.asm
cat $(GENDIR)/vondehi $(GENDIR)/main.lzma > $@
chmod +x $@
clean:
@$(RM) -vrf $(OBJDIR) $(BINDIR) $(GENDIR)
%/:
@mkdir -vp "$@"
.SECONDARY:
$(OBJDIR)/%.o: $(SRCDIR)/%.c $(OBJDIR)/ $(GENDIR)/shaders.h
$(CC) $(CFLAGS) -c "$<" -o "$@"
$(OBJCOPY) $@ --set-section-alignment *=1 -g -x -X -S --strip-unneeded
size $@
$(BINDIR)/%.elf: $(SRCDIR)/%.c $(BINDIR)/ $(GENDIR)/shaders.h
$(CC) $(CFLAGS) $(LIBS) "$<" -o "$@"
strip --strip-unneeded $@
sstrip -z $@
size $@
$(BINDIR)/main.smol: $(OBJDIR)/main.o $(BINDIR)/
$(PYTHON) ./smol/smold.py $(SMOLFLAGS) $(LIBS) $< $@
$(GENDIR)/%.lzma: $(BINDIR)/main.smol
./tools/autovndh.py $(AVNDH_FLAGS) --nostub $< > $@
heatmap: $(GENDIR)/%.lzma
../LZMA-Vizualizer/LzmaSpec $<
@stat --printf="$@: %s bytes\n" $<
rm $<
$(BINDIR)/main.sh: tools/shelldropper.sh $(GENDIR)/main.lzma
cat $^ > $@
chmod +x $@
$(BINDIR)/main.okp: $(BINDIR)/main.smol
cp $< cleanOKP/uncompressed
make -C cleanOKP all
mv cleanOKP/smol.okp $@
wc -c $@
vndh: $(BINDIR)/main.vndh
wc -c $<
okp: $(BINDIR)/main.okp
wc -c $<
sh: $(BINDIR)/main.sh
wc -c $<
smol: bin/main.smol
wc -c $<
elf: $(BINDIR)/main.elf
wc -c $<
delokp:
-rm cleanOKP/onekpaq_context.cache
run: all
bin/main.okp
runsmol: clean $(BINDIR)/main.smol
./tools/analyze.py bin/main.smol
./$(BINDIR)/main.smol
runokp: clean $(BINDIR)/main.okp
./tools/analyze.py bin/main.okp bin/main.smol
./$(BINDIR)/main.okp
runvndh: clean $(BINDIR)/main.vndh
./tools/analyze.py bin/main.vndh bin/main.smol
./$(BINDIR)/main.vndh
all: sh vndh okp #elf
./tools/analyze.py bin/*
purge: clean delokp
.PHONY: all clean