Ethereal-dev: [Ethereal-dev] Change build system to make static compiles work again (rfc)

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: Sun, 23 Feb 2003 13:24:32 +0100
The attached patch is my first attempt at fixing the problems that cause
a ./configure --enable-static to fail during linking stage due to multiple
definitions of the same symbols (reproduced on Suse 8.1 and HP/UX 10.20 and
reported by others on this list at least for newer versions of HP/UX).
What this patch does is to disable simultaneous builds of both, static
and shared binaries. This allows a small cleanup of the build process as
a side effect.

Please test and comment.

 ciao
              Jörg
--
Joerg Mayer                                          <jmayer@xxxxxxxxx>
I found out that "pro" means "instead of" (as in proconsul). Now I know
what proactive means.
Index: Makefile.am
===================================================================
RCS file: /usr/local/cvsroot/ethereal/Makefile.am,v
retrieving revision 1.555
diff -u -p -r1.555 Makefile.am
--- Makefile.am	20 Feb 2003 12:04:11 -0000	1.555
+++ Makefile.am	23 Feb 2003 11:54:20 -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
 
 #
@@ -405,38 +405,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 \
@@ -467,15 +446,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 \
@@ -485,15 +487,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   \
@@ -730,26 +735,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	\
@@ -789,10 +774,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
@@ -800,6 +781,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)	\
@@ -807,17 +795,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		\
@@ -836,14 +813,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 =		\
@@ -858,31 +827,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.
@@ -949,13 +907,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 
@@ -1022,7 +976,6 @@ CLEANFILES =	\
 DISTCLEANFILES =	\
 	aclocal-missing/*.m4 \
 	register.c	\
-	register-static.c \
 	rdps		\
 	ps.c		\
 	*~
@@ -1145,7 +1098,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.195
diff -u -p -r1.195 configure.in
--- configure.in	30 Jan 2003 10:20:41 -0000	1.195
+++ configure.in	23 Feb 2003 11:54:21 -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
@@ -746,6 +747,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(