Merge branch 'sxe_pc_check' into for-steve
[sxemacs] / autogen.sh
1 #!/bin/sh
2 # Configure script bootstrap for SXEmacs
3 #
4 # Copyright (C) 2005 - 2012 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.15"
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         GIT_BRANCH="$(git branch --no-color | awk '/^\*/ { print $2 }')"
56         IN_GIT="1"
57 fi
58 if test -z "$TREE_VERSION"; then
59         TREE_VERSION="$EXPECTED_TREE_VERSION"
60         if test -n "$IN_GIT"; then
61             echo "If you cloned this branch into your own you could issue:"
62             echo "\tgit tag -s v${TREE_VERSION}.<your branch_name>"
63             echo ""
64             echo "Be careful about pushing the tags as they probably will be "
65             echo "more of a nuisance..."
66             echo ""
67             TREE_VERSION="$EXPECTED_TREE_VERSION.$GIT_BRANCH"
68             echo "For now I am assuming the tre version will be $TREE_VERSION"
69             echo ""
70         fi
71 fi
72 if test -z "$GIT_VERSION"; then
73         GIT_VERSION="${TREE_VERSION}-no_git_version"
74 fi
75
76 emacs_major_version="$(echo $TREE_VERSION|cut -d. -f1)"
77 emacs_minor_version="$(echo $TREE_VERSION|cut -d. -f2)"
78 emacs_beta_version="$(echo $TREE_VERSION|cut -d. -f3)"
79 emacs_full_version="$emacs_major_version.$emacs_minor_version.$emacs_beta_version"
80 sxemacs_codename="Goggomobil"
81 sxemacs_git_version="$GIT_VERSION"
82
83 if test "$emacs_full_version" != "$EXPECTED_TREE_VERSION"; then
84     # Note, there is no need check for git repos, because
85     # it can only happen in such a case anyway...
86     echo "*******************************************"
87     echo " WARNING: Your git tags may be out of date "
88     echo ""
89     echo " Expected tree version $EXPECTED_TREE_VERSION "
90     echo " got $emacs_full_version (from $TREE_VERSION) "
91     set -x
92     git tag
93     git describe
94     git describe --long
95     git config -l
96     set +x
97     echo "*******************************************"
98 fi
99
100 autoconf_ver=$(autoconf --version 2>/dev/null | head -n1)
101 autoheader_ver=$(autoheader --version 2>/dev/null | head -n1)
102 automake_ver=$(automake --version 2>/dev/null | head -n1)
103 aclocal_ver=$(aclocal --version 2>/dev/null | head -n1)
104 libtool_ver=$(libtool --version 2>/dev/null | head -n1)
105
106
107 # When things go wrong... get a bigger hammer!
108 if test -n "$PHAMMER"; then
109     HAMMER=$PHAMMER
110 fi
111
112 if test -n "$HAMMER"; then
113         if test -n "$GIT" -a -n "$($GIT symbolic-ref HEAD 2>/dev/null)"; then
114                 $GIT clean -fxd
115         else
116                 echo "ERROR: Not a git workspace, or you don't have git" >&2
117                 exit 1
118         fi
119         unset HAMMER
120 fi
121
122
123 cat>sxemacs_version.m4<<EOF
124 dnl autogenerated version number
125 m4_define([SXEM4CS_VERSION], [$emacs_full_version])
126 m4_define([SXEM4CS_MAJOR_VERSION], [$emacs_major_version])
127 m4_define([SXEM4CS_MINOR_VERSION], [$emacs_minor_version])
128 m4_define([SXEM4CS_BETA_VERSION], [$emacs_beta_version])
129 m4_define([SXEM4CS_BETA_P], [$emacs_is_beta])
130 m4_define([SXEM4CS_GIT_VERSION], [$sxemacs_git_version])
131 m4_define([SXEM4CS_CODENAME], [$sxemacs_codename])
132 m4_define([4UTOCONF_VERSION], [$autoconf_ver])
133 m4_define([4UTOHEADER_VERSION], [$autoheader_ver])
134 m4_define([4CLOCAL_VERSION], [$aclocal_ver])
135 m4_define([4UTOMAKE_VERSION], [$automake_ver])
136 m4_define([4IBTOOL_VERSION], [$libtool_ver])
137 EOF
138
139 if type glibtoolize 2>/dev/null; then
140     LIBTOOLIZE=glibtoolize
141 else
142     LIBTOOLIZE=libtoolize
143 fi
144
145 # using libtoolize as we did before doesn't work anymore, so just mkdir --Horst
146 mkdir -p libltdl/m4
147 autoreconf --force --verbose --install -Wall
148
149 # hack-o-matic.  Using gmp's config.{guess,sub} lets us have properer
150 # detected machine configurations --SY.
151 guess=$(grep GMP config.guess)
152 sub=$(grep GMP config.sub)
153 if test -z "${guess}"; then
154     mv -f config.guess configfsf.guess
155     cp configgmp.guess config.guess
156 fi
157 if test -z "${sub}"; then
158     mv -f config.sub configfsf.sub
159     cp configgmp.sub config.sub
160 fi
161
162 cd $olddir