forked from jserv/amacc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
38 lines (30 loc) · 987 Bytes
/
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
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 ELF.o
$(CROSS_COMPILE)gcc $(CFLAGS) -fsigned-char -o amacc $? -g -ldl
ELF.o: ELF.c
$(CROSS_COMPILE)gcc $(CFLAGS) -fsigned-char -c -o $@ $< -g -ldl
check: $(BIN) $(TEST_OBJ)
@echo "[ compiled ]"
@$(ARM_EXEC) ./amacc tests/hello.c
@echo "[ nested ]"
@$(ARM_EXEC) ./amacc amacc.c tests/hello.c
$(TEST_DIR)/%.o: $(TEST_DIR)/%.c $(BIN)
@echo "[********* test $<******* ]"
@$(ARM_EXEC) ./amacc $< 2
@echo "[********* test $< elf*** ]"
@mkdir -p $(OBJ_DIR)
@$(ARM_EXEC) ./amacc -o $(OBJ_DIR)/$(notdir $(basename $<)) $<
@$(ARM_EXEC) $(OBJ_DIR)/$(notdir $(basename $<)) 2
@/bin/echo -e "$(PASS_COLOR)$< pass$(NO_COLOR)\n"
clean:
$(RM) $(BIN) $(OBJ_DIR)/*