d6cc911379d6c83fb174ab7c4877ac5cdd66b50e
[udpgate.git] / configure.ac
1 # $Id$
2 # Source file to generate "./configure" to prepare package for compilation
3 # Copyright (C) 2004 Jan Kratochvil <project-udpforward@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(udpforward,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 dnl Permit 'if NEVER' for Makefile.am-s; symbol 'FALSE' forbidden by automake
64 AM_CONDITIONAL(NEVER,false)
65
66 PERL=
67 AC_PATH_PROGS(PERL,perl5 perl)
68 AM_CONDITIONAL(HAVE_PERL,test -n "$PERL")
69
70 POD2MAN=
71 AC_PATH_PROGS(POD2MAN,pod2man)
72 AM_CONDITIONAL(HAVE_POD2MAN,[ test -n "$POD2MAN" ])
73 if test x$enable_man_pages = xyes;then
74         if test -z "$POD2MAN";then
75                 AC_MSG_ERROR([udpforward requires pod2man(1) for man pages; try --disable-man-pages.])
76         fi
77         if test -z "$PERL";then
78                 AC_MSG_ERROR([udpforward requires perl(1) for man pages; try --disable-man-pages.])
79         fi
80 elif test x$enable_man_pages != xno;then
81         if test -z "$POD2MAN";then
82                 AC_MSG_WARN([udpforward requires pod2man(1) for man pages by --enable-man-pages; mans will not be installed.])
83         fi
84         if test -z "$PERL";then
85                 AC_MSG_WARN([udpforward requires perl(1) for man pages by --enable-man-pages; mans will not be installed.])
86         fi
87 fi
88 AM_CONDITIONAL(ENABLE_MAN_PAGES,[ test x$enable_man_pages != xno -a -n "$POD2MAN" -a -n "$PERL" ])
89
90 dnl Separate 'acconfig.h' is no longer recommended by autoconf
91 AH_TOP([
92 #ifndef _UDPFORWARD_CONFIG_H
93 #define _UDPFORWARD_CONFIG_H 1
94 ])
95 AH_BOTTOM([
96 /* Do not place any stuff to AH_TOP as some of its includes
97  * would discard the effect of _FILE_OFFSET_BITS by AC_SYS_LARGEFILE.
98  */
99
100 #ifdef ENABLE_NLS
101 /* <libintl.h> is taken from "$(top_srcdir)/intl" if system doesn't provide intl */
102 #       include <libintl.h>
103 #define _(String) gettext (String)
104 #       ifdef gettext_noop
105 #               define N_(String) gettext_noop (String)
106 #       else
107 #               define N_(String) (String)
108 #       endif
109 #else /* !ENABLE_NLS */
110 /* Stubs that do something close enough.  */
111 #       define textdomain(String) (String)
112 #       define gettext(String) (String)
113 #       define dgettext(Domain,Message) (Message)
114 #       define dcgettext(Domain,Message,Type) (Message)
115 #       define bindtextdomain(Domain,Directory) (Domain)
116 #       define _(String) (String)
117 #       define N_(String) (String)
118 #endif /* !ENABLE_NLS */
119
120 #include <glib/gtypes.h>        /* for 'gchar' */
121 #define G_LOG_DOMAIN ((const gchar *)"UDPForward")
122
123 /**
124  * udpforward_printf_alloca:
125  * @format: Format string. See the sprintf() documentation.
126  * @args...: Arguments for @format. See the sprintf() documentation.
127  *
128  * Format the given format string @format as in sprintf().
129  * Output buffer is allocated automatically and it does not need to be deallocated
130  * manually as it is managed by g_alloca().
131  *
132  * @Returns: Formatted output string located in g_alloca() memory.
133  */
134 #define udpforward_printf_alloca(format,args...) ({ \
135                 gsize _udpforward_printf_alloca_size=udpforward_nv_printf_string_upper_bound((format) , ## args); \
136                 gchar *_udpforward_printf_alloca_r=g_alloca(_udpforward_printf_alloca_size); \
137                 g_snprintf(_udpforward_printf_alloca_r,_udpforward_printf_alloca_size,(format) , ## args); \
138                 (const gchar *)_udpforward_printf_alloca_r; \
139                 })
140 #include <stdarg.h>
141 #include <glib/gmessages.h>     /* for g_printf_string_upper_bound() */
142 static inline gsize udpforward_nv_printf_string_upper_bound(const gchar *format,...) G_GNUC_PRINTF(1,0) G_GNUC_UNUSED;
143 static inline gsize udpforward_nv_printf_string_upper_bound(const gchar *format,...)
144 {
145 va_list ap;
146 gsize r;
147
148         va_start(ap,format);
149         r=g_printf_string_upper_bound(format,ap);
150         va_end(ap);
151         return r;
152 }
153
154 #endif /* !_UDPFORWARD_CONFIG_H */
155 ])
156
157 dnl Do not use PKG_CHECK_MODULES() as it would not set 'GLIB_GENMARSHAL' etc.
158 AM_PATH_GLIB_2_0(,,[AC_MSG_ERROR([UDPForward requires glib-2.0 library.])],[])
159 dnl Force glib for the whole package
160 CFLAGS="$CFLAGS $GLIB_CFLAGS"
161 LIBS="$LIBS $GLIB_LIBS"
162
163 dnl popt
164 AC_CHECK_LIB(popt,poptParseArgvString,[POPT_LIBS="-lpopt"],[AC_MSG_ERROR([UDPForward requires popt library.])])
165 AC_SUBST(POPT_LIBS)
166
167 GLADE_W_INIT([
168         ./src/install/acquire/ui-gnome-interface.c
169         ./src/install/acquire/ui-gnome-interface.h
170         ./src/install/acquire/ui-gnome-callbacks.h
171         ./src/install/acquire/ui-gnome-support.c
172         ./src/install/acquire/ui-gnome-support.h
173         ])
174 AC_SUBST(GNOMEUI_CFLAGS)
175 AC_SUBST(GNOMEUI_LIBS)
176 AM_CONDITIONAL(HAVE_GLADE_WRITESOURCE,[ test "x$PATH_GLADE" != "x" ])
177 dnl Do not: AM_CONDITIONAL(BUILD_GLADESRC,[ test "xyes" = "x$BUILD_GLADESRC" ])
178 dnl as we do not need it as we are conditioned by ENABLE_INSTALL_PKG
179 GNOME_ADDON_LIBS=""
180 if test "x$BUILD_GLADESRC_TRUE" = "x"
181 then
182         AC_CHECK_LIB(Xi,XOpenDevice,GNOME_ADDON_LIBS="$GNOME_ADDON_LIBS -lXi")
183 fi
184 AC_SUBST(GNOME_ADDON_LIBS)
185
186 AC_SUBST(CFLAGS)
187 AC_SUBST(LIBS)
188
189 dnl "Makefile" output files MUST have pathnames incl./excl. "./" prefix as specified!
190 dnl FIXME: Why the rule above was written here?
191 AC_OUTPUT([
192 udpforward.spec
193 ./src/udpforward.pod.pl
194 ./po/Makefile.in
195 ./macros/glade-w.sh
196 Makefile
197 ./macros/Makefile
198 ./src/Makefile
199 ])
200
201 dnl FIXME: Why is "po/POTFILES" being substituted?
202 make -C src distfiles DISTFILES_PRINT=1 \
203                 |sed -n 's/^:DISTFILES: *\(.*\)$/\1/p'|tr ' ' '\n'|grep . >po/POTFILES.in
204 make -C po Makefile
205
206 echo done.