blob: c6a9cd0cf4eb717153650641c297b08203a38c6a [file] [log] [blame]
Iru Caie44b4072016-04-15 13:42:11 +08001LIBPAYLOAD_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"
Martin Roth9d8b2ff2016-04-23 17:19:41 -06006CFLAGS += -Wall -Werror -Os -ffreestanding -nostdinc -nostdlib
Denis 'GNUtoo' Carikli7d824992016-01-25 09:20:24 +01007
8all: nvramcui.elf
9
Martin Roth9d8b2ff2016-04-23 17:19:41 -060010$(LIBPAYLOAD_DIR):
Iru Caie44b4072016-04-15 13:42:11 +080011 $(MAKE) -C ../libpayload $(LPOPTS) defconfig
12 $(MAKE) -C ../libpayload $(LPOPTS)
13 $(MAKE) -C ../libpayload $(LPOPTS) install
14
15ifneq ($(strip $(wildcard libpayload)),)
16include $(XCOMPILE)
17LPGCC = CC="$(GCC_CC_x86_32)" "$(LIBPAYLOAD_DIR)/bin/lpgcc"
Martin Roth9d8b2ff2016-04-23 17:19:41 -060018%.elf: %.c Makefile
19 $(LPGCC) $(CFLAGS) -o $*.elf $*.c
Iru Caie44b4072016-04-15 13:42:11 +080020else
21# If libpayload is not found, first build libpayload,
22# then do the make, this time it'll find libpayload
23# and generate the nvramcui.elf target
Martin Roth9d8b2ff2016-04-23 17:19:41 -060024%.elf: $(LIBPAYLOAD_DIR)
Iru Caie44b4072016-04-15 13:42:11 +080025 $(MAKE) all
26endif
Denis 'GNUtoo' Carikli7d824992016-01-25 09:20:24 +010027
Denis 'GNUtoo' Carikli7d824992016-01-25 09:20:24 +010028clean:
29 rm -f nvramcui.elf
Martin Rothc3fbda42016-03-07 16:40:14 -070030
31distclean: clean
Martin Roth9d8b2ff2016-04-23 17:19:41 -060032 rm -rf build libpayload .config .config.old
33
34.PHONY: all clean distclean