Implement new, simplified module selection.  With GNU make it is now
sufficient to modify a single file, `modules.cfg', to control the
inclusion of modules and base extension files.

This change also fixes the creation of ftmodule.h; it now depends on
`modules.cfg' and thus is rebuilt only if necessary.

Finally, a version of `ftoption.h' in OBJ_DIR is preferred over the
default location.

* modules.cfg: New file.

* builds/freetype.mk: Don't include `modules.mk'.
Include all `rules.mk' files as specified in `modules.cfg'.
(FTOPTION_FLAG, FTOPTION_H): New variables.
(FT_CFLAGS): Add macro definition for FT_CONFIG_MODULES_H.
Add FTOPTION_FLAG.
($(FT_INIT_OBJ)): Don't use FT_MODULE_LIST.
(CONFIG_H): Add FTMODULE_H and FTOPTION_H.
(INCLUDES): Add DEVEL_DIR.
(INCLUDE_FLAGS, FTSYS_SRC, FTSYS_OBJ, FTDEBUG_SRC, FTDEBUG_OBJ,
OBJ_M, OBJ_S): Use `:=', not `='.
(remove_ftmodule_h): New phony target to delete `ftmodule.h'.
(distclean): Add remove_ftmodule_h.

* builds/modules.mk: (MODULE_LIST): Removed.
(make_module_list, clean_module_list): Replace targets
with...
(FTMODULE_H_INIT, FTMODULE_H_CREATE, FTMODULE_H_DONE): New
variables.  Reason for the change is that it is not possible to have
a phony prerequisite which is run only if the target file must be
rebuilt (phony prerequisites act like subroutines and are *always*
executed).  We only want to rebuild `ftmodule.h' if `module.cfg' is
changed.
Update all callers.
($FTMODULE_H)): Rule to create `ftmodule.h', depending on
`modules.cfg'.

* builds/toplevel.mk: Rewrite and simplify module handling.
(MODULES_CFG, FTMODULE_H): New variables.
Include MODULES_CFG.
(MODULES): New variable to include all `module.mk' and `rules.mk'
files.  We no longer use make's `wildcard' function for this.

* Makefile (USE_MODULES): Remove.  Update all users.
(OBJ_DIR): Define it here.

* src/*/module.mk: Change

    make_module_list: foo
    foo: ...

to

    FTMODULE_H_COMMANDS += FOO
    define FOO
    ...
    endef

in all files.  `FTMODULE_H_COMMANDS' is used in `FTMODULE_H_CREATE'.

* src/base/rules.mk (BASE_EXT_SRC): Use BASE_EXTENSIONS.

* builds/unix/detect.mk (setup): Always execute `configure' script.
(have_mk): Rename to...
(have_Makefile): This.
Don't use `strip' function.

* builds/unix/unix.mk: Include `install.mk' only if BUILD_PROJECT is
defined.
(have_mk): Don't use `strip' function.
Test for unix-def.mk in OBJ_DIR, not BUILD_DIR (and invert the test
accordingly).

* builds/unix/install.mk (install, uninstall): Handle `ftmodule.h'.

* builds/os2/os2-dev.mk, builds/unix/unix-dev.mk,
builds/win32/w32-bccd.mk, builds/win32/w32-dev.mk: Don't define
BUILD_DIR but DEVEL_DIR for development header files.

* builds/ansi/ansi-def.mk (TOP_DIR, OBJ_DIR),
builds/beos/beos-def.mk (TOP_DIR, OBJ_DIR), builds/unix/unix-def.in
(TOP_DIR, OBJ_DIR): Removed.  Defined elsewhere.

* builds/dos/dos-def.mk (OBJ_DIR), builds/os2/os2-def.mk (OBJ_DIR),
builds/win32/win32-def.mk (OBJ_DIR): Removed.  Defined elsewhere.

* builds/unix/unixddef.mk: Don't define BUILD_DIR but DEVEL_DIR for
development header files.
Don't define PLATFORM.

* configure: Copy `modules.cfg' to builddir if builddir != srcdir.
Update snippet taken from autoconf's m4sh.m4 to current CVS version.
Be more verbose.

* include/freetype/config/ftmodule.h: Add comments -- this file is
no longer used if FreeType is built with GNU make.

* docs/CHANGES, docs/CUSTOMIZE, docs/INSTALL, docs/INSTALL.ANY,
docs/INSTALL.GNU, docs/INSTALL.UNX: Document new build mechanism.
Other minor updates.

* modules.txt: Removed.  Contents included in `modules.cfg'.


* include/freetype/internal/ftmemory.h (FT_QAlloc_Debug,
FT_Free_Debug) [FT_STRICT_ALIASING]: Fix typos.

* src/base/ftdbgmem.c (FT_Alloc_Debug, FT_Realloc_Debug,
FT_QAlloc_Debug, FT_QRealloc_Debug, FT_Free_Debug)
[FT_STRICT_ALIASING]: Implement.
diff --git a/ChangeLog b/ChangeLog
index e9a636c..c2f700d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,123 @@
+2006-01-29  Werner Lemberg  <wl@gnu.org>
+
+	Implement new, simplified module selection.  With GNU make it is now
+	sufficient to modify a single file, `modules.cfg', to control the
+	inclusion of modules and base extension files.
+
+	This change also fixes the creation of ftmodule.h; it now depends on
+	`modules.cfg' and thus is rebuilt only if necessary.
+
+	Finally, a version of `ftoption.h' in OBJ_DIR is preferred over the
+	default location.
+
+	* modules.cfg: New file.
+
+	* builds/freetype.mk: Don't include `modules.mk'.
+	Include all `rules.mk' files as specified in `modules.cfg'.
+	(FTOPTION_FLAG, FTOPTION_H): New variables.
+	(FT_CFLAGS): Add macro definition for FT_CONFIG_MODULES_H.
+	Add FTOPTION_FLAG.
+	($(FT_INIT_OBJ)): Don't use FT_MODULE_LIST.
+	(CONFIG_H): Add FTMODULE_H and FTOPTION_H.
+	(INCLUDES): Add DEVEL_DIR.
+	(INCLUDE_FLAGS, FTSYS_SRC, FTSYS_OBJ, FTDEBUG_SRC, FTDEBUG_OBJ,
+	OBJ_M, OBJ_S): Use `:=', not `='.
+	(remove_ftmodule_h): New phony target to delete `ftmodule.h'.
+	(distclean): Add remove_ftmodule_h.
+
+	* builds/modules.mk: (MODULE_LIST): Removed.
+	(make_module_list, clean_module_list): Replace targets
+	with...
+	(FTMODULE_H_INIT, FTMODULE_H_CREATE, FTMODULE_H_DONE): New
+	variables.  Reason for the change is that it is not possible to have
+	a phony prerequisite which is run only if the target file must be
+	rebuilt (phony prerequisites act like subroutines and are *always*
+	executed).  We only want to rebuild `ftmodule.h' if `module.cfg' is
+	changed.
+	Update all callers.
+	($FTMODULE_H)): Rule to create `ftmodule.h', depending on
+	`modules.cfg'.
+
+	* builds/toplevel.mk: Rewrite and simplify module handling.
+	(MODULES_CFG, FTMODULE_H): New variables.
+	Include MODULES_CFG.
+	(MODULES): New variable to include all `module.mk' and `rules.mk'
+	files.  We no longer use make's `wildcard' function for this.
+
+	* Makefile (USE_MODULES): Remove.  Update all users.
+	(OBJ_DIR): Define it here.
+
+	* src/*/module.mk: Change
+
+	    make_module_list: foo
+	    foo: ...
+
+	to
+
+	    FTMODULE_H_COMMANDS += FOO
+	    define FOO
+	    ...
+	    endef
+
+	in all files.  `FTMODULE_H_COMMANDS' is used in `FTMODULE_H_CREATE'.
+
+	* src/base/rules.mk (BASE_EXT_SRC): Use BASE_EXTENSIONS.
+
+	* builds/unix/detect.mk (setup): Always execute `configure' script.
+	(have_mk): Rename to...
+	(have_Makefile): This.
+	Don't use `strip' function.
+
+	* builds/unix/unix.mk: Include `install.mk' only if BUILD_PROJECT is
+	defined.
+	(have_mk): Don't use `strip' function.
+	Test for unix-def.mk in OBJ_DIR, not BUILD_DIR (and invert the test
+	accordingly).
+
+	* builds/unix/install.mk (install, uninstall): Handle `ftmodule.h'.
+
+	* builds/os2/os2-dev.mk, builds/unix/unix-dev.mk,
+	builds/win32/w32-bccd.mk, builds/win32/w32-dev.mk: Don't define
+	BUILD_DIR but DEVEL_DIR for development header files.
+
+	* builds/ansi/ansi-def.mk (TOP_DIR, OBJ_DIR),
+	builds/beos/beos-def.mk (TOP_DIR, OBJ_DIR), builds/unix/unix-def.in
+	(TOP_DIR, OBJ_DIR): Removed.  Defined elsewhere.
+
+	* builds/dos/dos-def.mk (OBJ_DIR), builds/os2/os2-def.mk (OBJ_DIR),
+	builds/win32/win32-def.mk (OBJ_DIR): Removed.  Defined elsewhere.
+
+	* builds/unix/unixddef.mk: Don't define BUILD_DIR but DEVEL_DIR for
+	development header files.
+	Don't define PLATFORM.
+
+	* configure: Copy `modules.cfg' to builddir if builddir != srcdir.
+	Update snippet taken from autoconf's m4sh.m4 to current CVS version.
+	Be more verbose.
+
+	* include/freetype/config/ftmodule.h: Add comments -- this file is
+	no longer used if FreeType is built with GNU make.
+
+	* docs/CHANGES, docs/CUSTOMIZE, docs/INSTALL, docs/INSTALL.ANY,
+	docs/INSTALL.GNU, docs/INSTALL.UNX: Document new build mechanism.
+	Other minor updates.
+
+	* modules.txt: Removed.  Contents included in `modules.cfg'.
+
+
+	* include/freetype/internal/ftmemory.h (FT_QAlloc_Debug,
+	FT_Free_Debug) [FT_STRICT_ALIASING]: Fix typos.
+
+	* src/base/ftdbgmem.c (FT_Alloc_Debug, FT_Realloc_Debug,
+	FT_QAlloc_Debug, FT_QRealloc_Debug, FT_Free_Debug)
+	[FT_STRICT_ALIASING]: Implement.
+
 2006-01-31  Chia-I Wu  <b90201047@ntu.edu.tw>
 
 	* src/cff/cffobjs.c (cff_face_init), src/cid/cidobjs.c
-	(cid_face_init), src/pfr/pfrobjs.c (pfr_face_init), src/type1/t1objs.c
-	(T1_Face_Init): Set face->height to
-	MAX(1.2 * units_per_EM, ascender - descender).
+	(cid_face_init), src/pfr/pfrobjs.c (pfr_face_init),
+	src/type1/t1objs.c (T1_Face_Init): Set face->height to MAX(1.2 *
+	units_per_EM, ascender - descender).
 
 2006-01-31  Chia-I Wu  <b90201047@ntu.edu.tw>
 
@@ -13,8 +127,8 @@
 
 	* src/type1/t1afm.c (T1_Read_Metrics): Use the metrics from the AFM.
 
-	* include/freetype/freetype.h (FT_FaceRec): Mention that fields may be
-	changed after file attachment.
+	* include/freetype/freetype.h (FT_FaceRec): Mention that fields may
+	be changed after file attachment.
 
 2006-01-28  Werner Lemberg  <wl@gnu.org>
 
diff --git a/Makefile b/Makefile
index 8caf1f0..ab8dba5 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,7 @@
 #
 
 
-# Copyright 1996-2000, 2002 by
+# Copyright 1996-2000, 2002, 2006 by
 # David Turner, Robert Wilhelm, and Werner Lemberg.
 #
 # This file is part of the FreeType project, and may only be used, modified,
@@ -18,8 +18,6 @@
 PROJECT := freetype
 PROJECT_TITLE := FreeType
 
-USE_MODULES := 1
-
 # The variable TOP_DIR holds the path to the topmost directory in the project
 # engine source hierarchy.  If it is not defined, default it to `.'.
 #
@@ -27,6 +25,14 @@
   TOP_DIR := .
 endif
 
+# The variable OBJ_DIR gives the location where object files and the
+# FreeType library are built.
+#
+ifndef OBJ_DIR
+  OBJ_DIR := $(TOP_DIR)/objs
+endif
+
+
 include $(TOP_DIR)/builds/toplevel.mk
 
 # EOF
diff --git a/builds/ansi/ansi-def.mk b/builds/ansi/ansi-def.mk
index bf2aa36..b456439 100644
--- a/builds/ansi/ansi-def.mk
+++ b/builds/ansi/ansi-def.mk
@@ -3,7 +3,7 @@
 #
 
 
-# Copyright 1996-2000, 2003 by
+# Copyright 1996-2000, 2003, 2006 by
 # David Turner, Robert Wilhelm, and Werner Lemberg.
 #
 # This file is part of the FreeType project, and may only be used, modified,
@@ -13,30 +13,12 @@
 # fully.
 
 
-ifndef TOP_DIR
-  TOP_DIR := .
-endif
-
 DELETE    := rm -f
 SEP       := /
 BUILD_DIR := $(TOP_DIR)/builds/ansi
 PLATFORM  := ansi
 
 
-# The directory where all object files are placed.
-#
-# This lets you build the library in your own directory with something like
-#
-#   set TOP_DIR=.../path/to/freetype2/top/dir...
-#   set OBJ_DIR=.../path/to/obj/dir
-#   make -f $TOP_DIR/Makefile setup [options]
-#   make -f $TOP_DIR/Makefile
-#
-ifndef OBJ_DIR
-  OBJ_DIR := $(TOP_DIR)/objs
-endif
-
-
 # The directory where all library files are placed.
 #
 # By default, this is the same as $(OBJ_DIR); however, this can be changed
diff --git a/builds/beos/beos-def.mk b/builds/beos/beos-def.mk
index b569fe6..c987410 100644
--- a/builds/beos/beos-def.mk
+++ b/builds/beos/beos-def.mk
@@ -5,7 +5,7 @@
 #
 
 
