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>
309 lines
8.4 KiB
Makefile
309 lines
8.4 KiB
Makefile
# Need second expansion for TD_COPY_XXX concatenation rule to work
|
|
.SECONDEXPANSION:
|
|
|
|
.PHONY: \
|
|
FORCE \
|
|
all \
|
|
format \
|
|
canonicalize-remotes \
|
|
check-syntax \
|
|
check-format \
|
|
check \
|
|
install \
|
|
clean \
|
|
distclean \
|
|
config \
|
|
mrproper \
|
|
unlocal \
|
|
topdir.distclean \
|
|
topdir.clean \
|
|
topdir.mrproper \
|
|
topdir.install \
|
|
do-install-links \
|
|
install-links \
|
|
get-maintainer \
|
|
get-official \
|
|
get-pub \
|
|
git-init \
|
|
git-init-from-cvs \
|
|
git-config \
|
|
git-clone-to-remote \
|
|
git-import \
|
|
git-init-remote \
|
|
git-descr \
|
|
git-update-project-description \
|
|
install-deps-devel \
|
|
streamline \
|
|
git-ssh \
|
|
git-get-official \
|
|
git-get-maintainer \
|
|
git-get-pub \
|
|
pkg-manager-refresh \
|
|
pkg-install-build-deps \
|
|
pkg-install-release-deps \
|
|
pkg-install-testbuild-deps \
|
|
recache-vars \
|
|
test
|
|
|
|
ifeq ($(ORDERED_SUBDIRS),)
|
|
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)))
|
|
endif
|
|
|
|
ifeq ($(USE_USER_URL),true)
|
|
JANWARE_USER_PREFIX = $(JANWARE_USER)@
|
|
endif
|
|
|
|
PROJECT_DESCR = $(TOPDIR)/make/project.conf
|
|
GIT_DESCR = $(TOPDIR)/.git/description
|
|
GIT_MAIN_BRANCH ?= master
|
|
|
|
OPT_JANWARE_PROJECT ?= -j
|
|
INTERACTIVE ?= auto
|
|
PKG_MANAGER ?= $(JW_PKG_PY) --interactive=$(INTERACTIVE) pkg
|
|
|
|
ifeq ($(OPT_JANWARE_PROJECT),-j)
|
|
REMOTE_GIT_FLAVOUR ?= proj
|
|
else
|
|
OPT_JANWARE_PROJECT =
|
|
REMOTE_GIT_FLAVOUR ?= priv
|
|
endif
|
|
|
|
ifneq ($(wildcard $(TOPDIR)/make/defs.mk),)
|
|
include $(TOPDIR)/make/defs.mk
|
|
endif
|
|
|
|
include $(JWBDIR)/make/defs.mk
|
|
|
|
REMOTE_GIT_DIR = /$(JANWARE_USER)/$(REMOTE_GIT_FLAVOUR)/$(PROJECT)
|
|
REMOTE_GIT_URL = ssh://$(JANWARE_USER_PREFIX)devgit.janware.com$(REMOTE_GIT_DIR)
|
|
|
|
ifneq ($(DONT_CHECK_PREREQ_DONE),true)
|
|
ifndef PREREQ_DIRS_BUILD
|
|
PREREQ_DIRS_BUILD := $(call proj_query,proj-dir $(PREREQ_BUILD))
|
|
endif
|
|
PREREQ_DIRS_BUILD_DONE := $(addsuffix /dirs-all.done,$(filter-out $(TOPDIR) /opt/%,$(PREREQ_DIRS_BUILD)))
|
|
endif
|
|
|
|
ifneq ($(SUBDIRS_TO_ITERATE),)
|
|
ifeq ($(MAKECMDGOALS),)
|
|
SUBDIR_TARGETS = all
|
|
else
|
|
SUBDIR_TARGETS = $(filter $(ALLOWED_SUBDIR_TARGETS),$(MAKECMDGOALS))
|
|
endif
|
|
endif
|
|
|
|
all: topdir config
|
|
test: all
|
|
|
|
include $(JWBDIR)/make/dirs.mk
|
|
include $(JWBDIR)/make/pkg-dist.mk
|
|
include $(JWBDIR)/make/rules.mk
|
|
include $(JWBDIR)/make/doc-rules.mk
|
|
include $(JWBDIR)/make/list-files.mk
|
|
include $(JWBDIR)/make/projects+project.mk
|
|
include $(JWBDIR)/make/cache.mk
|
|
|
|
STREAMLINE_PROJECT ?= bash $(JWB_SCRIPT_DIR)/streamline-project.sh
|
|
|
|
INSTALLED_TOPDIR_FILES = $(addprefix $(INSTALL_DOCDIR)/, $(DOCS))
|
|
|
|
TD_CONF_DIR ?= $(JW_PKG_CONF_BASE_DIR)/topdir
|
|
TD_COPY_SRC ?= $(TD_CONF_DIR)
|
|
TD_COPY_FILES ?= $(filter-out Makefile,$(notdir $(wildcard $(TD_COPY_SRC)/*)))
|
|
# -- Internal variables, define JW_PKG_TOPDIR_COPY_PATH if you want to
|
|
# add more files appended to the target files
|
|
TD_COPY_SRC_PATH = $(subst :,$(space),$(JW_PKG_TOPDIR_COPY_PATH))
|
|
TD_GENERATE_FILES += $(TD_COPY_FILES) $(CACHE_PROJECT_MK)
|
|
|
|
test: all
|
|
format: topdir
|
|
check-syntax: topdir
|
|
check-format: topdir
|
|
check: check-syntax check-format
|
|
@echo "Static code checks completed successfully!"
|
|
install: topdir.install
|
|
clean: topdir.clean
|
|
distclean: topdir.distclean
|
|
config:
|
|
mrproper:distclean topdir.mrproper
|
|
|
|
local-%: FORCE
|
|
find . -name $@.mk | \
|
|
while read f; do (\
|
|
cd `dirname $$f` ;\
|
|
$(RM) -f local.mk ;\
|
|
ln -s `basename $$f` local.mk ;\
|
|
) done
|
|
|
|
unlocal:
|
|
$(RM) -f $(shell find . -name local.mk)
|
|
|
|
topdir: $$(TD_GENERATE_FILES)
|
|
topdir.clean:
|
|
$(RM) -rf *.done $(TD_GENERATE_FILES)
|
|
clean: topdir.clean
|
|
topdir.distclean: topdir.clean
|
|
$(RM) -rf dist *.dist
|
|
distclean: topdir.distclean
|
|
topdir.mrproper: topdir.distclean
|
|
find . -name '*.rep' | xargs -r $(RM) -f
|
|
|
|
topdir.install: prefix.done $(INSTALLED_TOPDIR_FILES)
|
|
|
|
do-install-links:
|
|
$(Q)@cwd=$(shell $(PWD)); \
|
|
echo "o in $(INSTALL_LIBDIR):" ;\
|
|
find lib -name '*.so' -o -name '*.so.*' -o -name '*.a' -o -name '*.dll' | \
|
|
$(SED) 's%^\./%%' | \
|
|
while read f; do \
|
|
cd $(INSTALL_LIBDIR) && { \
|
|
echo " sudo ln -sf $$cwd/$$f" ; \
|
|
sudo ln -sf $$cwd/$$f; \
|
|
}; \
|
|
done; \
|
|
echo "o in $(INSTALL_EXEDIR):" ;\
|
|
find bin -type f -a -perm -u+x | \
|
|
$(SED) 's%^\./%%' | \
|
|
while read f; do \
|
|
cd $(INSTALL_EXEDIR) && { \
|
|
echo " sudo ln -sf $$cwd/$$f" ; \
|
|
sudo ln -sf $$cwd/$$f; \
|
|
}; \
|
|
done ;\
|
|
echo "o in $(INSTALL_HDRDIR):" ;\
|
|
find include -name '*.h' | \
|
|
$(SED) 's%^\./%%' | \
|
|
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' | \
|
|
$(SED) 's%^\./%%' | \
|
|
while read f; do \
|
|
cd $(INSTALL_MAKEDIR) && { \
|
|
echo " sudo ln -sf $$cwd/$$f" ; \
|
|
sudo ln -sf $$cwd/$$f; \
|
|
}; \
|
|
done; \
|
|
|
|
install-links:
|
|
DEVELOPMENT=false make do-install-links
|
|
|
|
get-maintainer: git-get-maintainer
|
|
get-official: git-get-official
|
|
get-pub: git-get-pub
|
|
|
|
git-init: git-init.done $(GIT_DESCR)
|
|
|
|
git-init-from-cvs: git-init
|
|
$(LIST_VCS_FILES) -f | xargs git add
|
|
git commit -m "First commit of $(PKG_VERSION)"
|
|
|
|
git-config:
|
|
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)
|
|
|
|
git-clone-to-remote:
|
|
ssh $(JANWARE_USER)@devgit.janware.com "/opt/jw-pkg/bin/git-srv-admin.sh $(OPT_JANWARE_PROJECT) create-personal-project $(PROJECT)"
|
|
make git-config
|
|
git push --set-upstream origin $(GIT_MAIN_BRANCH)
|
|
git push --all $(REMOTE_GIT_URL)
|
|
make git-update-project-description
|
|
|
|
git-import: git-init git-config
|
|
git add -A
|
|
git status
|
|
git commit -am "First commit"
|
|
|
|
git-init-remote: git-import git-clone-to-remote
|
|
|
|
git-descr: $(GIT_DESCR)
|
|
|
|
git-update-project-description:
|
|
ssh $(JANWARE_USER)@devgit.janware.com "/opt/jw-pkg/bin/git-srv-admin.sh $(OPT_JANWARE_PROJECT) update-descriptions $(PROJECT)"
|
|
|
|
projects-%: FORCE
|
|
$(PYTHON) $(JWB_SCRIPT_DIR)/jw-pkg.py projects build $* $(PROJECT)
|
|
|
|
install-deps-devel:
|
|
sudo zypper in $(shell echo $(PKG_REQUIRES_DEVEL) | sed "s/ *= */-/g; s/ [^ ]\+-__NEXT_VERSION__//")
|
|
|
|
streamline:
|
|
$(STREAMLINE_PROJECT)
|
|
|
|
$(GIT_DESCR): $(PROJECT_DESCR_FILE)
|
|
/bin/bash $(JWB_SCRIPT_DIR)/ini-section.sh summary $< | tee $@.tmp
|
|
mv $@.tmp $@
|
|
|
|
git-init.done:
|
|
$(Q)if [ -e .git ]; then \
|
|
echo $(TOPDIR)/.git already exists, not running git init ;\
|
|
else \
|
|
@echo git init ;\
|
|
git init; \
|
|
fi
|
|
touch $@
|
|
|
|
prefix.done:
|
|
mkdir -p $(PREFIX)
|
|
touch $@
|
|
|
|
echo-build-deps:
|
|
$(Q)echo $(call proj_query, required-os-pkg --quote "build" $(PROJECT))
|
|
|
|
git-ssh-%: FORCE
|
|
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
|
|
|
|
git-get-official:
|
|
make git-get-devops
|
|
|
|
git-get-maintainer:
|
|
make git-get-$(call proj_query,getval global jw-maintainer)
|
|
|
|
git-get-pub:
|
|
set -e; if git remote | grep -q "^pub$$"; then \
|
|
git fetch --prune --recurse-submodules=on-demand pub master ;\
|
|
git submodule foreach --recursive 'git fetch --tags -f pub' ;\
|
|
git rebase --autostash pub/master ;\
|
|
git merge --ff-only pub/master ;\
|
|
git submodule update --init --recursive ;\
|
|
fi
|
|
|
|
git-get-%: FORCE
|
|
PGIT_SH_PROJECTS=. $(PGIT_SH) get --refspec $*:$(GIT_MAIN_BRANCH):current-branch
|
|
|
|
get-%: git-get-%
|
|
@:
|
|
|
|
pkg-manager-refresh:
|
|
$(PKG_MANAGER) refresh
|
|
|
|
pkg-install-build-deps:
|
|
$(PKG_MANAGER) install $(shell $(proj_query_cmd) required-os-pkg --quote --skip-excluded "build" $(PROJECT))
|
|
|
|
pkg-install-release-deps:
|
|
$(PKG_MANAGER) install $(shell $(proj_query_cmd) required-os-pkg --quote --skip-excluded "build,run,release" $(PROJECT))
|
|
|
|
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))
|
|
|
|
recache-vars:
|
|
rm -f $(TOPDIR)/make clean-cache cache
|
|
|
|
canonicalize-remotes:
|
|
$(PYTHON) $(JWB_SCRIPT_DIR)/jw-pkg.py projects canonicalize-remotes
|
|
|
|
Makefile: ;
|
|
|
|
%: $(TD_COPY_SRC)/% $$(foreach path,$$(TD_COPY_SRC_PATH),$$(wildcard $$(addprefix $$(path)/,$$@))) $$(wildcard $$@.*)
|
|
cat $^ > $@.tmp
|
|
mv $@.tmp $@
|