Makefile 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. DOWNLOAD:=kernel-headers-download $(patsubst %,%-download,$(TARGETS))
  42. TARGETS_INSTALL:=$(patsubst %,%-install,$(TARGETS))
  43. FIXUP:=$(patsubst %,%-fixup,$(CLIB))
  44. TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS))
  45. install: $(TARGETS_INSTALL)
  46. clean: $(TARGETS_CLEAN)
  47. download: $(DOWNLOAD)
  48. fixup: $(FIXUP)
  49. gcc-prepare: binutils-install gmp-install mpfr-install mpc-install libelf-install
  50. $(CLIB)-prepare: gcc-prepare kernel-headers-prepare
  51. gcc-configure: $(CLIB)-prepare
  52. $(CLIB)-compile: gcc-configure
  53. gcc-compile: $(CLIB)-install
  54. $(CLIB)-fixup: gcc-install $(GDB) $(ELF2FLT)
  55. %-download:
  56. $(TRACE) toolchain/$(patsubst %-download,%,$@)/download
  57. $(MAKE) -C $(patsubst %-download,%,$@) fetch
  58. %-prepare:
  59. $(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. %-configure: %-prepare
  68. $(TRACE) toolchain/$(patsubst %-configure,%,$@)/configure
  69. @if test x"$(patsubst %-configure,%,$@)" = x"$(CLIB)"; then \
  70. $(MAKE) -C $(patsubst %-configure,%,$@) configure \
  71. $(MAKE_TRACE); \
  72. else \
  73. $(MAKE) -C $(patsubst %-configure,%,$@) configure \
  74. CC='$(HOST_CC)' CFLAGS='$(HOST_CFLAGS)' $(MAKE_TRACE); \
  75. fi
  76. %-compile: %-configure
  77. $(TRACE) toolchain/$(patsubst %-compile,%,$@)/compile
  78. @if test x"$(patsubst %-compile,%,$@)" = x"$(CLIB)"; then \
  79. $(MAKE) -C $(patsubst %-compile,%,$@) compile \
  80. $(MAKE_TRACE); \
  81. else \
  82. $(MAKE) -C $(patsubst %-compile,%,$@) compile \
  83. CC='$(HOST_CC)' CFLAGS='$(HOST_CFLAGS)' CXXFLAGS='$(HOST_STATIC_CXXFLAGS)' $(MAKE_TRACE); \
  84. fi
  85. %-install: %-compile
  86. $(TRACE) toolchain/$(patsubst %-install,%,$@)/install
  87. @if test x"$(patsubst %-install,%,$@)" = x"$(CLIB)"; then \
  88. $(MAKE) -C $(patsubst %-install,%,$@) install \
  89. $(MAKE_TRACE); \
  90. else \
  91. $(MAKE) -C $(patsubst %-install,%,$@) install \
  92. CC='$(HOST_CC)' CFLAGS='$(HOST_CFLAGS)' CXXFLAGS='$(HOST_STATIC_CXXFLAGS)' $(MAKE_TRACE); \
  93. fi
  94. %-fixup: %-install
  95. $(TRACE) toolchain/$(patsubst %-fixup,%,$@)/fixup
  96. @$(MAKE) -C $(patsubst %-fixup,%,$@) fixup $(MAKE_TRACE)
  97. %-clean:
  98. $(TRACE) toolchain/$(patsubst %-clean,%,$@)/clean
  99. @$(MAKE) -C $(patsubst %-clean,%,$@) clean $(MAKE_TRACE)