lantiq: move the dsl-modem config to network.@dsl-modem[-1]
[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 $(curdir)/builddirs-install:=.
13 $(curdir)/builddirs-default:=. $(sort $(package-y) $(package-m))
14 $(curdir)/builddirs-prereq:=. $(sort $(prereq-y) $(prereq-m))
15 ifneq ($(IGNORE_ERRORS),)
16 package-y-filter := $(package-y)
17 package-m-filter := $(filter-out $(package-y),$(package-m))
18 package-n-filter := $(filter-out $(package-y) $(package-m),$(package-))
19 package-ignore-errors := $(filter n m y,$(IGNORE_ERRORS))
20 package-ignore-errors := $(if $(package-ignore-errors),$(package-ignore-errors),n m)
21 $(curdir)/builddirs-ignore-compile := $(foreach m,$(package-ignore-errors),$(package-$(m)-filter))
22 endif
23
24 ifdef CONFIG_USE_MKLIBS
25 define mklibs
26 rm -rf $(TMP_DIR)/mklibs-progs $(TMP_DIR)/mklibs-out
27 # first find all programs and add them to the mklibs list
28 find $(STAGING_DIR_ROOT) -type f -perm +100 -exec \
29 file -r -N -F '' {} + | \
30 awk ' /executable.*dynamically/ { print $$1 }' > $(TMP_DIR)/mklibs-progs
31 # find all loadable objects that are not regular libraries and add them to the list as well
32 find $(STAGING_DIR_ROOT) -type f -name \*.so\* -exec \
33 file -r -N -F '' {} + | \
34 awk ' /shared object/ { print $$1 }' > $(TMP_DIR)/mklibs-libs
35 mkdir -p $(TMP_DIR)/mklibs-out
36 $(STAGING_DIR_HOST)/bin/mklibs -D \
37 -d $(TMP_DIR)/mklibs-out \
38 --sysroot $(STAGING_DIR_ROOT) \
39 `cat $(TMP_DIR)/mklibs-libs | sed 's:/*[^/]\+/*$$::' | uniq | sed 's:^$(STAGING_DIR_ROOT):-L :'` \
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) \
43 )))) \
44 --target $(REAL_GNU_TARGET_NAME) \
45 `cat $(TMP_DIR)/mklibs-progs $(TMP_DIR)/mklibs-libs` 2>&1
46 $(RSTRIP) $(TMP_DIR)/mklibs-out
47 for lib in `ls $(TMP_DIR)/mklibs-out/*.so.* 2>/dev/null`; do \
48 LIB="$${lib##*/}"; \
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; \
53 done
54 endef
55 endif
56
57 # where to build (and put) .ipk packages
58 OPKG:= \
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 $(XARGS) $(STAGING_DIR_HOST)/bin/opkg \
64 --offline-root $(TARGET_DIR) \
65 --force-depends \
66 --force-overwrite \
67 --force-postinstall \
68 --force-maintainer \
69 --add-dest root:/ \
70 --add-arch all:100 \
71 --add-arch $(if $(ARCH_PACKAGES),$(ARCH_PACKAGES),$(BOARD)):200
72
73 PACKAGE_INSTALL_FILES:= \
74 $(foreach pkg,$(sort $(package-y)), \
75 $(foreach variant, \
76 $(if $(strip $(package/$(pkg)/variants)), \
77 $(package/$(pkg)/variants), \
78 $(if $(package/$(pkg)/default-variant), \
79 $(package/$(pkg)/default-variant), \
80 default \
81 ) \
82 ), \
83 $(PKG_INFO_DIR)/$(lastword $(subst /,$(space),$(pkg))).$(variant).install \
84 ) \
85 )
86
87 $(curdir)/cleanup: $(TMP_DIR)/.build
88 rm -rf $(STAGING_DIR_ROOT)
89
90 $(curdir)/install: $(TMP_DIR)/.build
91 - find $(STAGING_DIR_ROOT) -type d | $(XARGS) chmod 0755
92 rm -rf $(TARGET_DIR)
93 [ -d $(TARGET_DIR)/tmp ] || mkdir -p $(TARGET_DIR)/tmp
94 @$(FIND) `sed -e 's|.*|$(PACKAGE_DIR)/&_*.ipk|' $(PACKAGE_INSTALL_FILES)` | sort -u | $(OPKG) install
95 @for file in $(PACKAGE_INSTALL_FILES); do \
96 [ -s $$file.flags ] || continue; \
97 for flag in `cat $$file.flags`; do \
98 $(OPKG) flag $$flag < $$file; \
99 done; \
100 done || true
101 @-$(MAKE) package/preconfig
102 @if [ -d $(TOPDIR)/files ]; then \
103 $(call file_copy,$(TOPDIR)/files/.,$(TARGET_DIR)); \
104 fi
105 @mkdir -p $(TARGET_DIR)/etc/rc.d
106 @( \
107 cd $(TARGET_DIR); \
108 for script in ./etc/init.d/*; do \
109 grep '#!/bin/sh /etc/rc.common' $$script >/dev/null || continue; \
110 IPKG_INSTROOT=$(TARGET_DIR) $$(which bash) ./etc/rc.common $$script enable; \
111 done || true \
112 )
113 @-find $(TARGET_DIR) -name CVS | $(XARGS) rm -rf
114 @-find $(TARGET_DIR) -name .svn | $(XARGS) rm -rf
115 @-find $(TARGET_DIR) -name '.#*' | $(XARGS) rm -f
116 rm -f $(TARGET_DIR)/usr/lib/opkg/info/*.postinst
117 $(if $(CONFIG_CLEAN_IPKG),rm -rf $(TARGET_DIR)/usr/lib/opkg)
118 $(call mklibs)
119
120 PASSOPT=""
121 PASSARG=""
122 ifndef CONFIG_OPKGSMIME_PASSPHRASE
123 ifneq ($(call qstrip,$(CONFIG_OPKGSMIME_PASSFILE)),)
124 PASSOPT="-passin"
125 PASSARG="file:$(call qstrip,$(CONFIG_OPKGSMIME_PASSFILE))"
126 endif
127 endif
128
129 $(curdir)/index: FORCE
130 @echo Generating package index...
131 @(cd $(PACKAGE_DIR); \
132 $(SCRIPT_DIR)/ipkg-make-index.sh . 2>&1 > Packages && \
133 gzip -9c Packages > Packages.gz )
134 ifeq ($(call qstrip,$(CONFIG_OPKGSMIME_KEY)),)
135 @echo Signing key has not been configured
136 else
137 ifeq ($(call qstrip,$(CONFIG_OPKGSMIME_CERT)),)
138 @echo Certificate has not been configured
139 else
140 @echo Signing package index...
141 @(cd $(PACKAGE_DIR); \
142 openssl smime -binary -in Packages.gz \
143 -out Packages.sig -outform PEM -sign \
144 -signer $(CONFIG_OPKGSMIME_CERT) \
145 -inkey $(CONFIG_OPKGSMIME_KEY) \
146 $(PASSOPT) $(PASSARG) )
147 endif
148 endif
149
150 $(curdir)/preconfig:
151
152 $(curdir)/flags-install:= -j1
153
154 $(eval $(call stampfile,$(curdir),package,prereq,.config))
155 $(eval $(call stampfile,$(curdir),package,cleanup,$(TMP_DIR)/.build))
156 $(eval $(call stampfile,$(curdir),package,compile,$(TMP_DIR)/.build))
157 $(eval $(call stampfile,$(curdir),package,install,$(TMP_DIR)/.build))
158
159 $(eval $(call subdir,$(curdir)))