Makefile 3.7 KB

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