projects-dir.mk: Code beautification

Bigger diff, mostly because targets are reorganized into functional groups

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2018-11-02 11:40:00 +00:00
commit e00191a6e8

View file

@ -57,7 +57,7 @@ EXCLUDES_FILES = exclude-$(shell $(GET_OS_SH) name).txt exclude-$(shell $
TEXT_FILES_CACHE ?= text-files.txt TEXT_FILES_CACHE ?= text-files.txt
ifneq ($(wildcard $(EXCLUDES_FILES)),) ifneq ($(wildcard $(EXCLUDES_FILES)),)
EXCLUDE_FROM_BUILD += $(shell sed 's/\#.*//g' $(wildcard $(EXCLUDES_FILES))) EXCLUDE_FROM_BUILD += $(shell sed 's/\#.*//g' $(wildcard $(EXCLUDES_FILES)))
endif endif
BUILD_PROJECTS = $(filter-out $(EXCLUDE_FROM_BUILD),$(PROJECTS)) BUILD_PROJECTS = $(filter-out $(EXCLUDE_FROM_BUILD),$(PROJECTS))
@ -108,7 +108,6 @@ PGIT = /bin/bash $(MOD_SCRIPT_DIR)/pgit.sh
PROJECTS_PY = python2 $(MOD_SCRIPT_DIR)/projects.py --prefix $(shell pwd) $(PROJECTS_PY_EXTRA_OPTS) PROJECTS_PY = python2 $(MOD_SCRIPT_DIR)/projects.py --prefix $(shell pwd) $(PROJECTS_PY_EXTRA_OPTS)
PROJECTS_PY_BUILD = $(PROJECTS_PY) build $(PROJECTS_PY_EXTRA_BUILD_OPTS) PROJECTS_PY_BUILD = $(PROJECTS_PY) build $(PROJECTS_PY_EXTRA_BUILD_OPTS)
PURGE_SH = /bin/bash $(firstword $(wildcard $(MOD_SCRIPT_DIR)/purge-stale-projects.sh /opt/jw-build/bin/purge-stale-projects.sh) purge-not-found) PURGE_SH = /bin/bash $(firstword $(wildcard $(MOD_SCRIPT_DIR)/purge-stale-projects.sh /opt/jw-build/bin/purge-stale-projects.sh) purge-not-found)
RELEASE_SH = /bin/bash $(firstword $(wildcard $(MOD_SCRIPT_DIR)/build-release.sh /opt/jw-build/bin/build-release.sh) release-not-found)
PKG_MANAGER_SH ?= /bin/bash $(firstword $(wildcard $(MOD_SCRIPT_DIR)/pkg-manager.sh /opt/jw-build/bin/pkg-manager.sh) pkg-manager-not-found) PKG_MANAGER_SH ?= /bin/bash $(firstword $(wildcard $(MOD_SCRIPT_DIR)/pkg-manager.sh /opt/jw-build/bin/pkg-manager.sh) pkg-manager-not-found)
CREATE_PROJECT_SH ?= /bin/bash $(firstword $(wildcard $(MOD_SCRIPT_DIR)/jw-build-create-project.sh /opt/jw-build/bin/jw-build-create-project.sh) jw-build-create-project-not-found) CREATE_PROJECT_SH ?= /bin/bash $(firstword $(wildcard $(MOD_SCRIPT_DIR)/jw-build-create-project.sh /opt/jw-build/bin/jw-build-create-project.sh) jw-build-create-project-not-found)
LIST_VCS_FILES = /bin/bash $(firstword $(wildcard $(MOD_SCRIPT_DIR)/list-cvs-files.sh /opt/jw-build/bin/list-cvs-files.sh) list-cvs-files-not-found) LIST_VCS_FILES = /bin/bash $(firstword $(wildcard $(MOD_SCRIPT_DIR)/list-cvs-files.sh /opt/jw-build/bin/list-cvs-files.sh) list-cvs-files-not-found)
@ -120,6 +119,8 @@ CVS_ADMIN_SH = JW_BUILD_SSH_EXTRA_OPTS="$(JW_BUILD_SSH_EXTRA_OPTS)" $(G
# ------------ targets # ------------ targets
# --- mandatory targets
all: $(filter-out $(UNAVAILABLE_TARGETS),pull.done links.done) all: $(filter-out $(UNAVAILABLE_TARGETS),pull.done links.done)
$(PROJECTS_PY_BUILD) $@ $(BUILD_PROJECTS) $(PROJECTS_PY_BUILD) $@ $(BUILD_PROJECTS)
clean: clean-dirs done.clean clean: clean-dirs done.clean
@ -131,17 +132,28 @@ install:
@echo @echo
@exit 1 @exit 1
# --- build targets
rebuild: clean purge pull subdirs-all
subdirs-%:
FORCE_REBUILD_SUBDIRS=true make $*
# --- informative-only targets
doc-project doc-module:
$(BROWSER) $(firstword $(shell sed '/https:/ !d; s%.*https%https%; s/ .*//' $(firstword $(MAKEFILE_LIST))))
status: $(SSH_WRAPPER_SH)
for p in $(CVS_PROJECTS); do test -f $$d/CVS || echo $$p; done
cvs status $(addsuffix VERSION,$(CVS_PROJECTS))
$(PGIT) status
build-order-%: $(filter-out $(UNAVAILABLE_TARGETS),pull.done) build-order-%: $(filter-out $(UNAVAILABLE_TARGETS),pull.done)
$(PROJECTS_PY_BUILD) --build-order $* $(BUILD_PROJECTS) | sed 's/ */\n/g' $(PROJECTS_PY_BUILD) --build-order $* $(BUILD_PROJECTS) | sed 's/ */\n/g'
build-order: build-order-all build-order: build-order-all
clean-dirs:
if [ -n "$(wildcard */*.done)" ]; then ls */*.done 2>/dev/null | sed 's%/.*%%' | xargs -r $(PROJECTS_PY_BUILD) --exclude "" clean; fi
clean-all-dirs:
$(PROJECTS_PY_BUILD) clean $(PROJECTS)
echo-prereq-build: echo-prereq-build:
@$(PROJECTS_PY) requires-pkg --skip-excluded --flavours "build" $(BUILD_PROJECTS) @$(PROJECTS_PY) requires-pkg --skip-excluded --flavours "build" $(BUILD_PROJECTS)
@ -156,6 +168,45 @@ echo-os:
echo-excludes: echo-excludes:
@echo $(EXCLUDE_FROM_BUILD) @echo $(EXCLUDE_FROM_BUILD)
edit-%: | $(TEXT_FILES_CACHE)
$(EDITOR) $(shell grep "/$*$$" $(TEXT_FILES_CACHE))
list-files:
@for p in $(PROJECTS); do \
$(LIST_VCS_FILES) -znf $$p | sed -z "s/^/$$p\//" | \
xargs -0 realpath ;\
done
clean: clean.text-files-cache
clean.text-files-cache:
rm -f $(TEXT_FILES_CACHE)
$(TEXT_FILES_CACHE):
@make text-files-update
text-files-update:
@make --no-print-directory list-files | xargs file -N | grep ":.*text" | cut -d: -f1 > $(TEXT_FILES_CACHE).tmp
mv $(TEXT_FILES_CACHE).tmp $(TEXT_FILES_CACHE)
text-files-update-all:
@PROJECTS_TXT= make text-files-update
text-files-list list-text-files: | $(TEXT_FILES_CACHE)
@cat $(TEXT_FILES_CACHE)
loc-all:
@make --no-print-directory list-text-files | \
grep -v "iow-standalone\|jux3\|ntv2/contrib\|\.dia$$\|\.dat\$$\|bootsrap\.css\|mpegplayer/contrib\|gitweb.cgi" | \
xargs wc -l
find-code-files:
find . -name '*.c' -o -name '*.cpp' -o -name '*.h' \
-o -name Makefile -o -name '*.mk' \
-o -name '*.sh' -o -name '*.pl' -o -name '*.py' \
| grep -v "/dist/\|\.dep\.mk\|local.mk\|coordgen\|^\./[^/]\+/include/" \
| grep -v "contrib/wt\|/bin/\|contrib/bootstrap\|contrib/chntpw/src\|contrib/jquery/src\|contrib/ntv2linux" \
| grep -v "copilot-suse-tw-cf/initrd-tree" \
| grep -v "iow-standalone\|jux3" \
| grep -v "generated\|tmp\|old\|orig\|purged"
# --- package-related targets
pkg-manager-refresh: pkg-manager-refresh:
$(PKG_MANAGER_SH) refresh -y $(PKG_MANAGER_SH) refresh -y
@ -193,19 +244,30 @@ pkg-init-%:
pkg-%: $(filter-out $(UNAVAILABLE_TARGETS),pull.done) pkg-%: $(filter-out $(UNAVAILABLE_TARGETS),pull.done)
$(PROJECTS_PY_BUILD) $@ $(BUILD_PROJECTS) $(PROJECTS_PY_BUILD) $@ $(BUILD_PROJECTS)
doc-project doc-module: # --- generic cleanup targets
$(BROWSER) $(firstword $(shell sed '/https:/ !d; s%.*https%https%; s/ .*//' $(firstword $(MAKEFILE_LIST))))
status: $(SSH_WRAPPER_SH) clean-dirs:
for p in $(CVS_PROJECTS); do test -f $$d/CVS || echo $$p; done if [ -n "$(wildcard */*.done)" ]; then ls */*.done 2>/dev/null | sed 's%/.*%%' | xargs -r $(PROJECTS_PY_BUILD) --exclude "" clean; fi
cvs status $(addsuffix VERSION,$(CVS_PROJECTS))
$(PGIT) status clean-all-dirs:
$(PROJECTS_PY_BUILD) clean $(PROJECTS)
purge: $(SSH_WRAPPER_SH) purge: $(SSH_WRAPPER_SH)
ifneq ($(wildcard CVS),) ifneq ($(wildcard CVS),)
$(PURGE_SH) $(PURGE_SH)
endif endif
$(PROJECTS_TXT):
echo $(PROJECTS) | sed 's/ /\n/g; s%/%%g' > $@
done.clean:
rm -f *.done
# --- collab targets
list-maintainers: $(SSH_WRAPPER_SH)
$(GIT_SRV_ADMIN_SH) $@
update pull: purge cvs-update git-clone update pull: purge cvs-update git-clone
touch pull.done touch pull.done
@ -223,21 +285,13 @@ pull-all: purge cvs-update git-clone git-pull-all
diff-all diff: $(SSH_WRAPPER_SH) diff-all diff: $(SSH_WRAPPER_SH)
cvs diff -u; $(PGIT) diff cvs diff -u; $(PGIT) diff
rebuild: clean purge pull subdirs-all cvs-diff: $(SSH_WRAPPER_SH)
cvs diff -u
release: $(SSH_WRAPPER_SH)
$(RELEASE_SH)
subdirs-%:
FORCE_REBUILD_SUBDIRS=true make $*
cvs-update: $(SSH_WRAPPER_SH) cvs-update: $(SSH_WRAPPER_SH)
rm -f $@.done rm -f $@.done
make $@.done make $@.done
cvs-diff: $(SSH_WRAPPER_SH)
cvs diff -u
git-push push: $(SSH_WRAPPER_SH) git-push push: $(SSH_WRAPPER_SH)
$(PGIT) push $(PGIT) push
@ -274,11 +328,14 @@ git-show-non-master-branches:
done done
# git-echo-link-<filename> returns a string functioning as hyperlink to # git-echo-link-<filename> returns a string functioning as hyperlink to
# matching files in git, if embedded into a janware wiki or ticket. # matching files in git when embedded into a janware wiki or ticket.
git-echo-links-%: | $(TEXT_FILES_CACHE) git-echo-links-%: | $(TEXT_FILES_CACHE)
sed "/$*$$/!d; s%$(CWD)%%; s|^|\n \[\[jgit>/proj/$(JANWARE_USER)/|; s/$$/|$*\]\]\n/" $(TEXT_FILES_CACHE) sed "/$*$$/!d; s%$(CWD)%%; s|^|\n \[\[jgit>/proj/$(JANWARE_USER)/|; s/$$/|$*\]\]\n/" $(TEXT_FILES_CACHE)
pull-%: $(SSH_WRAPPER_SH) git-update-project-descriptions: $(SSH_WRAPPER_SH)
$(GIT_SRV_ADMIN_SH) -j update-descriptions all
git-pull-%: $(SSH_WRAPPER_SH)
PGIT_CLONE_FROM_USER=$* $(PGIT) clone PGIT_CLONE_FROM_USER=$* $(PGIT) clone
git-commit: git-commit:
@ -294,25 +351,12 @@ git-conv-%: $(SSH_WRAPPER_SH)
fi \ fi \
} }
check-conv: $(SSH_WRAPPER_SH) git-check-conv: $(SSH_WRAPPER_SH)
for p in `$(GIT_SRV_ADMIN_SH) -u jan -j list-personal-projects`; do \ for p in `$(GIT_SRV_ADMIN_SH) -u jan -j list-personal-projects`; do \
make git-conv-$$p ;\ make git-conv-$$p ;\
done done
list-maintainers: $(SSH_WRAPPER_SH) # --- rules
$(GIT_SRV_ADMIN_SH) $@
git-update-project-descriptions: $(SSH_WRAPPER_SH)
$(GIT_SRV_ADMIN_SH) -j update-descriptions all
$(PROJECTS_TXT):
echo $(PROJECTS) | sed 's/ /\n/g; s%/%%g' > $@
edit-%: | $(TEXT_FILES_CACHE)
$(EDITOR) $(shell grep "/$*$$" $(TEXT_FILES_CACHE))
done.clean:
rm -f *.done
links.done: links.done:
if [ -d btools ]; then ln -sf btools dspider-btools; fi if [ -d btools ]; then ln -sf btools dspider-btools; fi
@ -357,38 +401,3 @@ pull.done: $(filter-out $(UNAVAILABLE_TARGETS),cvs-update.done clone.done links.
clone.done: $(filter-out $(UNAVAILABLE_TARGETS),$(SSH_WRAPPER_SH)) clone.done: $(filter-out $(UNAVAILABLE_TARGETS),$(SSH_WRAPPER_SH))
$(PGIT) clone $(PGIT) clone
touch $@ touch $@
list-files:
@for p in $(PROJECTS); do \
$(LIST_VCS_FILES) -znf $$p | sed -z "s/^/$$p\//" | \
xargs -0 realpath ;\
done
clean: clean.text-files-cache
clean.text-files-cache:
rm -f $(TEXT_FILES_CACHE)
$(TEXT_FILES_CACHE):
@make text-files-update
text-files-update:
@make --no-print-directory list-files | xargs file -N | grep ":.*text" | cut -d: -f1 > $(TEXT_FILES_CACHE).tmp
mv $(TEXT_FILES_CACHE).tmp $(TEXT_FILES_CACHE)
text-files-update-all:
@PROJECTS_TXT= make text-files-update
text-files-list list-text-files: | $(TEXT_FILES_CACHE)
@cat $(TEXT_FILES_CACHE)
loc-all:
@make --no-print-directory list-text-files | \
grep -v "iow-standalone\|jux3\|ntv2/contrib\|\.dia$$\|\.dat\$$\|bootsrap\.css\|mpegplayer/contrib\|gitweb.cgi" | \
xargs wc -l
find-code-files:
find . -name '*.c' -o -name '*.cpp' -o -name '*.h' \
-o -name Makefile -o -name '*.mk' \
-o -name '*.sh' -o -name '*.pl' -o -name '*.py' \
| grep -v "/dist/\|\.dep\.mk\|local.mk\|coordgen\|^\./[^/]\+/include/" \
| grep -v "contrib/wt\|/bin/\|contrib/bootstrap\|contrib/chntpw/src\|contrib/jquery/src\|contrib/ntv2linux" \
| grep -v "copilot-suse-tw-cf/initrd-tree" \
| grep -v "iow-standalone\|jux3" \
| grep -v "generated\|tmp\|old\|orig\|purged"