shithub: freetype+ttf2subf

Download patch

ref: a90663f591e995bd148d7b45178c9d63a2b7eb93
parent: 7404301024208b605b0e81268469ddf3bf4cd00a
author: David Turner <[email protected]>
date: Fri Jul 7 20:41:13 EDT 2000

vast clean-up of the sources in order to allow flat
directory compilation (by defining the FT_FLAT_COMPILE
macro at compile time..)

moved "freetype2/BUILD" to "freetype2/docs/BUILD"

git/fs: mount .git/fs: mount/attach disallowed
--- a/Makefile
+++ b/Makefile
@@ -75,8 +75,8 @@
   #
   modules: make_module_list setup
 
-  include $(TOP)/config/detect.mk
-  include $(TOP)/config/modules.mk
+  include $(TOP)/builds/detect.mk
+  include $(TOP)/builds/modules.mk
 
   ifeq ($(wildcard $(FT_MODULE_LIST)),)
     setup: make_module_list
--- a/builds/ansi/ansi.mk
+++ b/builds/ansi/ansi.mk
@@ -20,7 +20,7 @@
 DELETE   := rm -f
 SEP      := /
 HOSTSEP  := $(SEP)
-BUILD    := $(TOP)/config/ansi
+BUILD    := $(TOP)/builds/ansi
 PLATFORM := ansi
 
 # The directory where all object files are placed.
@@ -105,7 +105,7 @@
   # Now include the main sub-makefile.  It contains all the rules used to
   # build the library with the previous variables defined.
   #
-  include $(TOP)/config/freetype.mk
+  include $(TOP)/builds/freetype.mk
 
   # The cleanup targets.
   #
--- a/builds/detect.mk
+++ b/builds/detect.mk
@@ -17,7 +17,7 @@
 # the following variables:
 #
 #   BUILD        The configuration and system-specific directory.  Usually
-#                `freetype/config/$(PLATFORM)' but can be different for
+#                `freetype/builds/$(PLATFORM)' but can be different for
 #                custom builds of the library.
 #
 # The following variables must be defined in system specific `detect.mk'
@@ -52,7 +52,7 @@
 COPY     := cp
 SEP      := /
 
-BUILD_CONFIG_ = $(TOP)$(SEP)config$(SEP)
+BUILD_CONFIG_ = $(TOP)$(SEP)builds$(SEP)
 BUILD         = $(BUILD_CONFIG_)$(PLATFORM)
 CONFIG_RULES  = $(BUILD)$(SEP)$(CONFIG_FILE)
 
@@ -70,7 +70,7 @@
 #
 BACKSLASH := $(strip \ )
 
-# Now, include all detection rule files found in the `config/<system>'
+# Now, include all detection rule files found in the `builds/<system>'
 # directories.  Note that the calling order of the various `detect.mk' files
 # isn't predictable.
 #
--- a/builds/dos/dos-gcc.mk
+++ b/builds/dos/dos-gcc.mk
@@ -20,7 +20,7 @@
 DELETE   := rm -f
 SEP      := /
 HOSTSEP  := $(strip \ )
-BUILD    := $(TOP)/config/dos
+BUILD    := $(TOP)/builds/dos
 PLATFORM := dos
 
 # The directory where all object files are placed.
@@ -105,7 +105,7 @@
   # Now include the main sub-makefile.  It contains all the rules used to
   # build the library with the previous variables defined.
   #
-  include $(TOP)/config/freetype.mk
+  include $(TOP)/builds/freetype.mk
 
   # The cleanup targets.
   #
--- a/builds/freetype.mk
+++ b/builds/freetype.mk
@@ -21,7 +21,7 @@
 # environment, or on the command line) are used:
 #
 #   BUILD          The architecture dependent directory,
-#                  e.g. `$(TOP)/config/unix'.
+#                  e.g. `$(TOP)/builds/unix'.
 #
 #   OBJ_DIR        The directory in which object files are created.
 #
@@ -112,7 +112,7 @@
 # IMPORTANT NOTE: The architecture-dependent directory must ALWAYS be placed
 #                 in front of the include list.  Porters are then able to
 #                 put their own version of some of the FreeType components
-#                 in the `freetype/config/<system>' directory, as these
+#                 in the `freetype/builds/<system>' directory, as these
 #                 files will override the default sources.
 #
 INCLUDES := $(BUILD) $(TOP)$(SEP)include $(SRC)
@@ -121,7 +121,7 @@
 
 
 # C flags used for the compilation of an object file.  This must include at
-# least the paths for the `base' and `config/<system>' directories;
+# least the paths for the `base' and `builds/<system>' directories;
 # debug/optimization/warning flags + ansi compliance if needed.
 #
 FT_CFLAGS  = $(CFLAGS) $(INCLUDE_FLAGS)
@@ -131,7 +131,7 @@
 
 # Include the `modules' rules file.
 #
-include $(TOP)/config/modules.mk
+include $(TOP)/builds/modules.mk
 
 
 # Initialize the list of objects.
--- a/builds/os2/os2-dev.mk
+++ b/builds/os2/os2-dev.mk
@@ -22,7 +22,7 @@
 DELETE   := del
 SEP      := /
 HOSTSEP  := $(strip \ )
-BUILD    := $(TOP)/config/os2
+BUILD    := $(TOP)/builds/os2
 PLATFORM := os2
 CC       := gcc
 
@@ -108,7 +108,7 @@
   # Now include the main sub-makefile.  It contains all the rules used to
   # build the library with the previous variables defined.
   #
-  include $(TOP)/config/freetype.mk
+  include $(TOP)/builds/freetype.mk
 
   # The cleanup targets.
   #
--- a/builds/os2/os2-gcc.mk
+++ b/builds/os2/os2-gcc.mk
@@ -20,7 +20,7 @@
 DELETE   := del
 SEP      := /
 HOSTSEP  := $(strip \ )
-BUILD    := $(TOP)/config/os2
+BUILD    := $(TOP)/builds/os2
 PLATFORM := os2
 CC       := gcc
 
@@ -106,7 +106,7 @@
   # Now include the main sub-makefile.  It contains all the rules used to
   # build the library with the previous variables defined.
   #
-  include $(TOP)/config/freetype.mk
+  include $(TOP)/builds/freetype.mk
 
   # The cleanup targets.
   #
--- a/builds/unix/unix-dev.mk
+++ b/builds/unix/unix-dev.mk
@@ -22,7 +22,7 @@
 DELETE   := rm -f
 SEP      := /
 HOSTSEP  := $(SEP)
-BUILD    := $(TOP)/config/unix
+BUILD    := $(TOP)/builds/unix
 PLATFORM := unix
 
 # The directory where all object files are placed.
@@ -107,7 +107,7 @@
   # Now include the main sub-makefile.  It contains all the rules used to
   # build the library with the previous variables defined.
   #
-  include $(TOP)/config/freetype.mk
+  include $(TOP)/builds/freetype.mk
 
   # The cleanup targets.
   #
--- a/builds/unix/unix-gcc.mk
+++ b/builds/unix/unix-gcc.mk
@@ -20,7 +20,7 @@
 DELETE   := rm -f
 SEP      := /
 HOSTSEP  := $(SEP)
-BUILD    := $(TOP)/config/unix
+BUILD    := $(TOP)/builds/unix
 PLATFORM := unix
 
 # The directory where all object files are placed.
@@ -105,7 +105,7 @@
   # Now include the main sub-makefile.  It contains all the rules used to
   # build the library with the previous variables defined.
   #
-  include $(TOP)/config/freetype.mk
+  include $(TOP)/builds/freetype.mk
 
   # The cleanup targets.
   #
--- a/builds/unix/unix.in
+++ b/builds/unix/unix.in
@@ -20,7 +20,7 @@
 DELETE   := @RMF@
 SEP      := /
 HOSTSEP  := $(SEP)
-BUILD    := $(TOP)/config/unix
+BUILD    := $(TOP)/builds/unix
 PLATFORM := unix
 
 # The directory where all object files are placed.
--- a/builds/unix/unix.mk
+++ b/builds/unix/unix.mk
@@ -20,7 +20,7 @@
 DELETE   := rm -f
 SEP      := /
 HOSTSEP  := $(SEP)
-BUILD    := $(TOP)/config/unix
+BUILD    := $(TOP)/builds/unix
 PLATFORM := unix
 
 # The directory where all object files are placed.
@@ -105,7 +105,7 @@
   # Now include the main sub-makefile.  It contains all the rules used to
   # build the library with the previous variables defined.
   #
-  include $(TOP)/config/freetype.mk
+  include $(TOP)/builds/freetype.mk
 
   # The cleanup targets.
   #
--- a/builds/win32/w32-dev.mk
+++ b/builds/win32/w32-dev.mk
@@ -25,7 +25,7 @@
 DELETE   := del
 SEP      := /
 HOSTSEP  := $(strip \ )
-BUILD    := $(TOP)/config/win32
+BUILD    := $(TOP)/builds/win32
 PLATFORM := win32
 CC       := gcc
 
@@ -111,7 +111,7 @@
   # Now include the main sub-makefile.  It contains all the rules used to
   # build the library with the previous variables defined.
   #
-  include $(TOP)/config/freetype.mk
+  include $(TOP)/builds/freetype.mk
 
   # The cleanup targets.
   #
--- a/builds/win32/w32-gcc.mk
+++ b/builds/win32/w32-gcc.mk
@@ -23,7 +23,7 @@
 DELETE   := del
 SEP      := /
 HOSTSEP  := $(strip \ )
-BUILD    := $(TOP)/config/win32
+BUILD    := $(TOP)/builds/win32
 PLATFORM := win32
 CC       := gcc
 
@@ -109,7 +109,7 @@
   # Now include the main sub-makefile.  It contains all the rules used to
   # build the library with the previous variables defined.
   #
-  include $(TOP)/config/freetype.mk
+  include $(TOP)/builds/freetype.mk
 
   # The cleanup targets.
   #
--- a/builds/win32/w32-icc.mk
+++ b/builds/win32/w32-icc.mk
@@ -108,7 +108,7 @@
 
 ifdef BUILD_FREETYPE
 
-include $(TOP)/config/freetype.mk
+include $(TOP)/builds/freetype.mk
 
 clean_freetype: clean_freetype_dos
 distclean_freetype: distclean_freetype_dos
