Makefile 3.9 KB

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