call Build/Clean for clean: in package makefiles
[openwrt/svn-archive/archive.git] / include / package.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 all: $(if $(DUMP),dumpinfo,compile)
9
10 PKG_BUILD_DIR ?= $(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
11 PKG_INSTALL_DIR ?= $(PKG_BUILD_DIR)/ipkg-install
12
13 include $(INCLUDE_DIR)/prereq.mk
14 include $(INCLUDE_DIR)/host.mk
15 include $(INCLUDE_DIR)/unpack.mk
16 include $(INCLUDE_DIR)/package-defaults.mk
17 include $(INCLUDE_DIR)/package-dumpinfo.mk
18 include $(INCLUDE_DIR)/package-ipkg.mk
19
20 STAMP_PREPARED:=$(PKG_BUILD_DIR)/.prepared
21 STAMP_CONFIGURED:=$(PKG_BUILD_DIR)/.configured
22 STAMP_BUILT:=$(PKG_BUILD_DIR)/.built
23 export CONFIG_SITE:=$(INCLUDE_DIR)/site/$(REAL_GNU_TARGET_NAME)
24
25 define Build/DefaultTargets
26 ifneq ($(strip $(PKG_SOURCE_URL)),)
27 download: $(DL_DIR)/$(PKG_SOURCE)
28
29 $(DL_DIR)/$(PKG_SOURCE):
30 mkdir -p $(DL_DIR)
31 $(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(PKG_SOURCE)" "$(PKG_MD5SUM)" $(PKG_SOURCE_URL)
32
33 $(STAMP_PREPARED): $(DL_DIR)/$(PKG_SOURCE)
34 endif
35
36 ifeq ($(DUMP),)
37 ifeq ($(CONFIG_AUTOREBUILD),y)
38 ifneq ($$(shell $(SCRIPT_DIR)/timestamp.pl -p $(PKG_BUILD_DIR) . $(PKG_FILE_DEPEND)),$(PKG_BUILD_DIR))
39 $$(info Forcing package rebuild)
40 $(STAMP_PREPARED): clean
41 endif
42 endif
43 endif
44
45 $(STAMP_PREPARED):
46 @-rm -rf $(PKG_BUILD_DIR)
47 @mkdir -p $(PKG_BUILD_DIR)
48 $(Build/Prepare)
49 touch $$@
50
51 $(STAMP_CONFIGURED): $(STAMP_PREPARED)
52 $(Build/Configure)
53 touch $$@
54
55 $(STAMP_BUILT): $(STAMP_CONFIGURED)
56 $(Build/Compile)
57 touch $$@
58
59 ifdef Build/InstallDev
60 ifneq ($$(shell $(SCRIPT_DIR)/timestamp.pl -p -x ipkg -x ipkg-install $(STAGING_DIR)/stampfiles/.$(PKG_NAME)-installed $(PKG_BUILD_DIR)),$(STAGING_DIR)/stampfiles/.$(PKG_NAME)-installed)
61 $(STAMP_BUILT): package-rebuild
62 endif
63
64 compile: $(STAGING_DIR)/stampfiles/.$(PKG_NAME)-installed
65 $(STAGING_DIR)/stampfiles/.$(PKG_NAME)-installed: $(STAMP_BUILT)
66 mkdir -p $(STAGING_DIR)/stampfiles
67 $(Build/InstallDev)
68 touch $$@
69 endif
70
71 package-rebuild: FORCE
72 @-rm -f $(STAMP_BUILT)
73
74 define Build/DefaultTargets
75 endef
76 endef
77
78 define BuildPackage
79 $(eval $(Package/Default))
80 $(eval $(Package/$(1)))
81
82 # <HACK> Support obsolete DESCRIPTION field
83 ifndef Package/$(1)/description
84 define Package/$(1)/description
85 $(TITLE)$(subst \,
86 ,\ $(DESCRIPTION))
87 endef
88 endif
89 # </HACK>
90
91 $(foreach FIELD, TITLE CATEGORY PRIORITY SECTION VERSION,
92 ifeq ($($(FIELD)),)
93 $$(error Package/$(1) is missing the $(FIELD) field)
94 endif
95 )
96
97 $(call shexport,Package/$(1)/description)
98 $(call shexport,Package/$(1)/config)
99
100 $(Dumpinfo)
101 $(BuildIPKG)
102 endef
103
104 define Build/Prepare
105 $(call Build/Prepare/Default,)
106 endef
107
108 define Build/Configure
109 $(call Build/Configure/Default,)
110 endef
111
112 define Build/Compile
113 $(call Build/Compile/Default,)
114 endef
115
116 $(PACKAGE_DIR):
117 mkdir -p $@
118
119 dumpinfo:
120 download:
121 prepare: $(STAMP_PREPARED)
122 configure: $(STAMP_CONFIGURED)
123 compile:
124 install:
125 clean: FORCE
126 $(Build/UninstallDev)
127 $(Build/Clean)
128 @rm -f $(STAGING_DIR)/stampfiles/.$(PKG_NAME)-installed
129 @rm -rf $(PKG_BUILD_DIR)