From 12ae1ba84d190c70043892a999b89d817bcb0ce0 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Sun, 18 Oct 2020 10:04:57 +0200 Subject: Makefile new --- .gitignore | 1 + Makefile | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++ clean-compile-mpost | 43 ---------------------------------------- clean-compile-mpost.in | 45 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 99 insertions(+), 43 deletions(-) create mode 100644 .gitignore create mode 100644 Makefile delete mode 100755 clean-compile-mpost create mode 100755 clean-compile-mpost.in diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a9fed2d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +clean-compile-mpost diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..80f76d8 --- /dev/null +++ b/Makefile @@ -0,0 +1,53 @@ +# +# clean-compile-mpost - compile metapost in a clean temporary directory +# +# Copyright (c) 2020 Erich Eckner +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, +# USA. +# + +SHELL = /bin/bash +DESTDIR = +BINDIR = /usr/bin + +VERSION = 0.0 + +all: clean-compile-mpost + +%: %.in + sed " \ + s/#VERSION#/$(VERSION)/; \ + s@#SHELL#@$(SHELL)@; \ + " $< > $@ && \ + ( [[ "$@" = *.* ]] || chmod +x "$@" ) + +.PHONY: install dist clean + +install: all + install -D -m0755 -t $(DESTDIR)$(BINDIR) clean-compile-mpost + +clean: + git clean -x -d -f + +dist: clean + git status --porcelain 2> /dev/null | grep -q "\S" && (git add .; git commit -m"neue Version: $(VERSION)") || true + ! git tag -d v$(VERSION) 2> /dev/null + git tag v$(VERSION) + knock-knock || true + git push + git push --tags + +# End of file diff --git a/clean-compile-mpost b/clean-compile-mpost deleted file mode 100755 index 6eba233..0000000 --- a/clean-compile-mpost +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash - -# clean-compile-mpost source.mp target-dir/ additional-file1 additional-file2 ... - -if ! source=$(readlink -e "$1"); then - >&2 printf 'Cannot read source "%s"\n' "$1" - exit 1 -fi -shift -if [ $# -eq 0 ]; then - target_dir=$(pwd) -else - if ! target_dir=$(readlink -e "$1"); then - >&2 printf 'Cannot read target-dir "%s"\n' "$1" - exit 1 - fi - shift -fi -if ! [ -d "${target_dir}" ]; then - >&2 printf 'Target-dir "%s" is no directory\n' "${target_dir}" - exit 1 -fi - -tmp_dir=$(mktemp -d) -trap 'cd /; rm -rf --one-file-system "${tmp_dir}"' EXIT - -for additional_file in "$@"; do - if ! cp "${additional_file}" "${tmp_dir}/"; then - >&2 printf 'Cannot not copy "%s"\n' "${additional_file}" - exit 1 - fi -done -if ! cp "${source}" "${tmp_dir}/"; then - >&2 printf 'Cannot not copy "%s"\n' "${additional_file}" - exit 1 -fi - -cd "${tmp_dir}" -mpost "${source##*/}" || exit $? -find . \ - -type f \ - -name "*.mps" \ - -exec install -m644 -t "${target_dir}/" '{}' + diff --git a/clean-compile-mpost.in b/clean-compile-mpost.in new file mode 100755 index 0000000..d304f92 --- /dev/null +++ b/clean-compile-mpost.in @@ -0,0 +1,45 @@ +#!#SHELL# + +# Version #VERSION# + +# clean-compile-mpost source.mp target-dir/ additional-file1 additional-file2 ... + +if ! source=$(readlink -e "$1"); then + >&2 printf 'Cannot read source "%s"\n' "$1" + exit 1 +fi +shift +if [ $# -eq 0 ]; then + target_dir=$(pwd) +else + if ! target_dir=$(readlink -e "$1"); then + >&2 printf 'Cannot read target-dir "%s"\n' "$1" + exit 1 + fi + shift +fi +if ! [ -d "${target_dir}" ]; then + >&2 printf 'Target-dir "%s" is no directory\n' "${target_dir}" + exit 1 +fi + +tmp_dir=$(mktemp -d) +trap 'cd /; rm -rf --one-file-system "${tmp_dir}"' EXIT + +for additional_file in "$@"; do + if ! cp "${additional_file}" "${tmp_dir}/"; then + >&2 printf 'Cannot not copy "%s"\n' "${additional_file}" + exit 1 + fi +done +if ! cp "${source}" "${tmp_dir}/"; then + >&2 printf 'Cannot not copy "%s"\n' "${additional_file}" + exit 1 +fi + +cd "${tmp_dir}" +mpost "${source##*/}" || exit $? +find . \ + -type f \ + -name "*.mps" \ + -exec install -m644 -t "${target_dir}/" '{}' + -- cgit v1.2.3-54-g00ecf