1 # SPDX-License-Identifier: GPL-2.0-only
3 # Copyright (C) 2006-2020 OpenWrt.org
5 include $(INCLUDE_DIR
)/download.mk
7 HOST_BUILD_DIR ?
= $(BUILD_DIR_HOST
)/$(PKG_NAME
)$(if
$(PKG_VERSION
),-$(PKG_VERSION
))
8 HOST_INSTALL_DIR ?
= $(HOST_BUILD_DIR
)/host-install
11 HOST_MAKE_J
:=$(if
$(MAKE_JOBSERVER
),$(MAKE_JOBSERVER
) $(if
$(filter 3.
% 4.0 4.1,$(MAKE_VERSION
)),-j
))
13 ifeq ($(strip $(HOST_BUILD_PARALLEL
)),0)
16 HOST_JOBS?
=$(if
$(HOST_BUILD_PARALLEL
),$(HOST_MAKE_J
),-j1
)
19 include $(INCLUDE_DIR
)/unpack.mk
20 include $(INCLUDE_DIR
)/depends.mk
21 include $(INCLUDE_DIR
)/quilt.mk
24 HOST_STAMP_PREPARED
=$(HOST_BUILD_DIR
)/.prepared
$(if
$(HOST_QUILT
)$(DUMP
),,$(shell $(call
$(if
$(CONFIG_AUTOREMOVE
),find_md5_reproducible
,find_md5
),${CURDIR} $(PKG_FILE_DEPENDS
),))_
$(call confvar
,CONFIG_AUTOREMOVE
$(HOST_PREPARED_DEPENDS
)))
25 HOST_STAMP_CONFIGURED
:=$(HOST_BUILD_DIR
)/.configured
26 HOST_STAMP_BUILT
:=$(HOST_BUILD_DIR
)/.built
27 HOST_BUILD_PREFIX?
=$(if
$(IS_PACKAGE_BUILD
),$(STAGING_DIR_HOSTPKG
),$(STAGING_DIR_HOST
))
28 HOST_STAMP_INSTALLED
:=$(HOST_BUILD_PREFIX
)/stamp
/.
$(PKG_NAME
)_installed
29 HOST_STAMP_PROGRAMS
:=$(foreach program
,$(PKG_PROGRAMS
),$(dir $(HOST_STAMP_INSTALLED
))$(subst $(PKG_NAME
),$(program
),$(notdir $(HOST_STAMP_INSTALLED
))) )
33 include $(INCLUDE_DIR
)/autotools.mk
35 _host_target
:=$(if
$(HOST_QUILT
),,.
)
37 Host
/Patch
:=$(Host
/Patch
/Default
)
38 define Host
/Prepare
/Default
39 $(if
$(strip $(HOST_UNPACK
)),$(HOST_UNPACK
))
40 [ ! -d .
/src
/ ] ||
$(CP
) .
/src
/* $(HOST_BUILD_DIR
)
45 $(call Host
/Prepare
/Default
)
48 HOST_CONFIGURE_VARS
= \
50 CFLAGS
="$(HOST_CFLAGS)" \
52 CPPFLAGS
="$(HOST_CPPFLAGS)" \
53 CXXFLAGS
="$(HOST_CXXFLAGS)" \
54 LDFLAGS
="$(HOST_LDFLAGS)" \
55 CONFIG_SHELL
="$(SHELL)"
57 HOST_CONFIGURE_ARGS
= \
58 --target
=$(GNU_HOST_NAME
) \
59 --host
=$(GNU_HOST_NAME
) \
60 --build
=$(GNU_HOST_NAME
) \
61 --disable-dependency-tracking \
64 --prefix=$(HOST_BUILD_PREFIX
) \
65 --exec-prefix
=$(HOST_BUILD_PREFIX
) \
66 --sysconfdir
=$(HOST_BUILD_PREFIX
)/etc \
67 --localstatedir
=$(HOST_BUILD_PREFIX
)/var \
68 --sbindir
=$(HOST_BUILD_PREFIX
)/bin
71 CFLAGS
="$(HOST_CFLAGS)" \
72 CPPFLAGS
="$(HOST_CPPFLAGS)" \
73 CXXFLAGS
="$(HOST_CXXFLAGS)" \
74 LDFLAGS
="$(HOST_LDFLAGS)"
78 HOST_CONFIGURE_CMD
= $(BASH
) .
/configure
80 ifeq ($(HOST_OS
),Darwin
)
81 HOST_CONFIG_SITE
:=$(INCLUDE_DIR
)/site
/darwin
84 define Host
/Configure
/Default
85 $(if
$(HOST_CONFIGURE_PARALLEL
),+)(cd
$(HOST_BUILD_DIR
)/$(3); \
86 if
[ -x configure
]; then \
87 $(CP
) $(SCRIPT_DIR
)/config.
{guess
,sub
} $(HOST_BUILD_DIR
)/$(3)/ && \
88 $(HOST_CONFIGURE_VARS
) \
90 $(HOST_CONFIGURE_CMD
) \
91 $(HOST_CONFIGURE_ARGS
) \
98 $(call Host
/Configure
/Default
)
101 define Host
/Compile
/Default
103 $(MAKE
) $(HOST_JOBS
) -C
$(HOST_BUILD_DIR
) \
109 $(call Host
/Compile
/Default
)
112 define Host
/Install
/Default
113 $(call Host
/Compile
/Default
,install)
117 $(call Host
/Install
/Default
,$(HOST_BUILD_PREFIX
))
121 ifneq ($(if
$(HOST_QUILT
),,$(CONFIG_AUTOREBUILD
)),)
122 define HostHost
/Autoclean
123 $(call rdep
,${CURDIR} $(PKG_FILE_DEPENDS
),$(HOST_STAMP_PREPARED
))
124 $(if
$(if
$(Host
/Compile
),$(filter prepare
,$(MAKECMDGOALS
)),1),,$(call rdep
,$(HOST_BUILD_DIR
),$(HOST_STAMP_BUILT
)))
128 define Host
/Exports
/Default
129 $(1) : export ACLOCAL_INCLUDE
=$$(foreach p
,$$(wildcard $$(STAGING_DIR_HOST
)/share
/aclocal
$$(STAGING_DIR_HOST
)/share
/aclocal-
* $(if
$(IS_PACKAGE_BUILD
),$$(STAGING_DIR
)/host
/share
/aclocal
$$(STAGING_DIR_HOSTPKG
)/share
/aclocal
$$(STAGING_DIR
)/host
/share
/aclocal-
*)),-I
$$(p
))
130 $(1) : export STAGING_PREFIX
=$$(HOST_BUILD_PREFIX
)
131 $(1) : export PKG_CONFIG_PATH
=$$(STAGING_DIR_HOST
)/lib
/pkgconfig
:$$(HOST_BUILD_PREFIX
)/lib
/pkgconfig
132 $(1) : export PKG_CONFIG_LIBDIR
=$$(HOST_BUILD_PREFIX
)/lib
/pkgconfig
133 $(1) : export GIT_CEILING_DIRECTORIES
=$$(BUILD_DIR_HOST
)
134 $(if
$(HOST_CONFIG_SITE
),$(1) : export CONFIG_SITE
:=$(HOST_CONFIG_SITE
))
135 $(if
$(IS_PACKAGE_BUILD
),$(1) : export PATH
=$$(TARGET_PATH_PKG
))
137 Host
/Exports
=$(Host
/Exports
/Default
)
142 define HostBuild
/Core
143 $(if
$(HOST_QUILT
),$(Host
/Quilt
))
144 $(if
$(DUMP
),,$(call HostHost
/Autoclean
))
146 $(HOST_STAMP_PREPARED
):
147 @
-rm -rf
$(HOST_BUILD_DIR
)
148 @mkdir
-p
$(HOST_BUILD_DIR
)
149 $(foreach hook
,$(Hooks
/HostPrepare
/Pre
),$(call
$(hook
))$(sep
))
151 $(foreach hook
,$(Hooks
/HostPrepare
/Post
),$(call
$(hook
))$(sep
))
154 $(call Host
/Exports
,$(HOST_STAMP_CONFIGURED
))
155 $(HOST_STAMP_CONFIGURED
): $(HOST_STAMP_PREPARED
)
156 $(foreach hook
,$(Hooks
/HostConfigure
/Pre
),$(call
$(hook
))$(sep
))
157 $(call Host
/Configure
)
158 $(foreach hook
,$(Hooks
/HostConfigure
/Post
),$(call
$(hook
))$(sep
))
161 $(call Host
/Exports
,$(HOST_STAMP_BUILT
))
162 $(HOST_STAMP_BUILT
): $(HOST_STAMP_CONFIGURED
)
163 $(foreach hook
,$(Hooks
/HostCompile
/Pre
),$(call
$(hook
))$(sep
))
165 $(foreach hook
,$(Hooks
/HostCompile
/Post
),$(call
$(hook
))$(sep
))
168 $(call Host
/Exports
,$(HOST_STAMP_INSTALLED
))
169 $(HOST_STAMP_INSTALLED
): $(HOST_STAMP_BUILT
) $(if
$(FORCE_HOST_INSTALL
),FORCE
)
170 $(call Host
/Install
,$(HOST_BUILD_PREFIX
))
171 $(foreach hook
,$(Hooks
/HostInstall
/Post
),$(call
$(hook
))$(sep
))
172 mkdir
-p
$$(shell dirname
$$@
)
173 touch
$(HOST_STAMP_BUILT
)
174 touch
$$@
$(HOST_STAMP_PROGRAMS
)
176 $(call DefaultTargets
,$(patsubst %,host-
%,$(DEFAULT_SUBDIR_TARGETS
)))
178 $(foreach t
,$(DEFAULT_SUBDIR_TARGETS
),
182 clean-build
: host-clean-build
185 $(call check_download_integrity
)
187 $(_host_target
)host-prepare
: $(HOST_STAMP_PREPARED
)
188 $(_host_target
)host-configure
: $(HOST_STAMP_CONFIGURED
)
189 $(_host_target
)host-compile
: $(HOST_STAMP_BUILT
) $(HOST_STAMP_INSTALLED
) $(HOST_STAMP_PROGRAMS
)
190 host-install
: host-compile
192 host-clean-build
: FORCE
193 $(call Host
/Uninstall
)
194 rm -rf
$(HOST_BUILD_DIR
) $(HOST_STAMP_BUILT
)
196 host-clean
: host-clean-build
198 rm -rf
$(HOST_STAMP_INSTALLED
) $(HOST_STAMP_PROGRAMS
)
200 ifneq ($(CONFIG_AUTOREMOVE
),)
202 $(FIND
) $(HOST_BUILD_DIR
) -mindepth
1 -maxdepth
1 -not
'(' -type f
-and
-name
'.*' -and
-size
0 ')' -print0 | \
210 $(if
$(if
$(PKG_HOST_ONLY
),,$(if
$(and
$(filter host-
%,$(MAKECMDGOALS
)),$(PKG_SKIP_DOWNLOAD
)),,$(STAMP_PREPARED
))),,
211 $(if
$(and
$(CONFIG_AUTOREMOVE
), $(wildcard $(HOST_STAMP_INSTALLED
), $(wildcard $(HOST_STAMP_BUILT
)))),,
212 $(if
$(strip $(PKG_SOURCE_URL
)),$(call Download
,default
))