-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
41 lines (32 loc) · 1.77 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
COPTION=--pedantic -std=c11 -g -I ./include -static
INCLUDEOBJ=./include/common.h ./include/tokenize.h ./include/parse.h ./include/codegen.h
CODE='int main(void){ int x; x=5; return x; }'
CODE='int main(void){ int x; x=0; x++; return x; }'
CODE='int main(void){ return "Hello"; }'
CODE='int main(void){ return "Hello"; }'
CODE='int foo(void){ return 5;} int main(void){return "Hello"; }'
CODE='int foo(void){ return 5;} int main(void){return foo(); }'
CODE='int main(void){ printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n******************************** start program ********************************\nHello World.\nThank you for running my App.\nThis App is compiled by 2kmcc compiler made by Ms.hsjoihs.\n2kmcc App is compiled my creating compiler.\nYou can compile using 2kmcc compiled by my creating compiler and exexute,\nwhen you input `make 2kmcc \"CODE=\\\"<your program>\\\"\"`\n\n\n\n\n\nstatus code = "); return 5; }'
9cc: main.o tokenize.o parse.o codegen.o
# gcc -std=c11 -g -static -o 9cc main.o tokenize.o parse.o codegen.o
gcc codegen.o main.o parse.o tokenize.o -o 9cc
main.o: ./src/main.c $(INCLUDEOBJ)
cc $(COPTION) -c -o main.o ./src/main.c
tokenize.o: ./src/tokenize.c $(INCLUDEOBJ)
cc $(COPTION) -c -o tokenize.o ./src/tokenize.c
parse.o: ./src/parse.c $(INCLUDEOBJ)
cc $(COPTION) -c -o parse.o ./src/parse.c
codegen.o: ./src/codegen.c $(INCLUDEOBJ)
cc $(COPTION) -c -o codegen.o ./src/codegen.c
test: test.c
gcc test.c -o test
debug: 9cc test
DEBUG=1 ./test $(FN)
2kmcc: 9cc test
DEBUG=1 ./test "2kmcc_1.c"
./tmp $(CODE) > tmp_2kmcc.s
cc -static tmp_2kmcc.s -o code_2kmcc
./code_2kmcc || echo $$?
clean:
rm -f 9cc test *.o *~ tmp* code_2kmcc
.PHONY: alltest clean debug