Add an 'Image Configuration' menu to menuconfig
[openwrt/svn-archive/archive.git] / include / package-ipkg.mk
1 #
2 # Copyright (C) 2006,2007 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 define BuildIPKGVariable
9 $(call shexport,Package/$(1)/$(2))
10 $(1)_COMMANDS += var2file "$(call shvar,Package/$(1)/$(2))" $(2);
11 endef
12
13 ifeq ($(DUMP),)
14 define BuildIPKG
15 IPKG_$(1):=$(PACKAGE_DIR)/$(1)_$(VERSION)_$(PKGARCH).ipk
16 IDIR_$(1):=$(PKG_BUILD_DIR)/ipkg/$(1)
17 INFO_$(1):=$(IPKG_STATE_DIR)/info/$(1).list
18
19 ifdef Package/$(1)/install
20 ifeq ($(CONFIG_PACKAGE_$(1)),y)
21 install: $$(INFO_$(1))
22 endif
23
24 ifneq ($(CONFIG_PACKAGE_$(1))$(DEVELOPER)$(SDK),)
25 compile: $$(IPKG_$(1))
26 else
27 compile: $(1)-disabled
28 $(1)-disabled:
29 @echo "WARNING: skipping $(1) -- package not selected"
30 endif
31 endif
32
33 ifeq ($(FORCEREBUILD),y)
34 $$(IPKG_$(1)): FORCE
35 endif
36
37 IDEPEND_$(1):=$$(strip $$(DEPENDS))
38
39
40 $(eval $(call BuildIPKGVariable,$(1),conffiles))
41 $(eval $(call BuildIPKGVariable,$(1),preinst))
42 $(eval $(call BuildIPKGVariable,$(1),postinst))
43 $(eval $(call BuildIPKGVariable,$(1),prerm))
44 $(eval $(call BuildIPKGVariable,$(1),postrm))
45 $$(IDIR_$(1))/CONTROL/control: $(PKG_BUILD_DIR)/.version-$(1)_$(VERSION)_$(PKGARCH)
46 @rm -f $(PACKAGE_DIR)/$(1)_*
47 mkdir -p $$(IDIR_$(1))/CONTROL
48 echo "Package: $(1)" > $$(IDIR_$(1))/CONTROL/control
49 echo "Version: $(VERSION)" >> $$(IDIR_$(1))/CONTROL/control
50 ( \
51 DEPENDS='$(EXTRA_DEPENDS)'; \
52 for depend in $$(filter-out @%,$$(IDEPEND_$(1))); do \
53 DEPENDS=$$$${DEPENDS:+$$$$DEPENDS, }$$$${depend##+}; \
54 done; \
55 echo "Depends: $$$$DEPENDS" >> $$(IDIR_$(1))/CONTROL/control; \
56 )
57 ( \
58 echo "Source: $(SOURCE)"; \
59 echo "Section: $(SECTION)"; \
60 echo "Priority: $(PRIORITY)"; \
61 echo "Maintainer: $(MAINTAINER)"; \
62 echo "Architecture: $(PKGARCH)"; \
63 echo -n "Description: "; getvar $(call shvar,Package/$(1)/description) | sed -e 's,^[[:space:]]*, ,g'; \
64 ) >> $$(IDIR_$(1))/CONTROL/control
65 chmod 644 $$(IDIR_$(1))/CONTROL/control
66 (cd $$(IDIR_$(1))/CONTROL; \
67 $($(1)_COMMANDS) \
68 )
69
70 $$(IPKG_$(1)): $(PKG_BUILD_DIR)/.built $$(IDIR_$(1))/CONTROL/control
71 $(call Package/$(1)/install,$$(IDIR_$(1)))
72 mkdir -p $(PACKAGE_DIR)
73 -find $$(IDIR_$(1)) -name CVS | xargs rm -rf
74 -find $$(IDIR_$(1)) -name .svn | xargs rm -rf
75 -find $$(IDIR_$(1)) -name '.#*' | xargs rm -f
76 $(RSTRIP) $$(IDIR_$(1))
77 $(IPKG_BUILD) $$(IDIR_$(1)) $(PACKAGE_DIR)
78 @[ -f $$(IPKG_$(1)) ] || false
79
80 $$(INFO_$(1)): $$(IPKG_$(1))
81 $(IPKG) install $$(IPKG_$(1))
82
83 $(1)-clean:
84 rm -f $(PACKAGE_DIR)/$(1)_*
85
86 clean: $(1)-clean
87
88 $(PKG_BUILD_DIR)/.version-$(1)_$(VERSION)_$(PKGARCH): $(PKG_BUILD_DIR)/.prepared
89 -@rm -f $(PKG_BUILD_DIR)/.version-$(1)_* 2>/dev/null
90 @touch $$@
91
92 $$(eval $$(call Build/DefaultTargets,$(1)))
93
94 ifdef Package/$(1)/install
95 ifneq ($$(CONFIG_PACKAGE_$(1))$(DEVELOPER)$(SDK),)
96 ifneq ($(MAKECMDGOALS),prereq)
97 ifneq ($(DUMP),1)
98 ifneq ($$(shell $(SCRIPT_DIR)/timestamp.pl -p -x ipkg -x ipkg-install '$$(IPKG_$(1))' '$(PKG_BUILD_DIR)'),$$(IPKG_$(1)))
99 $(PKG_BUILD_DIR)/.built: package-rebuild
100 $$(info Rebuilding $(subst $(TOPDIR)/,,$$(IPKG_$(1))))
101 endif
102 endif
103 endif
104 endif
105 endif
106 endef
107 endif