--- a/builds/win32/w32-lcc.mk
+++ b/builds/win32/w32-lcc.mk
@@ -19,7 +19,7 @@
 DELETE   := del
 SEP      := /
 HOSTSEP  := $(strip \ )
-BUILD    := $(TOP)/config/win32
+BUILD    := $(TOP)/builds/win32
 PLATFORM := win32
 CC       := lcc
 
@@ -105,7 +105,7 @@
   # Now include the main sub-makefile.  It contains all the rules used to
   # build the library with the previous variables defined.
   #
-  include $(TOP)/config/freetype.mk
+  include $(TOP)/builds/freetype.mk
 
   # The cleanup targets.
   #
--- a/builds/win32/w32-vcc.mk
+++ b/builds/win32/w32-vcc.mk
@@ -19,7 +19,7 @@
 DELETE   := del
 SEP      := /
 HOSTSEP  := $(strip \ )
-BUILD    := $(TOP)/config/win32
+BUILD    := $(TOP)/builds/win32
 PLATFORM := win32
 CC       := cl
 
@@ -105,7 +105,7 @@
   # Now include the main sub-makefile.  It contains all the rules used to
   # build the library with the previous variables defined.
   #
-  include $(TOP)/config/freetype.mk
+  include $(TOP)/builds/freetype.mk
 
   # The cleanup targets.
   #
--- a/config/freetype.mk
+++ b/config/freetype.mk
@@ -115,7 +115,7 @@
 #                 in the `freetype/config/<system>' directory, as these
 #                 files will override the default sources.
 #
-INCLUDES := $(BUILD) $(TOP)$(SEP)include $(INCLUDES)
+INCLUDES := $(BUILD) $(TOP)$(SEP)include $(SRC)
 
 INCLUDE_FLAGS = $(INCLUDES:%=$I%)
 
--- /dev/null
+++ b/docs/BUILD
@@ -1,0 +1,264 @@
+FreeType 2 compilation how-to
+
+
+Introduction:
+
+Welcome to this new beta of the FreeType 2 library. You'll find in this
+document instructions on how to compile the library on your favorite
+platform.
+
+  *** UNIX USERS : Even though the FT2 build system doesn't
+  ************** : use the Autoconf/Automake tools, these will
+  ************** : be introduced in the Unix-specific parts of
+  ************** : the build in our final release..
+
+
+I. QUICK COMMAND-LINE GUIDE:
+----------------------------
+
+  Install GNU Make, then try the following on Unix or any system with gcc:
+
+     make    // this will setup the build
+     make    // this will build the library
+
+  On Win32+Visual C++:
+
+     make setup visualc    // setup the build for VisualC++ on Win32
+     make                  // build the library
+
+  Then, go to the "demos" directory and type
+
+     make
+
+  To compile the demo programs..
+
+  If this doesn't work, read the following..
+
+
+
+II. COMMAND-LINE COMPILATION:
+-----------------------------
+
+  Note that if you do not want to compile FreeType 2 from a command line
+  shell, please skip to section III below (DETAILED COMPILATION)
+
+  FreeType 2 includes a powerful and flexible build system that allows you
+  to easily compile it on a great variety of platforms from the command
+  line. To do so, just follow these simple instructions:
+
+  a/ Install GNU Make:
+
+     Because GNU Make is the only Make tool supported to compile FreeType 2,
+     you should install it on your machine.
+
+     Because the FT2 build system relies on many important features of GNU
+     Make, trying to build the library with any other Make tool will *fail*.
+
+
+  b/ Invoke "make":
+
+     Go to the root FT2 directory, then simply invoke GNU Make from the
+     command line, this will launch the FreeType 2 Host Platform detection
+     routines. A summary will be displayed, for example, on Win32:
+
+     ========================================================================
+        FreeType build system -- automatic system detection
+
+        The following settings are used:
+
+          platform                     win32
+          compiler                     gcc
+          configuration directory      ./builds/win32
+          configuration rules          ./builds/win32/w32-gcc.mk
+
+        If this does not correspond to your system or settings please remove
+        the file 'config.mk' from this directory then read the INSTALL file
+        for help.
+
+        Otherwise, simply type 'make' again to build the library.
+     =========================================================================
+
+     If the detected settings correspond to your platform and compiler,
+     skip to step e/. Note that if your platform is completely alien to
+     the build system, the detected platform will be "ansi".
+
+
+  c/ Configure the build system for a different compiler:
+
+     If the build system correctly detected your platform, but you want to
+     use a different compiler than the one specified in the summary (for
+     most platforms, gcc is the defaut compiler), simply invoke GNU Make
+     like :
+
+         make setup <compiler>
+
+     For example:
+
+            to use Visual C++ on Win32, type:  "make setup visualc"
+            to use LCC-Win32 on Win32, type:   "make setup lcc"
+
+     The <compiler> name to use is platform-dependent. The list of available
+     compilers for your system is available in the file
+     "builds/<system>/detect.mk" (note that we hope to make the list
+     displayed at user demand in the final release)..
+
+     If you're satisfying by the new configuration summary, skip to step e/
+
+
+  d/ Configure the build system for an unknown platform/compiler:
+
+     What the auto-detection/setup phase of the build system does is simply
+     copy a file to the current directory under the name "config.mk".
+
+     For example, on OS/2+gcc, it would simply copy "builds/os2/os2-gcc.mk"
+     to "./config.mk"
+
+     If for some reason your platform isn't correctly detected, simply copy
+     manually the configuration sub-makefile to "./config.mk" and go to
+     step e/.
+
+     Note that this file is a sub-Makefile used to specify Make variables
+     used to invoke the compiler and linker during the build, you can easily
+     create your own version from one of the existing configuration files,
+     then copy it to the current directory under the name "./config.mk".
+
+
+  e/ Build the library:
+
+     The auto-detection/setup phase should have copied a file in the current
+     directory, called "./config.mk". This file contains definitions of various
+     Make variables used to invoke the compiler and linker during the build.
+
+     To launch the build, simply invoke GNU Make again: the top Makefile will
+     detect the configuration file and run the build with it..
+
+
+  f/ Build the demonstration programs:
+
+     Once the library is compiled, go to "demos", then invoke GNU Make.
+
+     Note that the demonstration programs include a tiny graphics sub-system
+     that includes "drivers" to display Windows on Win32, X11 and OS/2. The
+     build system should automatically detect which driver to use based on
+     the current platform.
+
+     UNIX USERS TAKE NOTE: XXXXXX
+
+     When building the demos, the build system tries to detect your X11 path
+     by looking for the patterns "X11R5/bin", "X11R6/bin" or "X11/bin" in
+     your current path. If no X11 path is found, the demo programs will not
+     be able to display graphics and will fail. Change your current path
+     if you encounter this problem.
+
+     Note that the release version will use Autoconf to detect everything
+     on Unix, so this will not be necessary !!
+
+
+II. DETAILED COMPILATION PROCEDURE:
+-----------------------------------
+
+  If you don't want to compile FreeType 2 from the command-line (for example
+  from a graphical IDE on a Mac or Windows), you'll need to understand how the
+  FreeType files are organized.
+
+  FreeType 2 has a very module design, and it is made of several components.
+  Each component must be compiled as a stand-alone object file, even when it
+  is really made of several C source files. For example, the "base layer"
+  component is made of the following C files:
+
+    src/
+      base/
+        ftcalc.c    - computations
+        ftobjs.c    - object management
+        ftstream.c  - stream input
+        ftlist.c    - simple list management
+        ftoutln.c   - simple outline processing
+        ftextend.c  - extensions support
+
+  However, you can create a single object file by compiling the file
+  "src/base/ftbase.c", whose content is basically:
+
+        #include <base/ftcalc.c>
+        #include <base/ftobjs.c>
+        #include <base/ftstream.c>
+        #include <base/ftlist.c>
+        #include <base/ftoutln.c>
+        #include <base/ftextend.c>
+
+  Similarly, each component has a single "englobing" C file to compile it
+  as a stand-alone object, i.e. :
+
+     src/base/ftbase.c         - the base layer, high-level interface
+     src/sfnt/sfnt.c           - the "sfnt" module
+     src/psnames/psnames.c     - the Postscript Names module
+     src/truetype/truetype.c   - the TrueType font driver
+     src/type1/type1.c         - the Type 1 font driver
+
+
+  To compile one component, do the following:
+
+   - add the top-level "include" directory to your compilation include path
+
+   - add the "src" directory to your compilation include path.
+
+   - compile the component "source" file (see list below), you don't need
+     to be in the component's directory..
+
+  For example, the following line can be used to compile the truetype driver
+  on Unix:
+
+     cd freetype2/
+     cc -c -Iinclude -Isrc  src/truetype/truetype.c
+
+  Alternatively:
+
+     cd freetype2/src/truetype
+     cc -c -I../../include -I.. truetype.c
+
+  The complete list of files to compile for a feature-complete build of
+  FreeType 2 is:
+
+     src/base/ftsystem.c         - system-specific memory and i/o support
+     src/base/ftinit.c           - initialisation layer
+     src/base/ftdebug.c          - debugging component (empty in release build)
+     src/base/ftbase.c           - the "base layer" component
+     src/base/ftglyph.c          - optional convenience functions
+     src/raster1/raster1.c       - the monochrome bitmap renderer
+     src/smooth/smooth.c         - the anti-aliased bitmap renderer
+     src/sfnt/sfnt.c             - the "sfnt" module
+     src/psnames/psnames.c       - the "psnames" module
+     src/truetype/truetype.c     - the TrueType font driver
+     src/type1/type1.c           - the Type 1 font driver (incl. Multiple Masters)
+     src/cid/type1cid.c          - the Type 1 CID-keyed font driver
+     src/cff/cff.c               - the OpenType/CFF/CEF font driver
+     src/winfonts/winfnt.c       - the Windows FNT/FON font driver
+
+  All font drivers are optional. the "sfnt" and "psnames" modules are
+  mandatory for certain drivers.
+
+
+III. Support for flat-directory compilation:
+----------------------------------------
+
+  It is now possible to put all FreeType 2 source files into a single
+  directory, with the exception of the "include" hierarchy.
+
+  Note that you'll still need to only compile the 'wrapper' sources described
+  above. Define the "FT_FLAT_COMPILE" macro when compiling. Here's an
+  example:
+  
+   1/ Copy all files in current directory:
+   
+     cp freetype2/src/base/*.[hc] .
+     cp freetype2/src/raster1/*.[hc] .
+     cp freetype2/src/smooth/*.[hc] .
+     etc...
+
+   2/ Compile sources:
+        
+     cc -c -DFT_FLAT_COMPILE -Ifreetype/include ftsystem.c
+     cc -c -DFT_FLAT_COMPILE -Ifreetype/include ftinit.c
+     cc -c -DFT_FLAT_COMPILE -Ifreetype/include ftdebug.c
+     cc -c -DFT_FLAT_COMPILE -Ifreetype/include ftbase.c
+     etc...
+
--- a/src/base/ftbase.c
+++ b/src/base/ftbase.c
@@ -16,6 +16,14 @@
 /***************************************************************************/
 
 