-# Copyright 1996-2000, 2003 by
+# Copyright 1996-2000, 2003, 2006 by
 # David Turner, Robert Wilhelm, and Werner Lemberg.
 #
 # This file is part of the FreeType project, and may only be used, modified,
@@ -15,30 +15,12 @@
 # fully.
 
 
-ifndef TOP_DIR
-  TOP_DIR := .
-endif
-
 DELETE    := rm -f
 SEP       := /
 BUILD_DIR := $(TOP_DIR)/builds/beos
 PLATFORM  := beos
 
 
-# The directory where all object files are placed.
-#
-# This lets you build the library in your own directory with something like
-#
-#   set TOP_DIR=.../path/to/freetype2/top/dir...
-#   set OBJ_DIR=.../path/to/obj/dir
-#   make -f $TOP_DIR/Makefile setup [options]
-#   make -f $TOP_DIR/Makefile
-#
-ifndef OBJ_DIR
-  OBJ_DIR := $(TOP_DIR)/objs
-endif
-
-
 # The directory where all library files are placed.
 #
 # By default, this is the same as $(OBJ_DIR); however, this can be changed
diff --git a/builds/dos/dos-def.mk b/builds/dos/dos-def.mk
index 70391bc..c68bd74 100644
--- a/builds/dos/dos-def.mk
+++ b/builds/dos/dos-def.mk
@@ -3,7 +3,7 @@
 #
 
 
-# Copyright 1996-2000, 2003, 2005 by
+# Copyright 1996-2000, 2003, 2005, 2006 by
 # David Turner, Robert Wilhelm, and Werner Lemberg.
 #
 # This file is part of the FreeType project, and may only be used, modified,
@@ -23,20 +23,6 @@
 #
 E := .exe
 
-# The directory where all object files are placed.
-#
-# This lets you build the library in your own directory with something like
-#
-#   set TOP_DIR=.../path/to/freetype2/top/dir...
-#   set OBJ_DIR=.../path/to/obj/dir
-#   make -f %TOP_DIR%/Makefile setup [options]
-#   make -f %TOP_DIR%/Makefile
-#
-ifndef OBJ_DIR
-  OBJ_DIR := $(TOP_DIR)/objs
-endif
-
-
 # The directory where all library files are placed.
 #
 # By default, this is the same as $(OBJ_DIR); however, this can be changed
diff --git a/builds/freetype.mk b/builds/freetype.mk
index a87f7fe..2f9b540 100644
--- a/builds/freetype.mk
+++ b/builds/freetype.mk
@@ -21,7 +21,7 @@
 # environment, or on the command line) are used:
 #
 #   BUILD_DIR      The architecture dependent directory,
-#                  e.g. `$(TOP_DIR)/builds/unix'.
+#                  e.g. `$(TOP_DIR)/builds/unix'.  Added to INCLUDES also.
 #
 #   OBJ_DIR        The directory in which object files are created.
 #
@@ -30,7 +30,9 @@
 #   DOC_DIR        The directory in which the API reference is created.
 #
 #   INCLUDES       A list of directories to be included additionally.
-#                  Usually empty.
+#
+#   DEVEL_DIR      Development directory which is added to the INCLUDES
+#                  variable before the standard include directories.
 #
 #   CFLAGS         Compilation flags.  This overrides the default settings
 #                  in the platform-specific configuration files.
@@ -42,9 +44,9 @@
 #                  file for `src/base/ftdebug.c'.  [For a normal build, this
 #                  file does nothing.]
 #
-#   FT_MODULE_LIST The file which contains the list of modules for the
-#                  current build.  Usually, this is automatically created by
-#                  `modules.mk'.
+#   FTMODULE_H     The file which contains the list of module classes for
+#                  the current build.  Usually, this is automatically
+#                  created by `modules.mk'.
 #
 #   BASE_OBJ_S
 #   BASE_OBJ_M     A list of base objects (for single object and multiple
@@ -115,15 +117,17 @@
 # include paths
 #
 # IMPORTANT NOTE: The architecture-dependent directory must ALWAYS be placed
-#                 in front of the include list.  Porters are then able to
+#                 before the standard include list.  Porters are then able to
 #                 put their own version of some of the FreeType components
 #                 in the `freetype/builds/<system>' directory, as these
 #                 files will override the default sources.
 #
