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 $(TMP_DIR)/.packagedeps
11 $(curdir)/builddirs:=$(sort $(package-) $(package-y) $(package-m))
12 $(curdir)/builddirs-install:=.
15 $(curdir)/builddirs-default:=. $(sort $(package-y) $(package-m))
16 $(curdir)/builddirs-prereq:=. $(sort $(prereq-y) $(prereq-m))
18 ifneq ($(IGNORE_ERRORS),)
19 package-y-filter := $(package-y)
20 package-m-filter := $(filter-out $(package-y),$(package-m))
21 package-n-filter := $(filter-out $(package-y) $(package-m),$(package-))
22 package-ignore-errors := $(filter n m y,$(IGNORE_ERRORS))
23 package-ignore-errors := $(if $(package-ignore-errors),$(package-ignore-errors),n m)
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-progs
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) \
44 -L /usr/lib/ebtables \
45 --ldlib $(patsubst $(STAGING_DIR_ROOT)/%,/%,$(firstword $(wildcard \
46 $(foreach name,ld-uClibc.so.* ld-linux.so.* ld-*.so, \
47 $(STAGING_DIR_ROOT)/lib/$(name) \
49 --target $(REAL_GNU_TARGET_NAME) \
50 `cat $(TMP_DIR)/mklibs-progs` 2>&1
51 $(RSTRIP) $(TMP_DIR)/mklibs-out
52 for lib in `ls $(TMP_DIR)/mklibs-out/*.so.* 2>/dev/null`; do \
54 DEST="`ls "$(TARGET_DIR)/lib/$$LIB" "$(TARGET_DIR)/usr/lib/$$LIB" 2>/dev/null`"; \
55 [ -n "$$DEST" ] || continue; \
56 echo "Copying stripped library $$lib to $$DEST"; \
57 cp "$$lib" "$$DEST" || exit 1; \
62 # where to build (and put) .ipk packages
64 IPKG_TMP=$(TMP_DIR)/ipkg \
65 IPKG_INSTROOT=$(TARGET_DIR) \
66 IPKG_CONF_DIR=$(STAGING_DIR)/etc \
67 IPKG_OFFLINE_ROOT=$(TARGET_DIR) \
68 $(XARGS) $(STAGING_DIR_HOST)/bin/opkg \
69 --offline-root $(TARGET_DIR) \
76 --add-arch $(if $(ARCH_PACKAGES),$(ARCH_PACKAGES),$(BOARD)):200
78 PACKAGE_INSTALL_FILES:= \
79 $(foreach pkg,$(sort $(package-y)), \
81 $(if $(package/$(pkg)/variants), \
82 $(package/$(pkg)/variants), \
83 $(if $(package/$(pkg)/default-variant), \
84 $(package/$(pkg)/default-variant), \
88 $(PKG_INFO_DIR)/$(lastword $(subst /,$(space),$(pkg))).$(variant).install \
92 $(curdir)/cleanup: $(TMP_DIR)/.build
93 rm -rf $(STAGING_DIR_ROOT)
95 $(curdir)/install: $(TMP_DIR)/.build
96 - find $(STAGING_DIR_ROOT) -type d | $(XARGS) chmod 0755
98 [ -d $(TARGET_DIR)/tmp ] || mkdir -p $(TARGET_DIR)/tmp
99 @$(FIND) `sed -e 's|.*|$(PACKAGE_DIR)/&_*.ipk|' $(PACKAGE_INSTALL_FILES)` | sort -u | $(OPKG) install
100 @for file in $(PACKAGE_INSTALL_FILES); do \
101 [ -s $$file.flags ] || continue; \
102 for flag in `cat $$file.flags`; do \
103 $(OPKG) flag $$flag < $$file; \
106 @-$(MAKE) package/preconfig
107 @if [ -d $(TOPDIR)/files ]; then \
108 $(call file_copy,$(TOPDIR)/files/.,$(TARGET_DIR)); \
110 @mkdir -p $(TARGET_DIR)/etc/rc.d
113 for script in ./etc/init.d/*; do \
114 grep '#!/bin/sh /etc/rc.common' $$script >/dev/null || continue; \
115 IPKG_INSTROOT=$(TARGET_DIR) $$(which bash) ./etc/rc.common $$script enable; \
118 @-find $(TARGET_DIR) -name CVS | $(XARGS) rm -rf
119 @-find $(TARGET_DIR) -name .svn | $(XARGS) rm -rf
120 @-find $(TARGET_DIR) -name '.#*' | $(XARGS) rm -f
121 rm -f $(TARGET_DIR)/usr/lib/opkg/info/*.postinst
122 $(if $(CONFIG_CLEAN_IPKG),rm -rf $(TARGET_DIR)/usr/lib/opkg)
125 $(curdir)/index: FORCE
126 @(cd $(PACKAGE_DIR); $(SCRIPT_DIR)/ipkg-make-index.sh . 2>&1 > Packages && \
127 gzip -9c Packages > Packages.gz \
132 $(curdir)/flags-install:= -j1
134 $(eval $(call stampfile,$(curdir),package,prereq,.config))
135 $(eval $(call stampfile,$(curdir),package,cleanup,$(TMP_DIR)/.build))
136 $(eval $(call stampfile,$(curdir),package,compile,$(TMP_DIR)/.build))
137 $(eval $(call stampfile,$(curdir),package,install,$(TMP_DIR)/.build))
139 $(eval $(call subdir,$(curdir)))