2 # Copyright (C) 2006-2010 OpenWrt.org
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
10 include $(INCLUDE_DIR)/feeds.mk
12 -include $(TMP_DIR)/.packagedeps
13 $(curdir)/builddirs:=$(sort $(package-) $(package-y) $(package-m))
14 $(curdir)/builddirs-install:=.
15 $(curdir)/builddirs-default:=. $(sort $(package-y) $(package-m))
16 $(curdir)/builddirs-prereq:=. $(sort $(prereq-y) $(prereq-m))
17 ifneq ($(IGNORE_ERRORS),)
18 package-y-filter := $(package-y)
19 package-m-filter := $(filter-out $(package-y),$(package-m))
20 package-n-filter := $(filter-out $(package-y) $(package-m),$(package-))
21 package-ignore-errors := $(filter n m y,$(IGNORE_ERRORS))
22 package-ignore-errors := $(if $(package-ignore-errors),$(package-ignore-errors),n m)
23 $(curdir)/builddirs-ignore-download := $(foreach m,$(package-ignore-errors),$(package-$(m)-filter))
24 $(curdir)/builddirs-ignore-compile := $(foreach m,$(package-ignore-errors),$(package-$(m)-filter))
27 ifdef CONFIG_USE_MKLIBS
29 rm -rf $(TMP_DIR)/mklibs-progs $(TMP_DIR)/mklibs-out
30 # first find all programs and add them to the mklibs list
31 find $(STAGING_DIR_ROOT) -type f -perm /100 -exec \
32 file -r -N -F '' {} + | \
33 awk ' /executable.*dynamically/ { print $$1 }' > $(TMP_DIR)/mklibs-progs
34 # find all loadable objects that are not regular libraries and add them to the list as well
35 find $(STAGING_DIR_ROOT) -type f -name \*.so\* -exec \
36 file -r -N -F '' {} + | \
37 awk ' /shared object/ { print $$1 }' > $(TMP_DIR)/mklibs-libs
38 mkdir -p $(TMP_DIR)/mklibs-out
39 $(STAGING_DIR_HOST)/bin/mklibs -D \
40 -d $(TMP_DIR)/mklibs-out \
41 --sysroot $(STAGING_DIR_ROOT) \
42 `cat $(TMP_DIR)/mklibs-libs | sed 's:/*[^/]\+/*$$::' | uniq | sed 's:^$(STAGING_DIR_ROOT):-L :'` \
43 --ldlib $(patsubst $(STAGING_DIR_ROOT)/%,/%,$(firstword $(wildcard \
44 $(foreach name,ld-uClibc.so.* ld-linux.so.* ld-*.so, \
45 $(STAGING_DIR_ROOT)/lib/$(name) \
47 --target $(REAL_GNU_TARGET_NAME) \
48 `cat $(TMP_DIR)/mklibs-progs $(TMP_DIR)/mklibs-libs` 2>&1
49 $(RSTRIP) $(TMP_DIR)/mklibs-out
50 for lib in `ls $(TMP_DIR)/mklibs-out/*.so.* 2>/dev/null`; do \
52 DEST="`ls "$(TARGET_DIR)/lib/$$LIB" "$(TARGET_DIR)/usr/lib/$$LIB" 2>/dev/null`"; \
53 [ -n "$$DEST" ] || continue; \
54 echo "Copying stripped library $$lib to $$DEST"; \
55 cp "$$lib" "$$DEST" || exit 1; \
60 # where to build (and put) .ipk packages
63 IPKG_TMP=$(TMP_DIR)/ipkg \
64 IPKG_INSTROOT=$(TARGET_DIR) \
65 IPKG_CONF_DIR=$(STAGING_DIR)/etc \
66 IPKG_OFFLINE_ROOT=$(TARGET_DIR) \
67 $(XARGS) $(STAGING_DIR_HOST)/bin/opkg \
68 --offline-root $(TARGET_DIR) \
75 --add-arch $(if $(ARCH_PACKAGES),$(ARCH_PACKAGES),$(BOARD)):200
77 PACKAGE_INSTALL_FILES:= \
78 $(foreach pkg,$(sort $(package-y)), \
80 $(if $(strip $(package/$(pkg)/variants)), \
81 $(package/$(pkg)/variants), \
82 $(if $(package/$(pkg)/default-variant), \
83 $(package/$(pkg)/default-variant), \
87 $(PKG_INFO_DIR)/$(lastword $(subst /,$(space),$(pkg))).$(variant).install \
91 $(curdir)/cleanup: $(TMP_DIR)/.build
92 rm -rf $(STAGING_DIR_ROOT)
94 $(curdir)/install: $(TMP_DIR)/.build
95 - find $(STAGING_DIR_ROOT) -type d | $(XARGS) chmod 0755
97 [ -d $(TARGET_DIR)/tmp ] || mkdir -p $(TARGET_DIR)/tmp
98 @$(FIND) `sed -e 's|.*|$(PACKAGE_DIR)$(if $(CONFIG_PER_FEED_REPO),/*)/&_*.ipk|' $(PACKAGE_INSTALL_FILES)` | sort -u | $(OPKG) install
99 @for file in $(PACKAGE_INSTALL_FILES); do \
100 [ -s $$file.flags ] || continue; \
101 for flag in `cat $$file.flags`; do \
102 $(OPKG) flag $$flag < $$file; \
105 @-$(MAKE) package/preconfig
106 @if [ -d $(TOPDIR)/files ]; then \
107 $(call file_copy,$(TOPDIR)/files/.,$(TARGET_DIR)); \
109 @mkdir -p $(TARGET_DIR)/etc/rc.d
112 for script in ./usr/lib/opkg/info/*.postinst; do \
113 IPKG_INSTROOT=$(TARGET_DIR) $$(which bash) $$script; \
116 @-find $(TARGET_DIR) -name CVS | $(XARGS) rm -rf
117 @-find $(TARGET_DIR) -name .svn | $(XARGS) rm -rf
118 @-find $(TARGET_DIR) -name '.#*' | $(XARGS) rm -f
119 rm -f $(TARGET_DIR)/usr/lib/opkg/info/*.postinst*
120 rm -f $(TARGET_DIR)/usr/lib/opkg/info/*.prerm*
121 $(if $(CONFIG_CLEAN_IPKG),rm -rf $(TARGET_DIR)/usr/lib/opkg)
126 ifndef CONFIG_OPKGSMIME_PASSPHRASE
127 ifneq ($(call qstrip,$(CONFIG_OPKGSMIME_PASSFILE)),)
129 PASSARG="file:$(call qstrip,$(CONFIG_OPKGSMIME_PASSFILE))"
134 ifneq ($(CONFIG_PER_FEED_REPO),)
135 PACKAGE_SUBDIRS=base $(FEEDS_ENABLED)
138 $(curdir)/index: FORCE
139 @echo Generating package index...
140 @for d in $(PACKAGE_SUBDIRS); do ( \
141 [ -d $(PACKAGE_DIR)/$$d ] && \
142 cd $(PACKAGE_DIR)/$$d || continue; \
143 $(SCRIPT_DIR)/ipkg-make-index.sh . 2>&1 > Packages && \
144 gzip -9c Packages > Packages.gz; \
146 ifdef CONFIG_SIGNED_PACKAGES
147 @echo Signing package index...
148 @for d in $(PACKAGE_SUBDIRS); do ( \
149 [ -d $(PACKAGE_DIR)/$$d ] && \
150 cd $(PACKAGE_DIR)/$$d || continue; \
151 $(STAGING_DIR_HOST)/bin/usign -S -m Packages -s $(BUILD_KEY); \
154 ifeq ($(call qstrip,$(CONFIG_OPKGSMIME_KEY)),)
155 @echo Signing key has not been configured
157 ifeq ($(call qstrip,$(CONFIG_OPKGSMIME_CERT)),)
158 @echo Certificate has not been configured
160 @echo Signing package index...
161 @for d in $(PACKAGE_SUBDIRS); do ( \
162 [ -d $(PACKAGE_DIR)/$$d ] && \
163 cd $(PACKAGE_DIR)/$$d || continue; \
164 openssl smime -binary -in Packages.gz \
165 -out Packages.sig -outform PEM -sign \
166 -signer $(CONFIG_OPKGSMIME_CERT) \
167 -inkey $(CONFIG_OPKGSMIME_KEY) \
168 $(PASSOPT) $(PASSARG); \
176 $(curdir)/flags-install:= -j1
178 $(eval $(call stampfile,$(curdir),package,prereq,.config))
179 $(eval $(call stampfile,$(curdir),package,cleanup,$(TMP_DIR)/.build))
180 $(eval $(call stampfile,$(curdir),package,compile,$(TMP_DIR)/.build))
181 $(eval $(call stampfile,$(curdir),package,install,$(TMP_DIR)/.build))
183 $(eval $(call subdir,$(curdir)))