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