Makefile 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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_MUSL),y)
  26. TARGETS+=musl
  27. CLIB:=musl
  28. endif
  29. DOWNLOAD:=kernel-headers-download $(patsubst %,%-download,$(TARGETS))
  30. TARGETS_INSTALL:=$(patsubst %,%-install,$(TARGETS))
  31. FIXUP:=$(patsubst %,%-fixup,$(CLIB))
  32. TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS))
  33. install: $(TARGETS_INSTALL)
  34. clean: $(TARGETS_CLEAN)
  35. download: $(DOWNLOAD)
  36. fixup: $(FIXUP)
  37. gcc-prepare: binutils-install gmp-install mpfr-install mpc-install libelf-install
  38. $(CLIB)-prepare: gcc-prepare kernel-headers-prepare
  39. gcc-configure: $(CLIB)-prepare
  40. $(CLIB)-compile: gcc-configure
  41. gcc-compile: $(CLIB)-install
  42. $(CLIB)-fixup: gcc-install gdb-install
  43. %-download:
  44. $(TRACE) toolchain/$(patsubst %-download,%,$@)/download
  45. $(MAKE) -C $(patsubst %-download,%,$@) fetch
  46. %-prepare:
  47. $(TRACE) toolchain/$(patsubst %-prepare,%,$@)/prepare
  48. @if test x"$(patsubst %-prepare,%,$@)" = x"$(CLIB)"; then \
  49. $(MAKE) -C $(patsubst %-prepare,%,$@) prepare \
  50. $(MAKE_TRACE); \
  51. else \
  52. $(MAKE) -C $(patsubst %-prepare,%,$@) prepare \
  53. CC='$(HOST_CC)' CFLAGS='$(HOST_CFLAGS)' $(MAKE_TRACE); \
  54. fi
  55. %-configure: %-prepare
  56. $(TRACE) toolchain/$(patsubst %-configure,%,$@)/configure
  57. @if test x"$(patsubst %-configure,%,$@)" = x"$(CLIB)"; then \
  58. $(MAKE) -C $(patsubst %-configure,%,$@) configure \
  59. $(MAKE_TRACE); \
  60. else \
  61. $(MAKE) -C $(patsubst %-configure,%,$@) configure \
  62. CC='$(HOST_CC)' CFLAGS='$(HOST_CFLAGS)' $(MAKE_TRACE); \
  63. fi
  64. %-compile: %-configure
  65. $(TRACE) toolchain/$(patsubst %-compile,%,$@)/compile
  66. @if test x"$(patsubst %-compile,%,$@)" = x"$(CLIB)"; then \
  67. $(MAKE) -C $(patsubst %-compile,%,$@) compile \
  68. $(MAKE_TRACE); \
  69. else \
  70. $(MAKE) -C $(patsubst %-compile,%,$@) compile \
  71. CC='$(HOST_CC)' CFLAGS='$(HOST_CFLAGS)' $(MAKE_TRACE); \
  72. fi
  73. %-install: %-compile
  74. $(TRACE) toolchain/$(patsubst %-install,%,$@)/install
  75. @if test x"$(patsubst %-install,%,$@)" = x"$(CLIB)"; then \
  76. $(MAKE) -C $(patsubst %-install,%,$@) install \
  77. $(MAKE_TRACE); \
  78. else \
  79. $(MAKE) -C $(patsubst %-install,%,$@) install \
  80. CC='$(HOST_CC)' CFLAGS='$(HOST_CFLAGS)' $(MAKE_TRACE); \
  81. fi
  82. %-fixup: %-install
  83. $(TRACE) toolchain/$(patsubst %-fixup,%,$@)/fixup
  84. @$(MAKE) -C $(patsubst %-fixup,%,$@) fixup $(MAKE_TRACE)
  85. %-clean:
  86. $(TRACE) toolchain/$(patsubst %-clean,%,$@)/clean
  87. @$(MAKE) -C $(patsubst %-clean,%,$@) clean $(MAKE_TRACE)