aboutsummaryrefslogtreecommitdiffstats
path: root/build/Makefile.common.inc
blob: 80f2c190ddcc67f2a8ae9f56ec01289f085d39a0 (plain)
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
# Usage:
#
# Other makefiles like Makefile.asciidoc.inc and Makefile.vty-reference.inc add
# entries to UPLOAD_FILES and CLEAN_FILES.
#
# Put the repository name (e.g. "osmo-bts") into OSMO_REPOSITORY and include
# this file at the end to have the common targets (upload, clean, install etc.).

SSH_COMMAND = ssh -o 'UserKnownHostsFile=$(OSMO_GSM_MANUALS_DIR)/build/known_hosts' -p 48
UPLOAD_PATH ?= generic@sysmocom-downloads:documents
SYMLINKS = common build
CLEAN_FILES += $(SYMLINKS) $(SHRINK_MARKER)
PDF_FILES = $(patsubst %.adoc,%.pdf,$(ASCIIDOC)) $(patsubst %.xml,%.pdf,$(VTY_REFERENCE))
SHRINK_MARKER = generated/.pdf_shrink_marker
PUBLISH_REF ?= master
PUBLISH_TEMPDIR = _publish_tmpdir

# Prefix (Makefile.am sets this to configure's --prefix when including)
prefix ?= /usr/local

$(SYMLINKS):
	ln -s $(OSMO_GSM_MANUALS_DIR)/$@ $@

# Reduce pdf size by storing the embedded images with less quality (SYS#6380)
shrink: $(SHRINK_MARKER)
$(SHRINK_MARKER): $(UPLOAD_FILES)
	$(OSMO_GSM_MANUALS_DIR)/build/shrink-pdfs.sh $(UPLOAD_FILES)

# Publish to $UPLOAD_PATH
upload: shrink
	rsync -avz $(UPLOAD_FILES) $(UPLOAD_PATH)/

# Publish to https://ftp.osmocom.org/docs/
publish: shrink
	[ -n "$(OSMO_REPOSITORY)" ] || exit 1
	rm -rf "$(PUBLISH_TEMPDIR)"
	mkdir -p "$(PUBLISH_TEMPDIR)/$(OSMO_REPOSITORY)/$(PUBLISH_REF)"
	cp $(UPLOAD_FILES) "$(PUBLISH_TEMPDIR)/$(OSMO_REPOSITORY)/$(PUBLISH_REF)"
	cd "$(PUBLISH_TEMPDIR)" && \
		rsync \
			-avzR \
			-e "$(SSH_COMMAND)" \
			"$(OSMO_REPOSITORY)" \
			docs@ftp.osmocom.org:web-files/
	rm -rf "$(PUBLISH_TEMPDIR)"

# Install and uninstall targets
# Notes about OSMO_GSM_MANUALS_NO_INSTALL:
# - osmo-gsm-manuals.git's tests/Makefile.am sets this, so the test pdfs will not
#   get installed
# - installing manuals by default is fine, because Osmocom projects won't include
#   the whole Makefile.common.inc unless --enable-manuals is passed to configure.
install: $(PDF_FILES)
	[ -n "$(OSMO_REPOSITORY)" ] || exit 1
	if [ "$(OSMO_GSM_MANUALS_NO_INSTALL)" != "1" ]; then \
		for i in $(PDF_FILES); do \
			install -vDm644 "$$i" "$(DESTDIR)$(prefix)/share/doc/$(OSMO_REPOSITORY)-doc/$$i" || exit 1; \
		done; \
	fi

uninstall:
	[ -n "$(OSMO_REPOSITORY)" ] || exit 1
	if [ "$(OSMO_GSM_MANUALS_NO_INSTALL)" != "1" ]; then \
		for i in $(PDF_FILES); do \
			rm -v "$(DESTDIR)$(prefix)/share/doc/$(OSMO_REPOSITORY)-doc/$$i"; \
		done; \
	fi

clean:
	-rm -rf $(CLEAN_FILES)

distclean: clean