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>
238 lines
7.7 KiB
Makefile
238 lines
7.7 KiB
Makefile
# ----- host and target variables
|
|
|
|
ifndef PLATFORM_MK_INCLUDED
|
|
PLATFORM_MK_INCLUDED = true
|
|
|
|
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
|
|
|
|
# "-include" tries search path, we don't want that
|
|
define try_include
|
|
ifneq ($$(wildcard $(1)),)
|
|
include $(1)
|
|
endif
|
|
endef
|
|
|
|
ifneq ($(JW_PKG_NO_CACHE),true)
|
|
$(eval $(call try_include,$(CACHE_PROJECT_MK)))
|
|
$(eval $(call try_include,$(CACHE_PROJECTS_MK)))
|
|
endif
|
|
|
|
$(eval $(call try_include,$(JWBDIR)/make/pre-local.mk))
|
|
$(eval $(call try_include,$(TOPDIR)/make/pre-local.mk))
|
|
$(eval $(call try_include,pre-local.mk))
|
|
|
|
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
|
|
|
|
# -- 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
|
|
|
|
ifeq ($(MAKE_BENCHMARK),true)
|
|
export SHELL := /bin/bash $(JWB_SCRIPT_DIR)/timed-make-shell.sh
|
|
else
|
|
export SHELL := /bin/bash
|
|
endif
|
|
|
|
JWB_SCRIPT_DIR := $(firstword $(wildcard $(JWBDIR)/scripts $(JWBDIR)/bin))
|
|
|
|
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)
|
|
|
|
# -- product
|
|
|
|
TARGET_PRODUCTS_ARM_NONE_EABI = \
|
|
st-nucleo-f103rb \
|
|
st-disc1-f429i \
|
|
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
|
|
|
|
ifeq ($(PLATFORM_INFO),)
|
|
PLATFORM_INFO := $(shell $(JW_PKG_PY) platform info --format '%{gnu-triplet} %{cascade}')
|
|
endif
|
|
HOST_TUPLE ?= $(word 1,$(PLATFORM_INFO))
|
|
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)
|
|
HOST_OS_CASCADE := $(wordlist 2,$(words $(PLATFORM_INFO)),$(PLATFORM_INFO))
|
|
PKG_FORMAT ?= $(patsubst pkg-%,%,$(filter pkg-%,$(HOST_OS_CASCADE)))
|
|
|
|
ifndef TARGET
|
|
ifneq ($(subst mingw,,$(CWD)),$(CWD))
|
|
TARGET := mingw
|
|
endif
|
|
endif
|
|
|
|
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
|
|
else ifeq ($(TARGET),linux)
|
|
endif
|
|
# -- fall back on defaults
|
|
TARGET_ARCH ?= $(HOST_ARCH)
|
|
TARGET_VENDOR ?= $(HOST_VENDOR)
|
|
TARGET_OS ?= $(HOST_OS)
|
|
TARGET_ABI ?= $(HOST_ABI)
|
|
endif
|
|
TARGET_TUPLE := $(TARGET_ARCH)-$(TARGET_VENDOR)-$(TARGET_OS)-$(TARGET_ABI)
|
|
endif
|
|
|
|
ifneq ($(TARGET_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)
|
|
else ifneq ($(TARGET_TRIPLET),)
|
|
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))
|
|
else
|
|
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))
|
|
endif
|
|
|
|
ifeq ($(TARGET_TUPLE),)
|
|
$(error TARGET_TUPLE is empty)
|
|
endif
|
|
|
|
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)
|
|
|
|
# - support legacy jw-pkg target variables
|
|
ifneq ($(findstring $(TARGET_ABI),mingw mingw32 mingw64),)
|
|
TARGET ?= mingw
|
|
else
|
|
TARGET ?= $(TARGET_OS)
|
|
endif
|
|
|
|
ifeq ($(OS_NAME_VERSION),)
|
|
OS_NAME_VERSION := $(shell $(JW_PKG_PY) platform info --format '%{id}-%{codename}')
|
|
endif
|
|
|
|
ifeq ($(OS_NAME),)
|
|
OS_NAME := $(word 1,$(subst -, ,$(OS_NAME_VERSION)))
|
|
endif
|
|
ARCH ?= $(TARGET_ARCH)
|
|
|
|
ARCH_32 = i586
|
|
|
|
ifndef ARCH
|
|
# TODO unreached code, test and fix this
|
|
ifeq ($(shell uname -m),armv7l)
|
|
ARCH = armv7hl
|
|
else ifeq ($(shell uname -m),armv6l)
|
|
ARCH = armv6hl
|
|
else ifeq ($(shell uname -m),aarch64)
|
|
ARCH = aarch64
|
|
else ifeq ($(shell uname -m),x86_64)
|
|
ARCH = x86_64
|
|
else
|
|
ARCH = $(ARCH_32)
|
|
endif
|
|
endif
|
|
|
|
ifneq ($(TARGET_TRIPLET),$(HOST_TRIPLET))
|
|
ifeq ($(TARGET),mingw)
|
|
FLAVOUR_PREFIX ?= win32-
|
|
FLAVOUR_SUFFIX ?= -win32
|
|
FLAVOUR_PATH_PREFIX ?= win32/
|
|
FLAVOUR_PATH_SUFFIX ?= /win32
|
|
else
|
|
FLAVOUR_PREFIX ?= $(TARGET_TRIPLET)-
|
|
FLAVOUR_SUFFIX ?= -$(TARGET_TRIPLET)
|
|
FLAVOUR_PATH_PREFIX ?= $(TARGET_TRIPLET)/
|
|
FLAVOUR_PATH_SUFFIX ?= /$(TARGET_TRIPLET)
|
|
endif
|
|
endif
|
|
|
|
TARGET_CPU ?= $(TARGET_ARCH)
|
|
endif # ifndef PLATFORM_MK_INCLUDED
|