kern

view Makefile @ 38:e6f75f91e606

- added makefile pattern to produce assembly output from c source files. - removed a commented out previous version of the gmtime_r function in klibc/time.c
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 10 Jun 2011 23:19:25 +0300
parents 2cbc2b922e49
children 928b0ebfff4d
line source
1 # collect all of our C and assembly source files
2 csrc = $(wildcard src/boot/*.c) $(wildcard src/*.c) $(wildcard src/klibc/*.c)
3 asmsrc = $(wildcard src/boot/*.S) $(wildcard src/*.S) $(wildcard src/klibc/*.S)
4 dep = $(asmsrc:.S=.d) $(csrc:.c=.d)
6 # each source file will generate one object file
7 obj = $(asmsrc:.S=.o) $(csrc:.c=.o)
9 CC = gcc
11 inc = -Isrc -Isrc/klibc -Isrc/boot
13 # -nostdinc instructs the compiler to ignore standard include directories
14 # -m32 instructs the compiler to produce 32bit code (in case we have a 64bit compiler)
15 CFLAGS = -O0 -m32 -Wall -g -nostdinc -fno-builtin $(inc)
16 ASFLAGS = -m32 -g -nostdinc -fno-builtin $(inc)
18 bin = kernel.elf
20 # default target: make an ELF binary by linking the object files
21 # we need to specify where to assume the text section (code) is going
22 # in memory, as well as the kernel entry point (kentry).
23 $(bin): $(obj)
24 ld -melf_i386 -o $@ -Ttext 0x100000 -e kentry $(obj) -Map link.map
26 %.s: %.c
27 $(CC) $(CFLAGS) -S -o $@ $<
29 -include $(dep)
31 %.d: %.c
32 @$(CPP) $(CFLAGS) -MM -MT $(@:.d=.o) $< >$@
34 %.d: %.S
35 @$(CPP) $(ASFLAGS) -MM -MT $(@:.d=.o) $< >$@
37 .PHONY: clean
38 clean:
39 rm -f $(obj) $(bin)
41 .PHONY: cleandep
42 cleandep:
43 rm -f $(dep)