Makefile 1.3 KB

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