Build improvements
[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 emacs_is_beta=t
26 if test -n "$GIT" -a -n "$($GIT symbolic-ref HEAD 2>/dev/null)"; then
27         TREE_VERSION="$($GIT tag|tail -n1|tr -d v)"
28         GIT_VERSION="$($GIT describe)"
29         IN_GIT="1"
30 fi
31 if test -z "$TREE_VERSION"; then
32         TREE_VERSION="22.1.14"
33         if test -n "$IN_GIT"; then
34             echo "If you cloned this branch into your own you should issue: git tag -s v${TREE_VERSION}.<your branch_name>"
35         fi
36 fi
37 if test -z "$GIT_VERSION"; then
38         GIT_VERSION="${TREE_VERSION}-no_git_version"
39 fi
40
41 emacs_major_version="$(echo $TREE_VERSION|cut -d. -f1)"
42 emacs_minor_version="$(echo $TREE_VERSION|cut -d. -f2)"
43 emacs_beta_version="$(echo $TREE_VERSION|cut -d. -f3)"
44 sxemacs_codename="Geo"
45 sxemacs_git_version="$GIT_VERSION"
46
47 autoconf_ver=$(autoconf --version 2>/dev/null | head -n1)
48 autoheader_ver=$(autoheader --version 2>/dev/null | head -n1)
49 automake_ver=$(automake --version 2>/dev/null | head -n1)
50 aclocal_ver=$(aclocal --version 2>/dev/null | head -n1)
51 libtool_ver=$(libtool --version 2>/dev/null | head -n1)
52
53
54 # When things go wrong... get a bigger hammer!
55 if test -n "$PHAMMER"; then
56     HAMMER=$PHAMMER
57 fi
58
59 if test -n "$HAMMER"; then
60         if test -n "$GIT" -a -n "$($GIT symbolic-ref HEAD 2>/dev/null)"; then
61                 $GIT clean -fxd
62         else
63                 echo "ERROR: Not a git workspace, or you don't have git" >&2
64                 exit 1
65         fi
66         unset HAMMER
67 fi
68
69
70 cat>sxemacs_version.m4<<EOF
71 dnl autogenerated version number
72 m4_define([SXEM4CS_VERSION], [$emacs_major_version.$emacs_minor_version.$emacs_beta_version])
73 m4_define([SXEM4CS_MAJOR_VERSION], [$emacs_major_version])
74 m4_define([SXEM4CS_MINOR_VERSION], [$emacs_minor_version])
75 m4_define([SXEM4CS_BETA_VERSION], [$emacs_beta_version])
76 m4_define([SXEM4CS_BETA_P], [$emacs_is_beta])
77 m4_define([SXEM4CS_GIT_VERSION], [$sxemacs_git_version])
78 m4_define([SXEM4CS_CODENAME], [$sxemacs_codename])
79 m4_define([4UTOCONF_VERSION], [$autoconf_ver])
80 m4_define([4UTOHEADER_VERSION], [$autoheader_ver])
81 m4_define([4CLOCAL_VERSION], [$aclocal_ver])
82 m4_define([4UTOMAKE_VERSION], [$automake_ver])
83 m4_define([4IBTOOL_VERSION], [$libtool_ver])
84 EOF
85
86 if test -z "$FORCE"; then
87     FORCE=
88 else
89     rm -rf autom4te.cache aclocal.m4
90     FORCE=--force
91 fi
92
93 if type glibtoolize 2>/dev/null; then
94     LIBTOOLIZE=glibtoolize
95 else
96     LIBTOOLIZE=libtoolize
97 fi
98
99 autoreconf $FORCE --verbose --install -Wall
100
101 # hack-o-matic.  Using gmp's config.{guess,sub} lets us have properer
102 # detected machine configurations --SY.
103 guess=$(grep GMP config.guess)
104 sub=$(grep GMP config.sub)
105 if test -z "${guess}"; then
106     mv -vf config.guess configfsf.guess
107     cp -v configgmp.guess config.guess
108 fi
109 if test -z "${sub}"; then
110     mv -vf config.sub configfsf.sub
111     cp -v configgmp.sub config.sub
112 fi
113
114 cd $olddir