2019-02-28 13:22:12 +00:00
|
|
|
# ----- define these variables
|
|
|
|
|
# CACHED_FILES = $(TOPDIR)/VERSION
|
|
|
|
|
# CACHED_VARS = VERSION
|
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
|
|
|
.PHONY: cache clean.cache
|
|
|
|
|
|
|
|
|
|
CACHED_FILES ?= $(VERSION_FILE) $(wildcard $(TOPDIR)/make/project.conf)
|
|
|
|
|
CACHED_VARS ?= PROJECT PREREQ_BUILD PREREQ_RUN PREREQ VERSION HEX_VERSION \
|
|
|
|
|
FULL_NAME WHICH PYTHON ECHO TEST BROWSER SED RM PWD ID CUT TR \
|
|
|
|
|
AWK GETENT XARGS FIND PRINTF PLATFORM_INFO OS_NAME_VERSION \
|
|
|
|
|
CAT BIN_INSTALL SUDO \
|
|
|
|
|
JW_PKG_LD_LIBRARY_PATH JW_PKG_EXE_PATH JW_PKG_PYTHON_PATH
|
2019-02-28 13:22:12 +00:00
|
|
|
|
make/[Makefile|*.mk): Improve variable caching
This commit aims at improving speed by using better caching.
- Makefile, cache.mk: Split .cache.mk up
To allow caching of runtime path variables which are
project-specific, split .cache.mk up in .cache-project.mk and
.cache-projects.mk
- ldlibpath.mk: Cache ldlibpath, exepath and pythonpath
Place the output of $(call proj_query ldlibpath), $(call
proj_query, exepath) and $(call proj_query pythonpath) in
JW_PKG_LD_LIBRARY_PATH, JW_PKG_EXE_PATH, and JW_PKG_PYTHON_PATH
respectively, and cache the variables in make/.project-cache.mk.
- cache.mk: Use = instead of :=
Recursively expanded variables are nearly as fast as := variables
if the assigned value is a fixed string. And sometimes it's not,
rightly so, because variables get assigned below, as with
JW_PKG_XXX for instance.
- cache.mk: Use $(TOPDIR) as variable values
Replace absolute references to project's topdir by $(TOPDIR) with
sed. As soon as the project queries produce absolute paths, they
will be transformed into relative paths which allow the code base
to be moved to a different location and still remain functional
without a rebuild.
Signed-off-by: Jan Lindemann <jan@janware.com>
2026-01-22 14:12:58 +01:00
|
|
|
CACHED_VARS_ONLY_PROJECT ?= \
|
|
|
|
|
PROJECT \
|
2026-06-17 14:08:58 +02:00
|
|
|
PREREQ_BUILD \
|
|
|
|
|
PREREQ_RUN \
|
make/[Makefile|*.mk): Improve variable caching
This commit aims at improving speed by using better caching.
- Makefile, cache.mk: Split .cache.mk up
To allow caching of runtime path variables which are
project-specific, split .cache.mk up in .cache-project.mk and
.cache-projects.mk
- ldlibpath.mk: Cache ldlibpath, exepath and pythonpath
Place the output of $(call proj_query ldlibpath), $(call
proj_query, exepath) and $(call proj_query pythonpath) in
JW_PKG_LD_LIBRARY_PATH, JW_PKG_EXE_PATH, and JW_PKG_PYTHON_PATH
respectively, and cache the variables in make/.project-cache.mk.
- cache.mk: Use = instead of :=
Recursively expanded variables are nearly as fast as := variables
if the assigned value is a fixed string. And sometimes it's not,
rightly so, because variables get assigned below, as with
JW_PKG_XXX for instance.
- cache.mk: Use $(TOPDIR) as variable values
Replace absolute references to project's topdir by $(TOPDIR) with
sed. As soon as the project queries produce absolute paths, they
will be transformed into relative paths which allow the code base
to be moved to a different location and still remain functional
without a rebuild.
Signed-off-by: Jan Lindemann <jan@janware.com>
2026-01-22 14:12:58 +01:00
|
|
|
PREREQ \
|
|
|
|
|
VERSION \
|
|
|
|
|
HEX_VERSION \
|
|
|
|
|
FULL_NAME \
|
|
|
|
|
JW_PKG_LD_LIBRARY_PATH \
|
|
|
|
|
JW_PKG_EXE_PATH \
|
|
|
|
|
JW_PKG_PYTHON_PATH
|
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
|
|
|
|
|
|
|
|
# We need this to cache JW_PKG_PYTHON_PATH
|
|
|
|
|
include $(JWBDIR)/make/py-path.mk
|
|
|
|
|
|
2019-02-28 14:48:57 +00:00
|
|
|
all: cache
|
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
|
|
|
clean: clean.cache
|
|
|
|
|
clean.cache:
|
make/[Makefile|*.mk): Improve variable caching
This commit aims at improving speed by using better caching.
- Makefile, cache.mk: Split .cache.mk up
To allow caching of runtime path variables which are
project-specific, split .cache.mk up in .cache-project.mk and
.cache-projects.mk
- ldlibpath.mk: Cache ldlibpath, exepath and pythonpath
Place the output of $(call proj_query ldlibpath), $(call
proj_query, exepath) and $(call proj_query pythonpath) in
JW_PKG_LD_LIBRARY_PATH, JW_PKG_EXE_PATH, and JW_PKG_PYTHON_PATH
respectively, and cache the variables in make/.project-cache.mk.
- cache.mk: Use = instead of :=
Recursively expanded variables are nearly as fast as := variables
if the assigned value is a fixed string. And sometimes it's not,
rightly so, because variables get assigned below, as with
JW_PKG_XXX for instance.
- cache.mk: Use $(TOPDIR) as variable values
Replace absolute references to project's topdir by $(TOPDIR) with
sed. As soon as the project queries produce absolute paths, they
will be transformed into relative paths which allow the code base
to be moved to a different location and still remain functional
without a rebuild.
Signed-off-by: Jan Lindemann <jan@janware.com>
2026-01-22 14:12:58 +01:00
|
|
|
rm -f $(CACHE_PROJECT_MK)
|
|
|
|
|
|
|
|
|
|
cache: $(CACHE_PROJECT_MK)
|
|
|
|
|
$(CACHE_PROJECT_MK): $(CACHED_FILES) $(JWBDIR)/make/cache.mk
|
2026-06-17 14:10:12 +02:00
|
|
|
@echo 'ifneq ($$(JW_PKG_NO_CACHE),true)' | tee $@.tmp
|
2026-05-05 16:54:18 +02:00
|
|
|
@echo $(foreach v,$(CACHED_VARS),$v = $(value $(v)) EOL) | \
|
|
|
|
|
$(SED) 's/\s\+EOL/\n/g;' | \
|
|
|
|
|
$(SED) 's/\s*\(\S\+\)\s*=\s*\(.*\)\s*/ifndef \1\n \1 = \2\nendif\n/g;' | \
|
make/[Makefile|*.mk): Improve variable caching
This commit aims at improving speed by using better caching.
- Makefile, cache.mk: Split .cache.mk up
To allow caching of runtime path variables which are
project-specific, split .cache.mk up in .cache-project.mk and
.cache-projects.mk
- ldlibpath.mk: Cache ldlibpath, exepath and pythonpath
Place the output of $(call proj_query ldlibpath), $(call
proj_query, exepath) and $(call proj_query pythonpath) in
JW_PKG_LD_LIBRARY_PATH, JW_PKG_EXE_PATH, and JW_PKG_PYTHON_PATH
respectively, and cache the variables in make/.project-cache.mk.
- cache.mk: Use = instead of :=
Recursively expanded variables are nearly as fast as := variables
if the assigned value is a fixed string. And sometimes it's not,
rightly so, because variables get assigned below, as with
JW_PKG_XXX for instance.
- cache.mk: Use $(TOPDIR) as variable values
Replace absolute references to project's topdir by $(TOPDIR) with
sed. As soon as the project queries produce absolute paths, they
will be transformed into relative paths which allow the code base
to be moved to a different location and still remain functional
without a rebuild.
Signed-off-by: Jan Lindemann <jan@janware.com>
2026-01-22 14:12:58 +01:00
|
|
|
$(SED) 's|$(realpath $(TOPDIR))|$$(TOPDIR)|g' | \
|
|
|
|
|
$(SED) 's|$(realpath $(PROJECTS_DIR))|$$(PROJECTS_DIR)|g' | \
|
|
|
|
|
$(GREP) . | \
|
2026-06-17 14:10:12 +02:00
|
|
|
tee -a $@.tmp
|
|
|
|
|
@echo 'endif # ifneq ($$(JW_PKG_NO_CACHE),true)' | tee -a $@.tmp
|
make/[Makefile|*.mk): Improve variable caching
This commit aims at improving speed by using better caching.
- Makefile, cache.mk: Split .cache.mk up
To allow caching of runtime path variables which are
project-specific, split .cache.mk up in .cache-project.mk and
.cache-projects.mk
- ldlibpath.mk: Cache ldlibpath, exepath and pythonpath
Place the output of $(call proj_query ldlibpath), $(call
proj_query, exepath) and $(call proj_query pythonpath) in
JW_PKG_LD_LIBRARY_PATH, JW_PKG_EXE_PATH, and JW_PKG_PYTHON_PATH
respectively, and cache the variables in make/.project-cache.mk.
- cache.mk: Use = instead of :=
Recursively expanded variables are nearly as fast as := variables
if the assigned value is a fixed string. And sometimes it's not,
rightly so, because variables get assigned below, as with
JW_PKG_XXX for instance.
- cache.mk: Use $(TOPDIR) as variable values
Replace absolute references to project's topdir by $(TOPDIR) with
sed. As soon as the project queries produce absolute paths, they
will be transformed into relative paths which allow the code base
to be moved to a different location and still remain functional
without a rebuild.
Signed-off-by: Jan Lindemann <jan@janware.com>
2026-01-22 14:12:58 +01:00
|
|
|
mv $@.tmp $@
|