From 8cb0d6d7fa9aaac316c29a64c541336b51b6f93d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Wed, 12 Mar 2014 14:35:07 +0100 Subject: [PATCH] build: Don't include in native programs when cross-compiling. * libguile/Makefile.am (gen-scmconfig.$(OBJEXT)): When cross-compiling, pass -DCROSS_COMPILING=1. (c-tokenize.$(OBJEXT)): Likewise. * libguile/c-tokenize.lex (%top): Include only when CROSS_COMPILING is undefined. * libguile/gen-scmconfig.c: Likewise. --- libguile/Makefile.am | 24 +++++++++++++----------- libguile/c-tokenize.lex | 9 +++++++-- libguile/gen-scmconfig.c | 8 +++++--- 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/libguile/Makefile.am b/libguile/Makefile.am index 6a631d89f..9be6d0fda 100644 --- a/libguile/Makefile.am +++ b/libguile/Makefile.am @@ -60,12 +60,13 @@ gen_scmconfig_SOURCES = gen-scmconfig.c ## the generated config.h and gen-scmconfig.h. Nothing else from Guile ## is included by this code generator. gen-scmconfig.$(OBJEXT): gen-scmconfig.c - $(AM_V_GEN) \ - if [ "$(cross_compiling)" = "yes" ]; then \ - $(CC_FOR_BUILD) $(DEFS) $(DEFAULT_INCLUDES) -I$(top_builddir) \ - -c -o $@ $<; \ - else \ - $(COMPILE) -c -o $@ $<; \ + $(AM_V_GEN) \ + if [ "$(cross_compiling)" = "yes" ]; then \ + $(CC_FOR_BUILD) -DCROSS_COMPILING=1 $(DEFS) \ + $(DEFAULT_INCLUDES) -I$(top_builddir) \ + -c -o "$@" "$<"; \ + else \ + $(COMPILE) -c -o "$@" "$<"; \ fi ## Override default rule; this should run on BUILD host. @@ -92,11 +93,12 @@ guile_filter_doc_snarfage_SOURCES = c-tokenize.c ## Override default rule; this should be compiled for BUILD host. ## For some reason, OBJEXT does not include the dot c-tokenize.$(OBJEXT): c-tokenize.c - $(AM_V_GEN) \ - if [ "$(cross_compiling)" = "yes" ]; then \ - $(CC_FOR_BUILD) -I$(top_builddir) -c -o $@ $<; \ - else \ - $(COMPILE) -c -o $@ $<; \ + $(AM_V_GEN) \ + if [ "$(cross_compiling)" = "yes" ]; then \ + $(CC_FOR_BUILD) -DCROSS_COMPILING=1 -I$(top_builddir) \ + -c -o "$@" "$<"; \ + else \ + $(COMPILE) -c -o "$@" "$<"; \ fi ## Override default rule; this should run on BUILD host. diff --git a/libguile/c-tokenize.lex b/libguile/c-tokenize.lex index a64b61da4..03fe9898c 100644 --- a/libguile/c-tokenize.lex +++ b/libguile/c-tokenize.lex @@ -1,7 +1,12 @@ %top{ /* Include before anything else because Gnulib headers such - as rely on it. */ -#include + as rely on it. + + However, when cross-compiling, don't include because it + contains information about the host, not about the build. */ +#ifndef CROSS_COMPILING +# include +#endif } %option noyywrap diff --git a/libguile/gen-scmconfig.c b/libguile/gen-scmconfig.c index 2f6fa6e6a..3c8be4f8e 100644 --- a/libguile/gen-scmconfig.c +++ b/libguile/gen-scmconfig.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2013 Free Software Foundation, Inc. +/* Copyright (C) 2003-2014 Free Software Foundation, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -132,8 +132,10 @@ **********************************************************************/ -#ifdef HAVE_CONFIG_H -# include +/* Don't include when cross-compiling because it contains + information about the host, not about the build machine. */ +#ifndef CROSS_COMPILING +# include #endif #include