source: trunk/autogen.sh @ 1782

Revision 1782, 4.1 KB checked in by Freddie Akeroyd, 2 months ago (diff)

Add build scripts. Refs #307

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1#!/bin/sh
2
3rm -fr autom4te.cache
4
5PACKAGE_RELEASE=""
6NEXUS_VERSION=""
7NEXUS_RELEASE=""
8while getopts "p:r:v:" opt; do
9  case $opt in
10    p)
11        PACKAGE_RELEASE="$OPTARG"
12        ;;
13    v)
14        NEXUS_VERSION="$OPTARG"
15        ;;
16    r)
17        NEXUS_RELEASE="$OPTARG"
18        ;;
19    \?)
20        echo "Invalid option: -$OPTARG" >&2
21        ;;
22  esac
23done
24if test ! -z "$PACKAGE_RELEASE"; then
25    echo "Setting package release to $PACKAGE_RELEASE"
26    mv configure.ac configure.ac.$$
27    sed -e "s/^m4_define.*PACKAGE_RELEASE.*/m4_define\([PACKAGE_RELEASE],[$PACKAGE_RELEASE]\)/" < configure.ac.$$ > configure.ac
28    rm -f configure.ac.$$
29fi
30if test ! -z "$NEXUS_VERSION"; then
31    echo "Setting NeXus version to $NEXUS_VERSION"
32    mv configure.ac configure.ac.$$
33    sed -e "s/^m4_define.*NEXUS_VERSION.*/m4_define\([NEXUS_VERSION],[$NEXUS_VERSION]\)/" < configure.ac.$$ > configure.ac
34    rm -f configure.ac.$$
35fi
36if test ! -z "$NEXUS_RELEASE"; then
37    echo "Setting NeXus release to $NEXUS_RELEASE"
38    mv configure.ac configure.ac.$$
39    sed -e "s/^m4_define.*NEXUS_RELEASE.*/m4_define\([NEXUS_RELEASE],[$NEXUS_RELEASE]\)/" < configure.ac.$$ > configure.ac
40    rm -f configure.ac.$$
41fi
42
43for libtoolize in glibtoolize libtoolize ; do
44        LIBTOOLIZE=`which $libtoolize 2>/dev/null`
45        if test "$LIBTOOLIZE" ; then
46                break;
47        fi
48done
49LIBTOOLIZE="$libtoolize --force --copy --automake"
50
51# set up environment variables with the correct
52# version of autoconf and automake - this also needs
53# to be done in configure.ac to maintain consistancy
54. ./autoversion.sh
55
56touch AUTHORS NEWS README
57rm -f ChangeLog
58
59# Discover what version of autoconf we are using.
60autoconfversion=`$AUTOCONF --version | head -n 1`
61automakeversion=`$AUTOMAKE --version | head -n 1`
62libtoolversion=`$LIBTOOLIZE --version | head -n 1`
63
64echo "Using $autoconfversion"
65echo "Using $automakeversion"
66echo "Using $libtoolversion"
67case $autoconfversion in
68    *2.6*)
69        ;;
70    *2.7*)
71        ;;
72    *)
73        echo "This autoconf version is not supported by NeXus."
74        echo "NeXus only supports autoconf 2.61 and above"
75        echo "You may download it from ftp://ftp.gnu.org/gnu/autoconf"
76        exit
77        ;;
78esac
79
80case $automakeversion in
81    *1.[4-9]*)
82        ;;
83    *1.1[0-9]*)
84        ;;
85    *)
86        echo "This automake version is not supported by NeXus."
87        echo "NeXus only supports automake 1.4 and above"
88        echo "You may download it from ftp://ftp.gnu.org/gnu/automake"
89        exit
90        ;;
91esac
92
93case $libtoolversion in
94    *1.[456]*)
95        ;;
96    *[2-9].*)
97        ;;
98    *)
99        echo "This libtool version is not supported by NeXus."
100        echo "NeXus only supports libtool 1.4 and above"
101        echo "You may download it from ftp://ftp.gnu.org/gnu/libtool"
102        exit
103        ;;
104esac
105
106echo -n "Locating GNU m4... "
107GNUM4=
108for prog in $M4 gm4 gnum4 m4; do
109        # continue if $prog generates error (e.g. does not exist)
110        ( $prog --version ) < /dev/null > /dev/null 2>&1
111        if test $? -ne 0 ; then continue; fi
112
113        # /dev/null input prevents a hang of the script for some m4 compilers (e.g. on FreeBSD)
114        case `$prog --version < /dev/null 2>&1` in
115        *GNU*)  GNUM4=$prog
116                break ;;
117        esac
118done
119if test x$GNUM4 = x ; then
120        echo "not found."
121        exit
122else
123        echo `which $GNUM4`
124fi
125
126#
127if { test ! -d config ; } ; then
128        mkdir config ;
129else
130        rm -rf config/* ; 
131fi
132
133# Prepare the use of libtool
134if ( $LIBTOOLIZE --version ) < /dev/null > /dev/null 2>&1 ; then
135        echo "Preparing the use of libtool ..."
136        $LIBTOOLIZE
137        if { test -r ltmain.sh ; } ; then mv ltmain.sh config/ ; fi
138        echo "done."
139else
140        echo "libtoolize not found -- aborting"
141        exit
142fi
143
144# Generate the Makefiles and configure files
145if ( $ACLOCAL --version ) < /dev/null > /dev/null 2>&1; then
146        echo "Building macros..."
147        $ACLOCAL
148        echo "done."
149else
150        echo "aclocal not found -- aborting"
151        exit
152fi
153
154if ( $AUTOHEADER --version ) < /dev/null > /dev/null 2>&1; then
155        echo "Building config header template..."
156        $AUTOHEADER 
157        echo "done."
158else
159        echo "autoheader not found -- aborting"
160        exit
161fi
162
163if ( $AUTOMAKE --version ) < /dev/null > /dev/null 2>&1; then
164        echo "Building Makefile templates..."
165        $AUTOMAKE
166        echo "done."
167else
168        echo "automake not found -- aborting"
169        exit
170fi
171
172if ( $AUTOCONF --version ) < /dev/null > /dev/null 2>&1; then
173        echo "Building configure..."
174        $AUTOCONF
175        echo "done."
176else
177        echo "autoconf not found -- aborting"
178        exit
179fi
180
Note: See TracBrowser for help on using the repository browser.