-
Notifications
You must be signed in to change notification settings - Fork 64
Expand file tree
/
Copy pathMakefile
More file actions
executable file
·76 lines (56 loc) · 2.22 KB
/
Copy pathMakefile
File metadata and controls
executable file
·76 lines (56 loc) · 2.22 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
####################################################################################
# How to Use in CSE VLAB
#
# 1. Test all testcases in tests
#
# make
# make compileAll
# make runAll
#
# 2. Test one testcase
#
# make
# make compileOne SCC_SRC_FILE=tests/Factorial.scc
# make runOne SCC_SRC_FILE=tests/Factorial.scc
#
####################################################################################
PROJ_ROOT_PATH = $(shell pwd)
C_SRC_FILES = $(shell find ./src -name "*.c")
H_SRC_FILES = $(shell find ./src -name "*.h")
#ALL_SCC_SRC_FILES = $(shell find ./tests -name "*.scc")
#ALL_SCC_SRC_FILES = ./tests/Factorial.scc ./tests/Stack.scc ./tests/BinaryTree.scc ./tests/EnvVars.scc ./tests/MultipleArguments.scc ./tests/DoWhile.scc ./tests/Associativity.scc ./tests/SystemPython3.scc
ALL_SCC_SRC_FILES = ./tests/Factorial.scc ./tests/Stack.scc ./tests/BinaryTree.scc ./tests/EnvVars.scc ./tests/MultipleArguments.scc ./tests/Associativity.scc ./tests/SystemPython3.scc
SCC_SRC_FILE = tests/Factorial.scc
#OBJS = $(C_SRC:.c=.o)
CC = gcc -g
all:
make scc
scc: $(C_SRC_FILES) $(H_SRC_FILES)
$(CC) -o scc -I $(PROJ_ROOT_PATH)/src $(C_SRC_FILES)
compileOne: scc
./scc < ${SCC_SRC_FILE} > ${SCC_SRC_FILE}.s
@echo "\n\n x86_64 assembly code generated in ${SCC_SRC_FILE}.s\n\n"
runOne: scc
./scc < ${SCC_SRC_FILE} > ${SCC_SRC_FILE}.s
$(CC) -no-pie ${SCC_SRC_FILE}.s libs/SccHeap.c libs/SccLib.c -I ${PROJ_ROOT_PATH}/libs -o ${SCC_SRC_FILE}.exe
${SCC_SRC_FILE}.exe
compileAll: scc
@for testCase in ${ALL_SCC_SRC_FILES}; do \
echo "\n\n...... $$testCase .... \n\n"; \
./scc < $$testCase > $$testCase.s; \
echo " x86_64 assembly code generated in $$testCase.s\n"; \
done
runAll: scc
@for testCase in ${ALL_SCC_SRC_FILES}; do \
echo "\n\n...... $$testCase .... \n\n"; \
./scc < $$testCase > $$testCase.s; \
$(CC) -no-pie $$testCase.s libs/SccHeap.c libs/SccLib.c -I ${PROJ_ROOT_PATH}/libs -o $$testCase.exe; \
$$testCase.exe; \
done
# https://gcc.gnu.org/onlinedocs/gcc-4.9.2/gcc/Preprocessor-Options.html
testHeap:
$(CC) -D USE_OUR_MALLOC_FREE libs/TestSccHeap.c libs/SccHeap.c -I ${PROJ_ROOT_PATH}/libs -o TestSccHeap
./TestSccHeap
clean:
rm -f *.o *.scc.s scc TestSccHeap
make -C tests