-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
74 lines (61 loc) · 2.07 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
70
71
72
73
74
# Directory to install to ('$(PREFIX)')
PREFIX ?= $(if $(VIRTUAL_ENV),$(VIRTUAL_ENV),$(CURDIR)/.local)
BINDIR = $(PREFIX)/bin
SHAREDIR = $(PREFIX)/share/ocrd_im6convert
# Docker tag
DOCKER_BASE_IMAGE ?= docker.io/ocrd/core:v2.69.0
DOCKER_TAG ?= ocrd/im6convert
# Python pip to install with ('$(PIP)')
PIP ?= $(shell which pip)
SCRIPTS = ocrd-im6convert
# BEGIN-EVAL makefile-parser --make-help Makefile
help:
@echo ""
@echo " Targets"
@echo ""
@echo " deps-ubuntu Install system packages (for use with containers)"
@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)')"
@echo " DOCKER_TAG Docker tag"
@echo " PIP Python pip to install with ('$(PIP)')"
# END-EVAL
# Install system packages (for use with containers)
deps-ubuntu:
apt-get -y install imagemagick
# 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: deps
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)
ifeq ($(findstring $(BINDIR),$(subst :, ,$(PATH))),)
@echo "you need to add '$(BINDIR)' to your PATH"
else
@echo "you already have '$(BINDIR)' in your PATH"
endif
# Uninstall scripts and $(SHAREDIR)
uninstall:
for script in $(SCRIPTS);do \
rm --verbose --force "$(BINDIR)/$$script";\
done
rm -rfv $(SHAREDIR)
# 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)' .
.PHONY: help deps deps-ubuntu install uninstall docker