Makefile 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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)
  14. # 10) build and install gdb debugger
  15. include $(TOPDIR)/rules.mk
  16. TARGETS:=binutils gmp mpfr mpc libelf gcc
  17. ifeq ($(ADK_TARGET_LIB_GLIBC),y)
  18. TARGETS+=glibc
  19. LIBC:=glibc
  20. endif
  21. ifeq ($(ADK_TARGET_LIB_EGLIBC),y)
  22. TARGETS+=eglibc
  23. LIBC:=eglibc
  24. endif
  25. ifeq ($(ADK_TARGET_LIB_UCLIBC),y)
  26. TARGETS+=uClibc
  27. LIBC:=uClibc
  28. endif
  29. ifeq ($(ADK_TARGET_LIB_MUSL),y)
  30. TARGETS+=musl
  31. LIBC:=musl
  32. endif
  33. ifeq ($(ADK_TOOLCHAIN_GDB),y)
  34. TARGETS+=gdb
  35. endif
  36. DOWNLOAD:=kernel-headers-download $(patsubst %,%-download,$(TARGETS))
  37. TARGETS_INSTALL:=$(patsubst %,%-install,$(TARGETS))
  38. FIXUP:=$(patsubst %,%-fixup,$(LIBC))
  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. $(LIBC)-prepare: gcc-prepare kernel-headers-prepare
  46. gcc-configure: $(LIBC)-prepare
  47. $(LIBC)-compile: gcc-configure
  48. gcc-compile: $(LIBC)-install
  49. ifeq ($(ADK_TOOLCHAIN_GDB),y)
  50. $(LIBC)-fixup: gcc-install gdb-install
  51. else
  52. $(LIBC)-fixup: gcc-install
  53. endif
  54. $(STAGING_HOST_DIR):
  55. @mkdir -p $(STAGING_HOST_DIR)/lib
  56. @mkdir -p $(STAGING_HOST_DIR)/include
  57. @mkdir -p $(STAGING_HOST_DIR)/$(REAL_GNU_TARGET_NAME)
  58. @ln -sf ../lib $(STAGING_HOST_DIR)/$(REAL_GNU_TARGET_NAME)/lib
  59. %-download:
  60. $(TRACE) toolchain/$(patsubst %-download,%,$@)/download
  61. $(MAKE) -C $(patsubst %-download,%,$@) fetch
  62. %-prepare: $(STAGING_HOST_DIR)
  63. $(TRACE) toolchain/$(patsubst %-prepare,%,$@)/prepare
  64. @if test x"$(patsubst %-prepare,%,$@)" = x"$(LIBC)"; then \
  65. $(MAKE) -C $(patsubst %-prepare,%,$@) prepare \
  66. $(MAKE_TRACE); \
  67. else \
  68. $(MAKE) -C $(patsubst %-prepare,%,$@) prepare \
  69. CC='$(CC_FOR_BUILD)' CFLAGS='$(CFLAGS_FOR_BUILD)' \
  70. $(MAKE_TRACE); \
  71. fi
  72. %-configure: %-prepare
  73. $(TRACE) toolchain/$(patsubst %-configure,%,$@)/configure
  74. @if test x"$(patsubst %-configure,%,$@)" = x"$(LIBC)"; then \
  75. $(MAKE) -C $(patsubst %-configure,%,$@) configure \
  76. $(MAKE_TRACE); \
  77. else \
  78. $(MAKE) -C $(patsubst %-configure,%,$@) configure \
  79. CC='$(CC_FOR_BUILD)' CFLAGS='$(CFLAGS_FOR_BUILD)' \
  80. $(MAKE_TRACE); \
  81. fi
  82. %-compile: %-configure
  83. $(TRACE) toolchain/$(patsubst %-compile,%,$@)/compile
  84. @if test x"$(patsubst %-compile,%,$@)" = x"$(LIBC)"; then \
  85. $(MAKE) -C $(patsubst %-compile,%,$@) compile \
  86. $(MAKE_TRACE); \
  87. else \
  88. $(MAKE) -C $(patsubst %-compile,%,$@) compile \
  89. CC='$(CC_FOR_BUILD)' CFLAGS='$(CFLAGS_FOR_BUILD)' \
  90. $(MAKE_TRACE); \
  91. fi
  92. %-install: %-compile
  93. $(TRACE) toolchain/$(patsubst %-install,%,$@)/install
  94. @if test x"$(patsubst %-install,%,$@)" = x"$(LIBC)"; then \
  95. $(MAKE) -C $(patsubst %-install,%,$@) install \
  96. $(MAKE_TRACE); \
  97. else \
  98. $(MAKE) -C $(patsubst %-install,%,$@) install \
  99. CC='$(CC_FOR_BUILD)' CFLAGS='$(CFLAGS_FOR_BUILD)' \
  100. $(MAKE_TRACE); \
  101. fi
  102. %-fixup: %-install
  103. $(TRACE) toolchain/$(patsubst %-fixup,%,$@)/fixup
  104. @$(MAKE) -C $(patsubst %-fixup,%,$@) fixup $(MAKE_TRACE)
  105. %-clean:
  106. $(TRACE) toolchain/$(patsubst %-clean,%,$@)/clean
  107. @$(MAKE) -C $(patsubst %-clean,%,$@) clean $(MAKE_TRACE)