Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ocrd-make -C to cleanup *.mk; link/copy only unless exists #13

Merged
merged 3 commits into from
Jun 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ CONFIGNAME := $(basename $(notdir $(CONFIGURATION)))

WORKSPACES := $(patsubst %/mets.xml,%,$(wildcard */data/mets.xml */mets.xml))

ifeq ($(filter help info repair deps-ubuntu install uninstall %.mk,$(MAKECMDGOALS)),)
ifeq ($(filter help cleanup info repair deps-ubuntu install uninstall %.mk,$(MAKECMDGOALS)),)
ifeq ($(notdir $(MAKEFILE_LIST)),Makefile)
$(error Did you forget to select a workflow configuration makefile?)
else
Expand All @@ -71,6 +71,7 @@ help:
@echo
@echo " Targets (general):"
@echo " * help (this message)"
@echo " * cleanup (remove symlinked/copied Makefiles)"
@echo " * deps-ubuntu (install extra system packages needed here, beyond ocrd and processors)"
@echo " * install (copy 'ocrd-make' script and configuration makefiles to"
@echo " * VIRTUAL_ENV=$(VIRTUAL_ENV))"
Expand Down Expand Up @@ -111,6 +112,9 @@ uninstall:
$(RM) $(BINDIR)/ocrd-make
$(RM) -r $(SHAREDIR)

cleanup:
find $(SHAREDIR) \( -name 'Makefile' -or -name '*.mk' \) -exec basename {} \; |xargs rm -v

.PHONY: deps-ubuntu install uninstall

# spawn a new configuration
Expand Down
13 changes: 11 additions & 2 deletions ocrd-make
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,22 @@ function process {
# we want to have a fall-back for FS without symlink support
# or when some makefile already exists (perhaps with customization)
# but unfortunately, `cp -u` has strange semantics w.r.t. retvalue
ln -t "$CURDIR" -s "$SHAREDIR"/{*.mk,Makefile} 2>/dev/null || cp -fu "$SHAREDIR"/{*.mk,Makefile} "$CURDIR"
for f in *.mk Makefile;do
local src="$SHAREDIR/$f"
local dst="$CURDIR/$f"
if [[ ! -e "$dst" || "$src" -nt "$dst" ]];then
ln -s "$src" "$dst" 2>/dev/null || cp -f "$src" "$dst"
fi
done
make -C "$CURDIR" "$@"
)
}


case ${1:--h} in
-c|-[-]cleanup|cleanup)
process --no-print-directory cleanup
exit
;;
-h|-[-]help|help)
cat <<EOF
(This will merely delegate to \`make\` on the current working directory "$PWD"
Expand Down