summaryrefslogtreecommitdiff
path: root/scripts/autogen.sh
blob: 102ca9905f485c48bb9738caa9cf7555385d1be2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
#!/bin/sh
# Run this to generate all the initial makefiles, etc.
# Shamelessly copied from Glade

DIE=0

if test -d m4local ; then
  :
else
  echo "Directory \`m4local' does not exist.  Creating it."
  if test -e m4local ; then
    echo "**Error**: A file \`m4local' exists and is not a directory."
    echo "Please remove it."
    DIE=1
  fi
  mkdir m4local
fi

libtoolv=`libtool --version | head -1 | sed 's,.*[      ]\([0-9][0-9]*\.[0-9][0-9]*\(\.[0-9][0-9]*\)\?\).*[a-z]*\([   ]?.*\|\)$,\1,'`
libtool_major=`echo $libtoolv | awk -F. '{print $1}'`
libtool_minor=`echo $libtoolv | awk -F. '{print $2}'`
libtool_point=`echo $libtoolv | awk -F. '{print $3}'`

test "$libtool_major" -le 1 && {
  test "$libtool_minor" -lt 5
} && {
  echo
  echo "**Warning**: You should have \`libtool' 1.5 or newer installed to"
  echo "create a Gutenprint distribution.  Earlier versions of libtool do"
  echo "not generate correct code for all platforms."
  echo "Get ftp://ftp.gnu.org/pub/gnu/libtool/libtool-1.5.tar.gz"
  echo "(or a newer version if it is available)"
  DIE=1
}

(autoconf --version) < /dev/null > /dev/null 2>&1 || {
  echo
  echo "**Error**: You must have \`autoconf' installed to"
  echo "create a Gutenprint distribution."
  echo "Download the appropriate package for your distribution,"
  echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
  DIE=1
}

test -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

test -f $srcdir/ChangeLog || echo > $srcdir/ChangeLog

(grep "^AM_PROG_LIBTOOL" $srcdir/configure.ac >/dev/null) && {
  (libtool --version) < /dev/null > /dev/null 2>&1 || {
    echo
    echo "**Error**: You must have \`libtool' installed to"
    echo "create a Gutenprint distribution."
    echo "Get ftp://ftp.gnu.org/pub/gnu/libtool/libtool-1.5.tar.gz"
    echo "(or a newer version if it is available)"
    DIE=1
  }
}

grep "^AM_GNU_GETTEXT" $srcdir/configure.ac >/dev/null && {
  grep "sed.*POTFILES" $srcdir/configure.ac >/dev/null || \
  (gettext --version) < /dev/null > /dev/null 2>&1 || {
    echo
    echo "**Error**: You must have \`gettext' installed to"
    echo "create a Gutenprint distribution."
    echo "Get ftp://ftp.gnu.org/pub/gnu/gettext/gettext-0.16.tar.gz"
    echo "(or a newer version if it is available)"
    DIE=1
  }
}

(pkg-config --version) < /dev/null > /dev/null 2>&1 || {
  echo
  echo "**Error**: You must have \`pkg-config' installed to"
  echo "create a Gutenprint distribution."
  echo "Download the appropriate package for your distribution,"
  echo "or get the source tarball at http://www.freedesktop.org/"
  DIE=1
}


#### MRS: The following now only generates a warning, since earlier
####      versions of gettext *do* work, they just don't create the
####      right uninstall code.

gettextv=`gettext --version | head -1 | awk '{print $NF}'`
gettext_major=`echo $gettextv | awk -F. '{print $1}'`
gettext_minor=`echo $gettextv | awk -F. '{print $2}'`
gettext_point=`echo $gettextv | awk -F. '{print $3}'`

test "$gettext_major" -eq 0 && {
  test "$gettext_minor" -lt 16
} && {
  echo
  echo "**Warning**: You must have \`gettext' 0.16 or newer installed to"
  echo "create a Gutenprint distribution.  Earlier versions of gettext do"
  echo "not generate the correct 'make uninstall' code."
  echo "Get ftp://ftp.gnu.org/gnu/gettext/gettext-0.16.tar.gz"
  echo "(or a newer version if it is available)"
}

