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