From: Peter Johnson Date: Thu, 20 Sep 2001 06:25:05 +0000 (-0000) Subject: Try to fix configure and automake files so everything builds a bit cleaner. X-Git-Tag: v0.1.0~314 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=91f41e241b5ac7076ef8f8b302793e3fc5ff5bf3;p=yasm Try to fix configure and automake files so everything builds a bit cleaner. Also try to fix the warnings on the GNU C Library. Still a lot of work and testing to be done here, but making progress. svn path=/trunk/yasm/; revision=204 --- diff --git a/acconfig.h b/acconfig.h index 50f402f2..2d3917e9 100644 --- a/acconfig.h +++ b/acconfig.h @@ -21,6 +21,9 @@ /* combined test for fork/way/msg* */ #undef USE_FORKWAITMSG +/* Check for GNU C Library */ +#undef HAVE_GNU_C_LIBRARY + @BOTTOM@ #endif /* YASM_CONFIG_H */ diff --git a/check/Makefile.am b/check/Makefile.am index f6b205a7..14634626 100644 --- a/check/Makefile.am +++ b/check/Makefile.am @@ -28,9 +28,7 @@ nocheck_error: @echo "Run configure with --enable-check before running make check" @exit 1 -if DEV -CFLAGS = -ansi -pedantic -Wall -g -endif +CFLAGS = @ANSI_CFLAGS@ @CHECK_CFLAGS@ EXTRA_DIST = \ NEWS \ diff --git a/configure.ac b/configure.ac index 03227f5b..ab07d5de 100644 --- a/configure.ac +++ b/configure.ac @@ -28,6 +28,17 @@ AM_CONDITIONAL(CHECK, test x$check = xtrue) AM_PROG_CC_STDC +if ${dev}; then + DEVFLAGS="-g" +fi + +if test "$GCC" = yes; then + ANSI_CFLAGS="-ansi -pedantic -Wall $DEVFLAGS" +else + ANSI_CFLAGS="$DEVFLAGS" +fi +AC_SUBST(ANSI_CFLAGS) + ALL_LINGUAS="" AM_GNU_GETTEXT @@ -74,7 +85,24 @@ AC_REPLACE_FUNCS(strdup strtoul) AC_CHECK_HEADERS(limits.h sys/queue.h sys/cdefs.h) +# Check for GNU C Library +AC_CHECK_HEADERS(features.h) +if test "$ac_cv_header_features_h" = yes; then + AC_MSG_CHECKING([for GNU C Library]) + AC_EGREP_CPP(gnulib, + [#include + #ifdef __GNU_LIBRARY__ + gnulib + #endif + ], have_gnulib=yes, have_gnulib=no) + AC_MSG_RESULT([$have_gnulib]) + if test "$have_gnulib" = yes; then + AC_DEFINE(HAVE_GNU_C_LIBRARY) + fi +fi + # Check for stuff wanted by the test suite. None of this is required. +CHECK_CFLAGS= if ${check}; then AC_CHECK_FUNCS(fork wait msgctl msgget msgrcv msgsnd strerror) if test "$ac_cv_func_fork" = yes && @@ -84,11 +112,13 @@ if ${check}; then test "$ac_cv_func_msgrcv" = yes && test "$ac_cv_func_msgsnd" = yes; then AC_DEFINE(USE_FORKWAITMSG) + CHECK_CFLAGS="-D_SVID_SOURCE" fi AC_TYPE_PID_T AC_HEADER_SYS_WAIT AC_CHECK_HEADERS(sys/types.h sys/ipc.h sys/msg.h unistd.h) fi +AC_SUBST(CHECK_CFLAGS) # Check for some target-specific stuff case "$host" in diff --git a/configure.in b/configure.in index 03227f5b..ab07d5de 100644 --- a/configure.in +++ b/configure.in @@ -28,6 +28,17 @@ AM_CONDITIONAL(CHECK, test x$check = xtrue) AM_PROG_CC_STDC +if ${dev}; then + DEVFLAGS="-g" +fi + +if test "$GCC" = yes; then + ANSI_CFLAGS="-ansi -pedantic -Wall $DEVFLAGS" +else + ANSI_CFLAGS="$DEVFLAGS" +fi +AC_SUBST(ANSI_CFLAGS) + ALL_LINGUAS="" AM_GNU_GETTEXT @@ -74,7 +85,24 @@ AC_REPLACE_FUNCS(strdup strtoul) AC_CHECK_HEADERS(limits.h sys/queue.h sys/cdefs.h) +# Check for GNU C Library +AC_CHECK_HEADERS(features.h) +if test "$ac_cv_header_features_h" = yes; then + AC_MSG_CHECKING([for GNU C Library]) + AC_EGREP_CPP(gnulib, + [#include + #ifdef __GNU_LIBRARY__ + gnulib + #endif + ], have_gnulib=yes, have_gnulib=no) + AC_MSG_RESULT([$have_gnulib]) + if test "$have_gnulib" = yes; then + AC_DEFINE(HAVE_GNU_C_LIBRARY) + fi +fi + # Check for stuff wanted by the test suite. None of this is required. +CHECK_CFLAGS= if ${check}; then AC_CHECK_FUNCS(fork wait msgctl msgget msgrcv msgsnd strerror) if test "$ac_cv_func_fork" = yes && @@ -84,11 +112,13 @@ if ${check}; then test "$ac_cv_func_msgrcv" = yes && test "$ac_cv_func_msgsnd" = yes; then AC_DEFINE(USE_FORKWAITMSG) + CHECK_CFLAGS="-D_SVID_SOURCE" fi AC_TYPE_PID_T AC_HEADER_SYS_WAIT AC_CHECK_HEADERS(sys/types.h sys/ipc.h sys/msg.h unistd.h) fi +AC_SUBST(CHECK_CFLAGS) # Check for some target-specific stuff case "$host" in diff --git a/libyasm/tests/Makefile.am b/libyasm/tests/Makefile.am index 7dc55967..9938959c 100644 --- a/libyasm/tests/Makefile.am +++ b/libyasm/tests/Makefile.am @@ -1,5 +1,7 @@ # $IdPath$ +CFLAGS = @ANSI_CFLAGS@ + if CHECK TESTS = \ bytecode_test diff --git a/libyasm/util.h b/libyasm/util.h index 0d56e213..320a9575 100644 --- a/libyasm/util.h +++ b/libyasm/util.h @@ -22,11 +22,11 @@ #ifndef YASM_UTIL_H #define YASM_UTIL_H -#ifndef HAVE_STRDUP +#if !defined(HAVE_STRDUP) || defined(HAVE_GNU_C_LIBRARY) char *strdup(const char *str); #endif -#ifndef HAVE_STRTOUL +#if !defined(HAVE_STRTOUL) || defined(HAVE_GNU_C_LIBRARY) unsigned long strtoul(const char *nptr, char **endptr, int base); #endif @@ -39,12 +39,15 @@ unsigned long strtoul(const char *nptr, char **endptr, int base); # define strcasecmp(x, y) strncmpi(x, y) # else # define USE_OUR_OWN_STRCASECMP +# endif +#endif + +#if defined(USE_OUR_OWN_STRCASECMP) || defined(HAVE_GNU_C_LIBRARY) int strcasecmp(const char *s1, const char *s2); int strncasecmp(const char *s1, const char *s2, size_t n); -# endif #endif -#ifndef HAVE_TOASCII +#if !defined(HAVE_TOASCII) || defined(HAVE_GNU_C_LIBRARY) # define toascii(c) ((c) & 0x7F) #endif diff --git a/modules/objfmts/dbg/Makefile.am b/modules/objfmts/dbg/Makefile.am index 8c74d03e..6cbd9931 100644 --- a/modules/objfmts/dbg/Makefile.am +++ b/modules/objfmts/dbg/Makefile.am @@ -9,6 +9,4 @@ INCLUDES = \ -I$(top_srcdir)/src \ -I$(top_builddir)/intl -if DEV -CFLAGS = -ansi -pedantic -Wall -g -endif +CFLAGS = @ANSI_CFLAGS@ diff --git a/modules/optimizers/basic/Makefile.am b/modules/optimizers/basic/Makefile.am index 351ce73b..31ea1c2a 100644 --- a/modules/optimizers/basic/Makefile.am +++ b/modules/optimizers/basic/Makefile.am @@ -9,6 +9,4 @@ INCLUDES = \ -I$(top_srcdir)/src \ -I$(top_builddir)/intl -if DEV -CFLAGS = -ansi -pedantic -Wall -g -endif +CFLAGS = @ANSI_CFLAGS@ diff --git a/modules/optimizers/dbg/Makefile.am b/modules/optimizers/dbg/Makefile.am index 351ce73b..31ea1c2a 100644 --- a/modules/optimizers/dbg/Makefile.am +++ b/modules/optimizers/dbg/Makefile.am @@ -9,6 +9,4 @@ INCLUDES = \ -I$(top_srcdir)/src \ -I$(top_builddir)/intl -if DEV -CFLAGS = -ansi -pedantic -Wall -g -endif +CFLAGS = @ANSI_CFLAGS@ diff --git a/modules/parsers/nasm/Makefile.am b/modules/parsers/nasm/Makefile.am index fd394472..0328aa5d 100644 --- a/modules/parsers/nasm/Makefile.am +++ b/modules/parsers/nasm/Makefile.am @@ -31,9 +31,7 @@ INCLUDES = \ -I$(top_srcdir)/src \ -I$(top_builddir)/intl -if DEV -CFLAGS = -ansi -pedantic -Wall -g -endif +CFLAGS = @ANSI_CFLAGS@ token.l bison.y: $(top_srcdir)/src/instrs.dat token.l.in bison.y.in gen_instr.pl if DEV diff --git a/modules/preprocs/raw/Makefile.am b/modules/preprocs/raw/Makefile.am index 55874d15..6b9c8ce7 100644 --- a/modules/preprocs/raw/Makefile.am +++ b/modules/preprocs/raw/Makefile.am @@ -9,6 +9,4 @@ INCLUDES = \ -I$(top_srcdir)/src \ -I$(top_builddir)/intl -if DEV -CFLAGS = -ansi -pedantic -Wall -g -endif +CFLAGS = @ANSI_CFLAGS@ diff --git a/src/Makefile.am b/src/Makefile.am index 8e9cc755..f97493d8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -41,9 +41,7 @@ libyasm_a_SOURCES = \ optimizer.h \ strcasecmp.c -if DEV -CFLAGS = -ansi -pedantic -Wall -g -endif +CFLAGS = @ANSI_CFLAGS@ EXTRA_DIST = \ instrs.dat \ diff --git a/src/objfmts/dbg/Makefile.am b/src/objfmts/dbg/Makefile.am index 8c74d03e..6cbd9931 100644 --- a/src/objfmts/dbg/Makefile.am +++ b/src/objfmts/dbg/Makefile.am @@ -9,6 +9,4 @@ INCLUDES = \ -I$(top_srcdir)/src \ -I$(top_builddir)/intl -if DEV -CFLAGS = -ansi -pedantic -Wall -g -endif +CFLAGS = @ANSI_CFLAGS@ diff --git a/src/optimizers/basic/Makefile.am b/src/optimizers/basic/Makefile.am index 351ce73b..31ea1c2a 100644 --- a/src/optimizers/basic/Makefile.am +++ b/src/optimizers/basic/Makefile.am @@ -9,6 +9,4 @@ INCLUDES = \ -I$(top_srcdir)/src \ -I$(top_builddir)/intl -if DEV -CFLAGS = -ansi -pedantic -Wall -g -endif +CFLAGS = @ANSI_CFLAGS@ diff --git a/src/optimizers/dbg/Makefile.am b/src/optimizers/dbg/Makefile.am index 351ce73b..31ea1c2a 100644 --- a/src/optimizers/dbg/Makefile.am +++ b/src/optimizers/dbg/Makefile.am @@ -9,6 +9,4 @@ INCLUDES = \ -I$(top_srcdir)/src \ -I$(top_builddir)/intl -if DEV -CFLAGS = -ansi -pedantic -Wall -g -endif +CFLAGS = @ANSI_CFLAGS@ diff --git a/src/parsers/nasm/Makefile.am b/src/parsers/nasm/Makefile.am index fd394472..0328aa5d 100644 --- a/src/parsers/nasm/Makefile.am +++ b/src/parsers/nasm/Makefile.am @@ -31,9 +31,7 @@ INCLUDES = \ -I$(top_srcdir)/src \ -I$(top_builddir)/intl -if DEV -CFLAGS = -ansi -pedantic -Wall -g -endif +CFLAGS = @ANSI_CFLAGS@ token.l bison.y: $(top_srcdir)/src/instrs.dat token.l.in bison.y.in gen_instr.pl if DEV diff --git a/src/preprocs/raw/Makefile.am b/src/preprocs/raw/Makefile.am index 55874d15..6b9c8ce7 100644 --- a/src/preprocs/raw/Makefile.am +++ b/src/preprocs/raw/Makefile.am @@ -9,6 +9,4 @@ INCLUDES = \ -I$(top_srcdir)/src \ -I$(top_builddir)/intl -if DEV -CFLAGS = -ansi -pedantic -Wall -g -endif +CFLAGS = @ANSI_CFLAGS@ diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am index 7dc55967..9938959c 100644 --- a/src/tests/Makefile.am +++ b/src/tests/Makefile.am @@ -1,5 +1,7 @@ # $IdPath$ +CFLAGS = @ANSI_CFLAGS@ + if CHECK TESTS = \ bytecode_test diff --git a/src/util.h b/src/util.h index 0d56e213..320a9575 100644 --- a/src/util.h +++ b/src/util.h @@ -22,11 +22,11 @@ #ifndef YASM_UTIL_H #define YASM_UTIL_H -#ifndef HAVE_STRDUP +#if !defined(HAVE_STRDUP) || defined(HAVE_GNU_C_LIBRARY) char *strdup(const char *str); #endif -#ifndef HAVE_STRTOUL +#if !defined(HAVE_STRTOUL) || defined(HAVE_GNU_C_LIBRARY) unsigned long strtoul(const char *nptr, char **endptr, int base); #endif @@ -39,12 +39,15 @@ unsigned long strtoul(const char *nptr, char **endptr, int base); # define strcasecmp(x, y) strncmpi(x, y) # else # define USE_OUR_OWN_STRCASECMP +# endif +#endif + +#if defined(USE_OUR_OWN_STRCASECMP) || defined(HAVE_GNU_C_LIBRARY) int strcasecmp(const char *s1, const char *s2); int strncasecmp(const char *s1, const char *s2, size_t n); -# endif #endif -#ifndef HAVE_TOASCII +#if !defined(HAVE_TOASCII) || defined(HAVE_GNU_C_LIBRARY) # define toascii(c) ((c) & 0x7F) #endif diff --git a/tests/Makefile.am b/tests/Makefile.am index 5a72427b..537a2069 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,5 +1,7 @@ # $IdPath$ +CFLAGS = @ANSI_CFLAGS@ + if CHECK #TESTS = \ diff --git a/util.h b/util.h index 0d56e213..320a9575 100644 --- a/util.h +++ b/util.h @@ -22,11 +22,11 @@ #ifndef YASM_UTIL_H #define YASM_UTIL_H -#ifndef HAVE_STRDUP +#if !defined(HAVE_STRDUP) || defined(HAVE_GNU_C_LIBRARY) char *strdup(const char *str); #endif -#ifndef HAVE_STRTOUL +#if !defined(HAVE_STRTOUL) || defined(HAVE_GNU_C_LIBRARY) unsigned long strtoul(const char *nptr, char **endptr, int base); #endif @@ -39,12 +39,15 @@ unsigned long strtoul(const char *nptr, char **endptr, int base); # define strcasecmp(x, y) strncmpi(x, y) # else # define USE_OUR_OWN_STRCASECMP +# endif +#endif + +#if defined(USE_OUR_OWN_STRCASECMP) || defined(HAVE_GNU_C_LIBRARY) int strcasecmp(const char *s1, const char *s2); int strncasecmp(const char *s1, const char *s2, size_t n); -# endif #endif -#ifndef HAVE_TOASCII +#if !defined(HAVE_TOASCII) || defined(HAVE_GNU_C_LIBRARY) # define toascii(c) ((c) & 0x7F) #endif