1
0

Makefile 4.1 KB

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