2021-03-08 05:05:39 +03:00
|
|
|
TARGET =
|
|
|
|
BUILDDIR =
|
|
|
|
|
|
|
|
ifeq ($(BUILDDIR), )
|
|
|
|
$(error BUILDDIR not specified)
|
|
|
|
endif
|
2021-03-02 12:23:43 +03:00
|
|
|
|
|
|
|
ifeq ($(TARGET), bios)
|
2021-08-07 08:26:34 +03:00
|
|
|
OBJCOPY_ARCH := elf32-i386
|
2021-03-02 12:23:43 +03:00
|
|
|
else ifeq ($(TARGET), uefi)
|
2021-08-07 08:26:34 +03:00
|
|
|
OBJCOPY_ARCH := elf64-x86-64
|
2021-07-20 14:35:43 +03:00
|
|
|
else ifeq ($(TARGET), uefi32)
|
2021-08-07 08:26:34 +03:00
|
|
|
OBJCOPY_ARCH := elf32-i386
|
2021-03-02 12:23:43 +03:00
|
|
|
else
|
2021-03-04 07:15:20 +03:00
|
|
|
$(error Invalid target)
|
2021-03-02 12:23:43 +03:00
|
|
|
endif
|
|
|
|
|
2021-08-07 08:26:34 +03:00
|
|
|
TOOLCHAIN ?= limine
|
2021-04-03 01:48:38 +03:00
|
|
|
|
2021-08-07 08:26:34 +03:00
|
|
|
TOOLCHAIN_CC ?= $(TOOLCHAIN)-gcc
|
|
|
|
TOOLCHAIN_LD ?= $(TOOLCHAIN)-ld
|
|
|
|
TOOLCHAIN_AR ?= $(TOOLCHAIN)-ar
|
|
|
|
TOOLCHAIN_OBJCOPY ?= $(TOOLCHAIN)-objcopy
|
|
|
|
TOOLCHAIN_OBJDUMP ?= $(TOOLCHAIN)-objdump
|
|
|
|
TOOLCHAIN_READELF ?= $(TOOLCHAIN)-readelf
|
2021-04-08 20:41:46 +03:00
|
|
|
|
2021-06-30 19:22:50 +03:00
|
|
|
ifeq ($(shell command -v $(TOOLCHAIN_CC) ; ), )
|
2021-08-07 08:26:34 +03:00
|
|
|
override TOOLCHAIN_CC := cc
|
2021-04-08 20:41:46 +03:00
|
|
|
endif
|
2021-06-30 19:22:50 +03:00
|
|
|
ifeq ($(shell command -v $(TOOLCHAIN_LD) ; ), )
|
2021-08-07 08:26:34 +03:00
|
|
|
override TOOLCHAIN_LD := ld
|
2021-05-31 01:32:43 +03:00
|
|
|
endif
|
2021-06-30 22:58:11 +03:00
|
|
|
ifeq ($(shell command -v $(TOOLCHAIN_AR) ; ), )
|
2021-08-07 08:26:34 +03:00
|
|
|
override TOOLCHAIN_AR := ar
|
2021-06-30 22:58:11 +03:00
|
|
|
endif
|
2021-06-30 19:22:50 +03:00
|
|
|
ifeq ($(shell command -v $(TOOLCHAIN_OBJCOPY) ; ), )
|
2021-08-07 08:26:34 +03:00
|
|
|
override TOOLCHAIN_OBJCOPY := objcopy
|
2021-04-08 20:41:46 +03:00
|
|
|
endif
|
2021-06-30 19:22:50 +03:00
|
|
|
ifeq ($(shell command -v $(TOOLCHAIN_OBJDUMP) ; ), )
|
2021-08-07 08:26:34 +03:00
|
|
|
override TOOLCHAIN_OBJDUMP := objdump
|
2021-04-08 20:41:46 +03:00
|
|
|
endif
|
2021-06-30 19:22:50 +03:00
|
|
|
ifeq ($(shell command -v $(TOOLCHAIN_READELF) ; ), )
|
2021-08-07 08:26:34 +03:00
|
|
|
override TOOLCHAIN_READELF := readelf
|
2021-04-08 20:41:46 +03:00
|
|
|
endif
|
2020-01-22 01:45:13 +03:00
|
|
|
|
2021-02-26 03:30:27 +03:00
|
|
|
COM_OUTPUT = false
|
|
|
|
E9_OUTPUT = false
|
|
|
|
|
2021-07-26 17:09:03 +03:00
|
|
|
BUILD_ID := $(shell dd if=/dev/urandom count=8 bs=1 2>/dev/null | od -An -t x4 | sed 's/^ /0x/g;s/ //g')
|
2021-07-01 00:14:15 +03:00
|
|
|
LIMINE_VERSION := $(shell cat ../version 2>/dev/null || ( git describe --exact-match --tags `git log -n1 --pretty='%h'` 2>/dev/null || ( git log -n1 --pretty='%h' && echo -n "(`git branch --show-current`)" ) ) )
|
2021-08-22 19:29:18 +03:00
|
|
|
LIMINE_COPYRIGHT := $(shell grep Copyright LICENSE.md)
|
2021-04-03 23:12:40 +03:00
|
|
|
|
2020-10-18 07:23:39 +03:00
|
|
|
WERROR = -Werror
|
2021-08-07 08:26:34 +03:00
|
|
|
CFLAGS ?= -O3 -g -pipe -Wall -Wextra $(WERROR)
|
2021-07-31 22:28:06 +03:00
|
|
|
|
|
|
|
S2CFLAGS := $(CFLAGS) -Os
|
2020-09-13 15:36:18 +03:00
|
|
|
|
2021-03-02 08:05:14 +03:00
|
|
|
INTERNAL_CFLAGS := \
|
2020-09-17 15:37:22 +03:00
|
|
|
-std=gnu11 \
|
2020-01-22 01:45:13 +03:00
|
|
|
-ffreestanding \
|
2020-09-13 15:36:18 +03:00
|
|
|
-fno-stack-protector \
|
2020-11-15 19:56:10 +03:00
|
|
|
-fno-omit-frame-pointer \
|
2021-03-02 12:23:43 +03:00
|
|
|
-fno-lto \
|
2021-04-02 17:45:14 +03:00
|
|
|
-fno-pic \
|
2020-09-21 13:46:42 +03:00
|
|
|
-Wno-address-of-packed-member \
|
2021-07-06 06:17:18 +03:00
|
|
|
-Wshadow \
|
2021-05-22 11:26:56 +03:00
|
|
|
-mno-80387 \
|
|
|
|
-mno-mmx \
|
|
|
|
-mno-3dnow \
|
|
|
|
-mno-sse \
|
|
|
|
-mno-sse2 \
|
2020-09-21 13:46:42 +03:00
|
|
|
-MMD \
|
2021-02-25 10:45:03 +03:00
|
|
|
-DBUILD_ID=$(BUILD_ID) \
|
2020-12-31 01:42:39 +03:00
|
|
|
-DLIMINE_VERSION='"$(LIMINE_VERSION)"' \
|
2021-08-22 19:29:18 +03:00
|
|
|
-DLIMINE_COPYRIGHT='"$(LIMINE_COPYRIGHT)"' \
|
2021-02-26 03:30:27 +03:00
|
|
|
-DCOM_OUTPUT=$(COM_OUTPUT) \
|
|
|
|
-DE9_OUTPUT=$(E9_OUTPUT) \
|
2020-04-29 17:53:05 +03:00
|
|
|
-I. \
|
2020-09-21 13:46:42 +03:00
|
|
|
-I..
|
2020-01-22 01:45:13 +03:00
|
|
|
|
2021-03-04 07:15:20 +03:00
|
|
|
ifeq ($(TARGET), bios)
|
|
|
|
INTERNAL_CFLAGS += \
|
2021-07-15 11:03:47 +03:00
|
|
|
-Dbios=1 \
|
|
|
|
-Duefi=0 \
|
2021-04-03 01:48:38 +03:00
|
|
|
-m32 \
|
|
|
|
-march=i386 \
|
2021-07-31 22:28:06 +03:00
|
|
|
-mabi=sysv \
|
2021-04-02 17:45:14 +03:00
|
|
|
-fno-pie
|
2021-03-04 07:15:20 +03:00
|
|
|
endif
|
|
|
|
|
2021-03-02 12:23:43 +03:00
|
|
|
ifeq ($(TARGET), uefi)
|
2021-05-03 02:08:31 +03:00
|
|
|
INTERNAL_CFLAGS32 := \
|
|
|
|
$(INTERNAL_CFLAGS) \
|
2021-07-15 11:03:47 +03:00
|
|
|
-Dbios=0 \
|
|
|
|
-Duefi=1 \
|
2021-05-03 02:08:31 +03:00
|
|
|
-m32 \
|
|
|
|
-march=i386 \
|
2021-07-31 22:28:06 +03:00
|
|
|
-mabi=sysv \
|
2021-05-03 02:08:31 +03:00
|
|
|
-fpie
|
|
|
|
|
2021-03-02 12:23:43 +03:00
|
|
|
INTERNAL_CFLAGS += \
|
2021-07-15 11:03:47 +03:00
|
|
|
-Dbios=0 \
|
|
|
|
-Duefi=1 \
|
2021-04-03 01:48:38 +03:00
|
|
|
-m64 \
|
|
|
|
-march=x86-64 \
|
2021-07-31 22:28:06 +03:00
|
|
|
-mabi=sysv \
|
2021-03-02 12:23:43 +03:00
|
|
|
-I../gnu-efi/inc \
|
|
|
|
-I../gnu-efi/inc/x86_64 \
|
2021-04-02 17:45:14 +03:00
|
|
|
-fpie \
|
2021-03-04 07:15:20 +03:00
|
|
|
-mno-red-zone
|
2021-03-02 12:23:43 +03:00
|
|
|
endif
|
|
|
|
|
2021-07-20 14:35:43 +03:00
|
|
|
ifeq ($(TARGET), uefi32)
|
|
|
|
INTERNAL_CFLAGS += \
|
|
|
|
-Dbios=0 \
|
|
|
|
-Duefi=1 \
|
|
|
|
-m32 \
|
|
|
|
-march=i386 \
|
2021-07-31 22:28:06 +03:00
|
|
|
-mabi=sysv \
|
2021-07-20 14:35:43 +03:00
|
|
|
-I../gnu-efi/inc \
|
|
|
|
-I../gnu-efi/inc/ia32 \
|
|
|
|
-fpie
|
|
|
|
endif
|
|
|
|
|
2021-08-07 08:26:34 +03:00
|
|
|
LDFLAGS ?=
|
2020-09-13 15:36:18 +03:00
|
|
|
|
2021-03-02 08:05:14 +03:00
|
|
|
INTERNAL_LDFLAGS := \
|
2020-01-22 01:45:13 +03:00
|
|
|
-nostdlib \
|
2021-03-02 12:23:43 +03:00
|
|
|
-z max-page-size=0x1000
|
|
|
|
|
|
|
|
ifeq ($(TARGET), bios)
|
|
|
|
INTERNAL_LDFLAGS += \
|
2021-05-31 01:32:43 +03:00
|
|
|
-melf_i386 \
|
|
|
|
-static
|
2021-03-02 12:23:43 +03:00
|
|
|
endif
|
2020-01-22 01:45:13 +03:00
|
|
|
|
2021-04-02 17:45:14 +03:00
|
|
|
ifeq ($(TARGET), uefi)
|
|
|
|
INTERNAL_LDFLAGS += \
|
2021-05-31 01:32:43 +03:00
|
|
|
-melf_x86_64 \
|
|
|
|
-static \
|
|
|
|
-pie \
|
|
|
|
--no-dynamic-linker \
|
|
|
|
-ztext
|
2021-04-02 17:45:14 +03:00
|
|
|
endif
|
|
|
|
|
2021-07-20 14:35:43 +03:00
|
|
|
ifeq ($(TARGET), uefi32)
|
|
|
|
INTERNAL_LDFLAGS += \
|
|
|
|
-melf_i386 \
|
|
|
|
-static \
|
|
|
|
-pie \
|
|
|
|
--no-dynamic-linker \
|
|
|
|
-ztext
|
|
|
|
endif
|
|
|
|
|
2021-03-08 02:50:23 +03:00
|
|
|
.PHONY: all clean builddir
|
2020-01-22 01:45:13 +03:00
|
|
|
|
2021-02-21 07:01:18 +03:00
|
|
|
C_FILES := $(shell find -L ./ -type f -name '*.c' | sort)
|
2021-03-02 12:23:43 +03:00
|
|
|
ifeq ($(TARGET), bios)
|
2021-02-21 07:01:18 +03:00
|
|
|
ASM_FILES := $(shell find -L ./ -type f -name '*.asm' | sort)
|
2021-03-13 11:48:11 +03:00
|
|
|
OBJ := $(addprefix $(BUILDDIR)/, $(ASM_FILES:.asm=.o) $(C_FILES:.c=.o))
|
2021-03-02 12:23:43 +03:00
|
|
|
endif
|
2021-03-07 02:52:25 +03:00
|
|
|
ifeq ($(TARGET), uefi)
|
2021-03-13 11:48:11 +03:00
|
|
|
ASM_FILES := $(shell find -L ./ -type f -name '*.asm64' | sort)
|
|
|
|
OBJ := $(addprefix $(BUILDDIR)/, $(ASM_FILES:.asm64=.o) $(C_FILES:.c=.o))
|
2021-03-07 02:52:25 +03:00
|
|
|
endif
|
2021-07-20 14:35:43 +03:00
|
|
|
ifeq ($(TARGET), uefi32)
|
|
|
|
ASM_FILES := $(shell find -L ./ -type f -name '*.asm32' | sort)
|
|
|
|
OBJ := $(addprefix $(BUILDDIR)/, $(ASM_FILES:.asm32=.o) $(C_FILES:.c=.o))
|
|
|
|
endif
|
2021-03-08 02:50:23 +03:00
|
|
|
HEADER_DEPS := $(addprefix $(BUILDDIR)/, $(C_FILES:.c=.d))
|
2020-01-22 01:45:13 +03:00
|
|
|
|
2021-03-02 12:23:43 +03:00
|
|
|
ifeq ($(TARGET), bios)
|
2021-03-08 05:05:39 +03:00
|
|
|
all:
|
|
|
|
$(MAKE) builddir
|
|
|
|
$(MAKE) $(BUILDDIR)/limine_dbg.elf $(BUILDDIR)/limine.sys $(BUILDDIR)/stage2.bin $(BUILDDIR)/stage2.bin.gz
|
2021-03-02 12:23:43 +03:00
|
|
|
else ifeq ($(TARGET), uefi)
|
2021-03-08 05:05:39 +03:00
|
|
|
all:
|
|
|
|
$(MAKE) builddir
|
|
|
|
$(MAKE) $(BUILDDIR)/BOOTX64.EFI
|
2021-07-20 14:35:43 +03:00
|
|
|
else ifeq ($(TARGET), uefi32)
|
|
|
|
all:
|
|
|
|
$(MAKE) builddir
|
|
|
|
$(MAKE) $(BUILDDIR)/BOOTIA32.EFI
|
2021-03-02 12:23:43 +03:00
|
|
|
endif
|
|
|
|
|
2021-03-08 02:50:23 +03:00
|
|
|
builddir:
|
|
|
|
for i in $(OBJ); do mkdir -p `dirname $$i`; done
|
2021-02-22 22:43:51 +03:00
|
|
|
|
2021-03-08 02:50:23 +03:00
|
|
|
$(BUILDDIR)/sys/smp_trampoline.bin: sys/smp_trampoline.real
|
|
|
|
nasm $< -f bin -o $@
|
|
|
|
|
|
|
|
$(BUILDDIR)/sys/smp_trampoline.o: $(BUILDDIR)/sys/smp_trampoline.bin
|
|
|
|
cd "`dirname $<`" && \
|
2021-04-08 20:41:46 +03:00
|
|
|
$(TOOLCHAIN_OBJCOPY) -B i8086 -I binary -O $(OBJCOPY_ARCH) "`basename $<`" $@
|
2021-03-08 02:50:23 +03:00
|
|
|
|
|
|
|
$(BUILDDIR)/font.o: font.bin
|
|
|
|
cd "`dirname $<`" && \
|
2021-04-08 20:41:46 +03:00
|
|
|
$(TOOLCHAIN_OBJCOPY) -B i8086 -I binary -O $(OBJCOPY_ARCH) "`basename $<`" $@
|
2021-03-08 02:50:23 +03:00
|
|
|
|
|
|
|
ifeq ($(TARGET), bios)
|
|
|
|
|
|
|
|
$(BUILDDIR)/stage2.bin.gz: $(BUILDDIR)/stage2.bin
|
|
|
|
gzip -n -9 < $< > $@
|
2021-02-21 01:04:06 +03:00
|
|
|
|
2021-03-08 02:50:23 +03:00
|
|
|
$(BUILDDIR)/stage2.bin: $(BUILDDIR)/limine.sys
|
2021-04-08 20:41:46 +03:00
|
|
|
dd if=$< bs=$$(( 0x$$($(TOOLCHAIN_READELF) -S $(BUILDDIR)/limine.elf | grep .stage3.text | sed 's/^.*] //' | awk '{print $$3}' | sed 's/^0*//') - 0x8000 )) count=1 of=$@
|
2021-02-21 01:04:06 +03:00
|
|
|
|
2021-03-12 07:19:56 +03:00
|
|
|
$(BUILDDIR)/stage2.map.o: $(BUILDDIR)/limine_stage2only.elf
|
2021-03-08 02:50:23 +03:00
|
|
|
GENSYMS="`pwd`/gensyms.sh" && \
|
|
|
|
cd "`dirname $<`" && \
|
2021-04-08 20:41:46 +03:00
|
|
|
"$$GENSYMS" $(TOOLCHAIN_OBJDUMP) $< stage2 32
|
2021-03-12 07:19:56 +03:00
|
|
|
|
|
|
|
$(BUILDDIR)/full.map.o: $(BUILDDIR)/limine_nomap.elf
|
|
|
|
GENSYMS="`pwd`/gensyms.sh" && \
|
|
|
|
cd "`dirname $<`" && \
|
2021-04-08 20:41:46 +03:00
|
|
|
"$$GENSYMS" $(TOOLCHAIN_OBJDUMP) $< full 32
|
2020-01-22 01:45:13 +03:00
|
|
|
|
2021-03-08 02:50:23 +03:00
|
|
|
$(BUILDDIR)/limine.sys: $(BUILDDIR)/limine.elf
|
2021-04-08 20:41:46 +03:00
|
|
|
$(TOOLCHAIN_OBJCOPY) -O binary $< $@
|
2020-11-15 19:56:10 +03:00
|
|
|
|
2021-03-12 07:19:56 +03:00
|
|
|
$(BUILDDIR)/limine_stage2only.elf: $(OBJ)
|
2021-05-31 01:32:43 +03:00
|
|
|
$(TOOLCHAIN_LD) $^ $(LDFLAGS) $(INTERNAL_LDFLAGS) -Tlinker_stage2only.ld -o $@ || \
|
2021-05-04 14:56:00 +03:00
|
|
|
( echo "This error may mean that stage 2 was trying to use stage 3 symbols before loading stage 3" && \
|
2021-02-25 13:28:14 +03:00
|
|
|
false )
|
2021-02-25 03:24:54 +03:00
|
|
|
|
2021-03-12 07:19:56 +03:00
|
|
|
$(BUILDDIR)/limine_nomap.elf: $(OBJ) $(BUILDDIR)/font.o $(BUILDDIR)/sys/smp_trampoline.o $(BUILDDIR)/stage2.map.o
|
2021-05-31 01:32:43 +03:00
|
|
|
$(TOOLCHAIN_LD) $^ $(LDFLAGS) $(INTERNAL_LDFLAGS) -Tlinker_nomap.ld -o $@
|
2021-03-12 07:19:56 +03:00
|
|
|
|
|
|
|
$(BUILDDIR)/limine.elf: $(OBJ) $(BUILDDIR)/font.o $(BUILDDIR)/sys/smp_trampoline.o $(BUILDDIR)/stage2.map.o $(BUILDDIR)/full.map.o
|
2021-05-31 01:32:43 +03:00
|
|
|
$(TOOLCHAIN_LD) $^ $(LDFLAGS) $(INTERNAL_LDFLAGS) -Tlinker.ld -o $@
|
2021-03-04 07:15:20 +03:00
|
|
|
|
2021-03-12 07:19:56 +03:00
|
|
|
$(BUILDDIR)/limine_dbg.elf: $(OBJ) $(BUILDDIR)/font.o $(BUILDDIR)/sys/smp_trampoline.o $(BUILDDIR)/stage2.map.o $(BUILDDIR)/full.map.o
|
2021-05-31 01:32:43 +03:00
|
|
|
$(TOOLCHAIN_LD) $^ $(LDFLAGS) $(INTERNAL_LDFLAGS) -Tlinker_dbg.ld -o $@
|
2021-03-04 07:15:20 +03:00
|
|
|
|
2021-03-08 02:50:23 +03:00
|
|
|
endif
|
2021-03-03 23:40:55 +03:00
|
|
|
|
2021-07-20 14:35:43 +03:00
|
|
|
$(BUILDDIR)/gnu-efi:
|
|
|
|
cp -r ../gnu-efi $(BUILDDIR)/
|
2021-07-25 17:23:36 +03:00
|
|
|
# gnu-efi's build system is broken and fails to actually detect clang.
|
|
|
|
# This is a workaround.
|
2021-07-26 17:09:03 +03:00
|
|
|
sed 's/-maccumulate-outgoing-args//g' < "$(BUILDDIR)/gnu-efi/Make.defaults" > sed.tmp
|
|
|
|
mv sed.tmp "$(BUILDDIR)/gnu-efi/Make.defaults"
|
2021-07-20 14:35:43 +03:00
|
|
|
|
2021-03-08 02:50:23 +03:00
|
|
|
ifeq ($(TARGET), uefi)
|
2021-03-02 08:05:14 +03:00
|
|
|
|
2021-04-08 02:15:35 +03:00
|
|
|
$(BUILDDIR)/full.map.o: $(BUILDDIR)/limine_efi_nomap.elf
|
|
|
|
GENSYMS="`pwd`/gensyms.sh" && \
|
|
|
|
cd "`dirname $<`" && \
|
2021-04-08 20:41:46 +03:00
|
|
|
"$$GENSYMS" $(TOOLCHAIN_OBJDUMP) $< full 64
|
2021-04-08 02:15:35 +03:00
|
|
|
|
2021-03-08 02:50:23 +03:00
|
|
|
$(BUILDDIR)/BOOTX64.EFI: $(BUILDDIR)/limine_efi.elf
|
2021-06-25 02:23:26 +03:00
|
|
|
$(TOOLCHAIN_OBJCOPY) -j .text -j .sdata -j .data -j .dynamic -j .dynsym -j .rel -j .rela -j .rel.* -j .rela.* -j .reloc -j .sbat --target efi-app-x86_64 --subsystem=10 $< $@
|
2021-03-04 07:15:20 +03:00
|
|
|
|
2021-07-20 14:35:43 +03:00
|
|
|
$(BUILDDIR)/gnu-efi/gnuefi/crt0-efi-x86_64.o $(BUILDDIR)/gnu-efi/gnuefi/libgnuefi.a: $(BUILDDIR)/gnu-efi
|
|
|
|
$(MAKE) -C $(BUILDDIR)/gnu-efi/gnuefi CC="$(TOOLCHAIN_CC) -m64 -march=x86-64" AR="$(TOOLCHAIN_AR)" ARCH=x86_64
|
2021-06-30 22:58:11 +03:00
|
|
|
|
2021-07-20 14:35:43 +03:00
|
|
|
$(BUILDDIR)/gnu-efi/lib/x86_64/efi_stub.o: $(BUILDDIR)/gnu-efi
|
|
|
|
$(MAKE) -C $(BUILDDIR)/gnu-efi/lib CC="$(TOOLCHAIN_CC) -m64 -march=x86-64" ARCH=x86_64 x86_64/efi_stub.o
|
2021-06-30 22:58:11 +03:00
|
|
|
|
2021-07-20 14:35:43 +03:00
|
|
|
$(BUILDDIR)/limine_efi_nomap.elf: $(BUILDDIR)/gnu-efi/gnuefi/crt0-efi-x86_64.o $(BUILDDIR)/gnu-efi/gnuefi/libgnuefi.a $(BUILDDIR)/gnu-efi/lib/x86_64/efi_stub.o $(OBJ) $(BUILDDIR)/font.o $(BUILDDIR)/sys/smp_trampoline.o
|
2021-05-31 01:32:43 +03:00
|
|
|
$(TOOLCHAIN_LD) \
|
2021-04-08 02:15:35 +03:00
|
|
|
-Tlinker_uefi_nomap.ld \
|
|
|
|
$^ $(LDFLAGS) $(INTERNAL_LDFLAGS) -o $@
|
|
|
|
|
2021-07-20 14:35:43 +03:00
|
|
|
$(BUILDDIR)/limine_efi.elf: $(BUILDDIR)/gnu-efi/gnuefi/crt0-efi-x86_64.o $(BUILDDIR)/gnu-efi/gnuefi/libgnuefi.a $(BUILDDIR)/gnu-efi/lib/x86_64/efi_stub.o $(OBJ) $(BUILDDIR)/font.o $(BUILDDIR)/sys/smp_trampoline.o $(BUILDDIR)/full.map.o
|
2021-05-31 01:32:43 +03:00
|
|
|
$(TOOLCHAIN_LD) \
|
2021-04-08 02:15:35 +03:00
|
|
|
-Tlinker_uefi.ld \
|
2021-04-02 17:45:14 +03:00
|
|
|
$^ $(LDFLAGS) $(INTERNAL_LDFLAGS) -o $@
|
2021-03-08 02:50:23 +03:00
|
|
|
|
|
|
|
endif
|
2020-01-22 01:45:13 +03:00
|
|
|
|
2021-07-20 14:35:43 +03:00
|
|
|
ifeq ($(TARGET), uefi32)
|
|
|
|
|
|
|
|
$(BUILDDIR)/full.map.o: $(BUILDDIR)/limine_efi_nomap.elf
|
|
|
|
GENSYMS="`pwd`/gensyms.sh" && \
|
|
|
|
cd "`dirname $<`" && \
|
|
|
|
"$$GENSYMS" $(TOOLCHAIN_OBJDUMP) $< full 32
|
|
|
|
|
|
|
|
$(BUILDDIR)/BOOTIA32.EFI: $(BUILDDIR)/limine_efi.elf
|
|
|
|
$(TOOLCHAIN_OBJCOPY) -j .text -j .sdata -j .data -j .dynamic -j .dynsym -j .rel -j .rela -j .rel.* -j .rela.* -j .reloc -j .sbat --target efi-app-ia32 --subsystem=10 $< $@
|
|
|
|
|
|
|
|
$(BUILDDIR)/gnu-efi/gnuefi/crt0-efi-ia32.o $(BUILDDIR)/gnu-efi/gnuefi/libgnuefi.a: $(BUILDDIR)/gnu-efi
|
|
|
|
$(MAKE) -C $(BUILDDIR)/gnu-efi/gnuefi CC="$(TOOLCHAIN_CC) -m32 -march=i386" AR="$(TOOLCHAIN_AR)" ARCH=ia32
|
|
|
|
|
|
|
|
$(BUILDDIR)/gnu-efi/lib/ia32/efi_stub.o: $(BUILDDIR)/gnu-efi
|
|
|
|
$(MAKE) -C $(BUILDDIR)/gnu-efi/lib CC="$(TOOLCHAIN_CC) -m32 -march=i386" ARCH=ia32 ia32/efi_stub.o
|
|
|
|
|
|
|
|
$(BUILDDIR)/limine_efi_nomap.elf: $(BUILDDIR)/gnu-efi/gnuefi/crt0-efi-ia32.o $(BUILDDIR)/gnu-efi/gnuefi/libgnuefi.a $(BUILDDIR)/gnu-efi/lib/ia32/efi_stub.o $(OBJ) $(BUILDDIR)/font.o $(BUILDDIR)/sys/smp_trampoline.o
|
|
|
|
$(TOOLCHAIN_LD) \
|
|
|
|
-Tlinker_uefi32_nomap.ld \
|
|
|
|
$^ $(LDFLAGS) $(INTERNAL_LDFLAGS) -o $@
|
|
|
|
|
|
|
|
$(BUILDDIR)/limine_efi.elf: $(BUILDDIR)/gnu-efi/gnuefi/crt0-efi-ia32.o $(BUILDDIR)/gnu-efi/gnuefi/libgnuefi.a $(BUILDDIR)/gnu-efi/lib/ia32/efi_stub.o $(OBJ) $(BUILDDIR)/font.o $(BUILDDIR)/sys/smp_trampoline.o $(BUILDDIR)/full.map.o
|
|
|
|
$(TOOLCHAIN_LD) \
|
|
|
|
-Tlinker_uefi32.ld \
|
|
|
|
$^ $(LDFLAGS) $(INTERNAL_LDFLAGS) -o $@
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
2020-09-21 13:46:42 +03:00
|
|
|
-include $(HEADER_DEPS)
|
|
|
|
|
2021-03-08 05:05:39 +03:00
|
|
|
$(BUILDDIR)/%.o: %.c
|
2021-04-08 20:41:46 +03:00
|
|
|
$(TOOLCHAIN_CC) $(CFLAGS) $(INTERNAL_CFLAGS) -c $< -o $@
|
2020-01-22 01:45:13 +03:00
|
|
|
|
2021-03-13 11:48:11 +03:00
|
|
|
-include $(HEADER_DEPS)
|
|
|
|
|
2021-03-05 01:12:40 +03:00
|
|
|
ifeq ($(TARGET), bios)
|
2021-03-08 05:05:39 +03:00
|
|
|
$(BUILDDIR)/%.s2.o: %.s2.c
|
2021-04-08 20:41:46 +03:00
|
|
|
$(TOOLCHAIN_CC) $(S2CFLAGS) $(INTERNAL_CFLAGS) -c $< -o $@
|
2021-03-05 01:12:40 +03:00
|
|
|
endif
|
|
|
|
|
2021-03-13 11:48:11 +03:00
|
|
|
-include $(HEADER_DEPS)
|
|
|
|
|
2021-03-07 02:52:25 +03:00
|
|
|
ifeq ($(TARGET), uefi)
|
2021-03-08 05:05:39 +03:00
|
|
|
$(BUILDDIR)/%.32.o: %.32.c
|
2021-04-08 20:41:46 +03:00
|
|
|
$(TOOLCHAIN_CC) $(CFLAGS) $(INTERNAL_CFLAGS32) -c $< -o $@.32
|
|
|
|
$(TOOLCHAIN_OBJCOPY) -I elf32-i386 -O elf64-x86-64 $@.32 $@
|
2021-03-07 02:52:25 +03:00
|
|
|
rm $@.32
|
|
|
|
endif
|
|
|
|
|
2021-07-06 00:28:04 +03:00
|
|
|
ifeq ($(TARGET), bios)
|
2021-03-08 05:05:39 +03:00
|
|
|
$(BUILDDIR)/%.o: %.asm
|
2021-04-11 11:00:57 +03:00
|
|
|
nasm $< -F dwarf -g -Werror -f elf32 -o $@
|
2021-07-06 00:28:04 +03:00
|
|
|
endif
|
2021-03-13 11:48:11 +03:00
|
|
|
|
2021-07-06 00:28:04 +03:00
|
|
|
ifeq ($(TARGET), uefi)
|
2021-03-13 11:48:11 +03:00
|
|
|
$(BUILDDIR)/%.o: %.asm64
|
2021-04-11 11:00:57 +03:00
|
|
|
nasm $< -F dwarf -g -Werror -f elf64 -o $@
|
2021-07-06 00:28:04 +03:00
|
|
|
endif
|
2020-09-04 02:37:24 +03:00
|
|
|
|
2021-07-20 14:35:43 +03:00
|
|
|
ifeq ($(TARGET), uefi32)
|
|
|
|
$(BUILDDIR)/%.o: %.asm32
|
|
|
|
nasm $< -F dwarf -g -Werror -f elf32 -o $@
|
|
|
|
endif
|
|
|
|
|
2020-01-22 01:45:13 +03:00
|
|
|
clean:
|
2021-03-08 02:50:23 +03:00
|
|
|
rm -rf $(BUILDDIR)
|