1
0

Makefile 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #
  2. # Copyright (C) 2007-2009 OpenWrt.org
  3. #
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. # Main makefile for the toolchain
  8. #
  9. # Steps:
  10. # 1) toolchain/binutils/compile
  11. # build & install binutils
  12. # 2) toolchain/gcc/minimal/compile
  13. # build & install a minimal gcc, needed for steps 3 & 4
  14. # 3) toolchain/kernel-headers/compile
  15. # install kernel headers, needed for step 4
  16. # 4) toolchain/libc/headers/compile
  17. # build & install libc headers & support files, needed for step 5
  18. # 5) toolchain/gcc/initial/compile
  19. # build & install an initial gcc, needed for step 6
  20. # 6) toolchain/libc/compile
  21. # build & install the final libc
  22. # 7) toolchain/gcc/final/compile
  23. # build & install the final gcc
  24. # 8) toolchain/libc/utils/compile
  25. # build & install libc utilities
  26. #
  27. # For musl, steps 2 and 4 are skipped, and step 3 is done after 5
  28. curdir:=toolchain
  29. # subdirectories to descend into
  30. $(curdir)/builddirs := $(if $(CONFIG_GDB),gdb) $(if $(CONFIG_EXTERNAL_TOOLCHAIN),wrapper,kernel-headers binutils gcc/initial gcc/final $(LIBC) fortify-headers) $(if $(CONFIG_NASM),nasm)
  31. ifdef CONFIG_USE_UCLIBC
  32. $(curdir)/builddirs += $(LIBC)/utils
  33. endif
  34. # builddir dependencies
  35. ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
  36. ifdef CONFIG_USE_MUSL
  37. $(curdir)/kernel-headers/compile:=$(curdir)/gcc/initial/compile
  38. $(curdir)/$(LIBC)/compile:=$(curdir)/kernel-headers/compile
  39. else
  40. $(curdir)/builddirs += $(LIBC)/headers gcc/minimal
  41. $(curdir)/gcc/minimal/compile:=$(curdir)/binutils/compile
  42. $(curdir)/kernel-headers/compile:=$(curdir)/gcc/minimal/compile
  43. $(curdir)/$(LIBC)/headers/compile:=$(curdir)/kernel-headers/compile
  44. $(curdir)/gcc/initial/compile:=$(curdir)/$(LIBC)/headers/compile
  45. endif
  46. $(curdir)/gcc/initial/compile+=$(curdir)/binutils/compile
  47. $(curdir)/$(LIBC)/compile:=$(curdir)/gcc/initial/compile
  48. $(curdir)/gcc/final/compile:=$(curdir)/$(LIBC)/compile
  49. $(curdir)/$(LIBC)/utils/compile:=$(curdir)/gcc/final/compile
  50. endif
  51. ifndef DUMP_TARGET_DB
  52. ifneq ($(ARCH),)
  53. $(TOOLCHAIN_DIR)/info.mk: .config
  54. @for dir in $(TOOLCHAIN_DIR); do ( \
  55. $(if $(QUIET),,set -x;) \
  56. mkdir -p "$$dir"; \
  57. cd "$$dir"; \
  58. ln -nsf lib lib64; \
  59. ln -nsf lib lib32; \
  60. mkdir -p stamp lib usr/include usr/lib ; \
  61. ); done
  62. @grep GCC_VERSION $@ >/dev/null 2>&1 || $(INSTALL_DATA) $(TOPDIR)/toolchain/info.mk $@
  63. @touch $@
  64. endif
  65. endif
  66. ifdef CONFIG_BUILDBOT
  67. ifneq ($(wildcard $(TOPDIR)/.git),)
  68. $(TOOLCHAIN_DIR)/stamp/.ver_check: $(TMP_DIR)/.build
  69. cd "$(TOPDIR)"; git log --format=%h -1 toolchain > $(TMP_DIR)/.ver_check
  70. cmp -s $(TMP_DIR)/.ver_check $@ || { \
  71. rm -rf $(BUILD_DIR) $(STAGING_DIR) $(TOOLCHAIN_DIR) $(BUILD_DIR_TOOLCHAIN); \
  72. mkdir -p $(TOOLCHAIN_DIR)/stamp; \
  73. mv $(TMP_DIR)/.ver_check $@; \
  74. }
  75. $(TOOLCHAIN_DIR)/info.mk $(STAGING_DIR)/.prepared: $(TOOLCHAIN_DIR)/stamp/.ver_check
  76. endif
  77. endif
  78. # prerequisites for the individual targets
  79. $(curdir)/ := .config prereq
  80. $(curdir)//compile = $(STAGING_DIR)/.prepared $(TOOLCHAIN_DIR)/info.mk $(tools/stamp-compile)
  81. ifndef DUMP_TARGET_DB
  82. $(TOOLCHAIN_DIR)/stamp/.gcc-initial_installed:
  83. endif
  84. $(curdir)/install: $(curdir)/compile
  85. $(eval $(call stampfile,$(curdir),toolchain,compile,$(TOOLCHAIN_DIR)/stamp/.gcc-initial_installed,,$(TOOLCHAIN_DIR)))
  86. $(eval $(call stampfile,$(curdir),toolchain,check,$(TMP_DIR)/.build))
  87. $(eval $(call subdir,$(curdir)))