(autopoint --version) < /dev/null > /dev/null 2>&1 || {
  echo
  echo "**Error**: You must have \`autopoint' installed to"
  echo "create a Gutenprint distribution."
  echo "Get ftp://ftp.gnu.org/pub/gnu/gettext/gettext-0.11.5.tar.gz"
  echo "(or a newer version if it is available)"
  DIE=1
  NO_AUTOMAKE=yes
}

(automake --version) < /dev/null > /dev/null 2>&1 || {
  echo
  echo "**Error**: You must have \`automake' installed to"
  echo "create a Gutenprint distribution."
  echo "Get ftp://ftp.gnu.org/pub/gnu/automake/automake-1.7.tar.gz"
  echo "(or a newer version if it is available)"
  DIE=1
  NO_AUTOMAKE=yes
}


# if no automake, don't bother testing for aclocal
test -n "$NO_AUTOMAKE" || (aclocal --version) < /dev/null > /dev/null 2>&1 || {
  echo
  echo "**Error**: Missing \`aclocal'.  The version of \`automake'"
  echo "installed doesn't appear recent enough."
  echo "Get ftp://ftp.gnu.org/pub/gnu/automake/automake-1.7.tar.gz"
  echo "(or a newer version if it is available)"
  DIE=1
}

# Check first for existence and then for proper version of Jade >= 1.2.1

jade_err=0

# Exists?
jade_exists=`type -p $jade`
test -z "$jade_exists" && jade_err=1

# Proper rev?
test "$jade_err" -eq 0 && {
#  echo "Checking for proper revision of jade..."
  jade_version=`jade -v < /dev/null 2>&1 | grep -i "jade version" | awk -F\" '{print $2}'`

  jade_version_major=`echo $jade_version | awk -F. '{print $1}'`
  jade_version_minor=`echo $jade_version | awk -F. '{print $2}'`
  jade_version_point=`echo $jade_version | awk -F. '{print $3}'`

  test "$jade_version_major" -ge 1 || jade_err=1

  test "$jade_version_minor" -lt 2 || {
      test "$jade_version_minor" -eq 2 -a "$jade_version_point" -lt 1
    } && jade_err=1

  test "$jade_err" -eq 1 && {
    echo " "
    echo "***Warning***: You must have \"Jade\" version 1.2.1 or"
    echo "newer installed to build the Gutenprint user's guide."
    echo "Get ftp://ftp.jclark.com/pub/jade/jade-1.2.1.tar.gz"
    echo "(or a newer version if available)"
    echo " "
  }
}

# Check for existence of dvips

dvipsloc=`type -p dvips`

test -z "$dvipsloc" && {
  echo " "
  echo "***Warning***: You must have \"dvips\" installed to"
  echo "build the Gutenprint user's guide."
  echo " "
}

# Check for existence of jadetex

jadetexloc=`type -p jadetex`

test -z "$jadetexloc" && {
  echo " "
  echo "***Warning***: You must have \"jadetex\" version 3.5 or"
  echo "newer installed to build the Gutenprint user's guide."
  echo "Get ftp://prdownloads.sourceforge.net/jadetex/jadetex-3.5.tar.gz"
  echo "(or a newer version if available)"
  echo " "
}

# Check for OpenJade >= 1.3

openjade_err=0

openjadeloc=`type -p openjade`

# Exists?
test -z "$openjadeloc" && openjade_err=1

