2 VPATH = $(TOP_SRCDIR)/threads:$(TOP_SRCDIR)/devices:$(TOP_SRCDIR)/lib
7 WARNINGS = -Wall -W -Wstrict-prototypes -Wmissing-prototypes
8 CFLAGS = -g -O3 -MMD $(WARNINGS) $(INCLUDES) $(DEFINES)
9 ASFLAGS = $(INCLUDES) $(DEFINES)
12 THREADS_SRC = start.S # Must be first.
13 THREADS_SRC += init.c # Start-up code.
14 THREADS_SRC += thread.c # Thread management core.
15 THREADS_SRC += switch.S # Thread switch routine.
16 THREADS_SRC += interrupt.c # Interrupt core.
17 THREADS_SRC += intr-stubs.S # Interrupt stubs.
18 THREADS_SRC += synch.c # Synchronization.
19 THREADS_SRC += palloc.c # Page allocator.
20 THREADS_SRC += malloc.c # Subpage allocator.
23 DEVICES_SRC = timer.c # Timer device.
24 DEVICES_SRC += kbd.c # Keyboard device.
25 DEVICES_SRC += vga.c # Video device.
26 DEVICES_SRC += serial.c # Serial port device.
29 LIB_SRC = debug.c # Debug helpers.
30 LIB_SRC += lib.c # Standard C library.
31 LIB_SRC += random.c # Pseudo-random numbers.
32 LIB_SRC += list.c # Doubly-linked lists.
33 LIB_SRC += bitmap.c # Bitmaps.
36 OBJECTS = $(patsubst %.c,%.o,$(patsubst %.S,%.o,$(SOURCES)))
40 intr-stubs.S: $(TOP_SRCDIR)/threads/intr-stubs.pl
41 $< > $@.tmp && mv $@.tmp $@
45 ld -T $(TOP_SRCDIR)/threads/kernel.lds -o $@ $^ \
46 `$(CC) -print-libgcc-file-name`
49 objcopy -O binary -R .note -R .comment -S $< $@
51 loader.bin: loader.S kernel.bin
52 gcc -c $< -DKERNEL_LOAD_PAGES=`perl -e 'print int (((-s "kernel.bin") + 4095) / 4096);'`
53 ld -N -e start -Ttext 0x7c00 --oformat binary -o $@ loader.o
55 diskimage.bin: loader.bin kernel.bin
56 cat loader.bin kernel.bin > diskimage.bin
59 rm -f *.o *.d *.bin intr-stubs.S