2020-09-22 10:48:37 +08:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-only
|
2009-03-02 11:03:21 +08:00
|
|
|
#
|
2020-09-22 10:48:37 +08:00
|
|
|
# Copyright (C) 2006-2020 OpenWrt.org
|
2006-10-10 21:25:18 +08:00
|
|
|
|
2016-12-21 23:39:56 +08:00
|
|
|
include $(INCLUDE_DIR)/download.mk
|
|
|
|
|
2009-02-22 12:37:20 +08:00
|
|
|
HOST_BUILD_DIR ?= $(BUILD_DIR_HOST)/$(PKG_NAME)$(if $(PKG_VERSION),-$(PKG_VERSION))
|
2009-02-23 02:10:05 +08:00
|
|
|
HOST_INSTALL_DIR ?= $(HOST_BUILD_DIR)/host-install
|
2010-08-18 22:23:06 +08:00
|
|
|
HOST_BUILD_PARALLEL ?=
|
2010-10-17 02:42:58 +08:00
|
|
|
|
2017-01-06 07:28:51 +08:00
|
|
|
HOST_MAKE_J:=$(if $(MAKE_JOBSERVER),$(MAKE_JOBSERVER) $(if $(filter 3.% 4.0 4.1,$(MAKE_VERSION)),-j))
|
2012-09-15 20:34:48 +08:00
|
|
|
|
2010-10-17 02:42:58 +08:00
|
|
|
ifeq ($(strip $(HOST_BUILD_PARALLEL)),0)
|
|
|
|
HOST_JOBS?=-j1
|
|
|
|
else
|
2017-01-06 07:28:51 +08:00
|
|
|
HOST_JOBS?=$(if $(HOST_BUILD_PARALLEL),$(HOST_MAKE_J),-j1)
|
2010-10-17 02:42:58 +08:00
|
|
|
endif
|
2007-08-07 08:04:25 +08:00
|
|
|
|
2006-10-14 08:40:27 +08:00
|
|
|
include $(INCLUDE_DIR)/unpack.mk
|
2007-04-16 02:28:24 +08:00
|
|
|
include $(INCLUDE_DIR)/depends.mk
|
2017-03-23 03:16:15 +08:00
|
|
|
include $(INCLUDE_DIR)/quilt.mk
|
2007-04-16 02:28:24 +08:00
|
|
|
|
2009-03-17 10:20:34 +08:00
|
|
|
BUILD_TYPES += host
|
2022-09-06 22:48:37 +08:00
|
|
|
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)))
|
2009-02-22 12:37:20 +08:00
|
|
|
HOST_STAMP_CONFIGURED:=$(HOST_BUILD_DIR)/.configured
|
|
|
|
HOST_STAMP_BUILT:=$(HOST_BUILD_DIR)/.built
|
2017-05-03 21:01:03 +08:00
|
|
|
HOST_BUILD_PREFIX?=$(if $(IS_PACKAGE_BUILD),$(STAGING_DIR_HOSTPKG),$(STAGING_DIR_HOST))
|
2016-01-21 03:12:13 +08:00
|
|
|
HOST_STAMP_INSTALLED:=$(HOST_BUILD_PREFIX)/stamp/.$(PKG_NAME)_installed
|
2024-04-04 14:11:28 +08:00
|
|
|
HOST_STAMP_PROGRAMS:=$(foreach program,$(PKG_PROGRAMS),$(dir $(HOST_STAMP_INSTALLED))$(subst $(PKG_NAME),$(program),$(notdir $(HOST_STAMP_INSTALLED))) )
|
2007-08-07 08:04:25 +08:00
|
|
|
|
2007-07-31 05:14:08 +08:00
|
|
|
override MAKEFLAGS=
|
2006-10-10 21:25:18 +08:00
|
|
|
|
2010-12-14 03:04:33 +08:00
|
|
|
include $(INCLUDE_DIR)/autotools.mk
|
2007-06-03 15:33:00 +08:00
|
|
|
|
2017-01-19 19:41:59 +08:00
|
|
|
_host_target:=$(if $(HOST_QUILT),,.)
|
|
|
|
|
2009-02-22 12:37:20 +08:00
|
|
|
Host/Patch:=$(Host/Patch/Default)
|
|
|
|
ifneq ($(strip $(HOST_UNPACK)),)
|
|
|
|
define Host/Prepare/Default
|
2009-03-02 11:03:21 +08:00
|
|
|
$(HOST_UNPACK)
|
2016-10-05 22:28:46 +08:00
|
|
|
[ ! -d ./src/ ] || $(CP) ./src/* $(HOST_BUILD_DIR)
|
2009-02-22 12:37:20 +08:00
|
|
|
$(Host/Patch)
|
2006-06-21 14:19:43 +08:00
|
|
|
endef
|
|
|
|
endif
|
|
|
|
|
2009-02-22 12:37:20 +08:00
|
|
|
define Host/Prepare
|
|
|
|
$(call Host/Prepare/Default)
|
2006-06-21 14:19:43 +08:00
|
|
|
endef
|
|
|
|
|
2009-03-01 05:03:17 +08:00
|
|
|
HOST_CONFIGURE_VARS = \
|
2012-01-15 19:43:13 +08:00
|
|
|
CC="$(HOSTCC)" \
|
2009-10-31 06:52:27 +08:00
|
|
|
CFLAGS="$(HOST_CFLAGS)" \
|
2018-04-20 19:04:41 +08:00
|
|
|
CXX="$(HOSTCXX)" \
|
2012-09-10 05:35:42 +08:00
|
|
|
CPPFLAGS="$(HOST_CPPFLAGS)" \
|
2022-01-15 21:10:47 +08:00
|
|
|
CXXFLAGS="$(HOST_CXXFLAGS)" \
|
2009-03-01 05:03:17 +08:00
|
|
|
LDFLAGS="$(HOST_LDFLAGS)" \
|
2017-01-05 22:51:05 +08:00
|
|
|
CONFIG_SHELL="$(SHELL)"
|
2009-03-01 05:03:17 +08:00
|
|
|
|
|
|
|
HOST_CONFIGURE_ARGS = \
|
|
|
|
--target=$(GNU_HOST_NAME) \
|
|
|
|
--host=$(GNU_HOST_NAME) \
|
|
|
|
--build=$(GNU_HOST_NAME) \
|
2022-08-25 10:32:13 +08:00
|
|
|
--disable-dependency-tracking \
|
2009-03-01 05:03:17 +08:00
|
|
|
--program-prefix="" \
|
|
|
|
--program-suffix="" \
|
2016-01-21 03:12:13 +08:00
|
|
|
--prefix=$(HOST_BUILD_PREFIX) \
|
|
|
|
--exec-prefix=$(HOST_BUILD_PREFIX) \
|
|
|
|
--sysconfdir=$(HOST_BUILD_PREFIX)/etc \
|
|
|
|
--localstatedir=$(HOST_BUILD_PREFIX)/var \
|
|
|
|
--sbindir=$(HOST_BUILD_PREFIX)/bin
|
2009-03-01 05:03:17 +08:00
|
|
|
|
2017-01-09 20:59:02 +08:00
|
|
|
HOST_MAKE_VARS = \
|
|
|
|
CFLAGS="$(HOST_CFLAGS)" \
|
2017-01-17 16:29:50 +08:00
|
|
|
CPPFLAGS="$(HOST_CPPFLAGS)" \
|
|
|
|
CXXFLAGS="$(HOST_CXXFLAGS)" \
|
2017-01-09 20:59:02 +08:00
|
|
|
LDFLAGS="$(HOST_LDFLAGS)"
|
|
|
|
|
2012-09-23 04:10:28 +08:00
|
|
|
HOST_MAKE_FLAGS =
|
|
|
|
|
2013-03-08 01:32:29 +08:00
|
|
|
HOST_CONFIGURE_CMD = $(BASH) ./configure
|
2009-03-01 05:03:17 +08:00
|
|
|
|
2017-10-06 01:45:44 +08:00
|
|
|
ifeq ($(HOST_OS),Darwin)
|
|
|
|
HOST_CONFIG_SITE:=$(INCLUDE_DIR)/site/darwin
|
|
|
|
endif
|
|
|
|
|
2009-02-22 12:37:20 +08:00
|
|
|
define Host/Configure/Default
|
2012-09-23 17:50:01 +08:00
|
|
|
$(if $(HOST_CONFIGURE_PARALLEL),+)(cd $(HOST_BUILD_DIR)/$(3); \
|
2009-03-01 05:03:17 +08:00
|
|
|
if [ -x configure ]; then \
|
|
|
|
$(CP) $(SCRIPT_DIR)/config.{guess,sub} $(HOST_BUILD_DIR)/$(3)/ && \
|
2017-01-05 22:51:05 +08:00
|
|
|
$(HOST_CONFIGURE_VARS) \
|
2009-03-01 05:03:17 +08:00
|
|
|
$(2) \
|
|
|
|
$(HOST_CONFIGURE_CMD) \
|
|
|
|
$(HOST_CONFIGURE_ARGS) \
|
|
|
|
$(1); \
|
|
|
|
fi \
|
2006-06-21 14:19:43 +08:00
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
2009-02-22 12:37:20 +08:00
|
|
|
define Host/Configure
|
|
|
|
$(call Host/Configure/Default)
|
2006-06-21 14:19:43 +08:00
|
|
|
endef
|
|
|
|
|
2009-02-22 12:37:20 +08:00
|
|
|
define Host/Compile/Default
|
2017-01-09 20:59:02 +08:00
|
|
|
+$(HOST_MAKE_VARS) \
|
|
|
|
$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) \
|
2012-09-23 04:10:28 +08:00
|
|
|
$(HOST_MAKE_FLAGS) \
|
|
|
|
$(1)
|
2006-06-21 14:19:43 +08:00
|
|
|
endef
|
|
|
|
|
2009-02-22 12:37:20 +08:00
|
|
|
define Host/Compile
|
|
|
|
$(call Host/Compile/Default)
|
2006-06-21 14:19:43 +08:00
|
|
|
endef
|
|
|
|
|
2009-04-06 17:56:06 +08:00
|
|
|
define Host/Install/Default
|
2017-02-09 20:34:21 +08:00
|
|
|
$(call Host/Compile/Default,install)
|
2009-04-06 17:56:06 +08:00
|
|
|
endef
|
|
|
|
|
|
|
|
define Host/Install
|
2016-10-06 06:02:21 +08:00
|
|
|
$(call Host/Install/Default,$(HOST_BUILD_PREFIX))
|
2009-04-06 17:56:06 +08:00
|
|
|
endef
|
|
|
|
|
|
|
|
|
2009-03-17 11:21:52 +08:00
|
|
|
ifneq ($(if $(HOST_QUILT),,$(CONFIG_AUTOREBUILD)),)
|
2009-02-22 12:37:20 +08:00
|
|
|
define HostHost/Autoclean
|
2009-04-28 00:02:21 +08:00
|
|
|
$(call rdep,${CURDIR} $(PKG_FILE_DEPENDS),$(HOST_STAMP_PREPARED))
|
2009-02-22 12:37:20 +08:00
|
|
|
$(if $(if $(Host/Compile),$(filter prepare,$(MAKECMDGOALS)),1),,$(call rdep,$(HOST_BUILD_DIR),$(HOST_STAMP_BUILT)))
|
2007-04-16 02:28:24 +08:00
|
|
|
endef
|
2006-06-21 14:19:43 +08:00
|
|
|
endif
|
|
|
|
|
2009-04-23 06:05:55 +08:00
|
|
|
define Host/Exports/Default
|
2017-01-19 02:47:36 +08:00
|
|
|
$(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))
|
2016-01-21 03:12:13 +08:00
|
|
|
$(1) : export STAGING_PREFIX=$$(HOST_BUILD_PREFIX)
|
|
|
|
$(1) : export PKG_CONFIG_PATH=$$(STAGING_DIR_HOST)/lib/pkgconfig:$$(HOST_BUILD_PREFIX)/lib/pkgconfig
|
|
|
|
$(1) : export PKG_CONFIG_LIBDIR=$$(HOST_BUILD_PREFIX)/lib/pkgconfig
|
2023-05-31 21:58:34 +08:00
|
|
|
$(1) : export GIT_CEILING_DIRECTORIES=$$(BUILD_DIR_HOST)
|
2017-10-06 01:45:44 +08:00
|
|
|
$(if $(HOST_CONFIG_SITE),$(1) : export CONFIG_SITE:=$(HOST_CONFIG_SITE))
|
2016-01-21 03:12:13 +08:00
|
|
|
$(if $(IS_PACKAGE_BUILD),$(1) : export PATH=$$(TARGET_PATH_PKG))
|
2009-04-23 06:05:55 +08:00
|
|
|
endef
|
|
|
|
Host/Exports=$(Host/Exports/Default)
|
|
|
|
|
2012-09-17 19:17:26 +08:00
|
|
|
.NOTPARALLEL:
|
|
|
|
|
2009-02-23 02:10:05 +08:00
|
|
|
ifndef DUMP
|
2016-12-14 22:36:39 +08:00
|
|
|
define HostBuild/Core
|
2009-03-17 11:21:52 +08:00
|
|
|
$(if $(HOST_QUILT),$(Host/Quilt))
|
2009-02-22 12:37:20 +08:00
|
|
|
$(if $(DUMP),,$(call HostHost/Autoclean))
|
2009-03-02 11:03:21 +08:00
|
|
|
|
2009-02-22 12:37:20 +08:00
|
|
|
$(HOST_STAMP_PREPARED):
|
|
|
|
@-rm -rf $(HOST_BUILD_DIR)
|
|
|
|
@mkdir -p $(HOST_BUILD_DIR)
|
2010-12-14 03:04:33 +08:00
|
|
|
$(foreach hook,$(Hooks/HostPrepare/Pre),$(call $(hook))$(sep))
|
2009-02-22 12:37:20 +08:00
|
|
|
$(call Host/Prepare)
|
2010-12-14 03:04:33 +08:00
|
|
|
$(foreach hook,$(Hooks/HostPrepare/Post),$(call $(hook))$(sep))
|
2006-06-21 14:19:43 +08:00
|
|
|
touch $$@
|
|
|
|
|
2009-04-30 22:15:45 +08:00
|
|
|
$(call Host/Exports,$(HOST_STAMP_CONFIGURED))
|
2009-02-22 12:37:20 +08:00
|
|
|
$(HOST_STAMP_CONFIGURED): $(HOST_STAMP_PREPARED)
|
2010-12-14 03:04:33 +08:00
|
|
|
$(foreach hook,$(Hooks/HostConfigure/Pre),$(call $(hook))$(sep))
|
2009-02-22 12:37:20 +08:00
|
|
|
$(call Host/Configure)
|
2010-12-14 03:04:33 +08:00
|
|
|
$(foreach hook,$(Hooks/HostConfigure/Post),$(call $(hook))$(sep))
|
2006-06-21 14:19:43 +08:00
|
|
|
touch $$@
|
|
|
|
|
2009-04-30 22:15:45 +08:00
|
|
|
$(call Host/Exports,$(HOST_STAMP_BUILT))
|
2012-10-15 21:19:41 +08:00
|
|
|
$(HOST_STAMP_BUILT): $(HOST_STAMP_CONFIGURED)
|
2010-12-14 03:04:33 +08:00
|
|
|
$(foreach hook,$(Hooks/HostCompile/Pre),$(call $(hook))$(sep))
|
2010-01-04 02:00:28 +08:00
|
|
|
$(call Host/Compile)
|
2010-12-14 03:04:33 +08:00
|
|
|
$(foreach hook,$(Hooks/HostCompile/Post),$(call $(hook))$(sep))
|
2010-01-04 02:00:28 +08:00
|
|
|
touch $$@
|
|
|
|
|
2016-10-06 06:28:45 +08:00
|
|
|
$(call Host/Exports,$(HOST_STAMP_INSTALLED))
|
2012-10-15 21:19:41 +08:00
|
|
|
$(HOST_STAMP_INSTALLED): $(HOST_STAMP_BUILT) $(if $(FORCE_HOST_INSTALL),FORCE)
|
2016-10-06 06:02:21 +08:00
|
|
|
$(call Host/Install,$(HOST_BUILD_PREFIX))
|
2010-12-14 03:04:33 +08:00
|
|
|
$(foreach hook,$(Hooks/HostInstall/Post),$(call $(hook))$(sep))
|
2010-01-04 02:00:28 +08:00
|
|
|
mkdir -p $$(shell dirname $$@)
|
2014-12-16 04:14:27 +08:00
|
|
|
touch $(HOST_STAMP_BUILT)
|
2023-05-30 19:20:19 +08:00
|
|
|
touch $$@ $(HOST_STAMP_PROGRAMS)
|
2012-10-15 21:19:41 +08:00
|
|
|
|
2017-01-18 21:00:48 +08:00
|
|
|
$(call DefaultTargets,$(patsubst %,host-%,$(DEFAULT_SUBDIR_TARGETS)))
|
2012-10-15 21:19:41 +08:00
|
|
|
ifndef STAMP_BUILT
|
2017-01-18 21:00:48 +08:00
|
|
|
$(foreach t,$(DEFAULT_SUBDIR_TARGETS),
|
|
|
|
$(t): host-$(t)
|
2017-01-19 01:00:00 +08:00
|
|
|
.$(t): .host-$(t)
|
2017-01-18 21:00:48 +08:00
|
|
|
)
|
2017-01-23 00:40:29 +08:00
|
|
|
clean-build: host-clean-build
|
2009-03-17 10:20:34 +08:00
|
|
|
endif
|
2012-10-15 21:19:41 +08:00
|
|
|
|
2021-08-20 05:14:22 +08:00
|
|
|
$(call check_download_integrity)
|
2020-11-19 23:32:46 +08:00
|
|
|
|
2017-01-19 19:41:59 +08:00
|
|
|
$(_host_target)host-prepare: $(HOST_STAMP_PREPARED)
|
|
|
|
$(_host_target)host-configure: $(HOST_STAMP_CONFIGURED)
|
2023-05-30 19:20:19 +08:00
|
|
|
$(_host_target)host-compile: $(HOST_STAMP_BUILT) $(HOST_STAMP_INSTALLED) $(HOST_STAMP_PROGRAMS)
|
2017-02-08 22:49:49 +08:00
|
|
|
host-install: host-compile
|
2017-01-23 00:40:29 +08:00
|
|
|
|
|
|
|
host-clean-build: FORCE
|
2019-09-28 19:10:59 +08:00
|
|
|
$(call Host/Uninstall)
|
2017-01-23 00:40:29 +08:00
|
|
|
rm -rf $(HOST_BUILD_DIR) $(HOST_STAMP_BUILT)
|
|
|
|
|
|
|
|
host-clean: host-clean-build
|
2009-02-22 12:37:20 +08:00
|
|
|
$(call Host/Clean)
|
2023-05-30 19:20:19 +08:00
|
|
|
rm -rf $(HOST_STAMP_INSTALLED) $(HOST_STAMP_PROGRAMS)
|
2006-06-21 14:19:43 +08:00
|
|
|
|
2017-01-19 01:00:00 +08:00
|
|
|
ifneq ($(CONFIG_AUTOREMOVE),)
|
|
|
|
host-compile:
|
2022-09-08 05:50:36 +08:00
|
|
|
$(FIND) $(HOST_BUILD_DIR) -mindepth 1 -maxdepth 1 -not '(' -type f -and -name '.*' -and -size 0 ')' -print0 | \
|
|
|
|
$(XARGS) -0 rm -rf
|
2017-01-19 01:00:00 +08:00
|
|
|
endif
|
2009-02-23 02:10:05 +08:00
|
|
|
endef
|
|
|
|
endif
|
2016-12-14 22:36:39 +08:00
|
|
|
|
|
|
|
define HostBuild
|
|
|
|
$(HostBuild/Core)
|
2022-11-11 23:40:45 +08:00
|
|
|
$(if $(if $(PKG_HOST_ONLY),,$(if $(and $(filter host-%,$(MAKECMDGOALS)),$(PKG_SKIP_DOWNLOAD)),,$(STAMP_PREPARED))),,
|
|
|
|
$(if $(and $(CONFIG_AUTOREMOVE), $(wildcard $(HOST_STAMP_INSTALLED), $(wildcard $(HOST_STAMP_BUILT)))),,
|
|
|
|
$(if $(strip $(PKG_SOURCE_URL)),$(call Download,default))
|
|
|
|
)
|
|
|
|
)
|
2016-12-14 22:36:39 +08:00
|
|
|
endef
|