fi
+LIBEVENT_GC_SECTIONS=
+if test "$GCC" = yes ; then
+ AC_CACHE_CHECK(
+ [if linker supports omitting unused code and data],
+ [libevent_cv_gc_sections_works],
+ [
+ origCFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -Wl,--gc-sections"
+ AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM([[]], [[]])],
+ [
+ if grep gc-sections conftest.err ; then
+ libevent_cv_gc_sections_works=no
+ else
+ libevent_cv_gc_sections_works=yes
+ fi
+ ],
+ [libevent_cv_gc_sections_works=no]
+ )
+ CFLAGS="$origCFLAGS"
+ AS_UNSET([origCFLAGS])
+ ]
+ )
+ case "$libevent_cv_gc_sections_works" in
+ yes)
+ CFLAGS="-ffunction-sections -fdata-sections $CFLAGS"
+ LIBEVENT_GC_SECTIONS="-Wl,--gc-sections"
+ ;;
+ esac
+fi
+AC_SUBST([LIBEVENT_GC_SECTIONS])
+
AC_CONFIG_FILES( [libevent.pc libevent_openssl.pc libevent_pthreads.pc] )
AC_OUTPUT(Makefile include/Makefile test/Makefile sample/Makefile)
AUTOMAKE_OPTIONS = foreign no-dependencies
-LDADD = ../libevent.la
+LDADD = @LIBEVENT_GC_SECTIONS@ ../libevent.la
AM_CFLAGS = -I$(top_srcdir) -I$(top_srcdir)/compat -I$(top_srcdir)/include -I../include
noinst_PROGRAMS = event-test time-test signal-test dns-example hello-world http-server
regress_SOURCES += regress_iocp.c
endif
-regress_LDADD = ../libevent.la $(PTHREAD_LIBS) $(ZLIB_LIBS)
+regress_LDADD = @LIBEVENT_GC_SECTIONS@ ../libevent.la $(PTHREAD_LIBS) $(ZLIB_LIBS)
regress_CFLAGS = -I$(top_srcdir) -I$(top_srcdir)/compat \
-I$(top_srcdir)/include -I../include $(PTHREAD_CFLAGS) $(ZLIB_CFLAGS)
regress_LDFLAGS = $(PTHREAD_CFLAGS)
endif
bench_SOURCES = bench.c
-bench_LDADD = ../libevent.la
+bench_LDADD = @LIBEVENT_GC_SECTIONS@ ../libevent.la
bench_cascade_SOURCES = bench_cascade.c
-bench_cascade_LDADD = ../libevent.la
+bench_cascade_LDADD = @LIBEVENT_GC_SECTIONS@ ../libevent.la
bench_http_SOURCES = bench_http.c
-bench_http_LDADD = ../libevent.la
+bench_http_LDADD = @LIBEVENT_GC_SECTIONS@ ../libevent.la
bench_httpclient_SOURCES = bench_httpclient.c
-bench_httpclient_LDADD = ../libevent_core.la
+bench_httpclient_LDADD = @LIBEVENT_GC_SECTIONS@ ../libevent_core.la
regress.gen.c regress.gen.h: regress.rpc $(top_srcdir)/event_rpcgen.py
$(top_srcdir)/event_rpcgen.py $(srcdir)/regress.rpc || echo "No Python installed"