Ethereal-dev: [Ethereal-dev] Updated fix for statically linking Ethereal

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

From: Joerg Mayer <jmayer@xxxxxxxxx>
Date: Fri, 28 Feb 2003 01:15:08 +0100
I've updated my patch that enables statically linking Ethereal on
some platforms again. I'd really like to receive some feedback before
I submit it.

 Ciao
         Jörg
-- 
Joerg Mayer <jmayer@xxxxxxxxx>
You can make it illegal, but you can't make it unpopular.
Index: Makefile.am
===================================================================
RCS file: /usr/local/cvsroot/ethereal/Makefile.am,v
retrieving revision 1.559
diff -p -u -r1.559 Makefile.am
--- Makefile.am	27 Feb 2003 02:45:42 -0000	1.559
+++ Makefile.am	28 Feb 2003 00:08:58 -0000
@@ -65,7 +65,7 @@ bin_SCRIPTS = @idl2eth_bin@
 man1_MANS = @ethereal_man@ @editcap_man@ @mergecap_man@ @tethereal_man@ @text2pcap_man@ @idl2eth_man@
 man_MANS =
 
-EXTRA_PROGRAMS = ethereal ethereal_static tethereal tethereal_static editcap mergecap dftest text2pcap
+EXTRA_PROGRAMS = ethereal tethereal editcap mergecap dftest text2pcap
 EXTRA_SCRIPTS = idl2eth
 
 #
@@ -406,38 +406,17 @@ DISSECTOR_SRC = \
 	packet-zebra.c
 
 if HAVE_PLUGINS
-plugin_src = \
-	plugins/docsis/packet-bpkmattr.c \
-	plugins/docsis/packet-bpkmreq.c \
-	plugins/docsis/packet-bpkmrsp.c \
-	plugins/docsis/packet-docsis.c \
-	plugins/docsis/packet-dsaack.c \
-	plugins/docsis/packet-dsareq.c \
-	plugins/docsis/packet-dsarsp.c \
-	plugins/docsis/packet-dscack.c \
-	plugins/docsis/packet-dscreq.c \
-	plugins/docsis/packet-dscrsp.c \
-	plugins/docsis/packet-dsdreq.c \
-	plugins/docsis/packet-dsdrsp.c \
-	plugins/docsis/packet-macmgmt.c \
-	plugins/docsis/packet-map.c \
-	plugins/docsis/packet-regack.c \
-	plugins/docsis/packet-regreq.c \
-	plugins/docsis/packet-regrsp.c \
-	plugins/docsis/packet-rngreq.c \
-	plugins/docsis/packet-rngrsp.c \
-	plugins/docsis/packet-tlv.c \
-	plugins/docsis/packet-uccreq.c \
-	plugins/docsis/packet-uccrsp.c \
-	plugins/docsis/packet-ucd.c \
-	plugins/giop/packet-cosnaming.c \
-	plugins/giop/packet-coseventcomm.c \
-	plugins/gryphon/packet-gryphon.c \
-	plugins/megaco/packet-megaco.c \
-	plugins/mgcp/packet-mgcp.c \
-	plugins/pcli/packet-pcli.c
+plugin_libs = \
+	plugins/docsis/docsis.la \
+	plugins/giop/cosnaming.la \
+	plugins/giop/coseventcomm.la \
+	plugins/gryphon/gryphon.la \
+	plugins/megaco/megaco.la \
+	plugins/mgcp/mgcp.la \
+	plugins/pcli/pcli.la
 
-plugin_static_ldadd = \
+if ENABLE_STATIC
+plugin_ldadd = \
 	plugins/docsis/packet-bpkmattr-static.o \
 	plugins/docsis/packet-bpkmreq-static.o \
 	plugins/docsis/packet-bpkmrsp-static.o \
@@ -468,15 +447,38 @@ plugin_static_ldadd = \
 	plugins/mgcp/packet-mgcp-static.o \
 	plugins/pcli/packet-pcli-static.o
 
