1#!/bin/sh
2# Run this to generate all the initial makefiles, etc.
3# Shamelessly copied from Glade
4
5DIE=0
6
7if test -d m4local ; then
8  :
9else
10  echo "Directory \`m4local' does not exist.  Creating it."
11  if test -e m4local ; then
12    echo "**Error**: A file \`m4local' exists and is not a directory."
13    echo "Please remove it."
14    DIE=1
15  fi
16  mkdir m4local
17fi
18
19libtoolv=`libtool --version | head -1 | sed 's,.*[      ]\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*[a-z]*\([   ]?.*\|\)$,\1,'`
20libtool_major=`echo $libtoolv | awk -F. '{print $1}'`
21libtool_minor=`echo $libtoolv | awk -F. '{print $2}'`
22libtool_point=`echo $libtoolv | awk -F. '{print $3}'`
23
24test "$libtool_major" -le 1 && {
25  test "$libtool_minor" -lt 5
26} && {
27  echo
28  echo "**Warning**: You should have \`libtool' 1.5 or newer installed to"
29  echo "create a gutenprint distribution.  Earlier versions of libtool do"
30  echo "not generate correct code for all platforms."
31  echo "Get ftp://ftp.gnu.org/pub/gnu/libtool/libtool-1.5.tar.gz"
32  echo "(or a newer version if it is available)"
33  DIE=1
34}
35
36(autoconf --version) < /dev/null > /dev/null 2>&1 || {
37  echo
38  echo "**Error**: You must have \`autoconf' installed to compile gutenprint."
39  echo "Download the appropriate package for your distribution,"
40  echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
41  DIE=1
42}
43
44test -f $srcdir/configure.ac && sed "s/XXXRELEASE_DATE=XXX/RELEASE_DATE=\"`date '+%d %b %Y'`\"/" $srcdir/m4extra/stp_release.m4.in > $srcdir/m4/stp_release.m4
45
46test -f $srcdir/ChangeLog || echo > $srcdir/ChangeLog
47
48(grep "^AM_PROG_LIBTOOL" $srcdir/configure.ac >/dev/null) && {
49  (libtool --version) < /dev/null > /dev/null 2>&1 || {
50    echo
51    echo "**Error**: You must have \`libtool' installed to compile gutenprint."
52    echo "Get ftp://ftp.gnu.org/pub/gnu/libtool/libtool-1.5.tar.gz"
53    echo "(or a newer version if it is available)"
54    DIE=1
55  }
56}
57
58grep "^AM_GNU_GETTEXT" $srcdir/configure.ac >/dev/null && {
59  grep "sed.*POTFILES" $srcdir/configure.ac >/dev/null || \
60  (gettext --version) < /dev/null > /dev/null 2>&1 || {
61    echo
62    echo "**Error**: You must have \`gettext' installed to compile gutenprint."
63    echo "Get ftp://ftp.gnu.org/pub/gnu/gettext/gettext-0.16.tar.gz"
64    echo "(or a newer version if it is available)"
65    DIE=1
66  }
67}
68
69(pkg-config --version) < /dev/null > /dev/null 2>&1 || {
70  echo
71  echo "**Error**: You must have \`pkg-config' installed to compile gutenprint."
72  echo "Download the appropriate package for your distribution,"
73  echo "or get the source tarball at http://www.freedesktop.org/"
74  DIE=1
75}
76
77
78#### MRS: The following now only generates a warning, since earlier
79####      versions of gettext *do* work, they just don't create the
80####      right uninstall code.
81
82gettextv=`gettext --version | head -1 | awk '{print $NF}'`
83gettext_major=`echo $gettextv | awk -F. '{print $1}'`
84gettext_minor=`echo $gettextv | awk -F. '{print $2}'`
85gettext_point=`echo $gettextv | awk -F. '{print $3}'`
86
87test "$gettext_major" -eq 0 && {
88  test "$gettext_minor" -lt 16
89} && {
90  echo
91  echo "**Warning**: You must have \`gettext' 0.16 or newer installed to"
92  echo "create a gutenprint distribution.  Earlier versions of gettext do"
93  echo "not generate the correct 'make uninstall' code."
94  echo "Get ftp://ftp.gnu.org/gnu/gettext/gettext-0.16.tar.gz"
95  echo "(or a newer version if it is available)"
96}
97
98(autopoint --version) < /dev/null > /dev/null 2>&1 || {
99  echo
100  echo "**Error**: You must have \`autopoint' installed to compile gutenprint."
101  echo "Get ftp://ftp.gnu.org/pub/gnu/gettext/gettext-0.11.5.tar.gz"
102  echo "(or a newer version if it is available)"
103  DIE=1
104  NO_AUTOMAKE=yes
105}
106
107(automake --version) < /dev/null > /dev/null 2>&1 || {
108  echo
109  echo "**Error**: You must have \`automake' installed to compile gutenprint."
110  echo "Get ftp://ftp.gnu.org/pub/gnu/automake/automake-1.7.tar.gz"
111  echo "(or a newer version if it is available)"
112  DIE=1
113  NO_AUTOMAKE=yes
114}
115
116
117# if no automake, don't bother testing for aclocal
118test -n "$NO_AUTOMAKE" || (aclocal --version) < /dev/null > /dev/null 2>&1 || {
119  echo
120  echo "**Error**: Missing \`aclocal'.  The version of \`automake'"
121  echo "installed doesn't appear recent enough."
122  echo "Get ftp://ftp.gnu.org/pub/gnu/automake/automake-1.7.tar.gz"
123  echo "(or a newer version if it is available)"
124  DIE=1
125}
126
127# Check first for existence and then for proper version of Jade >= 1.2.1
128
129jade_err=0
130
131# Exists?
132jade_exists=`type -p $jade`
133test -z "$jade_exists" && jade_err=1
134
135# Proper rev?
136test "$jade_err" -eq 0 && {
137#  echo "Checking for proper revision of jade..."
138  jade_version=`jade -v < /dev/null 2>&1 | grep -i "jade version" | awk -F\" '{print $2}'`
139
140  jade_version_major=`echo $jade_version | awk -F. '{print $1}'`
141  jade_version_minor=`echo $jade_version | awk -F. '{print $2}'`
142  jade_version_point=`echo $jade_version | awk -F. '{print $3}'`
143
144  test "$jade_version_major" -ge 1 || jade_err=1
145
146  test "$jade_version_minor" -lt 2 || {
147      test "$jade_version_minor" -eq 2 -a "$jade_version_point" -lt 1
148    } && jade_err=1
149
150  test "$jade_err" -eq 1 && {
151    echo " "
152    echo "***Warning***: You must have \"Jade\" version 1.2.1 or"
153    echo "newer installed to build the Gutenprint user's guide."
154    echo "Get ftp://ftp.jclark.com/pub/jade/jade-1.2.1.tar.gz"
155    echo "(or a newer version if available)"
156    echo " "
157  }
158}
159
160# Check for existence of dvips
161
162dvipsloc=`type -p dvips`
163
164test -z "$dvipsloc" && {
165  echo " "
166  echo "***Warning***: You must have \"dvips\" installed to"
167  echo "build the Gutenprint user's guide."
168  echo " "
169}
170
171# Check for existence of jadetex
172
173jadetexloc=`type -p jadetex`
174
175test -z "$jadetexloc" && {
176  echo " "
177  echo "***Warning***: You must have \"jadetex\" version 3.5 or"
178  echo "newer installed to build the Gutenprint user's guide."
179  echo "Get ftp://prdownloads.sourceforge.net/jadetex/jadetex-3.5.tar.gz"
180  echo "(or a newer version if available)"
181  echo " "
182}
183
184# Check for OpenJade >= 1.3
185
186openjade_err=0
187
188openjadeloc=`type -p openjade`
189
190# Exists?
191test -z "$openjadeloc" && openjade_err=1
192
193# Proper rev?
194test "$openjade_err" -eq 0 && {
195#  echo "Checking for proper revision of openjade..."
196  openjade_version=`openjade -v < /dev/null 2>&1 | sed 's/"//g' | grep -i "openjade version" $tmp_file | awk -F ' ' '{print $4}'`
197  openjade_version_major=`echo $openjade_version | awk -F. '{print $1}'`
198  openjade_version_minor=`echo $openjade_version | awk -F. '{print $2}'`
199  openjade_version_minor=`echo $openjade_version_minor | awk -F- '{print $1}'`
200
201  test "$openjade_version_major" -ge 1 || openjade_err=1
202  test "$openjade_version_minor" -ge 3 || openjade_err=1
203
204  test "$openjade_err" -eq 1 && {
205    echo " "
206    echo "***Warning***: You must have \"OpenJade\" version 1.3 or"
207    echo "newer installed to build the Gutenprint user's guide."
208    echo "Get http://download.sourceforge.net/openjade/openjade-1.3.tar.gz"
209    echo "(or a newer version if available)"
210    echo " "
211  }
212}
213
214# Check for ps2pdf
215
216ps2pdfloc=`type -p ps2pdf`
217
218test -z "ps2pdfloc" && {
219  echo " "
220  echo "***Warning***: You must have \"ps2pdf\" installed to"
221  echo "build the Gutenprint user's guide."
222  echo "\"ps2pdf\" comes from the GNU Ghostscript software package."
223  echo "Get ftp://ftp.gnu.org/gnu/ghostscript/ghostscript-6.5.1.tar.gz"
224  echo "(or a newer version if available)"
225  echo " "
226}
227
228# Check first for existence and then for proper version of sgmltools-lite >=3.0.2
229
230sgmltools_err=0
231
232# Exists?
233sgmltoolsloc=`type -p sgmltools`
234test -z "$sgmltoolsloc" && sgmltools_err=1
235
236# Proper rev?
237test "$sgmltools_err" -eq 0 && {
238#  echo "Checking for proper revision of sgmltools..."
239  sgmltools_version=`sgmltools --version | awk '{print $3}'`
240
241  sgmltools_version_major=`echo $sgmltools_version | awk -F. '{print $1}'`
242  sgmltools_version_minor=`echo $sgmltools_version | awk -F. '{print $2}'`
243  sgmltools_version_point=`echo $sgmltools_version | awk -F. '{print $3}'`
244
245  test "$sgmltools_version_major" -ge 3 || sgmltools_err=1
246  test "$sgmltools_version_minor" -gt 0 ||
247    (test "$sgmltools_version_minor" -eq 0 -a "$sgmltools_version_point" -ge 2) ||
248    sgmltools_err=1
249
250  test "$sgmltools_err" -eq 1 && {
251    echo " "
252    echo "***Warning***: You must have \"sgmltools-lite\" version 3.0.2"
253    echo "or newer installed to build the Gutenprint user's guide."
254    echo "Get http://prdownloads.sourceforge.net/projects/sgmltools-lite/sgmltools-lite-3.0.2.tar.gz"
255    echo "(or a newer version if available)"
256    echo " "
257  }
258}
259
260# Check for convert
261
262convertloc=`type -p convert`
263test -z "$convertloc" && {
264  echo " "
265  echo "***Warning***: You must have \"convert\" installed to"
266  echo "build the Gutenprint user's guide."
267  echo "\"convert\" comes from the ImageMagick software package."
268  echo "Go to http://imagemagick.sourceforge.net/http and get"
269  echo "the file ImageMagick-5.3.1.tar.gz"
270  echo "(or a newer version if available)"
271  echo " "
272}
273
274# Check for docbook version 4
275# Note workaround for Fedora installation
276# Include path for Fedora Docbook. A bit circuitous, but Fedora appends 
277# a bunch of extra stuff to the name of the directory-- including the 
278# version of Fedora (eg -fc9).  We don't want to test for every version 
279# of Fedora and modern bourne shells won't expand the glob (*); 
280# therefore, we do a `find` first and then test to see if there are any 
281# results.
282
283if test -d /usr/share/sgml/docbook ;  then
284  fedora_docbook=`find /usr/share/sgml/docbook -type d -name 'sgml-dtd-4.*' -print`
285fi
286
287{
288  test -d "/usr/share/sgml/docbook_4" || test -d "/usr/share/sgml/docbook/dtd/4.0" || test -d "/usr/share/sgml/docbook_4.1" || test -n "$fedora_docbook"
289} || {
290  echo " "
291  echo "***Warning***: You must have "Docbook v4" installed to"
292  echo "build the Gutenprint user's guide."
293  echo " "
294}
295
296if test "$DIE" -eq 1; then
297  exit 1
298fi
299
300if test -z "$*"; then
301  echo "**Warning**: I am going to run \`configure' with no arguments."
302  echo "If you wish to pass any to it, please specify them on the"
303  echo \`$0\'" command line."
304  echo
305fi
306
307case $CC in
308xlc )
309  am_opt=--include-deps;;
310esac
311
312for coin in `find $srcdir -name configure.ac -print`
313do
314  dr=`dirname $coin`
315  if test -f $dr/NO-AUTO-GEN; then
316    echo skipping $dr -- flagged as no auto-gen
317  else
318    echo processing $dr
319    macrodirs=`sed -n -e 's,^dnl AM_ACLOCAL_INCLUDE(\(.*\)),\1,gp' < $coin`
320    ( cd $dr
321      aclocalinclude="$ACLOCAL_FLAGS"
322      for k in $macrodirs; do
323  	if test -d $k; then
324          aclocalinclude="$aclocalinclude -I $k"
325  	##else
326	##  echo "**Warning**: No such directory \`$k'.  Ignored."
327        fi
328      done
329      if grep "^AM_GNU_GETTEXT" configure.ac >/dev/null; then
330	if grep "sed.*POTFILES" configure.ac >/dev/null; then
331	  : do nothing -- we still have an old unmodified configure.ac
332	else
333	  echo "Creating $dr/aclocal.m4 ..."
334	  rm -f aclocal.m4
335	  test -r aclocal.m4 || touch aclocal.m4
336	  # We've removed po/ChangeLog from the repository.  Version
337	  # 0.10.40 of gettext appends an entry to the ChangeLog every time
338	  # anyone runs autogen.sh.  Since developers do that a lot, and
339	  # then proceed to commit their entire sandbox, we wind up with
340	  # an ever-growing po/ChangeLog that generates CVS conflicts on
341	  # a routine basis.  There's no good reason for this.
342	  echo 'This ChangeLog is redundant. Please see the main ChangeLog for i18n changes.' > po/ChangeLog
343	  echo >> po/ChangeLog
344	  echo 'This file is present only to keep po/Makefile.in.in happy.' >> po/ChangeLog
345	  echo "Running autopoint...  Ignore non-fatal messages."
346	    autopoint --force
347	  echo "Making $dr/aclocal.m4 writable ..."
348	  test -r $dr/aclocal.m4 && chmod u+w $dr/aclocal.m4
349        fi
350      fi
351      if grep "^AM_PROG_LIBTOOL" configure.ac >/dev/null; then
352	echo "Running libtoolize..."
353	libtoolize --force --copy
354      fi
355      echo "Running aclocal $aclocalinclude ..."
356      aclocal $aclocalinclude
357      if grep "^AM_CONFIG_HEADER" configure.ac >/dev/null; then
358	echo "Running autoheader..."
359	autoheader
360      fi
361      echo "Running automake --gnu $am_opt ..."
362      automake --add-missing --force-missing --copy --gnu $am_opt
363      echo "Running autoconf ..."
364      autoconf
365    )
366  fi
367done
368
369conf_flags="--enable-maintainer-mode" #--enable-iso-c
370
371if test x$NOCONFIGURE = x; then
372  echo Running $srcdir/configure $conf_flags "$@" ...
373  $srcdir/configure $conf_flags "$@" \
374  && echo Now type \`make\' to compile $PKG_NAME || exit 1
375else
376  echo Skipping configure process.
377fi
378