]> granicus.if.org Git - graphviz/blob - autogen.sh
remove an unnecessary intermediate buffer
[graphviz] / autogen.sh
1 #! /bin/sh
2
3 if ! GRAPHVIZ_VERSION=$( python3 gen_version.py ) ; then
4     echo "Error: Failed to set version" >&2
5     exit 1
6 fi
7 GRAPHVIZ_VERSION_MAJOR=$( python3 gen_version.py --major )
8 GRAPHVIZ_VERSION_MINOR=$( python3 gen_version.py --minor )
9 GRAPHVIZ_VERSION_PATCH=$( python3 gen_version.py --patch )
10
11 if ! GRAPHVIZ_GIT_DATE=$( python3 gen_version.py --committer-date-iso ) ; then
12     echo "Error: Failed to set date" >&2
13     exit 1
14 fi
15 if [ "$GRAPHVIZ_GIT_DATE" = "0" ]; then
16     GRAPHVIZ_VERSION_DATE="0"
17     echo "Warning: build not started in a Git clone, or Git is not installed: setting version date to 0." >&2
18 else
19     GRAPHVIZ_AUTHOR_NAME=$( git log -n 1 --format="%an" )
20     GRAPHVIZ_AUTHOR_EMAIL=$( git log -n 1 --format="%ae" )
21     if ! GRAPHVIZ_VERSION_DATE=$( date -u +%Y%m%d.%H%M -d "$GRAPHVIZ_GIT_DATE" 2>/dev/null ) ; then
22         # try date with FreeBSD syntax
23         if ! GRAPHVIZ_VERSION_DATE=$( date -u -j -f "%Y-%m-%d %H:%M:%S" "$GRAPHVIZ_GIT_DATE" "+%Y%m%d.%H%M" 2>/dev/null); then
24             echo "Warning: we do not know how to invoke date correctly." >&2
25         fi    
26     fi
27     if ! GRAPHVIZ_CHANGE_DATE=$( date -u +"%a %b %e %Y" -d "$GRAPHVIZ_GIT_DATE" 2>/dev/null ) ; then
28         # try date with FreeBSD syntax
29         if ! GRAPHVIZ_CHANGE_DATE=$( date -u -j -f "%Y-%m-%d %H:%M:%S"  "$GRAPHVIZ_GIT_DATE" "+%a %b %e %Y" 2>/dev/null); then
30             echo "Warning: we do not know how to invoke date correctly." >&2
31         fi    
32     fi
33     echo "Graphviz: version date is based on time of last commit: $GRAPHVIZ_VERSION_DATE"
34
35     GRAPHVIZ_VERSION_COMMIT=$( git log -n 1 --format=%h )
36     echo "Graphviz: abbreviated hash of last commit: $GRAPHVIZ_VERSION_COMMIT"
37 fi
38
39 if ! GRAPHVIZ_COLLECTION=$( python3 gen_version.py --collection) ; then
40     echo "Error: Failed to set collection" >&2
41     exit 1
42 fi
43
44 # initialize version for a "development" build
45 cat >./version.m4 <<EOF
46 dnl Graphviz package version number, (as distinct from shared library version)
47
48 m4_define([graphviz_version_major],[$GRAPHVIZ_VERSION_MAJOR])
49 m4_define([graphviz_version_minor],[$GRAPHVIZ_VERSION_MINOR])
50 m4_define([graphviz_version_micro],[$GRAPHVIZ_VERSION_PATCH])
51 m4_define([graphviz_collection],[$GRAPHVIZ_COLLECTION])
52
53 m4_define([graphviz_version_date],[$GRAPHVIZ_VERSION_DATE])
54 m4_define([graphviz_change_date],["$GRAPHVIZ_CHANGE_DATE"])
55 m4_define([graphviz_git_date],["$GRAPHVIZ_GIT_DATE"])
56 m4_define([graphviz_author_name],["$GRAPHVIZ_AUTHOR_NAME"])
57 m4_define([graphviz_author_email],[$GRAPHVIZ_AUTHOR_EMAIL])
58 m4_define([graphviz_version_commit],[$GRAPHVIZ_VERSION_COMMIT])
59
60 EOF
61
62 # config/missing is created by autoreconf,  but apparently not recreated if already there.
63 # This breaks some builds from the graphviz.tar.gz sources.
64 # Arguably this is an autoconf bug.
65 rm -f config/missing
66
67 autoreconf -v --install --force || exit 1
68
69 # ensure config/depcomp exists even if still using automake-1.4
70 # otherwise "make dist" fails.
71 touch config/depcomp