1
0

host.mk 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #
  2. # Copyright (C) 2007-2015 OpenWrt.org
  3. #
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. TMP_DIR ?= $(TOPDIR)/tmp
  8. ifeq ($(if $(TARGET_BUILD),,$(DUMP)),)
  9. -include $(TMP_DIR)/.host.mk
  10. endif
  11. ifneq ($(__host_inc),1)
  12. __host_inc:=1
  13. export PATH:=$(TOPDIR)/staging_dir/host/bin:$(PATH)
  14. try-run = $(shell set -e; \
  15. TMP_F="$(TMP_DIR)/try-run.$$$$.tmp"; \
  16. if ($(1)) >/dev/null 2>&1; then echo "$(2)"; else echo "$(3)"; fi; \
  17. rm -f "$$TMP_F"; \
  18. )
  19. host-cc-option = $(call try-run, \
  20. $(HOSTCC) $(HOST_CFLAGS) $(1) -c -xc /dev/null -o "$$TMP_F",$(1),$(2) \
  21. )
  22. .PRECIOUS: $(TMP_DIR)/.host.mk
  23. $(TMP_DIR)/.host.mk: $(TOPDIR)/include/host.mk
  24. @mkdir -p $(TMP_DIR)
  25. @( \
  26. HOST_OS=`uname`; \
  27. case "$$HOST_OS" in \
  28. Linux) HOST_ARCH=`uname -m`;; \
  29. Darwin) HOST_ARCH=`uname -m`;; \
  30. *) HOST_ARCH=`uname -p`;; \
  31. esac; \
  32. GNU_HOST_NAME=`gcc -dumpmachine`; \
  33. [ -z "$$GNU_HOST_NAME" -o "$$HOST_OS" = "Darwin" ] && \
  34. GNU_HOST_NAME=`$(TOPDIR)/scripts/config.guess`; \
  35. echo "HOST_OS:=$$HOST_OS" > $@; \
  36. echo "HOST_ARCH:=$$HOST_ARCH" >> $@; \
  37. echo "GNU_HOST_NAME:=$$GNU_HOST_NAME" >> $@; \
  38. if gfind -L /dev/null || find -L /dev/null; then \
  39. echo "FIND_L=find -L \$$(1)" >> $@; \
  40. else \
  41. echo "FIND_L=find \$$(1) -follow" >> $@; \
  42. fi \
  43. ) >/dev/null 2>/dev/null
  44. endif