1
0

Makefile 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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 minimal gcc c compiler
  7. # 4) install kernel-headers
  8. # 5) install libc headers
  9. # 6) build and install initial static gcc
  10. # 7) build and install full libc
  11. # 8) build and install full shared gcc
  12. # 9) rebuild and install full libc (in case of musl/uclibc)
  13. # 10) build and install gdb debugger
  14. include $(ADK_TOPDIR)/rules.mk
  15. TARGETS:=binutils gmp mpfr mpc libelf gcc
  16. ifeq ($(ADK_TARGET_LIB_GLIBC),y)
  17. TARGETS+=glibc
  18. CLIB:=glibc
  19. endif
  20. ifeq ($(ADK_TARGET_LIB_UCLIBC_NG),y)
  21. TARGETS+=uclibc-ng
  22. CLIB:=uclibc-ng
  23. endif
  24. ifeq ($(ADK_TARGET_LIB_MUSL),y)
  25. TARGETS+=musl
  26. CLIB:=musl
  27. endif
  28. ifeq ($(ADK_TARGET_BINFMT_FLAT),y)
  29. TARGETS+=elf2flt
  30. ELF2FLT:=elf2flt-install
  31. endif
  32. # disable gdb for arc
  33. ifeq ($(ADK_TARGET_ARCH_ARC)$(ADK_TARGET_ARCH_METAG)$(ADK_TARGET_ARCH_OR1K),)
  34. TARGETS+=gdb
  35. GDB:=gdb-install
  36. endif
  37. ifeq (${ADK_PRELINK},y)
  38. TARGETS+=prelink-cross
  39. endif
  40. DOWNLOAD:=kernel-headers-download $(patsubst %,%-download,$(TARGETS))
  41. TARGETS_INSTALL:=$(patsubst %,%-install,$(TARGETS))
  42. FIXUP:=$(patsubst %,%-fixup,$(CLIB))
  43. TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS))
  44. install: $(TARGETS_INSTALL)
  45. clean: $(TARGETS_CLEAN)
  46. download: $(DOWNLOAD)
  47. fixup: $(FIXUP)
  48. gcc-prepare: binutils-install gmp-install mpfr-install mpc-install libelf-install
  49. $(CLIB)-prepare: gcc-prepare kernel-headers-prepare
  50. gcc-configure: $(CLIB)-prepare
  51. $(CLIB)-compile: gcc-configure
  52. gcc-compile: $(CLIB)-install
  53. $(CLIB)-fixup: gcc-install $(GDB) $(ELF2FLT)
  54. %-download:
  55. $(TRACE) toolchain/$(patsubst %-download,%,$@)/download
  56. $(MAKE) -C $(patsubst %-download,%,$@) fetch
  57. %-prepare:
  58. $(TRACE) toolchain/$(patsubst %-prepare,%,$@)/prepare
  59. @if test x"$(patsubst %-prepare,%,$@)" = x"$(CLIB)"; then \
  60. $(MAKE) -C $(patsubst %-prepare,%,$@) prepare \
  61. $(MAKE_TRACE); \
  62. else \
  63. $(MAKE) -C $(patsubst %-prepare,%,$@) prepare \
  64. CC='$(HOST_CC)' CFLAGS='$(HOST_CFLAGS)' $(MAKE_TRACE); \
  65. fi
  66. %-configure: %-prepare
  67. $(TRACE) toolchain/$(patsubst %-configure,%,$@)/configure
  68. @if test x"$(patsubst %-configure,%,$@)" = x"$(CLIB)"; then \
  69. $(MAKE) -C $(patsubst %-configure,%,$@) configure \
  70. $(MAKE_TRACE); \
  71. else \
  72. $(MAKE) -C $(patsubst %-configure,%,$@) configure \
  73. CC='$(HOST_CC)' CFLAGS='$(HOST_CFLAGS)' $(MAKE_TRACE); \
  74. fi
  75. %-compile: %-configure
  76. $(TRACE) toolchain/$(patsubst %-compile,%,$@)/compile
  77. @if test x"$(patsubst %-compile,%,$@)" = x"$(CLIB)"; then \
  78. $(MAKE) -C $(patsubst %-compile,%,$@) compile \
  79. $(MAKE_TRACE); \
  80. else \
  81. $(MAKE) -C $(patsubst %-compile,%,$@) compile \
  82. CC='$(HOST_CC)' CFLAGS='$(HOST_CFLAGS)' CXXFLAGS='$(HOST_STATIC_CXXFLAGS)' $(MAKE_TRACE); \
  83. fi
  84. %-install: %-compile
  85. $(TRACE) toolchain/$(patsubst %-install,%,$@)/install
  86. @if test x"$(patsubst %-install,%,$@)" = x"$(CLIB)"; then \
  87. $(MAKE) -C $(patsubst %-install,%,$@) install \
  88. $(MAKE_TRACE); \
  89. else \
  90. $(MAKE) -C $(patsubst %-install,%,$@) install \
  91. CC='$(HOST_CC)' CFLAGS='$(HOST_CFLAGS)' CXXFLAGS='$(HOST_STATIC_CXXFLAGS)' $(MAKE_TRACE); \
  92. fi
  93. %-fixup: %-install
  94. $(TRACE) toolchain/$(patsubst %-fixup,%,$@)/fixup
  95. @$(MAKE) -C $(patsubst %-fixup,%,$@) fixup $(MAKE_TRACE)
  96. %-clean:
  97. $(TRACE) toolchain/$(patsubst %-clean,%,$@)/clean
  98. @$(MAKE) -C $(patsubst %-clean,%,$@) clean $(MAKE_TRACE)