Initial git import
[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 tla >/dev/null 2>&1 && TLA=tla
21 olddir=$(pwd)
22 srcdir=$(dirname $0)
23 cd "$srcdir"
24
25 emacs_is_beta=t
26 if test -n "$TLA" -a -n "$($TLA tree-version | grep '/sxemacs')"; then
27         TREE_VERSION="$($TLA tree-version)"
28         ARCH_VERSION="$($TLA logs -f|tail -n1)"
29         MAIN_VERSION="$($TLA log-versions|grep -- '--main--'|tail -n1)"
30         MAIN_ARCH_VERSION="$(tla logs -f $MAIN_VERSION|tail -n1)"
31 elif test -d "{arch}" -a -s "{arch}/++default-version"; then
32         TREE_VERSION=$(cat "{arch}/++default-version")
33         ARCH_VERSION="$TREE_VERSION--version-X"
34         CURDIR=$(pwd)
35         cd "{arch}/sxemacs/sxemacs--main"
36         MAIN_VERSION="$(/bin/ls|tail -n1)"
37         cd "$MAIN_VERSION"
38         MAIN_VERSION="$(/bin/ls)/$MAIN_VERSION"
39         cd "$(/bin/ls)/patch-log"
40         MAIN_ARCH_VERSION="$MAIN_VERSION--$(/bin/ls|grep -v base|sort -k1.7|tail -n1)"
41         cd "$CURDIR"
42 else
43         TREE_VERSION="--22.1.12"
44         ARCH_VERSION="no_arch_version"
45         MAIN_ARCH_VERSION="no_arch_version"
46 fi
47
48 emacs_major_version="$(echo $TREE_VERSION|sed -e s/"^.*--"//|cut -d . -f1)"
49 emacs_minor_version="$(echo $TREE_VERSION|sed -e s/"^.*--"//|cut -d . -f2)"
50 emacs_beta_version="$(echo $TREE_VERSION|sed -e s/"^.*--"//|cut -d . -f3)"
51 sxemacs_codename="Fiat"
52 sxemacs_arch_version="$ARCH_VERSION"
53 sxemacs_main_arch_version="$MAIN_ARCH_VERSION"
54
55 autoconf_ver=$(autoconf --version 2>/dev/null | head -n1)
56 autoheader_ver=$(autoheader --version 2>/dev/null | head -n1)
57 automake_ver=$(automake --version 2>/dev/null | head -n1)
58 aclocal_ver=$(aclocal --version 2>/dev/null | head -n1)
59 libtool_ver=$(libtool --version 2>/dev/null | head -n1)
60
61
62 # When things go wrong... get a bigger hammer!
63 _regexp='++log\|=b\(ui\)*ld'
64
65 if test -n "$PHAMMER"; then
66     HAMMER=$PHAMMER
67 fi
68
69 if test -n "$HAMMER" -o -n "$REGEXP"; then
70     if test -n "$TLA" -a -n "$($TLA tree-version | grep '/sxemacs')"; then
71         if test -n "$REGEXP" -a "$HAMMER" != "BHFH"; then
72             $TLA inventory -pbB|grep -v "$_regexp\|$REGEXP"|xargs rm -vrf
73             unset REGEXP
74         else
75             if test "$HAMMER" = "BHFH"; then
76                 $TLA inventory -pjubB|xargs rm -vrf
77             else
78                 $TLA inventory -pbB|grep -v "$_regexp"|xargs rm -vrf
79             fi
80         fi
81     else
82         echo "ERROR: Could not HAMMER=$HAMMER because we are not inside a tla controled workspace"
83         exit 1
84     fi
85     unset HAMMER
86 fi
87
88 cat>sxemacs_version.m4<<EOF
89 dnl autogenerated version number
90 m4_define([SXEM4CS_VERSION], [$emacs_major_version.$emacs_minor_version.$emacs_beta_version])
91 m4_define([SXEM4CS_MAJOR_VERSION], [$emacs_major_version])
92 m4_define([SXEM4CS_MINOR_VERSION], [$emacs_minor_version])
93 m4_define([SXEM4CS_BETA_VERSION], [$emacs_beta_version])
94 m4_define([SXEM4CS_BETA_P], [$emacs_is_beta])
95 m4_define([SXEM4CS_ARCH_VERSION], [$sxemacs_arch_version])
96 m4_define([SXEM4CS_MAIN_ARCH_VERSION], [$sxemacs_main_arch_version])
97 m4_define([SXEM4CS_CODENAME], [$sxemacs_codename])
98 m4_define([4UTOCONF_VERSION], [$autoconf_ver])
99 m4_define([4UTOHEADER_VERSION], [$autoheader_ver])
100 m4_define([4CLOCAL_VERSION], [$aclocal_ver])
101 m4_define([4UTOMAKE_VERSION], [$automake_ver])
102 m4_define([4IBTOOL_VERSION], [$libtool_ver])
103 EOF
104
105 if test -z "$FORCE"; then
106     FORCE=
107 else
108     rm -rf autom4te.cache aclocal.m4
109     FORCE=--force
110 fi
111
112 if type glibtoolize 2>/dev/null; then
113     LIBTOOLIZE=glibtoolize
114 else
115     LIBTOOLIZE=libtoolize
116 fi
117
118 autoreconf $FORCE --verbose --install -Wall
119
120 # hack-o-matic.  Using gmp's config.{guess,sub} lets us have properer
121 # detected machine configurations --SY.
122 guess=$(grep GMP config.guess)
123 sub=$(grep GMP config.sub)
124 if test -z "${guess}"; then
125     mv -vf config.guess configfsf.guess
126     cp -v configgmp.guess config.guess
127 fi
128 if test -z "${sub}"; then
129     mv -vf config.sub configfsf.sub
130     cp -v configgmp.sub config.sub
131 fi
132
133 cd $olddir