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