Further improvements to build system wrt detection of compiler and libc features and prototypes, as discussed with James Antill on mailin list

darcs-hash:20060329002500-ac50b-e7618e476ea69802bd2cb0076244f49a0f178df7.gz
This commit is contained in:
axel 2006-03-29 10:25:00 +10:00
parent 13a51ba4c2
commit dc91d7aec4
2 changed files with 82 additions and 35 deletions

View file

@ -72,7 +72,7 @@ COMMON_OBJS_WITH_HEADER := builtin_help.o
# main.c exists, but main.h does not, etc. # main.c exists, but main.h does not, etc.
COMMON_OBJS_WITH_CODE := builtin_set.o builtin_commandline.o \ COMMON_OBJS_WITH_CODE := builtin_set.o builtin_commandline.o \
builtin_ulimit.c builtin_complete.o builtin_ulimit.o builtin_complete.o
# All objects that the system needs to build fish # All objects that the system needs to build fish
FISH_OBJS := $(COMMON_OBJS) $(COMMON_OBJS_WITH_CODE) \ FISH_OBJS := $(COMMON_OBJS) $(COMMON_OBJS_WITH_CODE) \
@ -170,8 +170,10 @@ SHARE_DIR_FILES :=share/fish.in
TESTS_DIR_FILES := $(TEST_IN) $(TEST_IN:.in=.out) $(TEST_IN:.in=.err) \ TESTS_DIR_FILES := $(TEST_IN) $(TEST_IN:.in=.out) $(TEST_IN:.in=.err) \
$(TEST_IN:.in=.status) tests/test.fish tests/gen_output.fish $(TEST_IN:.in=.status) tests/test.fish tests/gen_output.fish
# Files in ./share/completions/
COMPLETIONS_DIR_FILES := $(wildcard share/completions/*.fish) COMPLETIONS_DIR_FILES := $(wildcard share/completions/*.fish)
# Files in ./share/functions/
FUNCTIONS_DIR_FILES := $(wildcard share/functions/*.fish) FUNCTIONS_DIR_FILES := $(wildcard share/functions/*.fish)
# Programs to build # Programs to build
@ -483,11 +485,11 @@ fish_tests: $(FISH_TESTS_OBJS)
$(CC) $(FISH_TESTS_OBJS) $(LDFLAGS) -o $@ $(CC) $(FISH_TESTS_OBJS) $(LDFLAGS) -o $@
mimedb: $(MIME_OBJS) doc_src/mimedb.c mimedb: $(MIME_OBJS) doc_src/mimedb.o
$(CC) ${MIME_OBJS} doc_src/mimedb.c $(LDFLAGS) -o $@ $(CC) ${MIME_OBJS} doc_src/mimedb.o $(LDFLAGS) -o $@
set_color: set_color.o doc_src/set_color.c set_color: set_color.o doc_src/set_color.o
$(CC) set_color.o doc_src/set_color.c $(LDFLAGS) -o $@ $(CC) set_color.o doc_src/set_color.o $(LDFLAGS) -o $@
# Test program for the tokenizer library # Test program for the tokenizer library
tokenizer_test: tokenizer.c tokenizer.h util.o wutil.o common.o tokenizer_test: tokenizer.c tokenizer.h util.o wutil.o common.o

View file

@ -10,12 +10,12 @@ if test configure -ot configure.ac; then
# shell and autconf should take care of that themselves # shell and autconf should take care of that themselves
AC_MSG_NOTICE([running autoconf]) AC_MSG_NOTICE([running autoconf])
if autoconf; then if autoconf; then
./configure $@ ./configure "$@"
fi fi
exit exit
else else
AC_MSG_ERROR( [cannot find the autoconf program in your path. AC_MSG_ERROR( [cannot find the autoconf program in your path.
This program is needs to be run whenever the configure.ac file is modified. This program needs to be run whenever the configure.ac file is modified.
Please install it and try again.]) Please install it and try again.])
fi fi
else else
@ -32,7 +32,7 @@ if test ! -f ./config.h.in -o config.h.in -ot configure.ac; then
autoheader autoheader
else else
AC_MSG_ERROR( [cannot find the autoheader program in your path. AC_MSG_ERROR( [cannot find the autoheader program in your path.
This program is needs to be run whenever the configure.ac file is modified. This program needs to be run whenever the configure.ac file is modified.
Please install it and try again.]) Please install it and try again.])
fi fi
else else
@ -112,6 +112,31 @@ else
AC_SUBST( XSEL_MAN_PATH,[ ]) AC_SUBST( XSEL_MAN_PATH,[ ])
fi fi
#
# Test if the compiler accepts the -std=c99 flag. If so, that
# increases the odds of correct compilation, since we want to use the
# *wprintf functions, which where defined in C99.
#
XCFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -std=c99"
AC_MSG_CHECKING(if -std=c99 works)
AC_CACHE_VAL(local_cv_has__std_c99,[
AC_TRY_RUN([
#include <stdlib.h>
#include <stdio.h>
int main() {
return 0;
}],
local_cv_has__std_c99=yes,
local_cv_has__std_c99=no,
)])
AC_MSG_RESULT($local_cv_has__std_c99)
case x$local_cv_has__std_c99 in
xno) CFLAGS="$XCFLAGS" ;;
esac
# #
# If we are using gcc, set some flags that increase the odds of the # If we are using gcc, set some flags that increase the odds of the
# compiler producing a working binary... # compiler producing a working binary...
@ -119,16 +144,6 @@ fi
if test "$CC" = gcc; then if test "$CC" = gcc; then
#
# This seems to be needed in some glibc versions in order to get
# the prototypes for wide character functions like wcsdup and
# fwprintf. Fish should not actually use anu C99-specific
# features - if it does, please report this as a bug.
#
CFLAGS="$CFLAGS -std=c99"
# #
# -fno-optimize-sibling-calls seems to work around a bug where # -fno-optimize-sibling-calls seems to work around a bug where
# sending a SIGWINCH to fish on NetBSD causes fish to exit when # sending a SIGWINCH to fish on NetBSD causes fish to exit when
@ -148,27 +163,54 @@ if test "$CC" = gcc; then
CFLAGS="$CFLAGS -Wall" CFLAGS="$CFLAGS -Wall"
#
# This gives us access to prototypes for gnu extensions if we are
# compiling agains glibc. All extensions that are used must have a
# fallback implementation available in fallback.h, in order to
# keep fish working on non-gnu platforms.
#
CFLAGS="$CFLAGS -D _GNU_SOURCE"
fi fi
# Check if we are compiling against glibc
AC_MSG_CHECKING([if we are compiling against glibc])
AC_RUN_IFELSE(
[AC_LANG_PROGRAM([
#include <stdlib.h>
#ifdef __GLIBC__
#define STATUS 0
#else
#define STATUS 1
#endif],
[return STATUS;])],
[glibc=yes],
[glibc=no] )
if test "$glibc" = yes; then
AC_MSG_RESULT(yes)
#
# This gives us access to prototypes for gnu extensions and C99
# functions if we are compiling agains glibc. All GNU extensions
# that are used must have a fallback implementation available in
# fallback.h, in order to keep fish working on non-gnu platforms.
#
CFLAGS="$CFLAGS -D _GNU_SOURCE -D _ISOC99_SOURCE"
else
AC_MSG_RESULT(no)
fi
# Test cpu for special handling of ppc # Test cpu for special handling of ppc
#
# This is used to skip use of tputs on ppc systems, since it seemed to
# be broken, at least on older debin-based systems. This is obviously
# not the right way to to detect whether this workaround should be
# used, since it catches far to many systems, but I do not have the
# hardware available to narrow this problem down, and in practice, it
# seems that tputs is never really needed.
#
AC_CANONICAL_TARGET AC_CANONICAL_TARGET
if test $target_cpu = powerpc; then if test $target_cpu = powerpc; then
AC_DEFINE([TPUTS_KLUDGE],[1],[Evil kludge to get Power based machines to work]) AC_DEFINE([TPUTS_KLUDGE],[1],[Evil kludge to get Power based machines to work])
fi fi
AC_DEFINE_UNQUOTED([CPU],[L"$target_cpu"],[CPU type])
# Set up PREFIX and related preprocessor symbols. Fish needs to know # Set up PREFIX and related preprocessor symbols. Fish needs to know
# where it will be installed. One of the reasons for this is so that # where it will be installed. One of the reasons for this is so that
@ -208,6 +250,12 @@ AC_SUBST( [LOCALEDIR], [$datadir/locale])
# information about running processes. # information about running processes.
AC_CHECK_FILES([/proc/self/stat]) AC_CHECK_FILES([/proc/self/stat])
# This is ued to tell the wgetopt library to translate strings. This
# way wgetopt can be dropped into any project without requiring i18n.
AC_DEFINE([HAVE_TRANSLATE_H], [1],
[Define to 1 if the wgettext function should be used for translating strings.])
# Check for presense of various libraries # Check for presense of various libraries
AC_SEARCH_LIBS( gettext, intl, AC_SUBST( HAVE_GETTEXT, [1] ), AC_SUBST( HAVE_GETTEXT, [0] ) ) AC_SEARCH_LIBS( gettext, intl, AC_SUBST( HAVE_GETTEXT, [1] ), AC_SUBST( HAVE_GETTEXT, [0] ) )
AC_SEARCH_LIBS( connect, socket, , [AC_MSG_ERROR([Cannot find the socket library, needed to build this package.] )] ) AC_SEARCH_LIBS( connect, socket, , [AC_MSG_ERROR([Cannot find the socket library, needed to build this package.] )] )
@ -248,9 +296,10 @@ else
AC_MSG_RESULT(no) AC_MSG_RESULT(no)
fi fi
# If we have a fwprintf in libc, test that it actually works. As of
# March 2006, it is broken under Dragonfly BSD.
if test "$ac_cv_func_fwprintf" = yes; then if test "$ac_cv_func_fwprintf" = yes; then
# Check if fwprintf is broken
AC_MSG_CHECKING([if fwprintf is broken]) AC_MSG_CHECKING([if fwprintf is broken])
AC_RUN_IFELSE( AC_RUN_IFELSE(
[AC_LANG_PROGRAM([ [AC_LANG_PROGRAM([
@ -321,9 +370,6 @@ else
AC_MSG_RESULT(no) AC_MSG_RESULT(no)
fi fi
AC_DEFINE([HAVE_TRANSLATE_H], [1],
[Define to 1 if the wgettext function should be used for translating strings.])
# Check for _nl_msg_cat_cntr symbol # Check for _nl_msg_cat_cntr symbol
AC_MSG_CHECKING([for _nl_msg_cat_cntr symbol]) AC_MSG_CHECKING([for _nl_msg_cat_cntr symbol])
AC_TRY_LINK([#if HAVE_LIBINTL_H] AC_TRY_LINK([#if HAVE_LIBINTL_H]
@ -344,5 +390,4 @@ AC_CONFIG_FILES([Makefile fish.spec doc_src/fish.1 doc_src/Doxyfile etc/fish etc
AC_OUTPUT AC_OUTPUT
echo "fish is now configured." echo "fish is now configured."
echo "Now run 'make' and 'make install' to built and install fish." echo "Use 'make' and 'make install' to built and install fish."
echo "Good luck!"