SAY = @echo '$(strip $(1))'
endif
+PACKAGE := tfortune
+SLOGAN := fortune cookies with tags
AUTHOR := Andre Noll
+EMAIL := maan@tuebingen.mpg.de
COPYRIGHT_YEAR := 2019
-CLONE_URL := git://git.tuebingen.mpg.de/tfortune
-GITWEB_URL := http://git.tuebingen.mpg.de/tfortune.git
+PACKAGE_HOMEPAGE := http://people.tuebingen.mpg.de/maan/$(PACKAGE)/
+CLONE_URL := git://git.tuebingen.mpg.de/$(PACKAGE)/
+GITWEB_URL := http://git.tuebingen.mpg.de/$(PACKAGE).git
LICENSE := GNU GPL version 3
LICENSE_URL := https://www.gnu.org/licenses/gpl-3.0-standalone.html
+HOME_URL := http://people.tuebingen.mpg.de/maan/
define DESCRIPTION1 :=
Like fortune(1), tfortune is a Unix command line utility which prints
that enables bash command line completion is also included.
endef
LOGLEVELS := LL_DEBUG,LL_INFO,LL_NOTICE,LL_WARNING,LL_ERROR,LL_CRIT,LL_EMERG
-GIT_VERSION := $(shell ./version-gen.sh)
+GIT_VERSION := $(shell ./version-gen.sh $(PACKAGE) version.c)
cc_version := $(shell $(CC) --version | head -n 1)
build_date := $(shell date)
uname_rs := $(shell uname -rs)
index.html tfortune.suite: %: %.m4
$(call SAY, M4 $<)
$(M4) -D "AUTHOR=$(AUTHOR)" -D "COPYRIGHT_YEAR=$(COPYRIGHT_YEAR)" \
- -D "PACKAGE_BUGREPORT=$(PACKAGE_BUGREPORT)" \
+ -D "PACKAGE=$(PACKAGE)" \
+ -D "SLOGAN=$(SLOGAN)" \
+ -D "EMAIL=$(EMAIL)" \
-D "PACKAGE_URL=$(PACKAGE_URL)" \
+ -D "PACKAGE_HOMEPAGE=$(PACKAGE_HOMEPAGE)" \
-D "CLONE_URL=$(CLONE_URL)" \
-D "GITWEB_URL=$(GITWEB_URL)" \
+ -D "HOME_URL=$(HOME_URL)" \
-D "LICENSE=$(LICENSE)" \
-D "LICENSE_URL=$(LICENSE_URL)" \
-D "DESCRIPTION1=$(DESCRIPTION1)" \
TF_CPPFLAGS += -Wunused-macros
TF_CPPFLAGS += -DCOPYRIGHT_YEAR='"$(COPYRIGHT_YEAR)"'
+TF_CPPFLAGS += -DPACKAGE='"$(PACKAGE)"'
TF_CPPFLAGS += -DAUTHOR='"$(AUTHOR)"'
+TF_CPPFLAGS += -DEMAIL='"$(EMAIL)"'
+TF_CPPFLAGS += -DPACKAGE_HOMEPAGE='"$(PACKAGE_HOMEPAGE)"'
+TF_CPPFLAGS += -DCLONE_URL='"$(CLONE_URL)"'
+TF_CPPFLAGS += -DGITWEB_URL='"$(GITWEB_URL)"'
+TF_CPPFLAGS += -DHOME_URL='"$(HOME_URL)"'
+TF_CPPFLAGS += -DGET_VERSION='$(PACKAGE)_version'
TF_CPPFLAGS += -DLOGLEVELS='$(LOGLEVELS)'
TF_CPPFLAGS += -DBUILD_DATE='"$(build_date)"'
TF_CPPFLAGS += -DCC_VERSION='"$(cc_version)"'
$(INSTALL_DATA) tfortune.1 $(DESTDIR)$(mandir)
define README :=
-tfortune - fortune cookies with tags
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+tfortune - $(SLOGAN)
+
$(DESCRIPTION1)
$(DESCRIPTION2)
Resources
~~~~~~~~~
+| web page: $(PACKAGE_HOMEPAGE)
| git clone URL: $(CLONE_URL)
-| web page: $(PACKAGE_URL)
-| email: $(AUTHOR) <$(PACKAGE_BUGREPORT)>
+| gitweb: $(GITWEB_URL)
+| author's home page: $(HOME_URL)
+| Send feedback to: $(AUTHOR) <$(EMAIL)>
Documentation
~~~~~~~~~~~~~
}
EXPORT_CMD_HANDLER(help);
+const char *GET_VERSION(void);
static void handle_help_and_version(void)
{
int i;
const struct lls_command *cmd;
if (OPT_GIVEN(TFORTUNE, VERSION)) {
- printf("tfortune %s\n"
+ printf(PACKAGE " %s\n"
"Copyright (C) " COPYRIGHT_YEAR " " AUTHOR ".\n"
- "License " LICENSE ": <" LICENSE_URL ">.\n"
+ "License: " LICENSE ": <" LICENSE_URL ">.\n"
"This is free software: you are free to change and redistribute it.\n"
"There is NO WARRANTY, to the extent permitted by law.\n"
- "Report bugs to " AUTHOR " <" PACKAGE_BUGREPORT ">.\n"
+ "\n"
+ "Web page: " PACKAGE_HOMEPAGE "\n"
+ "Clone URL: " CLONE_URL "\n"
+ "Gitweb: " GITWEB_URL "\n"
+ "Author's Home Page: " HOME_URL "\n"
+ "Send feedback to: " AUTHOR " <" EMAIL ">\n"
,
- tf_version()
+ GET_VERSION()
);
exit(EXIT_SUCCESS);
}
# SPDX-License-Identifier: GPL-3.0-only
-version_file='version.c'
+package="$1"
+version_file="$2"
+
ver='unnamed_version'
# First try git, then gitweb, then default.
if [ -e '.git' -o -e '../.git' ]; then
# if there are differences (exit code 1), the working tree is dirty
git diff-index --quiet HEAD || git_ver=$git_ver-dirty
ver=$git_ver
-elif [ "${PWD%%-*}" = 'tfortune-' ]; then
- ver=${PWD##*/tfortune-}
+elif [ "${PWD%%-*}" = $package- ]; then
+ ver=${PWD##*/$package-}
fi
ver=${ver#v}
echo "$ver"
-
+[ -z "${version_file}" ] && exit 0
# update version file if necessary
-content="const char *tf_version(void) {return \"$ver\";};"
+content="const char *${package}_version(void) {return \"$ver\";};"
[ -r "$version_file" ] && echo "$content" | cmp -s - $version_file && exit 0
-echo >&2 "new git version: $ver"
echo "$content" > $version_file