259 lines
11 KiB
Makefile
259 lines
11 KiB
Makefile
# -*- makefile -*-
|
|
|
|
pkglib_MODULES += cpuid.mod
|
|
cpuid_mod_SOURCES = commands/i386/cpuid.c
|
|
cpuid_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
cpuid_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
|
|
pkglib_MODULES += at_keyboard.mod
|
|
at_keyboard_mod_SOURCES = term/at_keyboard.c
|
|
at_keyboard_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
at_keyboard_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
|
|
ifneq ($(platform), qemu)
|
|
pkglib_MODULES += vga_text.mod
|
|
vga_text_mod_SOURCES = term/i386/pc/vga_text.c term/i386/vga_common.c
|
|
vga_text_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
vga_text_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
endif
|
|
|
|
pkglib_MODULES += video_cirrus.mod
|
|
video_cirrus_mod_SOURCES = video/cirrus.c
|
|
video_cirrus_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
video_cirrus_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
|
|
pkglib_MODULES += video_bochs.mod
|
|
video_bochs_mod_SOURCES = video/bochs.c
|
|
video_bochs_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
video_bochs_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
|
|
pkglib_MODULES += relocator.mod
|
|
ifeq ($(platform), ieee1275)
|
|
relocator_mod_SOURCES = lib/relocator.c lib/i386/relocator32.S \
|
|
lib/i386/relocator64.S lib/i386/relocator16.S \
|
|
lib/$(target_cpu)/relocator_asm.S lib/i386/relocator.c \
|
|
lib/ieee1275/relocator.c
|
|
else
|
|
ifeq ($(platform), efi)
|
|
relocator_mod_SOURCES = lib/relocator.c lib/i386/relocator32.S \
|
|
lib/i386/relocator64.S lib/i386/relocator16.S \
|
|
lib/$(target_cpu)/relocator_asm.S lib/i386/relocator.c \
|
|
lib/efi/relocator.c
|
|
else
|
|
relocator_mod_SOURCES = lib/relocator.c lib/i386/relocator32.S \
|
|
lib/i386/relocator64.S lib/i386/relocator16.S \
|
|
lib/$(target_cpu)/relocator_asm.S lib/i386/relocator.c
|
|
endif
|
|
endif
|
|
relocator_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
relocator_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
|
relocator_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
|
|
pkglib_MODULES += ata.mod
|
|
ata_mod_SOURCES = disk/ata.c
|
|
ata_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
ata_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
|
|
# For linux.mod.
|
|
pkglib_MODULES += linux.mod
|
|
linux_mod_SOURCES = loader/i386/linux.c
|
|
linux_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
|
|
# For aout.mod
|
|
pkglib_MODULES += aout.mod
|
|
aout_mod_SOURCES = loader/aout.c
|
|
aout_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
aout_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
|
|
# For bsd.mod
|
|
pkglib_MODULES += bsd.mod
|
|
bsd_mod_SOURCES = loader/i386/bsd.c loader/i386/bsd32.c loader/i386/bsd64.c
|
|
bsd_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
bsd_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
bsd_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
|
|
|
# For setpci.mod
|
|
pkglib_MODULES += setpci.mod
|
|
setpci_mod_SOURCES = commands/setpci.c
|
|
setpci_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
setpci_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
|
|
pkglib_MODULES += multiboot.mod
|
|
multiboot_mod_SOURCES = loader/multiboot.c loader/i386/multiboot_mbi.c
|
|
multiboot_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
multiboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
multiboot_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
|
|
|
pkglib_MODULES += multiboot2.mod
|
|
multiboot2_mod_SOURCES = loader/multiboot.c loader/multiboot_mbi2.c
|
|
multiboot2_mod_CFLAGS = $(COMMON_CFLAGS) -DGRUB_USE_MULTIBOOT2
|
|
multiboot2_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
multiboot2_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
|
|
|
# For serial.mod.
|
|
pkglib_MODULES += serial.mod
|
|
serial_mod_SOURCES = term/serial.c
|
|
serial_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
serial_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
|
|
# On qemu it's compiled in
|
|
ifneq ($(platform), qemu)
|
|
# For pci.mod
|
|
pkglib_MODULES += pci.mod
|
|
pci_mod_SOURCES = bus/pci.c
|
|
pci_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
pci_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
endif
|
|
|
|
# For cs5536.mod
|
|
pkglib_MODULES += cs5536.mod
|
|
cs5536_mod_SOURCES = bus/cs5536.c
|
|
cs5536_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
cs5536_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
|
|
# For lspci.mod
|
|
pkglib_MODULES += lspci.mod
|
|
lspci_mod_SOURCES = commands/lspci.c
|
|
lspci_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
lspci_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
|
|
# For play.mod.
|
|
pkglib_MODULES += play.mod
|
|
play_mod_SOURCES = commands/i386/pc/play.c
|
|
play_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
play_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
|
|
# For iorw.mod.
|
|
pkglib_MODULES += iorw.mod
|
|
iorw_mod_SOURCES = commands/iorw.c
|
|
iorw_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
iorw_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
|
|
pkglib_MODULES += xnu.mod
|
|
xnu_mod_SOURCES = loader/xnu_resume.c loader/i386/xnu.c \
|
|
loader/macho32.c loader/macho64.c loader/macho.c loader/xnu.c
|
|
xnu_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
xnu_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
xnu_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
|
|
|
ifeq ($(enable_efiemu), yes)
|
|
|
|
efiemu32.o: efiemu/runtime/efiemu.c $(TARGET_OBJ2ELF)
|
|
-rm -f $@
|
|
ifeq ($(TARGET_APPLE_CC), 1)
|
|
-rm -f $@.bin
|
|
$(TARGET_CC) -c -m32 -DELF32 -DAPPLE_CC -o $@.bin -Wall -Werror $< -nostdlib -O2 -I$(srcdir)/efiemu/runtime -I$(srcdir)/include -Iinclude
|
|
$(OBJCONV) -felf32 -nu -nd $@.bin $@
|
|
-rm -f $@.bin
|
|
else
|
|
$(TARGET_CC) -c -m32 -DELF32 -o $@ -Wall -Werror $< -nostdlib -O2 -I$(srcdir)/efiemu/runtime -I$(srcdir)/include -Iinclude
|
|
if test ! -z $(TARGET_OBJ2ELF); then ./$(TARGET_OBJ2ELF) $@ || (rm -f $@; exit 1); fi
|
|
endif
|
|
|
|
efiemu64_c.o: efiemu/runtime/efiemu.c
|
|
ifeq ($(TARGET_APPLE_CC), 1)
|
|
$(TARGET_CC) -c -m64 -DAPPLE_CC=1 -DELF64 -o $@ -Wall -Werror $< -nostdlib -mno-red-zone -O2 -I$(srcdir)/efiemu/runtime -I$(srcdir)/include -Iinclude
|
|
else
|
|
$(TARGET_CC) -c -m64 -DELF64 -o $@ -Wall -Werror $< -nostdlib -mcmodel=large -mno-red-zone -O2 -I$(srcdir)/efiemu/runtime -I$(srcdir)/include -Iinclude
|
|
endif
|
|
|
|
efiemu64_s.o: efiemu/runtime/efiemu.S
|
|
-rm -f $@
|
|
ifeq ($(TARGET_APPLE_CC), 1)
|
|
$(TARGET_CC) -c -m64 -DAPPLE_CC=1 -DELF64 -o $@ -Wall -Werror $< -nostdlib -mno-red-zone -O2 -I$(srcdir)/efiemu/runtime -I$(srcdir)/include -Iinclude
|
|
else
|
|
$(TARGET_CC) -c -m64 -DELF64 -o $@ -Wall -Werror $< -nostdlib -mcmodel=large -mno-red-zone -O2 -I$(srcdir)/efiemu/runtime -I$(srcdir)/include -Iinclude
|
|
endif
|
|
|
|
efiemu64.o: efiemu64_c.o efiemu64_s.o $(TARGET_OBJ2ELF)
|
|
-rm -f $@
|
|
ifeq ($(TARGET_APPLE_CC), 1)
|
|
-rm -f $@.bin
|
|
$(TARGET_CC) -m64 -o $@.bin -Wl,-r $^ -nostdlib
|
|
$(OBJCONV) -felf64 -nu -nd $@.bin $@
|
|
-rm -f $@.bin
|
|
else
|
|
$(TARGET_CC) -m64 -o $@ -Wl,-r $^ -nostdlib
|
|
if test ! -z $(TARGET_OBJ2ELF); then ./$(TARGET_OBJ2ELF) $@ || (rm -f $@; exit 1); fi
|
|
endif
|
|
|
|
CLEANFILES += efiemu32.o efiemu64.o efiemu64_c.o efiemu64_s.o
|
|
pkglib_DATA += efiemu32.o efiemu64.o
|
|
|
|
endif
|
|
|
|
linux.init.x86_64: $(srcdir)/tests/boot/linux.init-x86_64.S
|
|
$(TARGET_CC) -o $@ $< -m64 -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\"
|
|
|
|
linux.init.i386: $(srcdir)/tests/boot/linux.init-i386.S
|
|
$(TARGET_CC) -o $@ $< -m32 -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\"
|
|
|
|
kfreebsd.init.x86_64: $(srcdir)/tests/boot/kfreebsd.init-x86_64.S
|
|
$(TARGET_CC) -o $@ $< -m64 -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" && freebsd-brandelf -t FreeBSD $@
|
|
|
|
kfreebsd.init.i386: $(srcdir)/tests/boot/kfreebsd.init-i386.S
|
|
$(TARGET_CC) -o $@ $< -m32 -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" && freebsd-brandelf -t FreeBSD $@
|
|
|
|
knetbsd.init.i386: $(srcdir)/tests/boot/knetbsd.init-i386.S
|
|
$(TARGET_CC) -o $@ $< -m32 -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\"
|
|
|
|
knetbsd.init.x86_64: $(srcdir)/tests/boot/knetbsd.init-x86_64.S
|
|
$(TARGET_CC) -o $@ $< -m64 -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\"
|
|
|
|
linux-initramfs.%: linux.init.% Makefile
|
|
TDIR=`mktemp -d`; cp $< $$TDIR/init; (cd $$TDIR; echo ./init | cpio --quiet --dereference -o -H newc) | gzip > $@; rm -rf $$TDIR
|
|
|
|
%.gz: %.img
|
|
gzip < $< > $@
|
|
|
|
kfreebsd-mfsroot.%.img: kfreebsd.init.% Makefile
|
|
TDIR=`mktemp -d`; mkdir $$TDIR/dev; mkdir $$TDIR/sbin; cp $< $$TDIR/sbin/init; makefs -t ffs -s 30m -f 1000 -o minfree=0,version=1 $@ $$TDIR; rm -rf $$TDIR
|
|
|
|
knetbsd.image.%: knetbsd.init.%
|
|
TDIR=`mktemp -d` && mkdir $$TDIR/dev && mkdir $$TDIR/sbin && cp $< $$TDIR/sbin/init && makefs -t ffs -s 64k -f 10 -o minfree=0,version=1 $@ $$TDIR && rm -rf $$TDIR
|
|
|
|
knetbsd.miniroot-image.i386.img: knetbsd.image.i386 $(GRUB_PAYLOADS_DIR)/knetbsd.miniroot.i386
|
|
$(OBJCOPY) --add-section=miniroot=$< $(GRUB_PAYLOADS_DIR)/knetbsd.miniroot.i386 $@
|
|
|
|
knetbsd.miniroot-image.x86_64.img: knetbsd.image.x86_64 $(GRUB_PAYLOADS_DIR)/knetbsd.miniroot.x86_64
|
|
$(OBJCOPY) --add-section=miniroot=$< $(GRUB_PAYLOADS_DIR)/knetbsd.miniroot.x86_64 $@
|
|
|
|
CLEANFILES += linux.init.i386 kfreebsd.init.i386 linux.init.x86_64 linux-initramfs.i386 linux-initramfs.x86_64
|
|
|
|
bootcheck-kfreebsd-i386: kfreebsd-mfsroot.i386.gz $(GRUB_PAYLOADS_DIR)/kfreebsd.i386 $(GRUB_PAYLOADS_DIR)/kfreebsd_env.i386 $(srcdir)/tests/boot/kfreebsd.cfg grub-shell
|
|
timeout -s KILL $(BOOTCHECK_TIMEOUT) ./grub-shell --qemu-opts="$(GRUB_QEMU_OPTS)" --boot=$(BOOTTARGET) --qemu=$(QEMU32) --files=/mfsroot.gz=kfreebsd-mfsroot.i386.gz --files=/kfreebsd=$(GRUB_PAYLOADS_DIR)/kfreebsd.i386 --files=/kfreebsd_env=$(GRUB_PAYLOADS_DIR)/kfreebsd_env.i386 $(srcdir)/tests/boot/kfreebsd.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
|
|
|
|
bootcheck-kfreebsd-x86_64: kfreebsd-mfsroot.x86_64.gz $(GRUB_PAYLOADS_DIR)/kfreebsd.x86_64 $(GRUB_PAYLOADS_DIR)/kfreebsd_env.x86_64 $(srcdir)/tests/boot/kfreebsd.cfg grub-shell
|
|
timeout -s KILL $(BOOTCHECK_TIMEOUT) ./grub-shell --qemu-opts="$(GRUB_QEMU_OPTS)" --boot=$(BOOTTARGET) --qemu=qemu-system-x86_64 --files=/mfsroot.gz=kfreebsd-mfsroot.x86_64.gz --files=/kfreebsd=$(GRUB_PAYLOADS_DIR)/kfreebsd.x86_64 --files=/kfreebsd_env=$(GRUB_PAYLOADS_DIR)/kfreebsd_env.x86_64 $(srcdir)/tests/boot/kfreebsd.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
|
|
|
|
bootcheck-knetbsd-i386: knetbsd.miniroot-image.i386.gz $(GRUB_PAYLOADS_DIR)/knetbsd.i386 $(srcdir)/tests/boot/knetbsd.cfg grub-shell
|
|
timeout -s KILL $(BOOTCHECK_TIMEOUT) ./grub-shell --qemu-opts="$(GRUB_QEMU_OPTS)" --boot=$(BOOTTARGET) --qemu=qemu-system-i386 --files=/miniroot.gz=knetbsd.miniroot-image.i386.gz --files=/knetbsd=$(GRUB_PAYLOADS_DIR)/knetbsd.i386 $(srcdir)/tests/boot/knetbsd.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
|
|
|
|
bootcheck-knetbsd-x86_64: knetbsd.miniroot-image.x86_64.gz $(GRUB_PAYLOADS_DIR)/knetbsd.x86_64 $(srcdir)/tests/boot/knetbsd.cfg grub-shell
|
|
timeout -s KILL $(BOOTCHECK_TIMEOUT) ./grub-shell --qemu-opts="$(GRUB_QEMU_OPTS)" --boot=$(BOOTTARGET) --qemu=qemu-system-x86_64 --files=/miniroot.gz=knetbsd.miniroot-image.x86_64.gz --files=/knetbsd=$(GRUB_PAYLOADS_DIR)/knetbsd.x86_64 $(srcdir)/tests/boot/knetbsd.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
|
|
|
|
bootcheck-linux-i386: linux-initramfs.i386 $(GRUB_PAYLOADS_DIR)/linux.i386 $(srcdir)/tests/boot/linux.cfg grub-shell
|
|
timeout -s KILL $(BOOTCHECK_TIMEOUT) ./grub-shell --qemu-opts="$(GRUB_QEMU_OPTS)" --boot=$(BOOTTARGET) --qemu=$(QEMU32) --files=/initrd=linux-initramfs.i386 --files=/linux=$(GRUB_PAYLOADS_DIR)/linux.i386 $(srcdir)/tests/boot/linux.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
|
|
|
|
bootcheck-linux-x86_64: linux-initramfs.x86_64 $(GRUB_PAYLOADS_DIR)/linux.x86_64 $(srcdir)/tests/boot/linux.cfg grub-shell
|
|
timeout -s KILL $(BOOTCHECK_TIMEOUT) ./grub-shell --qemu-opts="$(GRUB_QEMU_OPTS)" --boot=$(BOOTTARGET) --qemu=qemu-system-x86_64 --files=/initrd=linux-initramfs.x86_64 --files=/linux=$(GRUB_PAYLOADS_DIR)/linux.x86_64 $(srcdir)/tests/boot/linux.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
|
|
|
|
BOOTCHECKS += bootcheck-linux-i386 bootcheck-linux-x86_64
|
|
|
|
ifneq ($(platform), coreboot)
|
|
# Crashes because memory at 0-0x1000 is occupied
|
|
BOOTCHECKS += bootcheck-kfreebsd-i386 bootcheck-knetbsd-x86_64
|
|
endif
|
|
|
|
ifeq ($(platform), pc)
|
|
# Requires ACPI
|
|
BOOTCHECKS += bootcheck-kfreebsd-x86_64
|
|
# Crashes early on non-BIOS
|
|
BOOTCHECKS += bootcheck-knetbsd-i386
|
|
endif
|
|
|
|
.PHONY: bootcheck-linux-i386 bootcheck-linux-x86_64 \
|
|
bootcheck-kfreebsd-i386 bootcheck-kfreebsd-x86_64 \
|
|
bootcheck-knetbsd-i386 bootcheck-knetbsd-x86_64
|
|
|