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