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

1.1       root        1: # SeaBIOS build system
                      2: #
1.1.1.7 ! root        3: # Copyright (C) 2008-2012  Kevin O'Connor <[email protected]>
1.1       root        4: #
                      5: # This file may be distributed under the terms of the GNU LGPLv3 license.
                      6: 
                      7: # Output directory
                      8: OUT=out/
                      9: 
                     10: # Source files
1.1.1.7 ! root       11: SRCBOTH=misc.c stacks.c pmm.c output.c util.c block.c floppy.c ata.c mouse.c \
        !            12:     kbd.c pci.c serial.c clock.c pic.c cdrom.c ps2port.c smp.c resume.c \
        !            13:     pnpbios.c pirtable.c vgahooks.c ramdisk.c pcibios.c blockcmd.c \
        !            14:     usb.c usb-uhci.c usb-ohci.c usb-ehci.c usb-hid.c usb-msc.c \
        !            15:     virtio-ring.c virtio-pci.c virtio-blk.c virtio-scsi.c apm.c ahci.c
1.1.1.5   root       16: SRC16=$(SRCBOTH) system.c disk.c font.c
1.1.1.2   root       17: SRC32FLAT=$(SRCBOTH) post.c shadow.c memmap.c coreboot.c boot.c \
1.1.1.7 ! root       18:     acpi.c smm.c mptable.c smbios.c pciinit.c optionroms.c mtrr.c \
        !            19:     lzmadecode.c bootsplash.c jpeg.c usb-hub.c paravirt.c \
        !            20:     biostables.c xen.c bmp.c
1.1.1.3   root       21: SRC32SEG=util.c output.c pci.c pcibios.c apm.c stacks.c
1.1       root       22: 
                     23: # Default compiler flags
1.1.1.7 ! root       24: cc-option=$(shell if test -z "`$(1) $(2) -S -o /dev/null -xc /dev/null 2>&1`" \
        !            25:     ; then echo "$(2)"; else echo "$(3)"; fi ;)
        !            26: 
        !            27: COMMONCFLAGS = -I$(OUT) -Os -MD -g \
        !            28:     -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:     -minline-all-stringops \
        !            32:     -freg-struct-return -ffreestanding -fno-delete-null-pointer-checks \
        !            33:     -ffunction-sections -fdata-sections -fno-common
1.1       root       34: COMMONCFLAGS += $(call cc-option,$(CC),-nopie,)
                     35: COMMONCFLAGS += $(call cc-option,$(CC),-fno-stack-protector,)
                     36: COMMONCFLAGS += $(call cc-option,$(CC),-fno-stack-protector-all,)
                     37: 
1.1.1.7 ! root       38: CFLAGS32FLAT = $(COMMONCFLAGS) -DMODE16=0 -DMODESEGMENT=0 -fomit-frame-pointer
1.1.1.2   root       39: CFLAGSSEG = $(COMMONCFLAGS) -DMODESEGMENT=1 -fno-defer-pop \
1.1.1.7 ! root       40:     $(call cc-option,$(CC),-fno-jump-tables,-DMANUAL_NO_JUMP_TABLE) \
        !            41:     $(call cc-option,$(CC),-fno-tree-switch-conversion,)
        !            42: CFLAGS32SEG = $(CFLAGSSEG) -DMODE16=0 -fomit-frame-pointer
        !            43: CFLAGS16INC = $(CFLAGSSEG) -DMODE16=1 -Wa,src/code16gcc.s \
        !            44:     $(call cc-option,$(CC),--param large-stack-frame=4,-fno-inline)
        !            45: CFLAGS16 = $(CFLAGS16INC) -fomit-frame-pointer
1.1       root       46: 
                     47: # Run with "make V=1" to see the actual compile commands
                     48: ifdef V
                     49: Q=
                     50: else
                     51: Q=@
1.1.1.5   root       52: MAKEFLAGS += --no-print-directory
1.1       root       53: endif
                     54: 
1.1.1.7 ! root       55: # Common command definitions
        !            56: export HOSTCC             := $(CC)
        !            57: export CONFIG_SHELL       := sh
        !            58: export KCONFIG_AUTOHEADER := autoconf.h
        !            59: export KCONFIG_CONFIG     := $(CURDIR)/.config
        !            60: AS=as
1.1       root       61: OBJCOPY=objcopy
                     62: OBJDUMP=objdump
                     63: STRIP=strip
1.1.1.7 ! root       64: PYTHON=python
        !            65: 
        !            66: # Default targets
        !            67: -include $(KCONFIG_CONFIG)
