Makefile 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 and gmp
  7. # 3) build and install gcc c compiler
  8. # 4) install kernel-headers
  9. # 5) install libc headers
  10. # 6) build and install full gcc
  11. # 7) build and install full libc
  12. # 8) build and install gdb debugger
  13. include $(TOPDIR)/rules.mk
  14. TARGETS:=binutils gmp mpfr mpc gcc
  15. ifeq ($(ADK_TARGET_LIB_GLIBC),y)
  16. TARGETS+=glibc-ports glibc
  17. LIBC:=glibc
  18. endif
  19. ifeq ($(ADK_TARGET_LIB_EGLIBC),y)
  20. TARGETS+=eglibc
  21. LIBC:=eglibc
  22. endif
  23. ifeq ($(ADK_TARGET_LIB_UCLIBC),y)
  24. TARGETS+=uClibc
  25. LIBC:=uClibc
  26. endif
  27. TARGETS+=gdb
  28. DOWNLOAD:=kernel-headers-download $(patsubst %,%-download,$(TARGETS))
  29. TARGETS_INSTALL:=$(patsubst %,%-install,$(TARGETS))
  30. TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS))
  31. install: $(TARGETS_INSTALL)
  32. clean: $(TARGETS_CLEAN)
  33. download: $(DOWNLOAD)
  34. gcc-prepare: binutils-install gmp-install mpfr-install mpc-install
  35. ifeq ($(ADK_TARGET_LIB_GLIBC),y)
  36. $(LIBC)-prepare: gcc-prepare kernel-headers-prepare glibc-ports-prepare
  37. else
  38. $(LIBC)-prepare: gcc-prepare kernel-headers-prepare
  39. endif
  40. gcc-configure: $(LIBC)-prepare
  41. $(LIBC)-compile: gcc-configure
  42. gcc-compile: $(LIBC)-install
  43. $(STAGING_HOST_DIR):
  44. @mkdir -p $(STAGING_HOST_DIR)/lib
  45. @mkdir -p $(STAGING_HOST_DIR)/include
  46. @mkdir -p $(STAGING_HOST_DIR)/$(REAL_GNU_TARGET_NAME)
  47. @ln -sf ../lib $(STAGING_HOST_DIR)/$(REAL_GNU_TARGET_NAME)/lib
  48. $(TOOLCHAIN_BUILD_DIR):
  49. @mkdir -p $(TOOLCHAIN_BUILD_DIR)
  50. %-download:
  51. $(TRACE) toolchain/$(patsubst %-download,%,$@)/download
  52. $(MAKE) -C $(patsubst %-download,%,$@) fetch
  53. %-prepare: $(STAGING_HOST_DIR) $(TOOLCHAIN_BUILD_DIR)
  54. $(TRACE) toolchain/$(patsubst %-prepare,%,$@)/prepare
  55. @if test x"$(patsubst %-prepare,%,$@)" = x"$(LIBC)"; then \
  56. $(MAKE) -C $(patsubst %-prepare,%,$@) prepare \
  57. $(MAKE_TRACE); \
  58. else \
  59. $(MAKE) -C $(patsubst %-prepare,%,$@) prepare \
  60. CC='$(HOSTCC)' CFLAGS='$(HOSTCFLAGS)' \
  61. $(MAKE_TRACE); \
  62. fi
  63. %-configure: %-prepare
  64. $(TRACE) toolchain/$(patsubst %-configure,%,$@)/configure
  65. @if test x"$(patsubst %-configure,%,$@)" = x"$(LIBC)"; then \
  66. $(MAKE) -C $(patsubst %-configure,%,$@) configure \
  67. $(MAKE_TRACE); \
  68. else \
  69. $(MAKE) -C $(patsubst %-configure,%,$@) configure \
  70. CC='$(HOSTCC)' CFLAGS='$(HOSTCFLAGS)' \
  71. $(MAKE_TRACE); \
  72. fi
  73. %-compile: %-configure
  74. $(TRACE) toolchain/$(patsubst %-compile,%,$@)/compile
  75. @if test x"$(patsubst %-compile,%,$@)" = x"$(LIBC)"; then \
  76. $(MAKE) -C $(patsubst %-compile,%,$@) compile \
  77. $(MAKE_TRACE); \
  78. else \
  79. $(MAKE) -C $(patsubst %-compile,%,$@) compile \
  80. CC='$(HOSTCC)' CFLAGS='$(HOSTCFLAGS)' \
  81. $(MAKE_TRACE); \
  82. fi
  83. %-install: %-compile
  84. $(TRACE) toolchain/$(patsubst %-install,%,$@)/install
  85. @if test x"$(patsubst %-install,%,$@)" = x"$(LIBC)"; then \
  86. $(MAKE) -C $(patsubst %-install,%,$@) install \
  87. $(MAKE_TRACE); \
  88. else \
  89. $(MAKE) -C $(patsubst %-install,%,$@) install \
  90. CC='$(HOSTCC)' CFLAGS='$(HOSTCFLAGS)' \
  91. $(MAKE_TRACE); \
  92. fi
  93. %-clean:
  94. $(TRACE) toolchain/$(patsubst %-clean,%,$@)/clean
  95. @$(MAKE) -C $(patsubst %-clean,%,$@) clean $(MAKE_TRACE)