-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
237 lines (195 loc) · 6.87 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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
CFLAGS = -Wall -std=c99 -O3
CFLAGSDEBUG = -g -Wall -std=c99 -O0
OUTFILE = hac
SOURCES = src/main.c src/lex.c src/grammar.c src/tree.c src/lextest.c src/symbolTable.c src/codeGen.c src/testbfi.c src/compilerFunctions.c src/codeEss.c src/optimizer.c src/expander.c src/highlight.c
OBJS = temp/codeGen.o temp/symbolTable.o temp/grammar.o temp/tree.o temp/main.o temp/lex.o temp/lextest.o temp/testbfi.o temp/compilerFunctions.o temp/codeEss.o temp/optimizer.o temp/expander.o temp/highlight.o
ZIGCC = zig cc
WINCC = x86_64-w64-mingw32-gcc-11.1.0 #old one was i686-w64-mingw32-gcc; changed because false positives
#always compiles when using just make
test/hac: src/main.c src/lex.c src/grammar.c
cc $(CFLAGS) -o hac $(SOURCES)
debug: $(SOURCES)
cc $(CFLAGSDEBUG) -o hac $(SOURCES)
release: $(SOURCES)
cc $(CFLAGS) -o hac $(SOURCES)
bin/hac.exe: $(SOURCES)
$(WINCC) $(CFLAGS) -o bin/hac.exe $(SOURCES)
bin/hac.linux: $(SOURCES)
x86_64-linux-musl-cc -static $(CFLAGS) -o bin/hac.linux $(SOURCES)
bin/hac.js: src/main.c src/lex.c src/grammar.c
emcc -Wall -o bin/hac.js $(SOURCES)
bin/hac.html: src/main.c src/lex.c src/grammar.c
emcc -Wall -o bin/hac.html $(SOURCES)
all: test/hac bfi expander bin/hac bfalgoConverter
install: bin/hac expander bfi bfalgoConverter
@rm -rf $(HOME)/.Headache/
@echo "Installing Headache..."
@./bin/hac --version
@mkdir "$(HOME)/.Headache"
@cp bin/hac "$(HOME)/.Headache/"
@cp bfi "$(HOME)/.Headache/"
@cp expander "$(HOME)/.Headache/"
@cp bfalgoConverter "$(HOME)/.Headache/"
@echo "Please add $(HOME)/.Headache/ to your PATH"
uninstall:
@rm -rf $(HOME)/.Headache/
test: testlexical testsyntax testtree testchecks
bfide-bfi: src/bfide/main.swift src/bfide/BrainfuckInterpreter.swift
swiftc -o bfide-bfi src/bfide/*.swift
bfi: src/testbfi.c
cc $(CFLAGS) -DSTANDALONE src/testbfi.c -o bfi
expander: src/expander.c
cc $(CFLAGS) -DSTANDALONE src/expander.c -o expander
bfalgoConverter: src/bfalgoConverter.c
cc $(CFLAGS) src/bfalgoConverter.c -o bfalgoConverter
bfi.exe: src/testbfi.c
$(WINCC) $(CFLAGS) -DSTANDALONE src/testbfi.c -o bfi.exe
bfi.linux: src/testbfi.c
x86_64-linux-musl-cc $(CFLAGS) -DSTANDALONE src/testbfi.c -o bfi.linux
bfi.js: src/testbfi.c
emcc $(CFLAGS) -DSTANDALONE src/testbfi.c -s FORCE_FILESYSTEM=1 -lnodefs.js -o bfi.js
expander.exe: src/expander.c
$(WINCC) $(CFLAGS) -DSTANDALONE src/expander.c -o expander.exe
expander.linux: src/expander.c
x86_64-linux-musl-cc -static $(CFLAGS) -DSTANDALONE src/expander.c -o expander.linux
bfalgoConverter.exe: src/bfalgoConverter.c
$(WINCC) -static $(CFLAGS) src/bfalgoConverter.c -o bfalgoConverter.exe
bfalgoConverter.linux: src/bfalgoConverter.c
x86_64-linux-musl-cc -static $(CFLAGS) src/bfalgoConverter.c -o bfalgoConverter.linux
windows.zip: bfi.exe expander.exe bfalgoConverter.exe bin/hac.exe
rm -rf zipfolder.zip
rm -f src/*.o
mv bin/hac.exe hac.exe
zip -r zipfolder.zip hac.exe expander.exe bfi.exe bfalgoConverter.exe
mv zipfolder.zip hac-release-windows.zip
linux.zip: bfi.linux expander.linux bfalgoConverter.linux bin/hac.linux
rm -rf zipfolder.zip
rm -f src/*.o
mv bin/hac.linux hac.linux
zip -r zipfolder.zip hac.linux expander.linux bfi.linux bfalgoConverter.linux
mv zipfolder.zip hac-release-linux.zip
testoptimize: hac bfi
sh test/optimize/script.sh
testrunnable: hac bfi
sh test/runnable/script.sh
testbf: bfi
sh test/bf/script.sh
testbfide: bfide-bfi
mv bfi bfi-x
mv bfide-bfi bfi
sh test/bf/script.sh
mv bfi bfide-bfi
mv bfi-x bfi
testbin: hac
sh test/bin/script.sh
testtree: hac
sh test/tree/script.sh
testchecks: hac
sh test/checks/script.sh
testsyntax: hac
sh test/syntax/script.sh
testlexical: hac
sh test/lexical/script.sh
src/grammar.c: src/grammar.y
bison -d src/grammar.y --output src/grammar.c
src/lex.c: src/rules.lex src/grammar.c
flex src/rules.lex
mv lex.yy.c src/lex.c
clean:
rm -f src/lex.c
rm -f src/grammar.c
rm -rf bin
mkdir bin
rm -rf temp
mkdir temp
rm -rf *.dSYM
rm -f test/*/*.output
rm -f va.txt
rm -f val.out
rm -f grammar.output
rm -f *.out
rm -f *.bf
rm -f test/*.out
rm -f test/*.bf
rm -rf *.o
rm -f hac
rm -f bfide-bfi
rm -f bfi
rm -f expander
rm -f bfalgoConverter
rm -f *.exe
rm -f *.linux
#always generate zip
zip:
rm -rf zipfolder
rm -f src/*.o
zip -r zipfolder.zip src test README.txt Makefile
mv zipfolder.zip ../hac.zip
zip-release: all
rm -rf zipfolder
rm -f src/*.o
zip -r zipfolder.zip hac expander bfi bin/hac
mv zipfolder.zip ../hac-release.zip
temp:
mkdir temp
bin:
mkdir bin
bin/hac: src/grammar.c src/lex.c temp bin $(OBJS)
ls temp
cc -o bin/hac temp/*.o -O3
temp/optimizer.o:
cc -o temp/optimizer.o -Wall -O3 -c src/optimizer.c
temp/expander.o:
cc -o temp/expander.o -Wall -O3 -c src/expander.c
temp/testbfi.o:
cc -o temp/testbfi.o -Wall -O3 -c src/testbfi.c
temp/compilerFunctions.o:
cc -o temp/compilerFunctions.o -Wall -O3 -c src/compilerFunctions.c
temp/codeEss.o:
cc -o temp/codeEss.o -Wall -O3 -c src/codeEss.c
temp/lextest.o: src/lextest.c
cc -o temp/lextest.o -Wall -O3 -c src/lextest.c
temp/codeGen.o: src/codeGen.c
cc -o temp/codeGen.o -Wall -O3 -c src/codeGen.c
temp/symbolTable.o: src/symbolTable.c src/compilerFunctions.c
cc -o temp/symbolTable.o -Wall -O3 -c src/symbolTable.c
temp/grammar.o: src/grammar.c
cc -o temp/grammar.o -Wall -O3 -c src/grammar.c
temp/tree.o: src/tree.c
cc -o temp/tree.o -Wall -O3 -c src/tree.c
temp/main.o: src/main.c
cc -o temp/main.o -Wall -O3 -c src/main.c
temp/lex.o: src/lex.c
cc -o temp/lex.o -Wall -O3 -c src/lex.c
temp/highlight.o: src/highlight.c
cc -o temp/highlight.o -Wall -O3 -c src/highlight.c
## LIBS
hac.a: $(OBJS)
ar ruv hac.a temp/*.o
ranlib hac.a
hac.so: $(OBJS)
cc -shared temp/*.o -o hac.s
## ZIG CC EXPERIMENT
zig_windows : bfi_z.exe hac_z.exe expander_z.exe bfalgoConverter_z.exe
bfi_z.exe: src/testbfi.c
$(ZIGCC) $(CFLAGS) -DSTANDALONE src/testbfi.c -o bfi_z.exe -target x86_64-windows-gnu
hac_z.exe: $(SOURCES)
$(ZIGCC) $(CFLAGS) -o hac_z.exe $(SOURCES) -target x86_64-windows-gnu
expander_z.exe: src/expander.c
$(ZIGCC) $(CFLAGS) -DSTANDALONE src/expander.c -o expander_z.exe -target x86_64-windows-gnu
bfalgoConverter_z.exe: src/bfalgoConverter.c
$(ZIGCC) $(CFLAGS) src/bfalgoConverter.c -o bfalgoConverter_z.exe -target x86_64-windows-gnu
hac-release-z-windows.zip: bfi_z.exe hac_z.exe expander_z.exe bfalgoConverter_z.exe
rm -rf zipfolder.zip
rm -f src/*.o
zip -r zipfolder.zip hac_z.exe expander_z.exe bfi_z.exe bfalgoConverter_z.exe
mv zipfolder.zip hac-release-z-windows.zip
zig: hac_z bfi_z expander_z bfalgoConverter_z
bfi_z: src/testbfi.c
$(ZIGCC) $(CFLAGS) -DSTANDALONE src/testbfi.c -o bfi_z -target x86_64-macos-gnu
hac_z: $(SOURCES)
$(ZIGCC) $(CFLAGS) -o hac_z $(SOURCES) -target x86_64-macos-gnu
expander_z: src/expander.c
$(ZIGCC) $(CFLAGS) -DSTANDALONE src/expander.c -o expander_z -target x86_64-macos-gnu
bfalgoConverter_z: src/bfalgoConverter.c
$(ZIGCC) $(CFLAGS) src/bfalgoConverter.c -o bfalgoConverter_z -target x86_64-macos-gnu