xref: /aosp_15_r20/external/coreboot/payloads/linuxcheck/Makefile (revision b9411a12aaaa7e1e6a6fb7c5e057f44ee179a49c)
1LIBPAYLOAD_DIR=$(CURDIR)/libpayload
2XCOMPILE=$(LIBPAYLOAD_DIR)/libpayload.xcompile
3# build libpayload and put .config file in $(CURDIR) instead of ../libpayload
4# to avoid pollute the libpayload source directory and possible conflicts
5LPOPTS=obj="$(CURDIR)/build" DESTDIR="$(CURDIR)" DOTCONFIG="$(CURDIR)/.config"
6CFLAGS += -Wall -Wvla -Werror -Os -ffreestanding -nostdinc -nostdlib
7ifeq ($(CONFIG_ARCH_X86),y)
8TARGETARCH = i386
9endif
10
11all: linuxcheck.elf
12
13$(LIBPAYLOAD_DIR):
14	$(MAKE) -C ../libpayload $(LPOPTS) defconfig
15	$(MAKE) -C ../libpayload $(LPOPTS)
16	$(MAKE) -C ../libpayload $(LPOPTS) install
17
18ifneq ($(strip $(wildcard libpayload)),)
19include $(XCOMPILE)
20LPGCC = CC="$(GCC_CC_x86_32)" "$(LIBPAYLOAD_DIR)/bin/lpgcc"
21%.elf: %.c Makefile
22	$(LPGCC) $(CFLAGS) -o $*.elf $*.c $(TARGETARCH).c
23else
24# If libpayload is not found, first build libpayload,
25# then do the make, this time it'll find libpayload
26# and generate the linuxcheck.elf target
27%.elf: $(LIBPAYLOAD_DIR)
28	$(MAKE) all
29endif
30
31clean:
32	rm -f linuxcheck.elf
33
34distclean: clean
35	rm -rf build libpayload .config .config.old
36
37.PHONY: all clean distclean
38