-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
106 lines (71 loc) · 2.77 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
#############################
##############ZeOS #############
################################
########## Makefile ############
################################
# package dev86 is required
AS86 = as86 -0 -a
LD86 = ld86 -0
HOSTCFLAGS = -Wall -Wstrict-prototypes -g
HOSTCC = gcc
CC = gcc -m32
AS = as --32
LD = ld -melf_i386
OBJCOPY = objcopy -O binary -R .note -R .comment -S
INCLUDEDIR = include
# Define here flags to compile the tests if needed
JP =
CFLAGS = -O2 -g $(JP) -fno-omit-frame-pointer -ffreestanding -Wall -I$(INCLUDEDIR)
ASMFLAGS = -I$(INCLUDEDIR)
SYSLDFLAGS = -T system.lds
USRLDFLAGS = -T user.lds
LINKFLAGS = -g
SYSOBJ = interrupt.o entry.o sys_call_table.o io.o sched.o sys.o mm.o devices.o utils.o hardware.o list.o cbuffer.o
LIBZEOS = -L . -l zeos
#add to USROBJ the object files required to complete the user program
USROBJ = libc.o wrappers.o
all:zeos.bin
zeos.bin: bootsect system build user
$(OBJCOPY) system system.out
$(OBJCOPY) user user.out
./build bootsect system.out user.out > zeos.bin
build: build.c
$(HOSTCC) $(HOSTCFLAGS) -o $@ $<
bootsect: bootsect.o
$(LD86) -s -o $@ $<
bootsect.o: bootsect.s
$(AS86) -o $@ $<
bootsect.s: bootsect.S Makefile
$(CPP) $(ASMFLAGS) -traditional $< -o $@
entry.s: entry.S $(INCLUDEDIR)/asm.h $(INCLUDEDIR)/segment.h
$(CPP) $(ASMFLAGS) -o $@ $<
wrappers.s: wrappers.S $(INCLUDEDIR)/asm.h $(INCLUDEDIR)/segment.h
$(CPP) $(ASMFLAGS) -o $@ $<
sys_call_table.s: sys_call_table.S $(INCLUDEDIR)/asm.h $(INCLUDEDIR)/segment.h
$(CPP) $(ASMFLAGS) -o $@ $<
user.o:user.c $(INCLUDEDIR)/libc.h
interrupt.o:interrupt.c $(INCLUDEDIR)/interrupt.h $(INCLUDEDIR)/segment.h $(INCLUDEDIR)/types.h
io.o:io.c $(INCLUDEDIR)/io.h
sched.o:sched.c $(INCLUDEDIR)/sched.h
libc.o:libc.c $(INCLUDEDIR)/libc.h
mm.o:mm.c $(INCLUDEDIR)/types.h $(INCLUDEDIR)/mm.h
sys.o:sys.c $(INCLUDEDIR)/devices.h
utils.o:utils.c $(INCLUDEDIR)/utils.h
cbuffer.o:cbuffer.c $(INCLUDEDIR)/cbuffer.h
system.o:system.c $(INCLUDEDIR)/hardware.h system.lds $(SYSOBJ) $(INCLUDEDIR)/segment.h $(INCLUDEDIR)/types.h $(INCLUDEDIR)/interrupt.h $(INCLUDEDIR)/system.h $(INCLUDEDIR)/sched.h $(INCLUDEDIR)/mm.h $(INCLUDEDIR)/io.h $(INCLUDEDIR)/mm_address.h
system: system.o system.lds $(SYSOBJ)
$(LD) $(LINKFLAGS) $(SYSLDFLAGS) -o $@ $< $(SYSOBJ) $(LIBZEOS)
user: user.o user.lds $(USROBJ)
$(LD) $(LINKFLAGS) $(USRLDFLAGS) -o $@ $< $(USROBJ)
clean:
rm -f *.o *.s bochsout.txt parport.out system.out system bootsect zeos.bin user user.out *~ build
disk: zeos.bin
dd if=zeos.bin of=/dev/fd0
emul: zeos.bin
bochs -q -f .bochsrc
gdb: zeos.bin
bochs -q -f .bochsrc_gdb &
./generate_gdbcmd_file.sh
gdb -x .gdbcmd system
emuldbg: zeos.bin
bochs_nogdb -q -f .bochsrc