-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
47 lines (36 loc) · 901 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
39
40
41
42
43
44
45
46
47
SHELL=/bin/bash
CC = gcc
CCFLAGS = -g -Wno-deprecated-declarations
CLFLAGS = -g -lncurses
SRCDIR=src
OBJDIR=build
OUTDIR=bin
TARGET=riscv_sim
# DO NOT EDIT BELOW
SRCS=$(wildcard ./$(SRCDIR)/*.c) $(wildcard ./$(SRCDIR)/*/*.c)
OBJ_NAMES=$(patsubst %.c,%.o,$(SRCS))
OBJS=$(patsubst ./$(SRCDIR)%,./$(OBJDIR)%,$(OBJ_NAMES))
TARGET_PATH=./$(OUTDIR)/$(TARGET)
.PHONY: build
build: $(TARGET_PATH)
run: $(TARGET_PATH)
@cd bin && ./$(TARGET)
debug: $(TARGET_PATH)
@cd bin && ./$(TARGET) -d
test: $(TARGET_PATH)
@cd tests && ./test.bash
$(TARGET_PATH): $(OBJS)
@echo "Linking..."
@$(CC) -o $(TARGET_PATH) $(OBJS) $(CLFLAGS)
@echo "Binary generated in /bin"
./build/%.o: ./$(SRCDIR)/%.c
@echo "Compiling $<..."
@$(CC) $(CCFLAGS) -c $< -o $@
.PHONY: report
report:
@cd report && ./run.sh
.PHONY: clean
clean:
@echo "Removing Build and Test files..."
-@rm $(OBJS)
-@rm ./$(OUTDIR)/$(TARGET)