summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorIan M. <ian@aptel.org>2026-09-11 03:45:03 +0000
committerIan M. <ian@aptel.org>2026-09-11 03:46:03 +0000
commit4f97daf67e0baaf64251b5643af5c9552c522156 (patch)
treea9a45abcf288fa538b03fb566d2ee5c069b2af4e /Makefile
initial commit
Signed-off-by: Ian M. <ian@aptel.org>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile67
1 files changed, 67 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..2eb84ed
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,67 @@
+#
+# Copyright (c) 2026, Apollo Telephone Laboratories.
+# Provided under the BSD-3 clause.
+#
+
+CFILES = $(shell find core/ -name "*.c")
+OFILES = $(CFILES:.c=.o)
+DFILES = $(CFILES:.c=.d)
+
+CC = gcc
+LD = ld
+
+CFLAGS = \
+ -Wall \
+ -MMD \
+ -pedantic \
+ -fpic \
+ -ffreestanding \
+ -fno-stack-protector \
+ -fno-stack-check \
+ -fshort-wchar \
+ -mno-red-zone \
+ -maccumulate-outgoing-args \
+ -Ihead \
+ -Ignu-efi/inc
+
+LDFLAGS = \
+ -shared \
+ -Bsymbolic \
+ -Lgnu-efi/x86_64/lib \
+ -Lgnu-efi/x86_64/gnuefi \
+ -Tgnu-efi/gnuefi/elf_x86_64_efi.lds \
+ gnu-efi/x86_64/gnuefi/crt0-efi-x86_64.o
+
+OBJCOPY_FLAGS = \
+ -j .text \
+ -j .sdata \
+ -j .data \
+ -j .rodata \
+ -j .dynamic \
+ -j .dynsym \
+ -j .rel \
+ -j .rela \
+ -j .rel.* \
+ -j .rela.* \
+ -j .reloc \
+ --output-target efi-app-x86_64 \
+ --subsystem=10
+
+.PHONY: all
+all: prebuild gnu-efi $(OFILES)
+ ld $(LDFLAGS) $(OFILES) -lgnuefi -lefi -o main.so
+ objcopy $(OBJCOPY_FLAGS) main.so BOOTX64.EFI
+ rm -f *.so
+
+.PHONY: prebuild
+prebuild:
+ echo -e "/* Generated by build; DO NOT edit */\n" >head/sboot/config.h
+ cat config.def.h >>head/sboot/config.h
+
+gnu-efi:
+ git clone https://github.com/ncroxon/gnu-efi.git
+ cd gnu-efi; make
+
+-include $(DFILES)
+%.o: %.c
+ $(CC) -c $(CFLAGS) $< -o $@