Cleanup: Rename variables, remove edge-cases

- Rename some variables for clarity
    - BASE_PACKAGES  -> PREREQ_BASE
    - BUILD_PROJECTS -> TARGET_PROJECTS
    - BUILD_PROJECTS now contains $(TARGET_PROJECTS) and
      their dependencies

  - Remove almost all special treatment of packages, notably
    remove as many explicit project names from Makefile as
    possible

  - Work further towards making all targets work off the the
    current $(PROJECTS) definitions

  - Add target cloc, remove loc

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2018-11-30 13:18:44 +00:00
commit c49a3cbd03

View file

@ -20,26 +20,14 @@
SHELL = /bin/bash -o pipefail SHELL = /bin/bash -o pipefail
PROJECTS_TXT ?= projects.txt PROJECTS_TXT ?= projects.txt
JW_BUILD_VERBOSE ?= false JW_BUILD_VERBOSE ?= false
BASE_PACKAGES = cvs git make sudo PREREQ_BASE = cvs git make sudo
EXCLUDE_FROM_BUILD += \
dspider-btools \
dspider-shared \
feedfs-dspcd \
casview \
dspfs \
jux3 \
emscren-v8
# ------------ evaluate Makefile and environment variables # ------------ evaluate Makefile and environment variables
ifneq ($(wildcard $(PROJECTS_TXT)),) ifneq ($(wildcard $(PROJECTS_TXT)),)
PROJECTS ?= $(shell cat $(PROJECTS_TXT) | sed '/^ *\#/ d') PROJECTS ?= $(shell cat $(PROJECTS_TXT) | sed '/^ *\#/ d')
# TODO: this could be nicer
CVS_PROJECTS = $(PROJECTS)
else else
PROJECTS ?= $(shell ls -d */Makefile 2>/dev/null | sed 's%/[^/]*%%') PROJECTS ?= $(shell ls -d */Makefile 2>/dev/null | sed 's%/[^/]*%%')
CVS_PROJECTS = $(filter $(dir $(wildcard */CVS)),$(PROJECTS))
endif endif
ifeq ($(JW_BUILD_VERBOSE),true) ifeq ($(JW_BUILD_VERBOSE),true)
@ -63,8 +51,6 @@ 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))
ifndef JANWARE_USER ifndef JANWARE_USER
ifneq ($(wildcard CVS/Root),) ifneq ($(wildcard CVS/Root),)
JANWARE_USER = $(shell sed '/^:ext/ !d; s/:ext:\([^@]\+\)@.*/\1/' CVS/Root) JANWARE_USER = $(shell sed '/^:ext/ !d; s/:ext:\([^@]\+\)@.*/\1/' CVS/Root)
@ -120,12 +106,19 @@ EDITOR ?= xdg-open
GIT_SRV_ADMIN_SH = JW_BUILD_SSH_EXTRA_OPTS="$(JW_BUILD_SSH_EXTRA_OPTS)" $(GIT_SSH) $(JANWARE_USER)@git.janware.com /opt/jw-build/bin/git-srv-admin.sh GIT_SRV_ADMIN_SH = JW_BUILD_SSH_EXTRA_OPTS="$(JW_BUILD_SSH_EXTRA_OPTS)" $(GIT_SSH) $(JANWARE_USER)@git.janware.com /opt/jw-build/bin/git-srv-admin.sh
CVS_ADMIN_SH = JW_BUILD_SSH_EXTRA_OPTS="$(JW_BUILD_SSH_EXTRA_OPTS)" $(GIT_SSH) $(JANWARE_USER)@git.janware.com /opt/jw-build/bin/cvs-admin.sh CVS_ADMIN_SH = JW_BUILD_SSH_EXTRA_OPTS="$(JW_BUILD_SSH_EXTRA_OPTS)" $(GIT_SSH) $(JANWARE_USER)@git.janware.com /opt/jw-build/bin/cvs-admin.sh
# ------------ projects to be built
TARGET_PROJECTS = $(filter-out $(EXCLUDE_FROM_BUILD),$(PROJECTS))
BUILD_PROJECTS = $(shell $(PROJECTS_PY_BUILD) --build-order all $(TARGET_PROJECTS))
GIT_PROJECTS = $(patsubst %/,%,$(dir $(wildcard $(addsuffix /.git,$(BUILD_PROJECTS)))))
CVS_PROJECTS = $(patsubst %/,%,$(dir $(wildcard $(addsuffix /CVS,$(BUILD_PROJECTS)))))
# ------------ targets # ------------ targets
# --- mandatory 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) $@ $(TARGET_PROJECTS)
clean: clean-dirs done.clean clean: clean-dirs done.clean
distclean: clean-all-dirs done.clean distclean: clean-all-dirs done.clean
install: install:
@ -153,18 +146,18 @@ status: $(SSH_WRAPPER_SH)
$(PGIT) -uno status $(PGIT) -uno 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 $* $(TARGET_PROJECTS) | sed 's/ */\n/g'
build-order: build-order-all build-order: build-order-all
echo-prereq-build: echo-prereq-build:
@$(PROJECTS_PY) requires-pkg --skip-excluded --flavours "build" $(BUILD_PROJECTS) @$(PROJECTS_PY) requires-pkg --skip-excluded --flavours "build" $(TARGET_PROJECTS)
echo-prereq-install: echo-prereq-install:
@$(PROJECTS_PY) requires-pkg --skip-excluded --flavours "build run" $(BUILD_PROJECTS) @$(PROJECTS_PY) requires-pkg --skip-excluded --flavours "build run" $(TARGET_PROJECTS)
echo-prereq-release: echo-prereq-release:
@$(PROJECTS_PY) requires-pkg --skip-excluded --flavours "build run release" $(BUILD_PROJECTS) @$(PROJECTS_PY) requires-pkg --skip-excluded --flavours "build run release" $(TARGET_PROJECTS)
echo-os: echo-os:
@$(GET_OS_SH) @$(GET_OS_SH)
@ -186,27 +179,21 @@ clean.text-files-cache:
$(TEXT_FILES_CACHE): $(TEXT_FILES_CACHE):
@make text-files-update @make text-files-update
text-files-update: text-files-update:
@make --no-print-directory list-files | xargs file -N | grep ":.*text" | cut -d: -f1 > $(TEXT_FILES_CACHE).tmp @make -s --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) mv $(TEXT_FILES_CACHE).tmp $(TEXT_FILES_CACHE)
text-files-update-all: text-files-update-all:
@PROJECTS_TXT= make text-files-update @PROJECTS_TXT= make text-files-update
text-files-list list-text-files: | $(TEXT_FILES_CACHE) text-files-list list-text-files: | $(TEXT_FILES_CACHE)
@cat $(TEXT_FILES_CACHE) @cat $(TEXT_FILES_CACHE)
loc-all: cloc:
@make --no-print-directory list-text-files | \ for p in $(GIT_PROJECTS); do \
grep -v "iow-standalone\|jux3\|ntv2/contrib\|\.dia$$\|\.dat\$$\|bootsrap\.css\|mpegplayer/contrib\|gitweb.cgi" | \ git -C $$p submodule status | sed "s|^ *\([^ ]\+\) \+\([^ ]\+\) *.*|$$p/\2|" ;\
xargs wc -l done > cloc-ignore.txt
for p in $(foreach s,dist include bin lib,$(addsuffix /$s,$(BUILD_PROJECTS))); do \
find-code-files: echo $$p >> cloc-ignore.txt ;\
find . -name '*.c' -o -name '*.cpp' -o -name '*.h' \ done
-o -name Makefile -o -name '*.mk' \ cloc --exclude-list-file=cloc-ignore.txt $(BUILD_PROJECTS)
-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 # --- package-related targets
@ -214,10 +201,10 @@ pkg-manager-refresh:
$(PKG_MANAGER_SH) refresh -y $(PKG_MANAGER_SH) refresh -y
pkg-install-prereq-build: pkg-install-prereq-build:
$(PKG_MANAGER_SH) install -y $(BASE_PACKAGES) $(shell $(PROJECTS_PY) requires-pkg --skip-excluded --flavours "build" $(BUILD_PROJECTS)) $(PKG_MANAGER_SH) install -y $(PREREQ_BASE) $(shell $(PROJECTS_PY) requires-pkg --skip-excluded --flavours "build" $(TARGET_PROJECTS))
pkg-install-prereq-release: pkg-install-prereq-release:
$(PKG_MANAGER_SH) install -y $(BASE_PACKAGES) $(shell $(PROJECTS_PY) requires-pkg --skip-excluded --flavours "build run release" $(BUILD_PROJECTS)) $(PKG_MANAGER_SH) install -y $(PREREQ_BASE) $(shell $(PROJECTS_PY) requires-pkg --skip-excluded --flavours "build run release" $(TARGET_PROJECTS))
pkg-exclude-built-today: pkg-exclude-built-today:
touch $(EXCLUDES_FILE) touch $(EXCLUDES_FILE)
@ -247,7 +234,7 @@ pkg-init-%:
$(CREATE_PROJECT_SH) $* $(CREATE_PROJECT_SH) $*
pkg-%: $(filter-out $(UNAVAILABLE_TARGETS),pull.done) pkg-%: $(filter-out $(UNAVAILABLE_TARGETS),pull.done)
$(PROJECTS_PY_BUILD) $@ $(BUILD_PROJECTS) $(PROJECTS_PY_BUILD) $@ $(TARGET_PROJECTS)
# --- generic cleanup targets # --- generic cleanup targets