kern

view Makefile @ 66:637efe95d0d1

ops, forgot the -m in -m elf_i386 ld arg
author John Tsiombikas <nuclear@mutantstargoat.com>
date Thu, 06 Oct 2011 04:28:21 +0300
parents e49fdda97607
children 3941e82b07f2
line source
1 ifneq ($(shell uname -m), i386)
2 ccemu = -m32
4 ifeq ($(shell uname -s), FreeBSD)
5 ldemu = -m elf_i386_fbsd
6 else
7 ldemu = -m elf_i386
8 endif
9 endif
11 # collect all of our C and assembly source files
12 csrc = $(wildcard src/boot/*.c) $(wildcard src/*.c) $(wildcard src/klibc/*.c)
13 asmsrc = $(wildcard src/boot/*.S) $(wildcard src/*.S) $(wildcard src/klibc/*.S)
14 dep = $(asmsrc:.S=.d) $(csrc:.c=.d)
16 # each source file will generate one object file
17 obj = $(asmsrc:.S=.o) $(csrc:.c=.o)
19 CC = gcc
21 inc = -Isrc -Isrc/klibc -Isrc/boot
23 # -nostdinc instructs the compiler to ignore standard include directories
24 # -m32 instructs the compiler to produce 32bit code (in case we have a 64bit compiler)
25 CFLAGS = $(ccemu) -Wall -g -nostdinc -fno-builtin $(inc)
26 ASFLAGS = $(ccemu) -g -nostdinc -fno-builtin $(inc)
28 bin = kernel.elf
30 # default target: make an ELF binary by linking the object files
31 # we need to specify where to assume the text section (code) is going
32 # in memory, as well as the kernel entry point (kentry).
33 $(bin): $(obj)
34 ld $(ldemu) -o $@ -Ttext 0x100000 -e kentry $(obj) -Map link.map
36 %.s: %.c
37 $(CC) $(CFLAGS) -S -o $@ $<
39 -include $(dep)
41 %.d: %.c
42 @$(CPP) $(CFLAGS) -MM -MT $(@:.d=.o) $< >$@
44 %.d: %.S
45 @$(CPP) $(ASFLAGS) -MM -MT $(@:.d=.o) $< >$@
47 .PHONY: clean
48 clean:
49 rm -f $(obj) $(bin)
51 .PHONY: cleandep
52 cleandep:
53 rm -f $(dep)