Makefile 4.1 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:=$(VERSION_DIST)-SDK-$(if $(CONFIG_VERSION_FILENAMES),$(VERSION_NUMBER)-)$(BOARD)$(if $(SUBTARGET),-$(SUBTARGET))$(if $(GCCV),_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_TOOLCHAIN := staging_dir/toolchain-$(ARCH)$(ARCH_SUFFIX)_gcc-$(GCCV)_$(LIBC)-$(LIBCV)$(if $(CONFIG_arm),_eabi)
  16. EXCLUDE_DIRS:=*/ccache \
  17. */stamp \
  18. */stampfiles \
  19. */man \
  20. */info \
  21. */root-* \
  22. initial \
  23. *.install.clean \
  24. *.install.flags \
  25. *.install \
  26. */doc
  27. SDK_DIRS = \
  28. $(STAGING_SUBDIR_HOST) \
  29. $(STAGING_SUBDIR_TOOLCHAIN)
  30. BASE_FEED:=$(shell git config --get remote.origin.url 2>/dev/null | sed -ne 's/^/src-git base /p')
  31. 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'))
  32. 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'))
  33. 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)
  34. KDIR_BASE = $(patsubst $(TOPDIR)/%,%,$(LINUX_DIR))
  35. KERNEL_FILES_ARCH = \
  36. Makefile* \
  37. module.lds \
  38. Kbuild.platforms \
  39. */Platform \
  40. include \
  41. */include \
  42. scripts \
  43. kernel/asm-offsets.s
  44. KERNEL_FILES_BASE := \
  45. .config \
  46. Makefile \
  47. scripts \
  48. include \
  49. Module.symvers \
  50. modules.builtin \
  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. `cd $(TOPDIR); find $(KDIR_BASE) -name \*.ko` \
  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