]> git.tue.mpg.de Git - tfortune.git/commitdiff
Avoid duplication in version, README, man page.
authorAndre Noll <maan@tuebingen.mpg.de>
Sun, 17 Feb 2019 11:39:40 +0000 (12:39 +0100)
committerAndre Noll <maan@tuebingen.mpg.de>
Wed, 13 Mar 2019 08:24:19 +0000 (09:24 +0100)
URLs and the email address are currently spread out over multiple
files.  This commit cleans up the mess by defining everything in
Makefile and adjusting other places to use the information from there.
We use the opportunity to add a link to the author's home page.

version-gen.sh is made generic, i.e., it does not refer to tfortune
any more.

Makefile
config.mak.in
configure.ac
index.html.m4
tfortune.c
tfortune.suite.m4
version-gen.sh

index 1764913c90ec5dce62269fbf63f5295f129c2ff7..aefbe2113aff8fe195acdf07e91b4bbfd96fdac2 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -18,12 +18,17 @@ else
        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
@@ -47,7 +52,7 @@ define DESCRIPTION3 :=
        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)
@@ -90,10 +95,14 @@ version.c:
 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)" \
@@ -122,7 +131,14 @@ index.html tfortune.suite: %: %.m4
 
 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)"'
@@ -187,8 +203,8 @@ install install-strip: all
        $(INSTALL_DATA) tfortune.1 $(DESTDIR)$(mandir)
 
 define README :=
-tfortune - fortune cookies with tags
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+tfortune - $(SLOGAN)
+
 $(DESCRIPTION1)
 
 $(DESCRIPTION2)
@@ -197,9 +213,11 @@ $(DESCRIPTION3)
 
 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
 ~~~~~~~~~~~~~
index b42c106a02261f8e14245a00d72b2a06d8540f7b..829f4203e48463dbef25a1c4bebf4f128f51c96a 100644 (file)
@@ -7,11 +7,6 @@ exec_prefix := @exec_prefix@
 bindir := @bindir@
 datarootdir := @datarootdir@
 
-PACKAGE_TARNAME := @PACKAGE_TARNAME@
-PACKAGE_VERSION := @PACKAGE_VERSION@
-PACKAGE_BUGREPORT := @PACKAGE_BUGREPORT@
-PACKAGE_URL := @PACKAGE_URL@
-
 FLEX := @FLEX@
 BISON := @BISON@
 M4 := @M4@
index 58925f1c1bb5cb4bc926d8473418aec43eb61212..57e7d200f35c9bdb9bc64ed9e38a210c7a6b4618 100644 (file)
@@ -1,8 +1,8 @@
 # SPDX-License-Identifier: GPL-3.0-only
 
 AC_PREREQ([2.61])
-AC_INIT([tfortune], [m4_esyscmd_s(./version-gen.sh)],
-       [maan@tuebingen.mpg.de], [], [http://people.tuebingen.mpg.de/maan/tfortune/])
+# only for configure -h, see Makefile
+AC_INIT([software], [packages])
 AC_CONFIG_HEADERS([config.h])
 AC_CONFIG_FILES([config.mak])
 AC_USE_SYSTEM_EXTENSIONS
index e1b5f5ed1b8bf60dba9765b5e31f6d2c3b3763a2..3b77ae729aea01cd3b29638a152eaea8dd8b4b72 100644 (file)
                        <li>
                                gitweb: <a href="GITWEB_URL()">GITWEB_URL()</a>
                        </li>
-                       <li>
-                               Email: AUTHOR() &lt;<a
-                               href="mailto:PACKAGE_BUGREPORT()">PACKAGE_BUGREPORT()</a>&gt;
-                       </li>
+                       <li> The author's <a href="HOME_URL()">home page</a> </li>
+                       <li> Send feedback to <a href="mailto:EMAIL()">AUTHOR()</a> </li>
                </ul>
 
                <h2> License </h2>
index e11c6da7556e7f2b613b1be7829bc3914b8d62a6..751334dd2b91d2f49f077a3aa0b1383db3a32bae 100644 (file)
@@ -969,6 +969,7 @@ static int com_help(void)
 }
 EXPORT_CMD_HANDLER(help);
 
+const char *GET_VERSION(void);
 static void handle_help_and_version(void)
 {
        int i;
@@ -976,14 +977,19 @@ static void handle_help_and_version(void)
        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);
        }
index f3e288dbf141841d22c2e3fb1dc40c847b06dc5a..91d00c30a34f01b79c89c5ebf58fa91ec80c094d 100644 (file)
@@ -3,7 +3,7 @@
 [suite tfortune]
 caption = Subcommands
 [supercommand tfortune]
-       purpose = fortune cookies with tags
+       purpose = SLOGAN()
        [description]
                DESCRIPTION1()
 
@@ -403,15 +403,27 @@ caption = Subcommands
        This is free software: you are free to change and redistribute it.
        .br
        There is NO WARRANTY, to the extent permitted by law.
+       .P
+       Web page:
+       .UR PACKAGE_HOMEPAGE()
+       .UE
+       .br
+       Git clone URL:
+       .UR CLONE_URL()
+       .UE
+       .br
+       Gitweb:
+       .UR GITWEB_URL()
+       .UE
+       .br
+       Author's home page:
+       .UR HOME_URL()
+       .UE
        .br
        Report bugs to
-       .MT <PACKAGE_BUGREPORT()>
+       .MT EMAIL()
        AUTHOR()
        .ME
-       .br
-       Homepage:
-       .UR PACKAGE_URL()
-       .UE
 [/section]
 [section see also]
        .BR fortune (6)
index a2c90757ff894e7712a4377fc29e2c5b8962e85d..b9d6ca415baa2949c83c30bbc934c8529170782a 100755 (executable)
@@ -2,7 +2,9 @@
 
 # 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
@@ -13,15 +15,14 @@ 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