1.1       root       68: 
1.1.1.7 ! root       69: target-y = $(OUT) $(OUT)bios.bin
        !            70: target-$(CONFIG_BUILD_VGABIOS) += $(OUT)vgabios.bin
        !            71: 
        !            72: all: $(target-y)
        !            73: 
        !            74: # Make definitions
1.1.1.5   root       75: .PHONY : all clean distclean FORCE
1.1       root       76: 
                     77: vpath %.c src vgasrc
                     78: vpath %.S src vgasrc
                     79: 
1.1.1.7 ! root       80: 
        !            81: ################ Common build rules
1.1       root       82: 
                     83: # Verify the gcc configuration and test if -fwhole-program works.
1.1.1.6   root       84: TESTGCC:=$(shell CC="$(CC)" LD="$(LD)" tools/test-gcc.sh)
1.1       root       85: ifeq "$(TESTGCC)" "-1"
1.1.1.6   root       86: $(error "Please upgrade GCC and/or binutils")
1.1       root       87: endif
                     88: 
                     89: ifndef COMPSTRAT
                     90: COMPSTRAT=$(TESTGCC)
                     91: endif
                     92: 
                     93: # Do a whole file compile - three methods are supported.
                     94: ifeq "$(COMPSTRAT)" "1"
                     95: # First method - use -fwhole-program without -combine.
                     96: define whole-compile
                     97: @echo "  Compiling whole program $3"
                     98: $(Q)printf '$(foreach i,$2,#include "../$i"\n)' > $3.tmp.c
                     99: $(Q)$(CC) $1 -fwhole-program -DWHOLE_PROGRAM -c $3.tmp.c -o $3
                    100: endef
                    101: else
                    102: ifeq "$(COMPSTRAT)" "2"
                    103: # Second menthod - don't use -fwhole-program at all.
                    104: define whole-compile
                    105: @echo "  Compiling whole program $3"
                    106: $(Q)printf '$(foreach i,$2,#include "../$i"\n)' > $3.tmp.c
                    107: $(Q)$(CC) $1 -c $3.tmp.c -o $3
                    108: endef
                    109: else
                    110: # Third (and preferred) method - use -fwhole-program with -combine
                    111: define whole-compile
                    112: @echo "  Compiling whole program $3"
                    113: $(Q)$(CC) $1 -fwhole-program -DWHOLE_PROGRAM -combine -c $2 -o $3
                    114: endef
                    115: endif
                    116: endif
                    117: 
1.1.1.3   root      118: %.strip.o: %.o
                    119:        @echo "  Stripping $@"
                    120:        $(Q)$(STRIP) $< -o $@
1.1       root      121: 
                    122: $(OUT)%.s: %.c
                    123:        @echo "  Compiling to assembler $@"
1.1.1.7 ! root      124:        $(Q)$(CC) $(CFLAGS16) -S -c $< -o $@
1.1       root      125: 
                    126: $(OUT)%.lds: %.lds.S
                    127:        @echo "  Precompiling $@"
                    128:        $(Q)$(CPP) -P -D__ASSEMBLY__ $< -o $@
                    129: 
1.1.1.7 ! root      130: 
        !           131: ################ Main BIOS build rules
        !           132: 
1.1.1.5   root      133: $(OUT)asm-offsets.s: $(OUT)autoconf.h
                    134: 
1.1       root      135: $(OUT)asm-offsets.h: $(OUT)asm-offsets.s
                    136:        @echo "  Generating offset file $@"
                    137:        $(Q)./tools/gen-offsets.sh $< $@
                    138: 
1.1.1.7 ! root      139: $(OUT)ccode16.o: $(OUT)autoconf.h ; $(call whole-compile, $(CFLAGS16), $(addprefix src/, $(SRC16)),$@)
1.1       root      140: 
1.1.1.5   root      141: $(OUT)code32seg.o: $(OUT)autoconf.h ; $(call whole-compile, $(CFLAGS32SEG), $(addprefix src/, $(SRC32SEG)),$@)
1.1.1.2   root      142: 
1.1.1.5   root      143: $(OUT)ccode32flat.o: $(OUT)autoconf.h ; $(call whole-compile, $(CFLAGS32FLAT), $(addprefix src/, $(SRC32FLAT)),$@)
1.1       root      144: 
1.1.1.7 ! root      145: $(OUT)romlayout.o: romlayout.S $(OUT)asm-offsets.h
1.1       root      146:        @echo "  Compiling (16bit) $@"
1.1.1.7 ! root      147:        $(Q)$(CC) $(CFLAGS16) -c -D__ASSEMBLY__ $< -o $@
1.1       root      148: 
1.1.1.7 ! root      149: $(OUT)romlayout16.lds: $(OUT)ccode32flat.o $(OUT)code32seg.o $(OUT)ccode16.o $(OUT)romlayout.o tools/layoutrom.py
        !           150:        @echo "  Building ld scripts"
        !           151:        $(Q)./tools/buildversion.sh $(OUT)version.c
