swconfig: add a generic method for setting the port primary vlan id (used for transpa...
[openwrt.git] / include / package.mk
1 #
2 # Copyright (C) 2006-2008 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)$(if $(PKG_VERSION),-$(PKG_VERSION))
11 PKG_INSTALL_DIR ?= $(PKG_BUILD_DIR)/ipkg-install
12 PKG_MD5SUM ?= unknown
13
14 include $(INCLUDE_DIR)/prereq.mk
15 include $(INCLUDE_DIR)/host.mk
16 include $(INCLUDE_DIR)/unpack.mk
17 include $(INCLUDE_DIR)/depends.mk
18
19 STAMP_PREPARED=$(PKG_BUILD_DIR)/.prepared$(if $(QUILT)$(DUMP),,_$(shell $(call find_md5,${CURDIR} $(PKG_FILE_DEPEND),)))
20 STAMP_CONFIGURED:=$(PKG_BUILD_DIR)/.configured
21 STAMP_BUILT:=$(PKG_BUILD_DIR)/.built
22 STAMP_INSTALLED:=$(STAGING_DIR)/stamp/.$(PKG_NAME)_installed
23
24 include $(INCLUDE_DIR)/download.mk
25 include $(INCLUDE_DIR)/quilt.mk
26 include $(INCLUDE_DIR)/package-defaults.mk
27 include $(INCLUDE_DIR)/package-dumpinfo.mk
28 include $(INCLUDE_DIR)/package-ipkg.mk
29 include $(INCLUDE_DIR)/package-debug.mk
30 include $(INCLUDE_DIR)/package-bin.mk
31 include $(INCLUDE_DIR)/autotools.mk
32
33 override MAKEFLAGS=
34 CONFIG_SITE:=$(INCLUDE_DIR)/site/$(REAL_GNU_TARGET_NAME)
35 ifneq ($(CONFIG_LINUX_2_4),)
36 CONFIG_SITE:=$(subst linux-,linux2.4-,$(CONFIG_SITE))
37 endif
38 CUR_MAKEFILE:=$(filter-out Makefile,$(firstword $(MAKEFILE_LIST)))
39 SUBMAKE:=$(NO_TRACE_MAKE) $(if $(CUR_MAKEFILE),-f $(CUR_MAKEFILE))
40
41 ifeq ($(DUMP)$(filter prereq clean refresh update,$(MAKECMDGOALS)),)
42 ifneq ($(if $(QUILT),,$(CONFIG_AUTOREBUILD)),)
43 define Build/Autoclean
44 $(PKG_BUILD_DIR)/.dep_files: $(STAMP_PREPARED)
45 $(call rdep,${CURDIR} $(PKG_FILE_DEPEND),$(STAMP_PREPARED),$(PKG_BUILD_DIR)/.dep_files,-x "*/.dep_*")
46 $(if $(filter prepare,$(MAKECMDGOALS)),,$(call rdep,$(PKG_BUILD_DIR),$(STAMP_BUILT),,-x "*/.dep_*" -x "*/ipkg*"))
47 endef
48 endif
49 endif
50
51 define Download/default
52 FILE:=$(PKG_SOURCE)
53 URL:=$(PKG_SOURCE_URL)
54 SUBDIR:=$(PKG_SOURCE_SUBDIR)
55 PROTO:=$(PKG_SOURCE_PROTO)
56 $(if $(PKG_SOURCE_MIRROR),MIRROR:=$(filter 1,$(PKG_MIRROR)))
57 VERSION:=$(PKG_SOURCE_VERSION)
58 MD5SUM:=$(PKG_MD5SUM)
59 endef
60
61 define sep
62
63 endef
64
65 define Build/DefaultTargets
66 $(if $(QUILT),$(Build/Quilt))
67 $(if $(strip $(PKG_SOURCE_URL)),$(call Download,default))
68 $(call Build/Autoclean)
69
70 $(STAMP_PREPARED) : export PATH=$$(TARGET_PATH_PKG)
71 $(STAMP_PREPARED):
72 @-rm -rf $(PKG_BUILD_DIR)
73 @mkdir -p $(PKG_BUILD_DIR)
74 $(foreach hook,$(Hooks/Prepare/Pre),$(call $(hook))$(sep))
75 $(Build/Prepare)
76 $(foreach hook,$(Hooks/Prepare/Post),$(call $(hook))$(sep))
77 touch $$@
78
79 $(STAMP_CONFIGURED) : export PATH=$$(TARGET_PATH_PKG)
80 $(STAMP_CONFIGURED) : export CONFIG_SITE:=$$(CONFIG_SITE)
81 $(STAMP_CONFIGURED) : export PKG_CONFIG_PATH=$$(STAGING_DIR)/usr/lib/pkgconfig
82 $(STAMP_CONFIGURED) : export PKG_CONFIG_LIBDIR=$$(STAGING_DIR)/usr/lib/pkgconfig
83 $(STAMP_CONFIGURED): $(STAMP_PREPARED)
84 $(foreach hook,$(Hooks/Configure/Pre),$(call $(hook))$(sep))
85 $(Build/Configure)
86 $(foreach hook,$(Hooks/Configure/Post),$(call $(hook))$(sep))
87 touch $$@
88
89 $(STAMP_BUILT) : export PATH=$$(TARGET_PATH_PKG)
90 $(STAMP_BUILT) : export CONFIG_SITE:=$$(CONFIG_SITE)
91 $(STAMP_BUILT) : export PKG_CONFIG_PATH=$$(STAGING_DIR)/usr/lib/pkgconfig:$$(STAGING_DIR_HOST)/usr/lib/pkgconfig
92 $(STAMP_BUILT) : export PKG_CONFIG_LIBDIR=$$(STAGING_DIR)/usr/lib/pkgconfig
93 $(STAMP_BUILT): $(STAMP_CONFIGURED)
94 $(foreach hook,$(Hooks/Compile/Pre),$(call $(hook))$(sep))
95 $(Build/Compile)
96 $(foreach hook,$(Hooks/Compile/Post),$(call $(hook))$(sep))
97 $(Build/Install)
98 $(foreach hook,$(Hooks/Install/Post),$(call $(hook))$(sep))
99 touch $$@
100
101 $(STAMP_INSTALLED) : export PATH=$$(TARGET_PATH_PKG)
102 $(STAMP_INSTALLED): $(STAMP_BUILT)
103 $(SUBMAKE) -j1 clean-staging
104 rm -rf $(TMP_DIR)/stage-$(PKG_NAME)
105 mkdir -p $(TMP_DIR)/stage-$(PKG_NAME)/host $(STAGING_DIR)/packages $(STAGING_DIR_HOST)/packages
106 $(foreach hook,$(Hooks/InstallDev/Pre),\
107 $(call $(hook),$(TMP_DIR)/stage-$(PKG_NAME),$(TMP_DIR)/stage-$(PKG_NAME)/host)$(sep)\
108 )
109 $(call Build/InstallDev,$(TMP_DIR)/stage-$(PKG_NAME),$(TMP_DIR)/stage-$(PKG_NAME)/host)
110 $(foreach hook,$(Hooks/InstallDev/Post),\
111 $(call $(hook),$(TMP_DIR)/stage-$(PKG_NAME),$(TMP_DIR)/stage-$(PKG_NAME)/host)$(sep)\
112 )
113 if [ -d $(TMP_DIR)/stage-$(PKG_NAME) ]; then \
114 (cd $(TMP_DIR)/stage-$(PKG_NAME); find ./ > $(STAGING_DIR)/packages/$(PKG_NAME).list); \
115 $(CP) $(TMP_DIR)/stage-$(PKG_NAME)/* $(STAGING_DIR)/; \
116 fi
117 rm -rf $(TMP_DIR)/stage-$(PKG_NAME)
118 touch $$@
119
120 ifdef Build/InstallDev
121 compile: $(STAMP_INSTALLED)
122 endif
123
124 define Build/DefaultTargets
125 endef
126
127 prepare: $(STAMP_PREPARED)
128 configure: $(STAMP_CONFIGURED)
129 endef
130
131 define BuildPackage
132 $(eval $(Package/Default))
133 $(eval $(Package/$(1)))
134
135 ifdef DESCRIPTION
136 $$(error DESCRIPTION:= is obsolete, use Package/PKG_NAME/description)
137 endif
138
139 ifndef Package/$(1)/description
140 define Package/$(1)/description
141 $(TITLE)
142 endef
143 endif
144
145 $(foreach FIELD, TITLE CATEGORY PRIORITY SECTION VERSION,
146 ifeq ($($(FIELD)),)
147 $$(error Package/$(1) is missing the $(FIELD) field)
148 endif
149 )
150
151 $(call shexport,Package/$(1)/description)
152 $(call shexport,Package/$(1)/config)
153
154 $(if $(DUMP), \
155 $(Dumpinfo), \
156 $(foreach target, \
157 $(if $(Package/$(1)/targets),$(Package/$(1)/targets), \
158 $(if $(PKG_TARGETS),$(PKG_TARGETS), ipkg $(if $(CONFIG_DEBUG_DIR),debug)) \
159 ), $(BuildTarget/$(target)) \
160 ) \
161 )
162 $(if $(PKG_HOST_ONLY)$(DUMP),,$(call Build/DefaultTargets,$(1)))
163 endef
164
165 define pkg_install_files
166 $(foreach install_file,$(1),$(INSTALL_DIR) $(3)/`dirname $(install_file)`; $(INSTALL_DATA) $(2)/$(install_file) $(3)/`dirname $(install_file)`;)
167 endef
168
169 define pkg_install_bin
170 $(foreach install_apps,$(1),$(INSTALL_DIR) $(3)/`dirname $(install_apps)`; $(INSTALL_BIN) $(2)/$(install_apps) $(3)/`dirname $(install_apps)`;)
171 endef
172
173 Build/Prepare=$(call Build/Prepare/Default,)
174 Build/Configure=$(call Build/Configure/Default,)
175 Build/Compile=$(call Build/Compile/Default,)
176 Build/Install=$(if $(PKG_INSTALL),$(call Build/Install/Default,))
177
178 $(PACKAGE_DIR):
179 mkdir -p $@
180
181 dumpinfo:
182 download:
183 prepare:
184 configure:
185 compile:
186 install:
187 clean-staging: FORCE
188 rm -f $(STAMP_INSTALLED)
189 @-(\
190 cd "$(STAGING_DIR)"; \
191 if [ -f packages/$(PKG_NAME).list ]; then \
192 cat packages/$(PKG_NAME).list | xargs -r rm -f 2>/dev/null; \
193 fi; \
194 )
195
196 clean: clean-staging FORCE
197 $(call Build/UninstallDev,$(STAGING_DIR),$(STAGING_DIR_HOST))
198 $(Build/Clean)
199 rm -f $(STAGING_DIR)/packages/$(PKG_NAME).list $(STAGING_DIR_HOST)/packages/$(PKG_NAME).list
200 rm -rf $(PKG_BUILD_DIR)
This page took 0.049425 seconds and 5 git commands to generate.