blob: 838c90df0c989e459284a607a16d3e736d6bce89 [file] [log] [blame]
Ronald G. Minnich95c331b2018-09-14 01:21:05 -07001LIBPAYLOAD_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"
Jacob Garber9cd53c52019-06-27 13:23:38 -06006CFLAGS += -Wall -Wvla -Werror -Os -ffreestanding -nostdinc -nostdlib
Ronald G. Minnich95c331b2018-09-14 01:21:05 -07007ifeq ($(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