1.1.1.2   root      152:        $(Q)$(CC) $(CFLAGS32FLAT) -c $(OUT)version.c -o $(OUT)version.o
                    153:        $(Q)$(LD) -melf_i386 -r $(OUT)ccode32flat.o $(OUT)version.o -o $(OUT)code32flat.o
1.1.1.7 ! root      154:        $(Q)$(LD) -melf_i386 -r $(OUT)ccode16.o $(OUT)romlayout.o -o $(OUT)code16.o
1.1.1.2   root      155:        $(Q)$(OBJDUMP) -thr $(OUT)code32flat.o > $(OUT)code32flat.o.objdump
                    156:        $(Q)$(OBJDUMP) -thr $(OUT)code32seg.o > $(OUT)code32seg.o.objdump
1.1       root      157:        $(Q)$(OBJDUMP) -thr $(OUT)code16.o > $(OUT)code16.o.objdump
1.1.1.7 ! root      158:        $(Q)$(PYTHON) ./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      159: 
1.1.1.5   root      160: # These are actually built by tools/layoutrom.py above, but by pulling them
                    161: # into an extra rule we prevent make -j from spawning layoutrom.py 4 times.
1.1.1.7 ! root      162: $(OUT)romlayout32seg.lds $(OUT)romlayout32flat.lds $(OUT)code32flat.o $(OUT)code16.o: $(OUT)romlayout16.lds
1.1       root      163: 
1.1.1.3   root      164: $(OUT)rom16.o: $(OUT)code16.o $(OUT)romlayout16.lds
                    165:        @echo "  Linking $@"
                    166:        $(Q)$(LD) -T $(OUT)romlayout16.lds $< -o $@
1.1       root      167: 
1.1.1.2   root      168: $(OUT)rom32seg.o: $(OUT)code32seg.o $(OUT)romlayout32seg.lds
1.1.1.3   root      169:        @echo "  Linking $@"
                    170:        $(Q)$(LD) -T $(OUT)romlayout32seg.lds $< -o $@
1.1       root      171: 
1.1.1.3   root      172: $(OUT)rom.o: $(OUT)rom16.strip.o $(OUT)rom32seg.strip.o $(OUT)code32flat.o $(OUT)romlayout32flat.lds
1.1       root      173:        @echo "  Linking $@"
1.1.1.3   root      174:        $(Q)$(LD) -T $(OUT)romlayout32flat.lds $(OUT)rom16.strip.o $(OUT)rom32seg.strip.o $(OUT)code32flat.o -o $@
1.1       root      175: 
                    176: $(OUT)bios.bin.elf $(OUT)bios.bin: $(OUT)rom.o tools/checkrom.py
                    177:        @echo "  Prepping $@"
                    178:        $(Q)$(OBJDUMP) -thr $< > $<.objdump
                    179:        $(Q)$(OBJCOPY) -O binary $< $(OUT)bios.bin.raw
1.1.1.7 ! root      180:        $(Q)$(PYTHON) ./tools/checkrom.py $<.objdump $(OUT)bios.bin.raw $(OUT)bios.bin
1.1       root      181:        $(Q)$(STRIP) -R .comment $< -o $(OUT)bios.bin.elf
                    182: 
                    183: 
                    184: ################ VGA build rules
                    185: 
                    186: # VGA src files
1.1.1.7 ! root      187: SRCVGA=src/output.c src/util.c src/pci.c \
        !           188:     vgasrc/vgabios.c vgasrc/vgafb.c vgasrc/vgafonts.c vgasrc/vbe.c \
        !           189:     vgasrc/stdvga.c vgasrc/stdvgamodes.c vgasrc/stdvgaio.c \
        !           190:     vgasrc/clext.c vgasrc/bochsvga.c vgasrc/geodevga.c
