+Option --enable-bundle for the fully static built single-file binary.
authorshort <>
Sun, 23 May 2004 15:20:54 +0000 (15:20 +0000)
committershort <>
Sun, 23 May 2004 15:20:54 +0000 (15:20 +0000)
Makefile.am
autogen.pl
configure.ac
init.d/Makefile.am [new file with mode: 0644]
init.d/udpgate.init [new file with mode: 0755]
src/Makefile.am
src/bundle.h [new file with mode: 0644]
src/bundle.pl [new file with mode: 0755]

index e1e04e5..dc9060a 100644 (file)
@@ -20,7 +20,8 @@ include $(top_srcdir)/Makefile-head.am
 
 AUTOMAKE_OPTIONS=gnu
 ACLOCAL_AMFLAGS=-I macros
-SUBDIRS=macros src po
+# Keep 'po' and 'init.d' before 'src' for our .gmo files bundling.
+SUBDIRS=macros po init.d src
 ## to automatically rebuild aclocal.m4 if any of the macros in
 ## `macros/' change
 @MAINT@include macros/macros.dep
index 1386fee..001f2c6 100755 (executable)
@@ -35,13 +35,12 @@ AutoGen->run(
                "COPYRIGHT_HOLDER"=>'Jan Kratochvil <project-udpgate@jankratochvil.net>',
                "ARGV"=>\@ARGV,
                "clean"=>[qw(
-                               .include_test_false.c
-                               .include_test_all.stamp
                                *.pod.pl *.pod *.[0-9]
                                ./ChangeLog.bak
                                ./debian/changelog
-                               ./doc/*-pod.*
+                               ./init.d/udpgate
                                ./src/udpgate
+                               ./src/bundle.c
                                ./src/ui-gnome-callbacks.[ch]
                                ./src/ui-gnome-interface.[ch]
                                ./src/ui-gnome-support.[ch]
index 9d3c40b..ac82242 100644 (file)
@@ -58,8 +58,16 @@ 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)
 
 
+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)
 AM_CONDITIONAL(HAVE_PERL,test -n "$PERL")
@@ -235,6 +243,7 @@ udpgate.spec
 ./macros/glade-w.sh
 Makefile
 ./macros/Makefile
+./init.d/Makefile
 ./src/Makefile
 ])
 
diff --git a/init.d/Makefile.am b/init.d/Makefile.am
new file mode 100644 (file)
index 0000000..9e4788d
--- /dev/null
@@ -0,0 +1,27 @@
+# $Id$
+# automake source for UDP Gateway startup scripts Makefile
+# 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
+# the Free Software Foundation; exactly version 2 of June 1991 is required
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+
+include $(top_srcdir)/Makefile-head.am
+
+initddir=$(sysconfdir)/rc.d/init.d
+initd_SCRIPTS=udpgate
+EXTRA_DIST+=udpgate.init
+CLEANFILES+=udpgate
+udpgate: udpgate.init
+       $(LN_S) $< $@
+
diff --git a/init.d/udpgate.init b/init.d/udpgate.init
new file mode 100755 (executable)
index 0000000..bb48bd6
--- /dev/null
@@ -0,0 +1,61 @@
+#! /bin/sh
+# Startup script for udpgate
+#
+# chkconfig: 2345 98 02
+# description: UDP packats gateway
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+[ -f /usr/sbin/udpgate ] || exit 0
+
+prog="udpgate"
+
+start() {
+       echo -n $"Starting $prog: " 
+       daemon udpgate --start
+       RETVAL=$?
+       echo
+       return $RETVAL
+}
+
+stop() {
+       if test "x`pidof udpgate`" != x; then
+               echo -n $"Stopping $prog: "
+               killproc udpgate
+               echo
+       fi
+       RETVAL=$?
+       return $RETVAL
+}
+
+case "$1" in
+               start)
+                       start
+                       ;;
+               
+               stop)
+                       stop
+                       ;;
+               
+               status)
+                       status udpgate
+                       ;;
+               restart)
+                       stop
+                       start
+                       ;;
+               condrestart)
+                       if test "x`pidof udpgate`" != x; then
+                               stop
+                               start
+                       fi
+                       ;;
+               
+               *)
+                       echo $"Usage: $0 {start|stop|restart|condrestart|status}"
+                       exit 1
+
+esac
+
+exit $RETVAL
index afc9da3..cb6d3ba 100644 (file)
@@ -36,6 +36,23 @@ GNOME_SRCS= \
                $(GLADE_OUT)
 endif
 
+if ENABLE_BUNDLE
+
+nodist_udpgate_SOURCES=bundle.c
+
+BUNDLE_SRCS= \
+               bundle.h
+
+EXTRA_DIST+= \
+               bundle.pl
+
+# FIXME: GNU make(1) dependency by $(addprefix ...)
+bundle_files=$(top_srcdir)/init.d/$(PACKAGE).init $(addprefix $(top_builddir)/$(POSUB)/,$(CATALOGS))
+bundle.c: bundle.pl $(bundle_files)
+               $(PERL) bundle.pl $(bundle_files) >$@
+
+endif
+
 udpgate_SOURCES= \
                configuration.c \
                configuration.h \
@@ -47,7 +64,8 @@ udpgate_SOURCES= \
                packet.h \
                ui-line.c \
                ui-line.h \
-               $(GNOME_SRCS)
+               $(GNOME_SRCS) \
+               $(BUNDLE_SRCS)
 
 EXTRA_DIST+= \
                $(GLADE_IN)
diff --git a/src/bundle.h b/src/bundle.h
new file mode 100644 (file)
index 0000000..12289c1
--- /dev/null
@@ -0,0 +1,35 @@
+/* $Id$
+ * Include file for the bundled files with UDPGate.
+ * 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
+ * the Free Software Foundation; exactly version 2 of June 1991 is required
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+
+#ifndef _UDPGATE_BUNDLE_H
+#define _UDPGATE_BUNDLE_H 1
+
+
+#include <glib/gtypes.h>
+#include <glib/ghash.h>
+
+
+G_BEGIN_DECLS
+
+GHashTable *bundle_hash_new(void);
+
+G_END_DECLS
+
+
+#endif /* _UDPGATE_BUNDLE_H */
diff --git a/src/bundle.pl b/src/bundle.pl
new file mode 100755 (executable)
index 0000000..fdd252b
--- /dev/null
@@ -0,0 +1,84 @@
+#! /usr/bin/perl
+# 
+# $Id$
+# Perl generator for the bundled files with UDPGate.
+# 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
+# the Free Software Foundation; exactly version 2 of June 1991 is required
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+
+use vars qw($VERSION);
+$VERSION=do { my @r=(q$Revision$=~/\d+/g); sprintf "%d.".("%03d"x$#r),@r; };
+use strict;
+use warnings;
+
+use File::Basename;
+
+
+print <<"EOH";
+/* AUTOGENERATED FILE! DO NOT EDIT!
+ * Bundled files with UDPGate.
+ */
+
+
+#include "config.h"
+
+#include <glib/ghash.h>
+
+#include "bundle.h"    /* self */
+
+
+GHashTable *bundle_hash_new(void)
+{
+static GHashTable *hash;
+EOH
+my @files;
+for my $pathname (@ARGV) {
+       local *F;
+       open F,$pathname or die "Cannot open $pathname: $!";
+       local $/=undef();
+       my $F=<F>;
+       close F or warn "Cannot close $pathname: $!";
+       my $filename=basename $pathname;
+       (my $filename_sym=$filename)=~tr/a-zA-Z/_/c;
+       $filename_sym=~s/^_*//; # Prevent conflict with system internal symbols.
+       push @files,{
+                       "filename"    =>$filename,
+                       "filename_sym"=>$filename_sym,
+                       };
+       my $Fout=unpack "H*",$F;
+       $Fout=~s/../0x$&,/g;
+       $Fout=~s/(?:.....){1,16}/\t\t$&\n/g;
+       $Fout=~s/,\n$//;
+       print <<"EOH";
+static const guint8 ${filename_sym}_data[]={
+$Fout
+               };
+EOH
+       }
+print <<"EOH";
+
+       if (!hash) {
+               hash=g_hash_table_new(g_str_hash,g_str_equal);
+EOH
+       for (@files) {
+               print "\t\tg_hash_table_insert(hash,\"".$_->{"filename"}."\",(gpointer)".$_->{"filename_sym"}."_data);\n";
+               }
+print <<"EOH";
+               }
+       return hash;
+}
+
+/* EOF */
+EOH