Better support cross-compiling. Patch #19003.
authorBen Pfaff <blp@gnu.org>
Fri, 16 Feb 2007 19:24:25 +0000 (19:24 +0000)
committerBen Pfaff <blp@gnu.org>
Fri, 16 Feb 2007 19:24:25 +0000 (19:24 +0000)
ChangeLog
Makefile.am
acinclude.m4
configure.ac
src/language/lexer/ChangeLog
src/language/lexer/automake.mk
src/language/lexer/q2c.c

index 814e3b446eabf1d38912bc08b6b7c103c00f4204..8b5d7a18001d93e5e79117af7501dc08e9948c6f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+Fri Feb 16 10:50:38 2007  Ben Pfaff  <blp@gnu.org>
+
+       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  <blp@gnu.org>
 
        * README: Note that iconv is required.
index 0b37ce974ff650919c615d478e3a8033d71d3be5..d02ed4e19ad90897805063ed551b97b18b963de3 100644 (file)
@@ -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@
index 6fc3085c031e29db893a02746899c545a6aa8d29..e15ab76742376dd3ef36acd6373b0c4067c3de63 100644 (file)
@@ -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
index 2fa7901d36a437fdec409d88a48480f8a6faf0a7..16a2e47126f1150e9fcb12a2fa0fda322df41362 100644 (file)
@@ -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.
index f29c58599dcd029af6278d12aed38ffe73151a89..8d69b868f7feb75660863a8c3e083f10922dea4d 100644 (file)
@@ -1,3 +1,14 @@
+Fri Feb 16 11:14:42 2007  Ben Pfaff  <blp@gnu.org>
+
+       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  <blp@gnu.org>
 
        * q2c.c: Make q2c link under mingw32, by eliminating the
index 87808a3d7d9d04ec7e08e97e01c58cf82b9485d9..a82114e186f85fcb244ce86ac62b7904876344c0 100644 (file)
@@ -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)
index 4ba008fa3cacc668d9cb7374cf940dbf0e6378bf..f187d2427faa283eef324a2c3ba09159468b0e54 100644 (file)
@@ -16,8 +16,6 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA. */
 
-#include <config.h>
-
 #include <assert.h>
 #include <ctype.h>
 #include <stdio.h>
 #include <errno.h>
 #include <unistd.h>
 
-#include <libpspp/assertion.h>
-#include <libpspp/compiler.h>
+/* 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 ();
              }
          }
       }