kern

annotate Makefile @ 65:e49fdda97607

changed the makefile to only pass "emulation" (-m32 -melf_i386) only when not running on a i386 system. Also made that work for freebsd too
author John Tsiombikas <nuclear@mutantstargoat.com>
date Wed, 05 Oct 2011 02:34:58 +0300
parents 928b0ebfff4d
children 637efe95d0d1
rev   line source
nuclear@65 1 ifneq ($(shell uname -m), i386)
nuclear@65 2 ccemu = -m32
nuclear@65 3
nuclear@65 4 ifeq ($(shell uname -s), FreeBSD)
nuclear@65 5 ldemu = elf_i386_fbsd
nuclear@65 6 else
nuclear@65 7 ldemu = elf_i386
nuclear@65 8 endif
nuclear@65 9 endif
nuclear@65 10
nuclear@0 11 # collect all of our C and assembly source files
nuclear@10 12 csrc = $(wildcard src/boot/*.c) $(wildcard src/*.c) $(wildcard src/klibc/*.c)
nuclear@10 13 asmsrc = $(wildcard src/boot/*.S) $(wildcard src/*.S) $(wildcard src/klibc/*.S)
nuclear@7 14 dep = $(asmsrc:.S=.d) $(csrc:.c=.d)
nuclear@0 15
nuclear@0 16 # each source file will generate one object file
nuclear@2 17 obj = $(asmsrc:.S=.o) $(csrc:.c=.o)
nuclear@0 18
nuclear@0 19 CC = gcc
nuclear@0 20
nuclear@16 21 inc = -Isrc -Isrc/klibc -Isrc/boot
nuclear@16 22
nuclear@0 23 # -nostdinc instructs the compiler to ignore standard include directories
nuclear@0 24 # -m32 instructs the compiler to produce 32bit code (in case we have a 64bit compiler)
nuclear@65 25 CFLAGS = $(ccemu) -Wall -g -nostdinc -fno-builtin $(inc)
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)