+Option --enable-bundle for the fully static built single-file binary.
[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 AC_ARG_ENABLE(bundle,
62                 [  --enable-bundle                  Build single binary containing locale and init.d files (def.=no)],,enable_bundle=no)
63
64
65 AM_CONDITIONAL(ENABLE_BUNDLE,[ test "x$enable_bundle" = "xyes" ])
66 if test "x$enable_bundle" = "xyes"
67 then
68         AC_DEFINE(ENABLE_BUNDLE,,[Build single binary containing locale and init.d files.])
69 fi
70
71 PERL=
72 AC_PATH_PROGS(PERL,perl5 perl)
73 AM_CONDITIONAL(HAVE_PERL,test -n "$PERL")
74
75 POD2MAN=
76 AC_PATH_PROGS(POD2MAN,pod2man)
77 AM_CONDITIONAL(HAVE_POD2MAN,[ test -n "$POD2MAN" ])
78 if test x$enable_man_pages = xyes;then
79         if test -z "$POD2MAN";then
80                 AC_MSG_ERROR([udpgate requires pod2man(1) for man pages; try --disable-man-pages.])
81         fi
82         if test -z "$PERL";then
83                 AC_MSG_ERROR([udpgate requires perl(1) for man pages; try --disable-man-pages.])
84         fi
85 elif test x$enable_man_pages != xno;then
86         if test -z "$POD2MAN";then
87                 AC_MSG_WARN([udpgate requires pod2man(1) for man pages by --enable-man-pages; mans will not be installed.])
88         fi
89         if test -z "$PERL";then
90                 AC_MSG_WARN([udpgate requires perl(1) for man pages by --enable-man-pages; mans will not be installed.])
91         fi
92 fi
93 AM_CONDITIONAL(ENABLE_MAN_PAGES,[ test x$enable_man_pages != xno -a -n "$POD2MAN" -a -n "$PERL" ])
94
95 dnl Separate 'acconfig.h' is no longer recommended by autoconf
96 AH_TOP([
97 #ifndef _UDPGATE_CONFIG_H
98 #define _UDPGATE_CONFIG_H 1
99 ])
100 AH_BOTTOM([
101 /* Do not place any stuff to AH_TOP as some of its includes
102  * would discard the effect of _FILE_OFFSET_BITS by AC_SYS_LARGEFILE.
103  */
104
105 #ifdef ENABLE_NLS
106 /* <libintl.h> is taken from "$(top_srcdir)/intl" if system doesn't provide intl */
107 #       include <libintl.h>
108 #define _(String) gettext (String)
109 #       ifdef gettext_noop
110 #               define N_(String) gettext_noop (String)
111 #       else
112 #               define N_(String) (String)
113 #       endif
114 #else /* !ENABLE_NLS */
115 /* Stubs that do something close enough.  */
116 #       define textdomain(String) (String)
117 #       define gettext(String) (String)
118 #       define dgettext(Domain,Message) (Message)
119 #       define dcgettext(Domain,Message,Type) (Message)
120 #       define bindtextdomain(Domain,Directory) (Domain)
121 #       define _(String) (String)
122 #       define N_(String) (String)
123 #endif /* !ENABLE_NLS */
124
125 #include <glib/gtypes.h>        /* for 'gchar' */
126 #define G_LOG_DOMAIN ((const gchar *)"UDPGate")
127
128 /**
129  * udpgate_newn:
130  * @objp: Variable with the pointer to the objects wished to be allocated.
131  * Original value is discarded.
132  * @n: Numbers of objects to be allocated. Value %0 is permitted (%NULL assignment effect).
133  *
134  * Macro to allocate @n objects of type *@objp and to assign the resulting pointer to @objp.
135  * Allocated memory may contain garbage.
136  *
137  * @Returns: Initialized @objp value as the memory of size #sizeof(typeof(*objp))*n.
138  * Value %NULL is returned iff @n==%0;
139  */
140 #define udpgate_newn(objp,n) ((objp)=g_new(typeof(*(objp)),(n)))
141
142 /**
143  * udpgate_new:
144  * @objp: Variable with the pointer to the object wished to be allocated.
145  * Original value is discarded.
146  *
147  * Macro to allocate one object of type *@objp and to assign the resulting pointer to @objp.
148  * Allocated memory may contain garbage. Equivalent to udpgate_newn(objp,1) call.
149  *
150  * @Returns: Initialized @objp value as the memory of size #sizeof(typeof(*objp)).
151  * Value %NULL is never returned.
152  */
153 #define udpgate_new(objp) (udpgate_newn((objp),1))
154
155 /**
156  * UDPGATE_MEMZERO:
157  * @objp: Pointer to the variable to be cleared.
158  *
159  * Clears the sizeof(*@objp) bytes of the given pointer with memset().
160  * Pass _pointer_ to the object to be cleared.
161  */
162 #define UDPGATE_MEMZERO(objp) (memset((objp),0,sizeof(*(objp))))
163
164 /**
165  * udpgate_printf_alloca:
166  * @format: Format string. See the sprintf() documentation.
167  * @args...: Arguments for @format. See the sprintf() documentation.
168  *
169  * Format the given format string @format as in sprintf().
170  * Output buffer is allocated automatically and it does not need to be deallocated
171  * manually as it is managed by g_alloca().
172  *
173  * @Returns: Formatted output string located in g_alloca() memory.
174  */
175 #include <glib/galloca.h>
176 #include <glib/gutils.h>
177 #define udpgate_printf_alloca(format,args...) ({ \
178                 gsize _udpgate_printf_alloca_size=udpgate_nv_printf_string_upper_bound((format) , ## args); \
179                 gchar *_udpgate_printf_alloca_r=g_alloca(_udpgate_printf_alloca_size); \
180                 g_snprintf(_udpgate_printf_alloca_r,_udpgate_printf_alloca_size,(format) , ## args); \
181                 (const gchar *)_udpgate_printf_alloca_r; \
182                 })
183 #include <stdarg.h>
184 #include <glib/gmessages.h>     /* for g_printf_string_upper_bound() */
185 static inline gsize udpgate_nv_printf_string_upper_bound(const gchar *format,...) G_GNUC_PRINTF(1,0) G_GNUC_UNUSED;
186 static inline gsize udpgate_nv_printf_string_upper_bound(const gchar *format,...)
187 {
188 va_list ap;
189 gsize r;
190
191         va_start(ap,format);
192         r=g_printf_string_upper_bound(format,ap);
193         va_end(ap);
194         return r;
195 }
196
197 #endif /* !_UDPGATE_CONFIG_H */
198 ])
199
200 dnl Do not use PKG_CHECK_MODULES() as it would not set 'GLIB_GENMARSHAL' etc.
201 AM_PATH_GLIB_2_0(,,[AC_MSG_ERROR([UDPGate requires glib-2.0 library.])],[])
202 dnl Force glib for the whole package
203 CFLAGS="$CFLAGS $GLIB_CFLAGS"
204 LIBS="$LIBS $GLIB_LIBS"
205
206 dnl popt
207 AC_CHECK_LIB(popt,poptParseArgvString,[POPT_LIBS="-lpopt"],[AC_MSG_ERROR([UDPGate requires popt library.])])
208 AC_SUBST(POPT_LIBS)
209
210 GLADE_W_INIT([
211         ./src/ui-gnome-interface.c
212         ./src/ui-gnome-interface.h
213         ./src/ui-gnome-callbacks.h
214         ./src/ui-gnome-support.c
215         ./src/ui-gnome-support.h
216         ])
217 AC_SUBST(GNOMEUI_CFLAGS)
218 AC_SUBST(GNOMEUI_LIBS)
219 if $have_gnome
220 then
221         AC_DEFINE(HAVE_GNOME,,[Compile Gnome support.])
222 fi
223 AM_CONDITIONAL(HAVE_GNOME,[ $have_gnome ])
224 AM_CONDITIONAL(HAVE_GLADE_WRITESOURCE,[ test "x$PATH_GLADE" != "x" ])
225 dnl Do not: AM_CONDITIONAL(BUILD_GLADESRC,[ test "xyes" = "x$BUILD_GLADESRC" ])
226 dnl as we do not need it as we are conditioned by ENABLE_INSTALL_PKG
227 GNOME_ADDON_LIBS=""
228 if test "x$BUILD_GLADESRC_TRUE" = "x"
229 then
230         AC_CHECK_LIB(Xi,XOpenDevice,GNOME_ADDON_LIBS="$GNOME_ADDON_LIBS -lXi")
231 fi
232 AC_SUBST(GNOME_ADDON_LIBS)
233
234 AC_SUBST(CFLAGS)
235 AC_SUBST(LIBS)
236
237 dnl "Makefile" output files MUST have pathnames incl./excl. "./" prefix as specified!
238 dnl FIXME: Why the rule above was written here?
239 AC_OUTPUT([
240 udpgate.spec
241 ./src/udpgate.pod.pl
242 ./po/Makefile.in
243 ./macros/glade-w.sh
244 Makefile
245 ./macros/Makefile
246 ./init.d/Makefile
247 ./src/Makefile
248 ])
249
250 dnl FIXME: Why is "po/POTFILES" being substituted?
251 make -C src distfiles DISTFILES_PRINT=1 \
252                 |sed -n 's/^:DISTFILES: *\(.*\)$/\1/p'|tr ' ' '\n'|grep . >po/POTFILES.in
253 make -C po Makefile
254
255 echo done.