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 package-ignore-subdirs
:= $(sort $(foreach m
,$(package-ignore-errors
),$(package-
$(m
)-filter)))
24 $(curdir
)/builddirs-ignore-download
:= $(package-ignore-subdirs
)
25 $(curdir
)/builddirs-ignore-compile
:= $(package-ignore-subdirs
)
26 $(curdir
)/builddirs-ignore-host-download
:= $(package-ignore-subdirs
)
27 $(curdir
)/builddirs-ignore-host-compile
:= $(package-ignore-subdirs
)
30 ifdef CONFIG_USE_MKLIBS
32 rm -rf
$(TMP_DIR
)/mklibs-progs
$(TMP_DIR
)/mklibs-out
33 # first find all programs and add them to the mklibs list
34 find
$(STAGING_DIR_ROOT
) -type f
-perm
/100 -exec \
35 file
-r
-N
-F
'' {} + | \
36 awk
' /executable.*dynamically/ { print $$1 }' > $(TMP_DIR
)/mklibs-progs
37 # find all loadable objects that are not regular libraries and add them to the list as well
38 find
$(STAGING_DIR_ROOT
) -type f
-name \
*.so\
* -exec \
39 file
-r
-N
-F
'' {} + | \
40 awk
' /shared object/ { print $$1 }' > $(TMP_DIR
)/mklibs-libs
41 mkdir
-p
$(TMP_DIR
)/mklibs-out
42 $(STAGING_DIR_HOST
)/bin
/mklibs
-D \
43 -d
$(TMP_DIR
)/mklibs-out \
44 --sysroot
$(STAGING_DIR_ROOT
) \
45 `cat $(TMP_DIR)/mklibs-libs | sed 's:/*[^/]\+/*$$::' | uniq | sed 's:^$(STAGING_DIR_ROOT):-L :'` \
46 --ldlib
$(patsubst $(STAGING_DIR_ROOT
)/%,/%,$(firstword $(wildcard \
47 $(foreach name
,ld-uClibc.so.
* ld-linux.so.
* ld-
*.so ld-musl-
*.so.
*, \
48 $(STAGING_DIR_ROOT
)/lib
/$(name
) \
50 --target
$(REAL_GNU_TARGET_NAME
) \
51 `cat $(TMP_DIR)/mklibs-progs $(TMP_DIR)/mklibs-libs` 2>&1
52 $(RSTRIP
) $(TMP_DIR
)/mklibs-out
53 for lib in
`ls $(TMP_DIR)/mklibs-out/*.so.* 2>/dev/null`; do \
55 DEST
="`ls "$(TARGET_DIR
)/lib
/$$LIB" "$(TARGET_DIR
)/usr
/lib
/$$LIB" 2>/dev/null`"; \
56 [ -n
"$$DEST" ] || continue
; \
57 echo
"Copying stripped library $$lib to $$DEST"; \
58 cp
"$$lib" "$$DEST" || exit
1; \
63 # where to build (and put) .ipk packages
66 IPKG_TMP
=$(TMP_DIR
)/ipkg \
67 IPKG_INSTROOT
=$(TARGET_DIR
) \
68 IPKG_CONF_DIR
=$(STAGING_DIR
)/etc \
69 IPKG_OFFLINE_ROOT
=$(TARGET_DIR
) \
70 $(XARGS
) $(STAGING_DIR_HOST
)/bin
/opkg \
71 --offline-root
$(TARGET_DIR
) \
78 --add-arch
$(if
$(ARCH_PACKAGES
),$(ARCH_PACKAGES
),$(BOARD
)):200
80 PACKAGE_INSTALL_FILES
:= \
81 $(foreach pkg
,$(sort $(package-y
)), \
83 $(if
$(strip $(package
/$(pkg
)/variants
)), \
84 $(package
/$(pkg
)/variants
), \
85 $(if
$(package
/$(pkg
)/default-variant
), \
86 $(package
/$(pkg
)/default-variant
), \
90 $(PKG_INFO_DIR
)/$(lastword
$(subst /,$(space
),$(pkg
))).
$(variant
).
install \
94 $(curdir
)/cleanup
: $(TMP_DIR
)/.build
95 rm -rf
$(STAGING_DIR_ROOT
)
97 $(curdir
)/install: $(TMP_DIR
)/.build
$(curdir
)/system
/opkg
/host
/install
98 - find
$(STAGING_DIR_ROOT
) -type d |
$(XARGS
) chmod
0755
100 [ -d
$(TARGET_DIR
)/tmp
] || mkdir
-p
$(TARGET_DIR
)/tmp
101 @
$(FIND
) `sed -e 's|.*|$(PACKAGE_DIR)$(if $(CONFIG_PER_FEED_REPO),/*)/&_*.ipk|' $(PACKAGE_INSTALL_FILES)` |
sort -u |
$(OPKG
) install
102 @for file in
$(PACKAGE_INSTALL_FILES
); do \
103 [ -s
$$file.flags
] || continue
; \
104 for flag in
`cat $$file.flags`; do \
105 $(OPKG
) flag
$$flag < $$file; \
108 @
-$(MAKE
) package
/preconfig
109 @if
[ -d
$(TOPDIR
)/files
]; then \
110 $(call file_copy
,$(TOPDIR
)/files
/.
,$(TARGET_DIR
)); \
112 @mkdir
-p
$(TARGET_DIR
)/etc
/rc.d
115 for script in .
/usr
/lib
/opkg
/info/*.postinst
; do \
116 IPKG_INSTROOT
=$(TARGET_DIR
) $$(which bash
) $$script; \
118 for script in .
/etc
/init.d
/*; do \
119 grep
'#!/bin/sh /etc/rc.common' $$script >/dev
/null || continue
; \
120 IPKG_INSTROOT
=$(TARGET_DIR
) $$(which bash
) .
/etc
/rc.common
$$script enable
; \
123 $(if
$(SOURCE_DATE_EPOCH
),sed
-i
"s/Installed-Time: .*/Installed-Time: $(SOURCE_DATE_EPOCH)/" $(TARGET_DIR
)/usr
/lib
/opkg
/status
)
124 @
-find
$(TARGET_DIR
) -name CVS |
$(XARGS
) rm -rf
125 @
-find
$(TARGET_DIR
) -name .svn |
$(XARGS
) rm -rf
126 @
-find
$(TARGET_DIR
) -name
'.#*' |
$(XARGS
) rm -f
127 rm -f
$(TARGET_DIR
)/usr
/lib
/opkg
/info/*.postinst
*
128 rm -f
$(TARGET_DIR
)/usr
/lib
/opkg
/info/*.prerm
*
129 $(if
$(CONFIG_CLEAN_IPKG
),rm -rf
$(TARGET_DIR
)/usr
/lib
/opkg
)
134 ifndef CONFIG_OPKGSMIME_PASSPHRASE
135 ifneq ($(call qstrip
,$(CONFIG_OPKGSMIME_PASSFILE
)),)
137 PASSARG
="file:$(call qstrip,$(CONFIG_OPKGSMIME_PASSFILE))"
142 ifneq ($(CONFIG_PER_FEED_REPO
),)
143 ifneq ($(CONFIG_PER_FEED_REPO_ADD_DISABLED
),)
144 PACKAGE_SUBDIRS
=base kernel
$(FEEDS_AVAILABLE
)
146 PACKAGE_SUBDIRS
=base kernel
$(FEEDS_ENABLED
)
150 $(curdir
)/index
: FORCE
151 @echo Generating package index...
152 @for d in
$(PACKAGE_SUBDIRS
); do
( \
153 mkdir
-p
$(PACKAGE_DIR
)/$$d; \
154 cd
$(PACKAGE_DIR
)/$$d || continue
; \
155 $(SCRIPT_DIR
)/ipkg-make-index.sh .
2>&1 > Packages
&& \
156 gzip
-9nc Packages
> Packages.gz
; \
158 ifdef CONFIG_SIGNED_PACKAGES
159 @echo Signing package index...
160 @for d in
$(PACKAGE_SUBDIRS
); do
( \
161 [ -d
$(PACKAGE_DIR
)/$$d ] && \
162 cd
$(PACKAGE_DIR
)/$$d || continue
; \
163 $(STAGING_DIR_HOST
)/bin
/usign
-S
-m Packages
-s
$(BUILD_KEY
); \
166 ifeq ($(call qstrip
,$(CONFIG_OPKGSMIME_KEY
)),)
167 @echo Signing key has not been configured
169 ifeq ($(call qstrip
,$(CONFIG_OPKGSMIME_CERT
)),)
170 @echo Certificate has not been configured
172 @echo Signing package index...
173 @for d in
$(PACKAGE_SUBDIRS
); do
( \
174 [ -d
$(PACKAGE_DIR
)/$$d ] && \
175 cd
$(PACKAGE_DIR
)/$$d || continue
; \
176 openssl smime
-binary
-in Packages.gz \
177 -out Packages.sig
-outform PEM
-sign \
178 -signer
$(CONFIG_OPKGSMIME_CERT
) \
179 -inkey
$(CONFIG_OPKGSMIME_KEY
) \
180 $(PASSOPT
) $(PASSARG
); \
188 $(curdir
)/flags-install
:= -j1
190 $(eval
$(call stampfile
,$(curdir
),package
,prereq
,.config
))
191 $(eval
$(call stampfile
,$(curdir
),package
,cleanup
,$(TMP_DIR
)/.build
))
192 $(eval
$(call stampfile
,$(curdir
),package
,compile
,$(TMP_DIR
)/.build
))
193 $(eval
$(call stampfile
,$(curdir
),package
,install,$(TMP_DIR
)/.build
))
195 $(eval
$(call subdir
,$(curdir
)))