autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: LIBS


From: Russ Allbery
Subject: Re: LIBS
Date: Fri, 19 Jul 2013 20:34:26 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux)

Harlan Stenn <address@hidden> writes:

> So for reasons that may or may not still be valid, I've had folks
> successfully lobby me to separate out libraries that are needed for all
> programs from libraries that are needed for certain programs.

> I believe the reasons for this have to do with the size of the
> executables - folks Noticed that linking with unnecessary libraries
> caused the resulting executables to be much bigger and sucked up memory,
> especially in embedded systems.

> But if I don't put all of the detected libraries in LIBS then things
> like AC_CHECK_FUNCS won't find them.

> Suggestions on good ways to proceed?

I do lots and lots and lots of this sort of thing:

dnl Add the library flags to the default compiler flags and then remove them.
dnl
dnl To use these macros, pass the prefix string used for the variables as the
dnl only argument.  For example, to use these for a library with KRB5 as a
dnl prefix, one would use:
dnl
dnl     AC_DEFUN([RRA_LIB_KRB5_SWITCH], [RRA_LIB_HELPER_SWITCH([KRB5])])
dnl     AC_DEFUN([RRA_LIB_KRB5_RESTORE], [RRA_LIB_HELPER_RESTORE([KRB5])])
dnl
dnl Then, wrap checks for library features with RRA_LIB_KRB5_SWITCH and
dnl RRA_LIB_KRB5_RESTORE.
AC_DEFUN([RRA_LIB_HELPER_SWITCH],
[rra_$1[]_save_CPPFLAGS="$CPPFLAGS"
 rra_$1[]_save_LDFLAGS="$LDFLAGS"
 rra_$1[]_save_LIBS="$LIBS"
 CPPFLAGS="$$1[]_CPPFLAGS $CPPFLAGS"
 LDFLAGS="$$1[]_LDFLAGS $LDFLAGS"
 LIBS="$$1[]_LIBS $LIBS"])

AC_DEFUN([RRA_LIB_HELPER_RESTORE],
[CPPFLAGS="$rra_$1[]_save_CPPFLAGS"
 LDFLAGS="$rra_$1[]_save_LDFLAGS"
 LIBS="$rra_$1[]_save_LIBS"])

combined with adding libraries explicitly to XXX_LIBS in the probe macros,
and then linking with XXX_LDFLAGS and XXX_LIBS when that library is
needed.  It gets quite tedious, but it does work, including on hosts where
--as-needed isn't supported.

-- 
Russ Allbery (address@hidden)             <http://www.eyrie.org/~eagle/>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]