Lars, I thought I'd try and get to the bottom of this pch.h stuff.

Here's what happens now if I have separate build and source trees:

$ cd lyx/devel/build/src/tex2lyx
$ rm -f ~/lyx/devel/src/tex2lyx/pch.h.gch
$ make
make PCH_FLAGS= pch-file
make[1]: Entering directory `/home/angus/lyx/devel/build/src/tex2lyx'
g++ -DHAVE_CONFIG_H -I. -I../../../src/tex2lyx -I../../src  
-I../../../src/tex2lyx/.. -I../../../boost -Wextra -Wall 
-I/usr/X11R6/include  -g -O -fno-exceptions -x
c++-header ../../../src/tex2lyx/pch.h -MT ./pch.h.gch  -MD -MP \
        -MF "././pch.h.gch.Tdep" \
&& mv "././pch.h.gch.Tdep" "././pch.h.gch.dep" || rm "././pch.h.gch.Tdep"
make[1]: Leaving directory `/home/angus/lyx/devel/build/src/tex2lyx'
make  all-am
make[1]: Entering directory `/home/angus/lyx/devel/build/src/tex2lyx'
make[1]: Leaving directory `/home/angus/lyx/devel/build/src/tex2lyx'
$ ls -a
.           Floating.C      lyxfont.o       lyxlex_pimpl.o  preamble.o
..          Floating.o      lyxlayout.C     lyxtextclass.C  table.o
boost.o     FloatList.C     lyxlayout.h     lyxtextclass.h  tex2lyx
context.o   FloatList.o     lyxlayout.o     lyxtextclass.o  tex2lyx.o
counters.C  gettext.o       lyxlex.C        Makefile        texparser.o
counters.o  lengthcommon.o  lyxlex.o        math.o          text.o
.deps       .libs           lyxlex_pimpl.C  pch.h.gch.dep
$ ls -a .deps
.           counters.Po   lengthcommon.Po  lyxlex.Po        table.Po
..          Floating.Po   lyxfont.Po       lyxtextclass.Po  tex2lyx.Po
boost.Po    FloatList.Po  lyxlayout.Po     math.Po          texparser.Po
context.Po  gettext.Po    lyxlex_pimpl.Po  preamble.Po      text.Po
$ ls -a ~/lyx/devel/src/tex2lyx
.          CVS             lyxfont.h    preamble.C          tex2lyx.h
..         .cvsignore      Makefile.am  Spacing.h           texparser.C
boost.C    gettext.C       Makefile.in  table.C             texparser.h
ChangeLog  gettext.h       math.C       test-insets.tex     text.C
context.C  lengthcommon.C  pch.h        test-structure.tex
context.h  lyxfont.C       pch.h.gch    tex2lyx.C

The thing to note about all this is that you specify the "make target", -MT
correctly as "./pch.h.gch", but you don't actually tell the compiler to
generate this file, so it outputs it in the source directory, not the
build directory.

However, I find that explicitly passing "-o ./pch.h.gch" to the compiler
does work:

$ rm -f ~/lyx/devel/src/tex2lyx/pch.h.gch
$ g++ -DHAVE_CONFIG_H -I. -I../../../src/tex2lyx -I../../src  
-I../../../src/tex2lyx/.. -I../../../boost -Wextra -Wall 
-I/usr/X11R6/include  -g -O -fno-exceptions -x
c++-header ../../../src/tex2lyx/pch.h -o ./pch.h.gch -MT ./pch.h.gch  -MD
-MP -MF "././pch.h.gch.Tdep" && mv "././pch.h.gch.Tdep"
"././pch.h.gch.dep" || rm "././pch.h.gch.Tdep"
mv: overwrite `././pch.h.gch.dep'? y
$ ls -a
.           Floating.C      lyxfont.o       lyxlex_pimpl.o  pch.h.gch.dep
..          Floating.o      lyxlayout.C     lyxtextclass.C  preamble.o
boost.o     FloatList.C     lyxlayout.h     lyxtextclass.h  table.o
context.o   FloatList.o     lyxlayout.o     lyxtextclass.o  tex2lyx
counters.C  gettext.o       lyxlex.C        Makefile        tex2lyx.o
counters.o  lengthcommon.o  lyxlex.o        math.o          texparser.o
.deps       .libs           lyxlex_pimpl.C  pch.h.gch       text.o
$ ls -a ~/lyx/devel/src/tex2lyx
.          CVS             lyxfont.h    Spacing.h           texparser.C
..         .cvsignore      Makefile.am  table.C             texparser.h
boost.C    gettext.C       Makefile.in  test-insets.tex     text.C
ChangeLog  gettext.h       math.C       test-structure.tex
context.C  lengthcommon.C  pch.h        tex2lyx.C
context.h  lyxfont.C       preamble.C   tex2lyx.h

I'm off to bed now, but it seems that we could make progress by changing
config/common.am to explicitly define the output file, no?

Now that the .pch.h.gch file is in the build directory, I find that
compilation of an 'ordinary' file still succeeds:

$ rm -f math.o
$ if g++ -DHAVE_CONFIG_H -I. -I../../../src/tex2lyx -I../../src 
-Winvalid-pch --include=../../../src/tex2lyx/pch.h
-I../../../src/tex2lyx/.. -I../../../boost -Wextra -Wall 
-I/usr/X11R6/include  -g -O -fno-exceptions -MT math.o -MD -MP -MF
".deps/math.Tpo" -c -o math.o ../../../src/tex2lyx/math.C; then echo
success; else echo failure; fi
success

Ie, the compiler is finding the pch.h.gch file in the build directory not
in the source directory. Or do I miss something?

-- 
Angus

Reply via email to