1
0

Makefile 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. #
  4. # Steps to build toolchains
  5. # 1) build and install binutils
  6. # 2) build and install mpfr, mpc, libelf and gmp
  7. # 3) build and install minimal gcc c compiler
  8. # 4) install kernel-headers
  9. # 5) install libc headers
  10. # 6) build and install initial static gcc
  11. # 7) build and install full libc
  12. # 8) build and install full shared gcc
  13. # 9) rebuild and install full libc (in case of musl/uclibc)
  14. # 10) build and install gdb debugger
  15. include $(ADK_TOPDIR)/rules.mk
  16. TARGETS:=binutils gmp mpfr mpc libelf gcc gdb
  17. ifeq ($(ADK_TARGET_LIB_GLIBC),y)
  18. TARGETS+=glibc
  19. CLIB:=glibc
  20. endif
  21. ifeq ($(ADK_TARGET_LIB_UCLIBC),y)
  22. TARGETS+=uclibc
  23. CLIB:=uclibc
  24. endif
  25. ifeq ($(ADK_TARGET_LIB_UCLIBC_NG),y)
  26. TARGETS+=uclibc-ng
  27. CLIB:=uclibc-ng
  28. endif
  29. ifeq ($(ADK_TARGET_LIB_MUSL),y)
  30. TARGETS+=musl
  31. CLIB:=musl
  32. endif
  33. ifeq ($(ADK_TARGET_BINFMT_FLAT),y)
  34. TARGETS+=elf2flt
  35. endif
  36. DOWNLOAD:=kernel-headers-download $(patsubst %,%-download,$(TARGETS))
  37. TARGETS_INSTALL:=$(patsubst %,%-install,$(TARGETS))
  38. FIXUP:=$(patsubst %,%-fixup,$(CLIB))
  39. TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS))
  40. install: $(TARGETS_INSTALL)
  41. clean: $(TARGETS_CLEAN)
  42. download: $(DOWNLOAD)
  43. fixup: $(FIXUP)
  44. gcc-prepare: binutils-install gmp-install mpfr-install mpc-install libelf-install
  45. $(CLIB)-prepare: gcc-prepare kernel-headers-prepare
  46. gcc-configure: $(CLIB)-prepare
  47. $(CLIB)-compile: gcc-configure
  48. gcc-compile: $(CLIB)-install
  49. ifeq ($(ADK_TARGET_BINFMT_FLAT),y)
  50. $(CLIB)-fixup: gcc-install gdb-install elf2flt-install
  51. else
  52. $(CLIB)-fixup: gcc-install gdb-install
  53. endif
  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)