Makefile 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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/install
  11. # build & install binutils
  12. # 2) toolchain/gcc/minimal/install
  13. # build & install a minimal gcc, needed for steps 3 & 4
  14. # 3) toolchain/kernel-headers/install
  15. # install kernel headers, needed for step 4
  16. # 4) toolchain/libc/headers/install
  17. # build & install libc headers & support files, needed for step 5
  18. # 5) toolchain/gcc/initial/install
  19. # build & install an initial gcc, needed for step 6
  20. # 6) toolchain/libc/install
  21. # build & install the final libc
  22. # 7) toolchain/gcc/final/install
  23. # build & install the final gcc
  24. # 8) toolchain/libc/utils/install
  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_INSIGHT),insight) $(if $(CONFIG_EXTERNAL_TOOLCHAIN),wrapper,kernel-headers binutils gcc/initial gcc/final $(LIBC) fortify-headers) $(if $(CONFIG_YASM),yasm)
  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/install
  38. $(curdir)/$(LIBC)/compile:=$(curdir)/kernel-headers/install
  39. else
  40. $(curdir)/builddirs += $(LIBC)/headers gcc/minimal
  41. $(curdir)/gcc/minimal/compile:=$(curdir)/binutils/install
  42. $(curdir)/kernel-headers/compile:=$(curdir)/gcc/minimal/install
  43. $(curdir)/gcc/initial/prepare:=$(curdir)/gcc/minimal/prepare
  44. $(curdir)/$(LIBC)/prepare:=$(curdir)/$(LIBC)/headers/prepare
  45. $(curdir)/$(LIBC)/headers/compile:=$(curdir)/kernel-headers/install
  46. $(curdir)/gcc/initial/compile:=$(curdir)/$(LIBC)/headers/install
  47. endif
  48. $(curdir)/gcc/initial/compile+=$(curdir)/binutils/install
  49. $(curdir)/gcc/final/prepare:=$(curdir)/gcc/initial/prepare
  50. $(curdir)/$(LIBC)/compile:=$(curdir)/gcc/initial/install
  51. $(curdir)/gcc/final/compile:=$(curdir)/$(LIBC)/install
  52. $(curdir)/$(LIBC)/utils/compile:=$(curdir)/gcc/final/install
  53. $(curdir)/$(LIBC)/utils/prepare:=$(curdir)/$(LIBC)/headers/prepare
  54. endif
  55. $(curdir)/builddirs-compile:=$($(curdir)/builddirs-prepare)
  56. $(curdir)/builddirs-install:=$($(curdir)/builddirs-compile)
  57. ifndef DUMP_TARGET_DB
  58. ifneq ($(ARCH),)
  59. $(TOOLCHAIN_DIR)/info.mk: .config
  60. @for dir in $(TOOLCHAIN_DIR); do ( \
  61. $(if $(QUIET),,set -x;) \
  62. mkdir -p "$$dir"; \
  63. cd "$$dir"; \
  64. ln -nsf lib lib64; \
  65. ln -nsf lib lib32; \
  66. mkdir -p stamp lib usr/include usr/lib ; \
  67. ); done
  68. @grep GCC_VERSION $@ >/dev/null 2>&1 || $(INSTALL_DATA) $(TOPDIR)/toolchain/info.mk $@
  69. @touch $@
  70. endif
  71. endif
  72. # prerequisites for the individual targets
  73. $(curdir)/ := .config prereq
  74. $(curdir)//prepare = $(STAGING_DIR)/.prepared $(TOOLCHAIN_DIR)/info.mk $(tools/stamp-install)
  75. $(curdir)//compile = $(1)/prepare
  76. $(curdir)//install = $(1)/compile
  77. ifndef DUMP_TARGET_DB
  78. $(TOOLCHAIN_DIR)/stamp/.gcc-initial_installed:
  79. endif
  80. $(eval $(call stampfile,$(curdir),toolchain,install,$(TOOLCHAIN_DIR)/stamp/.gcc-initial_installed,,$(TOOLCHAIN_DIR)))
  81. $(eval $(call stampfile,$(curdir),toolchain,check,$(TMP_DIR)/.build))
  82. $(eval $(call subdir,$(curdir)))