-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
78 lines (57 loc) · 1.46 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
ARCH = mips-elf
ADDNAME = $(ARCH)-
AR = $(ADDNAME)ar
AS = $(ADDNAME)as
CC = $(ADDNAME)gcc
LD = $(ADDNAME)ld
NM = $(ADDNAME)nm
OBJCOPY = $(ADDNAME)objcopy
OBJDUMP = $(ADDNAME)objdump
RANLIB = $(ADDNAME)ranlib
STRIP = $(ADDNAME)strip
BIN2HEX = $(ADDNAME)bin2hex
GDB = mipsisa32r2-elf-gdb
RUN = mipsisa32r2-elf-run
OBJS = startup.o main.o interrupt.o vector.o intr.o
OBJS += lib.o
# hardware-dependent sources
OBJS += hardware.o serial.o timer.o sim-io.o
# sources of kozos
OBJS += kozos.o syscall.o memory.o consdrv.o tmrdrv.o command.o
TARGET = kozos
CFLAGS = -Wall -march=m4k -EL -nostdinc -nostdlib -fno-builtin
CFLAGS += -I.
CFLAGS += -G0 #これをしないとエラーが出る
CFLAGS += -Os
CFLAGS += -DKOZOS -DDEBUG
# cflags for GDB sim
CFLAGS += -DSIMULATOR
CFLAGS += -g
LFLAGS = -static -T ld.scr -L.
.SUFFIXES: .c .o
.SUFFIXES: .s .o
.SUFFIXES: .S .o
all : $(TARGET) $(TARGET).hex
$(TARGET) : $(OBJS) Makefile ld.scr
$(CC) $(OBJS) -o $(TARGET) $(CFLAGS) $(LFLAGS)
cp $(TARGET) $(TARGET).elf
$(STRIP) $(TARGET)
.c.o : $<
$(CC) -c $(CFLAGS) $<
.s.o : $<
$(CC) -c $(CFLAGS) $<
.S.o : $<
$(CC) -c $(CFLAGS) $<
$(TARGET).hex : $(TARGET)
$(OBJCOPY) -O ihex $(TARGET) $(TARGET).hex
image : $(TARGET).hex
obj_clean :
rm -f $(OBJS)
clean :
rm -f $(OBJS) $(TARGET) $(TARGET).elf $(TARGET).hex
line :
wc -l *.c *.h *.s *.S ld.scr Makefile
sim : $(TARGET)
$(GDB) $(TARGET).elf
run : $(TARGET)
$(RUN) $(TARGET).elf