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
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
)
30 ifdef CONFIG_USE_MIPS16
31 ifeq ($(strip $(PKG_USE_MIPS16
)),1)
32 TARGET_ASFLAGS_DEFAULT
= $(filter-out -mips16
-minterlink-mips16
,$(TARGET_CFLAGS
))
33 TARGET_CFLAGS
+= -mips16
-minterlink-mips16
37 include $(INCLUDE_DIR
)/prereq.mk
38 include $(INCLUDE_DIR
)/host.mk
39 include $(INCLUDE_DIR
)/unpack.mk
40 include $(INCLUDE_DIR
)/depends.mk
42 STAMP_NO_AUTOREBUILD
=$(wildcard $(PKG_BUILD_DIR
)/.no_autorebuild
)
43 PREV_STAMP_PREPARED
:=$(if
$(STAMP_NO_AUTOREBUILD
),$(wildcard $(PKG_BUILD_DIR
)/.prepared
*))
44 ifneq ($(PREV_STAMP_PREPARED
),)
45 STAMP_PREPARED
:=$(PREV_STAMP_PREPARED
)
48 STAMP_PREPARED
=$(PKG_BUILD_DIR
)/.prepared
$(if
$(QUILT
)$(DUMP
),,_
$(shell $(call find_md5
,${CURDIR} $(PKG_FILE_DEPENDS
),))$(call confvar
,$(PKG_PREPARED_DEPENDS
)))
50 STAMP_CONFIGURED
:=$(PKG_BUILD_DIR
)/.configured
$(if
$(DUMP
),,_
$(call confvar
,$(PKG_CONFIG_DEPENDS
)))
51 STAMP_CONFIGURED_WILDCARD
=$(patsubst %_
$(call confvar
,$(PKG_CONFIG_DEPENDS
)),%_
*,$(STAMP_CONFIGURED
))
52 STAMP_BUILT
:=$(PKG_BUILD_DIR
)/.built
53 STAMP_INSTALLED
:=$(STAGING_DIR
)/stamp
/.
$(PKG_NAME
)_installed
55 STAGING_FILES_LIST
:=$(PKG_NAME
)$(if
$(BUILD_VARIANT
),.
$(BUILD_VARIANT
),).list
56 ifneq ($(if
$(CONFIG_SRC_TREE_OVERRIDE
),$(wildcard .
/git-src
)),)
61 PKG_DIR_NAME
:=$(lastword
$(subst /,$(space
),$(CURDIR
)))
62 PKG_INSTALL_STAMP
:=$(PKG_INFO_DIR
)/$(PKG_DIR_NAME
).
$(if
$(BUILD_VARIANT
),$(BUILD_VARIANT
),default
).
install
64 include $(INCLUDE_DIR
)/download.mk
65 include $(INCLUDE_DIR
)/quilt.mk
66 include $(INCLUDE_DIR
)/package-defaults.mk
67 include $(INCLUDE_DIR
)/package-dumpinfo.mk
68 include $(INCLUDE_DIR
)/package-ipkg.mk
69 include $(INCLUDE_DIR
)/package-bin.mk
70 include $(INCLUDE_DIR
)/autotools.mk
73 CONFIG_SITE
:=$(INCLUDE_DIR
)/site
/$(REAL_GNU_TARGET_NAME
)
74 CUR_MAKEFILE
:=$(filter-out Makefile
,$(firstword $(MAKEFILE_LIST
)))
75 SUBMAKE
:=$(NO_TRACE_MAKE
) $(if
$(CUR_MAKEFILE
),-f
$(CUR_MAKEFILE
))
76 PKG_CONFIG_PATH
=$(STAGING_DIR
)/usr
/lib
/pkgconfig
79 ifeq ($(DUMP
)$(filter prereq
clean refresh update
,$(MAKECMDGOALS
)),)
80 ifneq ($(if
$(QUILT
),,$(CONFIG_AUTOREBUILD
)),)
81 define Build
/Autoclean
82 $(PKG_BUILD_DIR
)/.dep_files
: $(STAMP_PREPARED
)
83 $(call rdep
,${CURDIR} $(PKG_FILE_DEPENDS
),$(STAMP_PREPARED
),$(PKG_BUILD_DIR
)/.dep_files
,-x
"*/.dep_*")
84 $(if
$(filter prepare
,$(MAKECMDGOALS
)),,$(call rdep
,$(PKG_BUILD_DIR
),$(STAMP_BUILT
),,-x
"*/.dep_*" -x
"*/ipkg*"))
89 ifeq ($(CONFIG_
$(PKG_NAME
)_USE_CUSTOM_SOURCE_DIR
),y
)
92 # add hook to install a link to customer source path of dedicated package
93 Hooks
/Prepare
/Pre
+= prepare_custom_source_directory
94 ifeq ($(filter autoreconf
,$(Hooks
/Configure
/Pre
)),)
95 Hooks
/Configure
/Pre
+= autoreconf_target
97 # define empty default action
98 define Build
/Prepare
/Default
103 define Download
/default
105 URL
:=$(PKG_SOURCE_URL
)
106 SUBDIR
:=$(PKG_SOURCE_SUBDIR
)
107 PROTO
:=$(PKG_SOURCE_PROTO
)
108 $(if
$(PKG_SOURCE_MIRROR
),MIRROR
:=$(filter 1,$(PKG_MIRROR
)))
109 $(if
$(PKG_MIRROR_MD5SUM
),MIRROR_MD5SUM
:=$(PKG_MIRROR_MD5SUM
))
110 VERSION
:=$(PKG_SOURCE_VERSION
)
111 MD5SUM
:=$(PKG_MD5SUM
)
115 define Build
/Prepare
/Default
116 mkdir
-p
$(PKG_BUILD_DIR
)
117 ln
-s
$(CURDIR
)/git-src
$(PKG_BUILD_DIR
)/.git
118 ( cd
$(PKG_BUILD_DIR
); git checkout .
)
122 define Build
/Exports
/Default
123 $(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
))
124 $(1) : export STAGING_PREFIX
=$$(STAGING_DIR
)/usr
125 $(1) : export PATH
=$$(TARGET_PATH_PKG
)
126 $(1) : export CONFIG_SITE
:=$$(CONFIG_SITE
)
127 $(1) : export PKG_CONFIG_PATH
:=$$(PKG_CONFIG_PATH
)
128 $(1) : export PKG_CONFIG_LIBDIR
:=$$(PKG_CONFIG_PATH
)
129 $(1) : export CCACHE_DIR
:=$(STAGING_DIR
)/ccache
131 Build
/Exports
=$(Build
/Exports
/Default
)
133 define Build
/DefaultTargets
134 $(if
$(QUILT
),$(Build
/Quilt
))
135 $(if
$(USE_GIT_TREE
),,$(if
$(strip $(PKG_SOURCE_URL
)),$(call Download
,default
)))
136 $(call Build
/Autoclean
)
139 $(foreach hook
,$(Hooks
/Download
),
140 $(call
$(hook
))$(sep
)
143 $(STAMP_PREPARED
) : export PATH
=$$(TARGET_PATH_PKG
)
145 @
-rm -rf
$(PKG_BUILD_DIR
)
146 @mkdir
-p
$(PKG_BUILD_DIR
)
147 $(foreach hook
,$(Hooks
/Prepare
/Pre
),$(call
$(hook
))$(sep
))
149 $(foreach hook
,$(Hooks
/Prepare
/Post
),$(call
$(hook
))$(sep
))
152 $(call Build
/Exports
,$(STAMP_CONFIGURED
))
153 $(STAMP_CONFIGURED
): $(STAMP_PREPARED
)
154 $(foreach hook
,$(Hooks
/Configure
/Pre
),$(call
$(hook
))$(sep
))
156 $(foreach hook
,$(Hooks
/Configure
/Post
),$(call
$(hook
))$(sep
))
157 rm -f
$(STAMP_CONFIGURED_WILDCARD
)
160 $(call Build
/Exports
,$(STAMP_BUILT
))
161 $(STAMP_BUILT
): $(STAMP_CONFIGURED
)
162 $(foreach hook
,$(Hooks
/Compile
/Pre
),$(call
$(hook
))$(sep
))
164 $(foreach hook
,$(Hooks
/Compile
/Post
),$(call
$(hook
))$(sep
))
166 $(foreach hook
,$(Hooks
/Install
/Post
),$(call
$(hook
))$(sep
))
169 $(STAMP_INSTALLED
) : export PATH
=$$(TARGET_PATH_PKG
)
170 $(STAMP_INSTALLED
): $(STAMP_BUILT
)
171 $(SUBMAKE
) -j1 clean-staging
172 rm -rf
$(TMP_DIR
)/stage-
$(PKG_NAME
)
173 mkdir
-p
$(TMP_DIR
)/stage-
$(PKG_NAME
)/host
$(STAGING_DIR
)/packages
$(STAGING_DIR_HOST
)/packages
174 $(foreach hook
,$(Hooks
/InstallDev
/Pre
),\
175 $(call
$(hook
),$(TMP_DIR
)/stage-
$(PKG_NAME
),$(TMP_DIR
)/stage-
$(PKG_NAME
)/host
)$(sep
)\
177 $(call Build
/InstallDev
,$(TMP_DIR
)/stage-
$(PKG_NAME
),$(TMP_DIR
)/stage-
$(PKG_NAME
)/host
)
178 $(foreach hook
,$(Hooks
/InstallDev
/Post
),\
179 $(call
$(hook
),$(TMP_DIR
)/stage-
$(PKG_NAME
),$(TMP_DIR
)/stage-
$(PKG_NAME
)/host
)$(sep
)\
181 if
[ -f
$(STAGING_DIR
)/packages
/$(STAGING_FILES_LIST
) ]; then \
182 $(SCRIPT_DIR
)/clean-package.sh \
183 "$(STAGING_DIR)/packages/$(STAGING_FILES_LIST)" \
186 if
[ -d
$(TMP_DIR
)/stage-
$(PKG_NAME
) ]; then \
187 (cd
$(TMP_DIR
)/stage-
$(PKG_NAME
); find .
/ > $(TMP_DIR
)/stage-
$(PKG_NAME
).files
); \
189 mv
$(TMP_DIR
)/stage-
$(PKG_NAME
).files
$(STAGING_DIR
)/packages
/$(STAGING_FILES_LIST
) && \
190 $(CP
) $(TMP_DIR
)/stage-
$(PKG_NAME
)/* $(STAGING_DIR
)/; \
193 rm -rf
$(TMP_DIR
)/stage-
$(PKG_NAME
)
196 ifdef Build
/InstallDev
197 compile
: $(STAMP_INSTALLED
)
200 define Build
/DefaultTargets
203 prepare
: $(STAMP_PREPARED
)
204 configure
: $(STAMP_CONFIGURED
)
205 dist: $(STAMP_CONFIGURED
)
206 distcheck
: $(STAMP_CONFIGURED
)
209 define Build
/IncludeOverlay
210 $(eval
-include $(wildcard $(TOPDIR
)/overlay
/*/$(PKG_NAME
).mk
))
211 define Build
/IncludeOverlay
216 $(Build
/IncludeOverlay
)
217 $(eval
$(Package
/Default
))
218 $(eval
$(Package
/$(1)))
221 $$(error DESCRIPTION
:= is obsolete
, use Package
/PKG_NAME
/description
)
224 ifndef Package
/$(1)/description
225 define Package
/$(1)/description
230 $(foreach FIELD
, TITLE CATEGORY SECTION VERSION
,
232 $$(error Package
/$(1) is missing the
$(FIELD
) field
)
236 $(call shexport
,Package
/$(1)/description
)
237 $(call shexport
,Package
/$(1)/config
)
240 $(Dumpinfo
/Package
), \
242 $(if
$(Package
/$(1)/targets
),$(Package
/$(1)/targets
), \
243 $(if
$(PKG_TARGETS
),$(PKG_TARGETS
), ipkg
) \
244 ), $(BuildTarget
/$(target
)) \
247 $(if
$(PKG_HOST_ONLY
)$(DUMP
),,$(call Build
/DefaultTargets
,$(1)))
250 define pkg_install_files
251 $(foreach install_file
,$(1),$(INSTALL_DIR
) $(3)/`dirname $(install_file)`; $(INSTALL_DATA
) $(2)/$(install_file
) $(3)/`dirname $(install_file)`;)
254 define pkg_install_bin
255 $(foreach install_apps
,$(1),$(INSTALL_DIR
) $(3)/`dirname $(install_apps)`; $(INSTALL_BIN
) $(2)/$(install_apps
) $(3)/`dirname $(install_apps)`;)
258 Build
/Prepare
=$(call Build
/Prepare
/Default
,)
259 Build
/Configure
=$(call Build
/Configure
/Default
,)
260 Build
/Compile
=$(call Build
/Compile
/Default
,)
261 Build
/Install
=$(if
$(PKG_INSTALL
),$(call Build
/Install
/Default
,))
262 Build
/Dist
=$(call Build
/Dist
/Default
,)
263 Build
/DistCheck
=$(call Build
/DistCheck
/Default
,)
267 .PHONY
: prepare-package-install
268 prepare-package-install
:
269 @mkdir
-p
$(PKG_INFO_DIR
)
270 @touch
$(PKG_INSTALL_STAMP
).
clean
271 @echo
"$(filter-out essential,$(PKG_FLAGS))" > $(PKG_INSTALL_STAMP
).flags
280 compile
: prepare-package-install
283 rm -f
$(STAMP_INSTALLED
)
285 cd
"$(STAGING_DIR)"; \
286 if
[ -f packages
/$(STAGING_FILES_LIST
) ]; then \
287 cat packages
/$(STAGING_FILES_LIST
) | xargs
-r
rm -f
2>/dev
/null
; \
291 clean: clean-staging FORCE
292 $(call Build
/UninstallDev
,$(STAGING_DIR
),$(STAGING_DIR_HOST
))
294 rm -f
$(STAGING_DIR
)/packages
/$(STAGING_FILES_LIST
) $(STAGING_DIR_HOST
)/packages
/$(STAGING_FILES_LIST
)
295 rm -rf
$(PKG_BUILD_DIR
)