1#!/bin/sh
2# Run this program to build the configuration
3# files for GNU Typist:
4# [*/]Makefile.in, aclocal.m4, configure,
5# config.h.in, config.sub, config.guess
6# INSTALL, configure-w32, doc/gtypist.info, lessons/gtypist.typ
7# (maybe more)
8
9echo "Checking for required tools..."
10
11(autoconf --version) < /dev/null > /dev/null 2>&1 || {
12    echo
13    echo "**Error**: You must have \`autoconf' installed"
14    echo "Get ftp://ftp.gnu.org/gnu/autoconf/autoconf-2.57.tar.bz2"
15    echo "(or a newer version if it is available)"
16    exit 1
17}
18
19(automake --version) < /dev/null > /dev/null 2>&1 || {
20    echo
21    echo "**Error**: You must have \`automake' installed."
22    echo "Get ftp://ftp.gnu.org/gnu/automake/automake-1.7.7.tar.bz2"
23    echo "(or a newer version if it is available)"
24    exit 1
25}
26
27(gettext --version) < /dev/null > /dev/null 2>&1 || {
28    echo
29    echo "**Error**: You must have \`gettext' installed."
30    echo "Get ftp://ftp.gnu.org/gnu/gettext/gettext-0.12.1.tar.gz"
31    echo "(or a newer version if it is available)"
32    exit 1
33}
34
35(autopoint --version) < /dev/null > /dev/null 2>&1 || {
36    echo
37    echo "**Error**: You must have \`autopoint' (part of gettext) installed."
38    echo "Get ftp://ftp.gnu.org/gnu/gettext/gettext-0.12.1.tar.gz"
39    echo "(or a newer version if it is available)"
40    exit 1
41}
42
43(help2man --version) < /dev/null > /dev/null 2>&1 || {
44    echo
45    echo "**Error**: You must have \`help2man' installed."
46    echo "Get ftp://ftp.gnu.org/gnu/help2man/help2man_1.33.1.tar.gz"
47    echo "(or a newer version if it is available)"
48    exit 1
49}
50
51(makeinfo --version) < /dev/null > /dev/null 2>&1 || {
52    echo
53    echo "**Error**: You must have \`texinfo' installed."
54    echo "Get ftp://ftp.gnu.org/gnu/texinfo/texinfo-4.6.tar.bz2"
55    echo "(or a newer version if it is available)"
56    exit 1
57}
58
59# Copy gettext.h from gettext install
60
61gettext_exe=`which gettext`
62gettext_bin=`dirname $gettext_exe`
63gettext_home=`dirname $gettext_bin`
64gettexth=$gettext_home/share/gettext/gettext.h
65if [ ! -r "$gettexth" ]; then
66   echo "Couldn't find gettext.h"
67   echo "Looking for gettext.h in /usr/ ..."
68   gettexth=`find /usr/ -name gettext.h -print`
69fi
70if [ ! -r "$gettexth" ]; then
71    echo
72    echo "**Error**: Can not find gettext.h on your system."
73    echo "Get ftp://ftp.gnu.org/gnu/gettext/gettext-0.12.1.tar.gz"
74    echo "(or a newer version if it is available)"
75    exit 1
76fi
77
78echo "Copying gettext.h from $gettexth"
79cp $gettexth src/
80
81# Generate lesson menus
82(gawk --version) < /dev/null > /dev/null 2>&1 || {
83    echo
84    echo "**Error**: The git version requires \`gawk' (awk won't do)."
85    echo "This is needed to build lessons/gtypist.typ."
86    echo "Write to bug-gtypist@gnu.org if you have problems with this."
87    exit 1
88}
89echo "creating lessons/gtypist.typ..."
90(cd lessons && gawk -f ../tools/typcombine q.typ r.typ t.typ v.typ u.typ d.typ c.typ m.typ s.typ n.typ > gtypist.typ)
91
92VERSION=`./version.sh`
93
94for file in configure-w32 INSTALL
95  do
96  echo "creating $file..."
97  if test $file -nt ${file}.in; then
98      echo "*** \"$file\" has been modified,"
99      echo "but it is generated from ${file}.in."
100      echo "Please apply the changes to ${file}.in instead."
101      exit -1;
102  fi
103  sed "s/@VERSION/$VERSION/g" ${file}.in > $file
104  # TODO: this causes cvs to think that ${file}.in was modified...
105  # solution: use a "stamp" file for each $file ?
106  touch ${file}.in
107done
108
109# Add gettext infrastructure.
110echo "running autopoint..."
111autopoint
112
113# Build configuration files
114
115echo "creating build configuration files..."
116aclocal -I m4
117autoheader
118automake --add-missing
119
120if [ $? != 0 ]; then
121    echo ""
122    echo "Automake wasn't able to generate the necessary files like"
123    echo "config.sub, config.guess, etc. needed for compilation"
124    echo "You can copy them from some other place, but it's better"
125    echo "to investigate why automake --add-missing failed, so that"
126    echo "it doesn't cause some obscure problems later."
127    echo "After pressing ENTER, the process will continue, but"
128    echo "you can use CONTROL-C to interrupt it."
129    read
130fi
131
132autoconf
133if [ $? != 0 ]; then
134    echo -e \
135    	"--------------------------------------------------------------------" \
136    	"\nSomething was wrong, autoconf failed." \
137	"\nConsult notes on how to build if from git in the README.git file," \
138	"\nif you don't know how to resolve this."
139    exit 1
140fi
141
142
143if test -z "$*"; then
144    echo
145    echo "**Warning**: I am going to run \`configure' with no arguments."
146    echo "If you wish to pass any to it, please specify them on the"
147    echo \'$0\'" command line."
148fi
149
150echo
151echo running ./configure "$@"...
152echo
153./configure "$@"
154
155# Run make
156
157make
158
159# Create the source packages
160
161make dist
162
163