This replaces of wart in the tex2lyx building process (linking certain
files from src) by a smaller wart (one extra #define)

tex2lyx building pulls in quite a bit stuff from src, and tries to keep
dependencies low by replacing Font and Spacing by dummy versions defined
in tex2lyx. This needs a bit non-obvious trickery with include paths and
linked files.

The attached patch makes this replacement more obvious by #including
the replacement headers condionally depending on a C macro 'TEX2LYX'
which is only defined when building tex2lyx. 

Andre'
Index: Spacing.h
===================================================================
--- Spacing.h   (revision 19640)
+++ Spacing.h   (working copy)
@@ -12,6 +12,10 @@
 #ifndef SPACING_H
 #define SPACING_H
 
+#ifdef TEX2LYX
+#include "tex2lyx/Spacing.h"
+#else
+
 #include <iosfwd>
 #include <string>
 
@@ -88,8 +92,9 @@
 bool operator!=(Spacing const & a, Spacing const & b)
 {
        return !(a == b);
+}
 
+} // namespace lyx
 
-} // namespace lyx
-}
-#endif
+#endif // TEX2LYX
+#endif // SPACING_H
Index: Font.h
===================================================================
--- Font.h      (revision 19640)
+++ Font.h      (working copy)
@@ -15,6 +15,10 @@
 #ifndef FONT_H
 #define FONT_H
 
+#ifdef TEX2LYX
+#include "tex2lyx/Font.h"
+#else
+
 #include "Color.h"
 #include "support/docstream.h"
 
@@ -422,4 +426,5 @@
 
 } // namespace lyx
 
+#endif // TEX2LYX
 #endif
Index: tex2lyx/Font.h
===================================================================
--- tex2lyx/Font.h      (revision 19640)
+++ tex2lyx/Font.h      (working copy)
@@ -14,8 +14,8 @@
  *
  */
 
-#ifndef LYXFONT_H
-#define LYXFONT_H
+#ifndef TEX2LYX_FONT_H
+#define TEX2LYX_FONT_H
 
 namespace lyx {
 
@@ -40,4 +40,4 @@
 
 } // namespace lyx
 
-#endif // NOT LYXFONT_H
+#endif // TEX2LYX_FONT_H
Index: tex2lyx/Makefile.am
===================================================================
--- tex2lyx/Makefile.am (revision 19640)
+++ tex2lyx/Makefile.am (working copy)
@@ -1,8 +1,9 @@
 include $(top_srcdir)/config/common.am
 
-EXTRA_DIST = tex2lyx.man pch.h test-structure.tex test-insets.tex
+EXTRA_DIST = tex2lyx.man test-structure.tex test-insets.tex
+EXTRA_DIST += pch.h
 
-DISTCLEANFILES += tex2lyx.1 $(LINKED_FILES)
+DISTCLEANFILES += tex2lyx.1
 
 #noinst_LTLIBRARIES = libtexparser.la
 #
@@ -16,19 +17,28 @@
 
 bin_PROGRAMS = tex2lyx
 
-AM_CPPFLAGS += $(PCH_FLAGS) -I$(srcdir)/.. $(BOOST_INCLUDES)
+DEFAULT_INCLUDES = 
 
+AM_CPPFLAGS += \
+       -DTEX2LYX \
+       $(PCH_FLAGS) \
+       -I$(top_srcdir)/src/tex2lyx \
+       -I$(top_srcdir)/src  \
+       -I$(top_builddir)/src \
+       $(BOOST_INCLUDES)
+
+
 LINKED_FILES = \
-       FloatList.cpp \
-       Floating.cpp \
-       Counters.cpp \
-       Layout.h \
-       Layout.cpp \
-       TextClass.cpp \
-       TextClass.h \
-       Lexer.cpp 
+       ../FloatList.cpp \
+       ../Floating.cpp \
+       ../Counters.cpp \
+       ../Layout.h \
+       ../Layout.cpp \
+       ../TextClass.cpp \
+       ../TextClass.h \
+       ../Lexer.cpp 
 
-BUILT_SOURCES = $(PCH_FILE) $(LINKED_FILES)
+BUILT_SOURCES = $(PCH_FILE)
 
 tex2lyx_SOURCES = \
        $(LINKED_FILES) \
@@ -54,12 +64,5 @@
        $(top_builddir)/boost/liblyxboost.la \
        $(LIBICONV) @LIBS@
 
-$(LINKED_FILES) :
-       @rm -f $@ ; \
-       $(LN_S) $(top_srcdir)/src/$@ .
-
-rm_link_files:
-       rm -f $(LINKED_FILES)
-
 tex2lyx.1:
        cp -p $(srcdir)/tex2lyx.man tex2lyx.1
Index: tex2lyx/Spacing.h
===================================================================
--- tex2lyx/Spacing.h   (revision 19640)
+++ tex2lyx/Spacing.h   (working copy)
@@ -13,8 +13,8 @@
  * re-invent the wheel.
  */
 
-#ifndef SPACING_H
-#define SPACING_H
+#ifndef TEX2LYX_SPACING_H
+#define TEX2LYX_SPACING_H
 
 #include <string>
 
@@ -40,4 +40,4 @@
 
 } // namespace lyx
 
-#endif // NOT SPACING_H
+#endif // TEX2LYX_SPACING_H

Reply via email to