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

1.1       root        1: # SeaBIOS build system
                      2: #
1.1.1.5   root        3: # Copyright (C) 2008-2010  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: # Program version
1.1.1.5   root        8: VERSION=pre-0.6.3-$(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.3   root       16:         pnpbios.c pirtable.c vgahooks.c ramdisk.c pcibios.c blockcmd.c \
                     17:         usb.c usb-uhci.c usb-ohci.c usb-ehci.c usb-hid.c usb-msc.c \
1.1.1.5   root       18:         virtio-ring.c virtio-pci.c virtio-blk.c apm.c ahci.c
                     19: SRC16=$(SRCBOTH) system.c disk.c font.c
1.1.1.2   root       20: SRC32FLAT=$(SRCBOTH) post.c shadow.c memmap.c coreboot.c boot.c \
1.1       root       21:       acpi.c smm.c mptable.c smbios.c pciinit.c optionroms.c mtrr.c \
1.1.1.6 ! root       22:       lzmadecode.c bootsplash.c jpeg.c usb-hub.c paravirt.c \
        !            23:       biostables.c xen.c bmp.c
1.1.1.3   root       24: SRC32SEG=util.c output.c pci.c pcibios.c apm.c stacks.c
1.1       root       25: 
                     26: cc-option = $(shell if test -z "`$(1) $(2) -S -o /dev/null -xc \
                     27:               /dev/null 2>&1`"; then echo "$(2)"; else echo "$(3)"; fi ;)
                     28: 
                     29: # Default compiler flags
1.1.1.5   root       30: COMMONCFLAGS = -I$(OUT) -Os -MD \
                     31:                -Wall -Wno-strict-aliasing -Wold-style-definition \
1.1.1.2   root       32:                $(call cc-option,$(CC),-Wtype-limits,) \
                     33:                -m32 -march=i386 -mregparm=3 -mpreferred-stack-boundary=2 \
                     34:                -mrtd -minline-all-stringops \
                     35:                -freg-struct-return -ffreestanding -fomit-frame-pointer \
                     36:                -fno-delete-null-pointer-checks \
                     37:                -ffunction-sections -fdata-sections -fno-common
1.1       root       38: COMMONCFLAGS += $(call cc-option,$(CC),-nopie,)
                     39: COMMONCFLAGS += $(call cc-option,$(CC),-fno-stack-protector,)
                     40: COMMONCFLAGS += $(call cc-option,$(CC),-fno-stack-protector-all,)
                     41: 
1.1.1.2   root       42: CFLAGS32FLAT = $(COMMONCFLAGS) -g -DMODE16=0 -DMODESEGMENT=0
                     43: CFLAGSSEG = $(COMMONCFLAGS) -DMODESEGMENT=1 -fno-defer-pop \
                     44:             $(call cc-option,$(CC),-fno-jump-tables,-DMANUAL_NO_JUMP_TABLE) \
                     45:             $(call cc-option,$(CC),-fno-tree-switch-conversion,)
                     46: CFLAGS32SEG = $(CFLAGSSEG) -DMODE16=0 -g
                     47: CFLAGS16INC = $(CFLAGSSEG) -DMODE16=1 \
1.1.1.3   root       48:               $(call cc-option,$(CC),--param large-stack-frame=4,-fno-inline)
1.1       root       49: CFLAGS16 = $(CFLAGS16INC) -g
                     50: 
                     51: all: $(OUT) $(OUT)bios.bin
                     52: 
                     53: # Run with "make V=1" to see the actual compile commands
                     54: ifdef V
                     55: Q=
                     56: else
                     57: Q=@
1.1.1.5   root       58: MAKEFLAGS += --no-print-directory
1.1       root       59: endif
                     60: 
                     61: OBJCOPY=objcopy
                     62: OBJDUMP=objdump
                     63: STRIP=strip
                     64: 
1.1.1.5   root       65: .PHONY : all clean distclean FORCE
1.1       root       66: 
                     67: vpath %.c src vgasrc
                     68: vpath %.S src vgasrc
                     69: 
                     70: ################ Build rules
                     71: 
                     72: # Verify the gcc configuration and test if -fwhole-program works.
1.1.1.6 ! root       73: TESTGCC:=$(shell CC="$(CC)" LD="$(LD)" tools/test-gcc.sh)
1.1       root       74: ifeq "$(TESTGCC)" "-1"
1.1.1.6 ! root       75: $(error "Please upgrade GCC and/or binutils")
1.1       root       76: endif
                     77: 
                     78: ifndef COMPSTRAT
                     79: COMPSTRAT=$(TESTGCC)
                     80: endif
                     81: 
                     82: # Do a whole file compile - three methods are supported.
                     83: ifeq "$(COMPSTRAT)" "1"
                     84: # First method - use -fwhole-program without -combine.
                     85: define whole-compile
                     86: @echo "  Compiling whole program $3"
                     87: $(Q)printf '$(foreach i,$2,#include "../$i"\n)' > $3.tmp.c
                     88: $(Q)$(CC) $1 -fwhole-program -DWHOLE_PROGRAM -c $3.tmp.c -o $3
                     89: endef
                     90: else
                     91: ifeq "$(COMPSTRAT)" "2"
                     92: # Second menthod - don't use -fwhole-program at all.
                     93: define whole-compile
                     94: @echo "  Compiling whole program $3"
                     95: $(Q)printf '$(foreach i,$2,#include "../$i"\n)' > $3.tmp.c
                     96: $(Q)$(CC) $1 -c $3.tmp.c -o $3
                     97: endef
                     98: else
                     99: # Third (and preferred) method - use -fwhole-program with -combine
                    100: define whole-compile
                    101: @echo "  Compiling whole program $3"
                    102: $(Q)$(CC) $1 -fwhole-program -DWHOLE_PROGRAM -combine -c $2 -o $3
                    103: endef
                    104: endif
                    105: endif
                    106: 
1.1.1.3   root      107: %.strip.o: %.o
                    108:        @echo "  Stripping $@"
                    109:        $(Q)$(STRIP) $< -o $@
1.1       root      110: 
                    111: $(OUT)%.s: %.c
                    112:        @echo "  Compiling to assembler $@"
                    113:        $(Q)$(CC) $(CFLAGS16INC) -S -c $< -o $@
                    114: 
                    115: $(OUT)%.lds: %.lds.S
                    116:        @echo "  Precompiling $@"
                    117:        $(Q)$(CPP) -P -D__ASSEMBLY__ $< -o $@
                    118: 
1.1.1.5   root      119: $(OUT)asm-offsets.s: $(OUT)autoconf.h
                    120: 
1.1       root      121: $(OUT)asm-offsets.h: $(OUT)asm-offsets.s
                    122:        @echo "  Generating offset file $@"
                    123:        $(Q)./tools/gen-offsets.sh $< $@
                    124: 
                    125: 
1.1.1.5   root      126: $(OUT)ccode.16.s: $(OUT)autoconf.h ; $(call whole-compile, $(CFLAGS16) -S, $(addprefix src/, $(SRC16)),$@)
1.1       root      127: 
1.1.1.5   root      128: $(OUT)code32seg.o: $(OUT)autoconf.h ; $(call whole-compile, $(CFLAGS32SEG), $(addprefix src/, $(SRC32SEG)),$@)
1.1.1.2   root      129: 
1.1.1.5   root      130: $(OUT)ccode32flat.o: $(OUT)autoconf.h ; $(call whole-compile, $(CFLAGS32FLAT), $(addprefix src/, $(SRC32FLAT)),$@)
1.1       root      131: 
                    132: $(OUT)code16.o: romlayout.S $(OUT)ccode.16.s $(OUT)asm-offsets.h
                    133:        @echo "  Compiling (16bit) $@"
                    134:        $(Q)$(CC) $(CFLAGS16INC) -c -D__ASSEMBLY__ $< -o $@
                    135: 
1.1.1.5   root      136: $(OUT)romlayout16.lds: $(OUT)ccode32flat.o $(OUT)code32seg.o $(OUT)code16.o tools/layoutrom.py
1.1       root      137:        @echo "  Building ld scripts (version \"$(VERSION)\")"
                    138:        $(Q)echo 'const char VERSION[] = "$(VERSION)";' > $(OUT)version.c
1.1.1.2   root      139:        $(Q)$(CC) $(CFLAGS32FLAT) -c $(OUT)version.c -o $(OUT)version.o
                    140:        $(Q)$(LD) -melf_i386 -r $(OUT)ccode32flat.o $(OUT)version.o -o $(OUT)code32flat.o
                    141:        $(Q)$(OBJDUMP) -thr $(OUT)code32flat.o > $(OUT)code32flat.o.objdump
                    142:        $(Q)$(OBJDUMP) -thr $(OUT)code32seg.o > $(OUT)code32seg.o.objdump
1.1       root      143:        $(Q)$(OBJDUMP) -thr $(OUT)code16.o > $(OUT)code16.o.objdump
1.1.1.2   root      144:        $(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      145: 
1.1.1.5   root      146: # These are actually built by tools/layoutrom.py above, but by pulling them
                    147: # into an extra rule we prevent make -j from spawning layoutrom.py 4 times.
                    148: $(OUT)romlayout32seg.lds $(OUT)romlayout32flat.lds $(OUT)code32flat.o: $(OUT)romlayout16.lds
1.1       root      149: 
1.1.1.3   root      150: $(OUT)rom16.o: $(OUT)code16.o $(OUT)romlayout16.lds
                    151:        @echo "  Linking $@"
                    152:        $(Q)$(LD) -T $(OUT)romlayout16.lds $< -o $@
1.1       root      153: 
1.1.1.2   root      154: $(OUT)rom32seg.o: $(OUT)code32seg.o $(OUT)romlayout32seg.lds
1.1.1.3   root      155:        @echo "  Linking $@"
                    156:        $(Q)$(LD) -T $(OUT)romlayout32seg.lds $< -o $@
1.1       root      157: 
1.1.1.3   root      158: $(OUT)rom.o: $(OUT)rom16.strip.o $(OUT)rom32seg.strip.o $(OUT)code32flat.o $(OUT)romlayout32flat.lds
1.1       root      159:        @echo "  Linking $@"
1.1.1.3   root      160:        $(Q)$(LD) -T $(OUT)romlayout32flat.lds $(OUT)rom16.strip.o $(OUT)rom32seg.strip.o $(OUT)code32flat.o -o $@
1.1       root      161: 
                    162: $(OUT)bios.bin.elf $(OUT)bios.bin: $(OUT)rom.o tools/checkrom.py
                    163:        @echo "  Prepping $@"
                    164:        $(Q)$(OBJDUMP) -thr $< > $<.objdump
                    165:        $(Q)$(OBJCOPY) -O binary $< $(OUT)bios.bin.raw
                    166:        $(Q)./tools/checkrom.py $<.objdump $(OUT)bios.bin.raw $(OUT)bios.bin
                    167:        $(Q)$(STRIP) -R .comment $< -o $(OUT)bios.bin.elf
                    168: 
                    169: 
                    170: ################ VGA build rules
                    171: 
                    172: # VGA src files
                    173: SRCVGA=src/output.c src/util.c vgasrc/vga.c vgasrc/vgafb.c vgasrc/vgaio.c \
                    174:        vgasrc/vgatables.c vgasrc/vgafonts.c vgasrc/clext.c
                    175: 
1.1.1.5   root      176: $(OUT)vgaccode.16.s: $(OUT)autoconf.h ; $(call whole-compile, $(CFLAGS16) -S -Isrc, $(SRCVGA),$@)
1.1       root      177: 
                    178: $(OUT)vgalayout16.o: vgaentry.S $(OUT)vgaccode.16.s $(OUT)asm-offsets.h
                    179:        @echo "  Compiling (16bit) $@"
                    180:        $(Q)$(CC) $(CFLAGS16INC) -c -D__ASSEMBLY__ -Isrc $< -o $@
                    181: 
                    182: $(OUT)vgarom.o: $(OUT)vgalayout16.o $(OUT)vgalayout.lds
                    183:        @echo "  Linking $@"
                    184:        $(Q)$(LD) --gc-sections -T $(OUT)vgalayout.lds $(OUT)vgalayout16.o -o $@
                    185: 
                    186: $(OUT)vgabios.bin.raw: $(OUT)vgarom.o
                    187:        @echo "  Extracting binary $@"
                    188:        $(Q)$(OBJCOPY) -O binary $< $@
                    189: 
                    190: $(OUT)vgabios.bin: $(OUT)vgabios.bin.raw tools/buildrom.py
                    191:        @echo "  Finalizing rom $@"
                    192:        $(Q)./tools/buildrom.py $< $@
                    193: 
                    194: ####### dsdt build rules
1.1.1.3   root      195: src/%.hex: src/%.dsl
1.1       root      196:        @echo "Compiling DSDT"
1.1.1.3   root      197:        $(Q)cpp -P $< > $(OUT)$*.dsl.i
                    198:        $(Q)iasl -tc -p $(OUT)$* $(OUT)$*.dsl.i
                    199:        $(Q)cp $(OUT)$*.hex $@
                    200: 
                    201: $(OUT)ccode32flat.o: src/acpi-dsdt.hex
1.1       root      202: 
1.1.1.5   root      203: ####### Kconfig rules
                    204: export HOSTCC             := $(CC)
                    205: export CONFIG_SHELL       := sh
                    206: export KCONFIG_AUTOHEADER := autoconf.h
                    207: export KCONFIG_CONFIG     := $(CURDIR)/.config
                    208: 
                    209: $(OUT)autoconf.h : $(KCONFIG_CONFIG)
                    210:        $(Q)$(MAKE) silentoldconfig
                    211: 
                    212: $(KCONFIG_CONFIG):
                    213:        $(Q)$(MAKE) defconfig
                    214: 
                    215: %onfig:
                    216:        $(Q)mkdir -p $(OUT)/tools/kconfig/lxdialog
                    217:        $(Q)mkdir -p $(OUT)/include/config
                    218:        $(Q)$(MAKE) -C $(OUT) -f $(CURDIR)/tools/kconfig/Makefile srctree=$(CURDIR) src=tools/kconfig obj=tools/kconfig Q=$(Q) Kconfig=$(CURDIR)/src/Kconfig $@
                    219: 
1.1       root      220: ####### Generic rules
                    221: clean:
                    222:        $(Q)rm -rf $(OUT)
                    223: 
1.1.1.5   root      224: distclean: clean
                    225:        $(Q)rm -f .config .config.old
                    226: 
1.1       root      227: $(OUT):
                    228:        $(Q)mkdir $@
                    229: 
                    230: -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.