# Proper rev?
test "$openjade_err" -eq 0 && {
#  echo "Checking for proper revision of openjade..."
  openjade_version=`openjade -v < /dev/null 2>&1 | sed 's/"//g' | grep -i "openjade version" $tmp_file | awk -F ' ' '{print $4}'`
  openjade_version_major=`echo $openjade_version | awk -F. '{print $1}'`
  openjade_version_minor=`echo $openjade_version | awk -F. '{print $2}'`
  openjade_version_minor=`echo $openjade_version_minor | awk -F- '{print $1}' | sed -e 's/\([0-9][0-9]*\).*/\1/'`

  test "$openjade_version_major" -ge 1 || openjade_err=1
  test "$openjade_version_minor" -ge 3 || openjade_err=1

  test "$openjade_err" -eq 1 && {
    echo " "
    echo "***Warning***: You must have \"OpenJade\" version 1.3 or"
    echo "newer installed to build the Gutenprint user's guide."
    echo "Get http://download.sourceforge.net/openjade/openjade-1.3.tar.gz"
    echo "(or a newer version if available)"
    echo " "
  }
}

# Check for ps2pdf

ps2pdfloc=`type -p ps2pdf`

test -z "ps2pdfloc" && {
  echo " "
  echo "***Warning***: You must have \"ps2pdf\" installed to"
  echo "build the Gutenprint user's guide."
  echo "\"ps2pdf\" comes from the GNU Ghostscript software package."
  echo "Get ftp://ftp.gnu.org/gnu/ghostscript/ghostscript-6.5.1.tar.gz"
  echo "(or a newer version if available)"
  echo " "
}

# Check first for existence and then for proper version of sgmltools-lite >=3.0.2

sgmltools_err=0

# Exists?
sgmltoolsloc=`type -p sgmltools`
test -z "$sgmltoolsloc" && sgmltools_err=1

# Proper rev?
test "$sgmltools_err" -eq 0 && {
#  echo "Checking for proper revision of sgmltools..."
  sgmltools_version=`sgmltools --version | awk '{print $3}'`

  sgmltools_version_major=`echo $sgmltools_version | awk -F. '{print $1}'`
  sgmltools_version_minor=`echo $sgmltools_version | awk -F. '{print $2}'`
  sgmltools_version_point=`echo $sgmltools_version | awk -F. '{print $3}'`

  test "$sgmltools_version_major" -ge 3 || sgmltools_err=1
  test "$sgmltools_version_minor" -gt 0 ||
    (test "$sgmltools_version_minor" -eq 0 -a "$sgmltools_version_point" -ge 2) ||
    sgmltools_err=1

  test "$sgmltools_err" -eq 1 && {
    echo " "
    echo "***Warning***: You must have \"sgmltools-lite\" version 3.0.2"
    echo "or newer installed to build the Gutenprint user's guide."
    echo "Get http://prdownloads.sourceforge.net/projects/sgmltools-lite/sgmltools-lite-3.0.2.tar.gz"
    echo "(or a newer version if available)"
    echo " "
  }
}

# Check for convert

convertloc=`type -p convert`
test -z "$convertloc" && {
  echo " "
  echo "***Warning***: You must have \"convert\" installed to"
  echo "build the Gutenprint user's guide."
  echo "\"convert\" comes from the ImageMagick software package."
  echo "Go to http://imagemagick.sourceforge.net/http and get"
  echo "the file ImageMagick-5.3.1.tar.gz"
  echo "(or a newer version if available)"
  echo " "
}

# Check for docbook version 4
# Note workaround for Fedora installation
# Include path for Fedora Docbook. A bit circuitous, but Fedora appends 
# a bunch of extra stuff to the name of the directory-- including the 
# version of Fedora (eg -fc9).  We don't want to test for every version 
# of Fedora and modern bourne shells won't expand the glob (*); 
# therefore, we do a `find` first and then test to see if there are any 
# results.

if test -d /usr/share/sgml/docbook ;  then
  fedora_docbook=`find /usr/share/sgml/docbook -type d -name 'sgml-dtd-4.*' -print`
fi

{
  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"
} || {
  echo " "
  echo "***Warning***: You must have Docbook v4 installed to"
  echo "build the Gutenprint user's guide."
  echo " "
}

if test "$DIE" -eq 1; then
  exit 1
fi

