Makefile 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. $(CLIB)-install: gcc-configure kernel-headers-configure
  51. gcc-install: $(ELF2FLT) $(CLIB)-install
  52. gcc-final: gcc-install $(GDB)
  53. %-download:
  54. $(START_TRACE) "toolchain/$(patsubst %-download,%,$@)/download.. "
  55. $(MAKE) -C $(patsubst %-download,%,$@) fetch
  56. $(CMD_TRACE) " done"
  57. $(END_TRACE)
  58. %-prepare:
  59. $(START_TRACE) "toolchain/$(patsubst %-prepare,%,$@)/prepare.. "
  60. @if test x"$(patsubst %-prepare,%,$@)" = x"$(CLIB)"; then \
  61. $(MAKE) -C $(patsubst %-prepare,%,$@) prepare \
  62. $(MAKE_TRACE); \
  63. else \
  64. $(MAKE) -C $(patsubst %-prepare,%,$@) prepare \
  65. CC='$(HOST_CC)' CFLAGS='$(HOST_CFLAGS)' $(MAKE_TRACE); \
  66. fi
  67. $(CMD_TRACE) " done"
  68. $(END_TRACE)
  69. %-configure: %-prepare
  70. $(START_TRACE) "toolchain/$(patsubst %-configure,%,$@)/configure.. "
  71. @if test x"$(patsubst %-configure,%,$@)" = x"$(CLIB)"; then \
  72. $(MAKE) -C $(patsubst %-configure,%,$@) configure \
  73. $(MAKE_TRACE); \
  74. else \
  75. $(MAKE) -C $(patsubst %-configure,%,$@) configure \
  76. CC='$(HOST_CC)' CFLAGS='$(HOST_CFLAGS)' $(MAKE_TRACE); \
  77. fi
  78. $(CMD_TRACE) " done"
  79. $(END_TRACE)
  80. %-compile: %-configure
  81. $(START_TRACE) "toolchain/$(patsubst %-compile,%,$@)/compile.. "
  82. @if test x"$(patsubst %-compile,%,$@)" = x"$(CLIB)"; then \
  83. $(MAKE) -C $(patsubst %-compile,%,$@) compile \
  84. $(MAKE_TRACE); \
  85. else \
  86. $(MAKE) -C $(patsubst %-compile,%,$@) compile \
  87. CC='$(HOST_CC)' CFLAGS='$(HOST_CFLAGS)' CXXFLAGS='$(HOST_STATIC_CXXFLAGS)' $(MAKE_TRACE); \
  88. fi
  89. $(CMD_TRACE) " done"
  90. $(END_TRACE)
  91. %-install: %-compile
  92. $(START_TRACE) "toolchain/$(patsubst %-install,%,$@)/install.. "
  93. @if test x"$(patsubst %-install,%,$@)" = x"$(CLIB)"; then \
  94. $(MAKE) -C $(patsubst %-install,%,$@) install \
  95. $(MAKE_TRACE); \
  96. else \
  97. $(MAKE) -C $(patsubst %-install,%,$@) install \
  98. CC='$(HOST_CC)' CFLAGS='$(HOST_CFLAGS)' CXXFLAGS='$(HOST_STATIC_CXXFLAGS)' $(MAKE_TRACE); \
  99. fi
  100. $(CMD_TRACE) " done"
  101. $(END_TRACE)
  102. %-final: %-install
  103. $(START_TRACE) "toolchain/$(patsubst %-final,%,$@)/final.. "
  104. @$(MAKE) -C $(patsubst %-final,%,$@) final $(MAKE_TRACE)
  105. $(CMD_TRACE) " done"
  106. $(END_TRACE)
  107. %-clean:
  108. $(START_TRACE) "toolchain/$(patsubst %-clean,%,$@)/clean.. "
  109. @$(MAKE) -C $(patsubst %-clean,%,$@) clean $(MAKE_TRACE)
  110. $(CMD_TRACE) " done"
  111. $(END_TRACE)