Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
67 lines (51 loc) · 1.92 KB
/
Copy pathMakefile
File metadata and controls
67 lines (51 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# SPDX-License-Identifier: MPL-2.0
# loli-loader
# /Makefile
# Copyright (c) 2024-2025 Yao Zi.
ARCH = $(shell uname -m)
CC = cc
CCAS = cc
CCLD = cc
PYTHON = python
CONFIG_$(ARCH) = yes
ARCHFLAGS_$(CONFIG_x86_64) = -DLOLI_TARGET_X86_64 -mgeneral-regs-only
# For AArch64, UEFI Specification 2.10 states
# Floating point and SIMD instructions may be used.
# But it's not sure whether it's widely followed among firmware. Let's try not
# to be the trouble maker.
ARCHFLAGS_$(CONFIG_aarch64) = -DLOLI_TARGET_AARCH64 -mgeneral-regs-only
# Notice for riscv64: UEFI requires extensions are checked before usage, so
# it's important not to pass a -march argument with baseline higher than your
# distribution's requirement.
ARCHFLAGS_$(CONFIG_riscv64) = -DLOLI_TARGET_RISCV64
# For LoongArch, UEFI Specification (again 2.10) states
# FP unit can be used(CSR.EUEN.FPE to enable), calling convention refer
# to 2.3.8.2.
# But it's unclear whether SIMD instructions (LSX, LASX) are allowed.
ARCHFLAGS_$(CONFIG_loongarch64) = -DLOLI_TARGET_LOONGARCH64 -mno-lsx -mno-lasx
ifeq ($(DEBUG),)
DEBUG_FLAGS := -O2
else
DEBUG_FLAGS := -O0 -g
endif
MYCFLAGS ?= -ffreestanding -fno-stack-protector -fno-stack-check \
-fPIE -fshort-wchar -static -nostdinc -std=c99 \
-Wall \
$(DEBUG_FLAGS) $(ARCHFLAGS_yes) $(CFLAGS)
MYCCASFLAGS ?= $(MYCFLAGS) $(CCASFLAGS)
MYLDFLAGS = -z noexecstack -z separate-code $(LDFLAGS)
OBJS = src/loli.o src/efi.o src/string.o src/interaction.o
OBJS += src/memory.o src/file.o src/misc.o src/extlinux.o
OBJS += src/eficall.o src/entry.o src/graphics.o src/serial.o
OBJS += src/font.o src/ctype.o src/fdt.o src/initrd.o src/menu.o
default: loli.efi
loli.efi: loli.elf
$(PYTHON) tools/elf2efi.py loli.elf loli.efi
loli.elf: $(OBJS)
$(CCLD) -fPIE -o $@ $(MYLDFLAGS) $(OBJS) -nodefaultlibs -nostartfiles
%.o: %.c
$(CC) $(MYCFLAGS) -c $< -o $@ -Iinclude
%.o: %.S
$(CCAS) $(MYCCASFLAGS) -c $< -o $@
clean:
-rm $(OBJS)