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