Fix build on OpenIndiana
[sxemacs] / autogen.sh
1 #!/bin/sh
2 # Configure script bootstrap for SXEmacs
3 #
4 # Copyright (C) 2005, 2006, 2007 Steve Youngs.
5 # Copyright (C) 2006, 2007, 2008 Sebastian Freundt.
6 # Copyright (C) 2007, 2010, 2011 Nelson Ferreira
7
8 # This file is part of SXEmacs.
9
10 # SXEmacs is free software: you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation, either version 3 of the License, or
13 # (at your option) any later version.
14
15 # SXEmacs is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 # GNU General Public License for more details.
19
20 # You should have received a copy of the GNU General Public License
21 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
23 # Parts of SXEmacs are also distributed under a BSD-like licence.
24 # Check file headers for more information.
25
26 # BSD's m4 probably isn't gonna cut it, use gm4 if it is available
27 type gm4 >/dev/null 2>&1 && M4=gm4 || M4=m4
28
29 M4_VERSION=$($M4 --version | head -n1 | sed -e 's/^\(m4 \)\?(\?GNU M4)\? *//g' )
30 GOOD_M4=$( echo $M4_VERSION | awk -F. '{if( ($1>1) || ( ($1==1) && ($2>4) ) || ( ($1==1) && ($2==4) && ($3>=6) )) print 1 }')
31
32 if [ "$GOOD_M4" != "1" ]; then
33     echo You have m4 version $M4_VERSION.  SXEmacs requires m4 version 1.4.6 or later.
34     exit 1
35 fi
36
37 # To cater for Solaris
38 if test -d "/usr/xpg4/bin"; then
39     # don't add xpg4 dir to PATH if on OpenIndiana
40     grep -q OpenIndiana /etc/release 2>/dev/null||PATH=/usr/xpg4/bin:$PATH
41     export PATH
42 fi
43
44 type git >/dev/null 2>&1 && GIT=git
45 olddir=$(pwd)
46 srcdir=$(dirname $0)
47 cd "$srcdir"
48
49 EXPECTED_TREE_VERSION="22.1.14"
50
51 emacs_is_beta=t
52 if test -n "$GIT" -a -n "$($GIT symbolic-ref HEAD 2>/dev/null)"; then
53         TREE_VERSION="$($GIT tag|tail -n1|tr -d v)"
54         GIT_VERSION="$($GIT describe | head -n1)"
55         IN_GIT="1"
56 fi
57 if test -z "$TREE_VERSION"; then
58         TREE_VERSION="$EXPECTED_TREE_VERSION"
59         if test -n "$IN_GIT"; then
60             echo "If you cloned this branch into your own you should issue:"
61             echo "\tgit tag -s v${TREE_VERSION}.<your branch_name>"
62             echo "\tgit push --tag"
63         fi
64 fi
65 if test -z "$GIT_VERSION"; then
66         GIT_VERSION="${TREE_VERSION}-no_git_version"
67 fi
68
69 emacs_major_version="$(echo $TREE_VERSION|cut -d. -f1)"
70 emacs_minor_version="$(echo $TREE_VERSION|cut -d. -f2)"
71 emacs_beta_version="$(echo $TREE_VERSION|cut -d. -f3)"
72 emacs_full_version="$emacs_major_version.$emacs_minor_version.$emacs_beta_version"
73 sxemacs_codename="Geo"
74 sxemacs_git_version="$GIT_VERSION"
75
76 if test "$emacs_full_version" != "$EXPECTED_TREE_VERSION"; then
77     # Note, there is no need check for git repos, because
78     # it can only happen in such a case anyway...
79     echo "*******************************************"
80     echo " WARNING: Your git tags may be out of date "
81     echo ""
82     echo " Expected tree version $EXPECTED_TREE_VERSION "
83     echo " got $emacs_full_version (from $TREE_VERSION) "
84     set -x
85     git tag
86     git describe
87     git describe --long
88     git config -l
89     set +x
90     echo "*******************************************"
91 fi
92
93 autoconf_ver=$(autoconf --version 2>/dev/null | head -n1)
94 autoheader_ver=$(autoheader --version 2>/dev/null | head -n1)
95 automake_ver=$(automake --version 2>/dev/null | head -n1)
96 aclocal_ver=$(aclocal --version 2>/dev/null | head -n1)
97 libtool_ver=$(libtool --version 2>/dev/null | head -n1)
98
99
100 # When things go wrong... get a bigger hammer!
101 if test -n "$PHAMMER"; then
102     HAMMER=$PHAMMER
103 fi
104
105 if test -n "$HAMMER"; then
106         if test -n "$GIT" -a -n "$($GIT symbolic-ref HEAD 2>/dev/null)"; then
107                 $GIT clean -fxd
108         else
109                 echo "ERROR: Not a git workspace, or you don't have git" >&2
110                 exit 1
111         fi
112         unset HAMMER
113 fi
114
115
116 cat>sxemacs_version.m4<<EOF
117 dnl autogenerated version number
118 m4_define([SXEM4CS_VERSION], [$emacs_full_version])
119 m4_define([SXEM4CS_MAJOR_VERSION], [$emacs_major_version])
120 m4_define([SXEM4CS_MINOR_VERSION], [$emacs_minor_version])
121 m4_define([SXEM4CS_BETA_VERSION], [$emacs_beta_version])
122 m4_define([SXEM4CS_BETA_P], [$emacs_is_beta])
123 m4_define([SXEM4CS_GIT_VERSION], [$sxemacs_git_version])
124 m4_define([SXEM4CS_CODENAME], [$sxemacs_codename])
125 m4_define([4UTOCONF_VERSION], [$autoconf_ver])
126 m4_define([4UTOHEADER_VERSION], [$autoheader_ver])
127 m4_define([4CLOCAL_VERSION], [$aclocal_ver])
128 m4_define([4UTOMAKE_VERSION], [$automake_ver])
129 m4_define([4IBTOOL_VERSION], [$libtool_ver])
130 EOF
131
132 if test -z "$FORCE"; then
133     FORCE=
134 else
135     rm -rf autom4te.cache aclocal.m4
136     FORCE=--force
137 fi
138
139 if type glibtoolize 2>/dev/null; then
140     LIBTOOLIZE=glibtoolize
141 else
142     LIBTOOLIZE=libtoolize
143 fi
144
145 autoreconf $FORCE --verbose --install -Wall
146
147 # hack-o-matic.  Using gmp's config.{guess,sub} lets us have properer
148 # detected machine configurations --SY.
149 guess=$(grep GMP config.guess)
150 sub=$(grep GMP config.sub)
151 if test -z "${guess}"; then
152     mv -vf config.guess configfsf.guess
153     cp -v configgmp.guess config.guess
154 fi
155 if test -z "${sub}"; then
156     mv -vf config.sub configfsf.sub
157     cp -v configgmp.sub config.sub
158 fi
159
160 cd $olddir