Makefile 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. # disable gdb for some architectures
  42. 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),)
  43. TARGETS+=gdb
  44. GDB:=gdb-install
  45. endif
  46. ifeq (${ADK_PRELINK},y)
  47. TARGETS+=prelink-cross
  48. endif
  49. DOWNLOAD:=kernel-headers-download $(patsubst %,%-download,$(TARGETS))
  50. TARGETS_INSTALL:=$(patsubst %,%-install,$(TARGETS))
  51. FINAL:=$(patsubst %,%-final,$(COMPILER))
  52. TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS))
  53. install: $(TARGETS_INSTALL)
  54. clean: $(TARGETS_CLEAN)
  55. download: $(DOWNLOAD)
  56. final: $(FINAL)
  57. $(COMPILER)-configure: binutils-install gmp-install mpfr-install mpc-install libelf-install
  58. ifeq ($(ADK_TARGET_LIB_NEWLIB),y)
  59. $(CLIB)-install: $(COMPILER)-configure
  60. else
  61. $(CLIB)-install: $(COMPILER)-configure kernel-headers-configure
  62. endif
  63. $(COMPILER)-install: $(ELF2FLT) $(CLIB)-install
  64. $(COMPILER)-final: $(COMPILER)-install $(GDB)
  65. %-download:
  66. $(START_TRACE) "toolchain/$(patsubst %-download,%,$@)/download.. "
  67. $(MAKE) -C $(patsubst %-download,%,$@) fetch
  68. $(CMD_TRACE) " done"
  69. $(END_TRACE)
  70. %-prepare:
  71. $(START_TRACE) "toolchain/$(patsubst %-prepare,%,$@)/prepare.. "
  72. @if test x"$(patsubst %-prepare,%,$@)" = x"$(CLIB)"; then \
  73. $(MAKE) -C $(patsubst %-prepare,%,$@) prepare \
  74. $(MAKE_TRACE); \
  75. else \
  76. $(MAKE) -C $(patsubst %-prepare,%,$@) prepare \
  77. CC='$(HOST_CC)' CFLAGS='$(HOST_CFLAGS)' $(MAKE_TRACE); \
  78. fi
  79. $(CMD_TRACE) " done"
  80. $(END_TRACE)
  81. %-configure: %-prepare
  82. $(START_TRACE) "toolchain/$(patsubst %-configure,%,$@)/configure.. "
  83. @if test x"$(patsubst %-configure,%,$@)" = x"$(CLIB)"; then \
  84. $(MAKE) -C $(patsubst %-configure,%,$@) configure \
  85. $(MAKE_TRACE); \
  86. else \
  87. $(MAKE) -C $(patsubst %-configure,%,$@) configure \
  88. CC='$(HOST_CC)' CFLAGS='$(HOST_CFLAGS)' $(MAKE_TRACE); \
  89. fi
  90. $(CMD_TRACE) " done"
  91. $(END_TRACE)
  92. %-compile: %-configure
  93. $(START_TRACE) "toolchain/$(patsubst %-compile,%,$@)/compile.. "
  94. @if test x"$(patsubst %-compile,%,$@)" = x"$(CLIB)"; then \
  95. $(MAKE) -C $(patsubst %-compile,%,$@) compile \
  96. $(MAKE_TRACE); \
  97. else \
  98. $(MAKE) -C $(patsubst %-compile,%,$@) compile \
  99. CC='$(HOST_CC)' CFLAGS='$(HOST_CFLAGS)' CXXFLAGS='$(HOST_STATIC_CXXFLAGS)' $(MAKE_TRACE); \
  100. fi
  101. $(CMD_TRACE) " done"
  102. $(END_TRACE)
  103. %-install: %-compile
  104. $(START_TRACE) "toolchain/$(patsubst %-install,%,$@)/install.. "
  105. @if test x"$(patsubst %-install,%,$@)" = x"$(CLIB)"; then \
  106. $(MAKE) -C $(patsubst %-install,%,$@) install \
  107. $(MAKE_TRACE); \
  108. else \
  109. $(MAKE) -C $(patsubst %-install,%,$@) install \
  110. CC='$(HOST_CC)' CFLAGS='$(HOST_CFLAGS)' CXXFLAGS='$(HOST_STATIC_CXXFLAGS)' $(MAKE_TRACE); \
  111. fi
  112. $(CMD_TRACE) " done"
  113. $(END_TRACE)
  114. %-final: %-install
  115. $(START_TRACE) "toolchain/$(patsubst %-final,%,$@)/final.. "
  116. @$(MAKE) -C $(patsubst %-final,%,$@) final $(MAKE_TRACE)
  117. $(CMD_TRACE) " done"
  118. $(END_TRACE)
  119. %-clean:
  120. $(START_TRACE) "toolchain/$(patsubst %-clean,%,$@)/clean.. "
  121. @$(MAKE) -C $(patsubst %-clean,%,$@) clean $(MAKE_TRACE)
  122. $(CMD_TRACE) " done"
  123. $(END_TRACE)