From 10add4c7fbb4076b69e27c524e24081067c39f40 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Fri, 16 Feb 2007 19:24:25 +0000 Subject: [PATCH] Better support cross-compiling. Patch #19003. --- ChangeLog | 12 ++++++++++++ Makefile.am | 6 ++++-- acinclude.m4 | 35 ++++++++++++++++++++++++++++++++++ configure.ac | 2 +- src/language/lexer/ChangeLog | 11 +++++++++++ src/language/lexer/automake.mk | 6 +++--- src/language/lexer/q2c.c | 27 +++++++++++++++++++------- 7 files changed, 86 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 814e3b44..8b5d7a18 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +Fri Feb 16 10:50:38 2007 Ben Pfaff + + Better support cross-compiling by using CC_FOR_BUILD and + EXEEXT_FOR_BUILD for q2c. + + * Makefile.am: Add CC_FOR_BUILD, EXEEXT_FOR_BUILD variables. Use + in .q.c rule. + + * acinclude.m4: Add PSPP_CC_FOR_BUILD macro. + + * configure.ac: Call PSPP_CC_FOR_BUILD. + Mon Feb 12 16:39:18 2007 Ben Pfaff * README: Note that iconv is required. diff --git a/Makefile.am b/Makefile.am index 0b37ce97..d02ed4e1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -16,11 +16,13 @@ AM_CFLAGS+=-Wall -W -Wwrite-strings -Wstrict-prototypes \ -Wpointer-arith -Wno-sign-compare -Wmissing-prototypes endif +CC_FOR_BUILD = @CC_FOR_BUILD@ +EXEEXT_FOR_BUILD = @EXEEXT_FOR_BUILD@ .q.c: @$(top_srcdir)/mkinstalldirs `dirname $@` - ./src/language/lexer/q2c $< $@ + ./src/language/lexer/q2c$(EXEEXT_FOR_BUILD) $< $@ -$(all_q_sources:.q=.c): src/language/lexer/q2c$(EXEEXT) +$(all_q_sources:.q=.c): src/language/lexer/q2c$(EXEEXT_FOR_BUILD) all_q_sources = pkgsysconfdir = $(sysconfdir)/@PACKAGE@ diff --git a/acinclude.m4 b/acinclude.m4 index 6fc3085c..e15ab767 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -150,4 +150,39 @@ AC_DEFUN([PSPP_READLINE], AC_SUBST(LTLIBREADLINE) ]) +dnl Check for build tools. Adapted from bfd library. + +AC_DEFUN([PSPP_CC_FOR_BUILD], +[# Put a plausible default for CC_FOR_BUILD in Makefile. +if test -z "$CC_FOR_BUILD"; then + if test "x$cross_compiling" = "xno"; then + CC_FOR_BUILD='$(CC)' + else + CC_FOR_BUILD=cc + fi +fi +AC_SUBST(CC_FOR_BUILD) +# Also set EXEEXT_FOR_BUILD. +if test "x$cross_compiling" = "xno"; then + EXEEXT_FOR_BUILD='$(EXEEXT)' +else + AC_CACHE_CHECK([for build system executable suffix], pspp_cv_build_exeext, + [rm -f conftest* + echo 'int main () { return 0; }' > conftest.c + pspp_cv_build_exeext= + ${CC_FOR_BUILD} -o conftest conftest.c 1>&5 2>&5 + for file in conftest.*; do + case $file in # ( + *.c | *.o | *.obj | *.ilk | *.pdb) ;; # ( + *) pspp_cv_build_exeext=`echo $file | sed -e s/conftest//` ;; + esac + done + rm -f conftest* + test x"${pspp_cv_build_exeext}" = x && pspp_cv_build_exeext=no]) + EXEEXT_FOR_BUILD="" + test x"${pspp_cv_build_exeext}" != xno && EXEEXT_FOR_BUILD=${pspp_cv_build_exeex +t} +fi +AC_SUBST(EXEEXT_FOR_BUILD)]) + dnl aclocal.m4 ends here diff --git a/configure.ac b/configure.ac index 2fa7901d..16a2e471 100644 --- a/configure.ac +++ b/configure.ac @@ -18,7 +18,7 @@ PSPP_ENABLE_WARNING(-Wdeclaration-after-statement) AM_CONDITIONAL(cc_is_gcc, test x"$GCC" = x"yes" ) - +PSPP_CC_FOR_BUILD PSPP_PERL dnl Internationalization macros. diff --git a/src/language/lexer/ChangeLog b/src/language/lexer/ChangeLog index f29c5859..8d69b868 100644 --- a/src/language/lexer/ChangeLog +++ b/src/language/lexer/ChangeLog @@ -1,3 +1,14 @@ +Fri Feb 16 11:14:42 2007 Ben Pfaff + + Better support cross-compiling by using CC_FOR_BUILD and + EXEEXT_FOR_BUILD for q2c. + + * automake.mk: Use EXEEXT_FOR_BUILD and CC_FOR_BUILD to build and + clean q2c. + + * q2c.c: Avoid external dependencies, besides the standard C + library. + Sun Feb 11 20:31:51 2007 Ben Pfaff * q2c.c: Make q2c link under mingw32, by eliminating the diff --git a/src/language/lexer/automake.mk b/src/language/lexer/automake.mk index 87808a3d..a82114e1 100644 --- a/src/language/lexer/automake.mk +++ b/src/language/lexer/automake.mk @@ -15,9 +15,9 @@ language_lexer_sources = \ EXTRA_DIST += src/language/lexer/q2c.c -src/language/lexer/q2c$(EXEEXT): $(top_srcdir)/src/language/lexer/q2c.c +src/language/lexer/q2c$(EXEEXT_FOR_BUILD): $(top_srcdir)/src/language/lexer/q2c.c @$(top_srcdir)/mkinstalldirs `dirname $@` - $(CC) $(DEFAULT_INCLUDES) $(AM_CPPFLAGS) $(top_srcdir)/src/language/lexer/q2c.c -o $@ + $(CC_FOR_BUILD) $(top_srcdir)/src/language/lexer/q2c.c -o $(top_builddir)/src/language/lexer/q2c -CLEANFILES += src/language/lexer/q2c$(EXEEXT) +CLEANFILES += src/language/lexer/q2c$(EXEEXT_FOR_BUILD) diff --git a/src/language/lexer/q2c.c b/src/language/lexer/q2c.c index 4ba008fa..f187d242 100644 --- a/src/language/lexer/q2c.c +++ b/src/language/lexer/q2c.c @@ -16,8 +16,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include - #include #include #include @@ -28,11 +26,26 @@ #include #include -#include -#include +/* GNU C allows the programmer to declare that certain functions take + printf-like arguments, never return, etc. Conditionalize these + declarations on whether gcc is in use. */ +#if __GNUC__ > 1 +#define ATTRIBUTE(X) __attribute__ (X) +#else +#define ATTRIBUTE(X) +#endif + +/* Marks a function argument as possibly not used. */ +#define UNUSED ATTRIBUTE ((unused)) + +/* Marks a function that will never return. */ +#define NO_RETURN ATTRIBUTE ((noreturn)) + +/* Mark a function as taking a printf- or scanf-like format + string as its FMT'th argument and that the FIRST'th argument + is the first one to be checked against the format string. */ +#define PRINTF_FORMAT(FMT, FIRST) ATTRIBUTE ((format (__printf__, FMT, FIRST))) -#include "exit.h" - /* Max length of an input line. */ #define MAX_LINE_LEN 1024 @@ -1322,7 +1335,7 @@ dump_vars_init (int persistent) break; default: - NOT_REACHED (); + abort (); } } } -- 2.30.2