arch = x86_64 # $(shell uname -m | sed s,i[3456789]86,ia32,)
prefix = # /usr/bin/x86_64-pc-linux-gnu-
cc = $(prefix)gcc
ld = $(prefix)ld
oc = $(prefix)objcopy
inc = /usr/include/efi
lib = /usr/lib
crt = ./gnuefi
cflags = -fshort-wchar -I$(inc) -I$(inc)/$(arch) -I/usr/include -O2 -Wall -fpic -DEFI_FUNCTION_WRAPPER -ffreestanding -nostdlib -c
crtobj = $(crt)/crt0-efi-$(arch).o
ldsobj = $(crt)/elf_$(arch)_efi.lds
lflags = -T$(ldsobj) -shared -Bsymbolic -L$(lib) $(crtobj) -nostdlib -znocombreloc
lodlib = -lefi -lgnuefi $(shell $(cc) -print-libgcc-file-name)
format = efi-app-$(arch)
%.efi: %.so
$(oc) -j .text -j .sdata -j .data -j .dynamic -j .dynsym -j .rel -j .rela -j .reloc --target=$(format) $^ $@
%.so: %.o
$(ld) $(lflags) $^ -o $@ $(lodlib)
%.o: %.c
$(cc) $(cflags) $^ -o $@
%.o: %.S
$(cc) $(cflags) $^ -o $@
#
org 0x07C00
jmp boot_entry
nop
boot_entry:
mov ax, 3
int 16
mov ah, 2
mov al, 10
mov cx, 2
mov bx, 0x07E00
mov bp, 0
mov es, bp
int 13h
mov sp, 7E0h
mov bp, 7E00h
mov ds, bp
jmp 0000:7E00h
cli
hlt
jmp $-2
times 510-$+$$ db 00h
dw 0AA55h