1.1       root      191: 
1.1.1.7 ! root      192: CFLAGS16VGA = $(CFLAGS16INC) -Isrc
1.1       root      193: 
1.1.1.7 ! root      194: $(OUT)vgaccode16.raw.s: $(OUT)autoconf.h ; $(call whole-compile, $(CFLAGS16VGA) -S, $(SRCVGA),$@)
        !           195: 
        !           196: $(OUT)vgaccode16.o: $(OUT)vgaccode16.raw.s
        !           197:        @echo "  Fixup VGA rom assembler"
        !           198:        $(Q)$(PYTHON) ./tools/vgafixup.py $< $(OUT)vgaccode16.s
        !           199:        $(Q)$(AS) --32 src/code16gcc.s $(OUT)vgaccode16.s -o $@
        !           200: 
        !           201: $(OUT)vgaentry.o: vgaentry.S $(OUT)autoconf.h
1.1       root      202:        @echo "  Compiling (16bit) $@"
1.1.1.7 ! root      203:        $(Q)$(CC) $(CFLAGS16VGA) -c -D__ASSEMBLY__ $< -o $@
1.1       root      204: 
1.1.1.7 ! root      205: $(OUT)vgarom.o: $(OUT)vgaccode16.o $(OUT)vgaentry.o $(OUT)vgalayout.lds
1.1       root      206:        @echo "  Linking $@"
1.1.1.7 ! root      207:        $(Q)./tools/buildversion.sh $(OUT)vgaversion.c VAR16
        !           208:        $(Q)$(CC) $(CFLAGS16VGA) -c $(OUT)vgaversion.c -o $(OUT)vgaversion.o
        !           209:        $(Q)$(LD) --gc-sections -T $(OUT)vgalayout.lds $(OUT)vgaccode16.o $(OUT)vgaentry.o $(OUT)vgaversion.o -o $@
1.1       root      210: 
                    211: $(OUT)vgabios.bin.raw: $(OUT)vgarom.o
                    212:        @echo "  Extracting binary $@"
                    213:        $(Q)$(OBJCOPY) -O binary $< $@
                    214: 
                    215: $(OUT)vgabios.bin: $(OUT)vgabios.bin.raw tools/buildrom.py
                    216:        @echo "  Finalizing rom $@"
1.1.1.7 ! root      217:        $(Q)$(PYTHON) ./tools/buildrom.py $< $@
1.1       root      218: 
1.1.1.3   root      219: 
1.1.1.7 ! root      220: ################ DSDT build rules
1.1       root      221: 
1.1.1.7 ! root      222: src/%.hex: src/%.dsl ./tools/acpi_extract_preprocess.py ./tools/acpi_extract.py
        !           223:        @echo "Compiling DSDT"
        !           224:        $(Q)cpp -P $< > $(OUT)$*.dsl.i.orig
        !           225:        $(Q)$(PYTHON) ./tools/acpi_extract_preprocess.py $(OUT)$*.dsl.i.orig > $(OUT)$*.dsl.i
        !           226:        $(Q)iasl -l -tc -p $(OUT)$* $(OUT)$*.dsl.i
        !           227:        $(Q)$(PYTHON) ./tools/acpi_extract.py $(OUT)$*.lst > $(OUT)$*.off
        !           228:        $(Q)cat $(OUT)$*.off > $@
        !           229: 
        !           230: $(OUT)ccode32flat.o: src/acpi-dsdt.hex src/ssdt-proc.hex src/ssdt-pcihp.hex
        !           231: 
        !           232: ################ Kconfig rules
        !           233: 
        !           234: define do-kconfig
        !           235: $(Q)mkdir -p $(OUT)/tools/kconfig/lxdialog
        !           236: $(Q)mkdir -p $(OUT)/include/config
        !           237: $(Q)$(MAKE) -C $(OUT) -f $(CURDIR)/tools/kconfig/Makefile srctree=$(CURDIR) src=tools/kconfig obj=tools/kconfig Q=$(Q) Kconfig=$(CURDIR)/src/Kconfig $1
        !           238: endef
1.1.1.5   root      239: 
1.1.1.7 ! root      240: $(OUT)autoconf.h : $(KCONFIG_CONFIG) ; $(call do-kconfig, silentoldconfig)
        !           241: $(KCONFIG_CONFIG): ; $(call do-kconfig, defconfig)
        !           242: %onfig: ; $(call do-kconfig, $@)
        !           243: help: ; $(call do-kconfig, $@)
1.1.1.5   root      244: 
                    245: 
1.1.1.7 ! root      246: ################ Generic rules
1.1.1.5   root      247: 
1.1       root      248: clean:
                    249:        $(Q)rm -rf $(OUT)
                    250: 
1.1.1.5   root      251: distclean: clean
                    252:        $(Q)rm -f .config .config.old
                    253: 
1.1       root      254: $(OUT):
                    255:        $(Q)mkdir $@
                    256: 
                    257: -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.