Makefile 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. # This file is part of the OpenADK project. OpenADK is copyrighted
  2. # material, please see the LICENCE file in the top-level directory.
  3. #
  4. # Steps to build toolchains
  5. # 1) build and install binutils
  6. # 2) build and install mpfr, mpc, libelf and gmp
  7. # 3) build and install gcc c compiler
  8. # 4) install kernel-headers
  9. # 5) install libc headers
  10. # 6) build and install full gcc
  11. # 7) build and install full libc
  12. # 8) build and install gdb debugger
  13. include $(TOPDIR)/rules.mk
  14. TARGETS:=binutils gmp mpfr mpc libelf gcc
  15. ifeq ($(ADK_TARGET_LIB_GLIBC),y)
  16. TARGETS+=glibc-ports glibc
  17. LIBC:=glibc
  18. endif
  19. ifeq ($(ADK_TARGET_LIB_EGLIBC),y)
  20. TARGETS+=eglibc
  21. LIBC:=eglibc
  22. endif
  23. ifeq ($(ADK_TARGET_LIB_UCLIBC),y)
  24. TARGETS+=uClibc
  25. LIBC:=uClibc
  26. endif
  27. ifeq ($(ADK_TOOLCHAIN_GDB),y)
  28. TARGETS+=gdb
  29. endif
  30. DOWNLOAD:=kernel-headers-download $(patsubst %,%-download,$(TARGETS))
  31. TARGETS_INSTALL:=$(patsubst %,%-install,$(TARGETS))
  32. FIXUP:=$(patsubst %,%-fixup,$(LIBC))
  33. TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS))
  34. install: $(TARGETS_INSTALL)
  35. clean: $(TARGETS_CLEAN)
  36. download: $(DOWNLOAD)
  37. fixup: $(FIXUP)
  38. gcc-prepare: binutils-install gmp-install mpfr-install mpc-install libelf-install
  39. ifeq ($(ADK_TARGET_LIB_GLIBC),y)
  40. $(LIBC)-prepare: gcc-prepare kernel-headers-prepare glibc-ports-prepare
  41. else
  42. $(LIBC)-prepare: gcc-prepare kernel-headers-prepare
  43. endif
  44. gcc-configure: $(LIBC)-prepare
  45. $(LIBC)-compile: gcc-configure
  46. gcc-compile: $(LIBC)-install
  47. ifeq ($(ADK_TOOLCHAIN_GDB),y)
  48. $(LIBC)-fixup: gdb-install
  49. else
  50. $(LIBC)-fixup: gcc-install
  51. endif
  52. $(STAGING_HOST_DIR):
  53. @mkdir -p $(STAGING_HOST_DIR)/lib
  54. @mkdir -p $(STAGING_HOST_DIR)/include
  55. @mkdir -p $(STAGING_HOST_DIR)/$(REAL_GNU_TARGET_NAME)
  56. @ln -sf ../lib $(STAGING_HOST_DIR)/$(REAL_GNU_TARGET_NAME)/lib
  57. %-download:
  58. $(TRACE) toolchain/$(patsubst %-download,%,$@)/download
  59. $(MAKE) -C $(patsubst %-download,%,$@) fetch
  60. %-prepare: $(STAGING_HOST_DIR)
  61. $(TRACE) toolchain/$(patsubst %-prepare,%,$@)/prepare
  62. @if test x"$(patsubst %-prepare,%,$@)" = x"$(LIBC)"; then \
  63. $(MAKE) -C $(patsubst %-prepare,%,$@) prepare \
  64. $(MAKE_TRACE); \
  65. else \
  66. $(MAKE) -C $(patsubst %-prepare,%,$@) prepare \
  67. CC='$(CC_FOR_BUILD)' CFLAGS='$(CFLAGS_FOR_BUILD)' \
  68. $(MAKE_TRACE); \
  69. fi
  70. %-configure: %-prepare
  71. $(TRACE) toolchain/$(patsubst %-configure,%,$@)/configure
  72. @if test x"$(patsubst %-configure,%,$@)" = x"$(LIBC)"; then \
  73. $(MAKE) -C $(patsubst %-configure,%,$@) configure \
  74. $(MAKE_TRACE); \
  75. else \
  76. $(MAKE) -C $(patsubst %-configure,%,$@) configure \
  77. CC='$(CC_FOR_BUILD)' CFLAGS='$(CFLAGS_FOR_BUILD)' \
  78. $(MAKE_TRACE); \
  79. fi
  80. %-compile: %-configure
  81. $(TRACE) toolchain/$(patsubst %-compile,%,$@)/compile
  82. @if test x"$(patsubst %-compile,%,$@)" = x"$(LIBC)"; then \
  83. $(MAKE) -C $(patsubst %-compile,%,$@) compile \
  84. $(MAKE_TRACE); \
  85. else \
  86. $(MAKE) -C $(patsubst %-compile,%,$@) compile \
  87. CC='$(CC_FOR_BUILD)' CFLAGS='$(CFLAGS_FOR_BUILD)' \
  88. $(MAKE_TRACE); \
  89. fi
  90. %-install: %-compile
  91. $(TRACE) toolchain/$(patsubst %-install,%,$@)/install
  92. @if test x"$(patsubst %-install,%,$@)" = x"$(LIBC)"; then \
  93. $(MAKE) -C $(patsubst %-install,%,$@) install \
  94. $(MAKE_TRACE); \
  95. else \
  96. $(MAKE) -C $(patsubst %-install,%,$@) install \
  97. CC='$(CC_FOR_BUILD)' CFLAGS='$(CFLAGS_FOR_BUILD)' \
  98. $(MAKE_TRACE); \
  99. fi
  100. %-fixup: %-install
  101. $(TRACE) toolchain/$(patsubst %-fixup,%,$@)/fixup
  102. @$(MAKE) -C $(patsubst %-fixup,%,$@) fixup $(MAKE_TRACE)
  103. %-clean:
  104. $(TRACE) toolchain/$(patsubst %-clean,%,$@)/clean
  105. @$(MAKE) -C $(patsubst %-clean,%,$@) clean $(MAKE_TRACE)