+#ifdef FT_FLAT_COMPILE
+#include "ftcalc.c"
+#include "ftobjs.c"
+#include "ftstream.c"
+#include "ftlist.c"
+#include "ftoutln.c"
+#include "ftextend.c"
+#else
 #include <ftcalc.c>
 #include <ftobjs.c>
 #include <ftstream.c>
@@ -22,6 +30,6 @@
 #include <ftlist.c>
 #include <ftoutln.c>
 #include <ftextend.c>
-
+#endif
 
 /* END */
--- a/src/cff/cff.c
+++ b/src/cff/cff.c
@@ -18,11 +18,20 @@
 
 #define FT_MAKE_OPTION_SINGLE_OBJECT
 
-#include <t2driver.c>    /* driver interface     */
-#include <t2parse.c>     /* token parser         */
-#include <t2load.c>      /* tables loader        */
-#include <t2objs.c>      /* object management    */
-#include <t2gload.c>     /* glyph loader         */
+#ifdef FT_FLAT_COMPILE
+#include "t2driver.c"    /* driver interface     */
+#include "t2parse.c"     /* token parser         */
+#include "t2load.c"      /* tables loader        */
+#include "t2objs.c"      /* object management    */
+#include "t2gload.c"     /* glyph loader         */
+#else
+#include <cff/t2driver.c>    /* driver interface     */
+#include <cff/t2parse.c>     /* token parser         */
+#include <cff/t2load.c>      /* tables loader        */
+#include <cff/t2objs.c>      /* object management    */
+#include <cff/t2gload.c>     /* glyph loader         */
+#endif
+
 
 
 /* END */
--- a/src/cff/rules.mk
+++ b/src/cff/rules.mk
@@ -19,14 +19,7 @@
 T2_DIR_ := $(T2_DIR)$(SEP)
 
 
-# additional include flags used when compiling the driver
-#
-T2_INCLUDE := $(T2_DIR)
-
-# compilation flags for the driver
-#
-T2_CFLAGS  := $(T2_INCLUDE:%=$I%)
-T2_COMPILE := $(FT_COMPILE) $(T2_CFLAGS)
+T2_COMPILE := $(FT_COMPILE)
 
 
 # T2 driver sources (i.e., C files)
--- a/src/cff/t2driver.c
+++ b/src/cff/t2driver.c
@@ -22,10 +22,16 @@
 #include <freetype/internal/sfnt.h>
 #include <freetype/ttnameid.h>
 
-#include <t2driver.h>
-#include <t2gload.h>
-
 #include <freetype/internal/t2errors.h>
+
+#ifdef FT_FLAT_COMPILE
+#include "t2driver.h"
+#include "t2gload.h"
+#else
+#include <cff/t2driver.h>
+#include <cff/t2gload.h>
+#endif
+
 
 
   /*************************************************************************/
--- a/src/cff/t2gload.c
+++ b/src/cff/t2gload.c
@@ -23,8 +23,13 @@
 #include <freetype/ftoutln.h>
 #include <freetype/tttags.h>
 
-#include <t2load.h>
-#include <t2gload.h>
+#ifdef FT_FLAT_COMPILE
+#include "t2load.h"
+#include "t2gload.h"
+#else
+#include <cff/t2load.h>
+#include <cff/t2gload.h>
+#endif
 
 #include <freetype/internal/t2errors.h>
 
@@ -472,9 +477,9 @@
       builder->path_begun = 1;
       error = add_contour( builder );
       if ( !error )
-        error = add_point1( builder, x, y );
+        return error;
     }
-    return error;
+    return add_point1( builder, x, y );
   }
 
 
