jw-pkg/make/projects-dir-minimal.mk
Jan Lindemann 4823463b88
All checks were successful
CI / Packaging - Kali Linux (pull_request) Successful in 5m4s
CI / Packaging - OpenSUSE Tumbleweed (pull_request) Successful in 7m20s
CI / Packaging test (pull_request) Successful in 0s
CI / Packaging - Kali Linux (push) Successful in 5m14s
CI / Packaging - OpenSUSE Tumbleweed (push) Successful in 7m2s
CI / Packaging test (push) Successful in 0s
common.mk: Add file
This is the first in a series of attempts to clean up jw-pkg's makefile
fragments make/*.mk. It collects redundantly defined workspace and project
variables into one shared common.mk.

Variables needed in both the workspace directory and the project
directories are defined separately in the two contexts: Q in defs.mk and
projects-dir-minimal.mk, INTERACTIVE in topdir.mk and projects-dir.mk,
BROWSER and JWB_SCRIPT_DIR in defs.mk/platform.mk and projects-dir.mk, and
LIST_VCS_FILES and LIST_VCS_FILES_SH wrapping the same scm.sh ls-files call
under different names. PKG_MANAGER is defined in topdir.mk and
projects-dir.mk, and JW_PKG_PY_PROJECTS is a prefix only used to build two
other variables in projects-dir.mk.

This commit adds make/common.mk, included from defs.mk (and hence from
every project directory) and from projects-dir.mk (the workspace), and
collects the shared variables there:

- Q, INTERACTIVE, BROWSER, JWB_SCRIPT_DIR: one ?= definition each
- LIST_VCS_FILES: one definition; LIST_VCS_FILES_SH is dropped and the
  list-files target uses the shared name
- PKG_MANAGER moves to projects+project.mk, the fragment shared by the
  workspace and the topdir
- projects-dir-minimal.mk keeps its own Q, because the bootstrap recipes
  run before common.mk is parsed
- JW_PKG_PY_PROJECTS is inlined into JW_PKG_PY_BUILD and
  JW_PKG_PY_REQUIRED_OS_PKG

Signed-off-by: Jan Lindemann <jan@janware.com>
Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v0.87.0
2026-09-22 16:42:52 +02:00

88 lines
3.2 KiB
Makefile

#
# SPDX-License-Identifier: LGPL-2.0-only
#
# Makefile for managing multiple software repositories in one tree
# (C) Copyright 2001-2025, Jan Lindemann <jan@janware.com>
#
# This is the top-level Makefile for a software build tree organized by
# jw-pkg. It is provided under the terms of the GNU Lesser Public License,
# Version 2.
#
# Current documentation on how this Makefile is meant to be used can be found
# under https://janware.com/wiki/pub/en/sw/build/. Running "make help" might
# take you there semi-automatically.
#
PROJECTS_MAKEFILE_NAME := $(firstword $(MAKEFILE_LIST))
-include local.mk
JWBDIR ?= jw-pkg
# The bootstrap recipes below run before jw-pkg's common.mk is
# parsed, so Q must be defined here; a no-op in the steady state.
Q ?= @
ifeq ($(origin PROJECTS_DIR_REMOTE_BASE),undefined)
ifneq ($(wildcard $(JWBDIR)),)
PROJECTS_DIR_REMOTE_BASE := $(shell /usr/bin/python3 $(JWBDIR)/scripts/jw-pkg.py --interactive false -p . projects get-auth-info --remote-base --only-values)
endif
ifeq ($(PROJECTS_DIR_REMOTE_BASE),)
PROJECTS_DIR_REMOTE_BASE := https://janware.com/code
endif
endif
ifneq ($(findstring ssh://devgit.janware.com/,$(PROJECTS_DIR_REMOTE_BASE)),)
$(warning Using janware private SSH: $(PROJECTS_DIR_REMOTE_BASE))
PROJECTS_DIR_REMOTE_USER_SUBPATH ?= /proj
else ifneq ($(findstring ssh://devgit.janware.com,$(PROJECTS_DIR_REMOTE_BASE)),)
$(warning Using janware SSH: $(PROJECTS_DIR_REMOTE_BASE))
else ifneq ($(findstring https://,$(PROJECTS_DIR_REMOTE_BASE)),)
$(warning Using HTTPS: $(PROJECTS_DIR_REMOTE_BASE))
else ifneq ($(wildcard $(PROJECTS_DIR_REMOTE_BASE)),)
$(warning Using local PROJECTS_DIR_REMOTE_BASE = $(PROJECTS_DIR_REMOTE_BASE))
else
$(error Unsupported PROJECTS_DIR_REMOTE_BASE = "$(PROJECTS_DIR_REMOTE_BASE)")
endif
ifeq ($(JANWARE_USER),)
ifneq ($(wildcard $(JWBDIR)),)
JANWARE_USER := $(shell /usr/bin/python3 $(JWBDIR)/scripts/jw-pkg.py --interactive false -p . projects get-auth-info --username --only-values)
endif
endif
ifneq ($(JANWARE_USER),)
CLONE_FROM_USER ?= $(JANWARE_USER)
GIT_GLOBAL_OPTS += -c https.proactiveAuth=basic
export GIT_GLOBAL_OPTS
else
CLONE_FROM_USER ?= janware
endif
JWBDIR_GIT_REMOTE ?= $(PROJECTS_DIR_REMOTE_BASE)/$(CLONE_FROM_USER)$(PROJECTS_DIR_REMOTE_USER_SUBPATH)/$(notdir $(JWBDIR))
PROJECTS_DIR_INCLUDE_MK = $(JWBDIR)/make/projects-dir-include.mk
all:
include $(PROJECTS_DIR_INCLUDE_MK)
$(PROJECTS_DIR_INCLUDE_MK): | $(JWBDIR)
$(Q)echo Provided $@
$(JWBDIR):
git $(GIT_GLOBAL_OPTS) clone $(addprefix -b ,$(JW_PKG_BRANCH)) $(JWBDIR_GIT_REMOTE) $(JWBDIR)
ifneq ($(findstring proactiveAuth,$(GIT_GLOBAL_OPTS)),)
git -C $(JWBDIR) config set http.proactiveAuth basic
endif
RANDOM_STRING := some-random-string-to-id-this-makefile
all: link-makefile.done
link-makefile.done: | $(JWBDIR)
if [ ! -L $(PROJECTS_MAKEFILE_NAME) ] && grep -q $(RANDOM_STRING) $(PROJECTS_MAKEFILE_NAME); then \
ln -sf `git -C $(JWBDIR) ls-files | sed '/\.mk$$/ !d; s|^|$(JWBDIR)/|' | xargs grep -l $(RANDOM_STRING)` \
$(PROJECTS_MAKEFILE_NAME) ;\
fi
touch $@
init: link-makefile.done
clean: clean.link-makefile
clean.link-makefile:
rm -f link-makefile.done