Even friendlier advice to the novice git SXEmacs
[sxemacs] / autogen.sh
1 #!/bin/sh
2
3 # BSD's m4 probably isn't gonna cut it, use gm4 if it is available
4 type gm4 >/dev/null 2>&1 && M4=gm4 || M4=m4
5
6 M4_VERSION=$($M4 --version | head -1 | sed -e 's/^\(m4 \)\?(\?GNU M4)\? *//g' ) 
7 GOOD_M4=$( echo $M4_VERSION | awk -F. '{if( ($1>1) || ( ($1==1) && ($2>4) ) || ( ($1==1) && ($2==4) && ($3>=6) )) print 1 }')
8
9 if [ "$GOOD_M4" != "1" ]; then
10     echo You have m4 version $M4_VERSION.  SXEmacs requires m4 version 1.4.6 or later.
11     exit 1
12 fi
13
14 # To cater for Solaris
15 if test -d "/usr/xpg4/bin"; then
16     PATH=/usr/xpg4/bin:$PATH
17     export PATH
18 fi
19
20 type git >/dev/null 2>&1 && GIT=git
21 olddir=$(pwd)
22 srcdir=$(dirname $0)
23 cd "$srcdir"
24
25 EXPECTED_TREE_VERSION="22.1.14"
26
27 emacs_is_beta=t
28 if test -n "$GIT" -a -n "$($GIT symbolic-ref HEAD 2>/dev/null)"; then
29         TREE_VERSION="$($GIT tag|tail -n1|tr -d v)"
30         GIT_VERSION="$($GIT describe)"
31         IN_GIT="1"
32 fi
33 if test -z "$TREE_VERSION"; then
34         TREE_VERSION="$EXPECTED_TREE_VERSION"
35         if test -n "$IN_GIT"; then
36             echo "If you cloned this branch into your own you should issue:"
37             echo "\tgit tag -s v${TREE_VERSION}.<your branch_name>"
38             echo "\tgit push --tag"
39         fi
40 fi
41 if test -z "$GIT_VERSION"; then
42         GIT_VERSION="${TREE_VERSION}-no_git_version"
43 fi
44
45 emacs_major_version="$(echo $TREE_VERSION|cut -d. -f1)"
46 emacs_minor_version="$(echo $TREE_VERSION|cut -d. -f2)"
47 emacs_beta_version="$(echo $TREE_VERSION|cut -d. -f3)"
48 emacs_full_version="$emacs_major_version.$emacs_minor_version.$emacs_beta_version"
49 sxemacs_codename="Geo"
50 sxemacs_git_version="$GIT_VERSION"
51
52 if test "$emacs_full_version" != "$EXPECTED_TREE_VERSION"; then
53     # Note, there is no need check for git repos, because
54     # it can only happen in such a case anyway...
55     echo "*******************************************"
56     echo " WARNING: Your git tags may be out of date "
57     echo ""
58     echo " Expected tree version $EXPECTED_TREE_VERSION "
59     echo " got $emacs_full_version (from $TREE_VERSION) "
60     set -x
61     git tag
62     git describe
63     git describe --long
64     git config -l
65     set +x
66     echo "*******************************************" 
67 fi
68
69 autoconf_ver=$(autoconf --version 2>/dev/null | head -n1)
70 autoheader_ver=$(autoheader --version 2>/dev/null | head -n1)
71 automake_ver=$(automake --version 2>/dev/null | head -n1)
72 aclocal_ver=$(aclocal --version 2>/dev/null | head -n1)
73 libtool_ver=$(libtool --version 2>/dev/null | head -n1)
74
75
76 # When things go wrong... get a bigger hammer!
77 if test -n "$PHAMMER"; then
78     HAMMER=$PHAMMER
79 fi
80
81 if test -n "$HAMMER"; then
82         if test -n "$GIT" -a -n "$($GIT symbolic-ref HEAD 2>/dev/null)"; then
83                 $GIT clean -fxd
84         else
85                 echo "ERROR: Not a git workspace, or you don't have git" >&2
86                 exit 1
87         fi
88         unset HAMMER
89 fi
90
91
92 cat>sxemacs_version.m4<<EOF
93 dnl autogenerated version number
94 m4_define([SXEM4CS_VERSION], [$emacs_full_version])
95 m4_define([SXEM4CS_MAJOR_VERSION], [$emacs_major_version])
96 m4_define([SXEM4CS_MINOR_VERSION], [$emacs_minor_version])
97 m4_define([SXEM4CS_BETA_VERSION], [$emacs_beta_version])
98 m4_define([SXEM4CS_BETA_P], [$emacs_is_beta])
99 m4_define([SXEM4CS_GIT_VERSION], [$sxemacs_git_version])
100 m4_define([SXEM4CS_CODENAME], [$sxemacs_codename])
101 m4_define([4UTOCONF_VERSION], [$autoconf_ver])
102 m4_define([4UTOHEADER_VERSION], [$autoheader_ver])
103 m4_define([4CLOCAL_VERSION], [$aclocal_ver])
104 m4_define([4UTOMAKE_VERSION], [$automake_ver])
105 m4_define([4IBTOOL_VERSION], [$libtool_ver])
106 EOF
107
108 if test -z "$FORCE"; then
109     FORCE=
110 else
111     rm -rf autom4te.cache aclocal.m4
112     FORCE=--force
113 fi
114
115 if type glibtoolize 2>/dev/null; then
116     LIBTOOLIZE=glibtoolize
117 else
118     LIBTOOLIZE=libtoolize
119 fi
120
121 autoreconf $FORCE --verbose --install -Wall
122
123 # hack-o-matic.  Using gmp's config.{guess,sub} lets us have properer
124 # detected machine configurations --SY.
125 guess=$(grep GMP config.guess)
126 sub=$(grep GMP config.sub)
127 if test -z "${guess}"; then
128     mv -vf config.guess configfsf.guess
129     cp -v configgmp.guess config.guess
130 fi
131 if test -z "${sub}"; then
132     mv -vf config.sub configfsf.sub
133     cp -v configgmp.sub config.sub
134 fi
135
136 cd $olddir