#
# Copyright (C) 2008 Kevin O'Connor <kevin@koconnor.net>
#
-# This file may be distributed under the terms of the GNU GPLv3 license.
+# This file may be distributed under the terms of the GNU LGPLv3 license.
# Output directory
OUT=out/
# Source files
SRCBOTH=output.c util.c floppy.c ata.c system.c mouse.c kbd.c pci.c \
- serial.c clock.c pic.c cdrom.c ps2port.c
+ serial.c clock.c pic.c cdrom.c ps2port.c smpdetect.c resume.c \
+ pnpbios.c pirtable.c
SRC16=$(SRCBOTH) disk.c apm.c pcibios.c vgahooks.c
SRC32=$(SRCBOTH) post.c shadow.c post_menu.c memmap.c coreboot.c boot.c \
- acpi.c pirtable.c smm.c smpdetect.c mptable.c smbios.c pciinit.c \
- optionroms.c
+ acpi.c smm.c mptable.c smbios.c pciinit.c optionroms.c mtrr.c
TABLESRC=font.c cbt.c floppy_dbt.c
cc-option = $(shell if test -z "`$(1) $(2) -S -o /dev/null -xc \
COMMONCFLAGS = -Wall -Os -MD -m32 -march=i386 -mregparm=3 \
-mpreferred-stack-boundary=2 -mrtd \
-ffreestanding -fwhole-program -fomit-frame-pointer \
- -fno-delete-null-pointer-checks
+ -fno-delete-null-pointer-checks -Wno-strict-aliasing
COMMONCFLAGS += $(call cc-option,$(CC),-nopie,)
COMMONCFLAGS += $(call cc-option,$(CC),-fno-stack-protector,)
COMMONCFLAGS += $(call cc-option,$(CC),-fno-stack-protector-all,)
override CFLAGS = $(COMMONCFLAGS) -g -DMODE16=0
CFLAGS16INC = $(COMMONCFLAGS) -DMODE16=1 -fno-jump-tables -fno-defer-pop \
- $(call cc-option,$(CC),--param large-stack-frame=8,)
+ $(call cc-option,$(CC),--param large-stack-frame=4,)
CFLAGS16 = $(CFLAGS16INC) -g
TABLETMP=$(addprefix $(OUT), $(patsubst %.c,%.16.s,$(TABLESRC)))
$(OUT)%.proc.16.s: $(OUT)%.16.s
- @echo " Moving data sections to text in $<"
- $(Q)sed 's/\t\.section\t\.rodata.*// ; s/\t\.data//' < $< > $@
+ @echo " Moving data sections to text in $@"
+ $(Q)sed 's/^\t\.section\t\.\(ro\)\?data.*// ; s/^\t\.data$$//' < $< > $@
$(OUT)%.16.s: %.c
- @echo " Generating assembler for $<"
+ @echo " Compiling to assembler $@"
$(Q)$(CC) $(CFLAGS16INC) $(DEPHACK) -S -c $< -o $@
$(OUT)%.lds: %.lds.S
- @echo " Precompiling $<"
- $(Q)$(CPP) -P $< -o $@
+ @echo " Precompiling $@"
+ $(Q)$(CPP) -P -D__ASSEMBLY__ $< -o $@
+$(OUT)asm-offsets.h: $(OUT)asm-offsets.16.s
+ @echo " Generating offset file $@"
+ $(Q)./tools/gen-offsets.sh $< $@
-$(OUT)blob.16.s: ; $(call whole-compile, $(CFLAGS16) -S, $(addprefix src/, $(SRC16)),$@)
+$(OUT)ccode.16.s: ; $(call whole-compile, $(CFLAGS16) -S, $(addprefix src/, $(SRC16)),$@)
TABLEASM=$(addprefix $(OUT), $(patsubst %.c,%.proc.16.s,$(TABLESRC)))
-$(OUT)romlayout16.o: romlayout.S $(OUT)blob.16.s $(TABLEASM)
- @echo " Generating 16bit layout of $@"
- $(Q)$(CC) $(CFLAGS16) -c $< -o $@
+$(OUT)romlayout16.o: romlayout.S $(OUT)ccode.16.s $(OUT)asm-offsets.h $(TABLEASM)
+ @echo " Compiling (16bit) $@"
+ $(Q)$(CC) $(CFLAGS16INC) -c -D__ASSEMBLY__ $< -o $@
-$(OUT)romlayout32.o: ; $(call whole-compile, $(CFLAGS), $(addprefix src/, $(SRC32)),$@)
+$(OUT)ccode32.o: ; $(call whole-compile, $(CFLAGS), $(addprefix src/, $(SRC32)),$@)
-$(OUT)rom32.o: $(OUT)romlayout32.o $(OUT)rombios32.lds
+$(OUT)rom32.o: $(OUT)ccode32.o $(OUT)rombios32.lds
@echo " Linking (no relocs) $@"
- $(Q)$(LD) -r -T $(OUT)rombios32.lds $< -o $@
+ $(Q)$(LD) -r -d -T $(OUT)rombios32.lds $< -o $@
$(OUT)rom16.o: $(OUT)romlayout16.o $(OUT)rom32.o $(OUT)rombios16.lds
- @echo " Linking $@"
+ @echo " Linking (16bit) $@"
$(Q)$(OBJCOPY) --prefix-symbols=_code32_ $(OUT)rom32.o $(OUT)rom32.rename.o
$(Q)$(LD) -T $(OUT)rombios16.lds -R $(OUT)rom32.rename.o $< -o $@