forked from jserv/amacc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
43 lines (35 loc) · 1.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
CROSS_COMPILE ?= arm-linux-gnueabihf-
CFLAGS = -O0 -Wall
OBJ_DIR = elf
TEST_DIR = tests
TEST_SRC = $(wildcard $(TEST_DIR)/*.c)
TEST_OBJ = $(TEST_SRC:.c=.o)
PASS_COLOR = \x1b[32;01m
NO_COLOR = \x1b[0m
BIN = amacc
ARM_EXEC = qemu-arm -L /usr/$(shell echo $(CROSS_COMPILE) | sed s'/.$$//')
all: $(BIN)
amacc: amacc.c
$(CROSS_COMPILE)gcc $(CFLAGS) -fsigned-char -o amacc $? -g -ldl
check: $(BIN) $(TEST_OBJ)
@echo "[ JIT ]"
@$(ARM_EXEC) ./amacc tests/hello.c
@echo "[ compiled ]"
@$(ARM_EXEC) ./amacc -o $(OBJ_DIR)/hello tests/hello.c
@$(ARM_EXEC) $(OBJ_DIR)/hello
@echo "[ nested ]"
@$(ARM_EXEC) ./amacc amacc.c tests/hello.c
$(OBJ_DIR)/amacc: $(BIN)
@$(ARM_EXEC) ./$^ -o $(OBJ_DIR)/amacc amacc.c
$(TEST_DIR)/%.o: $(TEST_DIR)/%.c $(BIN) $(OBJ_DIR)/amacc
@echo "[*** verify $< <JIT>********]"
@$(ARM_EXEC) ./$(BIN) $< 2
@echo "[*** verify $< <ELF>********]"
@mkdir -p $(OBJ_DIR)
@$(ARM_EXEC) ./$(BIN) -o $(OBJ_DIR)/$(notdir $(basename $<)) $<
@$(ARM_EXEC) $(OBJ_DIR)/$(notdir $(basename $<)) 2
@echo "[*** verify $< <ELF-self>***]"
@$(ARM_EXEC) ./$(OBJ_DIR)/amacc $< 2
@/bin/echo -e "$(PASS_COLOR)$< pass$(NO_COLOR)\n"
clean:
$(RM) $(BIN) $(OBJ_DIR)/*