kernel: add usb-ohci-pci module
[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 $(INCLUDE_DIR)/feeds.mk
11
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 $(curdir)/builddirs-ignore-download := $(foreach m,$(package-ignore-errors),$(package-$(m)-filter))
24 $(curdir)/builddirs-ignore-compile := $(foreach m,$(package-ignore-errors),$(package-$(m)-filter))
25 endif
26
27 ifdef CONFIG_USE_MKLIBS
28 define 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-libs
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) \
42 `cat $(TMP_DIR)/mklibs-libs | sed 's:/*[^/]\+/*$$::' | uniq | sed 's:^$(STAGING_DIR_ROOT):-L :'` \
43 --ldlib $(patsubst $(STAGING_DIR_ROOT)/%,/%,$(firstword $(wildcard \
44 $(foreach name,ld-uClibc.so.* ld-linux.so.* ld-*.so, \
45 $(STAGING_DIR_ROOT)/lib/$(name) \
46 )))) \
47 --target $(REAL_GNU_TARGET_NAME) \
48 `cat $(TMP_DIR)/mklibs-progs $(TMP_DIR)/mklibs-libs` 2>&1
49 $(RSTRIP) $(TMP_DIR)/mklibs-out
50 for lib in `ls $(TMP_DIR)/mklibs-out/*.so.* 2>/dev/null`; do \
51 LIB="$${lib##*/}"; \
52 DEST="`ls "$(TARGET_DIR)/lib/$$LIB" "$(TARGET_DIR)/usr/lib/$$LIB" 2>/dev/null`"; \
53 [ -n "$$DEST" ] || continue; \
54 echo "Copying stripped library $$lib to $$DEST"; \
55 cp "$$lib" "$$DEST" || exit 1; \
56 done
57 endef
58 endif
59
60 # where to build (and put) .ipk packages
61 OPKG:= \
62 IPKG_NO_SCRIPT=1 \
63 IPKG_TMP=$(TMP_DIR)/ipkg \
64 IPKG_INSTROOT=$(TARGET_DIR) \
65 IPKG_CONF_DIR=$(STAGING_DIR)/etc \
66 IPKG_OFFLINE_ROOT=$(TARGET_DIR) \
67 $(XARGS) $(STAGING_DIR_HOST)/bin/opkg \
68 --offline-root $(TARGET_DIR) \
69 --force-depends \
70 --force-overwrite \
71 --force-postinstall \
72 --force-maintainer \
73 --add-dest root:/ \
74 --add-arch all:100 \
75 --add-arch $(if $(ARCH_PACKAGES),$(ARCH_PACKAGES),$(BOARD)):200
76
77 PACKAGE_INSTALL_FILES:= \
78 $(foreach pkg,$(sort $(package-y)), \
79 $(foreach variant, \
80 $(if $(strip $(package/$(pkg)/variants)), \
81 $(package/$(pkg)/variants), \
82 $(if $(package/$(pkg)/default-variant), \
83 $(package/$(pkg)/default-variant), \
84 default \
85 ) \
86 ), \
87 $(PKG_INFO_DIR)/$(lastword $(subst /,$(space),$(pkg))).$(variant).install \
88 ) \
89 )
90
91 $(curdir)/cleanup: $(TMP_DIR)/.build
92 rm -rf $(STAGING_DIR_ROOT)
93
94 $(curdir)/install: $(TMP_DIR)/.build
95 - find $(STAGING_DIR_ROOT) -type d | $(XARGS) chmod 0755
96 rm -rf $(TARGET_DIR)
97 [ -d $(TARGET_DIR)/tmp ] || mkdir -p $(TARGET_DIR)/tmp
98 @$(FIND) `sed -e 's|.*|$(PACKAGE_DIR)$(if $(CONFIG_PER_FEED_REPO),/*)/&_*.ipk|' $(PACKAGE_INSTALL_FILES)` | sort -u | $(OPKG) install
99 @for file in $(PACKAGE_INSTALL_FILES); do \
100 [ -s $$file.flags ] || continue; \
101 for flag in `cat $$file.flags`; do \
102 $(OPKG) flag $$flag < $$file; \
103 done; \
104 done || true
105 @-$(MAKE) package/preconfig
106 @if [ -d $(TOPDIR)/files ]; then \
107 $(call file_copy,$(TOPDIR)/files/.,$(TARGET_DIR)); \
108 fi
109 @mkdir -p $(TARGET_DIR)/etc/rc.d
110 @( \
111 cd $(TARGET_DIR); \
112 for script in ./usr/lib/opkg/info/*.postinst; do \
113 IPKG_INSTROOT=$(TARGET_DIR) $$(which bash) $$script; \
114 done || true \
115 )
116 @-find $(TARGET_DIR) -name CVS | $(XARGS) rm -rf
117 @-find $(TARGET_DIR) -name .svn | $(XARGS) rm -rf
118 @-find $(TARGET_DIR) -name '.#*' | $(XARGS) rm -f
119 rm -f $(TARGET_DIR)/usr/lib/opkg/info/*.postinst*
120 rm -f $(TARGET_DIR)/usr/lib/opkg/info/*.prerm*
121 $(if $(CONFIG_CLEAN_IPKG),rm -rf $(TARGET_DIR)/usr/lib/opkg)
122 $(call mklibs)
123
124 PASSOPT=""
125 PASSARG=""
126 ifndef CONFIG_OPKGSMIME_PASSPHRASE
127 ifneq ($(call qstrip,$(CONFIG_OPKGSMIME_PASSFILE)),)
128 PASSOPT="-passin"
129 PASSARG="file:$(call qstrip,$(CONFIG_OPKGSMIME_PASSFILE))"
130 endif
131 endif
132
133 PACKAGE_SUBDIRS=.
134 ifneq ($(CONFIG_PER_FEED_REPO),)
135 PACKAGE_SUBDIRS=base $(FEEDS_ENABLED)
136 endif
137
138 $(curdir)/index: FORCE
139 @echo Generating package index...
140 @for d in $(PACKAGE_SUBDIRS); do ( \
141 [ -d $(PACKAGE_DIR)/$$d ] && \
142 cd $(PACKAGE_DIR)/$$d || continue; \
143 $(SCRIPT_DIR)/ipkg-make-index.sh . 2>&1 > Packages && \
144 gzip -9c Packages > Packages.gz; \
145 ); done
146 ifeq ($(call qstrip,$(CONFIG_OPKGSMIME_KEY)),)
147 @echo Signing key has not been configured
148 else
149 ifeq ($(call qstrip,$(CONFIG_OPKGSMIME_CERT)),)
150 @echo Certificate has not been configured
151 else
152 @echo Signing package index...
153 @for d in $(PACKAGE_SUBDIRS); do ( \
154 [ -d $(PACKAGE_DIR)/$$d ] && \
155 cd $(PACKAGE_DIR)/$$d || continue; \
156 openssl smime -binary -in Packages.gz \
157 -out Packages.sig -outform PEM -sign \
158 -signer $(CONFIG_OPKGSMIME_CERT) \
159 -inkey $(CONFIG_OPKGSMIME_KEY) \
160 $(PASSOPT) $(PASSARG); \
161 ); done
162 endif
163 endif
164
165 $(curdir)/preconfig:
166
167 $(curdir)/flags-install:= -j1
168
169 $(eval $(call stampfile,$(curdir),package,prereq,.config))
170 $(eval $(call stampfile,$(curdir),package,cleanup,$(TMP_DIR)/.build))
171 $(eval $(call stampfile,$(curdir),package,compile,$(TMP_DIR)/.build))
172 $(eval $(call stampfile,$(curdir),package,install,$(TMP_DIR)/.build))
173
174 $(eval $(call subdir,$(curdir)))