Makefile 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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 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 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. all: install
  32. install: $(TARGETS_INSTALL)
  33. clean: $(TARGETS_CLEAN)
  34. download: $(DOWNLOAD)
  35. gcc-prepare: binutils-install gmp-install mpfr-install
  36. ifeq ($(ADK_TARGET_LIB_GLIBC),y)
  37. $(LIBC)-prepare: gcc-prepare kernel-headers-prepare glibc-ports-prepare
  38. else
  39. $(LIBC)-prepare: gcc-prepare kernel-headers-prepare
  40. endif
  41. gcc-configure: $(LIBC)-prepare
  42. $(LIBC)-compile: gcc-configure
  43. gcc-compile: $(LIBC)-install
  44. $(STAGING_TOOLS):
  45. @mkdir -p $(STAGING_TOOLS)/lib
  46. @mkdir -p $(STAGING_TOOLS)/include
  47. @mkdir -p $(STAGING_TOOLS)/$(REAL_GNU_TARGET_NAME)
  48. @ln -sf ../lib $(STAGING_TOOLS)/$(REAL_GNU_TARGET_NAME)/lib
  49. $(TOOLCHAIN_BUILD_DIR):
  50. @mkdir -p $(TOOLCHAIN_BUILD_DIR)
  51. %-download:
  52. $(TRACE) toolchain/$(patsubst %-download,%,$@)/download
  53. $(MAKE) -C $(patsubst %-download,%,$@) fetch
  54. %-prepare: $(STAGING_TOOLS) $(TOOLCHAIN_BUILD_DIR)
  55. $(TRACE) toolchain/$(patsubst %-prepare,%,$@)/prepare
  56. @if test x"$(patsubst %-prepare,%,$@)" = x"$(LIBC)"; then \
  57. $(MAKE) -C $(patsubst %-prepare,%,$@) prepare \
  58. $(MAKE_TRACE); \
  59. else \
  60. $(MAKE) -C $(patsubst %-prepare,%,$@) prepare \
  61. CC='$(HOSTCC)' CFLAGS='$(HOSTCFLAGS)' \
  62. $(MAKE_TRACE); \
  63. fi
  64. %-configure: %-prepare
  65. $(TRACE) toolchain/$(patsubst %-configure,%,$@)/configure
  66. @if test x"$(patsubst %-configure,%,$@)" = x"$(LIBC)"; then \
  67. $(MAKE) -C $(patsubst %-configure,%,$@) configure \
  68. $(MAKE_TRACE); \
  69. else \
  70. $(MAKE) -C $(patsubst %-configure,%,$@) configure \
  71. CC='$(HOSTCC)' CFLAGS='$(HOSTCFLAGS)' \
  72. $(MAKE_TRACE); \
  73. fi
  74. %-compile: %-configure
  75. $(TRACE) toolchain/$(patsubst %-compile,%,$@)/compile
  76. @if test x"$(patsubst %-compile,%,$@)" = x"$(LIBC)"; then \
  77. $(MAKE) -C $(patsubst %-compile,%,$@) compile \
  78. $(MAKE_TRACE); \
  79. else \
  80. $(MAKE) -C $(patsubst %-compile,%,$@) compile \
  81. CC='$(HOSTCC)' CFLAGS='$(HOSTCFLAGS)' \
  82. $(MAKE_TRACE); \
  83. fi
  84. %-install: %-compile
  85. $(TRACE) toolchain/$(patsubst %-install,%,$@)/install
  86. @if test x"$(patsubst %-install,%,$@)" = x"$(LIBC)"; then \
  87. $(MAKE) -C $(patsubst %-install,%,$@) install \
  88. $(MAKE_TRACE); \
  89. else \
  90. $(MAKE) -C $(patsubst %-install,%,$@) install \
  91. CC='$(HOSTCC)' CFLAGS='$(HOSTCFLAGS)' \
  92. $(MAKE_TRACE); \
  93. fi
  94. %-clean:
  95. $(TRACE) toolchain/$(patsubst %-clean,%,$@)/clean
  96. @$(MAKE) -C $(patsubst %-clean,%,$@) clean $(MAKE_TRACE)