3c7b0b49bc477b02a45d3aae27fd3201224596e0
[openwrt/svn-archive/archive.git] / package / Makefile
1 #
2 # Copyright (C) 2006-2010 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7
8 curdir:=package
9
10 -include $(TMP_DIR)/.packagedeps
11 $(curdir)/builddirs:=$(sort $(package-) $(package-y) $(package-m))
12 ifeq ($(SDK),1)
13 $(curdir)/builddirs-install:=.
14 else
15 $(curdir)/base-files/compile += $(curdir)/opkg/host/compile
16 $(curdir)/builddirs-default:=. $(sort $(package-y) $(package-m))
17 $(curdir)/builddirs-prereq:=. $(sort $(prereq-y) $(prereq-m))
18 $(curdir)/builddirs-install:=. $(sort $(package-y))
19 endif
20 ifneq ($(IGNORE_ERRORS),)
21 $(curdir)/builddirs-ignore-compile:= $(if $(filter m y, $(IGNORE_ERRORS)),$(foreach m,$(IGNORE_ERRORS),$(package-$(m))),$(package-m))
22 endif
23
24 $(curdir)/install:=$(curdir)/install-cleanup
25
26 $(curdir)/cleanup: $(TMP_DIR)/.build
27 - find $(STAGING_DIR_ROOT) -type d | $(XARGS) chmod 0755
28 rm -rf $(TARGET_DIR) $(STAGING_DIR_ROOT)
29
30 ifdef CONFIG_USE_MKLIBS
31 define 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-progs
41 mkdir -p $(TMP_DIR)/mklibs-out
42 $(STAGING_DIR_HOST)/bin/mklibs.py -D \
43 -d $(TMP_DIR)/mklibs-out \
44 --sysroot $(STAGING_DIR_ROOT) \
45 -L /lib \
46 -L /usr/lib \
47 -L /usr/lib/ebtables \
48 --ldlib $(patsubst $(STAGING_DIR_ROOT)/%,/%,$(firstword $(wildcard \
49 $(foreach name,ld-uClibc.so.* ld-linux.so.* ld-*.so, \
50 $(STAGING_DIR_ROOT)/lib/$(name) \
51 )))) \
52 --target $(REAL_GNU_TARGET_NAME) \
53 `cat $(TMP_DIR)/mklibs-progs` 2>&1
54 $(RSTRIP) $(TMP_DIR)/mklibs-out
55 for lib in `ls $(TMP_DIR)/mklibs-out/*.so.* 2>/dev/null`; do \
56 LIB="$${lib##*/}"; \
57 DEST="`ls "$(TARGET_DIR)/lib/$$LIB" "$(TARGET_DIR)/usr/lib/$$LIB" 2>/dev/null`"; \
58 [ -n "$$DEST" ] || continue; \
59 echo "Copying stripped library $$lib to $$DEST"; \
60 cp "$$lib" "$$DEST" || exit 1; \
61 done
62 endef
63 endif
64
65 $(curdir)/rootfs-prepare: $(TMP_DIR)/.build
66 @-$(MAKE) package/preconfig
67 @if [ -d $(TOPDIR)/files ]; then \
68 $(CP) $(TOPDIR)/files/. $(TARGET_DIR); \
69 fi
70 @mkdir -p $(TARGET_DIR)/etc/rc.d
71 @( \
72 cd $(TARGET_DIR); \
73 for script in ./etc/init.d/*; do \
74 grep '#!/bin/sh /etc/rc.common' $$script >/dev/null || continue; \
75 IPKG_INSTROOT=$(TARGET_DIR) $$(which bash) ./etc/rc.common $$script enable; \
76 done || true \
77 )
78 @-find $(TARGET_DIR) -name CVS | $(XARGS) rm -rf
79 @-find $(TARGET_DIR) -name .svn | $(XARGS) rm -rf
80 @-find $(TARGET_DIR) -name '.#*' | $(XARGS) rm -f
81 $(if $(CONFIG_CLEAN_IPKG),rm -rf $(TARGET_DIR)/usr/lib/opkg)
82 $(call mklibs)
83
84 $(curdir)/index: FORCE
85 @(cd $(PACKAGE_DIR); $(SCRIPT_DIR)/ipkg-make-index.sh . > Packages && \
86 gzip -9c Packages > Packages.gz \
87 )
88
89 $(curdir)/flags-install:= -j1
90
91 $(eval $(call stampfile,$(curdir),package,prereq,.config))
92 $(eval $(call stampfile,$(curdir),package,cleanup))
93 $(eval $(call stampfile,$(curdir),package,compile))
94 $(eval $(call stampfile,$(curdir),package,install))
95 $(eval $(call stampfile,$(curdir),package,rootfs-prepare))
96
97 $(eval $(call subdir,$(curdir)))