Various improvements
This commit is contained in:
		
							
								
								
									
										93
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										93
									
								
								Makefile
									
									
									
									
									
								
							@@ -1,24 +1,28 @@
 | 
			
		||||
SRC_DIR := ./src
 | 
			
		||||
DOCS_DIR := ./docs
 | 
			
		||||
TESTS_DIR := ./tests
 | 
			
		||||
BUILD_DIR := ./build
 | 
			
		||||
DOCS_BUILD_DIR := ./build/docs
 | 
			
		||||
SRC_DIR 	:= ./src
 | 
			
		||||
DOCS_DIR 	:= ./docs
 | 
			
		||||
TESTS_DIR 	:= ./tests
 | 
			
		||||
BUILD_DIR 	:= ./dist
 | 
			
		||||
 | 
			
		||||
.PHONY: help tests docs man install uninstall
 | 
			
		||||
.PHONY: help tests manpages install uninstall fixpath
 | 
			
		||||
 | 
			
		||||
all: man
 | 
			
		||||
all: manpages
 | 
			
		||||
 | 
			
		||||
help:
 | 
			
		||||
	@echo Usage: make TARGET
 | 
			
		||||
	@echo 'Usage:  make TARGET'
 | 
			
		||||
	@echo '	make prefix=/path install'
 | 
			
		||||
	@echo '	make prefix=/path uninstall'
 | 
			
		||||
	@echo
 | 
			
		||||
	@echo Available targets:
 | 
			
		||||
	@echo
 | 
			
		||||
	@echo 'help	print this help message'
 | 
			
		||||
	@echo 'tests	run tests from $(TESTS_DIR)'
 | 
			
		||||
	@echo 'lint	run shellcheck'
 | 
			
		||||
	@echo 'man	build manual pages from $(DOCS_DIR)'
 | 
			
		||||
	@echo '	help		print this help message'
 | 
			
		||||
	@echo '	tests		run tests from $(TESTS_DIR)'
 | 
			
		||||
	@echo '	lint		run shellcheck'
 | 
			
		||||
	@echo '	manpages	build manual pages from $(DOCS_DIR)'
 | 
			
		||||
	@echo '	install		install boring-backup with prefix'
 | 
			
		||||
	@echo '	uninstall	uninstall boring-backup with prefix'
 | 
			
		||||
	@echo
 | 
			
		||||
	@echo See README.md for more info.
 | 
			
		||||
	@echo 'prefix examples: $$HOME/.local, /usr/local, /usr/bin'
 | 
			
		||||
	@echo See README for more info.
 | 
			
		||||
 | 
			
		||||
tests:
 | 
			
		||||
	# See bats(1), https://bats-core.readthedocs.io/en/latest/index.html
 | 
			
		||||
