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