-plugin_libs = \
-	plugins/docsis/docsis.la \
-	plugins/giop/cosnaming.la \
-	plugins/giop/coseventcomm.la \
-	plugins/gryphon/gryphon.la \
-	plugins/megaco/megaco.la \
-	plugins/mgcp/mgcp.la \
-	plugins/pcli/pcli.la
+plugin_src = \
+	plugins/docsis/packet-bpkmattr.c \
+	plugins/docsis/packet-bpkmreq.c \
+	plugins/docsis/packet-bpkmrsp.c \
+	plugins/docsis/packet-docsis.c \
+	plugins/docsis/packet-dsaack.c \
+	plugins/docsis/packet-dsareq.c \
+	plugins/docsis/packet-dsarsp.c \
+	plugins/docsis/packet-dscack.c \
+	plugins/docsis/packet-dscreq.c \
+	plugins/docsis/packet-dscrsp.c \
+	plugins/docsis/packet-dsdreq.c \
+	plugins/docsis/packet-dsdrsp.c \
+	plugins/docsis/packet-macmgmt.c \
+	plugins/docsis/packet-map.c \
+	plugins/docsis/packet-regack.c \
+	plugins/docsis/packet-regreq.c \
+	plugins/docsis/packet-regrsp.c \
+	plugins/docsis/packet-rngreq.c \
+	plugins/docsis/packet-rngrsp.c \
+	plugins/docsis/packet-tlv.c \
+	plugins/docsis/packet-uccreq.c \
+	plugins/docsis/packet-uccrsp.c \
+	plugins/docsis/packet-ucd.c \
+	plugins/giop/packet-cosnaming.c \
+	plugins/giop/packet-coseventcomm.c \
+	plugins/gryphon/packet-gryphon.c \
+	plugins/megaco/packet-megaco.c \
+	plugins/mgcp/packet-mgcp.c \
+	plugins/pcli/packet-pcli.c
 
+else		# ENABLE_STATIC
 plugin_ldadd = \
 	"-dlopen" self	\
 	"-dlopen" plugins/docsis/docsis.la \
@@ -486,15 +488,18 @@ plugin_ldadd = \
 	"-dlopen" plugins/megaco/megaco.la \
 	"-dlopen" plugins/mgcp/mgcp.la \
 	"-dlopen" plugins/pcli/pcli.la
-else
+
 plugin_src =
 
-plugin_static_ldadd =
+endif		# ENABLE_STATIC
+
+else		# HAVE_PLUGINS
+plugin_src =
 
 plugin_libs =
 
 plugin_ldadd =
-endif
+endif		# HAVE_PLUGINS
 
 noinst_HEADERS = \
 	packet-afp.h   \
@@ -732,26 +737,6 @@ ethereal_SOURCES = \
 	summary.h      \
 	ui_util.h
 
-ethereal_static_SOURCES = \
-	$(DISSECTOR_SRC) \
-	$(ETHEREAL_COMMON_SRC) \
-	register-static.c     \
-	capture.c      \
-	capture.h      \
-	file.c         \
-	filters.c      \
-	filters.h      \
-	globals.h      \
-	menu.h         \
-	progress_dlg.h \
-	proto_hier_stats.h	\
-	proto_hier_stats.c	\
-	simple_dialog.h \
-	statusbar.h    \
-	summary.c      \
-	summary.h      \
-	ui_util.h
-
 EXTRA_ethereal_SOURCES = \
 	snprintf.c	\
 	snprintf.h	\
@@ -791,10 +776,6 @@ ethereal_DEPENDENCIES = \
 	$(ethereal_additional_libs)	\
 	$(plugin_libs)
 
-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
@@ -802,6 +783,13 @@ ethereal_static_DEPENDENCIES = \
 # @SOCKET_LIBS@ or @NSL_LIBS@, as those should also be included in
 # @GTK_LIBS@ (as those are also needed for X applications, and GTK+
 # applications are X applications).
+
+if ENABLE_STATIC
+ethereal_LDFLAGS = -Wl,-static -all-static
+else
+ethereal_LDFLAGS = -export-dynamic
+endif
+
 ethereal_LDADD = \
 	$(ethereal_optional_objects)	\
 	$(ethereal_additional_libs)	\
@@ -809,17 +797,6 @@ ethereal_LDADD = \
 	$(plugin_ldadd)			\
 	@PCAP_LIBS@ @GTK_LIBS@
 
-ethereal_static_LDADD = \
-	"-all-static" 			\
-	$(plugin_static_ldadd)		\
-	$(ethereal_optional_objects)	\
-	$(ethereal_additional_libs)	\
-	@SNMP_LIBS@ @SSL_LIBS@		\
-	@PCAP_LIBS@ @GTK_LIBS@
-
-ethereal_LDFLAGS = -export-dynamic
-ethereal_static_LDFLAGS = -Wl,-static
-
 TETHEREAL_TAP_SRC = \
 	tap-dcerpcstat.c	\
 	tap-iostat.c		\
@@ -838,14 +815,6 @@ tethereal_SOURCES = \
 	register.c     \
 	tethereal.c
 
