Iru Cai | e44b407 | 2016-04-15 13:42:11 +0800 | [diff] [blame] | 1 | LIBPAYLOAD_DIR=$(CURDIR)/libpayload |
| 2 | XCOMPILE=$(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 |
| 5 | LPOPTS=obj="$(CURDIR)/build" DESTDIR="$(CURDIR)" DOTCONFIG="$(CURDIR)/.config" |
Jacob Garber | 9cd53c5 | 2019-06-27 13:23:38 -0600 | [diff] [blame] | 6 | CFLAGS += -Wall -Wvla -Werror -Os -ffreestanding -nostdinc -nostdlib |
Denis 'GNUtoo' Carikli | 7d82499 | 2016-01-25 09:20:24 +0100 | [diff] [blame] | 7 | |
| 8 | all: nvramcui.elf |
| 9 | |
Martin Roth | 9d8b2ff | 2016-04-23 17:19:41 -0600 | [diff] [blame] | 10 | $(LIBPAYLOAD_DIR): |
Iru Cai | e44b407 | 2016-04-15 13:42:11 +0800 | [diff] [blame] | 11 | $(MAKE) -C ../libpayload $(LPOPTS) defconfig |
| 12 | $(MAKE) -C ../libpayload $(LPOPTS) |
| 13 | $(MAKE) -C ../libpayload $(LPOPTS) install |
| 14 | |
| 15 | ifneq ($(strip $(wildcard libpayload)),) |
| 16 | include $(XCOMPILE) |
| 17 | LPGCC = CC="$(GCC_CC_x86_32)" "$(LIBPAYLOAD_DIR)/bin/lpgcc" |
Martin Roth | 9d8b2ff | 2016-04-23 17:19:41 -0600 | [diff] [blame] | 18 | %.elf: %.c Makefile |
| 19 | $(LPGCC) $(CFLAGS) -o $*.elf $*.c |
Iru Cai | e44b407 | 2016-04-15 13:42:11 +0800 | [diff] [blame] | 20 | else |
| 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 Roth | 9d8b2ff | 2016-04-23 17:19:41 -0600 | [diff] [blame] | 24 | %.elf: $(LIBPAYLOAD_DIR) |
Iru Cai | e44b407 | 2016-04-15 13:42:11 +0800 | [diff] [blame] | 25 | $(MAKE) all |
| 26 | endif |
Denis 'GNUtoo' Carikli | 7d82499 | 2016-01-25 09:20:24 +0100 | [diff] [blame] | 27 | |
Denis 'GNUtoo' Carikli | 7d82499 | 2016-01-25 09:20:24 +0100 | [diff] [blame] | 28 | clean: |
| 29 | rm -f nvramcui.elf |
Martin Roth | c3fbda4 | 2016-03-07 16:40:14 -0700 | [diff] [blame] | 30 | |
| 31 | distclean: clean |
Martin Roth | 9d8b2ff | 2016-04-23 17:19:41 -0600 | [diff] [blame] | 32 | rm -rf build libpayload .config .config.old |
| 33 | |
| 34 | .PHONY: all clean distclean |