1
0

Makefile 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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_BINFMT_FLAT),y)
  26. TARGETS+=elf2flt
  27. ELF2FLT:=elf2flt-install
  28. endif
  29. # disable gdb for arc
  30. ifeq ($(ADK_TARGET_ARCH_ARC)$(ADK_TARGET_ARCH_METAG)$(ADK_TARGET_ARCH_OR1K),)
  31. TARGETS+=gdb
  32. GDB:=gdb-install
  33. endif
  34. ifeq (${ADK_PRELINK},y)
  35. TARGETS+=prelink-cross
  36. endif
  37. DOWNLOAD:=kernel-headers-download $(patsubst %,%-download,$(TARGETS))
  38. TARGETS_INSTALL:=$(patsubst %,%-install,$(TARGETS))
  39. FINAL:=$(patsubst %,%-final,gcc)
  40. TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS))
  41. install: $(TARGETS_INSTALL)
  42. clean: $(TARGETS_CLEAN)
  43. download: $(DOWNLOAD)
  44. final: $(FINAL)
  45. gcc-configure: binutils-install gmp-install mpfr-install mpc-install libelf-install
  46. $(CLIB)-install: gcc-configure kernel-headers-configure
  47. gcc-install: $(CLIB)-install
  48. gcc-final: gcc-install $(GDB) $(ELF2FLT)
  49. %-download:
  50. $(TRACE) toolchain/$(patsubst %-download,%,$@)/download
  51. $(MAKE) -C $(patsubst %-download,%,$@) fetch
  52. %-prepare:
  53. $(TRACE) toolchain/$(patsubst %-prepare,%,$@)/prepare
  54. @if test x"$(patsubst %-prepare,%,$@)" = x"$(CLIB)"; then \
  55. $(MAKE) -C $(patsubst %-prepare,%,$@) prepare \
  56. $(MAKE_TRACE); \
  57. else \
  58. $(MAKE) -C $(patsubst %-prepare,%,$@) prepare \
  59. CC='$(HOST_CC)' CFLAGS='$(HOST_CFLAGS)' $(MAKE_TRACE); \
  60. fi
  61. %-configure: %-prepare
  62. $(TRACE) toolchain/$(patsubst %-configure,%,$@)/configure
  63. @if test x"$(patsubst %-configure,%,$@)" = x"$(CLIB)"; then \
  64. $(MAKE) -C $(patsubst %-configure,%,$@) configure \
  65. $(MAKE_TRACE); \
  66. else \
  67. $(MAKE) -C $(patsubst %-configure,%,$@) configure \
  68. CC='$(HOST_CC)' CFLAGS='$(HOST_CFLAGS)' $(MAKE_TRACE); \
  69. fi
  70. %-compile: %-configure
  71. $(TRACE) toolchain/$(patsubst %-compile,%,$@)/compile
  72. @if test x"$(patsubst %-compile,%,$@)" = x"$(CLIB)"; then \
  73. $(MAKE) -C $(patsubst %-compile,%,$@) compile \
  74. $(MAKE_TRACE); \
  75. else \
  76. $(MAKE) -C $(patsubst %-compile,%,$@) compile \
  77. CC='$(HOST_CC)' CFLAGS='$(HOST_CFLAGS)' CXXFLAGS='$(HOST_STATIC_CXXFLAGS)' $(MAKE_TRACE); \
  78. fi
  79. %-install: %-compile
  80. $(TRACE) toolchain/$(patsubst %-install,%,$@)/install
  81. @if test x"$(patsubst %-install,%,$@)" = x"$(CLIB)"; then \
  82. $(MAKE) -C $(patsubst %-install,%,$@) install \
  83. $(MAKE_TRACE); \
  84. else \
  85. $(MAKE) -C $(patsubst %-install,%,$@) install \
  86. CC='$(HOST_CC)' CFLAGS='$(HOST_CFLAGS)' CXXFLAGS='$(HOST_STATIC_CXXFLAGS)' $(MAKE_TRACE); \
  87. fi
  88. %-final: %-install
  89. $(TRACE) toolchain/$(patsubst %-final,%,$@)/final
  90. @$(MAKE) -C $(patsubst %-final,%,$@) final $(MAKE_TRACE)
  91. %-clean:
  92. $(TRACE) toolchain/$(patsubst %-clean,%,$@)/clean
  93. @$(MAKE) -C $(patsubst %-clean,%,$@) clean $(MAKE_TRACE)