Ethereal-dev: [ethereal-dev] Simple patch to allow easy building of static linked ethereal

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Nathan Neulinger <nneul@xxxxxxx>
Date: Thu, 27 Jan 2000 15:54:44 -0600
This is a very simple hack to allow a user to easily build a staticly 
linked copy of ethereal. It will not have any support for plugins. 

At this time, no special handling is done, plugin loading should just 
fail. Ideally we should likely have some sort of test and compile out the
plugin menu, or put a diagnostic message up to indicate plugins are not
supported in the staticly linked version.

Basically, to enable, add --with-static-ethereal. This will cause the 
compilation process to additionally create ethereal_static. 

Note - this is intended for those of us who can do a normal build, but 
for various reasons, would also like to be able to link ethereal 
staticly. I am not sure how this patch will behave on a machine that 
cannot build the plugins (i.e. you might have a specifically issue gmake 
ethereal_static). 

Extending this to tethereal should be obvious, just have a look at the 
Makefile.am and configure.in changes. 

-- Nathan

------------------------------------------------------------
Nathan Neulinger                       EMail:  nneul@xxxxxxx
University of Missouri - Rolla         Phone: (573) 341-4841
Computing Services                       Fax: (573) 341-4216
? nneul-to-do
? packet-krb.c
? save-krb
? cvs2cl.pl
? ChangeLog.cvs2cl
Index: Makefile.am
===================================================================
RCS file: /cvsroot/ethereal/Makefile.am,v
retrieving revision 1.159
diff -u -r1.159 Makefile.am
--- Makefile.am	2000/01/26 07:00:14	1.159
+++ Makefile.am	2000/01/27 21:48:56
@@ -22,7 +22,8 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
-bin_PROGRAMS = ethereal editcap tethereal
+EXTRA_PROGRAMS = ethereal_static
+bin_PROGRAMS = ethereal editcap tethereal @ETHEREAL_STATIC@
 
 man_MANS = ethereal.1 editcap.1 tethereal.1
 
@@ -233,6 +234,9 @@
 	summary.h      \
 	ui_util.h
 
+ethereal_static_SOURCES = \
+	$(ethereal_SOURCES)
+
 EXTRA_ethereal_SOURCES = \
 	dfilter-grammar.c \
 	dfilter-grammar.h \
@@ -257,7 +261,8 @@
 # we should probably split this into stuff needed both
 # by ethereal and tethereal and stuff needed only by one or the
 # other.
-ethereal_optional_objects = @SNPRINTF_O@ @STRERROR_O@  @STRNCASECMP_O@ @MKSTEMP_O@ \
+ethereal_optional_objects = @SNPRINTF_O@ @STRERROR_O@ \
+	@STRNCASECMP_O@ @MKSTEMP_O@ \
 	@INET_ATON_O@ @INET_PTON_O@ @INET_NTOP_O@ 
 
 # Additional libs that I know how to build. These will be
@@ -270,6 +275,10 @@
 	$(ethereal_additional_libs)	\
 	plugins/gryphon/gryphon.la
 
+ethereal_static_DEPENDENCIES = \
+	$(ethereal_optional_objects)	\
+	$(ethereal_additional_libs)
+
 # This automake variable adds to the link-line for the executable.
 #
 # Note that Ethereal doesn't have to be linked with @GLIB_LIBS@, as
@@ -284,7 +293,14 @@
 	"-dlopen" self	\
 	"-dlopen" plugins/gryphon/gryphon.la @PCAP_LIBS@ @GTK_LIBS@
 
+ethereal_static_LDADD = \
+	$(ethereal_optional_objects)	\
+	$(ethereal_additional_libs) \
+	@SNMP_LIBS@			\
+	@PCAP_LIBS@ @GTK_LIBS@
+
 ethereal_LDFLAGS = -export-dynamic
+ethereal_static_LDFLAGS = -Wl,-static
 
 tethereal_SOURCES = \
 	$(DISSECTOR_SOURCES) \
Index: configure.in
===================================================================
RCS file: /cvsroot/ethereal/configure.in,v
retrieving revision 1.81
diff -u -r1.81 configure.in
--- configure.in	2000/01/26 02:31:35	1.81
+++ configure.in	2000/01/27 21:48:57
@@ -342,6 +342,22 @@
 dnl blank for now, but will be used in future
 AC_SUBST(ethereal_SUBDIRS)
 
+dnl check to see if user wants to also build ethereal_static
+AC_ARG_WITH(static-ethereal,
+  [  --with-static-ethereal   also build ethereal_static],
+  [
+    ETHEREAL_STATIC=
+    if test "x$withval" = xyes; then
+      ETHEREAL_STATIC=ethereal_static
+    elif test "x$withval" = x; then
+      ETHEREAL_STATIC=ethereal_static
+    fi
+  ],
+  [
+      ETHEREAL_STATIC=
+  ])
+AC_SUBST(ETHEREAL_STATIC)
+
 dnl check for plugins directory - stolen from Amanda's configure.in
 AC_ARG_WITH(plugindir,
   [  --with-plugindir=DIR   install plugins in DIR],