Annotation of qemu/roms/seabios/Makefile, revision 1.1.1.2

1.1       root        1: # SeaBIOS build system
                      2: #
                      3: # Copyright (C) 2008,2009  Kevin O'Connor <[email protected]>
                      4: #
                      5: # This file may be distributed under the terms of the GNU LGPLv3 license.
                      6: 
                      7: # Program version
1.1.1.2 ! root        8: VERSION=0.5.1-$(shell date +"%Y%m%d_%H%M%S")-$(shell hostname)
1.1       root        9: 
                     10: # Output directory
                     11: OUT=out/
                     12: 
                     13: # Source files
                     14: SRCBOTH=misc.c pmm.c stacks.c output.c util.c block.c floppy.c ata.c mouse.c \
                     15:         kbd.c pci.c serial.c clock.c pic.c cdrom.c ps2port.c smp.c resume.c \
1.1.1.2 ! root       16:         pnpbios.c pirtable.c vgahooks.c ramdisk.c pcibios.c \
1.1       root       17:         usb.c usb-uhci.c usb-ohci.c usb-hid.c paravirt.c
1.1.1.2 ! root       18: SRC16=$(SRCBOTH) system.c disk.c apm.c font.c
        !            19: SRC32FLAT=$(SRCBOTH) post.c shadow.c memmap.c coreboot.c boot.c \
1.1       root       20:       acpi.c smm.c mptable.c smbios.c pciinit.c optionroms.c mtrr.c \
                     21:       lzmadecode.c
1.1.1.2 ! root       22: SRC32SEG=util.c output.c pci.c pcibios.c apm.c
1.1       root       23: 
                     24: cc-option = $(shell if test -z "`$(1) $(2) -S -o /dev/null -xc \
                     25:               /dev/null 2>&1`"; then echo "$(2)"; else echo "$(3)"; fi ;)
                     26: 
                     27: # Default compiler flags
1.1.1.2 ! root       28: COMMONCFLAGS = -Os -MD -Wall -Wno-strict-aliasing -Wold-style-definition \
        !            29:                $(call cc-option,$(CC),-Wtype-limits,) \
        !            30:                -m32 -march=i386 -mregparm=3 -mpreferred-stack-boundary=2 \
        !            31:                -mrtd -minline-all-stringops \
        !            32:                -freg-struct-return -ffreestanding -fomit-frame-pointer \
        !            33:                -fno-delete-null-pointer-checks \
        !            34:                -ffunction-sections -fdata-sections -fno-common
1.1       root       35: COMMONCFLAGS += $(call cc-option,$(CC),-nopie,)
                     36: COMMONCFLAGS += $(call cc-option,$(CC),-fno-stack-protector,)
                     37: COMMONCFLAGS += $(call cc-option,$(CC),-fno-stack-protector-all,)
                     38: 
1.1.1.2 ! root       39: CFLAGS32FLAT = $(COMMONCFLAGS) -g -DMODE16=0 -DMODESEGMENT=0
        !            40: CFLAGSSEG = $(COMMONCFLAGS) -DMODESEGMENT=1 -fno-defer-pop \
        !            41:             $(call cc-option,$(CC),-fno-jump-tables,-DMANUAL_NO_JUMP_TABLE) \
        !            42:             $(call cc-option,$(CC),-fno-tree-switch-conversion,)
        !            43: CFLAGS32SEG = $(CFLAGSSEG) -DMODE16=0 -g
        !            44: CFLAGS16INC = $(CFLAGSSEG) -DMODE16=1 \
