Use per-binary LDFLAGS to remove linking to useless libraries. This will reduce the size of the binaries and may also speed up startup time slightly. These changes are based on suggestions and a patch by James Vega.

darcs-hash:20070324105629-ac50b-64425ff68a18e3adf51eee141d3a4450405c1ddb.gz
This commit is contained in:
axel 2007-03-24 20:56:29 +10:00
parent 3969c1b453
commit f36508837b
2 changed files with 113 additions and 34 deletions

View file

@ -55,16 +55,19 @@ localedir = @localedir@
prefix = @prefix@ prefix = @prefix@
optbindirs = @optbindirs@ optbindirs = @optbindirs@
# #
# Various flags # Various flags
# #
MACROS=-DLOCALEDIR=\"$(localedir)\" -DPREFIX=L\"$(prefix)\" -DDATADIR=L\"$(datadir)\" -DSYSCONFDIR=L\"$(sysconfdir)\" MACROS = -DLOCALEDIR=\"$(localedir)\" -DPREFIX=L\"$(prefix)\" -DDATADIR=L\"$(datadir)\" -DSYSCONFDIR=L\"$(sysconfdir)\"
CFLAGS=@CFLAGS@ $(MACROS) CFLAGS = @CFLAGS@ $(MACROS)
CPPFLAGS=@CPPFLAGS@ CPPFLAGS = @CPPFLAGS@
LDFLAGS= @LIBS@ @LDFLAGS@ LDFLAGS = @LIBS@ @LDFLAGS@
LDFLAGS_FISH = ${LDFLAGS} @LIBS_FISH@ @LDFLAGS_FISH@
LDFLAGS_FISH_PAGER = ${LDFLAGS} @LIBS_FISH_PAGER@
LDFLAGS_FISHD = ${LDFLAGS} @LIBS_FISHD@
LDFLAGS_MIMEDB = ${LDFLAGS} @LIBS_MIMEDB@
LDFLAGS_SET_COLOR = ${LDFLAGS} @LIBS_SET_COLOR@
# #
# Set to 1 if we have gettext # Set to 1 if we have gettext
@ -680,7 +683,7 @@ uninstall-translations:
# #
fish: $(FISH_OBJS) main.o fish: $(FISH_OBJS) main.o
$(CC) $(FISH_OBJS) main.o $(LDFLAGS) -o $@ $(CC) $(FISH_OBJS) main.o $(LDFLAGS_FISH) -o $@
# #
@ -688,7 +691,7 @@ fish: $(FISH_OBJS) main.o
# #
fish_pager: $(FISH_PAGER_OBJS) fish_pager: $(FISH_PAGER_OBJS)
$(CC) $(FISH_PAGER_OBJS) $(LDFLAGS) -o $@ $(CC) $(FISH_PAGER_OBJS) $(LDFLAGS_FISH_PAGER) -o $@
# #
@ -696,7 +699,7 @@ fish_pager: $(FISH_PAGER_OBJS)
# #
fishd: $(FISHD_OBJS) fishd: $(FISHD_OBJS)
$(CC) $(FISHD_OBJS) $(LDFLAGS) -o $@ $(CC) $(FISHD_OBJS) $(LDFLAGS_FISHD) -o $@
# #
@ -704,7 +707,7 @@ fishd: $(FISHD_OBJS)
# #
fish_tests: $(FISH_TESTS_OBJS) fish_tests: $(FISH_TESTS_OBJS)
$(CC) $(FISH_TESTS_OBJS) $(LDFLAGS) -o $@ $(CC) $(FISH_TESTS_OBJS) $(LDFLAGS_FISH) -o $@
# #
@ -714,7 +717,7 @@ fish_tests: $(FISH_TESTS_OBJS)
# #
mimedb: $(MIME_OBJS) mimedb: $(MIME_OBJS)
$(CC) $(MIME_OBJS) $(LDFLAGS) -o $@ $(CC) $(MIME_OBJS) $(LDFLAGS_MIMEDB) -o $@
# #
@ -732,7 +735,7 @@ count: count.o
# #
set_color: set_color.o print_help.o common.o set_color: set_color.o print_help.o common.o
$(CC) set_color.o print_help.o common.o wutil.o $(LDFLAGS) -o $@ $(CC) set_color.o print_help.o common.o wutil.o $(LDFLAGS_SET_COLOR) -o $@
# #

