+User notification of the probe timeout.
[udpgate.git] / configure.ac
1 # $Id$
2 # Source file to generate "./configure" to prepare package for compilation
3 # Copyright (C) 2004 Jan Kratochvil <project-udpgate@jankratochvil.net>
4
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; exactly version 2 of June 1991 is required
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
18
19 AC_INIT(src/main.c)
20 dnl 2.53 for AM_GLIB_GNU_GETTEXT:
21 AC_PREREQ(2.53)
22 dnl Not yet present in: Red Hat autoconf-2.57-3
23 dnl AC_CONFIG_MACRO_DIR(macros)
24 AM_INIT_AUTOMAKE(udpgate,1.0cvs)
25 AM_CONFIG_HEADER(config.h)
26 AM_MAINTAINER_MODE
27 dnl Prevent "AC_TRY_COMPILE was called before AC_ISC_POSIX":
28 AC_ISC_POSIX
29 AM_DISABLE_STATIC
30 AM_ENABLE_SHARED
31 AM_PROG_LIBTOOL
32
33 dnl Workaround for autoconf-2.57:
34 m4_pattern_allow([AC_MSG_WARN])
35 m4_pattern_allow([AC_CHECK_LIB])
36 m4_pattern_allow([AC_CHECK_HEADERS])
37
38 dnl gettext localization.
39 dnl Use simpler AM_GLIB_GNU_GETTEXT instead of AM_GNU_GETTEXT
40 dnl as we depend on glib and glib requires system installed gettext anyway.
41 dnl http://lists.gnome.org/archives/gtk-devel-list/2003-April/msg00066.html
42 dnl Special 'GETTEXT_PACKAGE' is required by glib gettext.
43 ALL_LINGUAS="cs"
44 GETTEXT_PACKAGE="$PACKAGE"
45 AC_SUBST(GETTEXT_PACKAGE)
46 AM_GLIB_GNU_GETTEXT
47
48 dnl Do not discard 'CFLAGS' settings as they may have been passed us by rpmbuild(8)
49
50 dnl Define MAINTAINER_MODE in config.h.
51 if test "$USE_MAINTAINER_MODE" = "yes";then
52         AC_DEFINE(MAINTAINER_MODE,,[Turn even some software behaviour according to MAINTAINER_MODE.])
53         CFLAGS="$CFLAGS -ggdb3 -Wall -Wstrict-prototypes -Wsign-compare"
54         fi
55 dnl Some Makefiles use additional tests etc.
56 AM_CONDITIONAL(MAINTAINER_MODE,[test "$USE_MAINTAINER_MODE" = "yes"])
57
58
59 AC_ARG_ENABLE(man-pages,
60                 [  --enable-man-pages=no/yes/auto   pod2man(1) required for man pages (def.=yes)],,enable_man_pages=yes)
61
62
63 PERL=
64 AC_PATH_PROGS(PERL,perl5 perl)
65 AM_CONDITIONAL(HAVE_PERL,test -n "$PERL")
66
67 POD2MAN=
68 AC_PATH_PROGS(POD2MAN,pod2man)
69 AM_CONDITIONAL(HAVE_POD2MAN,[ test -n "$POD2MAN" ])
70 if test x$enable_man_pages = xyes;then
71         if test -z "$POD2MAN";then
72                 AC_MSG_ERROR([udpgate requires pod2man(1) for man pages; try --disable-man-pages.])
73         fi
74         if test -z "$PERL";then
75                 AC_MSG_ERROR([udpgate requires perl(1) for man pages; try --disable-man-pages.])
76         fi
77 elif test x$enable_man_pages != xno;then
78         if test -z "$POD2MAN";then
79                 AC_MSG_WARN([udpgate requires pod2man(1) for man pages by --enable-man-pages; mans will not be installed.])
80         fi
81         if test -z "$PERL";then
82                 AC_MSG_WARN([udpgate requires perl(1) for man pages by --enable-man-pages; mans will not be installed.])
83         fi
84 fi
85 AM_CONDITIONAL(ENABLE_MAN_PAGES,[ test x$enable_man_pages != xno -a -n "$POD2MAN" -a -n "$PERL" ])
86
87 dnl Separate 'acconfig.h' is no longer recommended by autoconf
88 AH_TOP([
89 #ifndef _UDPGATE_CONFIG_H
90 #define _UDPGATE_CONFIG_H 1
91 ])
92 AH_BOTTOM([
93 /* Do not place any stuff to AH_TOP as some of its includes
94  * would discard the effect of _FILE_OFFSET_BITS by AC_SYS_LARGEFILE.
95  */
96
97 #ifdef ENABLE_NLS
98 /* <libintl.h> is taken from "$(top_srcdir)/intl" if system doesn't provide intl */
99 #       include <libintl.h>
100 #define _(String) gettext (String)
101 #       ifdef gettext_noop
102 #               define N_(String) gettext_noop (String)
103 #       else
104 #               define N_(String) (String)
105 #       endif
106 #else /* !ENABLE_NLS */
107 /* Stubs that do something close enough.  */
108 #       define textdomain(String) (String)
109 #       define gettext(String) (String)
110 #       define dgettext(Domain,Message) (Message)
111 #       define dcgettext(Domain,Message,Type) (Message)
112 #       define bindtextdomain(Domain,Directory) (Domain)
113 #       define _(String) (String)
114 #       define N_(String) (String)
115 #endif /* !ENABLE_NLS */
116
117 #include <glib/gtypes.h>        /* for 'gchar' */
118 #define G_LOG_DOMAIN ((const gchar *)"UDPGate")
119
120 /**
121  * udpgate_newn:
122  * @objp: Variable with the pointer to the objects wished to be allocated.
123  * Original value is discarded.
124  * @n: Numbers of objects to be allocated. Value %0 is permitted (%NULL assignment effect).
125  *
126  * Macro to allocate @n objects of type *@objp and to assign the resulting pointer to @objp.
127  * Allocated memory may contain garbage.
128  *
129  * @Returns: Initialized @objp value as the memory of size #sizeof(typeof(*objp))*n.
130  * Value %NULL is returned iff @n==%0;
131  */
132 #define udpgate_newn(objp,n) ((objp)=g_new(typeof(*(objp)),(n)))
133
134 /**
135  * udpgate_new:
136  * @objp: Variable with the pointer to the object wished to be allocated.
137  * Original value is discarded.
138  *
139  * Macro to allocate one object of type *@objp and to assign the resulting pointer to @objp.
140  * Allocated memory may contain garbage. Equivalent to udpgate_newn(objp,1) call.
141  *
142  * @Returns: Initialized @objp value as the memory of size #sizeof(typeof(*objp)).
143  * Value %NULL is never returned.
144  */
145 #define udpgate_new(objp) (udpgate_newn((objp),1))
146
147 /**
148  * UDPGATE_MEMZERO:
149  * @objp: Pointer to the variable to be cleared.
150  *
151  * Clears the sizeof(*@objp) bytes of the given pointer with memset().
152  * Pass _pointer_ to the object to be cleared.
153  */
154 #define UDPGATE_MEMZERO(objp) (memset((objp),0,sizeof(*(objp))))
155
156 /**
157  * udpgate_printf_alloca:
158  * @format: Format string. See the sprintf() documentation.
159  * @args...: Arguments for @format. See the sprintf() documentation.
160  *
161  * Format the given format string @format as in sprintf().
162  * Output buffer is allocated automatically and it does not need to be deallocated
163  * manually as it is managed by g_alloca().
164  *
165  * @Returns: Formatted output string located in g_alloca() memory.
166  */
167 #include <glib/galloca.h>
168 #include <glib/gutils.h>
169 #define udpgate_printf_alloca(format,args...) ({ \
170                 gsize _udpgate_printf_alloca_size=udpgate_nv_printf_string_upper_bound((format) , ## args); \
171                 gchar *_udpgate_printf_alloca_r=g_alloca(_udpgate_printf_alloca_size); \
172                 g_snprintf(_udpgate_printf_alloca_r,_udpgate_printf_alloca_size,(format) , ## args); \
173                 (const gchar *)_udpgate_printf_alloca_r; \
174                 })
175 #include <stdarg.h>
176 #include <glib/gmessages.h>     /* for g_printf_string_upper_bound() */
177 static inline gsize udpgate_nv_printf_string_upper_bound(const gchar *format,...) G_GNUC_PRINTF(1,0) G_GNUC_UNUSED;
178 static inline gsize udpgate_nv_printf_string_upper_bound(const gchar *format,...)
179 {
180 va_list ap;
181 gsize r;
182
183         va_start(ap,format);
184         r=g_printf_string_upper_bound(format,ap);
185         va_end(ap);
186         return r;
187 }
188
189 #endif /* !_UDPGATE_CONFIG_H */
190 ])
191
192 dnl Do not use PKG_CHECK_MODULES() as it would not set 'GLIB_GENMARSHAL' etc.
193 AM_PATH_GLIB_2_0(,,[AC_MSG_ERROR([UDPGate requires glib-2.0 library.])],[])
194 dnl Force glib for the whole package
195 CFLAGS="$CFLAGS $GLIB_CFLAGS"
196 LIBS="$LIBS $GLIB_LIBS"
197
198 dnl popt
199 AC_CHECK_LIB(popt,poptParseArgvString,[POPT_LIBS="-lpopt"],[AC_MSG_ERROR([UDPGate requires popt library.])])
200 AC_SUBST(POPT_LIBS)
201
202 GLADE_W_INIT([
203         ./src/ui-gnome-interface.c
204         ./src/ui-gnome-interface.h
205         ./src/ui-gnome-callbacks.h
206         ./src/ui-gnome-support.c
207         ./src/ui-gnome-support.h
208         ])
209 AC_SUBST(GNOMEUI_CFLAGS)
210 AC_SUBST(GNOMEUI_LIBS)
211 if $have_gnome
212 then
213         AC_DEFINE(HAVE_GNOME,,[Compile Gnome support.])
214 fi
215 AM_CONDITIONAL(HAVE_GNOME,[ $have_gnome ])
216 AM_CONDITIONAL(HAVE_GLADE_WRITESOURCE,[ test "x$PATH_GLADE" != "x" ])
217 dnl Do not: AM_CONDITIONAL(BUILD_GLADESRC,[ test "xyes" = "x$BUILD_GLADESRC" ])
218 dnl as we do not need it as we are conditioned by ENABLE_INSTALL_PKG
219 GNOME_ADDON_LIBS=""
220 if test "x$BUILD_GLADESRC_TRUE" = "x"
221 then
222         AC_CHECK_LIB(Xi,XOpenDevice,GNOME_ADDON_LIBS="$GNOME_ADDON_LIBS -lXi")
223 fi
224 AC_SUBST(GNOME_ADDON_LIBS)
225
226 AC_SUBST(CFLAGS)
227 AC_SUBST(LIBS)
228
229 dnl "Makefile" output files MUST have pathnames incl./excl. "./" prefix as specified!
230 dnl FIXME: Why the rule above was written here?
231 AC_OUTPUT([
232 udpgate.spec
233 ./src/udpgate.pod.pl
234 ./po/Makefile.in
235 ./macros/glade-w.sh
236 Makefile
237 ./macros/Makefile
238 ./src/Makefile
239 ])
240
241 dnl FIXME: Why is "po/POTFILES" being substituted?
242 make -C src distfiles DISTFILES_PRINT=1 \
243                 |sed -n 's/^:DISTFILES: *\(.*\)$/\1/p'|tr ' ' '\n'|grep . >po/POTFILES.in
244 make -C po Makefile
245
246 echo done.