-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
69 lines (58 loc) · 1.93 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
PROJECT_NAME := ocrd_pagetopdf
SCRIPTS = ocrd-pagetopdf
DOCKER_TAG = ocrd/pagetopdf
PIP ?= $(shell which pip)
# Directory to install to ('$(PREFIX)')
PREFIX ?= $(if $(VIRTUAL_ENV),$(VIRTUAL_ENV),/usr/local)
BINDIR = $(PREFIX)/bin
SHAREDIR = $(PREFIX)/share/$(PROJECT_NAME)
# BEGIN-EVAL makefile-parser --make-help Makefile
help:
@echo ""
@echo " Targets"
@echo ""
@echo " deps-ubuntu Install system packages (on Debian/Ubuntu)"
@echo " deps Install python packages"
@echo " install Install the executable in $(PREFIX)/bin and the ocrd-tool.json to $(SHAREDIR)"
@echo " uninstall Uninstall scripts and $(SHAREDIR)"
@echo " docker Build Docker image"
@echo ""
@echo " Variables"
@echo ""
@echo " PREFIX Directory to install to ('$(PREFIX)')"
# END-EVAL
# Install system packages (on Debian/Ubuntu)
deps-ubuntu:
apt-get install -y python3 python3-venv default-jre-headless ghostscript
# Install python packages
deps:
$(PIP) install ocrd # needed for ocrd CLI (and bashlib)
# Install the executable in $(PREFIX)/bin and the ocrd-tool.json to $(SHAREDIR)
install:
mkdir -p $(BINDIR)
for script in $(SCRIPTS);do \
sed 's,^SHAREDIR.*,SHAREDIR="$(SHAREDIR)",' $$script > $(BINDIR)/$$script ;\
chmod a+x $(BINDIR)/$$script ;\
done
mkdir -p $(SHAREDIR)
cp ocrd-tool.json $(SHAREDIR)
cp -r ptp $(SHAREDIR)
ifeq ($(findstring $(BINDIR),$(subst :, ,$(PATH))),)
@echo "you need to add '$(BINDIR)' to your PATH"
else
@echo "you already have '$(BINDIR)' in your PATH. good job."
endif
# Uninstall scripts and $(SHAREDIR)
uninstall:
for script in $(SCRIPTS);do \
rm --verbose --force "$(BINDIR)/$$script";\
done
rm -rfv $(SHAREDIR)
make -C ocr-pagetopdf PREFIX=$(PREFIX) uninstall
# Build Docker image
docker:
docker build \
--build-arg DOCKER_BASE_IMAGE=$(DOCKER_BASE_IMAGE) \
--build-arg VCS_REF=$$(git rev-parse --short HEAD) \
--build-arg BUILD_DATE=$$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
-t $(DOCKER_TAG) .