1AC_PREREQ(2.59)
2
3AC_INIT([pnm2ppa], 1.13, [pnm2ppa-users@lists.sourceforge.net])
4AC_CONFIG_HEADERS([config.h])
5AC_CONFIG_SRCDIR([ppa.c])
6AC_CANONICAL_BUILD
7AC_CANONICAL_HOST
8
9AM_MAINTAINER_MODE
10AM_INIT_AUTOMAKE([foreign no-exeext dist-bzip2])
11
12CFLAGS="${CFLAGS} -Wall -Wsign-compare -Wfloat-equal -Wformat-security -g"
13
14# Checks for programs.
15AC_PROG_CC
16
17AC_MSG_CHECKING([if cross compiling])
18if test "x$cross_compiling" = "xno"; then
19	CC_FOR_BUILD=${CC_FOR_BUILD-${CC-gcc}}
20	AC_MSG_RESULT([no])
21else
22	CC_FOR_BUILD=${CC_FOR_BUILD-gcc}
23	AC_MSG_RESULT([yes])
24fi
25
26AC_SUBST(CC_FOR_BUILD)
27
28#
29# do we need libm for 'sqrt' and 'pow'?
30#
31AC_SEARCH_LIBS(sqrt, m)
32AC_SEARCH_LIBS(pow, m)
33
34#
35# other things we rely on
36#
37AC_CHECK_FUNCS([memmove] [memset] [strcasecmp] [strchr] [strdup])
38AC_CHECK_HEADERS([sys/param.h])
39AC_C_INLINE
40AC_FUNC_MALLOC
41AC_HEADER_STDBOOL
42AC_TYPE_SIZE_T
43
44#
45# Some systems need a special library for 'getopt_long'
46# (for example MacOS and FreeBSD).
47#
48AC_SEARCH_LIBS(getopt_long, [gnugetopt iberty])
49
50#
51# check if the syslog feature is present
52# On some systems other than the libc is required to use this feature
53#
54AC_SEARCH_LIBS(syslog, [bsd socket inet])
55
56# do we have a syslog feature?
57if test "${ac_cv_search_syslog}" = "no"; then
58	# disable its usage
59	AC_DEFINE(__NO_SYSLOG__, 1, [no syslog])
60else
61	#
62	# okay, 'syslog' is present. But should we use it?
63	#
64	AC_MSG_CHECKING([whether to enable syslog])
65	AC_ARG_ENABLE(syslog,
66		AS_HELP_STRING([--enable-syslog], [enable syslog @<:@default=yes@:>@]),
67		[case "$enableval" in
68			y | yes) CONFIG_SYSLOG=yes ;;
69			*) CONFIG_SYSLOG=no ;;
70		esac],
71		[CONFIG_SYSLOG=yes])
72	AC_MSG_RESULT([${CONFIG_SYSLOG}])
73
74	if test "${CONFIG_SYSLOG}" = "yes"; then
75		AC_DEFINE(USE_SYSLOG, 1 , [use the syslog feature])
76	else
77		AC_DEFINE(__NO_SYSLOG__, 1, [no syslog])
78	fi
79fi
80
81#
82# Some things have to be done in accordance to the operating system
83#
84AC_MSG_CHECKING([operating system])
85case $host in
86	*-linux*)
87		AC_MSG_RESULT([Linux])
88		;;
89	*-solaris*)
90		AC_MSG_RESULT([SOLARIS])
91		AC_DEFINE(__NO_LOG_PERROR__, [], [absent])
92		;;
93	*-BeOS*)
94		AC_MSG_RESULT([BeOS])
95		# On BeOS the LDFLAGS should not be used.
96		AM_LDFLAGS=""
97		;;
98	*-darwin*)
99		AC_MSG_RESULT([Darwin/MacOS X])
100		CFLAGS="${CFLAGS} -no-cpp-precomp -traditional-cpp"
101		;;
102	*-bsd*)
103		AC_MSG_RESULT([FreeBSD])
104		;;
105	*)
106		AC_MSG_RESULT([unsupported operating system, pnm2ppa may fail])
107esac
108
109#
110# Debugging
111#
112AC_MSG_CHECKING([whether to enable debugging])
113AC_ARG_ENABLE(debug,
114	AS_HELP_STRING([--enable-debug], [enable debugging @<:@default=no@:>@]),
115		[case "$enableval" in
116		y | yes) CONFIG_DEBUG=yes ;;
117		*) CONFIG_DEBUG=no ;;
118	esac],
119	[CONFIG_DEBUG=no])
120AC_MSG_RESULT([${CONFIG_DEBUG}])
121if test "${CONFIG_DEBUG}" = "yes"; then
122	AC_DEFINE(DEBUG, 1, [debugging])
123	AM_CONDITIONAL(PNM2PPA_DEBUG, [true])
124	CFLAGS="${CFLAGS} -O1"
125else
126	CFLAGS="${CFLAGS} -O2 -DNDEBUG"
127	AM_CONDITIONAL(PNM2PPA_DEBUG, [false])
128fi
129
130#
131# define the compiled in language
132#
133AC_MSG_CHECKING([which language is to be used])
134AC_ARG_WITH([language],
135	AS_HELP_STRING([--with-language=EN | CZ | ES | FR | IT | NL],
136	[Compiled in language]),
137	[ppa_language="$withval"])
138
139# english language is the default
140if test -z "${ppa_language}"; then
141	# default is english
142	ppa_language=EN
143fi
144
145case "${ppa_language}" in
146	EN | en)
147		AC_DEFINE(LANG_EN, [], [english])
148		used_language="english"
149		;;
150	CZ | en)
151		AC_DEFINE(LANG_CZ, [], [cech])
152		used_language="cech"
153		;;
154	ES | es)
155		AC_DEFINE(LANG_ES, [], [espanol])
156		used_language="espanol"
157		;;
158	FR | fr)
159		AC_DEFINE(LANG_FR, [], [french])
160		used_language="french"
161		;;
162	IT | it)
163		AC_DEFINE(LANG_IT, [], [italian])
164		used_language="italian"
165		;;
166	NL | nl)
167		AC_DEFINE(LANG_NL, [], [dutch])
168		used_language="dutch"
169		;;
170	*)
171		AC_MSG_ERROR([Unsupported language])
172		;;
173esac
174
175AC_MSG_RESULT([${used_language}])
176
177AC_MSG_CHECKING([whether to build the 'parse_vlink' tool])
178AC_ARG_ENABLE(vlink,
179	AS_HELP_STRING([--enable-vlink], [enable building parse_vlink @<:@default=no@:>@]),
180	[case "$enableval" in
181		y | yes) CONFIG_VLINK=yes ;;
182		*) CONFIG_VLINK=no ;;
183	esac],
184	[CONFIG_VLINK=no])
185AC_MSG_RESULT([${CONFIG_VLINK}])
186
187if test "${CONFIG_VLINK}" = "yes"; then
188	AM_CONDITIONAL(BUILD_PARSE_VLINK, [true])
189else
190	AM_CONDITIONAL(BUILD_PARSE_VLINK, [false])
191fi
192
193AC_CONFIG_FILES(
194	[Makefile]
195	[ppa_protocol/Makefile]
196)
197AC_OUTPUT
198