Makefile 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. # Steps to build toolchains
  4. # 1) build and install binutils
  5. # 2) build and install mpfr, mpc, libelf and gmp
  6. # 3) build and install initial gcc
  7. # 4) install kernel-headers
  8. # 5) build and install full libc
  9. # 6) build and install full gcc
  10. # 7) build and install gdb debugger
  11. include $(ADK_TOPDIR)/rules.mk
  12. TARGETS:=binutils gmp mpfr mpc libelf
  13. ifeq ($(ADK_BUILD_COMPILER_GCC),y)
  14. TARGETS+=gcc
  15. COMPILER:=gcc
  16. endif
  17. ifeq ($(ADK_BUILD_COMPILER_LLVM),y)
  18. TARGETS+=llvm
  19. COMPILER:=llvm
  20. endif
  21. ifeq ($(ADK_TARGET_LIB_GLIBC),y)
  22. TARGETS+=glibc
  23. CLIB:=glibc
  24. endif
  25. ifeq ($(ADK_TARGET_LIB_UCLIBC_NG),y)
  26. TARGETS+=uclibc-ng
  27. CLIB:=uclibc-ng
  28. endif
  29. ifeq ($(ADK_TARGET_LIB_MUSL),y)
  30. TARGETS+=musl
  31. CLIB:=musl
  32. endif
  33. ifeq ($(ADK_TARGET_LIB_NEWLIB),y)
  34. TARGETS+=newlib
  35. CLIB:=newlib
  36. endif
  37. ifeq ($(ADK_TARGET_BINFMT_FLAT),y)
  38. TARGETS+=elf2flt
  39. ELF2FLT:=elf2flt-install
  40. endif
  41. ifeq ($(ADK_TOOLCHAIN_WITH_GDB),y)
  42. # disable gdb for some architectures
  43. ifeq ($(ADK_TARGET_ARCH_ARC)$(ADK_TARGET_ARCH_CR16)$(ADK_TARGET_ARCH_EPIPHANY)$(ADK_TARGET_ARCH_METAG)$(ADK_TARGET_ARCH_NDS32)$(ADK_TARGET_ARCH_OR1K),)
  44. TARGETS+=gdb
  45. GDB:=gdb-install
  46. endif
  47. endif
  48. ifeq (${ADK_PRELINK},y)
  49. TARGETS+=prelink-cross
  50. endif
  51. DOWNLOAD:=kernel-headers-download $(patsubst %,%-download,$(TARGETS))
  52. TARGETS_INSTALL:=$(patsubst %,%-install,$(TARGETS))
  53. FINAL:=$(patsubst %,%-final,$(COMPILER))
  54. TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS))
  55. install: $(TARGETS_INSTALL)
  56. clean: $(TARGETS_CLEAN)
  57. download: $(DOWNLOAD)
  58. final: $(FINAL)
  59. $(COMPILER)-configure: binutils-install gmp-install mpfr-install mpc-install libelf-install
  60. ifeq ($(ADK_TARGET_LIB_NEWLIB),y)
  61. $(CLIB)-install: $(COMPILER)-configure
  62. else
  63. $(CLIB)-install: $(COMPILER)-configure kernel-headers-configure
  64. endif
  65. $(COMPILER)-install: $(ELF2FLT) $(CLIB)-install
  66. $(COMPILER)-final: $(COMPILER)-install $(GDB)
  67. %-download:
  68. $(START_TRACE) "toolchain/$(patsubst %-download,%,$@)/download.. "
  69. $(MAKE) -C $(patsubst %-download,%,$@) fetch
  70. $(CMD_TRACE) " done"
  71. $(END_TRACE)
  72. %-prepare:
  73. $(START_TRACE) "toolchain/$(patsubst %-prepare,%,$@)/prepare.. "
  74. @if test x"$(patsubst %-prepare,%,$@)" = x"$(CLIB)"; then \
  75. $(MAKE) -C $(patsubst %-prepare,%,$@) prepare \
  76. $(MAKE_TRACE); \
  77. else \
  78. $(MAKE) -C $(patsubst %-prepare,%,$@) prepare \
  79. CC='$(HOST_CC)' CFLAGS='$(HOST_CFLAGS)' $(MAKE_TRACE); \
  80. fi
  81. $(CMD_TRACE) " done"
  82. $(END_TRACE)
  83. %-configure: %-prepare
  84. $(START_TRACE) "toolchain/$(patsubst %-configure,%,$@)/configure.. "
  85. @if test x"$(patsubst %-configure,%,$@)" = x"$(CLIB)"; then \
  86. $(MAKE) -C $(patsubst %-configure,%,$@) configure \
  87. $(MAKE_TRACE); \
  88. else \
  89. $(MAKE) -C $(patsubst %-configure,%,$@) configure \
  90. CC='$(HOST_CC)' CFLAGS='$(HOST_CFLAGS)' $(MAKE_TRACE); \
  91. fi
  92. $(CMD_TRACE) " done"
  93. $(END_TRACE)
  94. %-compile: %-configure
  95. $(START_TRACE) "toolchain/$(patsubst %-compile,%,$@)/compile.. "
  96. @if test x"$(patsubst %-compile,%,$@)" = x"$(CLIB)"; then \
  97. $(MAKE) -C $(patsubst %-compile,%,$@) compile \
  98. $(MAKE_TRACE); \
  99. else \
  100. $(MAKE) -C $(patsubst %-compile,%,$@) compile \
  101. CC='$(HOST_CC)' CFLAGS='$(HOST_CFLAGS)' CXXFLAGS='$(HOST_STATIC_CXXFLAGS)' $(MAKE_TRACE); \
  102. fi
  103. $(CMD_TRACE) " done"
  104. $(END_TRACE)
  105. %-install: %-compile
  106. $(START_TRACE) "toolchain/$(patsubst %-install,%,$@)/install.. "
  107. @if test x"$(patsubst %-install,%,$@)" = x"$(CLIB)"; then \
  108. $(MAKE) -C $(patsubst %-install,%,$@) install \
  109. $(MAKE_TRACE); \
  110. else \
  111. $(MAKE) -C $(patsubst %-install,%,$@) install \
  112. CC='$(HOST_CC)' CFLAGS='$(HOST_CFLAGS)' CXXFLAGS='$(HOST_STATIC_CXXFLAGS)' $(MAKE_TRACE); \
  113. fi
  114. $(CMD_TRACE) " done"
  115. $(END_TRACE)
  116. %-final: %-install
  117. $(START_TRACE) "toolchain/$(patsubst %-final,%,$@)/final.. "
  118. @$(MAKE) -C $(patsubst %-final,%,$@) final $(MAKE_TRACE)
  119. $(CMD_TRACE) " done"
  120. $(END_TRACE)
  121. %-clean:
  122. $(START_TRACE) "toolchain/$(patsubst %-clean,%,$@)/clean.. "
  123. @$(MAKE) -C $(patsubst %-clean,%,$@) clean $(MAKE_TRACE)
  124. $(CMD_TRACE) " done"
  125. $(END_TRACE)