summaryrefslogtreecommitdiff
path: root/configure.ac
blob: 0307ff367dbeda3bbb27b0b3dcd071457d88c867 (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
AC_PREREQ(2.59)

AC_INIT([pnm2ppa], 1.13, [pnm2ppa-users@lists.sourceforge.net])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_SRCDIR([ppa.c])
AC_CANONICAL_BUILD
AC_CANONICAL_HOST

AM_MAINTAINER_MODE
AM_INIT_AUTOMAKE([foreign no-exeext dist-bzip2])

CFLAGS="${CFLAGS} -Wall -Wsign-compare -Wfloat-equal -Wformat-security -g"

# Checks for programs.
AC_PROG_CC

AC_MSG_CHECKING([if cross compiling])
if test "x$cross_compiling" = "xno"; then
	CC_FOR_BUILD=${CC_FOR_BUILD-${CC-gcc}}
	AC_MSG_RESULT([no])
else
	CC_FOR_BUILD=${CC_FOR_BUILD-gcc}
	AC_MSG_RESULT([yes])
fi

AC_SUBST(CC_FOR_BUILD)

#
# do we need libm for 'sqrt' and 'pow'?
#
AC_SEARCH_LIBS(sqrt, m)
AC_SEARCH_LIBS(pow, m)

#
# other things we rely on
#
AC_CHECK_FUNCS([memmove] [memset] [strcasecmp] [strchr] [strdup])
AC_CHECK_HEADERS([sys/param.h])
AC_C_INLINE
AC_FUNC_MALLOC
AC_HEADER_STDBOOL
AC_TYPE_SIZE_T

#
# Some systems need a special library for 'getopt_long'
# (for example MacOS and FreeBSD).
#
AC_SEARCH_LIBS(getopt_long, [gnugetopt iberty])

#
# check if the syslog feature is present
# On some systems other than the libc is required to use this feature
#
AC_SEARCH_LIBS(syslog, [bsd socket inet])

# do we have a syslog feature?
if test "${ac_cv_search_syslog}" = "no"; then
	# disable its usage
	AC_DEFINE(__NO_SYSLOG__, 1, [no syslog])
else
	#
	# okay, 'syslog' is present. But should we use it?
	#
	AC_MSG_CHECKING([whether to enable syslog])
	AC_ARG_ENABLE(syslog,
		AS_HELP_STRING([--enable-syslog], [enable syslog @<:@default=yes@:>@]),
		[case "$enableval" in
			y | yes) CONFIG_SYSLOG=yes ;;
			*) CONFIG_SYSLOG=no ;;
		esac],
		[CONFIG_SYSLOG=yes])
	AC_MSG_RESULT([${CONFIG_SYSLOG}])

	if test "${CONFIG_SYSLOG}" = "yes"; then
		AC_DEFINE(USE_SYSLOG, 1 , [use the syslog feature])
	else
		AC_DEFINE(__NO_SYSLOG__, 1, [no syslog])
	fi
fi

#
# Some things have to be done in accordance to the operating system
#
AC_MSG_CHECKING([operating system])
case $host in
	*-linux*)
		AC_MSG_RESULT([Linux])
		;;
	*-solaris*)
		AC_MSG_RESULT([SOLARIS])
		AC_DEFINE(__NO_LOG_PERROR__, [], [absent])
		;;
	*-BeOS*)
		AC_MSG_RESULT([BeOS])
		# On BeOS the LDFLAGS should not be used.
		AM_LDFLAGS=""
		;;
	*-darwin*)
		AC_MSG_RESULT([Darwin/MacOS X])
		CFLAGS="${CFLAGS} -no-cpp-precomp -traditional-cpp"
		;;
	*-bsd*)
		AC_MSG_RESULT([FreeBSD])
		;;
	*)
		AC_MSG_RESULT([unsupported operating system, pnm2ppa may fail])
esac

#
# Debugging
#
AC_MSG_CHECKING([whether to enable debugging])
AC_ARG_ENABLE(debug,
	AS_HELP_STRING([--enable-debug], [enable debugging @<:@default=no@:>@]),
		[case "$enableval" in
		y | yes) CONFIG_DEBUG=yes ;;
		*) CONFIG_DEBUG=no ;;
	esac],
	[CONFIG_DEBUG=no])
AC_MSG_RESULT([${CONFIG_DEBUG}])
if test "${CONFIG_DEBUG}" = "yes"; then
	AC_DEFINE(DEBUG, 1, [debugging])
	AM_CONDITIONAL(PNM2PPA_DEBUG, [true])
	CFLAGS="${CFLAGS} -O1"
else
	CFLAGS="${CFLAGS} -O2 -DNDEBUG"
	AM_CONDITIONAL(PNM2PPA_DEBUG, [false])
fi

#
# define the compiled in language
#
AC_MSG_CHECKING([which language is to be used])
AC_ARG_WITH([language],
	AS_HELP_STRING([--with-language=EN | CZ | ES | FR | IT | NL],
	[Compiled in language]),
	[ppa_language="$withval"])

# english language is the default
if test -z "${ppa_language}"; then
	# default is english
	ppa_language=EN
fi

case "${ppa_language}" in
	EN | en)
		AC_DEFINE(LANG_EN, [], [english])
		used_language="english"
		;;
	CZ | en)
		AC_DEFINE(LANG_CZ, [], [cech])
		used_language="cech"
		;;
	ES | es)
		AC_DEFINE(LANG_ES, [], [espanol])
		used_language="espanol"
		;;
	FR | fr)
		AC_DEFINE(LANG_FR, [], [french])
		used_language="french"
		;;
	IT | it)
		AC_DEFINE(LANG_IT, [], [italian])
		used_language="italian"
		;;
	NL | nl)
		AC_DEFINE(LANG_NL, [], [dutch])
		used_language="dutch"
		;;
	*)
		AC_MSG_ERROR([Unsupported language])
		;;
esac

AC_MSG_RESULT([${used_language}])

AC_MSG_CHECKING([whether to build the 'parse_vlink' tool])
AC_ARG_ENABLE(vlink,
	AS_HELP_STRING([--enable-vlink], [enable building parse_vlink @<:@default=no@:>@]),
	[case "$enableval" in
		y | yes) CONFIG_VLINK=yes ;;
		*) CONFIG_VLINK=no ;;
	esac],
	[CONFIG_VLINK=no])
AC_MSG_RESULT([${CONFIG_VLINK}])

if test "${CONFIG_VLINK}" = "yes"; then
	AM_CONDITIONAL(BUILD_PARSE_VLINK, [true])
else
	AM_CONDITIONAL(BUILD_PARSE_VLINK, [false])
fi

AC_CONFIG_FILES(
	[Makefile]
	[ppa_protocol/Makefile]
)
AC_OUTPUT