Ronald G. Minnich | 95c331b | 2018-09-14 01:21:05 -0700 | [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 |
Ronald G. Minnich | 95c331b | 2018-09-14 01:21:05 -0700 | [diff] [blame] | 7 | ifeq ($(CONFIG_ARCH_X86),y) |
| 8 | TARGETARCH = i386 |
| 9 | endif |
| 10 | |
| 11 | all: linuxcheck.elf |
| 12 | |
| 13 | $(LIBPAYLOAD_DIR): |
| 14 | $(MAKE) -C ../libpayload $(LPOPTS) defconfig |
| 15 | $(MAKE) -C ../libpayload $(LPOPTS) |
| 16 | $(MAKE) -C ../libpayload $(LPOPTS) install |
| 17 | |
| 18 | ifneq ($(strip $(wildcard libpayload)),) |
| 19 | include $(XCOMPILE) |
| 20 | LPGCC = CC="$(GCC_CC_x86_32)" "$(LIBPAYLOAD_DIR)/bin/lpgcc" |
| 21 | %.elf: %.c Makefile |
| 22 | $(LPGCC) $(CFLAGS) -o $*.elf $*.c $(TARGETARCH).c |
| 23 | else |
| 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 |
| 29 | endif |
| 30 | |
| 31 | clean: |
| 32 | rm -f linuxcheck.elf |
| 33 | |
| 34 | distclean: clean |
| 35 | rm -rf build libpayload .config .config.old |
| 36 | |
| 37 | .PHONY: all clean distclean |