+Option --enable-bundle for the fully static built single-file binary.
[udpgate.git] / configure.ac
index d6cc911..ac82242 100644 (file)
@@ -1,6 +1,6 @@
 # $Id$
 # Source file to generate "./configure" to prepare package for compilation
-# Copyright (C) 2004 Jan Kratochvil <project-udpforward@jankratochvil.net>
+# Copyright (C) 2004 Jan Kratochvil <project-udpgate@jankratochvil.net>
 # 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -21,7 +21,7 @@ dnl 2.53 for AM_GLIB_GNU_GETTEXT:
 AC_PREREQ(2.53)
 dnl Not yet present in: Red Hat autoconf-2.57-3
 dnl AC_CONFIG_MACRO_DIR(macros)
-AM_INIT_AUTOMAKE(udpforward,1.0cvs)
+AM_INIT_AUTOMAKE(udpgate,1.0cvs)
 AM_CONFIG_HEADER(config.h)
 AM_MAINTAINER_MODE
 dnl Prevent "AC_TRY_COMPILE was called before AC_ISC_POSIX":
@@ -58,10 +58,15 @@ AM_CONDITIONAL(MAINTAINER_MODE,[test "$USE_MAINTAINER_MODE" = "yes"])
 
 AC_ARG_ENABLE(man-pages,
                [  --enable-man-pages=no/yes/auto   pod2man(1) required for man pages (def.=yes)],,enable_man_pages=yes)
+AC_ARG_ENABLE(bundle,
+               [  --enable-bundle                  Build single binary containing locale and init.d files (def.=no)],,enable_bundle=no)
 
 
-dnl Permit 'if NEVER' for Makefile.am-s; symbol 'FALSE' forbidden by automake
-AM_CONDITIONAL(NEVER,false)
+AM_CONDITIONAL(ENABLE_BUNDLE,[ test "x$enable_bundle" = "xyes" ])
+if test "x$enable_bundle" = "xyes"
+then
+       AC_DEFINE(ENABLE_BUNDLE,,[Build single binary containing locale and init.d files.])
+fi
 
 PERL=
 AC_PATH_PROGS(PERL,perl5 perl)
@@ -72,25 +77,25 @@ AC_PATH_PROGS(POD2MAN,pod2man)
 AM_CONDITIONAL(HAVE_POD2MAN,[ test -n "$POD2MAN" ])
 if test x$enable_man_pages = xyes;then
        if test -z "$POD2MAN";then
-               AC_MSG_ERROR([udpforward requires pod2man(1) for man pages; try --disable-man-pages.])
+               AC_MSG_ERROR([udpgate requires pod2man(1) for man pages; try --disable-man-pages.])
        fi
        if test -z "$PERL";then
-               AC_MSG_ERROR([udpforward requires perl(1) for man pages; try --disable-man-pages.])
+               AC_MSG_ERROR([udpgate requires perl(1) for man pages; try --disable-man-pages.])
        fi
 elif test x$enable_man_pages != xno;then
        if test -z "$POD2MAN";then
-               AC_MSG_WARN([udpforward requires pod2man(1) for man pages by --enable-man-pages; mans will not be installed.])
+               AC_MSG_WARN([udpgate requires pod2man(1) for man pages by --enable-man-pages; mans will not be installed.])
        fi
        if test -z "$PERL";then
