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 $(curdir
)/builddirs-ignore-compile
:= $(if
$(filter n m y
, $(IGNORE_ERRORS
)),$(foreach m
,$(IGNORE_ERRORS
),$(package-
$(subst n
,,$(m
)))),$(package-m
) $(package-
))
22 ifdef CONFIG_USE_MKLIBS
24 rm -rf
$(TMP_DIR
)/mklibs-progs
$(TMP_DIR
)/mklibs-out
25 # first find all programs and add them to the mklibs list
26 find
$(STAGING_DIR_ROOT
) -type f
-perm
+100 -exec \
27 file
-r
-N
-F
'' {} + | \
28 awk
' /executable.*dynamically/ { print $$1 }' > $(TMP_DIR
)/mklibs-progs
29 # find all loadable objects that are not regular libraries and add them to the list as well
30 find
$(STAGING_DIR_ROOT
) -type f
-name \
*.so\
* -exec \
31 file
-r
-N
-F
'' {} + | \
32 awk
' /shared object/ { print $$1 }' >> $(TMP_DIR
)/mklibs-progs
33 mkdir
-p
$(TMP_DIR
)/mklibs-out
34 $(STAGING_DIR_HOST
)/bin
/mklibs
-D \
35 -d
$(TMP_DIR
)/mklibs-out \
36 --sysroot
$(STAGING_DIR_ROOT
) \
39 -L
/usr
/lib
/ebtables \
40 --ldlib
$(patsubst $(STAGING_DIR_ROOT
)/%,/%,$(firstword $(wildcard \
41 $(foreach name
,ld-uClibc.so.
* ld-linux.so.
* ld-
*.so
, \
42 $(STAGING_DIR_ROOT
)/lib
/$(name
) \
44 --target
$(REAL_GNU_TARGET_NAME
) \
45 `cat $(TMP_DIR)/mklibs-progs` 2>&1
46 $(RSTRIP
) $(TMP_DIR
)/mklibs-out
47 for lib in
`ls $(TMP_DIR)/mklibs-out/*.so.* 2>/dev/null`; do \
49 DEST
="`ls "$(TARGET_DIR
)/lib
/$$LIB" "$(TARGET_DIR
)/usr
/lib
/$$LIB" 2>/dev/null`"; \
50 [ -n
"$$DEST" ] || continue
; \
51 echo
"Copying stripped library $$lib to $$DEST"; \
52 cp
"$$lib" "$$DEST" || exit
1; \
57 # where to build (and put) .ipk packages
59 IPKG_TMP
=$(TMP_DIR
)/ipkg \
60 IPKG_INSTROOT
=$(TARGET_DIR
) \
61 IPKG_CONF_DIR
=$(STAGING_DIR
)/etc \
62 IPKG_OFFLINE_ROOT
=$(TARGET_DIR
) \
63 $(STAGING_DIR_HOST
)/bin
/opkg \
64 --offline-root
$(TARGET_DIR
) \
71 --add-arch
$(if
$(ARCH_PACKAGES
),$(ARCH_PACKAGES
),$(BOARD
)):200
73 PACKAGE_INSTALL
:=$(sort $(foreach pkg
,$(package-y
),$(lastword
$(subst /,$(space
),$(pkg
)))))
74 PACKAGE_INSTALL_FILES
:=$(patsubst %,$(PKG_INFO_DIR
)/%.
install,$(PACKAGE_INSTALL
))
76 $(curdir
)/cleanup
: $(TMP_DIR
)/.build
77 rm -rf
$(STAGING_DIR_ROOT
)
79 $(curdir
)/install: $(TMP_DIR
)/.build
80 - find
$(STAGING_DIR_ROOT
) -type d |
$(XARGS
) chmod
0755
82 [ -d
$(TARGET_DIR
)/tmp
] || mkdir
-p
$(TARGET_DIR
)/tmp
83 $(OPKG
) install `cat $(PACKAGE_INSTALL_FILES) | sed -e 's,^\(.*\)$$,$(PACKAGE_DIR)/\1_*.ipk,'`
84 @for pkg in
$(PACKAGE_INSTALL
); do \
85 [ -s
$(PKG_INFO_DIR
)/$${pkg}.
install.flags
] || continue
; \
86 for flag in
`cat $(PKG_INFO_DIR)/$${pkg}.install.flags`; do \
87 $(OPKG
) flag
$$flag `cat $(PKG_INFO_DIR)/$${pkg}.install`; \
90 @
-$(MAKE
) package
/preconfig
91 @if
[ -d
$(TOPDIR
)/files
]; then \
92 ( cd
$(TOPDIR
)/files
; find
-type f
) | \
93 ( cd
$(TARGET_DIR
); while
:; do \
95 [ -z
"$$FILE" ] && break
; \
96 [ -L
"$$FILE" ] || continue
; \
97 echo
"Removing symlink $(TARGET_DIR)/$$FILE"; \
100 $(CP
) $(TOPDIR
)/files
/.
$(TARGET_DIR
); \
102 @mkdir
-p
$(TARGET_DIR
)/etc
/rc.d
105 for script in .
/etc
/init.d
/*; do \
106 grep
'#!/bin/sh /etc/rc.common' $$script >/dev
/null || continue
; \
107 IPKG_INSTROOT
=$(TARGET_DIR
) $$(which bash
) .
/etc
/rc.common
$$script enable
; \
110 @
-find
$(TARGET_DIR
) -name CVS |
$(XARGS
) rm -rf
111 @
-find
$(TARGET_DIR
) -name .svn |
$(XARGS
) rm -rf
112 @
-find
$(TARGET_DIR
) -name
'.#*' |
$(XARGS
) rm -f
113 rm -f
$(TARGET_DIR
)/usr
/lib
/opkg
/info/*.postinst
114 $(if
$(CONFIG_CLEAN_IPKG
),rm -rf
$(TARGET_DIR
)/usr
/lib
/opkg
)
117 $(curdir
)/index
: FORCE
118 @
(cd
$(PACKAGE_DIR
); $(SCRIPT_DIR
)/ipkg-make-index.sh .
2>&1 > Packages
&& \
119 gzip
-9c Packages
> Packages.gz \
124 $(curdir
)/flags-install
:= -j1
126 $(eval
$(call stampfile
,$(curdir
),package
,prereq
,.config
))
127 $(eval
$(call stampfile
,$(curdir
),package
,cleanup
,$(TMP_DIR
)/.build
))
128 $(eval
$(call stampfile
,$(curdir
),package
,compile
,$(TMP_DIR
)/.build
))
129 $(eval
$(call stampfile
,$(curdir
),package
,install,$(TMP_DIR
)/.build
))
131 $(eval
$(call subdir
,$(curdir
)))