On Sat, Jul 20, 2013 at 5:34 AM, Russ Allbery <rra@xxxxxxxxxxxx> wrote: > Harlan Stenn <stenn@xxxxxxx> 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: Russ could you add some proper licence text to this ? Preferally all permissive license ? I will add your stuff to autoconf-archive as an optionnal flags to: AX_SAVE_FLAGS/AX_RESTORE_FLAGS (see http://www.gnu.org/software/autoconf-archive/ax_save_flags.html#ax_save_flags) and I will add the AX_SWITCH_FLAGS macro > 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 (rra@xxxxxxxxxxxx) <http://www.eyrie.org/~eagle/> > > _______________________________________________ > Autoconf mailing list > Autoconf@xxxxxxx > https://lists.gnu.org/mailman/listinfo/autoconf _______________________________________________ Autoconf mailing list Autoconf@xxxxxxx https://lists.gnu.org/mailman/listinfo/autoconf