1.1       root       45:               $(call cc-option,$(CC),--param large-stack-frame=4,)
                     46: CFLAGS16 = $(CFLAGS16INC) -g
                     47: 
                     48: all: $(OUT) $(OUT)bios.bin
                     49: 
                     50: # Run with "make V=1" to see the actual compile commands
                     51: ifdef V
                     52: Q=
                     53: else
                     54: Q=@
                     55: endif
                     56: 
                     57: OBJCOPY=objcopy
                     58: OBJDUMP=objdump
                     59: STRIP=strip
                     60: 
                     61: .PHONY : all FORCE
                     62: 
                     63: vpath %.c src vgasrc
                     64: vpath %.S src vgasrc
                     65: 
                     66: ################ Build rules
                     67: 
                     68: # Verify the gcc configuration and test if -fwhole-program works.
                     69: TESTGCC:=$(shell CC=$(CC) tools/test-gcc.sh)
                     70: ifeq "$(TESTGCC)" "-1"
                     71: $(error "Please upgrade GCC")
                     72: endif
                     73: 
                     74: ifndef COMPSTRAT
                     75: COMPSTRAT=$(TESTGCC)
                     76: endif
                     77: 
                     78: # Do a whole file compile - three methods are supported.
                     79: ifeq "$(COMPSTRAT)" "1"
                     80: # First method - use -fwhole-program without -combine.
                     81: define whole-compile
                     82: @echo "  Compiling whole program $3"
                     83: $(Q)printf '$(foreach i,$2,#include "../$i"\n)' > $3.tmp.c
                     84: $(Q)$(CC) $1 -fwhole-program -DWHOLE_PROGRAM -c $3.tmp.c -o $3
                     85: endef
                     86: else
                     87: ifeq "$(COMPSTRAT)" "2"
                     88: # Second menthod - don't use -fwhole-program at all.
                     89: define whole-compile
                     90: @echo "  Compiling whole program $3"
                     91: $(Q)printf '$(foreach i,$2,#include "../$i"\n)' > $3.tmp.c
                     92: $(Q)$(CC) $1 -c $3.tmp.c -o $3
                     93: endef
                     94: else
                     95: # Third (and preferred) method - use -fwhole-program with -combine
                     96: define whole-compile
                     97: @echo "  Compiling whole program $3"
                     98: $(Q)$(CC) $1 -fwhole-program -DWHOLE_PROGRAM -combine -c $2 -o $3
                     99: endef
                    100: endif
                    101: endif
                    102: 
                    103: 
                    104: $(OUT)%.s: %.c
                    105:        @echo "  Compiling to assembler $@"
                    106:        $(Q)$(CC) $(CFLAGS16INC) -S -c $< -o $@
                    107: 
                    108: $(OUT)%.lds: %.lds.S
                    109:        @echo "  Precompiling $@"
                    110:        $(Q)$(CPP) -P -D__ASSEMBLY__ $< -o $@
                    111: 
                    112: $(OUT)asm-offsets.h: $(OUT)asm-offsets.s
                    113:        @echo "  Generating offset file $@"
                    114:        $(Q)./tools/gen-offsets.sh $< $@
                    115: 
                    116: 
                    117: $(OUT)ccode.16.s: ; $(call whole-compile, $(CFLAGS16) -S, $(addprefix src/, $(SRC16)),$@)
                    118: 
1.1.1.2 ! root      119: $(OUT)code32seg.o: ; $(call whole-compile, $(CFLAGS32SEG), $(addprefix src/, $(SRC32SEG)),$@)
        !           120: 
        !           121: $(OUT)ccode32flat.o: ; $(call whole-compile, $(CFLAGS32FLAT), $(addprefix src/, $(SRC32FLAT)),$@)
1.1       root      122: 
                    123: $(OUT)code16.o: romlayout.S $(OUT)ccode.16.s $(OUT)asm-offsets.h
                    124:        @echo "  Compiling (16bit) $@"
                    125:        $(Q)$(CC) $(CFLAGS16INC) -c -D__ASSEMBLY__ $< -o $@
                    126: 
1.1.1.2 ! root      127: $(OUT)romlayout16.lds $(OUT)romlayout32seg.lds $(OUT)romlayout32flat.lds $(OUT)code32flat.o: $(OUT)ccode32flat.o $(OUT)code32seg.o $(OUT)code16.o tools/layoutrom.py
1.1       root      128:        @echo "  Building ld scripts (version \"$(VERSION)\")"
                    129:        $(Q)echo 'const char VERSION[] = "$(VERSION)";' > $(OUT)version.c
1.1.1.2 ! root      130:        $(Q)$(CC) $(CFLAGS32FLAT) -c $(OUT)version.c -o $(OUT)version.o
        !           131:        $(Q)$(LD) -melf_i386 -r $(OUT)ccode32flat.o $(OUT)version.o -o $(OUT)code32flat.o
        !           132:        $(Q)$(OBJDUMP) -thr $(OUT)code32flat.o > $(OUT)code32flat.o.objdump
        !           133:        $(Q)$(OBJDUMP) -thr $(OUT)code32seg.o > $(OUT)code32seg.o.objdump
1.1       root      134:        $(Q)$(OBJDUMP) -thr $(OUT)code16.o > $(OUT)code16.o.objdump
1.1.1.2 ! root      135:        $(Q)./tools/layoutrom.py $(OUT)code16.o.objdump $(OUT)code32seg.o.objdump $(OUT)code32flat.o.objdump $(OUT)romlayout16.lds $(OUT)romlayout32seg.lds $(OUT)romlayout32flat.lds
1.1       root      136: 
                    137: 
1.1.1.2 ! root      138: $(OUT)rom16.o: $(OUT)code16.o $(OUT)rom32flat.o $(OUT)romlayout16.lds
1.1       root      139:        @echo "  Linking (no relocs) $@"
                    140:        $(Q)$(LD) -r -T $(OUT)romlayout16.lds $< -o $@
                    141: 
1.1.1.2 ! root      142: $(OUT)rom32seg.o: $(OUT)code32seg.o $(OUT)romlayout32seg.lds
        !           143:        @echo "  Linking (no relocs) $@"
        !           144:        $(Q)$(LD) -r -T $(OUT)romlayout32seg.lds $< -o $@
        !           145: 
        !           146: $(OUT)rom32flat.o: $(OUT)code32flat.o $(OUT)romlayout32flat.lds
