jw-pkg/make/projects-dir-minimal.mk
Jan Lindemann 50a19954b4 projects-dir-minimal.mk: Make included targets once
Targets defined by projects-dir.mk are not available before it is
included, but make makes up its mind about what targets are available
after parsing the included makefiles, so remove that redundancy.

On the other hand, a dependency alone is not enough for make to
understand that an included makefile has been remade, it needs a
rule, so add a dummy-rule body. In this case only echoing that the
include file has been provided.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-01-14 13:05:15 +01:00

82 lines
2.9 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
ifeq ($(origin PROJECTS_DIR_REMOTE_BASE),undefined)
ifneq ($(wildcard $(JWBDIR)),)
PROJECTS_DIR_REMOTE_BASE := $(shell /usr/bin/python3 $(JWBDIR)/scripts/jw-projects.py -p . 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://git.janware.com/srv/git,$(PROJECTS_DIR_REMOTE_BASE)),)
$(warning Using janware private SSH: $(PROJECTS_DIR_REMOTE_BASE))
PROJECTS_DIR_REMOTE_USER_SUBPATH ?= /proj
else ifneq ($(findstring ssh://git.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
$(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-projects.py -p . 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)
@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 $@
clean: clean.link-makefile
clean.link-makefile:
rm -f link-makefile.done