Cosmetic: Fixed checkstatic(1) compliance.
[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 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([udpgate requires pod2man(1) for man pages; try --disable-man-pages.])
76         fi
77         if test -z "$PERL";then
78                 AC_MSG_ERROR([udpgate 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([udpgate 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([udpgate 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 _UDPGATE_CONFIG_H
93 #define _UDPGATE_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 *)"UDPGate")
122
123 /**
124  * udpgate_newn:
125  * @objp: Variable with the pointer to the objects wished to be allocated.
126  * Original value is discarded.
127  * @n: Numbers of objects to be allocated. Value %0 is permitted (%NULL assignment effect).
128  *
129  * Macro to allocate @n objects of type *@objp and to assign the resulting pointer to @objp.
130  * Allocated memory may contain garbage.
131  *
132  * @Returns: Initialized @objp value as the memory of size #sizeof(typeof(*objp))*n.
133  * Value %NULL is returned iff @n==%0;
134  */
135 #define udpgate_newn(objp,n) ((objp)=g_new(typeof(*(objp)),(n)))
136
137 /**
138  * udpgate_new:
139  * @objp: Variable with the pointer to the object wished to be allocated.
140  * Original value is discarded.
141  *
142  * Macro to allocate one object of type *@objp and to assign the resulting pointer to @objp.
143  * Allocated memory may contain garbage. Equivalent to udpgate_newn(objp,1) call.
144  *
145  * @Returns: Initialized @objp value as the memory of size #sizeof(typeof(*objp)).
146  * Value %NULL is never returned.
147  */
148 #define udpgate_new(objp) (udpgate_newn((objp),1))
149
150 /**
151  * UDPGATE_MEMZERO:
152  * @objp: Pointer to the variable to be cleared.
153  *
154  * Clears the sizeof(*@objp) bytes of the given pointer with memset().
155  * Pass _pointer_ to the object to be cleared.
156  */
157 #define UDPGATE_MEMZERO(objp) (memset((objp),0,sizeof(*(objp))))
158
159 /**
160  * udpgate_printf_alloca:
161  * @format: Format string. See the sprintf() documentation.
162  * @args...: Arguments for @format. See the sprintf() documentation.
163  *
164  * Format the given format string @format as in sprintf().
165  * Output buffer is allocated automatically and it does not need to be deallocated
166  * manually as it is managed by g_alloca().
167  *
168  * @Returns: Formatted output string located in g_alloca() memory.
169  */
170 #include <glib/galloca.h>
171 #include <glib/gutils.h>
172 #define udpgate_printf_alloca(format,args...) ({ \
173                 gsize _udpgate_printf_alloca_size=udpgate_nv_printf_string_upper_bound((format) , ## args); \
174                 gchar *_udpgate_printf_alloca_r=g_alloca(_udpgate_printf_alloca_size); \
175                 g_snprintf(_udpgate_printf_alloca_r,_udpgate_printf_alloca_size,(format) , ## args); \
176                 (const gchar *)_udpgate_printf_alloca_r; \
177                 })
178 #include <stdarg.h>
179 #include <glib/gmessages.h>     /* for g_printf_string_upper_bound() */
180 static inline gsize udpgate_nv_printf_string_upper_bound(const gchar *format,...) G_GNUC_PRINTF(1,0) G_GNUC_UNUSED;
181 static inline gsize udpgate_nv_printf_string_upper_bound(const gchar *format,...)
182 {
183 va_list ap;
184 gsize r;
185
186         va_start(ap,format);
187         r=g_printf_string_upper_bound(format,ap);
188         va_end(ap);
189         return r;
190 }
191
192 #endif /* !_UDPGATE_CONFIG_H */
193 ])
194
195 dnl Do not use PKG_CHECK_MODULES() as it would not set 'GLIB_GENMARSHAL' etc.
196 AM_PATH_GLIB_2_0(,,[AC_MSG_ERROR([UDPGate requires glib-2.0 library.])],[])
197 dnl Force glib for the whole package
198 CFLAGS="$CFLAGS $GLIB_CFLAGS"
199 LIBS="$LIBS $GLIB_LIBS"
200
201 dnl popt
202 AC_CHECK_LIB(popt,poptParseArgvString,[POPT_LIBS="-lpopt"],[AC_MSG_ERROR([UDPGate requires popt library.])])
203 AC_SUBST(POPT_LIBS)
204
205 GLADE_W_INIT([
206         ./src/install/acquire/ui-gnome-interface.c
207         ./src/install/acquire/ui-gnome-interface.h
208         ./src/install/acquire/ui-gnome-callbacks.h
209         ./src/install/acquire/ui-gnome-support.c
210         ./src/install/acquire/ui-gnome-support.h
211         ])
212 AC_SUBST(GNOMEUI_CFLAGS)
213 AC_SUBST(GNOMEUI_LIBS)
214 AM_CONDITIONAL(HAVE_GLADE_WRITESOURCE,[ test "x$PATH_GLADE" != "x" ])
215 dnl Do not: AM_CONDITIONAL(BUILD_GLADESRC,[ test "xyes" = "x$BUILD_GLADESRC" ])
216 dnl as we do not need it as we are conditioned by ENABLE_INSTALL_PKG
217 GNOME_ADDON_LIBS=""
218 if test "x$BUILD_GLADESRC_TRUE" = "x"
219 then
220         AC_CHECK_LIB(Xi,XOpenDevice,GNOME_ADDON_LIBS="$GNOME_ADDON_LIBS -lXi")
221 fi
222 AC_SUBST(GNOME_ADDON_LIBS)
223
224 AC_SUBST(CFLAGS)
225 AC_SUBST(LIBS)
226
227 dnl "Makefile" output files MUST have pathnames incl./excl. "./" prefix as specified!
228 dnl FIXME: Why the rule above was written here?
229 AC_OUTPUT([
230 udpgate.spec
231 ./src/udpgate.pod.pl
232 ./po/Makefile.in
233 ./macros/glade-w.sh
234 Makefile
235 ./macros/Makefile
236 ./src/Makefile
237 ])
238
239 dnl FIXME: Why is "po/POTFILES" being substituted?
240 make -C src distfiles DISTFILES_PRINT=1 \
241                 |sed -n 's/^:DISTFILES: *\(.*\)$/\1/p'|tr ' ' '\n'|grep . >po/POTFILES.in
242 make -C po Makefile
243
244 echo done.