1## ---------------- ##
2## Initialization.  ##
3## ---------------- ##
4
5AC_INIT(src/main.c)
6AC_PREREQ(2.14a)
7AC_CONFIG_AUX_DIR(auxdir)
8AM_CONFIG_HEADER(config.h)
9
10# Initialize automake
11AM_INIT_AUTOMAKE(a2ps, 4.13)
12# Specify the liba2ps version number
13LIBVERSION=1:0:0
14AC_SUBST(LIBVERSION)
15GNU_PACKAGE="GNU $PACKAGE"
16AC_DEFINE_UNQUOTED(GNU_PACKAGE, "$GNU_PACKAGE",
17		   [The concatenation of the strings `GNU ', and PACKAGE.])
18AC_SUBST(GNU_PACKAGE)
19
20# Available translations
21ALL_LINGUAS="ca cs da de es et fr it ko nl no pl pt ru sl sv tr"
22
23## --------------------- ##
24## Checks for programs.  ##
25## --------------------- ##
26
27AC_PROG_AWK
28AC_PROG_GNU_M4
29AC_PROG_INSTALL
30AC_PROG_LN_S
31AC_PROG_MAKE_SET
32jm_PATH_PERL
33
34# Check for the C compiler and the various oddities that may exist
35AC_PROG_CC
36AC_AIX
37AC_MINIX
38AC_ISC_POSIX
39AC_PROG_CPP
40AM_PROG_CC_STDC
41AM_C_PROTOTYPES
42AC_PROG_YACC
43fp_PROG_ECHO
44missing_dir=`cd $ac_aux_dir && pwd`
45AM_MISSING_PROG(GPERF, gperf, $missing_dir)
46# I want flex, and only flex
47AM_PROG_LEX
48if test "$LEX" = lex; then
49  LEX="$missing_dir/missing flex"
50  LEX_OUTPUT_ROOT=lex.yy
51  AC_SUBST(LEX_OUTPUT_ROOT)dnl
52fi
53
54# Libtool.  By default, don't do shared libs, liba2ps is not widely used.
55AC_DISABLE_SHARED
56AC_PROG_LIBTOOL
57
58## ------------------------- ##
59## Checks for header files.  ##
60## ------------------------- ##
61
62AC_HEADER_STDC
63AC_HEADER_STAT
64AC_HEADER_TIME
65AC_HEADER_SYS_WAIT
66AC_HEADER_DIRENT
67AC_CHECK_HEADERS(sys/time.h sys/stat.h sys/types.h sys/ioctl.h  \
68 math.h string.h strings.h stdlib.h unistd.h stdarg.h pwd.h malloc.h \
69 memory.h errno.h fcntl.h stdbool.h fnmatch.h)
70
71## --------------------- ##
72## Checks for typedefs.  ##
73## --------------------- ##
74
75#
76# Checks for typedefs, structures, and compiler characteristics.
77#
78AC_C_CONST
79AC_C_INLINE
80AC_CHECK_TYPE(uchar, unsigned char)
81AC_TYPE_SIZE_T
82AC_TYPE_PID_T
83AC_TYPE_SIGNAL
84AC_STRUCT_TM
85AC_CHECK_MEMBERS((struct passwd.pw_gecos),,,
86[#if HAVE_PWD_H
87# include <pwd.h>
88#endif])
89jm_AC_PREREQ_XSTRTOUMAX
90jm_AC_TYPE_UINTMAX_T
91
92#
93# Portability non-Unix
94#
95AC_EXEEXT
96
97# Checking for sys_siglist.  Stolen from gmake-3.77
98AC_DECL_SYS_SIGLIST
99AC_MSG_CHECKING(for sys_siglist)
100AC_CACHE_VAL(ac_cv_check_symbol_sys_siglist,
101[AC_TRY_LINK(, [extern char *sys_siglist[]; puts(*sys_siglist);],
102             ac_cv_check_symbol_sys_siglist=yes,
103             ac_cv_check_symbol_sys_siglist=no)])
104if test "$ac_cv_check_symbol_sys_siglist" = yes; then
105  AC_DEFINE_UNQUOTED(HAVE_SYS_SIGLIST, 1,
106                     [Define if your system has `sys_siglist'.])
107fi
108AC_MSG_RESULT($ac_cv_check_symbol_sys_siglist)
109
110## ---------------------- ##
111## Checks for Libraries.  ##
112## ---------------------- ##
113
114# -lsun is sometimes needed on IRIX to use passwd
115AC_SEARCH_LIBS(getpwuid, sun,
116	       [AC_DEFINE(HAVE_GETPWUID, 1,
117                          [Define if you have the function `getpwuid'.])],)
118
119
120## ------------------------------ ##
121## checks for library functions.  ##
122## ------------------------------ ##
123
124AC_REPLACE_FUNCS(stpcpy stpncpy strtoul memcpy memset gethostname getuid)
125ad_REPLACE_FUNC_STRCASECMP
126ad_REPLACE_FUNC_STRNCASECMP
127ad_REPLACE_FUNC_RENAME
128AC_CHECK_FUNCS(uname strchr strerror strerror_r getcwd bcopy bzero tempnam strsignal psignal)
129ad_FUNC_SYSTEMPAPERNAME
130ad_FUNC_ATEXIT
131ad_FUNC_STRFTIME
132AC_FUNC_CLOSEDIR_VOID
133AC_FUNC_VPRINTF
134AM_FUNC_OBSTACK
135AC_FUNC_ALLOCA
136AM_FUNC_ERROR_AT_LINE
137jm_FUNC_MALLOC
138jm_FUNC_REALLOC
139jm_PREREQ_QUOTEARG
140
141# Check and replace broken or missing "fnmatch"
142AC_FUNC_FNMATCH
143if test $ac_cv_func_fnmatch_works = no; then
144  LIBOBJS="$LIBOBJS fnmatch.o"
145  AC_DEFINE_UNQUOTED(fnmatch, rpl_fnmatch,
146	  [Define to rpl_fnmatch if the replacement function should be used.])
147fi
148
149# Needed checks for tinyterm.[ch]
150ad_TINYTERM_CHECKS
151
152AC_CHECK_DECLS((fputs, strlen, strtoul, strtoull))
153
154# Internationalization.
155AM_GNU_GETTEXT
156
157# Save the cache
158AC_CACHE_SAVE
159
160# In path separator character.
161AC_DEFINE_UNQUOTED(DIRECTORY_SEPARATOR, '/',
162		   [The char used to separate component of a path])
163# Between paths separator character.
164AC_DEFINE_UNQUOTED(PATH_SEPARATOR, ':',
165		   [The char used to separate paths.])
166# We define SYNTAX_TABLE so that regex uses syntax tables
167AC_DEFINE(SYNTAX_TABLE, 1,
168	  [Define to enable syntax table support in `regex'.])
169
170## ---------------------------- ##
171## Various extentions/options.  ##
172## ---------------------------- ##
173
174# Some extra warnings
175ad_GCC_WARNINGS
176CFLAGS="$CFLAGS $EXTRA_CFLAGS"
177
178# Where to put the emacs files
179AM_PATH_LISPDIR
180
181# Shall the path to the tools be hardcoded?
182ad_ENABLE_PATHS
183
184# What should get installed?
185AC_ARG_ENABLE(extensions,
186AC_HELP_STRING(--disable-extensions,small foot print installation),
187[case "${enableval}" in
188  yes|no) ;;
189  *) AC_MSG_ERROR(bad value ${enableval} for --disable-extensions) ;;
190esac],[enable_extensions=yes])
191AM_CONDITIONAL(EXTENSIONS, test x$enable_extensions = xyes)
192if test x$enable_extensions = xyes; then
193  AC_CONFIG_SUBDIRS(ogonkify)
194fi
195
196AC_MSG_CHECKING(for PostScript fonts path)
197# Try to find some PostScript fonts.
198# Find out if ghostscript is installed
199ac_psfont_path=
200for ac_dir in /usr/local/ghostscript/fonts \
201  /usr/local/share/ghostscript/fonts;
202do
203  if test "cd $ac_dir 2>/dev/null && echo *.afm"; then
204    ac_psfont_path="$ac_psfont_path:$ac_dir";
205  fi
206done
207dnl Currently, we don't try TeX fonts, because sed expressions
208dnl explode.  Anyway, we really need to support kpathsea to get there.
209dnl # Try to find where are the TeX fonts.
210dnl for ac_dir in /usr/local/TeX /usr/local/tex /usr/local/teTeX;
211dnl do
212dnl   if test -d "$ac_dir/texmf/fonts/type1"; then
213dnl 	# There are fonts here.  Let's fetch all the directories.
214dnl 	for ac_dir2 in $ac_dir/texmf/fonts/type1/* \
215dnl 		       $ac_dir/texmf/fonts/type1/*/* \
216dnl 		       $ac_dir/texmf/fonts/type1/*/*/* \
217dnl 		       $ac_dir/texmf/fonts/afm/* \
218dnl 		       $ac_dir/texmf/fonts/afm/*/* \
219dnl 		       $ac_dir/texmf/fonts/afm/*/*/* ;
220dnl 	do
221dnl 	  if test -d "$ac_dir2" \
222dnl 	     && test -n `echo $ac_dir2/*.afm $ac_dir2/*.gsf $ac_dir2/*.pf?`; then
223dnl 	    ac_psfont_path="$ac_psfont_path:$ac_dir2";
224dnl 	  fi
225dnl 	done
226dnl   fi
227dnl done
228dnl # Remove the leading `:'
229if test -n "$ac_psfont_path"; then
230  PSFONT_PATH=`echo "$ac_psfont_path" | sed -e 's/^://'`
231fi
232AC_SUBST(PSFONT_PATH)
233AC_MSG_RESULT([$ac_psfont_path])
234
235## ---------------------------------------------------------- ##
236## Write a first sketch of a2ps.cfg.  The user should check.  ##
237## ---------------------------------------------------------- ##
238
239#
240# Check for the file program with follows the links
241#
242ad_PROG_FILE_LINK
243AC_SUBST(FILE_LINK)
244
245# How to send things in the printer queue
246ad_PROG_LPR
247
248#
249# default medium to use (defaulted to A4)
250#
251AC_ARG_WITH(medium,
252AC_HELP_STRING([--with-medium=medium],
253               [specify the default medium (A4, Letter, Legal, etc.) [default=A4]]),
254MEDIUM=$with_medium,
255if test x"$ac_cv_lib_paper_systempapername" = xyes; then
256  MEDIUM=libpaper
257else
258  MEDIUM=A4
259fi)
260AC_SUBST(MEDIUM)
261
262#
263# default encoding to use (defaulted to latin1)
264#
265AC_ARG_WITH(encoding,
266AC_HELP_STRING([--with-encoding=enc],
267               [specify the default encoding (ascii, latin1, latin2... latin6, hp etc.) [default=latin1]]),
268ENCODING=$with_encoding,
269ENCODING=latin1)
270AC_SUBST(ENCODING)
271
272########################
273# Nice special printers
274########################
275# Look for GV or Ghostview
276ad_CHECK_PROGS((gv, ghostview))
277if test "$COM_gv$COM_ghostview" = "##"; then
278  COM_DISPLAY="#"
279fi
280AC_SUBST(COM_DISPLAY)
281
282#################################
283# Helping people with delegations
284#################################
285# "Compressed" delegation
286ad_CHECK_PROG(gzip,
287[a2ps works better with gzip.
288Consider fetching gzip at any ftp site proposing GNU programs])
289ad_CHECK_PROGS((bzip, bzip2))
290
291# DVI delegation
292ad_CHECK_PROG(dvips)
293
294# ImageMagick for most image formats
295ad_CHECK_PROG(convert)
296
297# PDF delegation
298ad_CHECK_PROGS((acroread, pdf2ps))
299COM_acroread4='#'
300AC_SUBST(COM_acroread4)
301# If we have acroread, is it a version which supports -shrink etc.?
302if test "x$COM_acroread" = x; then
303  AC_CACHE_CHECK(whether acroread is acroread 4, a2_cv_com_acroread4,
304  [$acroread -helpall >conftest.help
305  if fgrep -e -size   conftest.help >/dev/null &&
306     fgrep -e -shrink conftest.help >/dev/null; then
307     a2_cv_com_acroread4=yes
308  else
309     a2_cv_com_acroread4=no
310  fi
311  rm -f conftest.help])
312  test "$a2_cv_com_acroread4" = yes && COM_acroread4=''
313fi
314
315# Outputting PDF
316ad_CHECK_PROGS((distill, ps2pdf))
317test "$COM_distill$COM_ps2pdf" = "##" && COM_PS2PDF="#"
318AC_SUBST(COM_PS2PDF)
319
320# PostScript delegation.  Check for psutils 1.17
321a2_PSUTILS(1, 17)
322
323# ROFF delegation
324ad_CHECK_PROG(grog,
325[a2ps works better with groff.
326Consider fetching groff at any ftp site proposing GNU programs])
327
328# Texinfo delegation
329ad_CHECK_PROGS((makeinfo, tex, latex))
330COM_TEXI="$COM_tex$COM_makeinfo$COM_dvips"
331COM_LATEX="$COM_latex$COM_dvips"
332AC_SUBST(COM_TEXI)
333AC_SUBST(COM_LATEX)
334
335## ---------- ##
336## Epilogue.  ##
337## ---------- ##
338
339# This is necessary so that .o files in LIBOBJS are also built via
340# the ANSI2KNR-filtering rules.
341LIBOBJS=`echo "$LIBOBJS" | sed 's/\.o /\$U.o /g;s/\.o$/\$U.o/'`
342# Autoconf 2.14a is not ready for libtool
343LTLIBOBJS=`echo "$LIBOBJS" | sed 's/\.o/\.lo/g'`
344AC_SUBST(LTLIBOBJS)
345LTALLOCA=`echo "$ALLOCA" | sed 's/\.o/\.lo/g'`
346AC_SUBST(LTALLOCA)
347
348# Shell scripts
349AC_CONFIG_FILES(contrib/card, chmod +x contrib/card)
350AC_CONFIG_FILES(contrib/fixps, chmod +x contrib/fixps)
351AC_CONFIG_FILES(contrib/pdiff, chmod +x contrib/pdiff)
352AC_CONFIG_FILES(contrib/psmandup, chmod +x contrib/psmandup)
353AC_CONFIG_FILES(contrib/psset, chmod +x contrib/psset)
354
355AC_OUTPUT(Makefile
356  src/Makefile
357  doc/Makefile
358  man/Makefile
359  tests/Makefile tests/defs
360  lib/Makefile
361  auxdir/Makefile
362  m4/Makefile
363  etc/Makefile etc/a2ps_cfg etc/a2ps-site.cfg
364  intl/Makefile po/Makefile.in
365  sheets/Makefile
366  encoding/Makefile
367  ps/Makefile
368  afm/Makefile
369  contrib/Makefile
370  contrib/sample/Makefile
371  contrib/emacs/Makefile
372  fonts/Makefile
373  ppd/Makefile)
374
375if test $MEDIUM = libpaper; then
376  libpaper_msg="
377*   (\`libpaper' means a2ps asks the medium to libpaper.  See man paperconf.)"
378fi
379
380cat <<EOF
381*****************************************************************
382* a2ps thinks it should be configured the following way:
383* - you print on \`$MEDIUM' paper$libpaper_msg
384* - your charset is \`$ENCODING'
385* - to send a JOB to the default printer, run \`$LPR job'
386* - to send a JOB to the printer PRINTER, run \`$LPR $LPR_QUEUE_OPTION PRINTER job'
387* - to ask \`file(1)' to follow the links, run \`$FILE_LINK'
388*   (\`file(1)' is used to guess the type of the files to print.)
389*
390* If a2ps is wrong somewhere, fix the \`System Dependent parameters'
391* in \`etc/a2ps-site.cfg'.  See the README file.
392*****************************************************************
393EOF
394