054b5aa7965f01658f60a707311eb851a3dd0818
[lede.git] / include / feeds.mk
1 #
2 # Copyright (C) 2014 OpenWrt.org
3 # Copyright (C) 2016 LEDE Project
4 #
5 # This is free software, licensed under the GNU General Public License v2.
6 # See /LICENSE for more information.
7 #
8
9 -include $(TMP_DIR)/.packagesubdirs
10
11 FEEDS_INSTALLED:=$(notdir $(wildcard $(TOPDIR)/package/feeds/*))
12 FEEDS_AVAILABLE:=$(sort $(FEEDS_INSTALLED) $(shell $(SCRIPT_DIR)/feeds list -n))
13 FEEDS_ENABLED:=$(foreach feed,$(FEEDS_AVAILABLE),$(if $(CONFIG_FEED_$(feed)),$(feed)))
14 FEEDS_DISABLED:=$(filter-out $(FEEDS_ENABLED),$(FEEDS_AVAILABLE))
15
16 PACKAGE_SUBDIRS=$(PACKAGE_DIR)
17 ifneq ($(CONFIG_PER_FEED_REPO),)
18   PACKAGE_SUBDIRS += $(OUTPUT_DIR)/packages/$(ARCH_PACKAGES)/base
19   ifneq ($(CONFIG_PER_FEED_REPO_ADD_DISABLED),)
20     PACKAGE_SUBDIRS += $(foreach FEED,$(FEEDS_AVAILABLE),$(OUTPUT_DIR)/packages/$(ARCH_PACKAGES)/$(FEED))
21   else
22     PACKAGE_SUBDIRS += $(foreach FEED,$(FEEDS_ENABLED),$(OUTPUT_DIR)/packages/$(ARCH_PACKAGES)/$(FEED))
23   endif
24 endif
25
26 PACKAGE_DIR_ALL := $(TOPDIR)/staging_dir/packages/$(BOARD)
27
28 opkg_package_files = $(wildcard \
29         $(foreach dir,$(PACKAGE_SUBDIRS), \
30           $(foreach pkg,$(1), $(dir)/$(pkg)_*.ipk)))
31
32 PKG_CONFIG_DEPENDS += \
33         CONFIG_PER_FEED_REPO \
34         CONFIG_PER_FEED_REPO_ADD_DISABLED \
35         CONFIG_PER_FEED_REPO_ADD_COMMENTED \
36         $(foreach feed,$(FEEDS_INSTALLED),CONFIG_FEED_$(feed))
37
38 # 1: package name
39 define FeedPackageDir
40 $(strip $(if $(CONFIG_PER_FEED_REPO), \
41   $(if $(Package/$(1)/subdir), \
42     $(abspath $(OUTPUT_DIR)/packages/$(ARCH_PACKAGES)/$(Package/$(1)/subdir)), \
43     $(PACKAGE_DIR)), \
44   $(PACKAGE_DIR)))
45 endef
46
47 # 1: destination file
48 define FeedSourcesAppend
49 ( \
50   echo "src/gz %n_core %U/targets/%S/packages"; \
51   $(strip $(if $(CONFIG_PER_FEED_REPO), \
52         $(foreach feed,base $(FEEDS_ENABLED),echo "src/gz %n_$(feed) %U/packages/%A/$(feed)";) \
53         $(if $(CONFIG_PER_FEED_REPO_ADD_DISABLED), \
54                 $(foreach feed,$(FEEDS_DISABLED),echo "$(if $(CONFIG_PER_FEED_REPO_ADD_COMMENTED),# )src/gz %n_$(feed) %U/packages/%A/$(feed)";)))) \
55 ) >> $(1)
56 endef