1 | include Makefile.config
|
---|
2 | include arch/$(ARCH)/Makefile.inc
|
---|
3 |
|
---|
4 | sources=src/cpu/cpu.c \
|
---|
5 | src/main/main.c \
|
---|
6 | src/main/kinit.c \
|
---|
7 | src/main/uinit.c \
|
---|
8 | src/proc/scheduler.c \
|
---|
9 | src/proc/thread.c \
|
---|
10 | src/proc/task.c \
|
---|
11 | src/proc/the.c \
|
---|
12 | src/mm/buddy.c \
|
---|
13 | src/mm/heap.c \
|
---|
14 | src/mm/frame.c \
|
---|
15 | src/mm/page.c \
|
---|
16 | src/mm/tlb.c \
|
---|
17 | src/mm/vm.c \
|
---|
18 | src/lib/func.c \
|
---|
19 | src/lib/list.c \
|
---|
20 | src/lib/memstr.c \
|
---|
21 | src/lib/sort.c \
|
---|
22 | src/debug/print.c \
|
---|
23 | src/debug/symtab.c \
|
---|
24 | src/time/clock.c \
|
---|
25 | src/time/timeout.c \
|
---|
26 | src/time/delay.c \
|
---|
27 | src/preempt/preemption.c \
|
---|
28 | src/synch/spinlock.c \
|
---|
29 | src/synch/condvar.c \
|
---|
30 | src/synch/rwlock.c \
|
---|
31 | src/synch/mutex.c \
|
---|
32 | src/synch/semaphore.c \
|
---|
33 | src/synch/waitq.c \
|
---|
34 | src/smp/ipi.c \
|
---|
35 | src/fb/font-8x16.c
|
---|
36 |
|
---|
37 | # CFLAGS options same for all targets
|
---|
38 | CFLAGS+=-nostdinc -Iinclude/ -Werror-implicit-function-declaration -Wmissing-prototypes -Werror
|
---|
39 |
|
---|
40 | ifdef DEBUG_SPINLOCK
|
---|
41 | CFLAGS+=-D$(DEBUG_SPINLOCK)
|
---|
42 | endif
|
---|
43 |
|
---|
44 | ifdef USERSPACE
|
---|
45 | CFLAGS+=-D$(USERSPACE)
|
---|
46 | endif
|
---|
47 |
|
---|
48 | ifdef TEST
|
---|
49 | test_objects:=$(addsuffix .o,$(basename test/$(TEST_DIR)/$(TEST_FILE)))
|
---|
50 | CFLAGS+=-D$(TEST)
|
---|
51 | endif
|
---|
52 | arch_objects:=$(addsuffix .o,$(basename $(arch_sources)))
|
---|
53 | objects:=$(addsuffix .o,$(basename $(sources)))
|
---|
54 |
|
---|
55 | .PHONY : all config depend build clean dist-clean boot
|
---|
56 |
|
---|
57 | all: dist-clean config depend build
|
---|
58 |
|
---|
59 | -include Makefile.depend
|
---|
60 |
|
---|
61 | config:
|
---|
62 | find src/ include/ -name arch -type l -exec rm \{\} \;
|
---|
63 | ln -s ../arch/$(ARCH)/src/ src/arch
|
---|
64 | ln -s ../arch/$(ARCH)/include/ include/arch
|
---|
65 |
|
---|
66 | depend:
|
---|
67 | $(CC) $(CFLAGS) -M $(arch_sources) $(sources) >Makefile.depend
|
---|
68 |
|
---|
69 | build: kernel.bin boot
|
---|
70 |
|
---|
71 | clean:
|
---|
72 | find src/ arch/$(ARCH)/src/ test/ -name '*.o' -exec rm \{\} \;
|
---|
73 | -rm *.bin kernel.map kernel.map.pre kernel.objdump src/debug/real_map.bin
|
---|
74 | $(MAKE) -C arch/$(ARCH)/boot/ clean
|
---|
75 |
|
---|
76 | dist-clean:
|
---|
77 | find src/ include/ -name arch -type l -exec rm \{\} \;
|
---|
78 | -rm Makefile.depend
|
---|
79 | -$(MAKE) clean
|
---|
80 |
|
---|
81 | src/debug/real_map.bin: $(arch_objects) $(objects) $(test_objects) arch/$(ARCH)/_link.ld
|
---|
82 | $(OBJCOPY) -I binary -O $(BFD_NAME) -B $(BFD_ARCH) --prefix-sections=symtab Makefile src/debug/empty_map.o
|
---|
83 | $(LD) -T arch/$(ARCH)/_link.ld $(LFLAGS) $(arch_objects) $(objects) $(test_objects) src/debug/empty_map.o -o $@ -Map kernel.map.pre
|
---|
84 | $(OBJDUMP) -t $(arch_objects) $(objects) $(test_objects) > kernel.objdump
|
---|
85 | tools/genmap.py kernel.map.pre kernel.objdump src/debug/real_map.bin
|
---|
86 |
|
---|
87 | src/debug/real_map.o: src/debug/real_map.bin
|
---|
88 | $(OBJCOPY) -I binary -O $(BFD_NAME) -B $(BFD_ARCH) --prefix-sections=symtab $< $@
|
---|
89 |
|
---|
90 |
|
---|
91 | kernel.bin: $(arch_objects) $(objects) $(test_objects) arch/$(ARCH)/_link.ld src/debug/real_map.o
|
---|
92 | $(LD) -T arch/$(ARCH)/_link.ld $(LFLAGS) $(arch_objects) $(objects) $(test_objects) src/debug/real_map.o -o $@ -Map kernel.map
|
---|
93 |
|
---|
94 | %.o: %.S
|
---|
95 | $(CC) $(ASFLAGS) $(CFLAGS) -c $< -o $@
|
---|
96 |
|
---|
97 | %.o: %.s
|
---|
98 | $(AS) $(ASFLAGS) $< -o $@
|
---|
99 |
|
---|
100 | %.o: %.c
|
---|
101 | $(CC) $(CFLAGS) -c $< -o $@
|
---|
102 |
|
---|
103 | KS=`cat kernel.bin | wc -c`
|
---|
104 |
|
---|
105 | boot:
|
---|
106 | $(MAKE) -C arch/$(ARCH)/boot build KERNEL_SIZE=$(KS)
|
---|