Using find's -exec to remove directories causes 'not found' errors when find tries...
[openwrt-10.03/.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       ifneq ($(CONFIG_PACKAGE_$(1))$(SDK)$(DEVELOPER),)
21         compile: $$(IPKG_$(1))
22
23         ifeq ($(CONFIG_PACKAGE_$(1)),y)
24           install: $$(INFO_$(1))
25         endif
26
27         ifneq ($(MAKECMDGOALS),prereq)
28           ifneq ($$(shell $(SCRIPT_DIR)/timestamp.pl -p -x ipkg -x ipkg-install '$$(IPKG_$(1))' '$(PKG_BUILD_DIR)'),$$(IPKG_$(1)))
29             $(PKG_BUILD_DIR)/.built: package-rebuild
30             $$(info Rebuilding $(subst $(TOPDIR)/,,$$(IPKG_$(1))))
31           endif
32         endif
33
34       else
35         compile: $(1)-disabled
36         $(1)-disabled:
37                 @echo "WARNING: skipping $(1) -- package not selected"
38       endif
39     endif
40
41     IDEPEND_$(1):=$$(strip $$(DEPENDS))
42   
43     $(eval $(call BuildIPKGVariable,$(1),conffiles))
44     $(eval $(call BuildIPKGVariable,$(1),preinst))
45     $(eval $(call BuildIPKGVariable,$(1),postinst))
46     $(eval $(call BuildIPKGVariable,$(1),prerm))
47     $(eval $(call BuildIPKGVariable,$(1),postrm))
48     $$(IDIR_$(1))/CONTROL/control: $(PKG_BUILD_DIR)/.version-$(1)_$(VERSION)_$(PKGARCH)
49         @rm -f $(PACKAGE_DIR)/$(1)_*
50         mkdir -p $$(IDIR_$(1))/CONTROL
51         echo "Package: $(1)" > $$(IDIR_$(1))/CONTROL/control
52         echo "Version: $(VERSION)" >> $$(IDIR_$(1))/CONTROL/control
53         ( \
54                 DEPENDS='$(EXTRA_DEPENDS)'; \
55                 for depend in $$(filter-out @%,$$(IDEPEND_$(1))); do \
56                         DEPENDS=$$$${DEPENDS:+$$$$DEPENDS, }$$$${depend##+}; \
57                 done; \
58                 echo "Depends: $$$$DEPENDS"; \
59                 echo "Source: $(SOURCE)"; \
60                 echo "Section: $(SECTION)"; \
61                 echo "Priority: $(PRIORITY)"; \
62                 echo "Maintainer: $(MAINTAINER)"; \
63                 echo "Architecture: $(PKGARCH)"; \
64                 echo -n "Description: "; getvar $(call shvar,Package/$(1)/description) | sed -e 's,^[[:space:]]*, ,g'; \
65         ) >> $$(IDIR_$(1))/CONTROL/control
66         chmod 644 $$(IDIR_$(1))/CONTROL/control
67         (cd $$(IDIR_$(1))/CONTROL; \
68                 $($(1)_COMMANDS) \
69         )
70
71     $$(IPKG_$(1)): $(PKG_BUILD_DIR)/.built $$(IDIR_$(1))/CONTROL/control
72         $(call Package/$(1)/install,$$(IDIR_$(1)))
73         mkdir -p $(PACKAGE_DIR)
74         -find $$(IDIR_$(1)) -name CVS   -exec rm -rf {} +
75         -find $$(IDIR_$(1)) -name .svn  -exec rm -rf {} +
76         -find $$(IDIR_$(1)) -name '.#*' -exec rm -f  {} +
77         $(RSTRIP) $$(IDIR_$(1))
78         $(IPKG_BUILD) $$(IDIR_$(1)) $(PACKAGE_DIR)
79         @[ -f $$(IPKG_$(1)) ] || false 
80
81     $$(INFO_$(1)): $$(IPKG_$(1))
82         $(IPKG) install $$(IPKG_$(1))
83
84     $(1)-clean:
85         rm -f $(PACKAGE_DIR)/$(1)_*
86
87     clean: $(1)-clean
88
89     $(PKG_BUILD_DIR)/.version-$(1)_$(VERSION)_$(PKGARCH): $(PKG_BUILD_DIR)/.prepared
90         -@rm -f $(PKG_BUILD_DIR)/.version-$(1)_* 2>/dev/null
91         @touch $$@
92
93     $$(eval $$(call Build/DefaultTargets,$(1)))
94
95   endef
96 endif