Makefile 3.4 KB

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