b5e4bfa12bc52e82d8e1f972473b3a066ea48ac8
[openwrt/staging/chunkeey.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)/rootfs.mk
11
12 -include $(TMP_DIR)/.packagedeps
13 $(curdir)/autoremove:=1
14 $(curdir)/builddirs:=$(sort $(package-) $(package-y) $(package-m))
15 $(curdir)/builddirs-install:=.
16 $(curdir)/builddirs-default:=. $(sort $(package-y) $(package-m))
17 $(curdir)/builddirs-prereq:=. $(sort $(prereq-y) $(prereq-m))
18 ifdef CHECK_ALL
19 $(curdir)/builddirs-check:=$($(curdir)/builddirs)
20 $(curdir)/builddirs-download:=$($(curdir)/builddirs)
21 endif
22 ifneq ($(IGNORE_ERRORS),)
23 package-y-filter := $(package-y)
24 package-m-filter := $(filter-out $(package-y),$(package-m))
25 package-n-filter := $(filter-out $(package-y) $(package-m),$(package-))
26 package-ignore-errors := $(filter n m y,$(IGNORE_ERRORS))
27 package-ignore-errors := $(if $(package-ignore-errors),$(package-ignore-errors),n m)
28 package-ignore-subdirs := $(sort $(foreach m,$(package-ignore-errors),$(package-$(m)-filter)))
29 $(curdir)/builddirs-ignore-download := $(package-ignore-subdirs)
30 $(curdir)/builddirs-ignore-compile := $(package-ignore-subdirs)
31 $(curdir)/builddirs-ignore-host-download := $(package-ignore-subdirs)
32 $(curdir)/builddirs-ignore-host-compile := $(package-ignore-subdirs)
33 endif
34
35 PACKAGE_INSTALL_FILES:= \
36 $(foreach pkg,$(sort $(package-y)), \
37 $(foreach variant, \
38 $(if $(strip $(package/$(pkg)/variants)), \
39 $(package/$(pkg)/variants), \
40 $(if $(package/$(pkg)/default-variant), \
41 $(package/$(pkg)/default-variant), \
42 default \
43 ) \
44 ), \
45 $(PKG_INFO_DIR)/$(lastword $(subst /,$(space),$(pkg))).$(variant).install \
46 ) \
47 )
48
49 $(curdir)/cleanup: $(TMP_DIR)/.build
50 rm -rf $(STAGING_DIR_ROOT)
51
52 $(curdir)/compile: $(curdir)/cleanup
53
54 $(curdir)/merge:
55 rm -rf $(PACKAGE_DIR_ALL)
56 mkdir -p $(PACKAGE_DIR_ALL)
57 -$(foreach pdir,$(PACKAGE_SUBDIRS),$(if $(wildcard $(pdir)/*.ipk),ln -s $(pdir)/*.ipk $(PACKAGE_DIR_ALL);))
58
59 $(curdir)/merge-index: $(curdir)/merge
60 (cd $(PACKAGE_DIR_ALL) && $(SCRIPT_DIR)/ipkg-make-index.sh . 2>&1 > Packages; )
61
62 $(curdir)/install: $(TMP_DIR)/.build $(curdir)/system/opkg/host/compile $(curdir)/merge $(if $(CONFIG_TARGET_PER_DEVICE_ROOTFS),$(curdir)/merge-index)
63 - find $(STAGING_DIR_ROOT) -type d | $(XARGS) chmod 0755
64 rm -rf $(TARGET_DIR) $(TARGET_DIR_ORIG)
65 [ -d $(TARGET_DIR)/tmp ] || mkdir -p $(TARGET_DIR)/tmp
66 $(call opkg,$(TARGET_DIR)) install \
67 $(call opkg_package_files,$(shell cat $(PACKAGE_INSTALL_FILES) 2>/dev/null))
68 @for file in $(PACKAGE_INSTALL_FILES); do \
69 [ -s $$file.flags ] || continue; \
70 for flag in `cat $$file.flags`; do \
71 $(call opkg,$(TARGET_DIR)) flag $$flag `cat $$file`; \
72 done; \
73 done || true
74 @-$(MAKE) package/preconfig
75
76 $(CP) $(TARGET_DIR) $(TARGET_DIR_ORIG)
77
78 $(call prepare_rootfs,$(TARGET_DIR))
79
80 $(curdir)/index: FORCE
81 @echo Generating package index...
82 @for d in $(PACKAGE_SUBDIRS); do ( \
83 mkdir -p $$d; \
84 cd $$d || continue; \
85 $(SCRIPT_DIR)/ipkg-make-index.sh . 2>&1 > Packages.manifest; \
86 grep -vE '^(Maintainer|LicenseFiles|Source|Require)' Packages.manifest > Packages && \
87 gzip -9nc Packages > Packages.gz; \
88 ); done
89 ifdef CONFIG_SIGNED_PACKAGES
90 @echo Signing package index...
91 @for d in $(PACKAGE_SUBDIRS); do ( \
92 [ -d $$d ] && \
93 cd $$d || continue; \
94 $(STAGING_DIR_HOST)/bin/usign -S -m Packages -s $(BUILD_KEY); \
95 ); done
96 endif
97
98 $(curdir)/preconfig:
99
100 $(curdir)/flags-install:= -j1
101
102 $(eval $(call stampfile,$(curdir),package,prereq,.config))
103 $(eval $(call stampfile,$(curdir),package,compile,$(TMP_DIR)/.build))
104 $(eval $(call stampfile,$(curdir),package,install,$(TMP_DIR)/.build))
105 $(eval $(call stampfile,$(curdir),package,check,$(TMP_DIR)/.build))
106
107 $(eval $(call subdir,$(curdir)))