Commit graph jw-pkg/make/cache.mk
Author SHA1 Message Date
2b04e387df
cache.mk: Avoid recaching stale variable values
All checks were successful
CI / Packaging - Kali Linux (pull_request) Successful in 4m5s
CI / Packaging - OpenSUSE Tumbleweed (pull_request) Successful in 5m0s
CI / Packaging test (pull_request) Successful in 0s
CI / Packaging - Kali Linux (push) Successful in 3m41s
CI / Packaging - OpenSUSE Tumbleweed (push) Successful in 4m33s
CI / Packaging test (push) Successful in 0s
If $(CACHE_PROJECT_MK) AKA .cache-project.mk already exists but needs
to be remade because of dependencies, it is included, its content
read, then the content cached again to the same file. That way stale
variables can leak into the refreshed cache.

This commit fixes the situation by removing it, then invoking make
again to remake it, thereby clearing the variable database and
forcing make to fill the variables afresh.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-08-11 14:25:34 +02:00
d90c0ebf18
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-22 14:38:24 +02:00
10bde0c05d
topdir.mk: Move PREREQ definition into defs.mk
At present, the PREREQ-variable is effectively only used to detect if
prerequiste packages haven't run "make all" before make is run in a
given package. Also, it's only useful in $(TOPDIR). This commit
splits the variable up into PREREQ_BUILD and PREREQ_RUN, and makes
the variables available in every Makefile of a package by placing
them in defs.mk instead of topdir.mk.

This also fixes a problem that PREREQ was cached before being filled,
hence empty. Which effectively wasn't much of a problem, because it
was basically unused, but still.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-06-17 20:16:29 +02:00
8712cbc7b5
cache.mk: Support JW_PKG_NO_CACHE
cache.mk generates .project-cache.mk, and this commit supports
disabling the definitions in the generated cache by setting
JW_PKG_NO_CACHE=true.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-06-17 20:16:29 +02:00
262be57741
cache.mk: Don't overwrite defined variables
Check with ifndef if a variable is defined before hard defining it in
cache.mk. This gives more flexibility when overriding variables with
local.mk.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-05-05 16:57:00 +02:00
741a3b6db2 make: Install cache-projects.mk
.cache-projects.mk is not installed / packaged, which makes builds
against an installed jw-pkg considerably slower. Change that, at the
risk of making the installed jw-pkg-devel less versatile. This commit
installs a cache file cache-projects.mk, renamed from
.cache-projects.mk, because there's no justification for hiding an
installed makefile. At least I can't think of one.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-01 09:50:52 +01:00
f05e1ee0e3 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-26 17:17:23 +01:00
92726d14a4 cache.mk: Replace $(RM) by rm
$(RM) is a cached variable, so it's not a good idea to
use it in cache.mk to get to a clean state

Signed-off-by: Jan Lindemann <jan@janware.com>
2019-11-19 13:13:22 +00:00
b2d6e6f554 Everywhere: Rename MODDIR -> JWBDIR
Rename the omnipresent MODDIR variable to JWBDIR, since that's more to the
point.

Signed-off-by: Jan Lindemann <jan@janware.com>
2019-06-29 21:34:18 +00:00
3dd55cf067 Further improve build time: Try to avoid calling projects.py
This commit tries to remove the necessity to call projects.py from $(TOPDIR) to
speed up recursive builds over all projects yet again. This is a major
undertaking. There are two variables which are filled py projects.py in
$(TOPDIR): PREREQ and PREREQ_DIRS. Sadly, the latter is a path relative to
$(TOPDIR)/make, so this is kind of pointless. Unless the cache is maintained in
$(TOPDIR), a thing I tried to avoid. So this commit is only able to cache
$(PREREQ), not $(PREREQ_DIRS), which still is a hassle. Introduced defs-dirs.mk
for that, to make it accessible to make.mk, and modified all the other parts of
the machinery, too.

Signed-off-by: Jan Lindemann <jan@janware.com>
2019-02-28 14:48:57 +00:00
9e245c986e make: Further improve build time
This commit sees several improvements to the build performance:

- Introduce cache.mk, which creates makefiles caching often used
  variables, per tree and per project.
- Define more variables with := enclosed in condistions, instead of
  defining them with ?=, because the RHS of ?= is expanded deferredly.
- Add more definitions for executables.
- Move some more specialized definitions out into specialized makefiles,
  notably htdocs.mk and tmpl.mk

Signed-off-by: Jan Lindemann <jan@janware.com>
2019-02-28 13:22:12 +00:00