-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
114 lines (74 loc) · 1.86 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
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# ********* global
# Project to compile (use a preprocessor definition)
#PROJECT_TO_COMPILE = TEST_ALLOC
#PROJECT_TO_COMPILE = TEST_FILESYSTEM
#PROJECT_TO_COMPILE = TEST_COMMANDS
PROJECT_TO_COMPILE = SHELL
TRACES = # -D TRACE_ALLOC -D PRINT_STACK
MIPS_TOOLS_BIN=/opt/mips-tools-cep/bin
# ******** MIPS
# MIPS | QEMU
ENV = QEMU
# if ENV == QEMU, opts = {ENV_Q_GRAPHICS, ENV_Q_NO_GRAPHICS}
ENV_OPTS = ENV_Q_NO_GRAPHICS
QEMU_OPTS = -nographic
AS = $(MIPS_TOOLS_BIN)/mips-elf-gcc
ASFLAGS = -c -Os
CC = $(MIPS_TOOLS_BIN)/mips-elf-gcc
CFLAGS = -Wall -Wextra -std=c99 -D $(PROJECT_TO_COMPILE) -D $(ENV) -D $(ENV_OPTS)
LD = $(MIPS_TOOLS_BIN)/mips-elf-gcc
LDFLAGS = -T cep.ld
aaOBJS=shell.o alloc.o commands.o filesystem.o simu_mips.o
.PHONY: all
all: mips pc
.PHONY: mips
mips: os_mips
%.o: %.s
$(AS) $(ASFLAGS) -o $@ $<
.PHONY: clean_mips
clean_mips:
$(RM) os_mips $(aaOBJS)
os_mips : $(aaOBJS)
$(CC) $(LDFLAGS) -o $@ $^
.PHONY: run_mips
run_mips: os_mips
"$(MIPS_TOOLS_BIN)/qemu-system-mips" -M mipscep $(QEMU_OPTS) -show-cursor --kernel os_mips
# ************ PC
# Executable name
EXE = os_pc
# Directories
SRC_DIR = .
OBJ_DIR = obj_pc
# Compiler
mmCC = gcc
# Compiler options
mmCDEBUG = -g
mmCOPTIMIZE = # -Os
mmCFLAGS = -D $(PROJECT_TO_COMPILE) $(TRACES) $(LIBC) -D PC -std=c99 $(CDEBUG) $(COPTIMIZE) -W -Wall -Wextra # -Werror
# Linker options
mmLDFLAGS = -rdynamic
# ----
SRC = $(wildcard $(SRC_DIR)/[^N]*.c)
mmOBJS = $(SRC:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.o)
.PHONY: debug
debug:
echo $(SRC) ; \
echo "$$PATH"
.PHONY: pc
pc: $(EXE)
$(EXE): $(mmOBJS)
$(mmCC) $(mmLDFLAGS) -o $@ $^
# Create obj directory if needed
$(OBJ_DIR):
mkdir -p $(OBJ_DIR)
$(OBJ_DIR)/%.o : $(SRC_DIR)/%.c | $(OBJ_DIR)
$(mmCC) $(mmCFLAGS) -o $@ -c $<
.PHONY: clean_pc
clean_pc:
@rm $(mmOBJS)
.PHONY: run_pc
run_pc: $(EXE)
./$(EXE)
# ****
.PHONY:clean
clean: clean_pc clean_mips