Diff markup
001 CC=gcc 001 CC=gcc
002 CFLAGS = -Wall -nostdlib -nostdinc -ffreestan 002 CFLAGS = -Wall -nostdlib -nostdinc -ffreestanding -DKERNEL_SOS
003 LDFLAGS = --warn-common 003 LDFLAGS = --warn-common
004 OBJECTS = bootstrap/multiboot.o 004 OBJECTS = bootstrap/multiboot.o \
005 hwcore/idt.o hwcore/gdt.o 005 hwcore/idt.o hwcore/gdt.o \
006 hwcore/exception.o hwcore/exception_ 006 hwcore/exception.o hwcore/exception_wrappers.o \
007 hwcore/irq.o hwcore/irq_wrappers.o h 007 hwcore/irq.o hwcore/irq_wrappers.o hwcore/i8259.o \
008 hwcore/paging.o 008 hwcore/paging.o \
009 hwcore/i8254.o drivers/x86_videomem. 009 hwcore/i8254.o drivers/x86_videomem.o drivers/bochs.o \
010 hwcore/cpu_context.o hwcore/cpu_cont <<
011 sos/kmem_vmm.o sos/kmem_slab.o sos/k 010 sos/kmem_vmm.o sos/kmem_slab.o sos/kmalloc.o \
012 sos/physmem.o sos/klibc.o !! 011 sos/physmem.o sos/klibc.o sos/main.o
013 sos/assert.o sos/main.o <<
014 012
015 KERNEL_OBJ = sos.elf 013 KERNEL_OBJ = sos.elf
016 MULTIBOOT_IMAGE = fd.img 014 MULTIBOOT_IMAGE = fd.img
017 PWD := $(shell pwd) 015 PWD := $(shell pwd)
018 016
019 017
020 all: $(MULTIBOOT_IMAGE) 018 all: $(MULTIBOOT_IMAGE)
021 019
022 $(MULTIBOOT_IMAGE): $(KERNEL_OBJ) 020 $(MULTIBOOT_IMAGE): $(KERNEL_OBJ)
023 ./support/build_image.sh $@ $< 021 ./support/build_image.sh $@ $<
024 022
025 $(KERNEL_OBJ): $(OBJECTS) ./support/sos.lds 023 $(KERNEL_OBJ): $(OBJECTS) ./support/sos.lds
026 $(LD) $(LDFLAGS) -T ./support/sos.lds 024 $(LD) $(LDFLAGS) -T ./support/sos.lds -o $@ $(OBJECTS)
027 -nm -C $@ | cut -d ' ' -f 1,3 > sos.ma 025 -nm -C $@ | cut -d ' ' -f 1,3 > sos.map
028 size $@ <<
029 026
030 -include .mkvars 027 -include .mkvars
031 028
032 # Create objects from C source code 029 # Create objects from C source code
033 %.o: %.c 030 %.o: %.c
034 $(CC) -I$(PWD) -c $< $(CFLAGS) -o $@ 031 $(CC) -I$(PWD) -c $< $(CFLAGS) -o $@
035 032
036 033
037 %.o: %.S 034 %.o: %.S
038 $(CC) -I$(PWD) -c $< $(CFLAGS) -DASM_S 035 $(CC) -I$(PWD) -c $< $(CFLAGS) -DASM_SOURCE=1 -o $@
039 036
040 037
041 clean: 038 clean:
042 $(RM) *.img *.o mtoolsrc *~ menu.txt * 039 $(RM) *.img *.o mtoolsrc *~ menu.txt *.img *.elf *.bin *.map
043 $(RM) *.log *.out bochs* 040 $(RM) *.log *.out bochs*
044 $(RM) bootstrap/*.o bootstrap/*~ 041 $(RM) bootstrap/*.o bootstrap/*~
045 $(RM) drivers/*.o drivers/*~ 042 $(RM) drivers/*.o drivers/*~
046 $(RM) hwcore/*.o hwcore/*~ 043 $(RM) hwcore/*.o hwcore/*~
047 $(RM) sos/*.o sos/*~ 044 $(RM) sos/*.o sos/*~
048 $(RM) support/*~ 045 $(RM) support/*~
049 $(RM) extra/*~ 046 $(RM) extra/*~