-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
137 lines (99 loc) · 2.33 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#Makefile:
#
COMMON_FLAG= -DARM=1 -DMIPS=2
ifeq ($(cpuarch) , arm)
CC=arm-linux-gcc
LD=arm-linux-ld
OBJCOPY=arm-linux-objcopy
CFLAGS= -O2 -g -I$(PRJPATH)/inc $(COMMON_FLAG) -DCPUARCH=ARM
ASFLAGS= -O2 -g -I$(PRJPATH)/inc $(COMMON_FLAG) -DCPUARCH=ARM
LDFLAGS=-Tlotus_works_arm.lds -Ttext 30000000
endif
ifeq ($(cpuarch) , mips)
CC=mips-sde-elf-gcc
LD=mips-sde-elf-ld
OBJCOPY=mips-sde-elf-objcopy
CFLAGS= -O2 -g -I$(PRJPATH)/inc -mips1 $(COMMON_FLAG) -DCPUARCH=MIPS
ASFLAGS= -O2 -g -I$(PRJPATH)/inc -mips1 $(COMMON_FLAG) -DCPUARCH=MIPS
LDFLAGS=-Tlotus_works_mips.lds
endif
export CC
export LD
export OBJCOPY
PRJPATH= $(shell pwd)
OUTPUTPATH= $(PRJPATH)/output
OUTPUTOBJ= $(wildcard output/*.o)
export OUTPUTPATH
export CFLAGS
export ASFLAGS
MODULE=arch int mem std task usr sem uart clk msg ltai
lotus_works: $(MODULE)
$(CC) -static -nostartfiles -nostdlib $(LDFLAGS) $(OUTPUTOBJ) -o $(OUTPUTPATH)/$@ -lgcc
$(OBJCOPY) -O binary $(OUTPUTPATH)/$@ $(OUTPUTPATH)/lotus_works.bin
cp $(OUTPUTPATH)/lotus_works.bin lotus_works.bin
.PHONY: test
test:
@echo $(cpuarch)
@echo $(MODULE)
$(CC) $(CFLAGS) -c setup.S -o setup.o
$(CC) $(CFLAGS) -c boot.c -o boot.o
cp setup.o ./output/setup.o
cp boot.o ./output/boot.o
.PHONY: arch
arch:
make -C $(PRJPATH)/arch/$(cpuarch)
arch_clean:
make -C $(PRJPATH)/arch/$(cpuarch) clean
.PHONY: int
int:
make -C $(PRJPATH)/int
int_clean:
make -C $(PRJPATH)/int clean
.PHONY: mem
mem:
make -C $(PRJPATH)/mem
mem_clean:
make -C $(PRJPATH)/mem clean
.PHONY: std
std:
make -C $(PRJPATH)/std
std_clean:
make -C $(PRJPATH)/std clean
.PHONY: task
task:
make -C $(PRJPATH)/task
task_clean:
make -C $(PRJPATH)/task clean
.PHONY: sem
sem:
make -C $(PRJPATH)/sem
sem_clean:
make -C $(PRJPATH)/sem clean
.PHONY: usr
usr:
make -C $(PRJPATH)/usr
usr_clean:
make -C $(PRJPATH)/usr clean
.PHONY: uart
uart:
make -C $(PRJPATH)/uart
uart_clean:
make -C $(PRJPATH)/uart clean
.PHONY: clk
clk:
make -C $(PRJPATH)/clk
clk_clean:
make -C $(PRJPATH)/clk clean
.PHONY: msg
msg:
make -C $(PRJPATH)/msg
msg_clean:
make -C $(PRJPATH)/msg clean
.PHONY: ltai
ltai:
make -C $(PRJPATH)/ltai
ltai_clean:
make -C $(PRJPATH)/ltai clean
clean: arch_clean int_clean mem_clean std_clean task_clean usr_clean sem_clean uart_clean clk_clean msg_clean ltai_clean
rm -rf $(OUTPUTPATH)/
mkdir $(OUTPUTPATH)/