Diff markup
001 001
002 002
003 003
004 004
005 005
006 006
007 007
008 008
009 009
010 010
011 011
012 012
013 013
014 014
015 015
016 016
017 017
018 CC=gcc 018 CC=gcc
019 LD=ld 019 LD=ld
020 CP=cp !! 020 CFLAGS = -Wall -nostdinc -ffreestanding -DKERNEL_SOS
021 STRIP=strip !! 021 LIBGCC := $(shell $(CC) -print-libgcc-file-name)
022 CFLAGS = -Wall -nostdinc -ffreestanding -DKER <<
023 LIBGCC = $(shell $(CC) -print-libgcc-file-nam <<
024 LDFLAGS = --warn-common -nostdlib 022 LDFLAGS = --warn-common -nostdlib
025 OBJECTS = bootstrap/multiboot.o !! 023 OBJECTS = bootstrap/multiboot.o \
026 hwcore/idt.o hwcore/gdt.o !! 024 hwcore/idt.o hwcore/gdt.o \
027 hwcore/swintr.o hwcore/swintr_wrappe !! 025 hwcore/swintr.o hwcore/swintr_wrappers.o \
028 hwcore/exception.o hwcore/exception_ !! 026 hwcore/exception.o hwcore/exception_wrappers.o \
029 hwcore/irq.o hwcore/irq_wrappers.o h !! 027 hwcore/irq.o hwcore/irq_wrappers.o hwcore/i8259.o \
030 hwcore/paging.o hwcore/i8254.o !! 028 hwcore/paging.o \
031 hwcore/cpu_context.o hwcore/cpu_cont !! 029 hwcore/i8254.o drivers/x86_videomem.o drivers/bochs.o \
032 hwcore/mm_context.o !! 030 hwcore/cpu_context.o hwcore/cpu_context_switch.o \
033 sos/kmem_vmm.o sos/kmem_slab.o sos/k !! 031 hwcore/mm_context.o \
034 sos/physmem.o sos/klibc.o !! 032 sos/kmem_vmm.o sos/kmem_slab.o sos/kmalloc.o \
035 sos/thread.o sos/kwaitq.o !! 033 sos/physmem.o sos/klibc.o \
036 sos/time.o sos/sched.o sos/ksynch.o !! 034 sos/thread.o sos/kwaitq.o \
037 sos/process.o sos/syscall.o !! 035 sos/time.o sos/sched.o sos/ksynch.o \
038 sos/assert.o sos/main.o sos/mouse_si !! 036 sos/process.o sos/syscall.o \
039 sos/uaccess.o sos/calcload.o !! 037 sos/assert.o sos/main.o sos/mouse_sim.o \
040 sos/umem_vmm.o sos/binfmt_elf32.o !! 038 sos/uaccess.o sos/calcload.o \
041 drivers/x86_videomem.o drivers/bochs !! 039 sos/umem_vmm.o sos/binfmt_elf32.o \
042 drivers/zero.o drivers/mem.o !! 040 drivers/zero.o drivers/mem.o \
043 drivers/ide.o drivers/kbd.o drivers/ <<
044 drivers/serial.o drivers/tty.o drive <<
045 drivers/console.o <<
046 sos/hash.o sos/fs.o sos/fs_nscache.o <<
047 drivers/fs_virtfs.o sos/chardev.o so <<
048 sos/blkcache.o sos/fs_pagecache.o <<
049 userland/userprogs.kimg 041 userland/userprogs.kimg
050 042
051 KERNEL_OBJ = sos.elf 043 KERNEL_OBJ = sos.elf
052 KERNEL_LOAD = sos.gz <<
053 MULTIBOOT_IMAGE = fd.img 044 MULTIBOOT_IMAGE = fd.img
054 PWD := $(shell pwd | sed 's/"/\\\"/g;s/\$$/\\\ !! 045 PWD := $(shell pwd)
055 046
056 047
057 all: $(MULTIBOOT_IMAGE) 048 all: $(MULTIBOOT_IMAGE)
058 049
059 $(MULTIBOOT_IMAGE): $(KERNEL_LOAD) !! 050 $(MULTIBOOT_IMAGE): $(KERNEL_OBJ)
060 ./support/build_image.sh $@ $< 051 ./support/build_image.sh $@ $<
061 052
062 $(KERNEL_LOAD): $(KERNEL_OBJ) <<
063 $(CP) $< $<.strip && $(STRIP) -sx -R . <<
064 gzip < $<.strip > $@ <<
065 <<
066 $(KERNEL_OBJ): $(OBJECTS) ./support/sos.lds 053 $(KERNEL_OBJ): $(OBJECTS) ./support/sos.lds
067 $(LD) $(LDFLAGS) -T ./support/sos.lds 054 $(LD) $(LDFLAGS) -T ./support/sos.lds -o $@ $(OBJECTS) $(LIBGCC)
068 -nm -C $@ | cut -d ' ' -f 1,3 > sos.ma 055 -nm -C $@ | cut -d ' ' -f 1,3 > sos.map
069 size $@ 056 size $@
070 057
071 -include .mkvars 058 -include .mkvars
072 059
073 # Create the userland programs to include in t 060 # Create the userland programs to include in the kernel image
074 userland/userprogs.kimg: FORCE 061 userland/userprogs.kimg: FORCE
075 $(MAKE) -C userland 062 $(MAKE) -C userland
076 063
077 064
078 %.o: %.c 065 %.o: %.c
079 $(CC) "-I$(PWD)" -c "$<" $(CFLAGS) -o !! 066 $(CC) -I$(PWD) -c $< $(CFLAGS) -o $@
080 067
081 068
082 %.o: %.S 069 %.o: %.S
083 $(CC) "-I$(PWD)" -c "$<" $(CFLAGS) -DA !! 070 $(CC) -I$(PWD) -c $< $(CFLAGS) -DASM_SOURCE=1 -o $@
084 071
085 FORCE: 072 FORCE:
086 @ 073 @
087 074
088 075
089 clean: 076 clean:
090 $(RM) fd*.img *.o mtoolsrc *~ menu.txt !! 077 $(RM) *.img *.o mtoolsrc *~ menu.txt *.img *.elf *.bin *.map
091 $(RM) *.log *.out bochs* sos.gz !! 078 $(RM) *.log *.out bochs*
092 $(RM) bootstrap/*.o bootstrap/*~ 079 $(RM) bootstrap/*.o bootstrap/*~
093 $(RM) drivers/*.o drivers/*~ 080 $(RM) drivers/*.o drivers/*~
094 $(RM) hwcore/*.o hwcore/*~ 081 $(RM) hwcore/*.o hwcore/*~
095 $(RM) sos/*.o sos/*~ 082 $(RM) sos/*.o sos/*~
096 $(RM) support/*~ 083 $(RM) support/*~
097 $(RM) extra/*~ 084 $(RM) extra/*~
098 $(MAKE) -C extra clean <<
099 $(MAKE) -C userland clean 085 $(MAKE) -C userland clean