-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
101 lines (86 loc) · 1.96 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
OBJS = \
entry.o\
bio.o\
console.o\
exec.o\
file.o\
fs.o\
ide.o\
kalloc.o\
main.o\
pipe.o\
proc.o\
spinlock.o\
string.o\
swtch.o\
syscall.o\
sysfile.o\
sysproc.o\
timer.o\
scif.o\
vectors.o\
vm.o\
trap.o\
# Cross-compiling (e.g., on Mac OS X)
# TOOLPREFIX = i386-jos-elf-
# Using native tools (e.g., on X86 Linux)
TOOLPREFIX =sh-linux-
CC = $(TOOLPREFIX)gcc
AS = $(TOOLPREFIX)gas
LD = $(TOOLPREFIX)ld
OBJCOPY = $(TOOLPREFIX)objcopy
OBJDUMP = $(TOOLPREFIX)objdump
CFLAGS = -fno-builtin -Wall -MD -ggdb -nostdinc -I. -I$(shell $(CC) -print-file-name=include)
# NOTE: it is important to append -m4-nofpu for SH-4A
#CFLAGS += -m4-nofpu -DDEBUG
#ASFLAGS = -DDEBUG
CFLAGS += -m4-nofpu
ASFLAGS =
# FreeBSD ld wants ``elf_i386_fbsd''
LDFLAGS +=
LIB = $(shell $(CC) -print-libgcc-file-name)
all: bootimg.bin
bootimg.bin: initcode $(OBJS) $(LIB) fs.img
$(OBJCOPY) -I binary fs.img fs_img.o
$(LD) $(LDFLAGS) -T sh4.ld -o bootimg $(OBJS) $(LIB) -b binary initcode fs.img
$(OBJCOPY) -S -O binary bootimg bootimg.bin
initcode: initcode.S
$(CC) $(CFLAGS) -I. -c initcode.S
$(OBJCOPY) -S -O binary initcode.o initcode
tags: $(OBJS)
etags *.S *.c
ULIB = ulib.o usys.o printf.o umalloc.o
_%: %.o $(ULIB) $(LIB)
$(LD) $(LDFLAGS) -N -e main -Ttext 0 -o $@ $^
$(OBJDUMP) -S $@ > $*.asm
$(OBJDUMP) -t $@ | sed '1,/SYMBOL TABLE/d; s/ .* / /; /^$$/d' > $*.sym
_forktest: forktest.o $(ULIB)
# forktest has less library code linked in - needs to be small
# in order to be able to max out the proc table.
$(LD) $(LDFLAGS) -N -e main -Ttext 0 -o _forktest forktest.o ulib.o usys.o
$(OBJDUMP) -S _forktest > forktest.asm
mkfs: mkfs.c fs.h
gcc -m32 -Werror -Wall -o mkfs mkfs.c
UPROGS=\
_cat\
_echo\
_forktest\
_grep\
_init\
_kill\
_ln\
_ls\
_mkdir\
_rm\
_sh\
_stressfs\
_usertests\
_wc\
_zombie\
fs.img: mkfs README $(UPROGS) initcode
./mkfs fs.img README $(UPROGS)
-include *.d
clean:
rm -rf *.o *.d *.asm *.sym \
initcode image linkout fs.img mkfs \
$(UPROGS)