-tethereal_static_SOURCES = \
-	$(DISSECTOR_SRC) \
-	$(ETHEREAL_COMMON_SRC) \
-	$(TETHEREAL_TAP_SRC) \
-	tethereal-tap-register.c \
-	register-static.c     \
-	tethereal.c
-
 # Additional libs that I know how to build. These will be
 # linked into the tethereal executable.
 tethereal_additional_libs =		\
@@ -860,31 +829,20 @@ tethereal_DEPENDENCIES = \
 	$(tethereal_additional_libs)	\
 	$(plugin_libs)
 
-tethereal_static_DEPENDENCIES = \
-	$(ethereal_optional_objects)	\
-	$(tethereal_additional_libs)
-
 # This automake variable adds to the link-line for the executable
-tethereal_LDADD = wiretap/libwiretap.a	\
+tethereal_LDADD = \
 	$(ethereal_optional_objects)	\
 	$(tethereal_additional_libs)	\
 	@SNMP_LIBS@ @SSL_LIBS@		\
 	$(plugin_ldadd)			\
-	@GLIB_LIBS@ -lm \
-	@PCAP_LIBS@ @SOCKET_LIBS@ @NSL_LIBS@
-
-tethereal_static_LDADD = \
-	"-all-static"		\
-	$(plugin_static_ldadd)	\
-	wiretap/libwiretap.a	\
-	$(ethereal_optional_objects)	\
-	$(tethereal_additional_libs)	\
-	@SNMP_LIBS@ @SSL_LIBS@		\
-	@GLIB_LIBS@ -lm \
+	@GLIB_LIBS@ -lm			\
 	@PCAP_LIBS@ @SOCKET_LIBS@ @NSL_LIBS@
 
+if ENABLE_STATIC
+tethereal_LDFLAGS = -Wl,-static -all-static
+else
 tethereal_LDFLAGS = -export-dynamic
-tethereal_static_LDFLAGS = -Wl,-static
+endif
 
 # Optional objects that I know how to build, and that are needed by
 # text2pcap.
@@ -951,13 +909,9 @@ SUFFIXES = .sh
 # The second argument is the directory in which the source files live.
 # All subsequent arguments are the files to scan.
 #
-register.c: $(DISSECTOR_SRC) $(srcdir)/make-reg-dotc
+register.c: $(plugin_src) $(DISSECTOR_SRC) $(srcdir)/make-reg-dotc
 	@echo Making register.c
-	@$(srcdir)/make-reg-dotc register.c $(srcdir) $(DISSECTOR_SRC)
-
-register-static.c: $(plugin_src) $(DISSECTOR_SRC) $(srcdir)/make-reg-dotc
-	@echo Making register-static.c
-	@$(srcdir)/make-reg-dotc register-static.c $(srcdir) $(plugin_src) $(DISSECTOR_SRC)
+	@$(srcdir)/make-reg-dotc register.c $(srcdir) $(plugin_src) $(DISSECTOR_SRC)
 
 #
 # Build "tethereal-tap-register.c", which contains a function 
@@ -1028,7 +982,6 @@ DISTCLEANFILES =	\
 
 MAINTAINERCLEANFILES =		\
 	register.c		\
-	register-static.c	\
 	ps.c
 
 EXTRA_DIST = \
@@ -1149,7 +1102,6 @@ if SETUID_INSTALL
 install-exec-hook:
 	-chmod +s $(DESTDIR)$(bindir)/ethereal
 	-chmod +s $(DESTDIR)$(bindir)/tethereal
-	-chmod +s $(DESTDIR)$(bindir)/ethereal_static
 else
 install-exec-hook:
 endif
Index: configure.in
===================================================================
RCS file: /usr/local/cvsroot/ethereal/configure.in,v
retrieving revision 1.196
diff -p -u -r1.196 configure.in
--- configure.in	26 Feb 2003 20:08:30 -0000	1.196
+++ configure.in	28 Feb 2003 00:08:58 -0000
@@ -22,6 +22,7 @@ AM_INIT_AUTOMAKE(ethereal, 0.9.9)
 dnl Checks for programs.
 AC_PROG_CC
 AC_PROG_CPP
+AM_DISABLE_STATIC
 AC_LIBTOOL_DLOPEN
 AC_PROG_LIBTOOL
 AC_PROG_YACC
@@ -757,6 +758,7 @@ dnl libtool defs
 AM_PROG_LIBTOOL
 AC_SUBST(LIBTOOL_DEPS)
 
+AM_CONDITIONAL(ENABLE_STATIC, test x$enable_shared = xno)
 AM_CONFIG_HEADER(config.h)
 AC_CONFIG_SUBDIRS(epan wiretap)
 AC_OUTPUT(