1dnl Process this file with autoconf to produce a configure script.
2AC_INIT([catdoc],[0.95])
3dnl Checks for programs.
4AC_PROG_CC
5case ${CC} in
6*djgpp*) ac_cv_c_bigendian=no
7		ac_cv_func_setvbuf_reversed=no
8;;
9*)
10;;
11esac
12AC_C_BIGENDIAN
13AC_PROG_INSTALL
14if test "$enable_wordview" != "no" ;then
15AC_ARG_WITH(wish,[  --with-wish=fullpath	  allows to specify full path for Tk interpreter to
16			  avoid checking, which requires X],
17WISH=$withval,[
18AC_PATH_PROGS(WISH,wish wish8.1 wish8.2 wish8.3 wish8.4)
19if test -n "$WISH"; then
20AC_CACHE_CHECK(checking if wish version is 8.1 or above ,[ac_cv_GOOD_WISH],
21changequote(<<,>>)dnl
22<<changequote(<<,>>)dnl>>
23<<echo 'if {[info tclversion]>=7.6} {
24 puts -nonewline "yes"
25} else {
26 puts -nonewline "no"
27}
28exit'>tmp$$.tcl
29ac_cv_GOOD_WISH=`$WISH tmp$$.tcl`
30rm tmp$$.tcl >>
31<<changequote([, ])dnl>>
32changequote([, ])dnl
33)
34if test "$ac_cv_GOOD_WISH" != yes; then
35enable_wordview=no
36fi
37fi
38])
39fi
40AC_ARG_WITH(install-root,[  --with-install-root=path
41			   allows to install catdoc into other directory
42			   than compilied-in path points to],installroot=$withval,)
43replsuffix=.replchars
44specsuffix=.specchars
45targetcharset=koi8-r
46sourcecharset=cp1251
47AC_ARG_WITH(input,[  --with-input=charset 	   set default charset to expect in 8-bit word files],sourcecharset=$withval,sourcecharset=cp1251)
48AC_ARG_WITH(output,[  --with-output=charset	   set default charset to output],targetcharset=$withval,targetcharset=koi8-r)
49if test "$targetcharset" = "utf-8";  then
50charsetcheck="$sourcecharset.txt"
51else
52charsetcheck="$sourcecharset.txt $targetcharset.txt"
53fi
54AC_ARG_ENABLE(charset-check,[  --disable-charset-check  allow make in charsets directory to succeed
55			   even if files for default charsets are not found],[if test "$enable_charset_check" = no;
56then
57 charsetcheck=""
58fi])
59test -z "$manext" && manext=.1
60test -z "$man1dir" && man1dir=\${prefix}/man/man1
61if test -n "$WISH"; then
62AC_ARG_ENABLE(wordview,[  --disable-wordview	   Do not install tcl-tk
63						wrapper],[:],)
64fi
65if test "$enable_wordview" = no; then
66	 installtargets=install-catdoc
67	  buildtargets="catdoc xls2csv catppt"
68else
69	installtargets="install-catdoc install-wordview"
70	buildtargets="catdoc xls2csv catppt wordview"
71fi
72dnl Checks for libraries.
73
74dnl Checks for header files.
75AC_HEADER_STDC
76AC_CHECK_HEADERS([unistd.h stdint.h])
77if test -z "$enable_langinfo"; then
78enable_langinfo=yes
79fi
80AC_ARG_ENABLE(langinfo,[  --disable-langinfo     Do not use system
81locale for output encoding],[
82	if test "$enable_langinfo" = yes; then
83        AC_CHECK_HEADER(langinfo.h,[
84 AC_MSG_CHECKING([For nl_langinfo(CODESET)])
85AC_TRY_COMPILE([#include <langinfo.h>],[nl_langinfo(CODESET);],[
86               AC_DEFINE(HAVE_LANGINFO,1,[Define this if you have XPG4 comliant nl_langinfo, which accepts CODESET argument])
87               enable_langinfo=yes
88               ],[enable_langinfo=no])
89AC_MSG_RESULT([$enable_langinfo])
90               ],[enable_langinfo=no])
91
92	fi],[])
93
94
95dnl Checks for typedefs, structures, and compiler characteristics.
96AC_C_CONST
97
98dnl Checks for library functions.
99AC_FUNC_SETVBUF_REVERSED
100
101#if test "$GCC" = "yes"; then
102#	CFLAGS="-g -O2 -Wall"
103#fi
104
105AC_DEFINE_UNQUOTED([SOURCE_CHARSET],"$sourcecharset",[Character encoding used by default for 8-bit source files])
106AC_DEFINE_UNQUOTED([TARGET_CHARSET],"$targetcharset",[Output character encoding used by default, if impossible to determine encoding from locale])
107AC_DEFINE_UNQUOTED([SPEC_EXT],"$specsuffix",[Suffix for files with special symbols map (ones to be replaced regardless of availability in target encoding)])
108AC_DEFINE_UNQUOTED([REPL_EXT],"$replsuffix",[Suffix for symbols replacement map (what to do with symbols, which are not available in the target encoding)])
109AC_DEFINE_UNQUOTED([UNKNOWN_CHAR],"?",[Symbol to represent character which is not available either in target encoding or in replacement map])
110AC_CHECK_FUNCS(strdup strtol)
111AC_REPLACE_FUNCS(strftime)
112AC_SUBST(specsuffix)
113AC_SUBST(replsuffix)
114AC_SUBST(buildtargets)
115AC_SUBST(installtargets)
116AC_SUBST(targetcharset)
117AC_SUBST(sourcecharset)
118AC_SUBST(man1dir)
119AC_SUBST(manext)
120AC_SUBST(charsetcheck)
121AC_SUBST(installroot)
122AC_SUBST(PACKAGE_VERSION)
123AC_SUBST(CFLAGS)
124AC_SUBST(WORDS_BIGENDIAN)
125AC_CONFIG_HEADER(src/config.h)
126AC_OUTPUT(doc/Makefile charsets/Makefile src/Makefile Makefile doc/catdoc.1 doc/xls2csv.1 doc/wordview.1 doc/catppt.1)
127