Makefile 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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:=OpenWrt-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. BASE_FEED:=$(if $(BASE_FEED),$(BASE_FEED),src-git base https://git.openwrt.org/$(filter-out unknown/ r%/,$(subst $(space),.,$(wordlist 1,2,$(subst .,$(space),$(VERSION_NUMBER))))/)openwrt.git)
  36. KDIR_BASE = $(patsubst $(TOPDIR)/%,%,$(LINUX_DIR))
  37. KERNEL_FILES_ARCH = \
  38. Makefile* \
  39. module.lds \
  40. Kbuild.platforms \
  41. */Platform \
  42. include \
  43. */include \
  44. scripts \
  45. kernel/asm-offsets.s
  46. KERNEL_FILES_BASE := \
  47. .config \
  48. Makefile \
  49. scripts \
  50. include \
  51. Module.symvers \
  52. $(addprefix arch/$(LINUX_KARCH)/,$(KERNEL_FILES_ARCH))
  53. KERNEL_FILES := $(patsubst $(TOPDIR)/%,%,$(wildcard $(addprefix $(LINUX_DIR)/,$(KERNEL_FILES_BASE))))
  54. all: compile
  55. $(BIN_DIR)/$(SDK_NAME).tar.bz2: clean
  56. mkdir -p $(SDK_BUILD_DIR)/dl $(SDK_BUILD_DIR)/package
  57. $(CP) $(INCLUDE_DIR) $(SCRIPT_DIR) $(TOPDIR)/docs $(SDK_BUILD_DIR)/
  58. $(TAR) -cf - -C $(TOPDIR) \
  59. $(foreach exclude,$(EXCLUDE_DIRS),--exclude="$(exclude)") \
  60. $(SDK_DIRS) $(KERNEL_FILES) | \
  61. $(TAR) -xf - -C $(SDK_BUILD_DIR)
  62. @-( \
  63. find \
  64. $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_HOST)/bin \
  65. $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_HOST)/usr/bin \
  66. $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_TOOLCHAIN)/bin \
  67. $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_TOOLCHAIN)/*/bin \
  68. $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_TOOLCHAIN)/libexec \
  69. -type f; \
  70. find \
  71. $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_HOST)/lib \
  72. $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_HOST)/usr/lib \
  73. -type f -name \*.so\* -or -name \*.a; \
  74. ) | xargs strip 2>/dev/null >/dev/null
  75. mkdir -p $(SDK_BUILD_DIR)/target/linux
  76. $(CP) $(GENERIC_PLATFORM_DIR) $(PLATFORM_DIR) $(SDK_BUILD_DIR)/target/linux/
  77. rm -rf \
  78. $(SDK_BUILD_DIR)/target/linux/*/files* \
  79. $(SDK_BUILD_DIR)/target/linux/*/patches*
  80. ./convert-config.pl $(TOPDIR)/.config > $(SDK_BUILD_DIR)/Config-build.in
  81. $(CP) -L \
  82. $(TOPDIR)/LICENSE \
  83. $(TOPDIR)/rules.mk \
  84. $(TOPDIR)/.config \
  85. ./files/Config.in \
  86. ./files/Makefile \
  87. ./files/include/prepare.mk \
  88. ./files/README.SDK \
  89. $(SDK_BUILD_DIR)/
  90. $(CP) \
  91. $(TOPDIR)/package/Makefile \
  92. $(SDK_BUILD_DIR)/package/
  93. -rm -f $(SDK_BUILD_DIR)/feeds.conf.default
  94. $(if $(BASE_FEED),echo "$(BASE_FEED)" > $(SDK_BUILD_DIR)/feeds.conf.default)
  95. if [ -f $(TOPDIR)/feeds.conf ]; then \
  96. cat $(TOPDIR)/feeds.conf >> $(SDK_BUILD_DIR)/feeds.conf.default; \
  97. else \
  98. cat $(TOPDIR)/feeds.conf.default >> $(SDK_BUILD_DIR)/feeds.conf.default; \
  99. fi
  100. $(SED) 's,^# REVISION:=.*,REVISION:=$(REVISION),g' $(SDK_BUILD_DIR)/include/version.mk
  101. $(SED) '/LINUX_VERMAGIC:=/ { s,unknown,$(LINUX_VERMAGIC),g }' $(SDK_BUILD_DIR)/include/kernel.mk
  102. find $(SDK_BUILD_DIR) -name .git | $(XARGS) rm -rf
  103. find $(SDK_BUILD_DIR) -name .svn | $(XARGS) rm -rf
  104. find $(SDK_BUILD_DIR) -name CVS | $(XARGS) rm -rf
  105. (cd $(BUILD_DIR); \
  106. tar cfj $@ $(SDK_NAME); \
  107. )
  108. download:
  109. prepare:
  110. compile: $(BIN_DIR)/$(SDK_NAME).tar.bz2
  111. install: compile
  112. clean:
  113. rm -rf $(SDK_BUILD_DIR) $(BIN_DIR)/$(SDK_NAME).tar.bz2