if test -z "$*"; then
  echo "**Warning**: I am going to run \`configure' with no arguments."
  echo "If you wish to pass any to it, please specify them on the"
  echo \`$0\'" command line."
  echo
fi

case $CC in
xlc )
  am_opt=--include-deps;;
esac

for coin in `find $srcdir -name configure.ac -print`
do
  dr=`dirname $coin`
  if test -f $dr/NO-AUTO-GEN; then
    echo skipping $dr -- flagged as no auto-gen
  else
    echo processing $dr
    macrodirs=`sed -n -e 's,^dnl AM_ACLOCAL_INCLUDE(\(.*\)),\1,gp' < $coin`
    ( cd $dr
      aclocalinclude="$ACLOCAL_FLAGS"
      for k in $macrodirs; do
  	if test -d $k; then
          aclocalinclude="$aclocalinclude -I $k"
  	##else
	##  echo "**Warning**: No such directory \`$k'.  Ignored."
        fi
      done
      if grep "^AM_GNU_GETTEXT" configure.ac >/dev/null; then
	if grep "sed.*POTFILES" configure.ac >/dev/null; then
	  : do nothing -- we still have an old unmodified configure.ac
	else
	  echo "Creating $dr/aclocal.m4 ..."
	  rm -f aclocal.m4
	  test -r aclocal.m4 || touch aclocal.m4
	  # We've removed po/ChangeLog from the repository.  Version
	  # 0.10.40 of gettext appends an entry to the ChangeLog every time
	  # anyone runs autogen.sh.  Since developers do that a lot, and
	  # then proceed to commit their entire sandbox, we wind up with
	  # an ever-growing po/ChangeLog that generates conflicts on
	  # a routine basis.  There's no good reason for this.
	  echo 'This ChangeLog is redundant. Please see the main ChangeLog for i18n changes.' > po/ChangeLog
	  echo >> po/ChangeLog
	  echo 'This file is present only to keep po/Makefile.in.in happy.' >> po/ChangeLog
	  echo "Running autopoint...  Ignore non-fatal messages."
	    autopoint --force
	    if [ $? -ne 0 ] ; then
		echo 'Autopoint failed!'
		exit 1
	    fi
	  echo "Making $dr/aclocal.m4 writable ..."
	  test -r $dr/aclocal.m4 && chmod u+w $dr/aclocal.m4
        fi
      fi
      if grep "^AM_PROG_LIBTOOL" configure.ac >/dev/null; then
	echo "Running libtoolize..."
	libtoolize --force --copy || (echo "libtoolize failed!"; exit 1)
	if [ $? -ne 0 ] ; then
	    echo 'libtoolize failed!'
	    exit 1
	fi
      fi
      echo "Running aclocal $aclocalinclude ..."
      aclocal $aclocalinclude
      if [ $? -ne 0 ] ; then
	  echo 'aclocal failed!'
	  exit 1
      fi
      if grep "^AM_CONFIG_HEADER" configure.ac >/dev/null; then
	echo "Running autoheader..."
	autoheader
	if [ $? -ne 0 ] ; then
	    echo 'autoheader failed!'
	    exit 1
	fi
      fi
      echo "Running automake --gnu $am_opt ..."
      automake --add-missing --force-missing --copy --gnu $am_opt
      if [ $? -ne 0 ] ; then
	  echo 'automake failed!'
	  exit 1
      fi
      echo "Running autoconf ..."
      autoconf
      if [ $? -ne 0 ] ; then
	  echo 'autoconf failed!'
	  exit 1
      fi
    )
    if [ $? -ne 0 ] ; then
	exit $?
    fi
  fi
done

conf_flags="--enable-maintainer-mode" #--enable-iso-c

if test x$NOCONFIGURE = x; then
  echo Running $srcdir/configure $conf_flags "$@" ...
  $srcdir/configure $conf_flags "$@" \
  && echo Now type \`make\' to compile $PKG_NAME || exit 1
else
  echo Skipping configure process.
fi