View file

@ -12,6 +12,26 @@
AC_INIT(fish,1.22.3,fish-users@lists.sf.net) AC_INIT(fish,1.22.3,fish-users@lists.sf.net)
#
# List of output variables produced by this configure script
#
AC_SUBST( docdir )
AC_SUBST( HAVE_GETTEXT )
AC_SUBST( LDFLAGS_FISH )
AC_SUBST( LIBS_FISH )
AC_SUBST( LIBS_FISH_PAGER )
AC_SUBST( LIBS_FISHD )
AC_SUBST( LIBS_MIMEDB )
AC_SUBST( LIBS_SET_COLOR )
AC_SUBST( localedir )
AC_SUBST( optbindirs )
AC_SUBST( prefix )
AC_SUBST( SEQ_FALLBACK )
AC_SUBST( XSEL )
AC_SUBST( XSEL_MAN )
AC_SUBST( XSEL_MAN_PATH )
# #
# If needed, run autoconf to regenerate the configure file # If needed, run autoconf to regenerate the configure file
# #
@ -107,8 +127,6 @@ for i in /usr/pkg /sw /opt /opt/local; do
done done
AC_SUBST( optbindirs, $optbindirs )
# #
# Tell autoconf to create config.h header # Tell autoconf to create config.h header
@ -161,7 +179,7 @@ if test "$SEQ_FALLBACK"; then
shebang=`grep "\(^#!/.*/fish\|^#!/usr/bin/env fish\)" $file` shebang=`grep "\(^#!/.*/fish\|^#!/usr/bin/env fish\)" $file`
if test "$shebang"; then if test "$shebang"; then
AC_SUBST( SEQ_FALLBACK, seq ) SEQ_FALLBACK=seq
AC_MSG_RESULT(yes, replace it) AC_MSG_RESULT(yes, replace it)
else else
AC_MSG_RESULT(no, keep it) AC_MSG_RESULT(no, keep it)
@ -185,13 +203,9 @@ AC_ARG_WITH(
) )
if [[ "$xsel" = "with_xsel" ]]; then if [[ "$xsel" = "with_xsel" ]]; then
AC_SUBST( XSEL,[xsel-0.9.6/xsel]) XSEL=xsel-0.9.6/xsel
AC_SUBST( XSEL_MAN,[xsel.1x]) XSEL_MAN=xsel.1x
AC_SUBST( XSEL_MAN_PATH,[xsel-0.9.6/xsel.1x]) XSEL_MAN_PATH=xsel-0.9.6/xsel.1x
else
AC_SUBST( XSEL,[ ])
AC_SUBST( XSEL_MAN,[ ])
AC_SUBST( XSEL_MAN_PATH,[ ])
fi fi
@ -291,7 +305,7 @@ if test "$CC" = gcc; then
# This is needed in order to get the really cool backtraces # This is needed in order to get the really cool backtraces
# #
LDFLAGS="$LDFLAGS -rdynamic" LDFLAGS_FISH="$LDFLAGS_FISH -rdynamic"
fi fi
@ -398,10 +412,7 @@ esac
# #
if [[ "$prefix" = NONE ]]; then if [[ "$prefix" = NONE ]]; then
export prefix=/usr/local prefix=/usr/local
AC_SUBST( prefix, /usr/local)
else
AC_SUBST( prefix, [$prefix])
fi fi
@ -413,9 +424,9 @@ fi
AC_ARG_VAR( [docdir], [Documentation direcotry] ) AC_ARG_VAR( [docdir], [Documentation direcotry] )
if test -z $docdir; then if test -z $docdir; then
AC_SUBST(docdir, [$datadir/doc/fish] ) docdir=$datadir/doc/fish
else else
AC_SUBST(docdir, [$docdir]) docdir=$docdir
fi fi
@ -424,7 +435,7 @@ fi
# installed. # installed.
# #
AC_SUBST( [localedir], [$datadir/locale]) localedir=$datadir/locale
# #
@ -448,10 +459,18 @@ AC_DEFINE(
# #
# Check presense of various libraries # Check presense of various libraries. This is done on a per-binary
# level, since including various extra libraries in all binaries only
# because thay are used by some of them can cause extra bloat and
# slower compiles when developing fish.
# #
# Only link with gettext if we are using it #
# Check for libraries needed by fish.
#
LIBS_COMMON=$LIBS
LIBS=""
if test x$local_gettext != xno; then if test x$local_gettext != xno; then
AC_SEARCH_LIBS( gettext, intl,,) AC_SEARCH_LIBS( gettext, intl,,)
fi fi
@ -459,8 +478,65 @@ AC_SEARCH_LIBS( connect, socket, , [AC_MSG_ERROR([Cannot find the socket library
AC_SEARCH_LIBS( nanosleep, rt, , [AC_MSG_ERROR([Cannot find the rt library, needed to build this package.] )] ) AC_SEARCH_LIBS( nanosleep, rt, , [AC_MSG_ERROR([Cannot find the rt library, needed to build this package.] )] )
AC_SEARCH_LIBS( setupterm, [ncurses curses], , [AC_MSG_ERROR([Could not find a curses implementation, needed to build fish])] ) AC_SEARCH_LIBS( setupterm, [ncurses curses], , [AC_MSG_ERROR([Could not find a curses implementation, needed to build fish])] )
AC_SEARCH_LIBS( iconv_open, iconv, , [AC_MSG_ERROR([Could not find an iconv implementation, needed to build fish])] ) AC_SEARCH_LIBS( iconv_open, iconv, , [AC_MSG_ERROR([Could not find an iconv implementation, needed to build fish])] )
LIBS_FISH=$LIBS
LIBS=$LIBS_COMMON
#
# Check for libraries needed by fishd.
#
LIBS_COMMON=$LIBS
LIBS=""
if test x$local_gettext != xno; then
AC_SEARCH_LIBS( gettext, intl,,)
fi
AC_SEARCH_LIBS( connect, socket, , [AC_MSG_ERROR([Cannot find the socket library, needed to build this package.] )] )
LIBS_FISHD=$LIBS
LIBS=$LIBS_COMMON
#
# Check for libraries needed by mimedb.
#
LIBS_COMMON=$LIBS
LIBS=""
if test x$local_gettext != xno; then
AC_SEARCH_LIBS( gettext, intl,,)
fi
LIBS_FISHD=$LIBS
LIBS=$LIBS_COMMON
#
# Check for libraries needed by fish_pager.
#
LIBS_COMMON=$LIBS
LIBS=""
if test x$local_gettext != xno; then
AC_SEARCH_LIBS( gettext, intl,,)
fi
AC_SEARCH_LIBS( connect, socket, , [AC_MSG_ERROR([Cannot find the socket library, needed to build this package.] )] )
AC_SEARCH_LIBS( setupterm, [ncurses curses], , [AC_MSG_ERROR([Could not find a curses implementation, needed to build fish])] )
LIBS_FISH_PAGER=$LIBS
LIBS=$LIBS_COMMON
#
# Check for libraries needed by set_color
#
LIBS_COMMON=$LIBS
LIBS=""
if test x$local_gettext != xno; then
AC_SEARCH_LIBS( gettext, intl,,)
fi
AC_SEARCH_LIBS( setupterm, [ncurses curses], , [AC_MSG_ERROR([Could not find a curses implementation, needed to build fish])] )
LIBS_SET_COLOR=$LIBS
LIBS=$LIBS_COMMON
# #
# Check presense of various header files # Check presense of various header files
# #
@ -617,7 +693,7 @@ AC_CHECK_FUNCS( dcgettext backtrace backtrace_symbols)
# #
if test x$local_gettext != xno; then if test x$local_gettext != xno; then
AC_CHECK_FUNC( gettext, AC_SUBST( HAVE_GETTEXT, 1 ), AC_SUBST( HAVE_GETTEXT, 0 ) ) AC_CHECK_FUNC( gettext, HAVE_GETTEXT=1, HAVE_GETTEXT=0 )
fi fi
# #