@@ -32,24 +36,63 @@ lint:
 | 
			
		||||
	shellcheck $(SRC_DIR)/lib/handlers/sources/*.sh
 | 
			
		||||
	shellcheck $(SRC_DIR)/lib/handlers/targets/*.sh
 | 
			
		||||
 | 
			
		||||
man: build_dir
 | 
			
		||||
	# See rst2man(1), rst2html(1),
 | 
			
		||||
manpages:
 | 
			
		||||
	mkdir -pv $(BUILD_DIR)/share/man/ru/man1
 | 
			
		||||
	# See rst2man(1)
 | 
			
		||||
	# https://docutils.sourceforge.io/docs/index.html
 | 
			
		||||
	rst2man $(DOCS_DIR)/boring-backup.ru.1.rst \
 | 
			
		||||
		> $(DOCS_BUILD_DIR)/boring-backup.ru.1
 | 
			
		||||
	rst2man -v $(DOCS_DIR)/manpages/boring-backup.ru.1.rst \
 | 
			
		||||
		> $(BUILD_DIR)/share/man/ru/man1/boring-backup.1
 | 
			
		||||
	sed -e 's/.SH NAME/.SH ИМЯ/' \
 | 
			
		||||
		-e 's/.SH AUTHOR/.SH АВТОРЫ/' \
 | 
			
		||||
		-e 's/.SH COPYRIGHT/.SH АВТОРСКИЕ ПРАВА/' \
 | 
			
		||||
		-i $(DOCS_BUILD_DIR)/boring-backup.ru.1
 | 
			
		||||
	gzip -9 $(DOCS_BUILD_DIR)/boring-backup.ru.1
 | 
			
		||||
		-i $(BUILD_DIR)/share/man/ru/man1/boring-backup.1
 | 
			
		||||
	gzip -vf9 $(BUILD_DIR)/share/man/ru/man1/boring-backup.1
 | 
			
		||||
 | 
			
		||||
build_dir:
 | 
			
		||||
	mkdir -p $(BUILD_DIR)
 | 
			
		||||
	mkdir -p $(DOCS_BUILD_DIR)
 | 
			
		||||
html: manpages
 | 
			
		||||
	mkdir -p $(BUILD_DIR)/share/doc/boring-backup
 | 
			
		||||
	zcat $(BUILD_DIR)/share/man/ru/man1/boring-backup.1.gz | \
 | 
			
		||||
		groff -man -Kutf8 -Thtml \
 | 
			
		||||
		> $(BUILD_DIR)/share/doc/boring-backup/boring-backup.1.html 2>/dev/null
 | 
			
		||||
	rm -v grohtml-*.png
 | 
			
		||||
 | 
			
		||||
install:
 | 
			
		||||
	# install
 | 
			
		||||
install: manpages
 | 
			
		||||
	@echo prefix: $$prefix
 | 
			
		||||
	install -Dm755 $(SRC_DIR)/boring-backup $$prefix/bin/boring-backup
 | 
			
		||||
	install -Dm644 $(SRC_DIR)/lib/lib.sh $$prefix/share/boring-backup/lib.sh
 | 
			
		||||
	install -Dm644 $(SRC_DIR)/lib/backup.sh $$prefix/share/boring-backup/backup.sh
 | 
			
		||||
	install -Dm644 $(SRC_DIR)/lib/common.sh $$prefix/share/boring-backup/common.sh
 | 
			
		||||
	install -Dm644 $(SRC_DIR)/lib/source.sh $$prefix/share/boring-backup/source.sh
 | 
			
		||||
	install -Dm644 $(SRC_DIR)/lib/uri.sh $$prefix/share/boring-backup/uri.sh
 | 
			
		||||
	install -Dm644 $(SRC_DIR)/lib/handlers/sources/tar.sh $$prefix/share/boring-backup/handlers/sources/tar.sh
 | 
			
		||||
	install -Dm644 $(SRC_DIR)/lib/handlers/sources/mysqldump.sh $$prefix/share/boring-backup/handlers/sources/mysqldump.sh
 | 
			
		||||
	install -Dm644 $(SRC_DIR)/lib/handlers/sources/pg_dump.sh $$prefix/share/boring-backup/handlers/sources/pg_dump.sh
 | 
			
		||||
	install -Dm644 $(SRC_DIR)/lib/handlers/targets/cp.sh $$prefix/share/boring-backup/handlers/targets/cp.sh
 | 
			
		||||
	install -Dm644 $(SRC_DIR)/lib/handlers/targets/s3cmd.sh $$prefix/share/boring-backup/handlers/targets/s3cmd.sh
 | 
			
		||||
	sed -e "s%LIBRARY=\"\$${LIBRARY:-.\/lib}\"%LIBRARY=\"\$${LIBRARY:-$$prefix\/share\/boring-backup}\"%" \
 | 
			
		||||
		-i $$prefix/share/boring-backup/lib.sh \
 | 
			
		||||
		-i $$prefix/bin/boring-backup
 | 
			
		||||
	install -Dm664 $(BUILD_DIR)/share/man/ru/man1/boring-backup.1.gz $$prefix/share/man/ru/man1/boring-backup.1.gz
 | 
			
		||||
 | 
			
		||||
uninstall:
 | 
			
		||||
	# uninstall
 | 
			
		||||
	@echo prefix: $$prefix
 | 
			
		||||
	rm $$prefix/bin/boring-backup
 | 
			
		||||
	rm $$prefix/share/boring-backup/lib.sh
 | 
			
		||||
	rm $$prefix/share/boring-backup/backup.sh
 | 
			
		||||
	rm $$prefix/share/boring-backup/common.sh
 | 
			
		||||
	rm $$prefix/share/boring-backup/source.sh
 | 
			
		||||
	rm $$prefix/share/boring-backup/uri.sh
 | 
			
		||||
	rm $$prefix/share/boring-backup/handlers/sources/tar.sh
 | 
			
		||||
	rm $$prefix/share/boring-backup/handlers/sources/mysqldump.sh
 | 
			
		||||
	rm $$prefix/share/boring-backup/handlers/sources/pg_dump.sh
 | 
			
		||||
	rm $$prefix/share/boring-backup/handlers/targets/cp.sh
 | 
			
		||||
	rm $$prefix/share/boring-backup/handlers/targets/s3cmd.sh
 | 
			
		||||
	rm -rv $$prefix/share/boring-backup
 | 
			
		||||
	rm $$prefix/share/man/ru/man1/boring-backup.1.gz
 | 
			
		||||
 | 
			
		||||
fixpath:
 | 
			
		||||
	# Set boring-backup library path
 | 
			
		||||
	@echo prefix: $$prefix
 | 
			
		||||
	@echo path: $$path
 | 
			
		||||
	sed -e "s%LIBRARY=\"\$${LIBRARY:-.\/lib}\"%LIBRARY=\"\$${LIBRARY:-$$path}\"%" \
 | 
			
		||||
		-i $$prefix/share/boring-backup/lib.sh \
 | 
			
		||||
		-i $$prefix/bin/boring-backup
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user