2007-08-19 19:28:59 +00:00
|
|
|
all: config
|
2007-08-22 14:42:53 +00:00
|
|
|
install: topdir.install
|
2007-08-16 18:03:28 +00:00
|
|
|
clean: topdir.clean
|
2016-04-19 11:36:15 +00:00
|
|
|
distclean: topdir.distclean
|
2007-08-16 18:03:28 +00:00
|
|
|
config:
|
2016-04-19 11:36:15 +00:00
|
|
|
mrproper:distclean topdir.mrproper
|
2007-08-16 18:03:28 +00:00
|
|
|
|
2019-01-30 16:23:07 +00:00
|
|
|
ifeq ($(ORDERED_SUBDIRS),)
|
2019-06-29 19:09:08 +00:00
|
|
|
SUBDIRS ?= $(dir $(wildcard $(addsuffix /Makefile,\
|
|
|
|
|
inst/pre make scripts contrib src libsrc \
|
|
|
|
|
tools include lib bin util exe plugins conf config cfg \
|
|
|
|
|
images htdocs tmpl doc test inst/post)))
|
2019-01-30 16:23:07 +00:00
|
|
|
endif
|
|
|
|
|
|
2019-03-13 15:45:01 +00:00
|
|
|
ifeq ($(USE_USER_URL),true)
|
|
|
|
|
JANWARE_USER_PREFIX = $(JANWARE_USER)@
|
|
|
|
|
endif
|
|
|
|
|
|
2019-03-03 18:12:28 +00:00
|
|
|
PROJECT_DESCR = $(TOPDIR)/make/project.conf
|
|
|
|
|
GIT_DESCR = $(TOPDIR)/.git/description
|
2025-11-24 11:22:56 +01:00
|
|
|
GIT_MAIN_BRANCH ?= master
|
2016-11-27 15:55:08 +00:00
|
|
|
|
2019-03-03 18:12:28 +00:00
|
|
|
OPT_JANWARE_PROJECT ?= -j
|
2026-01-28 08:10:09 +01:00
|
|
|
INTERACTIVE ?= auto
|
lib.Distro, ExecContext: Add classes, refactor lib.distro
The code below lib.distro, as left behind by the previous commit, is
geared towards being directly used as a command-line API. This commit
introduces the abstract base class Distro, a proxy for
distribution-specific interactions. The proxy abstracts distro
specifics into an API with proper method prototypes, not
argparse.Namespace contents, and can thus be more easily driven by
arbitrary code.
The Distro class is initialized with a member variable of type
ExecContext, another new class introduced by this commit. It is
designed to abstract the communication channel to the distribution
instance. Currently only one specialization exists, Local, which
interacts with the distribution and root file system it is running
in, but is planned to be subclassed to support interaction via SSH,
serial, chroot, or chains thereof.
Signed-off-by: Jan Lindemann <jan@janware.com>
2026-03-05 17:33:52 +01:00
|
|
|
PKG_MANAGER ?= $(JW_PKG_PY) --interactive=$(INTERACTIVE) distro
|
2016-11-27 15:55:08 +00:00
|
|
|
|
|
|
|
|
ifeq ($(OPT_JANWARE_PROJECT),-j)
|
2019-03-03 18:12:28 +00:00
|
|
|
REMOTE_GIT_FLAVOUR ?= proj
|
2016-11-27 15:55:08 +00:00
|
|
|
else
|
2019-03-06 12:38:20 +00:00
|
|
|
OPT_JANWARE_PROJECT =
|
2019-03-03 18:12:28 +00:00
|
|
|
REMOTE_GIT_FLAVOUR ?= priv
|
2016-11-27 15:55:08 +00:00
|
|
|
endif
|
|
|
|
|
|
2007-08-16 19:04:22 +00:00
|
|
|
ifneq ($(wildcard $(TOPDIR)/make/defs.mk),)
|
2009-05-27 11:26:17 +00:00
|
|
|
include $(TOPDIR)/make/defs.mk
|
|
|
|
|
endif
|
2007-08-16 18:03:28 +00:00
|
|
|
|
2019-06-29 21:34:18 +00:00
|
|
|
include $(JWBDIR)/make/defs.mk
|
2016-12-07 13:30:06 +00:00
|
|
|
|
2026-04-12 13:46:02 +02:00
|
|
|
REMOTE_GIT_DIR = /$(JANWARE_USER)/$(REMOTE_GIT_FLAVOUR)/$(PROJECT)
|
2019-03-13 15:45:01 +00:00
|
|
|
REMOTE_GIT_URL = ssh://$(JANWARE_USER_PREFIX)git.janware.com$(REMOTE_GIT_DIR)
|
2016-12-07 13:30:06 +00:00
|
|
|
|
2019-02-28 16:12:58 +00:00
|
|
|
ifneq ($(DONT_CHECK_PREREQ_DONE),true)
|
|
|
|
|
ifndef PREREQ
|
2026-03-15 12:25:11 +01:00
|
|
|
PREREQ := $(call proj_query,pkg-requires --no-subpackages --subsections=jw --syntax names-only --delimiter=' ' build $(PROJECT))
|
2019-02-28 16:12:58 +00:00
|
|
|
endif
|
|
|
|
|
ifndef PREREQ_DIRS
|
2019-03-03 18:12:28 +00:00
|
|
|
PREREQ_DIRS := $(call proj_query,proj-dir $(PREREQ))
|
2019-02-28 16:12:58 +00:00
|
|
|
endif
|
2019-03-03 18:12:28 +00:00
|
|
|
PREREQ_DIRS_DONE := $(addsuffix /dirs-all.done,$(filter-out $(TOPDIR) /opt/%,$(PREREQ_DIRS)))
|
2019-02-28 16:12:58 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
ifneq ($(SUBDIRS_TO_ITERATE),)
|
|
|
|
|
|
|
|
|
|
ifeq ($(MAKECMDGOALS),)
|
2019-03-03 18:12:28 +00:00
|
|
|
SUBDIR_TARGETS = all
|
2019-02-28 16:12:58 +00:00
|
|
|
else
|
2019-03-03 18:12:28 +00:00
|
|
|
SUBDIR_TARGETS = $(filter $(ALLOWED_SUBDIR_TARGETS),$(MAKECMDGOALS))
|
2019-02-28 16:12:58 +00:00
|
|
|
endif
|
2019-03-06 12:38:20 +00:00
|
|
|
|
2019-02-28 16:12:58 +00:00
|
|
|
endif
|
|
|
|
|
|
2019-07-01 17:37:10 +00:00
|
|
|
include $(JWBDIR)/make/dirs.mk
|
2026-03-16 13:51:11 +01:00
|
|
|
include $(JWBDIR)/make/pkg-dist.mk
|
2019-06-29 21:34:18 +00:00
|
|
|
include $(JWBDIR)/make/rules.mk
|
|
|
|
|
include $(JWBDIR)/make/doc-rules.mk
|
|
|
|
|
include $(JWBDIR)/make/list-files.mk
|
2026-02-17 18:13:22 +01:00
|
|
|
include $(JWBDIR)/make/projects+project.mk
|
2007-08-16 18:03:28 +00:00
|
|
|
|
2019-06-29 21:45:24 +00:00
|
|
|
STREAMLINE_PROJECT ?= bash $(JWB_SCRIPT_DIR)/streamline-project.sh
|
2015-12-12 12:46:58 +00:00
|
|
|
|
2019-03-03 18:12:28 +00:00
|
|
|
INSTALLED_TOPDIR_FILES = $(addprefix $(INSTALL_DOCDIR)/, $(DOCS))
|
2007-08-22 14:42:53 +00:00
|
|
|
|
2006-05-26 14:07:43 +00:00
|
|
|
local-%:
|
|
|
|
|
find . -name $@.mk | \
|
2006-06-01 09:10:30 +00:00
|
|
|
while read f; do (\
|
|
|
|
|
cd `dirname $$f` ;\
|
2017-09-02 19:26:52 +00:00
|
|
|
$(RM) -f local.mk ;\
|
2006-06-01 09:10:30 +00:00
|
|
|
ln -s `basename $$f` local.mk ;\
|
|
|
|
|
) done
|
2006-05-26 14:07:43 +00:00
|
|
|
|
|
|
|
|
unlocal:
|
2017-09-02 19:26:52 +00:00
|
|
|
$(RM) -f $(shell find . -name local.mk)
|
2007-05-23 11:30:53 +00:00
|
|
|
|
2019-01-30 16:23:20 +00:00
|
|
|
topdir.distclean: topdir.clean
|
|
|
|
|
$(RM) -rf dist *.dist
|
2007-08-16 18:03:28 +00:00
|
|
|
topdir.clean:
|
2019-01-30 16:23:20 +00:00
|
|
|
$(RM) -rf *.done
|
|
|
|
|
topdir.mrproper: topdir.distclean
|
2017-09-02 19:26:52 +00:00
|
|
|
find . -name '*.rep' | xargs -r $(RM) -f
|
2007-08-22 14:42:53 +00:00
|
|
|
|
2007-09-04 21:52:28 +00:00
|
|
|
topdir.install: prefix.done $(INSTALLED_TOPDIR_FILES)
|
|
|
|
|
|
2011-02-20 14:15:22 +00:00
|
|
|
do-install-links:
|
2026-01-25 17:34:53 +01:00
|
|
|
$(Q)@cwd=$(shell $(PWD)); \
|
2011-02-20 14:15:22 +00:00
|
|
|
echo "o in $(INSTALL_LIBDIR):" ;\
|
|
|
|
|
find lib -name '*.so' -o -name '*.so.*' -o -name '*.a' -o -name '*.dll' | \
|
2012-02-04 10:59:02 +00:00
|
|
|
$(SED) 's%^\./%%' | \
|
2011-02-20 14:15:22 +00:00
|
|
|
while read f; do \
|
2011-05-15 18:28:19 +00:00
|
|
|
cd $(INSTALL_LIBDIR) && { \
|
|
|
|
|
echo " sudo ln -sf $$cwd/$$f" ; \
|
|
|
|
|
sudo ln -sf $$cwd/$$f; \
|
|
|
|
|
}; \
|
2011-02-20 14:15:22 +00:00
|
|
|
done; \
|
|
|
|
|
echo "o in $(INSTALL_EXEDIR):" ;\
|
|
|
|
|
find bin -type f -a -perm -u+x | \
|
2012-02-04 10:59:02 +00:00
|
|
|
$(SED) 's%^\./%%' | \
|
2011-02-20 14:15:22 +00:00
|
|
|
while read f; do \
|
2011-05-15 18:28:19 +00:00
|
|
|
cd $(INSTALL_EXEDIR) && { \
|
|
|
|
|
echo " sudo ln -sf $$cwd/$$f" ; \
|
|
|
|
|
sudo ln -sf $$cwd/$$f; \
|
|
|
|
|
}; \
|
|
|
|
|
done ;\
|
|
|
|
|
echo "o in $(INSTALL_HDRDIR):" ;\
|
|
|
|
|
find include -name '*.h' | \
|
2012-02-04 10:59:02 +00:00
|
|
|
$(SED) 's%^\./%%' | \
|
2011-05-15 18:28:19 +00:00
|
|
|
while read f; do \
|
|
|
|
|
cd $(INSTALL_HDRDIR) && { \
|
|
|
|
|
echo " sudo ln -sf $$cwd/$$f" ; \
|
|
|
|
|
sudo ln -sf $$cwd/$$f; \
|
|
|
|
|
}; \
|
|
|
|
|
done; \
|
|
|
|
|
echo "o in $(INSTALL_MAKEDIR):" ;\
|
|
|
|
|
find make -name '*.mk' | \
|
2012-02-04 10:59:02 +00:00
|
|
|
$(SED) 's%^\./%%' | \
|
2011-05-15 18:28:19 +00:00
|
|
|
while read f; do \
|
|
|
|
|
cd $(INSTALL_MAKEDIR) && { \
|
|
|
|
|
echo " sudo ln -sf $$cwd/$$f" ; \
|
|
|
|
|
sudo ln -sf $$cwd/$$f; \
|
|
|
|
|
}; \
|
|
|
|
|
done; \
|
2012-01-30 14:59:21 +00:00
|
|
|
|
2016-04-20 14:37:09 +00:00
|
|
|
install-links:
|
|
|
|
|
DEVELOPMENT=false make do-install-links
|
|
|
|
|
|
2026-02-21 11:27:56 +01:00
|
|
|
get-maintainer: git-get-maintainer
|
2026-03-16 05:55:27 +01:00
|
|
|
get-official: git-get-official
|
2026-02-21 11:27:56 +01:00
|
|
|
|
2016-04-20 14:37:09 +00:00
|
|
|
git-init: git-init.done $(GIT_DESCR)
|
2014-06-24 18:49:35 +00:00
|
|
|
|
2013-05-30 12:50:42 +00:00
|
|
|
git-init-from-cvs: git-init
|
2017-05-25 09:54:57 +00:00
|
|
|
$(LIST_VCS_FILES) -f | xargs git add
|
2026-03-16 13:51:11 +01:00
|
|
|
git commit -m "First commit of $(PKG_VERSION)"
|
2012-01-30 14:59:21 +00:00
|
|
|
|
2013-06-11 13:49:54 +00:00
|
|
|
git-config:
|
2019-03-13 15:45:01 +00:00
|
|
|
git config --global user.name || git config --global user.name "$(FULL_NAME)"
|
|
|
|
|
git config --global user.email || git config --global user.email $(JANWARE_USER)@janware.com
|
|
|
|
|
git remote -v | grep -q '^origin' || git remote add origin $(REMOTE_GIT_URL)
|
|
|
|
|
git remote -v | grep -q "^origin *$(REMOTE_GIT_URL)" || git remote set-url --push origin $(REMOTE_GIT_URL)
|
2013-06-11 13:49:54 +00:00
|
|
|
|
|
|
|
|
git-clone-to-remote:
|
2025-11-26 17:48:01 +01:00
|
|
|
ssh $(JANWARE_USER)@git.janware.com "/opt/jw-pkg/bin/git-srv-admin.sh $(OPT_JANWARE_PROJECT) create-personal-project $(PROJECT)"
|
2019-03-13 15:45:01 +00:00
|
|
|
make git-config
|
2025-11-24 11:22:56 +01:00
|
|
|
git push --set-upstream origin $(GIT_MAIN_BRANCH)
|
2014-06-25 12:45:15 +00:00
|
|
|
git push --all $(REMOTE_GIT_URL)
|
2019-01-03 11:33:31 +00:00
|
|
|
make git-update-project-description
|
2012-09-02 16:06:47 +00:00
|
|
|
|
2014-06-24 18:49:35 +00:00
|
|
|
git-import: git-init git-config
|
2013-06-11 13:49:54 +00:00
|
|
|
git add -A
|
2016-05-08 13:11:06 +00:00
|
|
|
git status
|
2026-02-18 19:21:11 +01:00
|
|
|
git commit -am "First commit"
|
2013-06-11 13:49:54 +00:00
|
|
|
|
2016-04-20 14:37:09 +00:00
|
|
|
git-init-remote: git-import git-clone-to-remote
|
|
|
|
|
|
|
|
|
|
git-descr: $(GIT_DESCR)
|
2013-06-11 13:49:54 +00:00
|
|
|
|
2017-04-12 19:45:36 +00:00
|
|
|
git-update-project-description:
|
2025-11-26 17:48:01 +01:00
|
|
|
ssh $(JANWARE_USER)@git.janware.com "/opt/jw-pkg/bin/git-srv-admin.sh $(OPT_JANWARE_PROJECT) update-descriptions $(PROJECT)"
|
2017-04-12 19:45:36 +00:00
|
|
|
|
2012-05-01 10:42:27 +00:00
|
|
|
projects-%:
|
2026-01-28 07:56:33 +01:00
|
|
|
$(PYTHON) $(JWB_SCRIPT_DIR)/jw-pkg.py projects build $* $(PROJECT)
|
2012-04-30 07:56:35 +00:00
|
|
|
|
2014-10-23 13:14:54 +00:00
|
|
|
install-deps-devel:
|
2026-03-16 13:51:11 +01:00
|
|
|
sudo zypper in $(shell echo $(PKG_REQUIRES_DEVEL) | sed "s/ *= */-/g; s/ [^ ]\+-__NEXT_VERSION__//")
|
2014-10-23 13:14:54 +00:00
|
|
|
|
2015-12-12 12:46:58 +00:00
|
|
|
streamline:
|
|
|
|
|
$(STREAMLINE_PROJECT)
|
|
|
|
|
|
2016-04-20 14:37:09 +00:00
|
|
|
$(GIT_DESCR): $(PROJECT_DESCR_FILE)
|
2019-06-29 21:45:24 +00:00
|
|
|
/bin/bash $(JWB_SCRIPT_DIR)/ini-section.sh summary $< | tee $@.tmp
|
2016-04-20 14:37:09 +00:00
|
|
|
mv $@.tmp $@
|
|
|
|
|
|
|
|
|
|
git-init.done:
|
2026-01-25 17:34:53 +01:00
|
|
|
$(Q)if [ -e .git ]; then \
|
2016-04-20 14:37:09 +00:00
|
|
|
echo $(TOPDIR)/.git already exists, not running git init ;\
|
|
|
|
|
else \
|
2019-03-13 15:45:01 +00:00
|
|
|
@echo git init ;\
|
2016-04-20 14:37:09 +00:00
|
|
|
git init; \
|
|
|
|
|
fi
|
|
|
|
|
touch $@
|
|
|
|
|
|
|
|
|
|
prefix.done:
|
|
|
|
|
mkdir -p $(PREFIX)
|
|
|
|
|
touch $@
|
|
|
|
|
|
2019-12-07 19:21:08 +00:00
|
|
|
echo-build-deps:
|
2026-03-15 13:20:14 +01:00
|
|
|
$(Q)echo $(call proj_query, required-os-pkg --quote "build" $(PROJECT))
|
2017-04-05 13:31:19 +00:00
|
|
|
|
2018-10-18 18:30:17 +00:00
|
|
|
git-ssh-%:
|
|
|
|
|
bash -c "`git remote get-url --push $* | sed 's|ssh://||; s|\([^/]\+\)/\(.*\)|LC_CDPATH=/\2 ssh -o SendEnv=LC_CDPATH \1|'`"
|
|
|
|
|
git-ssh: git-ssh-origin
|
2018-12-16 18:45:24 +00:00
|
|
|
|
2026-02-21 09:29:11 +01:00
|
|
|
git-get-official:
|
|
|
|
|
make git-get-devops
|
2025-11-24 11:34:03 +01:00
|
|
|
|
2026-02-21 09:29:11 +01:00
|
|
|
git-get-maintainer:
|
|
|
|
|
make git-get-$(call proj_query,getval global jw-maintainer)
|
2025-11-24 11:22:56 +01:00
|
|
|
|
2026-02-21 09:29:11 +01:00
|
|
|
git-get-%:
|
2026-02-21 12:08:47 +01:00
|
|
|
PGIT_SH_PROJECTS=. $(PGIT_SH) get --refspec $*:$(GIT_MAIN_BRANCH):current-branch
|
2025-11-24 11:22:56 +01:00
|
|
|
|
2026-02-26 14:00:22 +01:00
|
|
|
get-%: git-get-%
|
|
|
|
|
@:
|
|
|
|
|
|
2020-11-11 16:16:42 +00:00
|
|
|
pkg-manager-refresh:
|
2026-01-28 08:10:09 +01:00
|
|
|
$(PKG_MANAGER) refresh
|
2020-11-11 16:16:42 +00:00
|
|
|
|
|
|
|
|
pkg-install-build-deps:
|
2026-03-15 13:20:14 +01:00
|
|
|
$(PKG_MANAGER) install $(shell $(proj_query_cmd) required-os-pkg --quote --skip-excluded "build" $(PROJECT))
|
2020-11-11 16:16:42 +00:00
|
|
|
|
|
|
|
|
pkg-install-release-deps:
|
2026-03-15 13:20:14 +01:00
|
|
|
$(PKG_MANAGER) install $(shell $(proj_query_cmd) required-os-pkg --quote --skip-excluded "build,run,release" $(PROJECT))
|
2020-11-11 16:16:42 +00:00
|
|
|
|
2026-03-15 16:39:28 +01:00
|
|
|
pkg-install-testbuild-deps:
|
|
|
|
|
$(PKG_MANAGER) install $(shell $(proj_query_cmd) pkg-requires --quote --skip-excluded --hide-self --syntax names-only --delimiter " " "build,run,devel,release" $(PROJECT))
|
2026-01-20 11:36:25 +01:00
|
|
|
|
2018-12-16 18:45:24 +00:00
|
|
|
echo-hash:
|
2026-01-25 17:34:53 +01:00
|
|
|
$(Q)/bin/bash $(PKG_SH_EXE) hash
|
2019-07-06 14:39:33 +00:00
|
|
|
|
|
|
|
|
recache-vars:
|
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 $(TOPDIR)/make clean-cache cache
|