-               AC_MSG_WARN([udpforward requires perl(1) for man pages by --enable-man-pages; mans will not be installed.])
+               AC_MSG_WARN([udpgate requires perl(1) for man pages by --enable-man-pages; mans will not be installed.])
        fi
 fi
 AM_CONDITIONAL(ENABLE_MAN_PAGES,[ test x$enable_man_pages != xno -a -n "$POD2MAN" -a -n "$PERL" ])
 
 dnl Separate 'acconfig.h' is no longer recommended by autoconf
 AH_TOP([
-#ifndef _UDPFORWARD_CONFIG_H
-#define _UDPFORWARD_CONFIG_H 1
+#ifndef _UDPGATE_CONFIG_H
+#define _UDPGATE_CONFIG_H 1
 ])
 AH_BOTTOM([
 /* Do not place any stuff to AH_TOP as some of its includes
@@ -118,10 +123,46 @@ AH_BOTTOM([
 #endif /* !ENABLE_NLS */
 
 #include <glib/gtypes.h>       /* for 'gchar' */
-#define G_LOG_DOMAIN ((const gchar *)"UDPForward")
+#define G_LOG_DOMAIN ((const gchar *)"UDPGate")
+
+/**
+ * udpgate_newn:
+ * @objp: Variable with the pointer to the objects wished to be allocated.
+ * Original value is discarded.
+ * @n: Numbers of objects to be allocated. Value %0 is permitted (%NULL assignment effect).
+ *
+ * Macro to allocate @n objects of type *@objp and to assign the resulting pointer to @objp.
+ * Allocated memory may contain garbage.
+ *
+ * @Returns: Initialized @objp value as the memory of size #sizeof(typeof(*objp))*n.
+ * Value %NULL is returned iff @n==%0;
+ */
+#define udpgate_newn(objp,n) ((objp)=g_new(typeof(*(objp)),(n)))
+
+/**
+ * udpgate_new:
+ * @objp: Variable with the pointer to the object wished to be allocated.
+ * Original value is discarded.
+ *
+ * Macro to allocate one object of type *@objp and to assign the resulting pointer to @objp.
+ * Allocated memory may contain garbage. Equivalent to udpgate_newn(objp,1) call.
+ *
+ * @Returns: Initialized @objp value as the memory of size #sizeof(typeof(*objp)).
+ * Value %NULL is never returned.
+ */
+#define udpgate_new(objp) (udpgate_newn((objp),1))
 
 /**
- * udpforward_printf_alloca:
+ * UDPGATE_MEMZERO:
+ * @objp: Pointer to the variable to be cleared.
+ *
+ * Clears the sizeof(*@objp) bytes of the given pointer with memset().
+ * Pass _pointer_ to the object to be cleared.
+ */
+#define UDPGATE_MEMZERO(objp) (memset((objp),0,sizeof(*(objp))))
+
+/**
+ * udpgate_printf_alloca:
  * @format: Format string. See the sprintf() documentation.
  * @args...: Arguments for @format. See the sprintf() documentation.
  *
@@ -131,16 +172,18 @@ AH_BOTTOM([
  *
  * @Returns: Formatted output string located in g_alloca() memory.
  */
-#define udpforward_printf_alloca(format,args...) ({ \
-               gsize _udpforward_printf_alloca_size=udpforward_nv_printf_string_upper_bound((format) , ## args); \
-               gchar *_udpforward_printf_alloca_r=g_alloca(_udpforward_printf_alloca_size); \
-               g_snprintf(_udpforward_printf_alloca_r,_udpforward_printf_alloca_size,(format) , ## args); \
-               (const gchar *)_udpforward_printf_alloca_r; \
+#include <glib/galloca.h>
+#include <glib/gutils.h>
+#define udpgate_printf_alloca(format,args...) ({ \
+               gsize _udpgate_printf_alloca_size=udpgate_nv_printf_string_upper_bound((format) , ## args); \
+               gchar *_udpgate_printf_alloca_r=g_alloca(_udpgate_printf_alloca_size); \
+               g_snprintf(_udpgate_printf_alloca_r,_udpgate_printf_alloca_size,(format) , ## args); \
+               (const gchar *)_udpgate_printf_alloca_r; \
                })
 #include <stdarg.h>
 #include <glib/gmessages.h>    /* for g_printf_string_upper_bound() */
-static inline gsize udpforward_nv_printf_string_upper_bound(const gchar *format,...) G_GNUC_PRINTF(1,0) G_GNUC_UNUSED;
-static inline gsize udpforward_nv_printf_string_upper_bound(const gchar *format,...)
+static inline gsize udpgate_nv_printf_string_upper_bound(const gchar *format,...) G_GNUC_PRINTF(1,0) G_GNUC_UNUSED;
+static inline gsize udpgate_nv_printf_string_upper_bound(const gchar *format,...)
 {
 va_list ap;
 gsize r;
@@ -151,28 +194,33 @@ gsize r;
        return r;
 }
 
-#endif /* !_UDPFORWARD_CONFIG_H */
+#endif /* !_UDPGATE_CONFIG_H */
 ])
 
 dnl Do not use PKG_CHECK_MODULES() as it would not set 'GLIB_GENMARSHAL' etc.
-AM_PATH_GLIB_2_0(,,[AC_MSG_ERROR([UDPForward requires glib-2.0 library.])],[])
+AM_PATH_GLIB_2_0(,,[AC_MSG_ERROR([UDPGate requires glib-2.0 library.])],[])
 dnl Force glib for the whole package
 CFLAGS="$CFLAGS $GLIB_CFLAGS"
 LIBS="$LIBS $GLIB_LIBS"
 
 dnl popt
-AC_CHECK_LIB(popt,poptParseArgvString,[POPT_LIBS="-lpopt"],[AC_MSG_ERROR([UDPForward requires popt library.])])
+AC_CHECK_LIB(popt,poptParseArgvString,[POPT_LIBS="-lpopt"],[AC_MSG_ERROR([UDPGate requires popt library.])])
 AC_SUBST(POPT_LIBS)
 
 GLADE_W_INIT([
-       ./src/install/acquire/ui-gnome-interface.c
-       ./src/install/acquire/ui-gnome-interface.h
-       ./src/install/acquire/ui-gnome-callbacks.h
-       ./src/install/acquire/ui-gnome-support.c
-       ./src/install/acquire/ui-gnome-support.h
+       ./src/ui-gnome-interface.c
+       ./src/ui-gnome-interface.h
+       ./src/ui-gnome-callbacks.h
+       ./src/ui-gnome-support.c
+       ./src/ui-gnome-support.h
        ])
 AC_SUBST(GNOMEUI_CFLAGS)
 AC_SUBST(GNOMEUI_LIBS)
+if $have_gnome
+then
+       AC_DEFINE(HAVE_GNOME,,[Compile Gnome support.])
+fi
+AM_CONDITIONAL(HAVE_GNOME,[ $have_gnome ])
 AM_CONDITIONAL(HAVE_GLADE_WRITESOURCE,[ test "x$PATH_GLADE" != "x" ])
 dnl Do not: AM_CONDITIONAL(BUILD_GLADESRC,[ test "xyes" = "x$BUILD_GLADESRC" ])
 dnl as we do not need it as we are conditioned by ENABLE_INSTALL_PKG
@@ -189,12 +237,13 @@ AC_SUBST(LIBS)
 dnl "Makefile" output files MUST have pathnames incl./excl. "./" prefix as specified!
 dnl FIXME: Why the rule above was written here?
 AC_OUTPUT([
-udpforward.spec
-./src/udpforward.pod.pl
+udpgate.spec
+./src/udpgate.pod.pl
 ./po/Makefile.in
 ./macros/glade-w.sh
 Makefile
 ./macros/Makefile
+./init.d/Makefile
 ./src/Makefile
 ])