From: Andre Noll Date: Sun, 17 Feb 2019 11:39:40 +0000 (+0100) Subject: Avoid duplication in version, README, man page. X-Git-Tag: v1.0.1~14 X-Git-Url: http://git.tuebingen.mpg.de/?p=tfortune.git;a=commitdiff_plain;h=6f18187fadd61f42a8e207342b27f17d9b1b9f77;ds=sidebyside Avoid duplication in version, README, man page. 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. --- diff --git a/Makefile b/Makefile index 1764913..aefbe21 100644 --- 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 ~~~~~~~~~~~~~ diff --git a/config.mak.in b/config.mak.in index b42c106..829f420 100644 --- a/config.mak.in +++ b/config.mak.in @@ -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@ diff --git a/configure.ac b/configure.ac index 58925f1..57e7d20 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/index.html.m4 b/index.html.m4 index e1b5f5e..3b77ae7 100644 --- a/index.html.m4 +++ b/index.html.m4 @@ -48,10 +48,8 @@
  • gitweb: GITWEB_URL()
  • -
  • - Email: AUTHOR() <PACKAGE_BUGREPORT()> -
  • +
  • The author's home page
  • +
  • Send feedback to AUTHOR()
  • License

    diff --git a/tfortune.c b/tfortune.c index e11c6da..751334d 100644 --- a/tfortune.c +++ b/tfortune.c @@ -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); } diff --git a/tfortune.suite.m4 b/tfortune.suite.m4 index f3e288d..91d00c3 100644 --- a/tfortune.suite.m4 +++ b/tfortune.suite.m4 @@ -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 + .MT EMAIL() AUTHOR() .ME - .br - Homepage: - .UR PACKAGE_URL() - .UE [/section] [section see also] .BR fortune (6) diff --git a/version-gen.sh b/version-gen.sh index a2c9075..b9d6ca4 100755 --- a/version-gen.sh +++ b/version-gen.sh @@ -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