Skip to content

Commit

Permalink
[build] Add git revision to version information
Browse files Browse the repository at this point in the history
- Start to use tags in the Git repository (like "v4.1") for versioning.
  The git revision is embedded into the header line of FORM outputs.
  When it is too long to fit in 79 characters, AC.LineLength is
  temporarily extended. (See also Issue #89)

- "make" in "sources" directory always tries to update "version.h" by
  (1) "version.h.in" in tarball distributions, or
  (2) "scripts/git-version-gen.sh".

- Similar in "doc/manual" and "doc/devref" directories, where
  "version.tex" is the target to be updated. Tarballs have the
  corresponding "version.tex.in".

- Also for the version passed to AC_INIT() in "configure.ac".
  ".version" is stored in tarballs. When bumping the version by tagging,
  you may need to run "autoreconf -if".

- Remove gendate.sh.

- Remove DATE option in "make".

- Revert HTMLCLEANFILES in 9a0f37f; htlatex invalidates .aux, .idx and
  .dvi files, so they need to be deleted.

- "make latex2html" should work in "doc/manual" and "doc/devref".
  Unfortunately, the target "latex2html" is not recursive.

Caveat: The build system doesn't work in tarballs without the configure
  script, e.g., files generated by "git archive" or from "Download ZIP"
  in GitHub. Should we allow builds in such cases?
  • Loading branch information
tueda committed Jun 6, 2016
1 parent e5cd477 commit fdacaeb
Show file tree
Hide file tree
Showing 16 changed files with 620 additions and 404 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ config.status
configure
stamp-h1

sources/version.h
sources/form
sources/tform
sources/parform
Expand Down Expand Up @@ -53,13 +54,13 @@ doc/*/*.tmp
doc/*/*.toc
doc/*/*.xref

doc/devref/devrefdate.tex
doc/devref/version.tex
doc/devref/html/
doc/doxygen/html/
doc/doxygen/latex/
doc/doxygen/pdflatex/
doc/manual/html/
doc/manual/manualdate.tex
doc/manual/version.tex

doc/devref/devref/
doc/manual/manual/
10 changes: 1 addition & 9 deletions INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,6 @@ To cleanup the distribution directory, the command

can be used.

The production date printed by the executable will be set to the time of the
release of the tar-file distribution, or the time of the compilation if you
use the sources acquired from CVS or GIT. If one wants to have another date
printed one can give the DATE option to the make command like

make vorm DATE="11 Nov 2011"


Testing
=======
Expand All @@ -185,8 +178,7 @@ you can choose to run one of the commands

to build all documentation in the specified format. If you want to build only
the manual or the source code documentation, you need to change directory into
"doc/manual" or "doc/doxygen" before you issue the make commands. The DATE
option can be used if necessary.
"doc/manual" or "doc/doxygen" before you issue the make commands.


Installation
Expand Down
17 changes: 16 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
SUBDIRS = doc sources check

EXTRA_DIST = README.md scripts/gendate.sh
EXTRA_DIST = README.md

dist-hook:
$(DISTHOOK_VERSION)

if FIXED_VERSION

DISTHOOK_VERSION = \
cp "$(srcdir)/.version" "$(distdir)/.version"

else

DISTHOOK_VERSION = \
$(SHELL) "$(top_srcdir)/scripts/git-version-gen.sh" -C "$(srcdir)" -v -o "$(distdir)/.version"

endif
62 changes: 32 additions & 30 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -1,42 +1,39 @@
m4_define([FORM_MAJORVERSION], [4])
m4_define([FORM_MINORVERSION], [1])
m4_define([FORM_VERSION], [FORM_MAJORVERSION.FORM_MINORVERSION])
# set to 'yes' for beta verstions
m4_define([VERSION_IS_BETA], [no])
# m4_esyscmd_s implementation for autoconf < 2.64.
# (Taken from m4sugar.m4 in autoconf 2.69.)
m4_ifndef([m4_esyscmd_s], [m4_define([m4_esyscmd_s],
[m4_chomp_all(m4_esyscmd([$1]))])])
m4_ifndef([m4_chomp_all], [m4_define([m4_chomp_all],
[m4_format([[%.*s]], m4_bregexp(m4_translit([[$1]], [
/], [/ ]), [/*$]), [$1])])])

# Get the version from
# (1) .version file available in a tarball, or
# (2) the latest tag in the repository.
m4_define([FORM_VERSION], m4_esyscmd_s([
if test -f .version; then
cat .version
else
scripts/git-version-gen.sh -C . -v
fi
]))

########################################
# Use the serial-tests option of AM_INIT_AUTOMAKE if automake >= 1.13.
# Assume the automake command is ${AUTOMAKE:-automake} as autoreconf does.
# It may not work if "make" re-runs a different version of automake.
m4_define([serial_tests], [m4_esyscmd_s([
${AUTOMAKE:-automake} --version | head -1 |
awk '{split ($NF,a,"."); if (a[1] >= 2 || (a[1] == 1 && a[2] >= 13)) { print "serial-tests" }}'
])])

AC_PREREQ(2.59)
AC_INIT([FORM], FORM_VERSION, [form@nikhef.nl])
AC_CONFIG_SRCDIR([sources/form3.h])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_AUX_DIR([build-aux])

dnl Use the serial-tests option if automake >= 1.13.
dnl Assume the automake command is ${AUTOMAKE:-automake} as autoreconf does.
dnl It may not work if "make" re-runs a different version of automake.
m4_define([serial_tests], [m4_esyscmd([
${AUTOMAKE:-automake} --version | head -1 |
awk '{split ($NF,a,"."); if (a[1] >= 2 || (a[1] == 1 && a[2] >= 13)) { print "serial-tests" }}'
])])
AM_INIT_AUTOMAKE([1.7 foreign -Wall dist-bzip2] serial_tests)

AC_DEFINE(MAJORVERSION, FORM_MAJORVERSION, [Major version of FORM.])
AC_DEFINE(MINORVERSION, FORM_MINORVERSION, [Minor version of FORM.])
AS_IF([test "x[]VERSION_IS_BETA" = xyes],
[AC_DEFINE(BETAVERSION, 1, [Define to 1 in the beta version.])])

AH_VERBATIM([PRODUCTIONDATE],
[/* Set production date. */
#ifndef PRODUCTIONDATE
#ifdef HAVE_PRODUCTIONDATE_H
#include "production-date.h"
#else
#define PRODUCTIONDATE __DATE__
#endif
#endif])
AS_IF([test -f $srcdir/sources/production-date.h],
[AC_DEFINE(HAVE_PRODUCTIONDATE_H, , [Define to include production-date.h.])])
# Check for .version file
AM_CONDITIONAL([FIXED_VERSION], [test -f $srcdir/.version])

# Check for automake >= 1.10
flag=false
Expand All @@ -57,6 +54,7 @@ AM_PROG_CC_C_O
AC_PROG_CXX([g++ c++ icpc])
CFLAGS=$cflagsbackup
CXXFLAGS=$cxxflagsbackup
AC_PROG_LN_S

# Checks for header files
AC_HEADER_STDC
Expand Down Expand Up @@ -628,11 +626,13 @@ AC_PATH_PROG(PDFLATEX, pdflatex, "")
AC_PATH_PROG(DVIPS, dvips, "")
AC_PATH_PROG(MAKEINDEX, makeindex, "")
AC_PATH_PROG(HTLATEX, htlatex, "")
AC_PATH_PROG(LATEX2HTML, latex2html, "")
AM_CONDITIONAL(CONFIG_TEX, [test ! -z "$LATEX"])
AM_CONDITIONAL(CONFIG_PS, [test ! \( -z "$LATEX" -o -z "$DVIPS" \)])
AM_CONDITIONAL(CONFIG_PDF, [test ! -z "$PDFLATEX"])
AM_CONDITIONAL(CONFIG_MAKEINDEX, [test ! -z "$MAKEINDEX"])
AM_CONDITIONAL(CONFIG_HTLATEX, [test ! -z "$HTLATEX"])
AM_CONDITIONAL(CONFIG_LATEX2HTML, [test ! -z "$LATEX2HTML"])

# Check for Ruby >= 1.8 and test/unit.
AC_PATH_PROG(RUBY, ruby, "")
Expand Down Expand Up @@ -677,6 +677,8 @@ echo "##################### CONFIGURATION #####################"
echo
outputdir=$(eval "echo $bindir")
outputdir=$(eval "echo $outputdir")
echo "FORM $VERSION"
echo
echo "Compiling for: $print_cpu $print_os ($print_data_model $print_api)"
echo
echo "Optionally linked libraries:"
Expand Down
137 changes: 94 additions & 43 deletions doc/devref/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
TEXFILES = \
TEXSRC = \
cvs.tex \
devref.tex \
formrun.tex \
Expand All @@ -8,55 +8,101 @@ TEXFILES = \

MAIN = devref

EXTRA_DIST = $(TEXFILES) .latex2html-init
TEXFILES = $(TEXSRC) $(MAIN).tex version.tex

.PHONY: FORCE dvi html ps pdf clean-local
EXTRA_DIST = $(TEXSRC) .latex2html-init

DATEFILE = devrefdate.tex
$(DATEFILE): FORCE
$(SHELL) $(top_srcdir)/scripts/gendate.sh -t -r $(srcdir) -i $(srcdir)/$(DATEFILE).in -o $(DATEFILE) "$(DATE)"
FORCE:
.PHONY: dvi latex2html html ps pdf clean-local update_version_tex

dist-hook:
$(SHELL) $(top_srcdir)/scripts/gendate.sh -t -r $(srcdir) -i $(srcdir)/$(DATEFILE).in -o $(distdir)/$(DATEFILE).in "$(DATE)"
# NOTE: htlatex invalidate .aux, .idx, .dvi files.
HTMLCLEANFILES = idxmake.dvi idxmake.log $(MAIN).4ct $(MAIN).4dx $(MAIN).4ix \
$(MAIN).4tc $(MAIN).aux $(MAIN).css $(MAIN).dvi $(MAIN).html $(MAIN)2.html \
$(MAIN).idv $(MAIN).idx $(MAIN).ilg $(MAIN).ind $(MAIN).lg $(MAIN).log \
$(MAIN).tmp $(MAIN).xref

CLEANFILES = \
$(MAIN).4ct $(MAIN).4dx $(MAIN).4ix $(MAIN).4tc $(MAIN).aux $(MAIN).css $(MAIN).dvi \
$(MAIN).html $(MAIN)2.html $(MAIN).idv $(MAIN).idx $(MAIN).ilg $(MAIN).ind $(MAIN).lg \
$(MAIN).log $(MAIN).out $(MAIN).pdf $(MAIN).ps $(MAIN).tmp $(MAIN).toc $(MAIN).xref \
idxmake.dvi idxmake.log texput.log $(DATEFILE)
CLEANFILES = $(MAIN).pdf $(MAIN).ps $(MAIN).toc $(DATEFILE) texput.log \
version.tex $(HTMLCLEANFILES)

clean-local:
rm -rf html
rm -rf html $(MAIN)

latex2html: $(MAIN).dvi
latex2html -init_file $(srcdir)/.latex2html-init $(MAIN).tex
cat $(MAIN)/index.html | sed 's/$(MAIN).html#/#/g' >$(MAIN)/index.html.tmp
mv $(MAIN)/index.html.tmp $(MAIN)/index.html
cat $(MAIN)/$(MAIN).html | sed 's/$(MAIN).html#/#/g' >$(MAIN)/$(MAIN).html.tmp
mv $(MAIN)/$(MAIN).html.tmp $(MAIN)/$(MAIN).html
# Automatic versioning.

version.tex: update_version_tex
$(UPDATE_VERSION_TEX)

dist-hook:
$(DISTHOOK_VERSION_TEX)

if FIXED_VERSION

UPDATE_VERSION_TEX = \
[ -f version.tex ] || $(LN_S) "$(srcdir)/version.tex.in" version.tex

DISTHOOK_VERSION_H = \
cp "$(srcdir)/version.tex.in" "$(distdir)/version.tex.in"

else

UPDATE_VERSION_TEX = \
$(SHELL) "$(top_srcdir)/scripts/git-version-gen.sh" -C "$(srcdir)" -t -o version.tex --date-format '%e %B %Y'

DISTHOOK_VERSION_TEX = \
$(SHELL) "$(top_srcdir)/scripts/git-version-gen.sh" -C "$(srcdir)" -t -o "$(distdir)/version.tex.in" --date-format '%e %B %Y'

endif

#################### CONFIG_TEX
if CONFIG_TEX

dvi: $(DATEFILE) $(MAIN).dvi
dvi: $(MAIN).dvi

$(MAIN).dvi: $(DATEFILE) $(TEXFILES)
@set -e ;\
${LATEX} $(MAIN).tex; \
${LATEX} $(MAIN).tex
if CONFIG_MAKEINDEX
$(MAIN).dvi: $(TEXFILES)
$(LATEX) $(MAIN).tex; while [ `grep -v 'Package: rerunfilecheck' $(MAIN).log | grep -c Rerun` -gt 0 ]; do $(LATEX) $(MAIN).tex; done
$(MAKEINDEX) $(MAIN)
$(LATEX) $(MAIN).tex; while [ `grep -v 'Package: rerunfilecheck' $(MAIN).log | grep -c Rerun` -gt 0 ]; do $(LATEX) $(MAIN).tex; done
else
$(MAIN).dvi: $(TEXFILES)
$(LATEX) $(MAIN).tex; while [ `grep -v 'Package: rerunfilecheck' $(MAIN).log | grep -c Rerun` -gt 0 ]; do $(LATEX) $(MAIN).tex; done
endif

########## CONFIG_HTLATEX
if CONFIG_HTLATEX
########## CONFIG_LATEX2HTML
if CONFIG_LATEX2HTML

latex2html: $(MAIN)/$(MAIN).html

$(MAIN)/$(MAIN).html: $(MAIN).dvi
$(LATEX2HTML) -init_file $(srcdir)/.latex2html-init $(MAIN).tex
cat $(MAIN)/index.html | sed 's/$(MAIN).html#/#/g' >$(MAIN)/index.html.tmp
mv $(MAIN)/index.html.tmp $(MAIN)/index.html
cat $(MAIN)/$(MAIN).html | sed 's/$(MAIN).html#/#/g' >$(MAIN)/$(MAIN).html.tmp
mv $(MAIN)/$(MAIN).html.tmp $(MAIN)/$(MAIN).html

$(MAIN).aux: $(DATEFILE) $(MAIN).dvi
endif
########## CONFIG_LATEX2HTML

html: $(DATEFILE) html/$(MAIN).html
########## CONFIG_HTLATEX
if CONFIG_HTLATEX

html/$(MAIN).html: $(DATEFILE) $(MAIN).aux
@set -e ;\
mkdir -p html; \
${HTLATEX} $(MAIN) "html,mathml-" "" "-dhtml/"
html: html/$(MAIN).html

if CONFIG_MAKEINDEX
html/$(MAIN).html: $(TEXFILES)
mkdir -p html
$(HTLATEX) $(MAIN) "html,mathml-" "" "-dhtml/"
$(TEX) '\def\filename{{$(MAIN)}{idx}{4dx}{ind}} \input idxmake.4ht'
$(MAKEINDEX) -o $(MAIN).ind $(MAIN).4dx
$(HTLATEX) $(MAIN) "html,mathml-" "" "-dhtml/"
sed 's/table.tabular {margin-left: auto; margin-right: auto;}/table.tabular {margin-left: inherit;}/' html/$(MAIN).css >html/$(MAIN).css.tmp
mv html/$(MAIN).css.tmp html/$(MAIN).css
rm -f $(HTMLCLEANFILES)
else
html/$(MAIN).html: $(DATEFILE)
mkdir -p html
$(HTLATEX) $(MAIN) "html,mathml-" "" "-dhtml/"
rm -f $(HTMLCLEANFILES)
endif

endif
########## CONFIG_HTLATEX
Expand All @@ -67,20 +113,25 @@ if CONFIG_PS
ps: $(DATEFILE) $(MAIN).ps

$(MAIN).ps: $(DATEFILE) $(MAIN).dvi
${DVIPS} -o $(MAIN).ps $(MAIN).dvi
$(DVIPS) -o $(MAIN).ps $(MAIN).dvi

endif
########## CONFIG_PS

########## CONFIG_PDF
if CONFIG_PS

pdf: $(DATEFILE) $(MAIN).pdf

$(MAIN).pdf: $(DATEFILE) $(TEXFILES)
@set -e ;\
${PDFLATEX} $(MAIN).tex; \
${PDFLATEX} $(MAIN).tex
if CONFIG_PDF

pdf: $(MAIN).pdf

if CONFIG_MAKEINDEX
$(MAIN).pdf: $(TEXFILES)
$(PDFLATEX) $(MAIN).tex; while [ `grep -v 'Package: rerunfilecheck' $(MAIN).log | grep -c Rerun` -gt 0 ]; do $(PDFLATEX) $(MAIN).tex; done
$(MAKEINDEX) $(MAIN)
$(PDFLATEX) $(MAIN).tex; while [ `grep -v 'Package: rerunfilecheck' $(MAIN).log | grep -c Rerun` -gt 0 ]; do $(PDFLATEX) $(MAIN).tex; done
else
$(MAIN).pdf: $(TEXFILES)
$(PDFLATEX) $(MAIN).tex; while [ `grep -v 'Package: rerunfilecheck' $(MAIN).log | grep -c Rerun` -gt 0 ]; do $(PDFLATEX) $(MAIN).tex; done
endif

endif
########## CONFIG_PDF
Expand Down
6 changes: 5 additions & 1 deletion doc/devref/devref.tex.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
\input{version.tex}
\def\formdate{\repodate}


\documentclass[11pt,titlepage]{article}
\usepackage{makeidx}

Expand Down Expand Up @@ -38,7 +42,7 @@

\thispagestyle{empty}
\title{\Huge FORM \\ \Large version @VERSION@ \\ \huge Developer's reference manual}
\date{\input{devrefdate}}
\date{\formdate}
\author{J.A.M.Vermaseren et al.}
\maketitle

Expand Down
Loading

0 comments on commit fdacaeb

Please sign in to comment.