kern

annotate Makefile @ 98:921a264297a4

merged the filesystem stuff
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 17 Apr 2014 17:03:30 +0300
parents 637efe95d0d1
children
rev   line source
nuclear@65 1 ifneq ($(shell uname -m), i386)
nuclear@72 2 # -m32 instructs the compiler to produce 32bit code
nuclear@65 3 ccemu = -m32
nuclear@65 4
nuclear@65 5 ifeq ($(shell uname -s), FreeBSD)
nuclear@66 6 ldemu = -m elf_i386_fbsd
nuclear@65 7 else
nuclear@66 8 ldemu = -m elf_i386
nuclear@65 9 endif
nuclear@65 10 endif
nuclear@65 11
nuclear@0 12 # collect all of our C and assembly source files
nuclear@10 13 csrc = $(wildcard src/boot/*.c) $(wildcard src/*.c) $(wildcard src/klibc/*.c)
nuclear@10 14 asmsrc = $(wildcard src/boot/*.S) $(wildcard src/*.S) $(wildcard src/klibc/*.S)
nuclear@7 15 dep = $(asmsrc:.S=.d) $(csrc:.c=.d)
nuclear@0 16
nuclear@0 17 # each source file will generate one object file
nuclear@2 18 obj = $(asmsrc:.S=.o) $(csrc:.c=.o)
nuclear@0 19
nuclear@0 20 CC = gcc
nuclear@0 21
nuclear@72 22 inc = -Isrc -Isrc/klibc -Isrc/boot -Iinclude
nuclear@16 23
nuclear@0 24 # -nostdinc instructs the compiler to ignore standard include directories
nuclear@72 25 CFLAGS = $(ccemu) -Wall -g -nostdinc -fno-builtin $(inc) -DKERNEL
nuclear@65 26 ASFLAGS = $(ccemu) -g -nostdinc -fno-builtin $(inc)
nuclear@0 27
nuclear@0 28 bin = kernel.elf
nuclear@0 29
nuclear@0 30 # default target: make an ELF binary by linking the object files
nuclear@1 31 # we need to specify where to assume the text section (code) is going
nuclear@1 32 # in memory, as well as the kernel entry point (kentry).
nuclear@0 33 $(bin): $(obj)
nuclear@65 34 ld $(ldemu) -o $@ -Ttext 0x100000 -e kentry $(obj) -Map link.map
nuclear@0 35
nuclear@38 36 %.s: %.c
nuclear@38 37 $(CC) $(CFLAGS) -S -o $@ $<
nuclear@38 38
nuclear@7 39 -include $(dep)
nuclear@7 40
nuclear@7 41 %.d: %.c
nuclear@7 42 @$(CPP) $(CFLAGS) -MM -MT $(@:.d=.o) $< >$@
nuclear@7 43
nuclear@7 44 %.d: %.S
nuclear@7 45 @$(CPP) $(ASFLAGS) -MM -MT $(@:.d=.o) $< >$@
nuclear@7 46
nuclear@0 47 .PHONY: clean
nuclear@0 48 clean:
nuclear@0 49 rm -f $(obj) $(bin)
nuclear@7 50
nuclear@7 51 .PHONY: cleandep
nuclear@7 52 cleandep:
nuclear@7 53 rm -f $(dep)