[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Order of AM_CPPFLAGS and other xxx_CFLAGS

From: Rik
Subject: Re: Order of AM_CPPFLAGS and other xxx_CFLAGS
Date: Sun, 17 Nov 2013 09:14:46 -0800

On 11/14/2013 07:57 PM, Michael Goffioul wrote:
> Rik,
> This changeset breaks my compilation with MSVC:
> http://hg.savannah.gnu.org/hgweb/octave/rev/a230b996ae8a
> The problem is that compilation of (among others) __init_fltk__.cc uses
> now the following CPPFLAGS definition:
> The variable GRAPHICS_CFLAGS, pulled from fltk-config, contains a -Ixxx
> statement containing the base installation directory of my MXE system.
> The libgnu directory, on the other hand, is part of AM_CPPFLAGS. As a
> result, gnulib header substitution fails for some headers. A similar
> problem could also occur on Linux if any of the variables preceding
> AM_CPPFLAGS happen to contain -I/usr/include. I believe the libgnu
> directory should appear early in the include chain, otherwise it'll fail
> to override what it's supposed to override.
Ugh.  This doesn't look like it is going to be fun to solve.

The changeset was made to fix bug #36064
(https://savannah.gnu.org/bugs/?func=detailitem&item_id=36064) and I do
like the approach taken.  Thus, I'd like to pursue the minimally disturbing
changeset that allows MSVC to compile.  Base compiling of Octave, no weird
cross-compilations or MXE environment, work just fine with the current
ordering so I don't think we should hack on the Octave build system. 
Instead, I think something specific to MXE, and possibly specific to using
the MSVC compiler, should be enough.

One solution, would be to add a new diff file 'msvc-octave-2.patch' to the
the src/ directory of MXE.  This patch would revert the above-mentioned
changeset just for MSVC MEX builds.

A second solution, would be to try and place libgnu earlier in the include
list.  For conventional Octave builds we had a problem with this which is
why it is always the last entry in the AM_CPPFLAGS list.  If I look at the
CXX compile command in the Makefile generated in the MXE temporary build
directory I find it has the line:

dldfcn/dldfcn___init_fltk___la-__init_fltk__.lo: dldfcn/__init_fltk__.cc
$(INCLUDES) $(dldfcn___init_fltk___la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS)
$(CXXFLAGS) -MT dldfcn/dldfcn___init_fltk___la-__init_fltk__.lo -MD -MP -MF
dldfcn/$(DEPDIR)/dldfcn___init_fltk___la-__init_fltk__.Tpo -c -o
dldfcn/dldfcn___init_fltk___la-__init_fltk__.lo `test -f
'dldfcn/__init_fltk__.cc' || echo '$(srcdir)/'`dldfcn/__init_fltk__.cc

which expands on my system to

/bin/bash ../libtool  --tag=CXX   --mode=compile i686-pc-mingw32-g++
-I/home/rik/wip/Projects_Mine/mxe-octave/usr/i686-pc-mingw32/include  -Wall
-W -Wshadow -Wold-style-cast -Wformat -Wpointer-arith -Wwrite-strings
-Wcast-align -Wcast-qual -g -O2 -pthread -MT
dldfcn/dldfcn___init_fltk___la-__init_fltk__.lo -MD -MP -MF
dldfcn/.deps/dldfcn___init_fltk___la-__init_fltk__.Tpo -c -o
dldfcn/dldfcn___init_fltk___la-__init_fltk__.lo `test -f
'dldfcn/__init_fltk__.cc' || echo

Contrary to the regular build where $(INCLUDES) is null, it seems to have
been filled with $(AM_CPPFLAGS) for the MEX build.  The important point is
that the entry for libgnu is already ahead of the base reference to
.../mxe-octave/usr/i686-pc-mingw32/include.  Maybe you can check the last
octave compilation log in mxe-octave/log/octave and see whether this is
also the case for the MSVC build.  If it is, then just putting libgnu early
isn't going to help.

A third solution would be to add another .patch file to change octave's
configure.ac to add a sed command to remove any -I
.../mxe-octave/usr/i686-pc-mingw32/include entry from *both*

Finally, I think the problem may mostly be with FLTK which has it's own
math.h file.  Various FLTK files use '#include "FL/math.h"', but math.h
then tries to pick up a copy of "<math.h>" and through a long process you
are getting the raw math.h rather than the one in libgnu.  It might be
possible to write a different sort of .patch that adds some -D defines to
change the behavior of FL/math.h.  It's just a possibility because I notice
from the file that they are already doing some odd things on OSX and maybe
something odd needs to be done for MEX as well.

--- top of FL/math.h ---
// Xcode on OS X includes files by recursing down into directories.
// This code catches the cycle and directly includes the required file.
#ifdef fl_math_h_cyclic_include
#  include "/usr/include/math.h"

#ifndef fl_math_h
#  define fl_math_h

#  define fl_math_h_cyclic_include
#  include <math.h>
#  undef fl_math_h_cyclic_include
--- end code ---

Hopefully one of these solutions will work for you.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]