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