@@ -595,8 +600,8 @@
       v = *ip++;
       if ( v >= 32 || v == 28 )
       {
-        FT_Int  shift = 16;
-        FT_Long val;
+        FT_Int    shift = 16;
+        FT_Int32  val;
 
 
         /* this is an operand, push it on the stack */
@@ -604,7 +609,7 @@
         {
           if ( ip + 1 >= limit )
             goto Syntax_Error;
-          val = (FT_Short)( ( (FT_Int)ip[0] << 8 ) + ip[1] );
+          val = (FT_Int32)( ( (FT_Short)ip[0] << 8 ) | ip[1] );
           ip += 2;
         }
         else if ( v < 247 )
@@ -640,7 +645,7 @@
 
 #ifdef FT_DEBUG_LEVEL_TRACE
         if ( !( val & 0xFFFF ) )
-          FT_TRACE4(( " %d", (FT_Int)( val >> 16 ) ));
+          FT_TRACE4(( " %d", (FT_Int32)( val >> 16 ) ));
         else
           FT_TRACE4(( " %.2f", val/65536.0 ));
 #endif
@@ -1296,7 +1301,7 @@
           {
             FT_Pos start_x, start_y; /* record start x,y values for alter use */
             FT_Int dx = 0, dy = 0;   /* used in hort./vert. algorithm below   */
-            FT_Int hort_flag, count;
+            FT_Int horizontal, count;
  
             FT_TRACE4(( " flex1" ));
    
@@ -1314,7 +1319,7 @@
             args = stack;
             
             /* grab up to the last argument */
-            while ( args < decoder->top - 1)
+            for ( count = 5; count > 0; count-- )
             {
               dx += args[0];
               dy += args[1];
@@ -1328,7 +1333,7 @@
             if ( dy < 0 ) dy = -dy;
    
             /* strange test, but here it is... */
-            hort_flag = (dx > dy);
+            horizontal = (dx > dy);
    
             for ( count = 5; count > 0; count-- )
             {
@@ -1338,7 +1343,7 @@
               args += 2;
             }
    
-            if (hort_flag)
+            if (horizontal)
             {
               x += args[0];
               y  = start_y;
--- a/src/cff/t2gload.h
+++ b/src/cff/t2gload.h
@@ -20,7 +20,12 @@
 #define T2GLOAD_H
 
 #include <freetype/freetype.h>
-#include <t2objs.h>
+
+#ifdef FT_FLAT_COMPILE
+#include "t2objs.h"
+#else
+#include <cff/t2objs.h>
+#endif
 
 #ifdef __cplusplus
   extern "C" {
--- a/src/cff/t2load.c
+++ b/src/cff/t2load.c
@@ -23,10 +23,16 @@
 
 #include <freetype/internal/t2errors.h>
 #include <freetype/tttags.h>
-#include <t2load.h>
-#include <t2parse.h>
 
+#ifdef FT_FLAT_COMPILE
+#include "t2load.h"
+#include "t2parse.h"
+#else
+#include <cff/t2load.h>
+#include <cff/t2parse.h>
+#endif
 
+
   /*************************************************************************/
   /*                                                                       */
   /* The macro FT_COMPONENT is used in trace mode.  It is an implicit      */
@@ -283,8 +289,6 @@
   }
 
 
-#if 0 /* unused until we fully support pure-CFF fonts */
-
   LOCAL_FUNC
   FT_String*  T2_Get_String( CFF_Index*          index,
                              FT_UInt             sid,
@@ -319,7 +323,6 @@
     }
   }
 
-#endif /* 0 */
 
 
   /*************************************************************************/
--- a/src/cff/t2load.h
+++ b/src/cff/t2load.h
@@ -29,14 +29,11 @@
   FT_String*  T2_Get_Name( CFF_Index*  index,
                            FT_UInt     element );
 
-#if 0  /* will be used later for pure-CFF font support */
-
   LOCAL_DEF
   FT_String*  T2_Get_String( CFF_Index*          index,
                              FT_UInt             sid,
                              PSNames_Interface*  interface );
 
-#endif
 
   LOCAL_DEF
   FT_Error  T2_Access_Element( CFF_Index*  index,
--- a/src/cff/t2objs.c
+++ b/src/cff/t2objs.c
@@ -19,14 +19,21 @@
 #include <freetype/internal/ftdebug.h>
 #include <freetype/internal/ftcalc.h>
 #include <freetype/internal/ftstream.h>
+#include <freetype/fterrors.h>
 #include <freetype/ttnameid.h>
 #include <freetype/tttags.h>
 
 #include <freetype/internal/sfnt.h>
 #include <freetype/internal/psnames.h>
-#include <t2objs.h>
 
-#include <t2load.h>
+#ifdef FT_FLAT_COMPILE
+#include "t2objs.h"
+#include "t2load.h"
+#else
+#include <cff/t2objs.h>
+#include <cff/t2load.h>
+#endif
+
 #include <freetype/internal/t2errors.h>
 
 
@@ -46,7 +53,131 @@
   /*                                                                       */
   /*************************************************************************/
 
+  static
+  FT_String*   T2_StrCopy( FT_Memory  memory, const FT_String*  source )
+  {
+    FT_Error   error;
+    FT_String* result = 0;
+    FT_Int     len = (FT_Int)strlen(source);
+    
+    if ( !ALLOC( result, len+1 ) )
+    {
+      MEM_Copy( result, source, len );
+      result[len] = 0;
+    }
+    return result;
+  }
 
+
+  /* this function is used to build a Unicode charmap from the glyph names */
+  /* in a file..                                                           */
+  static
+  FT_Error   CFF_Build_Unicode_Charmap( T2_Face             face,
+                                        FT_ULong            base_offset,
+                                        PSNames_Interface*  psnames )
+  {
+    CFF_Font*       font = (CFF_Font*)face->extra.data;
+    FT_Memory       memory = FT_FACE_MEMORY(face);
+    FT_UInt         n, num_glyphs = face->root.num_glyphs;
+    const char**    glyph_names;
+    FT_Error        error;
+    CFF_Font_Dict*  dict = &font->top_font.font_dict;
+    FT_ULong        charset_offset;
+    FT_Byte         format;
+    FT_Stream       stream = face->root.stream;
+
+    charset_offset = dict->charset_offset;
+    if (!charset_offset)
+    {
+      FT_ERROR(( "CFF.Build_Unicode_Charmap: charset table is missing\n" ));
+      error = FT_Err_Invalid_File_Format;
+      goto Exit;
+    }
+
+    /* seek to charset table and allocate glyph names table */
+    if ( FILE_Seek( base_offset + charset_offset )           ||
+         ALLOC_ARRAY( glyph_names, num_glyphs, const char* ) )
+      goto Exit;
+
+    /* now, read each glyph name and store it in the glyph name table */
+    if ( READ_Byte(format) )
+      goto Fail;
+      
+    switch (format)
+    {
+      case 0:  /* format 0 - one SID per glyph */
+        {
+          const char**  gname = glyph_names;
+          const char**  limit = gname + num_glyphs;
+          
+          if ( ACCESS_Frame( num_glyphs*2 ) )
+            goto Fail;
+          
+          for ( ; gname < limit; gname++ )
+            gname[0] = T2_Get_String( &font->string_index,
+                                      GET_UShort(),
+                                      psnames );
+          FORGET_Frame();
+          break;
+        }
+        
+      case 1:  /* format 1 - sequential ranges                    */
+      case 2:  /* format 2 - sequential ranges with 16-bit counts */
+        {
+          const char**  gname = glyph_names;
+          const char**  limit = gname + num_glyphs;
+          FT_UInt       len = 3;
+          
+          if (format == 2)
+            len++;
+          
+          while (gname < limit)
+          {
+            FT_UInt   first;
+            FT_UInt   count;
+              
+            if ( ACCESS_Frame( len ) )
+              goto Fail;
+
+            first = GET_UShort();
+            if (format == 3)
+              count = GET_UShort();
+            else
+              count = GET_Byte();
+
+            FORGET_Frame();
+            
+            for ( ; count > 0; count-- )
+            {
+              gname[0] = T2_Get_String( &font->string_index,
+                                        first,
+                                        psnames );
+              gname++;
+              first++;
+            }
+          }
+          break;
+        }
+        
+      default:   /* unknown charset format  !! */
+        FT_ERROR(( "CFF: unknown charset format !!\n" ));
+        error = FT_Err_Invalid_File_Format;
+        goto Fail;
+    }
+
+    /* all right, the glyph names were loaded, we now need to create */
+    /* the corresponding unicode charmap..                           */
+
+  Fail:
+    for ( n = 0; n < num_glyphs; n++ )
+      FREE( glyph_names[n] );
+      
+    FREE( glyph_names );
+        
+  Exit:
+    return error;
+  }
+  
   /*************************************************************************/
   /*                                                                       */
   /* <Function>                                                            */
@@ -77,15 +208,20 @@
                           FT_Int         num_params,
                           FT_Parameter*  params )
   {
-    FT_Error         error;
-    SFNT_Interface*  sfnt;
+    FT_Error            error;
+    SFNT_Interface*     sfnt;
+    PSNames_Interface*  psnames;
+    FT_Bool             pure_cff    = 1;
+    FT_Bool             sfnt_format = 0;
 
-
     sfnt = (SFNT_Interface*)FT_Get_Module_Interface(
              face->root.driver->root.library, "sfnt" );
     if ( !sfnt )
       goto Bad_Format;
 
+    psnames = (PSNames_Interface*)FT_Get_Module_Interface(
+             face->root.driver->root.library, "psnames" );
+
     /* create input stream from resource */
     if ( FILE_Seek( 0 ) )
       goto Exit;
@@ -92,33 +228,62 @@
 
     /* check that we have a valid OpenType file */
     error = sfnt->init_face( stream, face, face_index, num_params, params );
-    if ( error )
-      goto Exit;
-
-    if ( face->format_tag != 0x4F54544FL )  /* `OTTO'; OpenType/CFF font */
+    if ( !error )
     {
-      FT_TRACE2(( "[not a valid OpenType/CFF font]\n" ));
-      goto Bad_Format;
-    }
+      if ( face->format_tag != 0x4F54544FL )  /* `OTTO'; OpenType/CFF font */
+      {
+        FT_TRACE2(( "[not a valid OpenType/CFF font]\n" ));
+        goto Bad_Format;
+      }
 
-    /* If we are performing a simple font format check, exit immediately */
-    if ( face_index < 0 )
-      return T2_Err_Ok;
+      /* If we are performing a simple font format check, exit immediately */
+      if ( face_index < 0 )
+        return T2_Err_Ok;
 
-    /* Load font directory */
-    error = sfnt->load_face( stream, face, face_index, num_params, params );
-    if ( error )
-      goto Exit;
+      sfnt_format = 1;  
 
-    /* now, load the CFF part of the file */
-    error = face->goto_table( face, TTAG_CFF, stream, 0 );
-    if ( error )
-      goto Exit;
+      /* now, the font can be either an OpenType/CFF font, or a SVG CEF font */
+      /* in the later case, it doesn't have a "head" table..                 */
+      error = face->goto_table( face, TTAG_head, stream, 0 );
+      if (!error)
+      {
+        pure_cff = 0;
 
+        /* Load font directory */
+        error = sfnt->load_face( stream, face, face_index, num_params, params );
+        if ( error )
+          goto Exit;
+      }
+      else
+      {
+        /* load the "cmap" table by hand */
+        error = sfnt->load_charmaps( face, stream );
+        if (error)
+          goto Exit;
+          
+        /* XXX: for now, we don't load the GPOS table, as OpenType Layout */
+        /* support will be added later to FreeType 2 as a separate module */
+      }
+
+      /* now, load the CFF part of the file */
+      error = face->goto_table( face, TTAG_CFF, stream, 0 );
+      if ( error )
+        goto Exit;
+    }
+    else
     {
+      /* rewind to start of file, we're going to load a pure-CFF font */
+      (void)FILE_Seek(0);
+      error = FT_Err_Ok;
+    }
+
+
+    /* now load and parse the CFF table in the file */
+    {
       CFF_Font*  cff;
       FT_Memory  memory = face->root.memory;
       FT_Face    root;
+      FT_UInt    flags;
 
 
       if ( ALLOC( cff, sizeof ( *cff ) ) )
@@ -130,11 +295,80 @@
         goto Exit;
 
       /* Complement the root flags with some interesting information. */
-      /* Note that for OpenType/CFF, there is no need to do this, but */
-      /* this will be necessary for pure CFF fonts through.           */
+      /* Note that this is only necessary for pure CFF and CEF fonts  */
+      
       root = &face->root;
-    }
+      if (pure_cff)
+      {
+        CFF_Font_Dict*  dict = &cff->top_font.font_dict;
+      
+        /* we need the psnames module for pure-CFF and CEF formats */
+        if (!psnames)
+        {
+          FT_ERROR(( "cannot open CFF & CEF fonts without the 'psnames' module\n" ));
+          goto Bad_Format;
+        }
+        
+        /* retrieve font family & style name */
+        if (dict->cid_registry)
+        {
+          root->family_name = T2_Get_String( &cff->string_index,
+                                             dict->cid_font_name,
+                                             psnames );
 
+          root->style_name  = T2_StrCopy( memory, "Regular" );  /* XXXX */
+        }
+        else
+        {
+          root->family_name = T2_Get_String( &cff->string_index,
+                                             dict->base_font_name,
+                                             psnames );
+                                             
+          root->style_name  = T2_Get_String( &cff->string_index,
+                                             dict->weight,
+                                             psnames );
+        }
+        
+          /*********************************************************************/
+          /*                                                                   */
+          /* Compute face flags.                                               */
+          /*                                                                   */
+          flags = FT_FACE_FLAG_SCALABLE  |    /* scalable outlines */
+                  FT_FACE_FLAG_HORIZONTAL;    /* horizontal data   */
+
+          if (sfnt_format)
+            flags |= FT_FACE_FLAG_SFNT;
+    
+          /* fixed width font? */
+          if ( dict->is_fixed_pitch )
+            flags |= FT_FACE_FLAG_FIXED_WIDTH;
+
+/* XXXX: WE DO NOT SUPPORT KERNING METRICS IN THE GPOS TABLE FOR NOW */
+#if 0
+          /* kerning available ? */
+          if ( face->kern_pairs )
+            flags |= FT_FACE_FLAG_KERNING;
+#endif
+
+          root->face_flags = flags;
+    
+          /*********************************************************************/
+          /*                                                                   */
+          /* Compute style flags.                                              */
+          /*                                                                   */
+          flags = 0;
+    
+          if ( dict->italic_angle )
+            flags |= FT_STYLE_FLAG_ITALIC;
+            
+          /* XXXX : may not be correct .. */
+          if ( cff->top_font.private_dict.force_bold )
+            flags |= FT_STYLE_FLAG_BOLD;
+            
+          root->style_flags = flags;
+      }
+    }
+    
   Exit:
     return error;
 
--- a/src/cff/t2parse.c
+++ b/src/cff/t2parse.c
@@ -16,7 +16,12 @@
 /***************************************************************************/
 
 
-#include <t2parse.h>
+#ifdef FT_FLAT_COMPILE
+#include "t2parse.h"
+#else
+#include <cff/t2parse.h>
+#endif
+
 #include <freetype/internal/t2errors.h>
 
 
@@ -417,7 +422,11 @@
 
   static const T2_Field_Handler  t2_field_handlers[] =
   {
-#include <t2tokens.h>
+#ifdef FT_FLAT_COMPILE
+#include "t2tokens.h"
+#else
+#include <cff/t2tokens.h>
+#endif
     { 0, 0, 0, 0, 0, 0, 0 }
   };
 
--- a/src/cid/cidafm.c
+++ b/src/cid/cidafm.c
@@ -15,8 +15,12 @@
 /*                                                                         */
 /***************************************************************************/
 
+#ifdef FT_FLAT_COMPILE
+#include "cidafm.h"
+#else
+#include <cid/cidafm.h>
+#endif
 
-#include <cidafm.h>
 #include <freetype/internal/ftstream.h>
 #include <freetype/internal/t1types.h>
 #include <freetype/internal/t1errors.h>
--- a/src/cid/cidafm.h
+++ b/src/cid/cidafm.h
@@ -19,7 +19,11 @@
 #ifndef CIDAFM_H
 #define CIDAFM_H
 
-#include <cidobjs.h>
+#ifdef FT_FLAT_COMPILE
+#include "cidobjs.h"
+#else
+#include <cid/cidobjs.h>
+#endif
 
 
 #ifdef __cplusplus
--- a/src/cid/cidgload.c
+++ b/src/cid/cidgload.c
@@ -16,8 +16,14 @@
 /***************************************************************************/
 
 
-#include <cidload.h>
-#include <cidgload.h>
+#ifdef FT_FLAT_COMPILE
+#include "cidload.h"
+#include "cidgload.h"
+#else
+#include <cid/cidload.h>
+#include <cid/cidgload.h>
+#endif
+
 #include <freetype/internal/ftdebug.h>
 #include <freetype/internal/ftstream.h>
 #include <freetype/ftoutln.h>
--- a/src/cid/cidgload.h
+++ b/src/cid/cidgload.h
@@ -19,7 +19,11 @@
 #ifndef CIDGLOAD_H
 #define CIDGLOAD_H
 
-#include <cidobjs.h>
+#ifdef FT_FLAT_COMPILE
+#include "cidobjs.h"
+#else
+#include <cid/cidobjs.h>
+#endif
 
 #ifdef __cplusplus
   extern "C" {
--- a/src/cid/cidload.c
+++ b/src/cid/cidload.c
@@ -22,8 +22,13 @@
 
 #include <freetype/internal/t1types.h>
 #include <freetype/internal/t1errors.h>
-#include <cidload.h>
 
+#ifdef FT_FLAT_COMPILE
+#include "cidload.h"
+#else
+#include <cid/cidload.h>
+#endif
+
 #include <stdio.h>
 #include <ctype.h>  /* for isspace(), isalnum() */
 
@@ -238,7 +243,11 @@
   static
   const CID_Field_Rec  t1_field_records[] =
   {
-#include <cidtokens.h>
+#ifdef FT_FLAT_COMPILE
+#include "cidtokens.h"
+#else
+#include <cid/cidtokens.h>
+#endif
     { 0, 0, 0, 0, 0, 0, 0, 0 }
   };
 
--- a/src/cid/cidload.h
+++ b/src/cid/cidload.h
@@ -20,7 +20,12 @@
 #define CIDLOAD_H
 
 #include <freetype/internal/ftstream.h>
-#include <cidparse.h>
+
+#ifdef FT_FLAT_COMPILE
+#include "cidparse.h"
+#else
+#include <cid/cidparse.h>
+#endif
 
 #ifdef __cplusplus
   extern "C" {
--- a/src/cid/cidobjs.c
+++ b/src/cid/cidobjs.c
@@ -19,8 +19,14 @@
 #include <freetype/internal/ftdebug.h>
 #include <freetype/internal/ftstream.h>
 
-#include <cidgload.h>
-#include <cidload.h>
+#ifdef FT_FLAT_COMPILE
+#include "cidgload.h"
+#include "cidload.h"
+#else
+#include <cid/cidgload.h>
+#include <cid/cidload.h>
+#endif
+
 #include <freetype/internal/psnames.h>
 
 
--- a/src/cid/cidparse.c
+++ b/src/cid/cidparse.c
@@ -21,7 +21,12 @@
 #include <freetype/internal/ftobjs.h>
 #include <freetype/internal/ftstream.h>
 #include <freetype/internal/t1errors.h>
-#include <cidparse.h>
+
+#ifdef FT_FLAT_COMPILE
+#include "cidparse.h"
+#else
+#include <cid/cidparse.h>
+#endif
 
 #include <string.h>     /* for strncmp() */
 
--- a/src/cid/cidriver.c
+++ b/src/cid/cidriver.c
@@ -16,8 +16,13 @@
 /***************************************************************************/
 
 
-#include <cidriver.h>
-#include <cidgload.h>
+#ifdef FT_FLAT_COMPILE
+#include "cidriver.h"
+#include "cidgload.h"
+#else
+#include <cid/cidriver.h>
+#include <cid/cidgload.h>
+#endif
 
 #include <freetype/internal/ftdebug.h>
 #include <freetype/internal/ftstream.h>
--- a/src/cid/rules.mk
+++ b/src/cid/rules.mk
@@ -19,14 +19,7 @@
 CID_DIR_ := $(CID_DIR)$(SEP)
 
 
-# additional include flags used when compiling the driver
-#
-CID_INCLUDE := $(CID_DIR)
-
-# compilation flags for the driver
-#
-CID_CFLAGS  := $(CID_INCLUDE:%=$I%)
-CID_COMPILE := $(FT_COMPILE) $(CID_CFLAGS)
+CID_COMPILE := $(FT_COMPILE)
 
 
 # CID driver sources (i.e., C files)
--- a/src/cid/type1cid.c
+++ b/src/cid/type1cid.c
@@ -18,14 +18,18 @@
 
 #define FT_MAKE_OPTION_SINGLE_OBJECT
 
-#include <cidparse.c>
-#include <cidload.c>
-#include <cidobjs.c>
-#include <cidriver.c>
-#include <cidgload.c>
-
-#if 0
-#include <cidafm.c>
+#ifdef FT_FLAT_COMPILE
+#include "cidparse.c"
+#include "cidload.c"
+#include "cidobjs.c"
+#include "cidriver.c"
+#include "cidgload.c"
+#else
+#include <cid/cidparse.c>
+#include <cid/cidload.c>
+#include <cid/cidobjs.c>
+#include <cid/cidriver.c>
+#include <cid/cidgload.c>
 #endif
 
 
--- a/src/psnames/psmodule.c
+++ b/src/psnames/psmodule.c
@@ -18,8 +18,15 @@
 
 #include <freetype/internal/psnames.h>
 #include <freetype/internal/ftobjs.h>
-#include <psmodule.h>
 
+#ifdef FT_FLAT_COMPILE
+#include "psmodule.h"
+#include "pstables.h"
+#else
+#include <psnames/psmodule.h>
+#include <psnames/pstables.h>
+#endif
+
 #include <stdlib.h>     /* for qsort()             */
 #include <string.h>     /* for strcmp(), strncpy() */
 
@@ -27,9 +34,6 @@
 #ifndef FT_CONFIG_OPTION_NO_POSTSCRIPT_NAMES
 
 
-  /* see the Python script `freetype2/docs/glnames.py' which is used */
-  /* to generate the following file                                  */
-#include <pstables.h>
 
 
 #ifdef FT_CONFIG_OPTION_ADOBE_GLYPH_LIST
--- a/src/psnames/rules.mk
+++ b/src/psnames/rules.mk
@@ -18,15 +18,10 @@
 PSNAMES_DIR  := $(SRC_)psnames
 PSNAMES_DIR_ := $(PSNAMES_DIR)$(SEP)
 
-# additional include flags used when compiling the driver
-#
-PSNAMES_INCLUDE := $(PSNAMES_DIR)
 
-
 # compilation flags for the driver
 #
-PSNAMES_CFLAGS  := $(PSNAMES_INCLUDE:%=$I%)
-PSNAMES_COMPILE := $(FT_COMPILE) $(PSNAMES_CFLAGS)
+PSNAMES_COMPILE := $(FT_COMPILE)
 
 
 # PSNames driver sources (i.e., C files)
--- a/src/raster1/ftrend1.c
+++ b/src/raster1/ftrend1.c
@@ -18,8 +18,14 @@
 
 #include <freetype/internal/ftobjs.h>
 #include <freetype/ftoutln.h>
-#include <ftrend1.h>
-#include <ftraster.h>
+
+#ifdef FT_FLAT_COMPILE
+#include "ftrend1.h"
+#include "ftraster.h"
+#else
+#include <raster1/ftrend1.h>
+#include <raster1/ftraster.h>
+#endif
 
 
   /* initialize renderer -- init its raster */
--- a/src/raster1/raster1.c
+++ b/src/raster1/raster1.c
@@ -18,8 +18,13 @@
 
 #define FT_MAKE_OPTION_SINGLE_OBJECT
 
-#include <ftraster.c>
-#include <ftrend1.c>
+#ifdef FT_FLAT_COMPILE
+#include "ftraster.c"
+#include "ftrend1.c"
+#else
+#include <raster1/ftraster.c>
+#include <raster1/ftrend1.c>
+#endif
 
 
 /* END */
--- a/src/raster1/rules.mk
+++ b/src/raster1/rules.mk
@@ -18,15 +18,9 @@
 RAS1_DIR  := $(SRC_)raster1
 RAS1_DIR_ := $(RAS1_DIR)$(SEP)
 
-# additional include flags used when compiling the driver
-#
-RAS1_INCLUDE := $(RAS1_DIR)
-
-
 # compilation flags for the driver
 #
-RAS1_CFLAGS  := $(RAS1_INCLUDE:%=$I%)
-RAS1_COMPILE := $(FT_COMPILE) $(RAS1_CFLAGS)
+RAS1_COMPILE := $(FT_COMPILE)
 
 
 # raster1 driver sources (i.e., C files)
--- a/src/sfnt/rules.mk
+++ b/src/sfnt/rules.mk
@@ -19,14 +19,9 @@
 SFNT_DIR_ := $(SFNT_DIR)$(SEP)
 
 
-# additional include flags used when compiling the driver
-#
-SFNT_INCLUDE := $(SFNT_DIR)
-
 # compilation flags for the driver
 #
-SFNT_CFLAGS  := $(SFNT_INCLUDE:%=$I%)
-SFNT_COMPILE := $(FT_COMPILE) $(SFNT_CFLAGS)
+SFNT_COMPILE := $(FT_COMPILE)
 
 
 # SFNT driver sources (i.e., C files)
--- a/src/sfnt/sfdriver.c
+++ b/src/sfnt/sfdriver.c
@@ -18,12 +18,23 @@
 
 #include <freetype/internal/sfnt.h>
 #include <freetype/internal/ftobjs.h>
-#include <sfdriver.h>
-#include <ttload.h>
-#include <ttsbit.h>
-#include <ttpost.h>
-#include <ttcmap.h>
-#include <sfobjs.h>
+
+#ifdef FT_FLAT_COMPILE
+#include "sfdriver.h"
+#include "ttload.h"
+#include "ttsbit.h"
+#include "ttpost.h"
+#include "ttcmap.h"
+#include "sfobjs.h"
+#else
+#include <sfnt/sfdriver.h>
+#include <sfnt/ttload.h>
+#include <sfnt/ttsbit.h>
+#include <sfnt/ttpost.h>
+#include <sfnt/ttcmap.h>
+#include <sfnt/sfobjs.h>
+#endif
+
 
 #include <string.h>     /* for strcmp() */
 
--- a/src/sfnt/sfnt.c
+++ b/src/sfnt/sfnt.c
@@ -18,19 +18,41 @@
 
 #define FT_MAKE_OPTION_SINGLE_OBJECT
 
-#include <ttload.c>
-#include <ttcmap.c>
-#include <sfobjs.c>
+#ifdef FT_FLAT_COMPILE
 
+#include "ttload.c"
+#include "ttcmap.c"
+#include "sfobjs.c"
+
 #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
-#include <ttsbit.c>
+#include "ttsbit.c"
 #endif
 
 #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
-#include <ttpost.c>
+#include "ttpost.c"
 #endif
+#include "sfdriver.c"
 
-#include <sfdriver.c>
+
+#else /* FT_FLAT_COMPILE */
+
+#include <sfnt/ttload.c>
+#include <sfnt/ttcmap.c>
+#include <sfnt/sfobjs.c>
+
+#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
+#include <sfnt/ttsbit.c>
+#endif
+
+#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
+#include <sfnt/ttpost.c>
+#endif
+#include <sfnt/sfdriver.c>
+
+#endif   /* FT_FLAT_COMPILE */
+
+
+
 
 
 /* END */
--- a/src/sfnt/sfobjs.c
+++ b/src/sfnt/sfobjs.c
@@ -16,7 +16,12 @@
 /***************************************************************************/
 
 
-#include <sfobjs.h>
+#ifdef FT_FLAT_COMPILE
+#include "sfobjs.h"
+#else
+#include <sfnt/sfobjs.h>
+#endif
+
 #include <freetype/internal/sfnt.h>
 #include <freetype/internal/psnames.h>
 #include <freetype/ttnameid.h>
--- a/src/sfnt/ttcmap.c
+++ b/src/sfnt/ttcmap.c
@@ -19,8 +19,15 @@
 #include <freetype/internal/ftdebug.h>
 #include <freetype/internal/tterrors.h>
 
-#include <ttload.h>
-#include <ttcmap.h>
+#ifdef FT_FLAT_COMPILE
+#include "ttload.h"
+#include "ttcmap.h"
+#else
+#include <sfnt/ttload.h>
+#include <sfnt/ttcmap.h>
+#endif
+
+
 
 
   /*************************************************************************/
--- a/src/sfnt/ttload.c
+++ b/src/sfnt/ttload.c
@@ -21,8 +21,15 @@
 #include <freetype/internal/tterrors.h>
 #include <freetype/tttags.h>
 
-#include <ttload.h>
-#include <ttcmap.h>
+#ifdef FT_FLAT_COMPILE
+#include "ttload.h"
+#include "ttcmap.h"
+#else
+#include <sfnt/ttload.h>
+#include <sfnt/ttcmap.h>
+#endif
+
+
 
 
   /*************************************************************************/
--- a/src/sfnt/ttpost.c
+++ b/src/sfnt/ttpost.c
@@ -29,8 +29,14 @@
 #include <freetype/internal/tterrors.h>
 #include <freetype/tttags.h>
 
-#include <ttpost.h>
-#include <ttload.h>
+#ifdef FT_FLAT_COMPILE
+#include "ttpost.h"
+#include "ttload.h"
+#else
+#include <sfnt/ttpost.h>
+#include <sfnt/ttload.h>
+#endif
+
 
 
   /*************************************************************************/
--- a/src/sfnt/ttsbit.c
+++ b/src/sfnt/ttsbit.c
@@ -20,7 +20,12 @@
 #include <freetype/internal/tterrors.h>
 #include <freetype/tttags.h>
 
-#include <ttsbit.h>
+#ifdef FT_FLAT_COMPILE
+#include "ttsbit.h"
+#else
+#include <sfnt/ttsbit.h>
+#endif
+
 
 
   /*************************************************************************/
--- a/src/sfnt/ttsbit.h
+++ b/src/sfnt/ttsbit.h
@@ -19,7 +19,12 @@
 #ifndef TTSBIT_H
 #define TTSBIT_H
 
-#include <ttload.h>
+#ifdef FT_FLAT_COMPILE
+#include "ttload.h"
+#else
+#include <sfnt/ttload.h>
+#endif
+
 
 
 #ifdef __cplusplus
--- a/src/smooth/ftgrays.c
+++ b/src/smooth/ftgrays.c
@@ -123,8 +123,13 @@
 
 #else /* _STANDALONE_ */
 
-
+#ifdef FT_FLAT_COMPILE
 #include "ftgrays.h"
+#else
+#include <smooth/ftgrays.h>
+#endif
+
+
 #include <freetype/internal/ftobjs.h>  /* for FT_UNUSED()               */
 #include <freetype/internal/ftdebug.h> /* for FT_TRACE() and FT_ERROR() */
 #include <freetype/ftoutln.h>          /* for FT_Outline_Decompose()    */
--- a/src/smooth/ftsmooth.c
+++ b/src/smooth/ftsmooth.c
@@ -18,8 +18,16 @@
 
 #include <freetype/internal/ftobjs.h>
 #include <freetype/ftoutln.h>
-#include <ftsmooth.h>
-#include <ftgrays.h>
+
+#ifdef FT_FLAT_COMPILE
+#include "ftsmooth.h"
+#include "ftgrays.h"
+#else
+#include <smooth/ftsmooth.h>
+#include <smooth/ftgrays.h>
+#endif
+
+
 
 
   /* initialize renderer -- init its raster */
--- a/src/smooth/rules.mk
+++ b/src/smooth/rules.mk
@@ -18,15 +18,9 @@
 SMOOTH_DIR  := $(SRC_)smooth
 SMOOTH_DIR_ := $(SMOOTH_DIR)$(SEP)
 
-# additional include flags used when compiling the driver
-#
-SMOOTH_INCLUDE := $(SMOOTH_DIR)
-
-
 # compilation flags for the driver
 #
-SMOOTH_CFLAGS  := $(SMOOTH_INCLUDE:%=$I%)
-SMOOTH_COMPILE := $(FT_COMPILE) $(SMOOTH_CFLAGS)
+SMOOTH_COMPILE := $(FT_COMPILE)
 
 
 # smooth driver sources (i.e., C files)
--- a/src/smooth/smooth.c
+++ b/src/smooth/smooth.c
@@ -18,8 +18,15 @@
 
 #define FT_MAKE_OPTION_SINGLE_OBJECT
 
-#include <ftgrays.c>
-#include <ftsmooth.c>
+#ifdef FT_FLAT_COMPILE
+#include "ftgrays.c"
+#include "ftsmooth.c"
+#else
+#include <smooth/ftgrays.c>
+#include <smooth/ftsmooth.c>
+#endif
+
+
 
 
 /* END */
--- a/src/truetype/rules.mk
+++ b/src/truetype/rules.mk
@@ -19,14 +19,9 @@
 TT_DIR_ := $(TT_DIR)$(SEP)
 
 
-# additional include flags used when compiling the driver
-#
-TT_INCLUDE := $(TT_DIR)
-
 # compilation flags for the driver
 #
-TT_CFLAGS  := $(TT_INCLUDE:%=$I%)
-TT_COMPILE := $(FT_COMPILE) $(TT_CFLAGS)
+TT_COMPILE := $(FT_COMPILE)
 
 
 # TrueType driver sources (i.e., C files)
--- a/src/truetype/truetype.c
+++ b/src/truetype/truetype.c
@@ -18,13 +18,26 @@
 
 #define FT_MAKE_OPTION_SINGLE_OBJECT
 
-#include <ttdriver.c>    /* driver interface     */
-#include <ttpload.c>     /* tables loader        */
-#include <ttgload.c>     /* glyph loader         */
-#include <ttobjs.c>      /* object manager       */
+#ifdef FT_FLAT_COMPILE
 
+#include "ttdriver.c"    /* driver interface     */
+#include "ttpload.c"     /* tables loader        */
+#include "ttgload.c"     /* glyph loader         */
+#include "ttobjs.c"      /* object manager       */
 #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
-#include <ttinterp.c>    /* bytecode interpreter */
+#include "ttinterp.c"    /* bytecode interpreter */
+#endif
+
+#else
+
+#include <truetype/ttdriver.c>    /* driver interface     */
+#include <truetype/ttpload.c>     /* tables loader        */
+#include <truetype/ttgload.c>     /* glyph loader         */
+#include <truetype/ttobjs.c>      /* object manager       */
+#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
+#include <truetype/ttinterp.c>    /* bytecode interpreter */
+#endif
+
 #endif
 
 
--- a/src/truetype/ttdriver.c
+++ b/src/truetype/ttdriver.c
@@ -21,8 +21,14 @@
 #include <freetype/internal/sfnt.h>
 #include <freetype/ttnameid.h>
 
-#include <ttdriver.h>
-#include <ttgload.h>
+#ifdef FT_FLAT_COMPILE
+#include "ttdriver.h"
+#include "ttgload.h"
+#else
+#include <truetype/ttdriver.h>
+#include <truetype/ttgload.h>
+#endif
+
 
 
   /*************************************************************************/
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -23,11 +23,12 @@
 #include <freetype/tttags.h>
 #include <freetype/ftoutln.h>
 
-#include <ttgload.h>
-
-#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
-#include <ttinterp.h>
+#ifdef FT_FLAT_COMPILE
+#include "ttgload.h"
+#else
+#include <truetype/ttgload.h>
 #endif
+
 
 
   /*************************************************************************/
--- a/src/truetype/ttgload.h
+++ b/src/truetype/ttgload.h
@@ -19,11 +19,22 @@
 #ifndef TTGLOAD_H
 #define TTGLOAD_H
 
-#include <ttobjs.h>
+#ifdef FT_FLAT_COMPILE
 
+#include "ttobjs.h"
 #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
-#include <ttinterp.h>
+#include "ttinterp.h"
 #endif
+
+#else
+
+#include <truetype/ttobjs.h>
+#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
+#include <truetype/ttinterp.h>
+#endif
+
+#endif
+
 
 #ifdef __cplusplus
   extern "C" {
--- a/src/truetype/ttinterp.c
+++ b/src/truetype/ttinterp.c
@@ -20,9 +20,14 @@
 #include <freetype/internal/ftcalc.h>
 #include <freetype/ftsystem.h>
 
-#include <ttobjs.h>
+#ifdef FT_FLAT_COMPILE
+#include "ttinterp.h"
+#else
+#include <truetype/ttinterp.h>
+#endif
+
+
 #include <freetype/internal/tterrors.h>
-#include <ttinterp.h>
 
 
 #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
--- a/src/truetype/ttinterp.h
+++ b/src/truetype/ttinterp.h
@@ -19,7 +19,12 @@
 #ifndef TTINTERP_H
 #define TTINTERP_H
 
-#include <ttobjs.h>
+#ifdef FT_FLAT_COMPILE
+#include "ttobjs.h"
+#else
+#include <truetype/ttobjs.h>
+#endif
+
 
 
 #ifdef __cplusplus
--- a/src/truetype/ttobjs.c
+++ b/src/truetype/ttobjs.c
@@ -24,15 +24,27 @@
 
 #include <freetype/internal/sfnt.h>
 #include <freetype/internal/psnames.h>
-#include <ttobjs.h>
 
-#include <ttpload.h>
-#include <ttgload.h>
-#include <freetype/internal/tterrors.h>
+#ifdef FT_FLAT_COMPILE
 
+#include "ttgload.h"
+#include "ttpload.h"
 #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
-#include <ttinterp.h>
+#include "ttinterp.h"
 #endif
+
+#else
+
+#include <truetype/ttgload.h>
+#include <truetype/ttpload.h>
+#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
+#include <truetype/ttinterp.h>
+#endif
+
+#endif
+
+#include <freetype/internal/tterrors.h>
+
 
 
   /*************************************************************************/
--- a/src/truetype/ttpload.c
+++ b/src/truetype/ttpload.c
@@ -21,7 +21,12 @@
 #include <freetype/internal/ftstream.h>
 #include <freetype/tttags.h>
 
-#include <ttpload.h>
+#ifdef FT_FLAT_COMPILE
+#include "ttpload.h"
+#else
+#include <truetype/ttpload.h>
+#endif
+
 #include <freetype/internal/tterrors.h>
 
 
--- a/src/type1/rules.mk
+++ b/src/type1/rules.mk
@@ -19,14 +19,9 @@
 T1_DIR_ := $(T1_DIR)$(SEP)
 
 
-# additional include flags used when compiling the driver
-#
-T1_INCLUDE := $(T1_DIR)
-
 # compilation flags for the driver
 #
-T1_CFLAGS  := $(T1_INCLUDE:%=$I%)
-T1_COMPILE := $(FT_COMPILE) $(T1_CFLAGS)
+T1_COMPILE := $(FT_COMPILE)
 
 
 # Type1 driver sources (i.e., C files)
--- a/src/type1/t1afm.c
+++ b/src/type1/t1afm.c
@@ -16,7 +16,12 @@
 /***************************************************************************/
 
 
-#include <t1afm.h>
+#ifdef FT_FLAT_COMPILE
+#include "t1afm.h"
+#else
+#include <type1/t1afm.h>
+#endif
+
 #include <freetype/internal/ftstream.h>
 #include <freetype/internal/t1types.h>
 
--- a/src/type1/t1driver.c
+++ b/src/type1/t1driver.c
@@ -16,9 +16,15 @@
 /***************************************************************************/
 
 
-#include <t1driver.h>
-#include <t1gload.h>
-#include <t1afm.h>
+#ifdef FT_FLAT_COMPILE
+#include "t1driver.h"
+#include "t1gload.h"
+#include "t1afm.h"
+#else
+#include <type1/t1driver.h>
+#include <type1/t1gload.h>
+#include <type1/t1afm.h>
+#endif
 
 #include <freetype/internal/ftdebug.h>
 #include <freetype/internal/ftstream.h>
--- a/src/type1/t1gload.c
+++ b/src/type1/t1gload.c
@@ -16,14 +16,26 @@
 /***************************************************************************/
 
 
-#include <t1gload.h>
+#ifdef FT_FLAT_COMPILE
+
+#include <type1/t1gload.h>
+#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
+#include <type1/t1hinter.h>
+#endif
+
+#else
+
+#include <type1/t1gload.h>
+#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
+#include <type1/t1hinter.h>
+#endif
+
+#endif
+
 #include <freetype/internal/ftdebug.h>
 #include <freetype/internal/ftstream.h>
 #include <freetype/ftoutln.h>
 
-#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
-#include <t1hinter.h>
-#endif
 
 #include <string.h>     /* for strcmp() */
 
--- a/src/type1/t1gload.h
+++ b/src/type1/t1gload.h
@@ -19,7 +19,12 @@
 #ifndef T1GLOAD_H
 #define T1GLOAD_H
 
-#include <t1objs.h>
+#ifdef FT_FLAT_COMPILE
+#include "t1objs.h"
+#else
+#include <type1/t1objs.h>
+#endif
+
 
 #ifdef __cplusplus
   extern "C" {
--- a/src/type1/t1hinter.c
+++ b/src/type1/t1hinter.c
@@ -26,8 +26,14 @@
 
 
 #include <freetype/internal/ftdebug.h>
-#include <t1objs.h>
-#include <t1hinter.h>
+#ifdef FT_FLAT_COMPILE
+#include "t1objs.h"
+#include "t1hinter.h"
+#else
+#include <type1/t1objs.h>
+#include <type1/t1hinter.h>
+#endif
+
 
 
   /*************************************************************************/
--- a/src/type1/t1hinter.h
+++ b/src/type1/t1hinter.h
@@ -19,8 +19,13 @@
 #ifndef T1HINTER_H
 #define T1HINTER_H
 
-#include <t1objs.h>
-#include <t1gload.h>
+#ifdef FT_FLAT_COMPILE
+#include "t1objs.h"
+#include "t1gload.h"
+#else
+#include <type1/t1objs.h>
+#include <type1/t1gload.h>
+#endif
 
 #ifdef __cplusplus
   extern "C" {
--- a/src/type1/t1load.c
+++ b/src/type1/t1load.c
@@ -20,8 +20,14 @@
 #include <freetype/internal/ftdebug.h>
 #include <freetype/internal/t1types.h>
 
-#include <t1tokens.h>
-#include <t1parse.h>
+#ifdef FT_FLAT_COMPILE
+#include "t1tokens.h"
+#include "t1parse.h"
+#else
+#include <type1/t1tokens.h>
+#include <type1/t1parse.h>
+#endif
+
 
 #include <stdio.h>
 
--- a/src/type1/t1load.h
+++ b/src/type1/t1load.h
@@ -20,7 +20,13 @@
 #define T1LOAD_H
 
 #include <freetype/internal/ftstream.h>
-#include <t1parse.h>
+
+#ifdef FT_FLAT_COMPILE
+#include "t1parse.h"
+#else
+#include <type1/t1parse.h>
+#endif
+
 
 #ifdef __cplusplus
   extern "C" {
--- a/src/type1/t1objs.c
+++ b/src/type1/t1objs.c
@@ -19,13 +19,27 @@
 #include <freetype/internal/ftdebug.h>
 #include <freetype/internal/ftstream.h>
 
-#include <t1gload.h>
-#include <t1load.h>
-#include <t1afm.h>
+#ifdef FT_FLAT_COMPILE
 
+#include "t1gload.h"
+#include "t1load.h"
+#include "t1afm.h"
 #ifndef T1_CONFIG_OPTION_DISABLE_HINTER
-#include <t1hinter.h>
+#include "t1hinter.h"
 #endif
+
+#else
+
+#include <type1/t1gload.h>
+#include <type1/t1load.h>
+#include <type1/t1afm.h>
+#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
+#include <type1/t1hinter.h>
+#endif
+
+#endif
+
+
 
 #include <freetype/internal/psnames.h>
 
--- a/src/type1/t1parse.c
+++ b/src/type1/t1parse.c
@@ -18,7 +18,13 @@
 
 #include <freetype/internal/ftdebug.h>
 #include <freetype/internal/t1types.h>
-#include <t1parse.h>
+
+#ifdef FT_FLAT_COMPILE
+#include "t1parse.h"
+#else
+#include <type1/t1parse.h>
+#endif
+
 
 #include <stdio.h>  /* for sscanf()  */
 #include <string.h> /* for strncpy() */
--- a/src/type1/t1parse.h
+++ b/src/type1/t1parse.h
@@ -31,7 +31,13 @@
 #define T1PARSE_H
 
 #include <freetype/internal/ftstream.h>
-#include <t1tokens.h>
+
+#ifdef FT_FLAT_COMPILE
+#include "t1tokens.h"
+#else
+#include <type1/t1tokens.h>
+#endif
+
 
 #ifdef __cplusplus
   extern "C" {
--- a/src/type1/t1tokens.c
+++ b/src/type1/t1tokens.c
@@ -32,8 +32,14 @@
 #include <freetype/internal/ftstream.h>
 #include <freetype/internal/ftdebug.h>
 
-#include <t1tokens.h>
-#include <t1load.h>
+#ifdef FT_FLAT_COMPILE
+#include "t1tokens.h"
+#include "t1load.h"
+#else
+#include <type1/t1tokens.h>
+#include <type1/t1load.h>
+#endif
+
 
 #include <string.h>     /* for strncmp() */
 
--- a/src/type1/t1tokens.h
+++ b/src/type1/t1tokens.h
@@ -19,7 +19,12 @@
 #ifndef T1TOKENS_H
 #define T1TOKENS_H
 
-#include <t1objs.h>
+#ifdef FT_FLAT_COMPILE
+#include "t1objs.h"
+#else
+#include <type1/t1objs.h>
+#endif
+
 
 
 #ifdef __cplusplus
--- a/src/type1/type1.c
+++ b/src/type1/type1.c
@@ -18,20 +18,39 @@
 
 #define FT_MAKE_OPTION_SINGLE_OBJECT
 
-#include <t1driver.c>
-#include <t1objs.c>
-#include <t1load.c>
-#include <t1gload.c>
-#include <t1tokens.c>
-#include <t1parse.c>
+#ifdef FT_FLAT_COMPILE
 
+#include "t1driver.c"
+#include "t1objs.c"
+#include "t1load.c"
+#include "t1gload.c"
+#include "t1tokens.c"
+#include "t1parse.c"
 #ifndef T1_CONFIG_OPTION_DISABLE_HINTER
-#include <t1hinter.c>
+#include "t1hinter.c"
 #endif
+#ifndef T1_CONFIG_OPTION_NO_AFM
+#include "t1afm.c"
+#endif
 
+#else /* FT_FLAT_COMPILE */
+
+#include <type1/t1driver.c>
+#include <type1/t1objs.c>
+#include <type1/t1load.c>
+#include <type1/t1gload.c>
+#include <type1/t1tokens.c>
+#include <type1/t1parse.c>
+#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
+#include <type1/t1hinter.c>
+#endif
 #ifndef T1_CONFIG_OPTION_NO_AFM
-#include <t1afm.c>
+#include <type1/t1afm.c>
 #endif
+
+#endif
+
+
 
 
 /* END */
--- a/src/type1z/rules.mk
+++ b/src/type1z/rules.mk
@@ -19,14 +19,9 @@
 T1Z_DIR_ := $(T1Z_DIR)$(SEP)
 
 
-# additional include flags used when compiling the driver
-#
-T1Z_INCLUDE := $(SHARED) $(T1Z_DIR)
-
 # compilation flags for the driver
 #
-T1Z_CFLAGS  := $(T1Z_INCLUDE:%=$I%)
-T1Z_COMPILE := $(FT_COMPILE) $(T1Z_CFLAGS)
+T1Z_COMPILE := $(FT_COMPILE)
 
 
 # Type1 driver sources (i.e., C files)
--- a/src/type1z/type1z.c
+++ b/src/type1z/type1z.c
@@ -18,14 +18,28 @@
 
 #define FT_MAKE_OPTION_SINGLE_OBJECT
 
-#include <z1parse.c>
-#include <z1load.c>
-#include <z1objs.c>
-#include <z1driver.c>
-#include <z1gload.c>
+#ifdef FT_FLAT_COMPILE
 
+#include "z1parse.c"
+#include "z1load.c"
+#include "z1objs.c"
+#include "z1driver.c"
+#include "z1gload.c"
 #ifndef Z1_CONFIG_OPTION_NO_AFM
-#include <z1afm.c>
+#include "z1afm.c"
+#endif
+
+#else
+
+#include <type1z/z1parse.c>
+#include <type1z/z1load.c>
+#include <type1z/z1objs.c>
+#include <type1z/z1driver.c>
+#include <type1z/z1gload.c>
+#ifndef Z1_CONFIG_OPTION_NO_AFM
+#include <type1z/z1afm.c>
+#endif
+
 #endif
 
 
--- a/src/type1z/z1afm.c
+++ b/src/type1z/z1afm.c
@@ -16,7 +16,12 @@
 /***************************************************************************/
 
 
-#include <z1afm.h>
+#ifdef FT_FLAT_COMPILE
+#include "z1afm.h"
+#else
+#include <type1z/z1afm.h>
+#endif
+
 #include <freetype/internal/ftstream.h>
 #include <freetype/internal/t1types.h>
 
--- a/src/type1z/z1afm.h
+++ b/src/type1z/z1afm.h
@@ -19,7 +19,12 @@
 #ifndef Z1AFM_H
 #define Z1AFM_H
 
-#include <z1objs.h>
+#ifdef FT_FLAT_COMPILE
+#include "z1objs.h"
+#else
+#include <type1z/z1objs.h>
+#endif
+
 
 
 #ifdef __cplusplus
--- a/src/type1z/z1driver.c
+++ b/src/type1z/z1driver.c
@@ -15,10 +15,18 @@
  *
  ******************************************************************/
 
-#include <z1driver.h>
-#include <z1gload.h>
-#include <z1load.h>
-#include <z1afm.h>
+#ifdef FT_FLAT_COMPILE
+#include "z1driver.h"
+#include "z1gload.h"
+#include "z1load.h"
+#include "z1afm.h"
+#else
+#include <type1z/z1driver.h>
+#include <type1z/z1gload.h>
+#include <type1z/z1load.h>
+#include <type1z/z1afm.h>
+#endif
+
 
 #include <freetype/internal/ftdebug.h>
 #include <freetype/internal/ftstream.h>
--- a/src/type1z/z1gload.c
+++ b/src/type1z/z1gload.c
@@ -15,7 +15,12 @@
  *
  ******************************************************************/
 
-#include <z1gload.h>
+#ifdef FT_FLAT_COMPILE
+#include "z1gload.h"
+#else
+#include <type1z/z1gload.h>
+#endif
+
 #include <freetype/internal/ftdebug.h>
 #include <freetype/internal/ftstream.h>
 #include <freetype/ftoutln.h>
--- a/src/type1z/z1gload.h
+++ b/src/type1z/z1gload.h
@@ -35,7 +35,12 @@
 #ifndef Z1GLOAD_H
 #define Z1GLOAD_H
 
-#include <z1objs.h>
+#ifdef FT_FLAT_COMPILE
+#include "z1objs.h"
+#else
+#include <type1z/z1objs.h>
+#endif
+
 
 #ifdef __cplusplus
   extern "C" {
--- a/src/type1z/z1load.c
+++ b/src/type1z/z1load.c
@@ -65,7 +65,13 @@
 
 #include <freetype/internal/t1types.h>
 #include <freetype/internal/t1errors.h>
-#include <z1load.h>
+
+#ifdef FT_FLAT_COMPILE
+#include "z1load.h"
+#else
+#include <type1z/z1load.h>
+#endif
+
 #include <stdio.h>
 
 #undef  FT_COMPONENT
@@ -631,7 +637,11 @@
 #define Z1_TOPDICT_NUM_FIXED2(n,f,m)   Z1_NEW_FIXED_TABLE2(n,f,m)
 
 /* including this file defines all field variables */
-#include <z1tokens.h>
+#ifdef FT_FLAT_COMPILE
+#include "z1tokens.h"
+#else
+#include <type1z/z1tokens.h>
+#endif
 
  /*********************************************************************
   *
@@ -1203,7 +1213,11 @@
   static
   const Z1_KeyWord  t1_keywords[] =
   {
-#include <z1tokens.h>  
+#ifdef FT_FLAT_COMPILE
+#include "z1tokens.h"
+#else
+#include <type1z/z1tokens.h>
+#endif
     
     /* now add the special functions... */
     Z1_KEYWORD_CALLBACK( "FontName", parse_font_name ),
--- a/src/type1z/z1load.h
+++ b/src/type1z/z1load.h
@@ -21,7 +21,14 @@
 #include <freetype/internal/ftstream.h>
 #include <freetype/internal/t1types.h>
 #include <freetype/ftmm.h>
-#include <z1parse.h>
+
+#ifdef FT_FLAT_COMPILE
+#include "z1parse.h"
+#else
+#include <type1z/z1parse.h>
+#endif
+
+
 
 #ifdef __cplusplus
   extern "C" {
--- a/src/type1z/z1objs.c
+++ b/src/type1z/z1objs.c
@@ -18,10 +18,18 @@
 #include <freetype/internal/ftdebug.h>
 #include <freetype/internal/ftstream.h>
 
-#include <z1gload.h>
-#include <z1load.h>
+#ifdef FT_FLAT_COMPILE
+#include "z1gload.h"
+#include "z1load.h"
+#include "z1afm.h"
+#else
+#include <type1z/z1gload.h>
+#include <type1z/z1load.h>
+#include <type1z/z1afm.h>
+#endif
+
+
 #include <freetype/internal/psnames.h>
-#include <z1afm.h>
 
 /* Required by tracing mode */
 #undef   FT_COMPONENT
--- a/src/type1z/z1parse.c
+++ b/src/type1z/z1parse.c
@@ -33,7 +33,13 @@
 #include <freetype/internal/ftobjs.h>
 #include <freetype/internal/ftstream.h>
 #include <freetype/internal/t1errors.h>
-#include <z1parse.h>
+
+#ifdef FT_FLAT_COMPILE
+#include "z1parse.h"
+#else
+#include <type1z/z1parse.h>
+#endif
+
 
 #undef FT_COMPONENT
 #define FT_COMPONENT  trace_t1load
--- a/src/winfonts/rules.mk
+++ b/src/winfonts/rules.mk
@@ -19,14 +19,7 @@
 FNT_DIR_ := $(FNT_DIR)$(SEP)
 
 
-# additional include flags used when compiling the driver
-#
-FNT_INCLUDE := $(FNT_DIR)
-
-# compilation flags for the driver
-#
-FNT_CFLAGS  := $(FNT_INCLUDE:%=$I%)
-FNT_COMPILE := $(FT_COMPILE) $(FNT_CFLAGS)
+FNT_COMPILE := $(FT_COMPILE)
 
 
 # Windows driver sources (i.e., C files)
--- a/src/winfonts/winfnt.c
+++ b/src/winfonts/winfnt.c
@@ -15,7 +15,12 @@
 /*                                                                         */
 /***************************************************************************/
 
-#include <winfnt.h>
+#ifdef FT_FLAT_COMPILE
+#include "winfnt.h"
+#else
+#include <winfonts/winfnt.h>
+#endif
+
 #include <freetype/fterrors.h>
 #include <freetype/internal/ftstream.h>
 #include <freetype/internal/ftdebug.h>
@@ -170,6 +175,7 @@
          READ_Fields( winmz_header_fields, &mz_header ) )
       goto Exit;
 
+    error = FT_Err_Unknown_File_Format;
     if ( mz_header.magic == WINFNT_MZ_MAGIC )
     {
       /* yes, now look for a NE header in the file */
@@ -179,6 +185,7 @@
            READ_Fields( winne_header_fields, &ne_header ) )
         goto Exit;
       
+      error = FT_Err_Unknown_File_Format;
       if ( ne_header.magic == WINFNT_NE_MAGIC )
       {
         /* good, now look in the resource table for each FNT resource */