//makefile
#this is the MakeFile for my little first kernel
CC=gcc
AS=nasm
LD=ld
GET=co
HEX=-hexcpy
ECHO=@echo
ASFLAGS=-f elf
CFLAGS=-Wall -O -fstrength-reduce -fomit-frame-pointer \
-finline-functions -nostdinc -fno-builtin -I./
LDFLAGS=-T link.ld
SRCS=kernel.c disp.c stdlib.c gdt.c idt.c isrs.c
OBJS=start.o kernel.o disp.o stdlib.o gdt.o idt.o isrs.o
TARG=kernel.bin
FNL=disk.flp
all: kernel.bin
start.o:
$(AS) $(ASFLAGS) boot.asm -o $@
$(SRCS):
$(GET) $@
$(CC) $(CFLAGS) $(SRCS)
$(TARG): $(OBJS)
$(LD) $(LDFLAGS) -o $@ $(OBJS)
$(ECHO) BUILD SUCCESSFUL !!!
clean:
-rm *.o
$(ECHO) FINAL FILE BUILD SUCCESSFUL !!!
////////////////////////////////////////////////////////////////////////////////////////////////////////////
///link.ld
OUTPUT_FORMAT("binary")
ENTRY(start)
phys = 0x00100000;
SECTIONS
{
.text phys : AT(phys) {
code = .;
*(.text)
. = ALIGN(4096);
}
.data : AT(phys + (data - code))
{
data = .;
*(.data)
. = ALIGN(4096);
}
.bss : AT(phys + (bss - code))
{
bss = .;
*(.bss)
. = ALIGN(4096);
}
end = .;
}
本文地址:http://com.8s8s.com/it/it31874.htm