-INCLUDES := $(subst /,$(COMPILER_SEP),$(OBJ_DIR) $(BUILD_DIR) \
+INCLUDES := $(subst /,$(COMPILER_SEP),$(OBJ_DIR) \
+                                      $(DEVEL_DIR) \
+                                      $(BUILD_DIR) \
                                       $(TOP_DIR)/include)
 
-INCLUDE_FLAGS = $(INCLUDES:%=$I%)
+INCLUDE_FLAGS := $(INCLUDES:%=$I%)
 
 
 # C flags used for the compilation of an object file.  This must include at
@@ -137,19 +141,30 @@
 # FreeType.  This is required to let our sources include the internal
 # headers (something forbidden by clients).
 #
-FT_CFLAGS  = $(CPPFLAGS) $(INCLUDE_FLAGS) $(CFLAGS) $DFT2_BUILD_LIBRARY
+# Finally, we define FT_CONFIG_MODULES_H so that the compiler uses the
+# generated version of `ftmodule.h' in $(OBJ_DIR).  If there is an
+# `ftoption.h' files in $(OBJ_DIR), define FT_CONFIG_OPTIONS_H too.
+#
+ifneq ($(wildcard $(OBJ_DIR)/ftoption.h),)
+  FTOPTION_H    := $(OBJ_DIR)/ftoption.h
+  FTOPTION_FLAG := $DFT_CONFIG_OPTIONS_H="<ftoption.h>"
+endif
+
+FT_CFLAGS  = $(CPPFLAGS) \
+             $(INCLUDE_FLAGS) \
+             $(CFLAGS) \
+             $DFT2_BUILD_LIBRARY \
+             $DFT_CONFIG_MODULES_H="<ftmodule.h>" \
+             $(FTOPTION_FLAG)
 FT_CC      = $(CC) $(FT_CFLAGS)
 FT_COMPILE = $(CC) $(ANSIFLAGS) $(FT_CFLAGS)
 
 
-# Include the `modules' rules file.
-#
-include $(TOP_DIR)/builds/modules.mk
-
-# Includes the 'exports' rules file.
+# Include the `exports' rules file.
 #
 include $(TOP_DIR)/builds/exports.mk
 
+
 # Initialize the list of objects.
 #
 OBJECTS_LIST :=
@@ -166,7 +181,9 @@
 BASE_H     := $(wildcard $(INTERNAL_DIR)/*.h) \
               $(wildcard $(SERVICES_DIR)/*.h)
 CONFIG_H   := $(wildcard $(CONFIG_DIR)/*.h) \
-              $(wildcard $(BUILD_DIR)/freetype/config/*.h)
+              $(wildcard $(BUILD_DIR)/freetype/config/*.h) \
+              $(FTMODULE_H) \
+              $(FTOPTION_H)
 CACHE_H    := $(wildcard $(CACHE_DIR)/*.h)
 DEVEL_H    := $(wildcard $(TOP_DIR)/devel/*.h)
 
@@ -176,10 +193,10 @@
 # ftsystem component
 #
 ifndef FTSYS_SRC
-  FTSYS_SRC = $(BASE_DIR)/ftsystem.c
+  FTSYS_SRC := $(BASE_DIR)/ftsystem.c
 endif
 
-FTSYS_OBJ = $(OBJ_DIR)/ftsystem.$O
+FTSYS_OBJ := $(OBJ_DIR)/ftsystem.$O
 
 OBJECTS_LIST += $(FTSYS_OBJ)
 
@@ -190,10 +207,10 @@
 # ftdebug component
 #
 ifndef FTDEBUG_SRC
-  FTDEBUG_SRC = $(BASE_DIR)/ftdebug.c
+  FTDEBUG_SRC := $(BASE_DIR)/ftdebug.c
 endif
 
-FTDEBUG_OBJ = $(OBJ_DIR)/ftdebug.$O
+FTDEBUG_OBJ := $(OBJ_DIR)/ftdebug.$O
 
 OBJECTS_LIST += $(FTDEBUG_OBJ)
 
@@ -203,7 +220,8 @@
 
 # Include all rule files from FreeType components.
 #
-include $(wildcard $(SRC_DIR)/*/rules.mk)
+include $(SRC_DIR)/base/rules.mk
+include $(patsubst %,$(SRC_DIR)/%/rules.mk,$(MODULES))
 
 
 # ftinit component
@@ -222,17 +240,14 @@
 
 OBJECTS_LIST += $(FTINIT_OBJ)
 
-$(FTINIT_OBJ): $(FTINIT_SRC) $(FREETYPE_H) $(FT_MODULE_LIST)
+$(FTINIT_OBJ): $(FTINIT_SRC) $(FREETYPE_H)
 	$(FT_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<)
 
 
-# All FreeType library objects
+# All FreeType library objects.
 #
-#   By default, we include the base layer extensions.  These could be
-#   omitted on builds which do not want them.
-#
-OBJ_M = $(BASE_OBJ_M) $(BASE_EXT_OBJ) $(DRV_OBJS_M)
-OBJ_S = $(BASE_OBJ_S) $(BASE_EXT_OBJ) $(DRV_OBJS_S)
+OBJ_M := $(BASE_OBJ_M) $(BASE_EXT_OBJ) $(DRV_OBJS_M)
+OBJ_S := $(BASE_OBJ_S) $(BASE_EXT_OBJ) $(DRV_OBJS_S)
 
 
 # The target `multi' on the Make command line indicates that we want to
@@ -298,13 +313,18 @@
 	-$(DELETE) $(subst /,\,$(PROJECT_LIBRARY) $(DISTCLEAN) $(NO_OUTPUT))
 
 
-.PHONY: remove_config_mk
+.PHONY: remove_config_mk remove_ftmodule_h
 
 # Remove configuration file (used for distclean).
 #
 remove_config_mk:
 	-$(DELETE) $(subst /,$(SEP),$(CONFIG_MK) $(NO_OUTPUT))
 
+# Remove module list (used for distclean).
+#
+remove_ftmodule_h:
+	-$(DELETE) $(subst /,$(SEP),$(FTMODULE_H) $(NO_OUTPUT))
+
 
 .PHONY: clean distclean
 
@@ -314,7 +334,7 @@
 # implementation.
 #
 clean: clean_project
-distclean: distclean_project remove_config_mk
+distclean: distclean_project remove_config_mk remove_ftmodule_h
 	-$(DELETE) $(subst /,$(SEP),$(DOC_DIR)/*.html $(NO_OUTPUT))
 
 
diff --git a/builds/modules.mk b/builds/modules.mk
index 5102dc0..5f1f9ee 100644
--- a/builds/modules.mk
+++ b/builds/modules.mk
@@ -3,7 +3,7 @@
 #
 
 
-# Copyright 1996-2000, 2003 by
+# Copyright 1996-2000, 2003, 2006 by
 # David Turner, Robert Wilhelm, and Werner Lemberg.
 #
 # This file is part of the FreeType project, and may only be used, modified,
@@ -20,43 +20,45 @@
 # This file is in charge of handling the generation of the modules list
 # file.
 
-.PHONY: make_module_list clean_module_list
 
-# MODULE_LIST, as its name suggests, indicates where the modules list
-# resides.  For now, it is in `include/freetype/config/ftmodule.h'.
+# Build the modules list.
 #
-ifndef MODULE_LIST
-  MODULE_LIST := $(TOP_DIR)/include/$(PROJECT)/config/ftmodule.h
-endif
-
-# To build the modules list, we invoke the `make_module_list' target.
-#
-# This rule is commented out by default since FreeType comes already with
-# an ftmodule.h file.
-#
-#$(MODULE_LIST): make_module_list
-
+$(FTMODULE_H): $(MODULES_CFG)
+	$(FTMODULE_H_INIT)
+	$(FTMODULE_H_CREATE)
+	$(FTMODULE_H_DONE)
 
 ifneq ($(findstring $(PLATFORM),dos win32 win16 os2),)
   OPEN_MODULE   := @echo$(space)
-  CLOSE_MODULE  :=  >> $(subst /,\,$(MODULE_LIST))
-  REMOVE_MODULE := @-$(DELETE) $(subst /,\,$(MODULE_LIST))
+  CLOSE_MODULE  :=  >> $(subst /,\,$(FTMODULE_H))
+  REMOVE_MODULE := @-$(DELETE) $(subst /,\,$(FTMODULE_H))
 else
   OPEN_MODULE   := @echo "
-  CLOSE_MODULE  := " >> $(MODULE_LIST)
-  REMOVE_MODULE := @-$(DELETE) $(MODULE_LIST)
+  CLOSE_MODULE  := " >> $(FTMODULE_H)
+  REMOVE_MODULE := @-$(DELETE) $(FTMODULE_H)
 endif
 
 
-# Before the modules list file can be generated, we must remove the file in
-# order to `clean' the list.
-#
-clean_module_list:
-	$(REMOVE_MODULE)
-	@-echo Regenerating modules list in $(MODULE_LIST)...
+define FTMODULE_H_INIT
+$(REMOVE_MODULE)
+@-echo Generating modules list in $(FTMODULE_H)...
+$(OPEN_MODULE)/* This is a generated file. */$(CLOSE_MODULE)
+endef
 
-make_module_list: clean_module_list
-	@echo done.
+# It is no mistake that the final closing parenthesis is on the
+# next line -- it produces proper newlines during the expansion
+# of `foreach'.
+#
+define FTMODULE_H_CREATE
+$(foreach COMMAND,$(FTMODULE_H_COMMANDS),$($(COMMAND))
+)
+endef
+
+define FTMODULE_H_DONE
+$(OPEN_MODULE)/* EOF */$(CLOSE_MODULE)
+@echo done.
+endef
+
 
 # $(OPEN_DRIVER) & $(CLOSE_DRIVER) are used to specify a given font driver
 # in the `module.mk' rules file.
@@ -68,10 +70,10 @@
 ECHO_DRIVER_DESC := (
 ECHO_DRIVER_DONE := )"
 
-# Each `module.mk' in the `src' sub-dirs is used to add one rule to the
-# target `make_module_list'.
+# Each `module.mk' in the `src/*' subdirectories adds a variable with
+# commands to $(FTMODULE_H_COMMANDS).  Note that we can't use SRC_DIR here.
 #
-include $(wildcard $(TOP_DIR)/src/*/module.mk)
+-include $(patsubst %,$(TOP_DIR)/src/%/module.mk,$(MODULES))
 
 
 # EOF
diff --git a/builds/os2/os2-def.mk b/builds/os2/os2-def.mk
index 0e563ac..6ca739e 100644
--- a/builds/os2/os2-def.mk
+++ b/builds/os2/os2-def.mk
@@ -3,7 +3,7 @@
 #
 
 
-# Copyright 1996-2000, 2003, 2005 by
+# Copyright 1996-2000, 2003, 2005, 2006 by
 # David Turner, Robert Wilhelm, and Werner Lemberg.
 #
 # This file is part of the FreeType project, and may only be used, modified,
@@ -22,20 +22,6 @@
 #
 E := .exe
 
-# The directory where all object files are placed.
-#
-# This lets you build the library in your own directory with something like
-#
-#   set TOP_DIR=.../path/to/freetype2/top/dir...
-#   set OBJ_DIR=.../path/to/obj/dir
-#   make -f %TOP_DIR%/Makefile setup [options]
-#   make -f %TOP_DIR%/Makefile
-#
-ifndef OBJ_DIR
-  OBJ_DIR := $(TOP_DIR)/objs
-endif
-
-
 # The directory where all library files are placed.
 #
 # By default, this is the same as $(OBJ_DIR); however, this can be changed
diff --git a/builds/os2/os2-dev.mk b/builds/os2/os2-dev.mk
index 96890fa..bd12215 100644
--- a/builds/os2/os2-dev.mk
+++ b/builds/os2/os2-dev.mk
@@ -5,7 +5,7 @@
 #
 
 
-# Copyright 1996-2000, 2003 by
+# Copyright 1996-2000, 2003, 2006 by
 # David Turner, Robert Wilhelm, and Werner Lemberg.
 #
 # This file is part of the FreeType project, and may only be used, modified,
@@ -19,9 +19,12 @@
   TOP_DIR := .
 endif
 
-include $(TOP_DIR)/builds/os2/os2-def.mk
-BUILD_DIR := $(TOP_DIR)/devel
+DEVEL_DIR := $(TOP_DIR)/devel
 
+# include OS/2-specific definitions
+include $(TOP_DIR)/builds/os2/os2-def.mk
+
+# include gcc-specific definitions
 include $(TOP_DIR)/builds/compiler/gcc-dev.mk
 
 # include linking instructions
diff --git a/builds/toplevel.mk b/builds/toplevel.mk
index 6ee3818..4a6c9fc 100644
--- a/builds/toplevel.mk
+++ b/builds/toplevel.mk
@@ -3,7 +3,7 @@
 #
 
 
-# Copyright 1996-2000, 2001, 2003 by
+# Copyright 1996-2000, 2001, 2003, 2006 by
 # David Turner, Robert Wilhelm, and Werner Lemberg.
 #
 # This file is part of the FreeType project, and may only be used, modified,
@@ -36,6 +36,7 @@
 
 .PHONY: all setup distclean modules
 
+
 # The `space' variable is used to avoid trailing spaces in defining the
 # `T' variable later.
 #
@@ -43,6 +44,36 @@
 space := $(empty) $(empty)
 
 
+# The main configuration file, defining the `XXX_MODULES' variables.  We
+# prefer a `modules.cfg' file in OBJ_DIR over TOP_DIR.
+#
+ifndef MODULES_CFG
+  MODULES_CFG := $(TOP_DIR)/modules.cfg
+  ifneq ($(wildcard $(OBJ_DIR)/modules.cfg),)
+    MODULES_CFG := $(OBJ_DIR)/modules.cfg
+  endif
+endif
+
+
+# FTMODULE_H, as its name suggests, indicates where the FreeType module
+# classes resides.
+#
+ifndef FTMODULE_H
+  FTMODULE_H := $(OBJ_DIR)/ftmodule.h
+endif
+
+
+include $(MODULES_CFG)
+
+
+# The list of modules we are using.
+#
+MODULES := $(FONT_MODULES)    \
+           $(HINTING_MODULES) \
+           $(RASTER_MODULES)  \
+           $(AUX_MODULES)
+
+
 ifndef CONFIG_MK
   CONFIG_MK := config.mk
 endif
@@ -71,33 +102,17 @@
 #
 ifdef check_platform
 
-  # This is the first rule `make' sees.
-  #
-  all: setup
-
-  ifdef USE_MODULES
-    # If the module list $(MODULE_LIST) file is not present, generate it.
-    #
-    #modules: make_module_list setup
-  endif
+  all modules: setup
 
   include $(TOP_DIR)/builds/detect.mk
 
-  ifdef USE_MODULES
-    include $(TOP_DIR)/builds/modules.mk
-
-    ifeq ($(wildcard $(MODULE_LIST)),)
-      setup: make_module_list
-    endif
-  endif
-
   # This rule makes sense for Unix only to remove files created by a run
   # of the configure script which hasn't been successful (so that no
   # `config.mk' has been created).  It uses the built-in $(RM) command of
   # GNU make.  Similarly, `nul' is created if e.g. `make setup win32' has
   # been erroneously used.
   #
-  # note: This test is duplicated in "builds/toplevel.mk".
+  # Note: This test is duplicated in `builds/unix/detect.mk'.
   #
   is_unix := $(strip $(wildcard /sbin/init) \
                      $(wildcard /usr/sbin/init) \
@@ -126,14 +141,25 @@
   #
   all: single
 
-  ifdef USE_MODULES
-    modules: make_module_list
-  endif
-
   BUILD_PROJECT := yes
   include $(CONFIG_MK)
 
 endif # test check_platform
 
 
+# We always need the list of modules in ftmodule.h.
+#
+all setup: $(FTMODULE_H)
+
+
+# The `modules' target unconditionally rebuilds the module list.
+#
+modules:
+	$(FTMODULE_H_INIT)
+	$(FTMODULE_H_CREATE)
+	$(FTMODULE_H_DONE)
+
+include $(TOP_DIR)/builds/modules.mk
+
+
 # EOF
diff --git a/builds/unix/detect.mk b/builds/unix/detect.mk
index a0419dc..aafe352 100644
--- a/builds/unix/detect.mk
+++ b/builds/unix/detect.mk
@@ -3,7 +3,7 @@
 #
 
 
-# Copyright 1996-2000, 2002, 2003, 2004 by
+# Copyright 1996-2000, 2002, 2003, 2004, 2006 by
 # David Turner, Robert Wilhelm, and Werner Lemberg.
 #
 # This file is part of the FreeType project, and may only be used, modified,
@@ -66,22 +66,22 @@
       # platform).
       #
       CONFIG_FILE := unix.mk
-      setup: $(BUILD_DIR)/unix-def.mk
       unix: setup
+      must_configure := 1
       .PHONY: unix
     endif
   endif
 
-  setup: std_setup
+  have_Makefile := $(wildcard $(OBJ_DIR)/Makefile)
 
-  have_mk := $(strip $(wildcard $(OBJ_DIR)/Makefile))
-  ifneq ($(have_mk),)
-    # we are building FT2 not in the src tree
-    $(BUILD_DIR)/unix-def.mk: $(TOP_DIR)/builds/unix/unix-def.in
-	    $(TOP_DIR)/builds/unix/configure $(CFG)
-  else
-    $(BUILD_DIR)/unix-def.mk: $(TOP_DIR)/builds/unix/unix-def.in
-	    cd builds/unix; ./configure $(CFG)
+      setup: std_setup
+  ifdef must_configure
+    ifneq ($(have_Makefile),)
+      # we are building FT2 not in the src tree
+	      $(TOP_DIR)/builds/unix/configure $(CFG)
+    else
+	      cd builds/unix; ./configure $(CFG)
+    endif
   endif
 
 endif   # test PLATFORM unix
diff --git a/builds/unix/install.mk b/builds/unix/install.mk
index 54cfd74..668a806 100644
--- a/builds/unix/install.mk
+++ b/builds/unix/install.mk
@@ -3,7 +3,7 @@
 #
 
 
-# Copyright 1996-2000, 2002, 2003 by
+# Copyright 1996-2000, 2002, 2003, 2006 by
 # David Turner, Robert Wilhelm, and Werner Lemberg.
 #
 # This file is part of the FreeType project, and may only be used, modified,
@@ -24,17 +24,17 @@
 
 # Unix installation and deinstallation targets.
 #
-# note that we don't install internal headers since 2.2.0, and
-# we remove any 'internal' directory found in $(includedir)/freetype2/freetype
+# Note that we no longer install internal headers, and we remove any
+# `internal' subdirectory found in `$(includedir)/freetype2/freetype'.
 #
 install: $(PROJECT_LIBRARY)
-	$(MKINSTALLDIRS) $(DESTDIR)$(libdir)                                 \
-                         $(DESTDIR)$(libdir)/pkgconfig                       \
-                         $(DESTDIR)$(includedir)/freetype2/freetype/config   \
-                         $(DESTDIR)$(includedir)/freetype2/freetype/cache    \
-                         $(DESTDIR)$(bindir)                                 \
+	$(MKINSTALLDIRS) $(DESTDIR)$(libdir)                               \
+                         $(DESTDIR)$(libdir)/pkgconfig                     \
+                         $(DESTDIR)$(includedir)/freetype2/freetype/config \
+                         $(DESTDIR)$(includedir)/freetype2/freetype/cache  \
+                         $(DESTDIR)$(bindir)                               \
                          $(DESTDIR)$(datadir)/aclocal
-	$(LIBTOOL) --mode=install $(INSTALL) \
+	$(LIBTOOL) --mode=install $(INSTALL)                             \
                                   $(PROJECT_LIBRARY) $(DESTDIR)$(libdir)
 	-for P in $(PUBLIC_H) ; do                           \
           $(INSTALL_DATA)                                    \
@@ -52,8 +52,10 @@
 	-$(DELDIR) $(DESTDIR)$(includedir)/freetype2/freetype/internal
 	$(INSTALL_DATA) $(BUILD_DIR)/ft2unix.h \
           $(DESTDIR)$(includedir)/ft2build.h
-	$(INSTALL_DATA) $(OBJ_BUILD)/ftconfig.h \
+	$(INSTALL_DATA) $(OBJ_BUILD)/ftconfig.h                        \
           $(DESTDIR)$(includedir)/freetype2/freetype/config/ftconfig.h
+	$(INSTALL_DATA) $(OBJ_BUILD)/ftmodule.h                        \
+          $(DESTDIR)$(includedir)/freetype2/freetype/config/ftmodule.h
 	$(INSTALL_SCRIPT) -m 755 $(OBJ_BUILD)/freetype-config \
           $(DESTDIR)$(bindir)/freetype-config
 	$(INSTALL_SCRIPT) -m 644 $(BUILD_DIR)/freetype2.m4 \
diff --git a/builds/unix/unix-def.in b/builds/unix/unix-def.in
index c263e0e..801bdaa 100644
--- a/builds/unix/unix-def.in
+++ b/builds/unix/unix-def.in
@@ -3,7 +3,7 @@
 #
 
 
-# Copyright 1996-2000, 2002, 2004 by
+# Copyright 1996-2000, 2002, 2004, 2006 by
 # David Turner, Robert Wilhelm, and Werner Lemberg.
 #
 # This file is part of the FreeType project, and may only be used, modified,
@@ -13,9 +13,6 @@
 # fully.
 
 
-ifndef TOP_DIR
-  TOP_DIR := .
-endif
 TOP_DIR := $(shell cd $(TOP_DIR); pwd)
 
 DELETE    := @RMF@
@@ -61,20 +58,6 @@
 version_info := @version_info@
 
 
-# The directory where all object files are placed.
-#
-# This lets you build the library in your own directory with something like
-#
-#   set TOP_DIR=.../path/to/freetype2/top/dir...
-#   set OBJ_DIR=.../path/to/obj/dir
-#   make -f $TOP_DIR/Makefile setup [options]
-#   make -f $TOP_DIR/Makefile
-#
-ifndef OBJ_DIR
-  OBJ_DIR := $(shell cd $(TOP_DIR)/objs; pwd)
-endif
-
-
 # The directory where all library files are placed.
 #
 # By default, this is the same as $(OBJ_DIR); however, this can be changed
diff --git a/builds/unix/unix-dev.mk b/builds/unix/unix-dev.mk
index 12c641a..76bae38 100644
--- a/builds/unix/unix-dev.mk
+++ b/builds/unix/unix-dev.mk
@@ -6,7 +6,7 @@
 #
 
 
-# Copyright 1996-2000, 2003 by
+# Copyright 1996-2000, 2003, 2006 by
 # David Turner, Robert Wilhelm, and Werner Lemberg.
 #
 # This file is part of the FreeType project, and may only be used, modified,
@@ -16,9 +16,9 @@
 # fully.
 
 
-include $(TOP_DIR)/builds/unix/unixddef.mk
-BUILD_DIR := $(TOP_DIR)/devel
+DEVEL_DIR := $(TOP_DIR)/devel
 
+include $(TOP_DIR)/builds/unix/unixddef.mk
 include $(TOP_DIR)/builds/compiler/gcc-dev.mk
 include $(TOP_DIR)/builds/link_std.mk
 
diff --git a/builds/unix/unix.mk b/builds/unix/unix.mk
index c1555ac..7f9d9a3 100644
--- a/builds/unix/unix.mk
+++ b/builds/unix/unix.mk
@@ -3,7 +3,7 @@
 #
 
 
-# Copyright 1996-2000, 2002, 2004 by
+# Copyright 1996-2000, 2002, 2004, 2006 by
 # David Turner, Robert Wilhelm, and Werner Lemberg.
 #
 # This file is part of the FreeType project, and may only be used, modified,
@@ -16,14 +16,14 @@
 BUILD_DIR := $(TOP_DIR)/builds/unix
 PLATFORM  := unix
 
-have_mk := $(strip $(wildcard $(BUILD_DIR)/unix-def.mk))
+have_mk := $(wildcard $(OBJ_DIR)/unix-def.mk)
 ifneq ($(have_mk),)
-  include $(BUILD_DIR)/unix-def.mk
-  include $(BUILD_DIR)/unix-cc.mk
-else
-  # we are building FT2 not in the src tree
+  # We are building FreeType 2 not in the src tree.
   include $(OBJ_DIR)/unix-def.mk
   include $(OBJ_DIR)/unix-cc.mk
+else
+  include $(BUILD_DIR)/unix-def.mk
+  include $(BUILD_DIR)/unix-cc.mk
 endif
 
 ifdef BUILD_PROJECT
@@ -48,14 +48,15 @@
   #
   #   librarian library_file {list of object files}
   #
-  $(PROJECT_LIBRARY): $(OBJECTS_LIST)
-ifdef CLEAN_LIBRARY
-	  -$(CLEAN_LIBRARY) $(NO_OUTPUT)
-endif
-	  $(LINK_LIBRARY)
+    $(PROJECT_LIBRARY): $(OBJECTS_LIST)
+  ifdef CLEAN_LIBRARY
+	    -$(CLEAN_LIBRARY) $(NO_OUTPUT)
+  endif
+	    $(LINK_LIBRARY)
+
+  include $(TOP_DIR)/builds/unix/install.mk
 
 endif
 
-include $(TOP_DIR)/builds/unix/install.mk
 
 # EOF
diff --git a/builds/unix/unixddef.mk b/builds/unix/unixddef.mk
index 947673e..e26d61e 100644
--- a/builds/unix/unixddef.mk
+++ b/builds/unix/unixddef.mk
@@ -4,7 +4,7 @@
 #
 
 
-# Copyright 1996-2000, 2003 by
+# Copyright 1996-2000, 2003, 2006 by
 # David Turner, Robert Wilhelm, and Werner Lemberg.
 #
 # This file is part of the FreeType project, and may only be used, modified,
@@ -23,11 +23,7 @@
 SEP    := /
 
 # we use a special devel ftoption.h
-BUILD_DIR := $(TOP_DIR)/devel
-
-# do not set the platform to `unix', or libtool will trick you
-PLATFORM := unixdev
-
+DEVEL_DIR := $(TOP_DIR)/devel
 
 # The directory where all object files are placed.
 #
diff --git a/builds/win32/w32-bccd.mk b/builds/win32/w32-bccd.mk
index 2951999..51b15d9 100644
--- a/builds/win32/w32-bccd.mk
+++ b/builds/win32/w32-bccd.mk
@@ -3,7 +3,7 @@
 #
 
 
-# Copyright 1996-2000, 2003 by
+# Copyright 1996-2000, 2003, 2006 by
 # David Turner, Robert Wilhelm, and Werner Lemberg.
 #
 # This file is part of the FreeType project, and may only be used, modified,
@@ -13,8 +13,9 @@
 # fully.
 
 
+DEVEL_DIR := $(TOP_DIR)/devel
+
 include $(TOP_DIR)/builds/win32/win32-def.mk
-BUILD_DIR := $(TOP_DIR)/devel
 
 include $(TOP_DIR)/builds/compiler/bcc-dev.mk
 
diff --git a/builds/win32/w32-dev.mk b/builds/win32/w32-dev.mk
index 0b665de..bf3fe3a 100644
--- a/builds/win32/w32-dev.mk
+++ b/builds/win32/w32-dev.mk
@@ -5,7 +5,7 @@
 #
 
 
-# Copyright 1996-2000, 2003 by
+# Copyright 1996-2000, 2003, 2006 by
 # David Turner, Robert Wilhelm, and Werner Lemberg.
 #
 # This file is part of the FreeType project, and may only be used, modified,
@@ -23,8 +23,9 @@
   TOP_DIR := .
 endif
 
+DEVEL_DIR := $(TOP_DIR)/devel
+
 include $(TOP_DIR)/builds/win32/win32-def.mk
-BUILD_DIR := $(TOP_DIR)/devel
 
 include $(TOP_DIR)/builds/compiler/gcc-dev.mk
 
diff --git a/builds/win32/win32-def.mk b/builds/win32/win32-def.mk
index e402e74..87dc12a 100644
--- a/builds/win32/win32-def.mk
+++ b/builds/win32/win32-def.mk
@@ -3,7 +3,7 @@
 #
 
 
-# Copyright 1996-2000, 2003, 2005 by
+# Copyright 1996-2000, 2003, 2005, 2006 by
 # David Turner, Robert Wilhelm, and Werner Lemberg.
 #
 # This file is part of the FreeType project, and may only be used, modified,
@@ -22,19 +22,6 @@
 #
 E := .exe
 
-# The directory where all object files are placed.
-#
-# This lets you build the library in your own directory with something like
-#
-#   set TOP_DIR=.../path/to/freetype2/top/dir...
-#   set OBJ_DIR=.../path/to/obj/dir
-#   make -f %TOP_DIR%/Makefile setup [options]
-#   make -f %TOP_DIR%/Makefile
-#
-ifndef OBJ_DIR
-  OBJ_DIR := $(TOP_DIR)/objs
-endif
-
 
 # The directory where all library files are placed.
 #
diff --git a/configure b/configure
index 3f9c7b3..4921a30 100644
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# Copyright 2002, 2003, 2004, 2005 by
+# Copyright 2002, 2003, 2004, 2005, 2006 by
 # David Turner, Robert Wilhelm, and Werner Lemberg.
 #
 # This file is part of the FreeType project, and may only be used, modified,
@@ -30,7 +30,8 @@
   fi
 fi
 
-# Uh, oh.  This is taken from autoconf.  They know what they are doing...
+# Get `dirname' functionality.  This is taken and adapted from autoconf's
+# m4sh.m4 (_AS_EXPR_PREPARE, AS_DIRNAME_EXPR, and AS_DIRNAME_SED).
 
 if expr a : '\(a\)' >/dev/null 2>&1; then
   ft_expr=expr
@@ -38,18 +39,30 @@
   ft_expr=false
 fi
 
-ft2_dir=`(dirname "$0") 2>/dev/null ||
-$ft_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-         X"$0" : 'X\(//\)[^/]' \| \
-         X"$0" : 'X\(//\)$' \| \
-         X"$0" : 'X\(/\)' \| \
-         .     : '\(.\)' 2>/dev/null ||
-echo X"$0" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
-         /^X\(\/\/\)[^/].*/{ s//\1/; q; }
-         /^X\(\/\/\)$/{ s//\1/; q; }
-         /^X\(\/\).*/{ s//\1/; q; }
-         s/.*/./; q'`
+ft2_dir=`(dirname "$0") 2>/dev/null                         ||
+         $ft_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+                  X"$0" : 'X\(//\)[^/]' \| \
+                  X"$0" : 'X\(//\)$' \| \
+                  X"$0" : 'X\(/\)' \| \
+                  .     : '\(.\)' 2>/dev/null               ||
+         echo X"$0" |
+           sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+                  s//\1/
+                  q
+                }
+                /^X\(\/\/\)[^/].*/{
+                  s//\1/
+                  q
+                }
+                /^X\(\/\/\)$/{
+                  s//\1/
+                  q
+                }
+                /^X\(\/\).*/{
+                  s//\1/
+                  q
+                }
+                s/.*/./; q'`
 
 abs_curr_dir=`pwd`
 abs_ft2_dir=`cd "$ft2_dir" && pwd`
@@ -58,6 +71,9 @@
 
 if test "$abs_curr_dir" != "$abs_ft2_dir"; then
   mkdir reference
+  echo "Copying \`modules.cfg'"
+  cp $abs_ft2_dir/modules.cfg $abs_curr_dir
+  echo "Generating \`Makefile'"
   echo "TOP_DIR   := $abs_ft2_dir"               > Makefile
   echo "OBJ_DIR   := $abs_curr_dir"             >> Makefile
   echo "OBJ_BUILD := \$(OBJ_DIR)"               >> Makefile
diff --git a/docs/CHANGES b/docs/CHANGES
index fb55d89..4b35f44 100644
--- a/docs/CHANGES
+++ b/docs/CHANGES
@@ -15,6 +15,14 @@
 
   II. IMPORTANT CHANGES
 
+    - FreeType's build  mechanism has been redesigned.   With GNU make
+      it  is  now  sufficient  in   most  cases  to  edit  two  files:
+      `modules.cfg',  to  select   the  library  components,  and  the
+      configuration  file  `include/freetype/config/ftoption.h' (which
+      can be copied to the objects directory).  Removing unused module
+      directories   to    prevent   its   compilation    and   editing
+      `include/freetype/config/ftmodule.h' is no longer necessary.
+
     - The  LIGHT  hinting algorithm  produces  more pleasant  results.
       Also, using the  FT_LOAD_TARGET_LIGHT flags within FT_Load_Glyph
       always forces auto-hinting, as a special exception.
diff --git a/docs/CUSTOMIZE b/docs/CUSTOMIZE
index e1b3c06..0fe3f47 100644
--- a/docs/CUSTOMIZE
+++ b/docs/CUSTOMIZE
@@ -1,56 +1,55 @@
 How to customize the compilation of the library
 ===============================================
 
-  FreeType  is  highly  customizable  to  fit various  needs,  and  this
-  document describes how it is possible to select options and components
-  at compilation time.
+  FreeType  is highly  customizable  to fit  various  needs, and  this
+  document  describes  how  it  is  possible  to  select  options  and
+  components at compilation time.
 
 
 I. Configuration macros
 
-  The file found in `include/freetype/config/ftoption.h' contains a list
-  of commented configuration macros that can be toggled by developers to
-  indicate which features should be active while building the library.
+  The  file found  in `include/freetype/config/ftoption.h'  contains a
+  list  of  commented configuration  macros  that  can  be toggled  by
+  developers  to  indicate  which  features  should  be  active  while
+  building the library.
   
-  These  options  range from  debug  level  to  availability of  certain
-  features, like native TrueType hinting through a bytecode interpreter.
+  These  options range  from debug  level to  availability  of certain
+  features,   like  native   TrueType  hinting   through   a  bytecode
+  interpreter.
   
-  We invite you to read this  file for more information.  You can change
-  the file's content to suit your  needs, or override it with one of the
-  techniques described below.
+  We  invite you  to read  this file  for more  information.   You can
+  change the  file's content to suit  your needs, or  override it with
+  one of the techniques described below.
 
   
 II. Modules list
 
-  The file found in `include/freetype/config/ftmodule.h' contains a list
-  of  names  corresponding  to  the  modules  and  font  drivers  to  be
-  statically compiled in the FreeType library during the build.
+  If you  use GNU make  please edit the top-level  file `modules.cfg'.
+  It contains a  list of available FreeType modules  and extensions to
+  be compiled.  Change it to suit your own preferences.  Be aware that
+  certain modules  depend on  others, as described  in the  file.  GNU
+  make  uses `modules.cfg'  to  generate `ftmodule.h'  (in the  object
+  directory).
 
-  You can change it to suit your own preferences.  Be aware that certain
-  modules depend  on others, as  described by the file  `modules.txt' in
-  this directory.
-
-  You can modify  the file's content to suit your  needs, or override it
-  at compile time with one of the methods described below.
-
-  Note that  you also  have to  rename the various  `*.mk' files  in the
-  module directories  which you  want to exclude  so that  the extension
-  isn't `.mk'  -- GNU make uses  a simple globbing  mechanism to include
-  all those files.
+  If  you don't  use  GNU make  you  have to  manually  edit the  file
+  `include/freetype/config/ftmodule.h'  (which is  *not* used  with if
+  compiled with GNU make) to  add or remove the drivers and components
+  you want  to compile into  the library.  See `INSTALL.ANY'  for more
+  information.
 
 
 III. System interface
 
-  FreeType's default interface to the  system (i.e., the parts that deal
-  with   memory   management   and    i/o   streams)   is   located   in
+  FreeType's  default interface to  the system  (i.e., the  parts that
+  deal  with  memory  management   and  i/o  streams)  is  located  in
   `src/base/ftsystem.c'.
   
-  The  current implementation uses  standard C  library calls  to manage
-  memory and to read font files.  It is however possible to write custom
-  implementations to suit specific systems.
+  The current  implementation uses standard C library  calls to manage
+  memory  and to read  font files.   It is  however possible  to write
+  custom implementations to suit specific systems.
 
-  To  tell  the GNU  Make-based  build system  to  use  a custom  system
-  interface, you  have to define  the environment variable  FTSYS_SRC to
+  To  tell the  GNU Make-based  build system  to use  a  custom system
+  interface, you have to  define the environment variable FTSYS_SRC to
   point to the relevant implementation:
   
     on Unix:
@@ -69,21 +68,31 @@
      
 IV. Overriding default configuration and module headers
 
-  It  is  possible to  override  the  default  configuration and  module
-  headers without changing the original files.  There are two ways to do
-  that:
+  It  is possible  to override  the default  configuration  and module
+  headers without  changing the original files.  There  are three ways
+  to do that:
 
 
-  1. Using the C include path
+  1. With GNU make
+
+    [This is actually a combination of method 2 and 3.]
+
+    Just put your custom  `ftoption.h' file into the objects directory
+    (normally  `<topdir>/objs'),  which  GNU  make  prefers  over  the
+    standard location.   No action is needed  for `ftmodule.h' because
+    it is generated automatically in the objects directory.
+
+
+  2. Using the C include path
   
-    Use the C include path to ensure that your own versions of the files
-    are used at compile time when the lines
+    Use the  C include path  to ensure that  your own versions  of the
+    files are used at compile time when the lines
     
       #include FT_CONFIG_OPTIONS_H
       #include FT_CONFIG_MODULES_H
 
-    are       compiled.       Their      default       values      being
-    <freetype/config/ftoption.h>  and  <freetype/config/ftmodule.h>, you
+    are      compiled.       Their      default      values      being
+    <freetype/config/ftoption.h> and <freetype/config/ftmodule.h>, you
     can do something like:
 
       custom/
@@ -96,14 +105,14 @@
         freetype/
           ...
 
-    then change the  C include path to always give  the path to `custom'
+    then change the C include path to always give the path to `custom'
     before the FreeType 2 `include'.
 
 
-  2. Redefining FT_CONFIG_OPTIONS_H and FT_CONFIG_MODULES_H
+  3. Redefining FT_CONFIG_OPTIONS_H and FT_CONFIG_MODULES_H
   
-    Another way to  do the same thing is to redefine  the macros used to
-    name  the  configuration headers.   To  do  so,  you need  a  custom
+    Another way to do the same thing is to redefine the macros used to
+    name  the configuration  headers.  To  do  so, you  need a  custom
     `ft2build.h' whose content can be as simple as:
    
       #ifndef __FT2_BUILD_MY_PLATFORM_H__
@@ -123,19 +132,19 @@
         my-ftoption.h        => custom options header
         my-ftmodule.h        => custom modules list header
 
-    and  change the C  include path  to ensure  that `custom'  is always
+    and change  the C include path  to ensure that  `custom' is always
     placed before the FT2 `include' during compilation.
 
-------------------------------------------------------------------------
+----------------------------------------------------------------------
 
-Copyright 2003, 2005 by
+Copyright 2003, 2005, 2006 by
 David Turner, Robert Wilhelm, and Werner Lemberg.
 
-This  file is  part  of the  FreeType  project, and  may  only be  used,
-modified,  and  distributed under  the  terms  of  the FreeType  project
-license, LICENSE.TXT.  By continuing  to use, modify, or distribute this
-file  you indicate that  you have  read the  license and  understand and
-accept it fully.
+This  file is  part of  the FreeType  project, and  may only  be used,
+modified,  and distributed  under the  terms of  the  FreeType project
+license,  LICENSE.TXT.  By  continuing to  use, modify,  or distribute
+this file you  indicate that you have read  the license and understand
+and accept it fully.
 
 
 --- end of CUSTOMIZE ---
diff --git a/docs/INSTALL b/docs/INSTALL
index d53cafa..98ca4c4 100644
--- a/docs/INSTALL
+++ b/docs/INSTALL
@@ -1,6 +1,6 @@
 
-There are several ways to  build the FreeType library, depending on your
-system  and  the level  of  customization you  need.   Here  is a  short
+There are  several ways  to build the  FreeType library,  depending on
+your system and the level of  customization you need.  Here is a short
 overview of the documentation available:
 
 
@@ -9,15 +9,16 @@
 
   1. Native TrueType Hinting
 
-    Native TrueType  hinting is disabled  by default[1].  If  you really
+    Native TrueType hinting is  disabled by default[1].  If you really
     need it, read the file `TRUETYPE' for information.
 
 
   2. Unix Systems (as well as Cygwin or MSys on Windows)
 
-    Please  read *both*  `UPGRADE.UNX' and  `INSTALL.UNX' to  install or
-    upgrade FreeType 2 on a Unix system.  Note that you *need* GNU Make,
-    since other make tools won't work (this includes BSD Make).
+    Please read  *both* `UPGRADE.UNX' and `INSTALL.UNX'  to install or
+    upgrade FreeType  2 on  a Unix system.   Note that you  *need* GNU
+    Make for automatic compilation,  since other make tools won't work
+    (this includes BSD Make).
 
 
   3. On VMS with the `mms' build tool
@@ -27,61 +28,62 @@
 
   4. Other systems using GNU Make
   
-    On non-Unix platforms, it is possible to build the library using GNU
-    Make utility.   Note that *NO  OTHER MAKE TOOL WILL  WORK*[2]!  This
-    methods  supports  several compilers  on  Windows,  OS/2, and  BeOS,
-    including MinGW, Visual C++, Borland C++, and more.
+    On non-Unix platforms,  it is possible to build  the library using
+    GNU Make  utility.  Note that  *NO OTHER MAKE TOOL  WILL WORK*[2]!
+    This  methods supports  several  compilers on  Windows, OS/2,  and
+    BeOS, including MinGW, Visual C++, Borland C++, and more.
 
     Instructions are provided in the file `INSTALL.GNU'.
 
 
   5. With an IDE Project File (e.g., for Visual Studio or CodeWarrior)
   
-    We provide  a small  number of `project  files' for various  IDEs to
-    automatically build the library as  well.  Note that these files are
-    not   supported  and  only   sporadically  maintained   by  FreeType
+    We provide a  small number of `project files'  for various IDEs to
+    automatically build  the library as  well.  Note that  these files
+    are  not supported  and only  sporadically maintained  by FreeType
     developers, so don't expect them to work in each release.
     
-    To find  them, have a look  at the content  of the `builds/<system>'
+    To find them, have a  look at the content of the `builds/<system>'
     directory, where <system> stands for your OS or environment.
 
 
   6. From you own IDE, or own Makefiles
   
-    If you want to create your own project file, follow the instructions
-    given in the `INSTALL.ANY' document of this directory.
+    If  you  want  to  create   your  own  project  file,  follow  the
+    instructions   given  in  the   `INSTALL.ANY'  document   of  this
+    directory.
 
 
 II. Custom builds of the library
 ================================
 
-  Customizing the  compilation of  FreeType is easy,  and allows  you to
-  select only  the components of the  font engine that  you really need.
+  Customizing the compilation  of FreeType is easy, and  allows you to
+  select only the components of  the font engine that you really need.
   For more details read the file `CUSTOMIZE'.
 
 
-------------------------------------------------------------------------
+----------------------------------------------------------------------
 
 [1] More details on:  http://www.freetype.org/patents.html
 
-[2] make++, a  make tool written in Perl, has  sufficient support of GNU
+[2] make++, a make tool written in Perl, has sufficient support of GNU
     make extensions to build FreeType.  See
 
       http://makepp.sourceforge.net
 
-    for more information;  you need version 1.19 or  newer, and you must
+    for more information; you need version 1.19 or newer, and you must
     pass option `--norc-substitution'.
 
-------------------------------------------------------------------------
+----------------------------------------------------------------------
 
-Copyright 2000, 2001, 2002, 2003, 2004, 2005 by
+Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006 by
 David Turner, Robert Wilhelm, and Werner Lemberg.
 
-This  file is  part  of the  FreeType  project, and  may  only be  used,
-modified,  and  distributed under  the  terms  of  the FreeType  project
-license, LICENSE.TXT.  By continuing  to use, modify, or distribute this
-file  you indicate that  you have  read the  license and  understand and
-accept it fully.
+This  file is  part of  the FreeType  project, and  may only  be used,
+modified,  and distributed  under the  terms of  the  FreeType project
+license,  LICENSE.TXT.  By  continuing to  use, modify,  or distribute
+this file you  indicate that you have read  the license and understand
+and accept it fully.
 
 
 --- end of INSTALL ---
diff --git a/docs/INSTALL.ANY b/docs/INSTALL.ANY
index 09d0d10..fd882cd 100644
--- a/docs/INSTALL.ANY
+++ b/docs/INSTALL.ANY
@@ -1,29 +1,29 @@
 Instructions on how to build FreeType with your own build tool
 ==============================================================
 
-See the file `CUSTOMIZE' to  learn how to customize FreeType to specific
-environments.
+See  the  file `CUSTOMIZE'  to  learn  how  to customize  FreeType  to
+specific environments.
 
 
 I. Standard procedure
 ---------------------
 
-  * DISABLE  PRE-COMPILED HEADERS!   This is  very important  for Visual
+  * DISABLE PRE-COMPILED  HEADERS!  This is very  important for Visual
     C++, because FreeType uses lines like:
     
       #include FT_FREETYPE_H
     
-    which are not correctly supported by this compiler while being ISO C
-    compliant!
+    which are not correctly supported by this compiler while being ISO
+    C compliant!
 
-  * You need to add  the directories `freetype2/include' to your include
-    path when compiling the library.
+  * You  need  to  add  the directories  `freetype2/include'  to  your
+    include path when compiling the library.
 
-  * FreeType 2 is made of several components; each of them is located in
-    a     subdirectory     of     `freetype2/src'.      For     example,
+  * FreeType 2 is made of  several components; each of them is located
+    in    a   subdirectory    of   `freetype2/src'.     For   example,
     `freetype2/src/truetype/' contains the TrueType font driver.
 
-  * DO NOT COMPILE ALL C FILES!  Rather, compile the following ones:
+  * DO NOT COMPILE ALL C FILES!  Rather, compile the following ones.
 
     -- base components (required)
 
@@ -63,7 +63,8 @@
       src/type42/type42.c     -- Type 42 font driver
       src/winfonts/winfnt.c   -- Windows FONT / FNT font driver
 
-    -- rasterizers (optional; at least one is needed for vector formats)
+    -- rasterizers (optional; at least one is needed for
+       vector formats)
 
       src/raster/raster.c     -- monochrome rasterizer
       src/smooth/smooth.c     -- anti-aliasing rasterizer
@@ -90,17 +91,19 @@
       `type42.c'   needs `truetype.c'
 
 
-  Read the file `CUSTOMIZE' in case you want to compile only a subset of
-  the drivers, renderers, and optional modules.
+  Read the file `CUSTOMIZE' in case  you want to compile only a subset
+  of  the  drivers,  renderers,   and  optional  modules;  a  detailed
+  description of the various base  extension is given in the top-level
+  file `modules.cfg'.
 
-  You are done.   In case of problems, see the  archives of the FreeType
+  You are done.  In case of problems, see the archives of the FreeType
   development mailing list.
 
 
 II. Support for flat-directory compilation
 ------------------------------------------
 
-  It  is possible  to put  all  FreeType 2  source files  into a  single
+  It is  possible to  put all  FreeType 2 source  files into  a single
   directory, with the *exception* of the `include' hierarchy.
 
   1. Copy all files in current directory
@@ -118,19 +121,19 @@
       cc -c -Ifreetype2/include ftbase.c
       etc.
 
-    You don't need to define  the FT_FLAT_COMPILATION macro (as this was
-    required in previous releases of FreeType 2).
+    You don't  need to define  the FT_FLAT_COMPILATION macro  (as this
+    was required in previous releases of FreeType 2).
 
-------------------------------------------------------------------------
+----------------------------------------------------------------------
 
 Copyright 2003, 2005, 2006 by
 David Turner, Robert Wilhelm, and Werner Lemberg.
 
-This  file is  part  of the  FreeType  project, and  may  only be  used,
-modified,  and  distributed under  the  terms  of  the FreeType  project
-license, LICENSE.TXT.  By continuing  to use, modify, or distribute this
-file  you indicate that  you have  read the  license and  understand and
-accept it fully.
+This  file is  part of  the FreeType  project, and  may only  be used,
+modified,  and distributed  under the  terms of  the  FreeType project
+license,  LICENSE.TXT.  By  continuing to  use, modify,  or distribute
+this file you  indicate that you have read  the license and understand
+and accept it fully.
 
 
 --- end of INSTALL.ANY ---
diff --git a/docs/INSTALL.GNU b/docs/INSTALL.GNU
index 096b4b5..3859eee 100644
--- a/docs/INSTALL.GNU
+++ b/docs/INSTALL.GNU
@@ -1,34 +1,34 @@
-This document contains instructions how to build the FreeType library on
-non-Unix  systems with  the help  of  GNU Make.   Note that  if you  are
-running Cygwin or MSys in Windows, you should follow the instructions in
-the file INSTALL.UNX instead.
+This document contains instructions  how to build the FreeType library
+on non-Unix systems  with the help of GNU Make.  Note  that if you are
+running Cygwin or MSys in  Windows, you should follow the instructions
+in the file INSTALL.UNX instead.
 
 
-  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:
+  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.
 
   1. Install GNU Make
   -------------------
 
-    Because GNU Make is the only Make tool supported to compile FreeType
-    2, you should install it on your machine.
+    Because  GNU Make  is  the  only Make  tool  supported to  compile
+    FreeType 2, you should install it on your machine.
 
-    The FreeType 2  build system relies on many  features special to GNU
+    The FreeType 2 build system relies on many features special to GNU
     Make.
 
-    NEARLY ALL  OTHER MAKE TOOLS  FAIL, INCLUDING `BSD MAKE',  SO REALLY
+    NEARLY ALL OTHER MAKE TOOLS  FAIL, INCLUDING `BSD MAKE', SO REALLY
     INSTALL A RECENT VERSION OF GNU MAKE ON YOUR SYSTEM!
 
-    Note  that make++,  a make  tool  written in  Perl, supports  enough
+    Note that  make++, a  make tool written  in Perl,  supports enough
     features of GNU make to compile FreeType.  See
     
       http://makepp.sourceforge.net
 
-    for more information;  you need version 1.19 or  newer, and you must
+    for more information; you need version 1.19 or newer, and you must
     pass option `--norc-substitution'.
 
-    Make sure that  you are invoking GNU Make from  the command line, by
+    Make sure that you are invoking GNU Make from the command line, by
     typing something like:
 
       make -v
@@ -41,10 +41,10 @@
   2. Invoke `make'
   ----------------
 
-    Go to the root directory of  FreeType 2, 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:
+    Go to  the root  directory of FreeType  2, 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.
 
 
       ==============================================================
@@ -54,8 +54,8 @@
 
         platform                     win32
         compiler                     gcc
-        configuration directory      ./builds/win32
-        configuration rules          ./builds/win32/w32-gcc.mk
+        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
@@ -67,33 +67,33 @@
       =============================================================
 
 
-    If the  detected settings correspond to your  platform and compiler,
-    skip to step  5.  Note that if your platform  is completely alien to
+    If the detected settings correspond to your platform and compiler,
+    skip to step 5.  Note that if your platform is completely alien to
     the build system, the detected platform will be `ansi'.
 
 
   3. 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), invoke  GNU Make
+    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), invoke GNU Make
     with
 
       make setup <compiler>
 
     Examples:
 
-      to use Visual C++ on Win32, type:  "make setup visualc"
-      to use Borland C++ on Win32, type  "make setup bcc32"
-      to use Watcom C++ on Win32, type   "make setup watcom"
-      to use Intel C++ on Win32, type    "make setup intelc"
-      to use LCC-Win32 on Win32, type:   "make setup lcc"
-      to use Watcom C++ on OS/2, type    "make setup watcom"
-      to use VisualAge C++ on OS/2, type "make setup visualage"
+      to use Visual C++ on Win32, type:  `make setup visualc'
+      to use Borland C++ on Win32, type  `make setup bcc32'
+      to use Watcom C++ on Win32, type   `make setup watcom'
+      to use Intel C++ on Win32, type    `make setup intelc'
+      to use LCC-Win32 on Win32, type:   `make setup lcc'
+      to use Watcom C++ on OS/2, type    `make setup watcom'
+      to use VisualAge C++ on OS/2, type `make setup visualage'
 
-    The  <compiler> name  to  use is  platform-dependent.   The list  of
-    available  compilers  for  your  system  is available  in  the  file
+    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'.
 
     If you  are satisfied  by the new  configuration summary,  skip to
@@ -103,53 +103,57 @@
   4. Configure the build system for an unknown platform/compiler
   --------------------------------------------------------------
 
-    The auto-detection/setup phase of the  build system copies a file to
-    the current directory under the name `config.mk'.
+    The auto-detection/setup  phase of the build system  copies a file
+    to the current directory under the name `config.mk'.
 
-    For    example,    on     OS/2+gcc,    it    would    simply    copy
+    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, copy
-    manually the  configuration sub-makefile to `./config.mk'  and go to
+    If for  some reason your  platform isn't correctly  detected, copy
+    manually the configuration sub-makefile to `./config.mk' and go to
     step 5.
 
-    Note that this file is a sub-Makefile used to specify Make variables
-    for compiler and linker invocation 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'.
+    Note  that  this file  is  a  sub-Makefile  used to  specify  Make
+    variables  for compiler  and linker  invocation 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'.
 
 
   5. 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.
+    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.  [It has also generated a file called
+    `ftmodule.h'   in  the  objects   directory  (which   is  normally
+    `<toplevel>/objs/');  please read  the  file `docs/CUSTOMIZE'  for
+    customization of FreeType.]
 
-    To launch the build, simply  invoke GNU Make again: The top Makefile
-    will detect the configuration file and run the build with it.
+    To  launch  the build,  simply  invoke  GNU  Make again:  The  top
+    Makefile will detect the configuration file and run the build with
+    it.
 
 
   Final note
   
-    The  build system  builds a  statically linked  library of  the font
-    engine in the `objs' directory.   It does _not_ support the build of
-    DLLs on Windows and OS/2.  If you need these, you have to either use
-    an  IDE-specific  project  file,   or  follow  the  instructions  in
-    `INSTALL.ANY' to create your own Makefiles.
+    The build  system builds a  statically linked library of  the font
+    engine in the  `objs' directory.  It does _not_  support the build
+    of  DLLs on  Windows and  OS/2.  If  you need  these, you  have to
+    either   use  an   IDE-specific  project   file,  or   follow  the
+    instructions in `INSTALL.ANY' to create your own Makefiles.
 
-------------------------------------------------------------------------
+----------------------------------------------------------------------
 
-Copyright 2003, 2004, 2005 by
+Copyright 2003, 2004, 2005, 2006 by
 David Turner, Robert Wilhelm, and Werner Lemberg.
 
-This  file is  part  of the  FreeType  project, and  may  only be  used,
-modified,  and  distributed under  the  terms  of  the FreeType  project
-license, LICENSE.TXT.  By continuing  to use, modify, or distribute this
-file  you indicate that  you have  read the  license and  understand and
-accept it fully.
+This  file is  part of  the FreeType  project, and  may only  be used,
+modified,  and distributed  under the  terms of  the  FreeType project
+license,  LICENSE.TXT.  By  continuing to  use, modify,  or distribute
+this file you  indicate that you have read  the license and understand
+and accept it fully.
 
 
 --- end of INSTALL.GNU ---
diff --git a/docs/INSTALL.UNX b/docs/INSTALL.UNX
index f6deea8..13cb896 100644
--- a/docs/INSTALL.UNX
+++ b/docs/INSTALL.UNX
@@ -1,62 +1,62 @@
-This document contains instructions on how to build the FreeType library
-on Unix systems.  This also works  for emulations like Cygwin or MSys on
-Win32:
+This  document contains  instructions  on how  to  build the  FreeType
+library on Unix  systems.  This also works for  emulations like Cygwin
+or MSys on Win32:
 
 
   1. Ensure that you are using GNU Make
   -------------------------------------
 
-    The FreeType  build system _exclusively_  works with GNU  Make.  You
-    will not be able to  compile the library with the instructions below
-    using any other alternative (including BSD Make).
+    The FreeType build system  _exclusively_ works with GNU Make.  You
+    will  not be  able to  compile the  library with  the instructions
+    below using any other alternative (including BSD Make).
 
-    [Well, this is not  really correct.  Recently, a perl implementation
-    of make called `makepp' has appeared which can also build FreeType 2
-    successfully on Unix platforms.  See
+    [Well,  this  is not  really  correct.  A  few  years  ago a  perl
+    implementation of make called `makepp' has appeared which can also
+    build FreeType 2 successfully on Unix platforms.  See
 
       http://makepp.sourceforge.net
 
-    for more details; you need version  1.19 or newer, and you must pass
-    option `--norc-substitution'.]
+    for more  details; you  need version 1.19  or newer, and  you must
+    pass option `--norc-substitution'.]
 
-    Trying to compile the library  with a different Make tool will print
-    a message like:
+    Trying  to compile  the library  with a  different Make  tool will
+    print a message like:
 
       Sorry, GNU make is required to build FreeType2.
 
-    and the build process will be aborted.  If this happens, install GNU
-    Make on  your system,  and use the  GNUMAKE environment  variable to
-    name it.
+    and the build  process will be aborted.  If  this happens, install
+    GNU Make on your system,  and use the GNUMAKE environment variable
+    to name it, if necessary.
 
 
   2. Build and install the library
   --------------------------------
 
-    The  following should  work on  all  Unix systems  where the  `make'
+    The following  should work  on all Unix  systems where  the `make'
     command invokes GNU Make:
 
       ./configure [options]
       make
       make install           (as root)
 
-    The default  installation path is  `/usr/local'.  It can  be changed
+    The default installation path  is `/usr/local'.  It can be changed
     with the `--prefix=<path>' option.  Example:
 
       ./configure --prefix=/usr
 
-    When using a  different command to invoke GNU  Make, use the GNUMAKE
-    variable.  For  example, if  `gmake' is the  command to use  on your
+    When using a different command to invoke GNU Make, use the GNUMAKE
+    variable.  For example,  if `gmake' is the command  to use on your
     system, do something like:
 
        GNUMAKE=gmake ./configure [options]
        gmake
        gmake install            (as root)
 
-    If this still doesn't work, there must be a problem with your system
-    (e.g., you are using a very old version of GNU Make).
+    If  this still doesn't  work, there  must be  a problem  with your
+    system (e.g., you are using a very old version of GNU Make).
 
-    It  is  possible  to  compile  FreeType in  a  different  directory.
-    Assuming the  FreeType source  files in directory  `/src/freetype' a
+    It  is possible  to  compile FreeType  in  a different  directory.
+    Assuming the FreeType source  files in directory `/src/freetype' a
     compilation in directory `foo' works as follows:
 
       cd foo
@@ -64,16 +64,16 @@
       make
       make install
 
-------------------------------------------------------------------------
+----------------------------------------------------------------------
 
-Copyright 2003, 2004, 2005 by
+Copyright 2003, 2004, 2005, 2006 by
 David Turner, Robert Wilhelm, and Werner Lemberg.
 
-This  file is  part  of the  FreeType  project, and  may  only be  used,
-modified,  and  distributed under  the  terms  of  the FreeType  project
-license, LICENSE.TXT.  By continuing  to use, modify, or distribute this
-file  you indicate that  you have  read the  license and  understand and
-accept it fully.
+This  file is  part of  the FreeType  project, and  may only  be used,
+modified,  and distributed  under the  terms of  the  FreeType project
+license,  LICENSE.TXT.  By  continuing to  use, modify,  or distribute
+this file you  indicate that you have read  the license and understand
+and accept it fully.
 
 
 --- end of INSTALL.UNX ---
diff --git a/docs/modules.txt b/docs/modules.txt
deleted file mode 100644
index e1a8cfd..0000000
--- a/docs/modules.txt
+++ /dev/null
@@ -1,28 +0,0 @@
-This file shows the interdependencies of various FreeType modules.
-
-Note that the use of `psnames' can be controlled in ftconfig.h
-(FT_CONFIG_OPTION_POSTSCRIPT_NAMES).
-
-  module       dependency
- ---------------------------------------
-  cff          sfnt, pshinter, psnames
-  cid          psaux, pshinter, psnames
-  truetype     sfnt
-  type1        psaux, pshinter, psnames
-  type42       truetype
-  psaux        psnames
-  sfnt         psnames
-
-------------------------------------------------------------------------
-
-Copyright 2001, 2002 by
-David Turner, Robert Wilhelm, and Werner Lemberg.
-
-This  file  is  part  of the  FreeType  project, and may  only be  used,
-modified,  and  distributed  under  the  terms of  the FreeType  project
-license, LICENSE.TXT.   By continuing to use, modify, or distribute this
-file you  indicate that  you have  read the  license and understand  and
-accept it fully.
-
-
---- end of modules.txt ---
diff --git a/include/freetype/config/ftmodule.h b/include/freetype/config/ftmodule.h
index f9694b8..d92b0ee 100644
--- a/include/freetype/config/ftmodule.h
+++ b/include/freetype/config/ftmodule.h
@@ -1,3 +1,15 @@
+/*
+ *  This file registers the FreeType modules compiled into the library.
+ *
+ *  If you use GNU make, this file IS NOT USED!  Instead, it is created in
+ *  the objects directory (normally `<topdir>/objs/') based on information
+ *  from `<topdir>/modules.cfg'.
+ *
+ *  Please read `docs/INSTALL.ANY' and `docs/CUSTOMIZE' how to compile
+ *  FreeType without GNU make.
+ *
+ */
+
 FT_USE_MODULE(autofit_module_class)
 FT_USE_MODULE(tt_driver_class)
 FT_USE_MODULE(t1_driver_class)
@@ -16,3 +28,5 @@
 FT_USE_MODULE(ft_smooth_lcd_renderer_class)
 FT_USE_MODULE(ft_smooth_lcdv_renderer_class)
 FT_USE_MODULE(bdf_driver_class)
+
+/* EOF */
diff --git a/include/freetype/internal/ftmemory.h b/include/freetype/internal/ftmemory.h
index 8543642..40703d5 100644
--- a/include/freetype/internal/ftmemory.h
+++ b/include/freetype/internal/ftmemory.h
@@ -108,7 +108,6 @@
   FT_BASE( FT_Pointer )
   FT_QAlloc_Debug( FT_Memory    memory,
                    FT_Long      size,
-                   void*        P,
                    FT_Error    *p_error,
                    const char*  file_name,
                    FT_Long      line_no );
@@ -133,7 +132,7 @@
 
   FT_BASE( void )
   FT_Free_Debug( FT_Memory    memory,
-                 FT_Pointer   block,
+                 const void  *P,
                  const char*  file_name,
                  FT_Long      line_no );
 
diff --git a/modules.cfg b/modules.cfg
new file mode 100644
index 0000000..f251fd8
--- /dev/null
+++ b/modules.cfg
@@ -0,0 +1,227 @@
+# modules.cfg
+#
+# Copyright 2005 by
+# David Turner, Robert Wilhelm, and Werner Lemberg.
+#
+# This file is part of the FreeType project, and may only be used, modified,
+# and distributed under the terms of the FreeType project license,
+# LICENSE.TXT.  By continuing to use, modify, or distribute this file you
+# indicate that you have read the license and understand and accept it
+# fully.
+#
+#
+# In case you compile the FreeType library with GNU make or makepp, this
+# file controls which components are built into the library.  Otherwise,
+# please read this file for information on the various modules and its
+# dependencies, then follow the instructions in the file `docs/INSTALL.ANY'.
+#
+# To deactivate a module, simply comment out the corresponding line.  To
+# activate a module, remove the comment character.
+#
+# Note that many modules and components are further controlled with macros
+# in the file `include/freetype/config/ftoption.h'.
+
+
+####
+#### font modules -- at least one is required
+####
+####   The order given here (from top to down) is the order used for testing
+####   font formats in the compiled library.
+####
+
+# TrueType font driver.
+#
+# This driver needs the `sfnt' module.
+FONT_MODULES += truetype
+
+# PostScript Type 1 font driver.
+#
+# This driver needs the `psaux', `pshinter', and `psnames' modules.
+FONT_MODULES += type1
+
+# CFF/OpenType font driver.
+#
+# This driver needs the `sfnt', `pshinter', and `psnames' modules.
+FONT_MODULES += cff
+
+# Type 1 CID-keyed font driver.
+#
+# This driver needs the `psaux', `pshinter', and `psnames' modules.
+FONT_MODULES += cid
+
+# PFR/TrueDoc font driver.  See optional extension ftpfr.c below also.
+FONT_MODULES += pfr
+
+# PostScript Type 42 font driver.
+#
+# This driver needs the `truetype' module.
+FONT_MODULES += type42
+
+# Windows FONT/FNT font driver.  See optional extension ftwinfnt.c below
+# also.
+FONT_MODULES += winfonts
+
+# PCF font driver.
+FONT_MODULES += pcf
+
+# BDF font driver.  See optional extension ftbdf.c below also.
+FONT_MODULES += bdf
+
+# SFNT files support.  If used without `truetype' or `cff', it supports
+# bitmap-only fonts within an SFNT wrapper.
+#
+# This driver needs the `psnames' module.
+FONT_MODULES += sfnt
+
+
+####
+#### hinting modules
+####
+
+# FreeType's auto hinter.
+HINTING_MODULES += autofit
+
+# PostScript hinter.
+HINTING_MODULES += pshinter
+
+# The TrueType hinting engine doesn't have a module of its own but is
+# controlled in file include/freetype/config/ftoption.h
+# (TT_CONFIG_OPTION_BYTECODE_INTERPRETER and friends).
+
+
+####
+#### raster modules -- at least one is required for vector font formats
+####
+
+# Monochrome rasterizer.
+RASTER_MODULES += raster
+
+# Anti-aliasing rasterizer.
+RASTER_MODULES += smooth
+
+
+####
+#### auxiliary modules
+####
+
+# FreeType's cache sub-system (quite stable but still in beta -- this means
+# that its public API is subject to change if necessary).  See
+# include/freetype/ftcache.h.
+AUX_MODULES += cache
+
+# TrueType GX/AAT table validation.  Needs ftgxval.c below.
+# AUX_MODULES += gxvalid
+
+# Support for streams compressed with gzip (files with suffix .gz).
+#
+# See include/freetype/ftgzip.h for the API.
+AUX_MODULES += gzip
+
+# Support for streams compressed with LZW (files with suffix .Z).
+#
+# See include/freetype/ftlzw.h for the API.
+AUX_MODULES += lzw
+
+# OpenType table validation.  Needs ftotval.c below.
+#
+# AUX_MODULES += otvalid
+
+# Auxiliary PostScript driver component to share common code.
+#
+# This module depends on `psnames'.
+AUX_MODULES += psaux
+
+# Support for PostScript glyph names.
+#
+# This module can be controlled in ftconfig.h
+# (FT_CONFIG_OPTION_POSTSCRIPT_NAMES).
+AUX_MODULES += psnames
+
+
+####
+#### base module extensions
+####
+
+# Exact bounding box calculation.
+#
+# See include/freetype/ftbbox.h for the API.
+BASE_EXTENSIONS += ftbbox.c
+
+# Access BDF-specific strings.  Needs BDF font driver.
+#
+# See include/freetype/ftbdf.h for the API.
+BASE_EXTENSIONS += ftbdf.c
+
+# Utility functions for converting 1bpp, 2bpp, 4bpp, and 8bpp bitmaps into
+# 8bpp format, and for emboldening of bitmap glyphs..
+#
+# See include/freetype/ftbitmap.h for the API. 
+BASE_EXTENSIONS += ftbitmap.c
+
+# Convenience functions to handle glyphs.
+#
+# See include/freetype/ftglyph.h for the API.
+BASE_EXTENSIONS += ftglyph.c
+
+# Interface for gxvalid module (which is required).
+#
+# See include/freetype/ftgxval.h for the API.
+# BASE_EXTENSIONS += ftgxval.c
+
+# Multiple Master font interface.
+#
+# See include/freetype/ftmm.h for the API.
+BASE_EXTENSIONS += ftmm.c
+
+# Interface for otvalid module (which is required).
+#
+# See include/freetype/ftotval.h for the API.
+# BASE_EXTENSIONS += ftotval.c
+
+# Interface for accessing PFR-specific data.  Needs PFR font driver.
+#
+# See include/freetype/ftpfr.h for the API.
+BASE_EXTENSIONS += ftpfr.c
+
+# Path stroker.
+#
+# See include/freetype/ftstroke.h for the API.
+BASE_EXTENSIONS += ftstroke.c
+
+# Support for synthetic embolding and slanting of fonts.
+#
+# See include/freetype/ftsynth.h for the API.
+BASE_EXTENSIONS += ftsynth.c
+
+# Interface to access data specific to PostScript Type 1 and Type 2 (CFF)
+# fonts.
+#
+# See include/freetype/t1tables.h for the API.
+BASE_EXTENSIONS += fttype1.c
+
+# Interface for accessing data specific to Windows FNT files.  Needs winfnt
+# driver.
+#
+# See include/freetype/ftwinfnt.h for the API.
+BASE_EXTENSIONS += ftwinfnt.c
+
+# Support functions for X11.  Useful only for building the XFree86 font
+# server.
+#
+# See include/freetype/ftxf86.h for the API.
+# BASE_EXTENSIONS += ftxf86.c
+
+
+####
+#### The components `ftsystem.c' (for memory allocation and stream I/O
+#### management) and `ftdebug.c' (for emitting debug messages to the user)
+#### are controlled with the following variables.
+####
+####   ftsystem.c:  $(FTSYS_SRC)
+####   ftdebug.c:   $(FTDEBUG_SRC)
+####
+#### Please refer to docs/CUSTOMIZE for details.
+####
+
+
+# EOF
diff --git a/src/autofit/module.mk b/src/autofit/module.mk
index 37b64aa..4a386ce 100644
--- a/src/autofit/module.mk
+++ b/src/autofit/module.mk
@@ -13,12 +13,11 @@
 # fully.
 
 
-.PHONY: add_autofit_module
+FTMODULE_H_COMMANDS += AUTOFIT_MODULE
 
-make_module_list: add_autofit_module
-
-add_autofit_module:
-	$(OPEN_DRIVER)autofit_module_class$(CLOSE_DRIVER)
-	$(ECHO_DRIVER)autofit   $(ECHO_DRIVER_DESC)automatic hinting module$(ECHO_DRIVER_DONE)
+define AUTOFIT_MODULE
+$(OPEN_DRIVER)autofit_module_class$(CLOSE_DRIVER)
+$(ECHO_DRIVER)autofit   $(ECHO_DRIVER_DESC)automatic hinting module$(ECHO_DRIVER_DONE)
+endef
 
 # EOF
diff --git a/src/base/ftdbgmem.c b/src/base/ftdbgmem.c
index 4c1e68d..557a05c 100644
--- a/src/base/ftdbgmem.c
+++ b/src/base/ftdbgmem.c
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    Memory debugger (body).                                              */
 /*                                                                         */
-/*  Copyright 2001, 2002, 2003, 2004, 2005 by                              */
+/*  Copyright 2001, 2002, 2003, 2004, 2005, 2006 by                        */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -887,6 +887,115 @@
   }
 
 
+#ifdef FT_STRICT_ALIASING
+
+
+  FT_BASE_DEF( FT_Pointer )
+  FT_Alloc_Debug( FT_Memory    memory,
+                  FT_Long      size,
+                  FT_Error    *p_error,
+                  const char*  file_name,
+                  FT_Long      line_no )
+  {
+    FT_MemTable  table = (FT_MemTable)memory->user;
+
+
+    if ( table )
+    {
+      table->file_name = file_name;
+      table->line_no   = line_no;
+    }
+
+    return FT_Alloc( memory, size, p_error );
+  }
+
+
+  FT_BASE_DEF( FT_Pointer )
+  FT_Realloc_Debug( FT_Memory    memory,
+                    FT_Long      current,
+                    FT_Long      size,
+                    void*        block,
+                    FT_Error    *p_error,
+                    const char*  file_name,
+                    FT_Long      line_no )
+  {
+    FT_MemTable  table = (FT_MemTable)memory->user;
+
+
+    if ( table )
+    {
+      table->file_name = file_name;
+      table->line_no   = line_no;
+    }
+
+    return FT_Realloc( memory, current, size, block, p_error );
+  }
+
+
+  FT_BASE_DEF( FT_Pointer )
+  FT_QAlloc_Debug( FT_Memory    memory,
+                   FT_Long      size,
+                   FT_Error    *p_error,
+                   const char*  file_name,
+                   FT_Long      line_no )
+  {
+    FT_MemTable  table = (FT_MemTable)memory->user;
+
+
+    if ( table )
+    {
+      table->file_name = file_name;
+      table->line_no   = line_no;
+    }
+
+    return FT_QAlloc( memory, size, p_error );
+  }
+
+
+  FT_BASE_DEF( FT_Pointer )
+  FT_QRealloc_Debug( FT_Memory    memory,
+                     FT_Long      current,
+                     FT_Long      size,
+                     void*        block,
+                     FT_Error    *p_error,
+                     const char*  file_name,
+                     FT_Long      line_no )
+  {
+    FT_MemTable  table = (FT_MemTable)memory->user;
+
+
+    if ( table )
+    {
+      table->file_name = file_name;
+      table->line_no   = line_no;
+    }
+
+    return FT_QRealloc( memory, current, size, block, p_error );
+  }
+
+
+  FT_BASE_DEF( void )
+  FT_Free_Debug( FT_Memory    memory,
+                 const void  *P,
+                 const char*  file_name,
+                 FT_Long      line_no )
+  {
+    FT_MemTable  table = (FT_MemTable)memory->user;
+
+
+    if ( table )
+    {
+      table->file_name = file_name;
+      table->line_no   = line_no;
+    }
+
+    FT_Free( memory, (void *)P );
+  }
+
+
+#else /* !FT_STRICT_ALIASING */
+
+
   FT_BASE_DEF( FT_Error )
   FT_Alloc_Debug( FT_Memory    memory,
                   FT_Long      size,
@@ -988,6 +1097,8 @@
   }
 
 
+#endif /* !FT_STRICT_ALIASING */
+
   static int
   ft_mem_source_compare( const void*  p1,
                          const void*  p2 )
diff --git a/src/base/rules.mk b/src/base/rules.mk
index 32dadbd..bbc6cb7 100644
--- a/src/base/rules.mk
+++ b/src/base/rules.mk
@@ -3,7 +3,7 @@
 #
 
 
-# Copyright 1996-2000, 2002, 2003, 2004, 2005 by
+# Copyright 1996-2000, 2002, 2003, 2004, 2005, 2006 by
 # David Turner, Robert Wilhelm, and Werner Lemberg.
 #
 # This file is part of the FreeType project, and may only be used, modified,
@@ -46,23 +46,11 @@
 
 # Base layer `extensions' sources
 #
-# An extension is added to the library file (.a or .lib) as a separate
-# object.  It will then be linked to the final executable only if one of its
-# symbols is used by the application.
+# An extension is added to the library file as a separate object.  It is
+# then linked to the final executable only if one of its symbols is used by
+# the application.
 #
-BASE_EXT_SRC := $(BASE_DIR)/ftbitmap.c \
-                $(BASE_DIR)/ftbbox.c   \
-                $(BASE_DIR)/ftbdf.c    \
-                $(BASE_DIR)/ftglyph.c  \
-                $(BASE_DIR)/ftgxval.c  \
-                $(BASE_DIR)/ftmm.c     \
-                $(BASE_DIR)/ftotval.c  \
-                $(BASE_DIR)/ftpfr.c    \
-                $(BASE_DIR)/ftstroke.c \
-                $(BASE_DIR)/ftsynth.c  \
-                $(BASE_DIR)/fttype1.c  \
-                $(BASE_DIR)/ftwinfnt.c \
-                $(BASE_DIR)/ftxf86.c
+BASE_EXT_SRC := $(patsubst %,$(BASE_DIR)/%,$(BASE_EXTENSIONS))
 
 # Default extensions objects
 #
diff --git a/src/bdf/module.mk b/src/bdf/module.mk
index 3d56d73..a978973 100644
--- a/src/bdf/module.mk
+++ b/src/bdf/module.mk
@@ -24,12 +24,11 @@
 # THE SOFTWARE.
 
 
-.PHONY: add_bdf_driver
+FTMODULE_H_COMMANDS += BDF_DRIVER
 
-make_module_list: add_bdf_driver
-
-add_bdf_driver:
-	$(OPEN_DRIVER)bdf_driver_class$(CLOSE_DRIVER)
-	$(ECHO_DRIVER)bdf       $(ECHO_DRIVER_DESC)bdf bitmap fonts$(ECHO_DRIVER_DONE)
+define BDF_DRIVER
+$(OPEN_DRIVER)bdf_driver_class$(CLOSE_DRIVER)
+$(ECHO_DRIVER)bdf       $(ECHO_DRIVER_DESC)bdf bitmap fonts$(ECHO_DRIVER_DONE)
+endef
 
 # EOF
diff --git a/src/cff/module.mk b/src/cff/module.mk
index 121a50b..0474e37 100644
--- a/src/cff/module.mk
+++ b/src/cff/module.mk
@@ -13,12 +13,11 @@
 # fully.
 
 
-.PHONY: add_cff_driver
+FTMODULE_H_COMMANDS += CFF_DRIVER
 
-make_module_list: add_cff_driver
-
-add_cff_driver:
-	$(OPEN_DRIVER)cff_driver_class$(CLOSE_DRIVER)
-	$(ECHO_DRIVER)cff       $(ECHO_DRIVER_DESC)OpenType fonts with extension *.otf$(ECHO_DRIVER_DONE)
+define CFF_DRIVER
+$(OPEN_DRIVER)cff_driver_class$(CLOSE_DRIVER)
+$(ECHO_DRIVER)cff       $(ECHO_DRIVER_DESC)OpenType fonts with extension *.otf$(ECHO_DRIVER_DONE)
+endef
 
 # EOF
diff --git a/src/cid/module.mk b/src/cid/module.mk
index 84a8140..41e5a68 100644
--- a/src/cid/module.mk
+++ b/src/cid/module.mk
@@ -13,12 +13,11 @@
 # fully.
 
 
-.PHONY: add_type1cid_driver
+FTMODULE_H_COMMANDS += TYPE1CID_DRIVER
 
-make_module_list: add_type1cid_driver
-
-add_type1cid_driver:
-	$(OPEN_DRIVER)t1cid_driver_class$(CLOSE_DRIVER)
-	$(ECHO_DRIVER)cid       $(ECHO_DRIVER_DESC)Postscript CID-keyed fonts, no known extension$(ECHO_DRIVER_DONE)
+define TYPE1CID_DRIVER
+$(OPEN_DRIVER)t1cid_driver_class$(CLOSE_DRIVER)
+$(ECHO_DRIVER)cid       $(ECHO_DRIVER_DESC)Postscript CID-keyed fonts, no known extension$(ECHO_DRIVER_DONE)
+endef
 
 # EOF
diff --git a/src/gxvalid/module.mk b/src/gxvalid/module.mk
index 41b33a7..3e1d7d9 100644
--- a/src/gxvalid/module.mk
+++ b/src/gxvalid/module.mk
@@ -13,12 +13,11 @@
 # fully.
 
 
-.PHONY: add_gxvalid_module
+FTMODULE_H_COMMANDS += GXVALID_MODULE
 
-make_module_list: add_gxvalid_module
-
-add_gxvalid_module:
-	$(OPEN_DRIVER)gxvalid_module_class$(CLOSE_DRIVER)
-	$(ECHO_DRIVER)gxvalid     $(ECHO_DRIVER_DESC)TrueTypeGX/AAT validation module$(ECHO_DRIVER_DONE)
+define GXVALID_MODULE
+$(OPEN_DRIVER)gxvalid_module_class$(CLOSE_DRIVER)
+$(ECHO_DRIVER)gxvalid     $(ECHO_DRIVER_DESC)TrueTypeGX/AAT validation module$(ECHO_DRIVER_DONE)
+endef
 
 # EOF
diff --git a/src/otvalid/module.mk b/src/otvalid/module.mk
index 966fece..4ef4387 100644
--- a/src/otvalid/module.mk
+++ b/src/otvalid/module.mk
@@ -13,12 +13,11 @@
 # fully.
 
 
-.PHONY: add_otvalid_module
+FTMODULE_H_COMMANDS += OTVALID_MODULE
 
-make_module_list: add_otvalid_module
-
-add_otvalid_module:
-	$(OPEN_DRIVER)otvalid_module_class$(CLOSE_DRIVER)
-	$(ECHO_DRIVER)otvalid     $(ECHO_DRIVER_DESC)OpenType validation module$(ECHO_DRIVER_DONE)
+define OTVALID_MODULE
+$(OPEN_DRIVER)otvalid_module_class$(CLOSE_DRIVER)
+$(ECHO_DRIVER)otvalid     $(ECHO_DRIVER_DESC)OpenType validation module$(ECHO_DRIVER_DONE)
+endef
 
 # EOF
diff --git a/src/pcf/module.mk b/src/pcf/module.mk
index e2da8d4..5bc7ce3 100644
--- a/src/pcf/module.mk
+++ b/src/pcf/module.mk
@@ -24,12 +24,11 @@
 # THE SOFTWARE.
 
 
-.PHONY: add_pcf_driver
+FTMODULE_H_COMMANDS += PCF_DRIVER
 
-make_module_list: add_pcf_driver
-
-add_pcf_driver:
-	$(OPEN_DRIVER)pcf_driver_class$(CLOSE_DRIVER)
-	$(ECHO_DRIVER)pcf       $(ECHO_DRIVER_DESC)pcf bitmap fonts$(ECHO_DRIVER_DONE)
+define PCF_DRIVER
+$(OPEN_DRIVER)pcf_driver_class$(CLOSE_DRIVER)
+$(ECHO_DRIVER)pcf       $(ECHO_DRIVER_DESC)pcf bitmap fonts$(ECHO_DRIVER_DONE)
+endef
 
 # EOF
diff --git a/src/pfr/module.mk b/src/pfr/module.mk
index d93b631..53ab34a 100644
--- a/src/pfr/module.mk
+++ b/src/pfr/module.mk
@@ -13,12 +13,11 @@
 # fully.
 
 
-.PHONY: add_pfr_driver
+FTMODULE_H_COMMANDS += PFR_DRIVER
 
-make_module_list: add_pfr_driver
-
-add_pfr_driver:
-	$(OPEN_DRIVER)pfr_driver_class$(CLOSE_DRIVER)
-	$(ECHO_DRIVER)pfr       $(ECHO_DRIVER_DESC)PFR/TrueDoc font files with extension *.pfr$(ECHO_DRIVER_DONE)
+define PFR_DRIVER
+$(OPEN_DRIVER)pfr_driver_class$(CLOSE_DRIVER)
+$(ECHO_DRIVER)pfr       $(ECHO_DRIVER_DESC)PFR/TrueDoc font files with extension *.pfr$(ECHO_DRIVER_DONE)
+endef
 
 # EOF
diff --git a/src/psaux/module.mk b/src/psaux/module.mk
index 9abd525..5431522 100644
--- a/src/psaux/module.mk
+++ b/src/psaux/module.mk
@@ -13,12 +13,11 @@
 # fully.
 
 
-.PHONY: add_psaux_module
+FTMODULE_H_COMMANDS += PSAUX_MODULE
 
-make_module_list: add_psaux_module
-
-add_psaux_module:
-	$(OPEN_DRIVER)psaux_module_class$(CLOSE_DRIVER)
-	$(ECHO_DRIVER)psaux     $(ECHO_DRIVER_DESC)Postscript Type 1 & Type 2 helper module$(ECHO_DRIVER_DONE)
+define PSAUX_MODULE
+$(OPEN_DRIVER)psaux_module_class$(CLOSE_DRIVER)
+$(ECHO_DRIVER)psaux     $(ECHO_DRIVER_DESC)Postscript Type 1 & Type 2 helper module$(ECHO_DRIVER_DONE)
+endef
 
 # EOF
diff --git a/src/pshinter/module.mk b/src/pshinter/module.mk
index 42ed7b7..cd171d0 100644
--- a/src/pshinter/module.mk
+++ b/src/pshinter/module.mk
@@ -13,12 +13,11 @@
 # fully.
 
 
-.PHONY: add_pshinter_module
+FTMODULE_H_COMMANDS += PSHINTER_MODULE
 
-make_module_list: add_pshinter_module
-
-add_pshinter_module:
-	$(OPEN_DRIVER)pshinter_module_class$(CLOSE_DRIVER)
-	$(ECHO_DRIVER)pshinter  $(ECHO_DRIVER_DESC)Postscript hinter module$(ECHO_DRIVER_DONE)
+define PSHINTER_MODULE
+$(OPEN_DRIVER)pshinter_module_class$(CLOSE_DRIVER)
+$(ECHO_DRIVER)pshinter  $(ECHO_DRIVER_DESC)Postscript hinter module$(ECHO_DRIVER_DONE)
+endef
 
 # EOF
diff --git a/src/psnames/module.mk b/src/psnames/module.mk
index 255a0e0..a93063b 100644
--- a/src/psnames/module.mk
+++ b/src/psnames/module.mk
@@ -13,12 +13,11 @@
 # fully.
 
 
-.PHONY: add_psnames_module
+FTMODULE_H_COMMANDS += PSNAMES_MODULE
 
-make_module_list: add_psnames_module
-
-add_psnames_module:
-	$(OPEN_DRIVER)psnames_module_class$(CLOSE_DRIVER)
-	$(ECHO_DRIVER)psnames   $(ECHO_DRIVER_DESC)Postscript & Unicode Glyph name handling$(ECHO_DRIVER_DONE)
+define PSNAMES_MODULE
+$(OPEN_DRIVER)psnames_module_class$(CLOSE_DRIVER)
+$(ECHO_DRIVER)psnames   $(ECHO_DRIVER_DESC)Postscript & Unicode Glyph name handling$(ECHO_DRIVER_DONE)
+endef
 
 # EOF
diff --git a/src/raster/module.mk b/src/raster/module.mk
index 2f5682f..59c737b 100644
--- a/src/raster/module.mk
+++ b/src/raster/module.mk
@@ -13,12 +13,11 @@
 # fully.
 
 
-.PHONY: add_raster_module
+FTMODULE_H_COMMANDS += RASTER_MODULE
 
-make_module_list: add_raster_module
-
-add_raster_module:
-	$(OPEN_DRIVER)ft_raster1_renderer_class$(CLOSE_DRIVER)
-	$(ECHO_DRIVER)raster    $(ECHO_DRIVER_DESC)monochrome bitmap renderer$(ECHO_DRIVER_DONE)
+define RASTER_MODULE
+$(OPEN_DRIVER)ft_raster1_renderer_class$(CLOSE_DRIVER)
+$(ECHO_DRIVER)raster    $(ECHO_DRIVER_DESC)monochrome bitmap renderer$(ECHO_DRIVER_DONE)
+endef
 
 # EOF
diff --git a/src/sfnt/module.mk b/src/sfnt/module.mk
index 00a2d77..d339138 100644
--- a/src/sfnt/module.mk
+++ b/src/sfnt/module.mk
@@ -13,12 +13,11 @@
 # fully.
 
 
-.PHONY: add_sfnt_module
+FTMODULE_H_COMMANDS += SFNT_MODULE
 
-make_module_list: add_sfnt_module
-
-add_sfnt_module:
-	$(OPEN_DRIVER)sfnt_module_class$(CLOSE_DRIVER)
-	$(ECHO_DRIVER)sfnt      $(ECHO_DRIVER_DESC)helper module for TrueType & OpenType formats$(ECHO_DRIVER_DONE)
+define SFNT_MODULE
+$(OPEN_DRIVER)sfnt_module_class$(CLOSE_DRIVER)
+$(ECHO_DRIVER)sfnt      $(ECHO_DRIVER_DESC)helper module for TrueType & OpenType formats$(ECHO_DRIVER_DONE)
+endef
 
 # EOF
diff --git a/src/smooth/module.mk b/src/smooth/module.mk
index bc2f7ff..05ad4ba 100644
--- a/src/smooth/module.mk
+++ b/src/smooth/module.mk
@@ -13,16 +13,15 @@
 # fully.
 
 
-.PHONY: add_smooth_renderer
+FTMODULE_H_COMMANDS += SMOOTH_RENDERER
 
-make_module_list: add_smooth_renderer
-
-add_smooth_renderer:
-	$(OPEN_DRIVER)ft_smooth_renderer_class$(CLOSE_DRIVER)
-	$(ECHO_DRIVER)smooth    $(ECHO_DRIVER_DESC)anti-aliased bitmap renderer$(ECHO_DRIVER_DONE)
-	$(OPEN_DRIVER)ft_smooth_lcd_renderer_class$(CLOSE_DRIVER)
-	$(ECHO_DRIVER)smooth    $(ECHO_DRIVER_DESC)anti-aliased bitmap renderer for LCDs$(ECHO_DRIVER_DONE)
-	$(OPEN_DRIVER)ft_smooth_lcdv_renderer_class$(CLOSE_DRIVER)
-	$(ECHO_DRIVER)smooth    $(ECHO_DRIVER_DESC)anti-aliased bitmap renderer for vertical LCDs$(ECHO_DRIVER_DONE)
+define SMOOTH_RENDERER
+$(OPEN_DRIVER)ft_smooth_renderer_class$(CLOSE_DRIVER)
+$(ECHO_DRIVER)smooth    $(ECHO_DRIVER_DESC)anti-aliased bitmap renderer$(ECHO_DRIVER_DONE)
+$(OPEN_DRIVER)ft_smooth_lcd_renderer_class$(CLOSE_DRIVER)
+$(ECHO_DRIVER)smooth    $(ECHO_DRIVER_DESC)anti-aliased bitmap renderer for LCDs$(ECHO_DRIVER_DONE)
+$(OPEN_DRIVER)ft_smooth_lcdv_renderer_class$(CLOSE_DRIVER)
+$(ECHO_DRIVER)smooth    $(ECHO_DRIVER_DESC)anti-aliased bitmap renderer for vertical LCDs$(ECHO_DRIVER_DONE)
+endef
 
 # EOF
diff --git a/src/truetype/module.mk b/src/truetype/module.mk
index 2f2d853..3b05afc 100644
--- a/src/truetype/module.mk
+++ b/src/truetype/module.mk
@@ -13,12 +13,11 @@
 # fully.
 
 
-.PHONY: add_truetype_driver
+FTMODULE_H_COMMANDS += TRUETYPE_DRIVER
 
-make_module_list: add_truetype_driver
-
-add_truetype_driver:
-	$(OPEN_DRIVER)tt_driver_class$(CLOSE_DRIVER)
-	$(ECHO_DRIVER)truetype  $(ECHO_DRIVER_DESC)Windows/Mac font files with extension *.ttf or *.ttc$(ECHO_DRIVER_DONE)
+define TRUETYPE_DRIVER
+$(OPEN_DRIVER)tt_driver_class$(CLOSE_DRIVER)
+$(ECHO_DRIVER)truetype  $(ECHO_DRIVER_DESC)Windows/Mac font files with extension *.ttf or *.ttc$(ECHO_DRIVER_DONE)
+endef
 
 # EOF
diff --git a/src/type1/module.mk b/src/type1/module.mk
index cbcd8c7..baf98c0 100644
--- a/src/type1/module.mk
+++ b/src/type1/module.mk
@@ -13,12 +13,11 @@
 # fully.
 
 
-.PHONY: add_type1_driver
+FTMODULE_H_COMMANDS += TYPE1_DRIVER
 
-make_module_list: add_type1_driver
-
-add_type1_driver:
-	$(OPEN_DRIVER)t1_driver_class$(CLOSE_DRIVER)
-	$(ECHO_DRIVER)type1     $(ECHO_DRIVER_DESC)Postscript font files with extension *.pfa or *.pfb$(ECHO_DRIVER_DONE)
+define TYPE1_DRIVER
+$(OPEN_DRIVER)t1_driver_class$(CLOSE_DRIVER)
+$(ECHO_DRIVER)type1     $(ECHO_DRIVER_DESC)Postscript font files with extension *.pfa or *.pfb$(ECHO_DRIVER_DONE)
+endef
 
 # EOF
diff --git a/src/type42/module.mk b/src/type42/module.mk
index 35c7010..8bd40a5 100644
--- a/src/type42/module.mk
+++ b/src/type42/module.mk
@@ -13,12 +13,11 @@
 # fully.
 
 
-.PHONY: add_type42_driver
+FTMODULE_H_COMMANDS += TYPE42_DRIVER
 
-make_module_list: add_type42_driver
-
-add_type42_driver:
-	$(OPEN_DRIVER)t42_driver_class$(CLOSE_DRIVER)
-	$(ECHO_DRIVER)type42    $(ECHO_DRIVER_DESC)Type 42 font files with no known extension$(ECHO_DRIVER_DONE)
+define TYPE42_DRIVER
+$(OPEN_DRIVER)t42_driver_class$(CLOSE_DRIVER)
+$(ECHO_DRIVER)type42    $(ECHO_DRIVER_DESC)Type 42 font files with no known extension$(ECHO_DRIVER_DONE)
+endef
 
 # EOF
diff --git a/src/winfonts/module.mk b/src/winfonts/module.mk
index fec9354..0ace3ae 100644
--- a/src/winfonts/module.mk
+++ b/src/winfonts/module.mk
@@ -13,11 +13,11 @@
 # fully.
 
 
-.PHONY: add_windows_driver
+FTMODULE_H_COMMANDS += WINDOWS_DRIVER
 
-make_module_list: add_windows_driver
+define WINDOWS_DRIVER
+$(OPEN_DRIVER)winfnt_driver_class$(CLOSE_DRIVER)
+$(ECHO_DRIVER)winfnt    $(ECHO_DRIVER_DESC)Windows bitmap fonts with extension *.fnt or *.fon$(ECHO_DRIVER_DONE)
+endef
 
-add_windows_driver:
-	$(OPEN_DRIVER)winfnt_driver_class$(CLOSE_DRIVER)
-	$(ECHO_DRIVER)winfnt    $(ECHO_DRIVER_DESC)Windows bitmap fonts with extension *.fnt or *.fon$(ECHO_DRIVER_DONE)
-
+# EOF