2019-03-02 17:21:48 +00:00
|
|
|
# ----- host and target variables
|
|
|
|
|
|
|
|
|
|
ifndef PLATFORM_MK_INCLUDED
|
2019-03-03 18:12:28 +00:00
|
|
|
PLATFORM_MK_INCLUDED = true
|
2019-03-02 17:21:48 +00:00
|
|
|
|
cache.mk: Include from topdir.mk, not make.mk
During a topdir "make all", caching variables is currently not the
first thing that happens. Instead, variables are cached as soon as a
project recurses into the make subdirectory. That was necessary,
because some makefiles were regenerated in the make subdirectory by
autoconf, potentially contributing variables that needed to be
cached.
As of now, autoconf is long gone and this is no longer true. And for
some variables, the two step process becomes involved, notably for
PYTHONPATH, which coding agents would like to look at from the topdir
very early on.
This commit moves the .project-cache.mk creation to topdir.mk, and
.projects-cache.mk creation to jw-pkg/Makefile to address that.
Signed-off-by: Jan Lindemann <jan@janware.com>
2026-07-09 07:44:35 +02:00
|
|
|
CACHE_PROJECT_MK ?= $(TOPDIR)/.cache-project.mk
|
|
|
|
|
CACHE_PROJECTS_MK := $(JWBDIR)/.cache-projects.mk
|
|
|
|
|
JW_PKG_NO_CACHE ?= false
|
|
|
|
|
|
|
|
|
|
ifneq ($(filter clean distclean,$(MAKECMDGOALS)),)
|
|
|
|
|
ifeq ($(TOPDIR),.)
|
|
|
|
|
JW_PKG_NO_CACHE = true
|
|
|
|
|
endif
|
|
|
|
|
endif
|
|
|
|
|
|
2019-03-03 09:56:11 +00:00
|
|
|
# "-include" tries search path, we don't want that
|
|
|
|
|
define try_include
|
|
|
|
|
ifneq ($$(wildcard $(1)),)
|
|
|
|
|
include $(1)
|
|
|
|
|
endif
|
|
|
|
|
endef
|
|
|
|
|
|
cache.mk: Include from topdir.mk, not make.mk
During a topdir "make all", caching variables is currently not the
first thing that happens. Instead, variables are cached as soon as a
project recurses into the make subdirectory. That was necessary,
because some makefiles were regenerated in the make subdirectory by
autoconf, potentially contributing variables that needed to be
cached.
As of now, autoconf is long gone and this is no longer true. And for
some variables, the two step process becomes involved, notably for
PYTHONPATH, which coding agents would like to look at from the topdir
very early on.
This commit moves the .project-cache.mk creation to topdir.mk, and
.projects-cache.mk creation to jw-pkg/Makefile to address that.
Signed-off-by: Jan Lindemann <jan@janware.com>
2026-07-09 07:44:35 +02:00
|
|
|
ifneq ($(JW_PKG_NO_CACHE),true)
|
|
|
|
|
$(eval $(call try_include,$(CACHE_PROJECT_MK)))
|
|
|
|
|
$(eval $(call try_include,$(CACHE_PROJECTS_MK)))
|
2026-07-08 19:34:41 +02:00
|
|
|
endif
|
cache.mk: Include from topdir.mk, not make.mk
During a topdir "make all", caching variables is currently not the
first thing that happens. Instead, variables are cached as soon as a
project recurses into the make subdirectory. That was necessary,
because some makefiles were regenerated in the make subdirectory by
autoconf, potentially contributing variables that needed to be
cached.
As of now, autoconf is long gone and this is no longer true. And for
some variables, the two step process becomes involved, notably for
PYTHONPATH, which coding agents would like to look at from the topdir
very early on.
This commit moves the .project-cache.mk creation to topdir.mk, and
.projects-cache.mk creation to jw-pkg/Makefile to address that.
Signed-off-by: Jan Lindemann <jan@janware.com>
2026-07-09 07:44:35 +02:00
|
|
|
|
2019-06-29 21:34:18 +00:00
|
|
|
$(eval $(call try_include,$(JWBDIR)/make/pre-local.mk))
|
2019-03-03 09:56:11 +00:00
|
|
|
$(eval $(call try_include,$(TOPDIR)/make/pre-local.mk))
|
|
|
|
|
$(eval $(call try_include,pre-local.mk))
|
|
|
|
|
|
2026-06-18 12:29:05 +02:00
|
|
|
ifdef PREREQ_RUN_ADD
|
|
|
|
|
# If PREREQ_RUN_ADD was defined in pre-local.mk, set these potentially cached
|
|
|
|
|
# paths up for fresh calculation in ldlibpath.mk / py-path.mk
|
|
|
|
|
undefine JW_PKG_EXE_PATH
|
|
|
|
|
undefine JW_PKG_LD_LIBRARY_PATH
|
|
|
|
|
undefine JW_PKG_PYTHON_PATH
|
|
|
|
|
PREREQ_RUN += $(PREREQ_RUN_ADD)
|
|
|
|
|
endif
|
2026-03-02 10:27:14 +01:00
|
|
|
|
|
|
|
|
# -- What do I know about myself?
|
|
|
|
|
VERSION_FILE ?= $(firstword $(wildcard VERSION) $(TOPDIR)/VERSION)
|
|
|
|
|
ifndef DEVELOPMENT
|
|
|
|
|
ifeq ($(wildcard $(VERSION_FILE)),)
|
|
|
|
|
DEVELOPMENT := true
|
|
|
|
|
else
|
|
|
|
|
DEVELOPMENT := $(shell grep -q 'dev' $(VERSION_FILE) && echo true)
|
|
|
|
|
endif
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
# -- Conclude the build system's location:
|
|
|
|
|
ifeq ($(PROJECTS_DIR),)
|
|
|
|
|
ifeq ($(DEVELOPMENT),true)
|
|
|
|
|
PROJECTS_DIR ?= $(TOPDIR)/..
|
|
|
|
|
else
|
|
|
|
|
PROJECTS_DIR ?= /opt
|
|
|
|
|
endif
|
|
|
|
|
endif
|
|
|
|
|
|
2019-08-02 05:48:32 +00:00
|
|
|
ifeq ($(MAKE_BENCHMARK),true)
|
|
|
|
|
export SHELL := /bin/bash $(JWB_SCRIPT_DIR)/timed-make-shell.sh
|
|
|
|
|
else
|
|
|
|
|
export SHELL := /bin/bash
|
|
|
|
|
endif
|
|
|
|
|
|
2019-06-29 21:45:24 +00:00
|
|
|
JWB_SCRIPT_DIR := $(firstword $(wildcard $(JWBDIR)/scripts $(JWBDIR)/bin))
|
2026-03-02 10:27:14 +01:00
|
|
|
|
|
|
|
|
include $(JWBDIR)/make/py-version.mk
|
|
|
|
|
|
|
|
|
|
JW_PKG_PY = $(PYTHON) $(JWB_SCRIPT_DIR)/jw-pkg.py -p $(PROJECTS_DIR) -t $(TOPDIR) --topdir-format absolute $(JW_PKG_PY_EXTRA_OPTS)
|
|
|
|
|
|
2019-03-29 13:32:16 +00:00
|
|
|
# -- product
|
|
|
|
|
|
|
|
|
|
TARGET_PRODUCTS_ARM_NONE_EABI = \
|
|
|
|
|
st-nucleo-f103rb \
|
2019-04-04 14:36:38 +00:00
|
|
|
st-disc1-f429i \
|
2019-03-29 13:32:16 +00:00
|
|
|
st-disco-f769i
|
|
|
|
|
|
|
|
|
|
TAGGED_TMPL_TAGS_ARM_NONE_EABI ?= $(TARGET_PRODUCTS_ARM_NONE_EABI)
|
|
|
|
|
|
|
|
|
|
TARGET_PRODUCTS += \
|
|
|
|
|
$(TARGET_PRODUCTS_ARM_NONE_EABI)
|
|
|
|
|
TARGET_PRODUCT = $(firstword $(foreach t,$(TAGGED_TMPL_TAGS),$(filter $(t),$(TARGET_PRODUCTS))))
|
|
|
|
|
|
|
|
|
|
TAGGED_TMPL_MAKEFILES = $(wildcard $(addsuffix .mk,$(foreach t,$(TAGGED_TMPL_DIRS),$(addprefix $(t)/,$(TAGGED_TMPL_TAGS)))))
|
|
|
|
|
|
|
|
|
|
ifneq ($(foreach t,$(TAGGED_TMPL_TAGS),$(filter $(t),$(TAGGED_TMPL_TAGS_ARM_NONE_EABI))),)
|
|
|
|
|
TARGET_TRIPLET ?= arm-none-eabi
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
# -- arch, vendor, os, libc
|
|
|
|
|
|
2026-04-24 12:16:20 +02:00
|
|
|
ifeq ($(PLATFORM_INFO),)
|
|
|
|
|
PLATFORM_INFO := $(shell $(JW_PKG_PY) platform info --format '%{gnu-triplet} %{cascade}')
|
2019-03-03 19:49:54 +00:00
|
|
|
endif
|
2026-04-24 12:16:20 +02:00
|
|
|
HOST_TUPLE ?= $(word 1,$(PLATFORM_INFO))
|
2026-03-02 12:42:40 +00:00
|
|
|
HOST_TUPLE_WORDS := $(subst -, ,$(HOST_TUPLE))
|
|
|
|
|
HOST_ARCH := $(word 1,$(HOST_TUPLE_WORDS))
|
|
|
|
|
HOST_VENDOR := $(word 2,$(HOST_TUPLE_WORDS))
|
|
|
|
|
HOST_OS := $(word 3,$(HOST_TUPLE_WORDS))
|
|
|
|
|
HOST_ABI := $(word 4,$(HOST_TUPLE_WORDS))
|
|
|
|
|
HOST_TRIPLET := $(HOST_ARCH)-$(HOST_OS)-$(HOST_ABI)
|
2026-04-24 12:16:20 +02:00
|
|
|
HOST_OS_CASCADE := $(wordlist 2,$(words $(PLATFORM_INFO)),$(PLATFORM_INFO))
|
2026-03-02 12:42:40 +00:00
|
|
|
PKG_FORMAT ?= $(patsubst pkg-%,%,$(filter pkg-%,$(HOST_OS_CASCADE)))
|
2019-03-03 19:49:54 +00:00
|
|
|
|
2009-07-12 19:30:17 +00:00
|
|
|
ifndef TARGET
|
2019-03-02 17:21:48 +00:00
|
|
|
ifneq ($(subst mingw,,$(CWD)),$(CWD))
|
2019-03-03 18:12:28 +00:00
|
|
|
TARGET := mingw
|
2019-02-27 20:46:54 +00:00
|
|
|
endif
|
2009-07-09 11:53:53 +00:00
|
|
|
endif
|
|
|
|
|
|
2019-03-03 18:12:28 +00:00
|
|
|
DEFINE_FROM_TARGET := false
|
|
|
|
|
ifdef TARGET
|
|
|
|
|
ifndef TARGET_TUPLE
|
|
|
|
|
ifndef TARGET_TRIPLET
|
|
|
|
|
DEFINE_FROM_TARGET := true
|
|
|
|
|
endif
|
|
|
|
|
else ifndef TARGET_TRIPLET
|
|
|
|
|
ifndef TARGET_TUPLE
|
|
|
|
|
DEFINE_FROM_TARGET := true
|
|
|
|
|
endif
|
|
|
|
|
endif
|
|
|
|
|
ifeq ($(DEFINE_FROM_TARGET),true)
|
|
|
|
|
ifeq ($(TARGET),mingw)
|
|
|
|
|
TARGET_ARCH ?= i686
|
|
|
|
|
TARGET_ABI := mingw32
|
|
|
|
|
TARGET_OS ?= w64
|
|
|
|
|
else ifeq ($(TARGET),mingw32)
|
|
|
|
|
TARGET_ARCH ?= i686
|
|
|
|
|
TARGET_ABI := mingw32
|
|
|
|
|
TARGET_OS ?= w64
|
|
|
|
|
else ifeq ($(TARGET),mingw64)
|
|
|
|
|
TARGET_ARCH ?= x86_64
|
|
|
|
|
TARGET_ABI := mingw64
|
|
|
|
|
TARGET_OS := w64
|
2019-03-03 19:49:54 +00:00
|
|
|
else ifeq ($(TARGET),linux)
|
2019-03-03 18:12:28 +00:00
|
|
|
endif
|
2019-03-03 19:49:54 +00:00
|
|
|
# -- fall back on defaults
|
|
|
|
|
TARGET_ARCH ?= $(HOST_ARCH)
|
|
|
|
|
TARGET_VENDOR ?= $(HOST_VENDOR)
|
|
|
|
|
TARGET_OS ?= $(HOST_OS)
|
|
|
|
|
TARGET_ABI ?= $(HOST_ABI)
|
2019-03-03 18:12:28 +00:00
|
|
|
endif
|
|
|
|
|
TARGET_TUPLE := $(TARGET_ARCH)-$(TARGET_VENDOR)-$(TARGET_OS)-$(TARGET_ABI)
|
2019-03-02 17:21:48 +00:00
|
|
|
endif
|
2009-07-09 11:53:53 +00:00
|
|
|
|
2019-03-02 17:21:48 +00:00
|
|
|
ifneq ($(TARGET_TUPLE),)
|
2019-03-03 18:12:28 +00:00
|
|
|
TARGET_TUPLE_WORDS ?= $(subst -, ,$(TARGET_TUPLE))
|
|
|
|
|
TARGET_ARCH ?= $(word 1,$(TARGET_TUPLE_WORDS))
|
|
|
|
|
TARGET_VENDOR ?= $(word 2,$(TARGET_TUPLE_WORDS))
|
|
|
|
|
TARGET_OS ?= $(word 3,$(TARGET_TUPLE_WORDS))
|
|
|
|
|
TARGET_ABI ?= $(word 4,$(TARGET_TUPLE_WORDS))
|
|
|
|
|
TARGET_TRIPLET ?= $(TARGET_ARCH)-$(TARGET_OS)-$(TARGET_ABI)
|
2019-03-02 17:21:48 +00:00
|
|
|
else ifneq ($(TARGET_TRIPLET),)
|
2019-03-03 18:12:28 +00:00
|
|
|
TARGET_TRIPLET_WORDS ?= $(subst -, ,$(TARGET_TRIPLET))
|
|
|
|
|
TARGET_ARCH ?= $(word 1,$(TARGET_TRIPLET_WORDS))
|
|
|
|
|
TARGET_VENDOR ?= unknown
|
|
|
|
|
TARGET_OS ?= $(word 2,$(TARGET_TRIPLET_WORDS))
|
|
|
|
|
TARGET_ABI ?= $(word 3,$(TARGET_TRIPLET_WORDS))
|
|
|
|
|
TARGET_TUPLE ?= $(TARGET_ARCH)-$(TARGET_VENDOR)-$(TARGET_OS)-$(TARGET_ABI)
|
|
|
|
|
TARGET_TUPLE_WORDS ?= $(subst -, ,$(TARGET_TUPLE))
|
2019-03-02 17:21:48 +00:00
|
|
|
else
|
2019-03-03 18:12:28 +00:00
|
|
|
TARGET_TUPLE ?= $(HOST_TUPLE)
|
|
|
|
|
TARGET_TUPLE_WORDS ?= $(subst -, ,$(TARGET_TUPLE))
|
|
|
|
|
TARGET_ARCH ?= $(word 1,$(TARGET_TUPLE_WORDS))
|
|
|
|
|
TARGET_VENDOR ?= $(word 2,$(TARGET_TUPLE_WORDS))
|
|
|
|
|
TARGET_OS ?= $(word 3,$(TARGET_TUPLE_WORDS))
|
|
|
|
|
TARGET_ABI ?= $(word 4,$(TARGET_TUPLE_WORDS))
|
|
|
|
|
TARGET_TRIPLET ?= $(TARGET_ARCH)-$(TARGET_OS)-$(TARGET_ABI)
|
|
|
|
|
TARGET_TRIPLET_WORDS ?= $(subst -, ,$(TARGET_TRIPLET))
|
2019-03-02 17:21:48 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
ifeq ($(TARGET_TUPLE),)
|
|
|
|
|
$(error TARGET_TUPLE is empty)
|
|
|
|
|
endif
|
|
|
|
|
|
2019-03-17 15:28:24 +00:00
|
|
|
ifeq ($(TARGET_ARCH),armv7l)
|
|
|
|
|
SYSTEM_LIBDIR_NAME = lib
|
|
|
|
|
else ifeq ($(TARGET_ARCH),armv6l)
|
|
|
|
|
SYSTEM_LIBDIR_NAME = lib
|
|
|
|
|
else ifeq ($(TARGET_ARCH),aarch64)
|
|
|
|
|
SYSTEM_LIBDIR_NAME = lib
|
|
|
|
|
else ifeq ($(TARGET_ARCH),x86_64)
|
|
|
|
|
SYSTEM_LIBDIR_NAME = lib64
|
|
|
|
|
else
|
|
|
|
|
SYSTEM_LIBDIR_NAME = lib
|
|
|
|
|
endif
|
|
|
|
|
SYSTEM_LIBDIR = /usr/$(SYSTEM_LIBDIR_NAME)
|
|
|
|
|
|
2025-11-26 17:48:01 +01:00
|
|
|
# - support legacy jw-pkg target variables
|
2019-03-02 17:21:48 +00:00
|
|
|
ifneq ($(findstring $(TARGET_ABI),mingw mingw32 mingw64),)
|
2019-03-03 18:12:28 +00:00
|
|
|
TARGET ?= mingw
|
2019-03-02 17:21:48 +00:00
|
|
|
else
|
2019-03-03 18:12:28 +00:00
|
|
|
TARGET ?= $(TARGET_OS)
|
2019-03-02 17:21:48 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
ifeq ($(OS_NAME_VERSION),)
|
2026-04-24 12:16:20 +02:00
|
|
|
OS_NAME_VERSION := $(shell $(JW_PKG_PY) platform info --format '%{id}-%{codename}')
|
2019-03-02 17:21:48 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
ifeq ($(OS_NAME),)
|
2026-03-02 10:44:05 +01:00
|
|
|
OS_NAME := $(word 1,$(subst -, ,$(OS_NAME_VERSION)))
|
2019-03-02 17:21:48 +00:00
|
|
|
endif
|
2019-03-03 18:12:28 +00:00
|
|
|
ARCH ?= $(TARGET_ARCH)
|
2019-03-02 17:21:48 +00:00
|
|
|
|
2019-03-03 18:12:28 +00:00
|
|
|
ARCH_32 = i586
|
2019-03-02 17:21:48 +00:00
|
|
|
|
|
|
|
|
ifndef ARCH
|
|
|
|
|
# TODO unreached code, test and fix this
|
|
|
|
|
ifeq ($(shell uname -m),armv7l)
|
2019-03-03 18:12:28 +00:00
|
|
|
ARCH = armv7hl
|
2019-03-02 17:21:48 +00:00
|
|
|
else ifeq ($(shell uname -m),armv6l)
|
2019-03-03 18:12:28 +00:00
|
|
|
ARCH = armv6hl
|
2019-03-02 17:21:48 +00:00
|
|
|
else ifeq ($(shell uname -m),aarch64)
|
2019-03-03 18:12:28 +00:00
|
|
|
ARCH = aarch64
|
2019-03-02 17:21:48 +00:00
|
|
|
else ifeq ($(shell uname -m),x86_64)
|
2019-03-03 18:12:28 +00:00
|
|
|
ARCH = x86_64
|
2019-03-02 17:21:48 +00:00
|
|
|
else
|
2019-03-03 18:12:28 +00:00
|
|
|
ARCH = $(ARCH_32)
|
2019-03-02 17:21:48 +00:00
|
|
|
endif
|
|
|
|
|
endif
|
|
|
|
|
|
2019-03-03 10:45:08 +00:00
|
|
|
ifneq ($(TARGET_TRIPLET),$(HOST_TRIPLET))
|
2019-03-02 17:21:48 +00:00
|
|
|
ifeq ($(TARGET),mingw)
|
2019-03-03 18:12:28 +00:00
|
|
|
FLAVOUR_PREFIX ?= win32-
|
|
|
|
|
FLAVOUR_SUFFIX ?= -win32
|
|
|
|
|
FLAVOUR_PATH_PREFIX ?= win32/
|
|
|
|
|
FLAVOUR_PATH_SUFFIX ?= /win32
|
2019-03-02 17:21:48 +00:00
|
|
|
else
|
2019-03-03 18:12:28 +00:00
|
|
|
FLAVOUR_PREFIX ?= $(TARGET_TRIPLET)-
|
|
|
|
|
FLAVOUR_SUFFIX ?= -$(TARGET_TRIPLET)
|
|
|
|
|
FLAVOUR_PATH_PREFIX ?= $(TARGET_TRIPLET)/
|
|
|
|
|
FLAVOUR_PATH_SUFFIX ?= /$(TARGET_TRIPLET)
|
2019-03-02 17:21:48 +00:00
|
|
|
endif
|
|
|
|
|
endif
|
|
|
|
|
|
2019-03-20 15:06:25 +00:00
|
|
|
TARGET_CPU ?= $(TARGET_ARCH)
|
2019-03-02 17:21:48 +00:00
|
|
|
endif # ifndef PLATFORM_MK_INCLUDED
|