Initial implementation of timer pool and timer tag
[akaros.git] / kern / Makefrag
1 #
2 # Makefile fragment for ROS kernel.
3 # This is NOT a complete makefile;
4 # you must run GNU make in the top-level directory
5 # where the GNUmakefile is located.
6 #
7
8 OBJDIRS += kern
9 CC=ivycc --deputy
10
11 KERN_LDFLAGS := $(LDFLAGS) -Lobj/ivylib -T kern/kernel.ld -nostdlib
12
13 # entry.S must be first, so that it's the first code in the text segment!!!
14 #
15 # We also snatch the use of a couple handy source files
16 # from the lib directory, to avoid gratuitous code duplication.
17 KERN_SRCFILES :=        kern/entry.S \
18                         kern/smp_entry.S \
19                         kern/init.c \
20                         kern/console.c \
21                         kern/monitor.c \
22                         kern/pmap.c \
23                         kern/env.c \
24                         kern/kclock.c \
25                         kern/picirq.c \
26                         kern/printf.c \
27                         kern/trap.c \
28                         kern/trapentry.S \
29                         kern/sched.c \
30                         kern/syscall.c \
31                         kern/kdebug.c \
32                         kern/apic.c \
33                         kern/testing.c \
34                         kern/atomic.c \
35                         kern/smp.c \
36                         lib/printfmt.c \
37                         lib/readline.c \
38                         lib/string.c \
39                         lib/timer.c
40
41 # Only build files if they exist.
42 KERN_SRCFILES := $(wildcard $(KERN_SRCFILES))
43
44 KERN_BINFILES :=        user/null \
45                                         user/hello \
46                                         user/buggyhello \
47                                         user/evilhello \
48                                         user/testbss \
49                                         user/divzero \
50                                         user/breakpoint \
51                                         user/softint \
52                                         user/badsegment \
53                                         user/faultread \
54                                         user/faultreadkernel \
55                                         user/faultwrite \
56                                         user/faultwritekernel
57
58 KERN_OBJFILES := $(patsubst %.c, $(OBJDIR)/%.o, $(KERN_SRCFILES))
59 KERN_OBJFILES := $(patsubst %.S, $(OBJDIR)/%.o, $(KERN_OBJFILES))
60 KERN_OBJFILES := $(patsubst obj/lib/%, obj/kern/%, $(KERN_OBJFILES))
61
62 KERN_BINFILES := $(patsubst %, $(OBJDIR)/%, $(KERN_BINFILES))
63
64 # How to build kernel object files
65 $(OBJDIR)/kern/%.o: kern/%.c
66         @echo + cc $<
67         @mkdir -p $(@D)
68         $(V)$(CC) -nostdinc $(KERN_CFLAGS) -c -o $@ $<
69
70 $(OBJDIR)/kern/%.o: kern/%.S
71         @echo + as $<
72         @mkdir -p $(@D)
73         $(V)$(CC) -nostdinc $(KERN_CFLAGS) -c -o $@ $<
74
75 $(OBJDIR)/kern/%.o: lib/%.c
76         @echo + cc $<
77         @mkdir -p $(@D)
78         $(V)$(CC) -nostdinc $(KERN_CFLAGS) -c -o $@ $<
79
80 # How to build the kernel itself
81 $(OBJDIR)/kern/kernel: $(KERN_OBJFILES) $(KERN_BINFILES) kern/kernel.ld $(OBJDIR)/ivylib/libivykern.a
82         @echo + ld $@
83         $(V)$(LD) -o $@ $(KERN_LDFLAGS) $(KERN_OBJFILES) -livykern $(GCC_LIB) -b binary $(KERN_BINFILES)
84         $(V)$(OBJDUMP) -S $@ > $@.asm
85         $(V)$(NM) -n $@ > $@.sym
86
87 # How to build the Bochs disk image
88 $(OBJDIR)/kern/bochs.img: $(OBJDIR)/kern/kernel $(OBJDIR)/boot/boot
89         @echo + mk $@
90         $(V)dd if=/dev/zero of=$(OBJDIR)/kern/bochs.img~ count=10000 2>/dev/null
91         $(V)dd if=$(OBJDIR)/boot/boot of=$(OBJDIR)/kern/bochs.img~ conv=notrunc 2>/dev/null
92         $(V)dd if=$(OBJDIR)/kern/kernel of=$(OBJDIR)/kern/bochs.img~ seek=1 conv=notrunc 2>/dev/null
93         $(V)mv $(OBJDIR)/kern/bochs.img~ $(OBJDIR)/kern/bochs.img
94
95 all: $(OBJDIR)/kern/bochs.img
96
97 grub: $(OBJDIR)/jos-grub
98
99 $(OBJDIR)/jos-grub: $(OBJDIR)/kern/kernel
100         @echo + oc $@
101         $(V)$(OBJCOPY) --adjust-vma=0x10000000 $^ $@