2 # Copyright (C) 2006-2008 OpenWrt.org
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
10 all: $(if
$(DUMP
),dumpinfo
,compile
)
12 PKG_BUILD_DIR ?
= $(BUILD_DIR
)/$(PKG_NAME
)$(if
$(PKG_VERSION
),-$(PKG_VERSION
))
13 PKG_INSTALL_DIR ?
= $(PKG_BUILD_DIR
)/ipkg-install
16 PKG_INFO_DIR
:= $(STAGING_DIR
)/pkginfo
18 ifneq ($(CONFIG_PKG_BUILD_USE_JOBSERVER
),)
19 MAKE_J
:=$(if
$(MAKE_JOBSERVER
),$(MAKE_JOBSERVER
) -j
)
21 MAKE_J
:=-j
$(CONFIG_PKG_BUILD_JOBS
)
24 ifeq ($(strip $(PKG_BUILD_PARALLEL
)),0)
27 PKG_JOBS?
=$(if
$(PKG_BUILD_PARALLEL
)$(CONFIG_PKG_DEFAULT_PARALLEL
),\
28 $(if
$(CONFIG_PKG_BUILD_PARALLEL
),$(MAKE_J
),-j1
),-j1
)
31 include $(INCLUDE_DIR
)/prereq.mk
32 include $(INCLUDE_DIR
)/host.mk
33 include $(INCLUDE_DIR
)/unpack.mk
34 include $(INCLUDE_DIR
)/depends.mk
36 STAMP_NO_AUTOREBUILD
=$(wildcard $(PKG_BUILD_DIR
)/.no_autorebuild
)
37 PREV_STAMP_PREPARED
:=$(if
$(STAMP_NO_AUTOREBUILD
),$(wildcard $(PKG_BUILD_DIR
)/.prepared
*))
38 ifneq ($(PREV_STAMP_PREPARED
),)
39 STAMP_PREPARED
:=$(PREV_STAMP_PREPARED
)
42 STAMP_PREPARED
=$(PKG_BUILD_DIR
)/.prepared
$(if
$(QUILT
)$(DUMP
),,_
$(shell $(call find_md5
,${CURDIR} $(PKG_FILE_DEPENDS
),))$(call confvar
,$(PKG_PREPARED_DEPENDS
)))
44 STAMP_CONFIGURED
:=$(PKG_BUILD_DIR
)/.configured
$(if
$(DUMP
),,_
$(call confvar
,$(PKG_CONFIG_DEPENDS
)))
45 STAMP_CONFIGURED_WILDCARD
=$(patsubst %_
$(call confvar
,$(PKG_CONFIG_DEPENDS
)),%_
*,$(STAMP_CONFIGURED
))
46 STAMP_BUILT
:=$(PKG_BUILD_DIR
)/.built
47 STAMP_INSTALLED
:=$(STAGING_DIR
)/stamp
/.
$(PKG_NAME
)_installed
49 STAGING_FILES_LIST
:=$(PKG_NAME
)$(if
$(BUILD_VARIANT
),.
$(BUILD_VARIANT
),).list
50 ifneq ($(if
$(CONFIG_SRC_TREE_OVERRIDE
),$(wildcard .
/git-src
)),)
55 include $(INCLUDE_DIR
)/download.mk
56 include $(INCLUDE_DIR
)/quilt.mk
57 include $(INCLUDE_DIR
)/package-defaults.mk
58 include $(INCLUDE_DIR
)/package-dumpinfo.mk
59 include $(INCLUDE_DIR
)/package-ipkg.mk
60 include $(INCLUDE_DIR
)/package-bin.mk
61 include $(INCLUDE_DIR
)/autotools.mk
64 CONFIG_SITE
:=$(INCLUDE_DIR
)/site
/$(REAL_GNU_TARGET_NAME
)
65 CUR_MAKEFILE
:=$(filter-out Makefile
,$(firstword $(MAKEFILE_LIST
)))
66 SUBMAKE
:=$(NO_TRACE_MAKE
) $(if
$(CUR_MAKEFILE
),-f
$(CUR_MAKEFILE
))
67 PKG_CONFIG_PATH
=$(STAGING_DIR
)/usr
/lib
/pkgconfig
70 ifeq ($(DUMP
)$(filter prereq
clean refresh update
,$(MAKECMDGOALS
)),)
71 ifneq ($(if
$(QUILT
),,$(CONFIG_AUTOREBUILD
)),)
72 define Build
/Autoclean
73 $(PKG_BUILD_DIR
)/.dep_files
: $(STAMP_PREPARED
)
74 $(call rdep
,${CURDIR} $(PKG_FILE_DEPENDS
),$(STAMP_PREPARED
),$(PKG_BUILD_DIR
)/.dep_files
,-x
"*/.dep_*")
75 $(if
$(filter prepare
,$(MAKECMDGOALS
)),,$(call rdep
,$(PKG_BUILD_DIR
),$(STAMP_BUILT
),,-x
"*/.dep_*" -x
"*/ipkg*"))
80 ifeq ($(CONFIG_
$(PKG_NAME
)_USE_CUSTOM_SOURCE_DIR
),y
)
83 # add hook to install a link to customer source path of dedicated package
84 Hooks
/Prepare
/Pre
+= prepare_custom_source_directory
85 ifeq ($(filter autoreconf
,$(Hooks
/Configure
/Pre
)),)
86 Hooks
/Configure
/Pre
+= autoreconf_target
88 # define empty default action
89 define Build
/Prepare
/Default
94 define Download
/default
96 URL
:=$(PKG_SOURCE_URL
)
97 SUBDIR
:=$(PKG_SOURCE_SUBDIR
)
98 PROTO
:=$(PKG_SOURCE_PROTO
)
99 $(if
$(PKG_SOURCE_MIRROR
),MIRROR
:=$(filter 1,$(PKG_MIRROR
)))
100 $(if
$(PKG_MIRROR_MD5SUM
),MIRROR_MD5SUM
:=$(PKG_MIRROR_MD5SUM
))
101 VERSION
:=$(PKG_SOURCE_VERSION
)
102 MD5SUM
:=$(PKG_MD5SUM
)
106 define Build
/Prepare
/Default
107 mkdir
-p
$(PKG_BUILD_DIR
)
108 ln
-s
$(CURDIR
)/git-src
$(PKG_BUILD_DIR
)/.git
109 ( cd
$(PKG_BUILD_DIR
); git checkout .
)
113 define Build
/Exports
/Default
114 $(1) : export ACLOCAL_INCLUDE
=$$(foreach p
,$$(wildcard $$(STAGING_DIR
)/usr
/share
/aclocal
$$(STAGING_DIR
)/usr
/share
/aclocal-
* $$(STAGING_DIR
)/host
/share
/aclocal
$$(STAGING_DIR
)/host
/share
/aclocal-
*),-I
$$(p
))
115 $(1) : export STAGING_PREFIX
=$$(STAGING_DIR
)/usr
116 $(1) : export PATH
=$$(TARGET_PATH_PKG
)
117 $(1) : export CONFIG_SITE
:=$$(CONFIG_SITE
)
118 $(1) : export PKG_CONFIG_PATH
:=$$(PKG_CONFIG_PATH
)
119 $(1) : export PKG_CONFIG_LIBDIR
:=$$(PKG_CONFIG_PATH
)
120 $(1) : export CCACHE_DIR
:=$(STAGING_DIR
)/ccache
122 Build
/Exports
=$(Build
/Exports
/Default
)
124 define Build
/DefaultTargets
125 $(if
$(QUILT
),$(Build
/Quilt
))
126 $(if
$(USE_GIT_TREE
),,$(if
$(strip $(PKG_SOURCE_URL
)),$(call Download
,default
)))
127 $(call Build
/Autoclean
)
130 $(foreach hook
,$(Hooks
/Download
),
131 $(call
$(hook
))$(sep
)
134 $(STAMP_PREPARED
) : export PATH
=$$(TARGET_PATH_PKG
)
136 @
-rm -rf
$(PKG_BUILD_DIR
)
137 @mkdir
-p
$(PKG_BUILD_DIR
)
138 $(foreach hook
,$(Hooks
/Prepare
/Pre
),$(call
$(hook
))$(sep
))
140 $(foreach hook
,$(Hooks
/Prepare
/Post
),$(call
$(hook
))$(sep
))
143 $(call Build
/Exports
,$(STAMP_CONFIGURED
))
144 $(STAMP_CONFIGURED
): $(STAMP_PREPARED
)
145 $(foreach hook
,$(Hooks
/Configure
/Pre
),$(call
$(hook
))$(sep
))
147 $(foreach hook
,$(Hooks
/Configure
/Post
),$(call
$(hook
))$(sep
))
148 rm -f
$(STAMP_CONFIGURED_WILDCARD
)
151 $(call Build
/Exports
,$(STAMP_BUILT
))
152 $(STAMP_BUILT
): $(STAMP_CONFIGURED
)
153 $(foreach hook
,$(Hooks
/Compile
/Pre
),$(call
$(hook
))$(sep
))
155 $(foreach hook
,$(Hooks
/Compile
/Post
),$(call
$(hook
))$(sep
))
157 $(foreach hook
,$(Hooks
/Install
/Post
),$(call
$(hook
))$(sep
))
160 $(STAMP_INSTALLED
) : export PATH
=$$(TARGET_PATH_PKG
)
161 $(STAMP_INSTALLED
): $(STAMP_BUILT
)
162 $(SUBMAKE
) -j1 clean-staging
163 rm -rf
$(TMP_DIR
)/stage-
$(PKG_NAME
)
164 mkdir
-p
$(TMP_DIR
)/stage-
$(PKG_NAME
)/host
$(STAGING_DIR
)/packages
$(STAGING_DIR_HOST
)/packages
165 $(foreach hook
,$(Hooks
/InstallDev
/Pre
),\
166 $(call
$(hook
),$(TMP_DIR
)/stage-
$(PKG_NAME
),$(TMP_DIR
)/stage-
$(PKG_NAME
)/host
)$(sep
)\
168 $(call Build
/InstallDev
,$(TMP_DIR
)/stage-
$(PKG_NAME
),$(TMP_DIR
)/stage-
$(PKG_NAME
)/host
)
169 $(foreach hook
,$(Hooks
/InstallDev
/Post
),\
170 $(call
$(hook
),$(TMP_DIR
)/stage-
$(PKG_NAME
),$(TMP_DIR
)/stage-
$(PKG_NAME
)/host
)$(sep
)\
172 if
[ -d
$(TMP_DIR
)/stage-
$(PKG_NAME
) ]; then \
173 (cd
$(TMP_DIR
)/stage-
$(PKG_NAME
); find .
/ > $(TMP_DIR
)/stage-
$(PKG_NAME
).files
); \
175 mv
$(TMP_DIR
)/stage-
$(PKG_NAME
).files
$(STAGING_DIR
)/packages
/$(STAGING_FILES_LIST
) && \
176 $(CP
) $(TMP_DIR
)/stage-
$(PKG_NAME
)/* $(STAGING_DIR
)/; \
179 rm -rf
$(TMP_DIR
)/stage-
$(PKG_NAME
)
182 ifdef Build
/InstallDev
183 compile
: $(STAMP_INSTALLED
)
186 define Build
/DefaultTargets
189 prepare
: $(STAMP_PREPARED
)
190 configure
: $(STAMP_CONFIGURED
)
191 dist: $(STAMP_CONFIGURED
)
192 distcheck
: $(STAMP_CONFIGURED
)
195 define Build
/IncludeOverlay
196 $(eval
-include $(wildcard $(TOPDIR
)/overlay
/*/$(PKG_NAME
).mk
))
197 define Build
/IncludeOverlay
202 $(Build
/IncludeOverlay
)
203 $(eval
$(Package
/Default
))
204 $(eval
$(Package
/$(1)))
207 $$(error DESCRIPTION
:= is obsolete
, use Package
/PKG_NAME
/description
)
210 ifndef Package
/$(1)/description
211 define Package
/$(1)/description
216 $(foreach FIELD
, TITLE CATEGORY PRIORITY SECTION VERSION
,
218 $$(error Package
/$(1) is missing the
$(FIELD
) field
)
222 $(call shexport
,Package
/$(1)/description
)
223 $(call shexport
,Package
/$(1)/config
)
226 $(Dumpinfo
/Package
), \
228 $(if
$(Package
/$(1)/targets
),$(Package
/$(1)/targets
), \
229 $(if
$(PKG_TARGETS
),$(PKG_TARGETS
), ipkg
) \
230 ), $(BuildTarget
/$(target
)) \
233 $(if
$(PKG_HOST_ONLY
)$(DUMP
),,$(call Build
/DefaultTargets
,$(1)))
236 define pkg_install_files
237 $(foreach install_file
,$(1),$(INSTALL_DIR
) $(3)/`dirname $(install_file)`; $(INSTALL_DATA
) $(2)/$(install_file
) $(3)/`dirname $(install_file)`;)
240 define pkg_install_bin
241 $(foreach install_apps
,$(1),$(INSTALL_DIR
) $(3)/`dirname $(install_apps)`; $(INSTALL_BIN
) $(2)/$(install_apps
) $(3)/`dirname $(install_apps)`;)
244 Build
/Prepare
=$(call Build
/Prepare
/Default
,)
245 Build
/Configure
=$(call Build
/Configure
/Default
,)
246 Build
/Compile
=$(call Build
/Compile
/Default
,)
247 Build
/Install
=$(if
$(PKG_INSTALL
),$(call Build
/Install
/Default
,))
248 Build
/Dist
=$(call Build
/Dist
/Default
,)
249 Build
/DistCheck
=$(call Build
/DistCheck
/Default
,)
261 rm -f
$(STAMP_INSTALLED
)
263 cd
"$(STAGING_DIR)"; \
264 if
[ -f packages
/$(STAGING_FILES_LIST
) ]; then \
265 cat packages
/$(STAGING_FILES_LIST
) | xargs
-r
rm -f
2>/dev
/null
; \
269 clean: clean-staging FORCE
270 $(call Build
/UninstallDev
,$(STAGING_DIR
),$(STAGING_DIR_HOST
))
272 rm -f
$(STAGING_DIR
)/packages
/$(STAGING_FILES_LIST
) $(STAGING_DIR_HOST
)/packages
/$(STAGING_FILES_LIST
)
273 rm -rf
$(PKG_BUILD_DIR
)