Makefile 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. #
  2. # Copyright (C) 2006-2014 OpenWrt.org
  3. #
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. include $(TOPDIR)/rules.mk
  8. include $(INCLUDE_DIR)/kernel.mk
  9. include $(INCLUDE_DIR)/host.mk
  10. include $(INCLUDE_DIR)/version.mk
  11. override MAKEFLAGS=
  12. SDK_NAME:=libreCMC-SDK-$(if $(CONFIG_VERSION_FILENAMES),$(VERSION_NUMBER)-)$(BOARD)$(if $(SUBTARGET),-$(SUBTARGET))_gcc-$(GCCV)$(DIR_SUFFIX).$(HOST_OS)-$(HOST_ARCH)
  13. SDK_BUILD_DIR:=$(BUILD_DIR)/$(SDK_NAME)
  14. STAGING_SUBDIR_HOST := staging_dir/host
  15. STAGING_SUBDIR_TARGET := staging_dir/target-$(ARCH)$(ARCH_SUFFIX)_$(LIBC)-$(LIBCV)$(if $(CONFIG_arm),_eabi)
  16. STAGING_SUBDIR_TOOLCHAIN := staging_dir/toolchain-$(ARCH)$(ARCH_SUFFIX)_gcc-$(GCCV)_$(LIBC)-$(LIBCV)$(if $(CONFIG_arm),_eabi)
  17. EXCLUDE_DIRS:=*/ccache \
  18. */stamp \
  19. */stampfiles \
  20. */man \
  21. */info \
  22. */root-* \
  23. initial \
  24. *.install.clean \
  25. *.install.flags \
  26. *.install \
  27. */doc
  28. SDK_DIRS = \
  29. $(STAGING_SUBDIR_HOST) \
  30. $(STAGING_SUBDIR_TARGET) \
  31. $(STAGING_SUBDIR_TOOLCHAIN)
  32. BASE_FEED:=$(shell git config --get remote.origin.url 2>/dev/null | sed -ne 's/^/src-git base /p')
  33. BASE_FEED:=$(if $(BASE_FEED),$(BASE_FEED),$(shell cd $(TOPDIR); LC_ALL=C git svn info 2>/dev/null | sed -ne 's/^URL: /src-gitsvn base /p'))
  34. BASE_FEED:=$(if $(BASE_FEED),$(BASE_FEED),$(shell cd $(TOPDIR); LC_ALL=C svn info 2>/dev/null | sed -ne 's/^URL: /src-svn base /p'))
  35. KDIR_BASE = $(patsubst $(TOPDIR)/%,%,$(LINUX_DIR))
  36. KERNEL_FILES_ARCH = \
  37. Makefile* \
  38. module.lds \
  39. Kbuild.platforms \
  40. */Platform \
  41. include \
  42. */include \
  43. scripts \
  44. kernel/asm-offsets.s
  45. KERNEL_FILES_BASE := \
  46. .config \
  47. Makefile \
  48. scripts \
  49. include \
  50. Module.symvers \
  51. $(addprefix arch/$(LINUX_KARCH)/,$(KERNEL_FILES_ARCH))
  52. KERNEL_FILES := $(patsubst $(TOPDIR)/%,%,$(wildcard $(addprefix $(LINUX_DIR)/,$(KERNEL_FILES_BASE))))
  53. all: compile
  54. $(BIN_DIR)/$(SDK_NAME).tar.bz2: clean
  55. mkdir -p $(SDK_BUILD_DIR)/dl $(SDK_BUILD_DIR)/package
  56. $(CP) $(INCLUDE_DIR) $(SCRIPT_DIR) $(TOPDIR)/docs $(SDK_BUILD_DIR)/
  57. $(TAR) -cf - -C $(TOPDIR) \
  58. $(foreach exclude,$(EXCLUDE_DIRS),--exclude="$(exclude)") \
  59. $(SDK_DIRS) $(KERNEL_FILES) | \
  60. $(TAR) -xf - -C $(SDK_BUILD_DIR)
  61. @-( \
  62. find \
  63. $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_HOST)/bin \
  64. $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_HOST)/usr/bin \
  65. $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_TOOLCHAIN)/bin \
  66. $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_TOOLCHAIN)/*/bin \
  67. $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_TOOLCHAIN)/libexec \
  68. -type f; \
  69. find \
  70. $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_HOST)/lib \
  71. $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_HOST)/usr/lib \
  72. -type f -name \*.so\* -or -name \*.a; \
  73. ) | xargs strip 2>/dev/null >/dev/null
  74. mkdir -p $(SDK_BUILD_DIR)/target/linux
  75. $(CP) $(GENERIC_PLATFORM_DIR) $(PLATFORM_DIR) $(SDK_BUILD_DIR)/target/linux/
  76. rm -rf \
  77. $(SDK_BUILD_DIR)/target/linux/*/files* \
  78. $(SDK_BUILD_DIR)/target/linux/*/patches*
  79. ./convert-config.pl $(TOPDIR)/.config > $(SDK_BUILD_DIR)/Config-build.in
  80. $(CP) -L \
  81. $(TOPDIR)/LICENSE \
  82. $(TOPDIR)/rules.mk \
  83. $(TOPDIR)/.config \
  84. ./files/Config.in \
  85. ./files/Makefile \
  86. ./files/include/prepare.mk \
  87. ./files/README.SDK \
  88. $(SDK_BUILD_DIR)/
  89. $(CP) \
  90. $(TOPDIR)/package/Makefile \
  91. $(SDK_BUILD_DIR)/package/
  92. -rm -f $(SDK_BUILD_DIR)/feeds.conf.default
  93. $(if $(BASE_FEED),echo "$(BASE_FEED)" > $(SDK_BUILD_DIR)/feeds.conf.default)
  94. if [ -f $(TOPDIR)/feeds.conf ]; then \
  95. cat $(TOPDIR)/feeds.conf >> $(SDK_BUILD_DIR)/feeds.conf.default; \
  96. else \
  97. cat $(TOPDIR)/feeds.conf.default >> $(SDK_BUILD_DIR)/feeds.conf.default; \
  98. fi
  99. $(SED) 's,^# REVISION:=.*,REVISION:=$(REVISION),g' $(SDK_BUILD_DIR)/include/version.mk
  100. $(SED) '/LINUX_VERMAGIC:=/ { s,unknown,$(LINUX_VERMAGIC),g }' $(SDK_BUILD_DIR)/include/kernel.mk
  101. find $(SDK_BUILD_DIR) -name .git | $(XARGS) rm -rf
  102. find $(SDK_BUILD_DIR) -name .svn | $(XARGS) rm -rf
  103. find $(SDK_BUILD_DIR) -name CVS | $(XARGS) rm -rf
  104. (cd $(BUILD_DIR); \
  105. tar cfj $@ $(SDK_NAME); \
  106. )
  107. download:
  108. prepare:
  109. compile: $(BIN_DIR)/$(SDK_NAME).tar.bz2
  110. install: compile
  111. clean:
  112. rm -rf $(SDK_BUILD_DIR) $(BIN_DIR)/$(SDK_NAME).tar.bz2