| 1 |
# |
| 2 |
# Purgatory (an uncomfortable intermediate state) |
| 3 |
# In this case the code that runs between kernels |
| 4 |
# |
| 5 |
|
| 6 |
# There is probably a cleaner way to do this but for now this |
| 7 |
# should keep us from accidentially include unsafe library functions |
| 8 |
# or headers. |
| 9 |
|
| 10 |
PURGATORY = purgatory/purgatory.ro |
| 11 |
PURGATORY_SRCS = |
| 12 |
PURGATORY_SRCS += purgatory/purgatory.c |
| 13 |
PURGATORY_SRCS += purgatory/printf.c |
| 14 |
PURGATORY_SRCS += purgatory/string.c |
| 15 |
PURGATORY_MAP = purgatory/purgatory.map |
| 16 |
|
| 17 |
dist += purgatory/Makefile $(PURGATORY_SRCS) \ |
| 18 |
purgatory/include/purgatory.h purgatory/include/string.h |
| 19 |
|
| 20 |
include $(srcdir)/purgatory/arch/alpha/Makefile |
| 21 |
include $(srcdir)/purgatory/arch/arm/Makefile |
| 22 |
include $(srcdir)/purgatory/arch/arm64/Makefile |
| 23 |
include $(srcdir)/purgatory/arch/i386/Makefile |
| 24 |
include $(srcdir)/purgatory/arch/ia64/Makefile |
| 25 |
include $(srcdir)/purgatory/arch/mips/Makefile |
| 26 |
include $(srcdir)/purgatory/arch/ppc/Makefile |
| 27 |
include $(srcdir)/purgatory/arch/ppc64/Makefile |
| 28 |
include $(srcdir)/purgatory/arch/riscv/Makefile |
| 29 |
include $(srcdir)/purgatory/arch/s390/Makefile |
| 30 |
include $(srcdir)/purgatory/arch/sh/Makefile |
| 31 |
include $(srcdir)/purgatory/arch/x86_64/Makefile |
| 32 |
include $(srcdir)/purgatory/arch/loongarch/Makefile |
| 33 |
|
| 34 |
PURGATORY_SRCS+=$($(ARCH)_PURGATORY_SRCS) |
| 35 |
|
| 36 |
PURGATORY_OBJS = $(call objify, $(PURGATORY_SRCS)) purgatory/sha256.o |
| 37 |
PURGATORY_DEPS = $(call depify, $(PURGATORY_OBJS)) |
| 38 |
|
| 39 |
clean += $(PURGATORY_OBJS) $(PURGATORY_DEPS) $(PURGATORY) $(PURGATORY_MAP) $(PURGATORY).sym |
| 40 |
|
| 41 |
-include $(PURGATORY_DEPS) |
| 42 |
|
| 43 |
purgatory/sha256.o: CFLAGS += -O2 $($(ARCH)_PURGATORY_SHA256_CFLAGS) |
| 44 |
|
| 45 |
purgatory/sha256.o: $(srcdir)/util_lib/sha256.c |
| 46 |
mkdir -p $(@D) |
| 47 |
$(COMPILE.c) -o $@ $^ |
| 48 |
|
| 49 |
$(PURGATORY): CC=$(TARGET_CC) |
| 50 |
$(PURGATORY): CFLAGS=$(PURGATORY_EXTRA_CFLAGS) \ |
| 51 |
$($(ARCH)_PURGATORY_EXTRA_CFLAGS) \ |
| 52 |
-Os -fno-builtin -ffreestanding \ |
| 53 |
-fno-zero-initialized-in-bss \ |
| 54 |
-fno-PIC -fno-PIE -fno-stack-protector -fno-tree-vectorize |
| 55 |
|
| 56 |
$(PURGATORY): CPPFLAGS=$($(ARCH)_PURGATORY_EXTRA_CFLAGS) \ |
| 57 |
-I$(srcdir)/purgatory/include \ |
| 58 |
-I$(srcdir)/purgatory/arch/$(ARCH)/include \ |
| 59 |
-I$(srcdir)/util_lib/include \ |
| 60 |
-I$(srcdir)/include \ |
| 61 |
-Iinclude \ |
| 62 |
-I$(shell $(CC) -print-file-name=include) |
| 63 |
$(PURGATORY): LDFLAGS=$($(ARCH)_PURGATORY_EXTRA_CFLAGS)\ |
| 64 |
-Wl,--no-undefined -nostartfiles -nostdlib \ |
| 65 |
-nodefaultlibs -e purgatory_start -r \ |
| 66 |
-Wl,-Map=$(PURGATORY_MAP) |
| 67 |
|
| 68 |
$(PURGATORY): $(PURGATORY_OBJS) |
| 69 |
$(MKDIR) -p $(@D) |
| 70 |
$(CC) $(CFLAGS) $(LDFLAGS) -o [email protected] $^ |
| 71 |
# $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) --no-undefined -e purgatory_start -r -o $@ $(PURGATORY_OBJS) $(UTIL_LIB) |
| 72 |
$(STRIP) --strip-debug -o $@ [email protected] |
| 73 |
|
| 74 |
echo:: |
| 75 |
@echo "PURGATORY_SRCS $(PURGATORY_SRCS)" |
| 76 |
@echo "PURGATORY_DEPS $(PURGATORY_DEPS)" |
| 77 |
@echo "PURGATORY_OBJS $(PURGATORY_OBJS)" |