1.1       root      147:        @echo "  Linking (no relocs) $@"
1.1.1.2 ! root      148:        $(Q)$(LD) -r -T $(OUT)romlayout32flat.lds $< -o $@
1.1       root      149: 
1.1.1.2 ! root      150: $(OUT)rom.o: $(OUT)rom16.o $(OUT)rom32seg.o $(OUT)rom32flat.o $(OUT)rombios16.lds  $(OUT)rombios32seg.lds $(OUT)rombios.lds
1.1       root      151:        @echo "  Linking $@"
1.1.1.2 ! root      152:        $(Q)$(LD) -T $(OUT)rombios16.lds $(OUT)rom16.o -R $(OUT)rom32seg.o -R $(OUT)rom32flat.o -o $(OUT)rom16.reloc.o
1.1       root      153:        $(Q)$(STRIP) $(OUT)rom16.reloc.o -o $(OUT)rom16.final.o
                    154:        $(Q)$(OBJCOPY) --adjust-vma 0xf0000 $(OUT)rom16.o $(OUT)rom16.moved.o
1.1.1.2 ! root      155:        $(Q)$(LD) -T $(OUT)rombios32seg.lds $(OUT)rom32seg.o -R $(OUT)rom16.o -R $(OUT)rom32flat.o -o $(OUT)rom32seg.reloc.o
        !           156:        $(Q)$(STRIP) $(OUT)rom32seg.reloc.o -o $(OUT)rom32seg.final.o
        !           157:        $(Q)$(OBJCOPY) --adjust-vma 0xf0000 $(OUT)rom32seg.o $(OUT)rom32seg.moved.o
        !           158:        $(Q)$(LD) -T $(OUT)rombios.lds $(OUT)rom16.final.o $(OUT)rom32seg.final.o $(OUT)rom32flat.o -R $(OUT)rom16.moved.o -R $(OUT)rom32seg.moved.o -o $@
1.1       root      159: 
                    160: $(OUT)bios.bin.elf $(OUT)bios.bin: $(OUT)rom.o tools/checkrom.py
                    161:        @echo "  Prepping $@"
                    162:        $(Q)$(OBJDUMP) -thr $< > $<.objdump
                    163:        $(Q)$(OBJCOPY) -O binary $< $(OUT)bios.bin.raw
                    164:        $(Q)./tools/checkrom.py $<.objdump $(OUT)bios.bin.raw $(OUT)bios.bin
                    165:        $(Q)$(STRIP) -R .comment $< -o $(OUT)bios.bin.elf
                    166: 
                    167: 
                    168: ################ VGA build rules
                    169: 
                    170: # VGA src files
                    171: SRCVGA=src/output.c src/util.c vgasrc/vga.c vgasrc/vgafb.c vgasrc/vgaio.c \
                    172:        vgasrc/vgatables.c vgasrc/vgafonts.c vgasrc/clext.c
                    173: 
                    174: $(OUT)vgaccode.16.s: ; $(call whole-compile, $(CFLAGS16) -S -Isrc, $(SRCVGA),$@)
                    175: 
                    176: $(OUT)vgalayout16.o: vgaentry.S $(OUT)vgaccode.16.s $(OUT)asm-offsets.h
                    177:        @echo "  Compiling (16bit) $@"
                    178:        $(Q)$(CC) $(CFLAGS16INC) -c -D__ASSEMBLY__ -Isrc $< -o $@
                    179: 
                    180: $(OUT)vgarom.o: $(OUT)vgalayout16.o $(OUT)vgalayout.lds
                    181:        @echo "  Linking $@"
                    182:        $(Q)$(LD) --gc-sections -T $(OUT)vgalayout.lds $(OUT)vgalayout16.o -o $@
                    183: 
                    184: $(OUT)vgabios.bin.raw: $(OUT)vgarom.o
                    185:        @echo "  Extracting binary $@"
                    186:        $(Q)$(OBJCOPY) -O binary $< $@
                    187: 
                    188: $(OUT)vgabios.bin: $(OUT)vgabios.bin.raw tools/buildrom.py
                    189:        @echo "  Finalizing rom $@"
                    190:        $(Q)./tools/buildrom.py $< $@
                    191: 
                    192: ####### dsdt build rules
                    193: src/acpi-dsdt.hex: src/acpi-dsdt.dsl
                    194:        @echo "Compiling DSDT"
                    195:        $(Q)cpp -P $< > $(OUT)acpi-dsdt.dsl.i
                    196:        $(Q)iasl -tc -p $@ $(OUT)acpi-dsdt.dsl.i
                    197:        $(Q)rm $(OUT)acpi-dsdt.dsl.i
                    198: 
                    199: ####### Generic rules
                    200: clean:
                    201:        $(Q)rm -rf $(OUT)
                    202: 
                    203: $(OUT):
                    204:        $(Q)mkdir $@
                    205: 
                    206: -include $(OUT)*.d

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.