Commit c30aea98 authored by David Turner's avatar David Turner
Browse files

another massive changes in order to completely avoid

compiler warnings with GCC + "-ansi -pedantic -Wall -W"
and LCC.

Also fixed the compilation of "type1z" with Win32-LCC
(its pre-processor is broken !!)

Updated the BUILD document too
parent bfe2f98f
......@@ -151,7 +151,7 @@ II. COMMAND-LINE COMPILATION:
if you encounter this problem.
Note that the release version will use Autoconf to detect everything
on UNix, so this will not be necessary !!
on Unix, so this will not be necessary !!
II. DETAILED COMPILATION PROCEDURE:
......@@ -160,46 +160,31 @@ II. DETAILED COMPILATION PROCEDURE:
If you don't want to compile FreeType 2 from the command-line (for example
from a graphical IDE on a Mac or Windows), you'll need to understand how the
FreeType files are organized.
First of all, all configuration files are located in "freetype2/config",
with system-specific overrides in "freetype2/config/<system>". You should
always place "config/<system>" and "config" in your compilation include
path, **in this order**
Also, place the directory "include" in the compilation include path, as
well as "src/base" and "src/shared"
Now, FreeType 2 is a very modular design, made of several distinct components.
Each component can be compiler either as a stand-alone object file, or as a
list of independent objects.
For example, the "base layer" is made of the following independent source
files:
freetype2/
src/
base/
ftcalc.c
ftdebug.c
ftextend.c
ftlist.c
ftobjs.c
ftstream.c
ftraster.c
ftoutln.c
ftsystem.c
You can compile each of these files separately.
Another method is to compile the file "src/base/ftbase.c" which performs
a simple include on all these individual files. This will compile the whole
base layer as a single object file.
Note that through careful macro definitions, compiling a module as a single
component avoids the generation of many externals (that really correspond
to intra-module dependencies) and provides greater optimisations
opportunities.
FreeType 2 has a very module design, and it is made of several components.
Each component must be compiled as a stand-alone object file, even when it
is really made of several C source files. For example, the "base layer"
component is made of the following C files:
src/
base/
ftcalc.c - computations
ftobjs.c - object management
ftstream.c - stream input
ftlist.c - simple list management
ftoutln.c - simple outline processing
ftextend.c - extensions support
However, you can create a single object file by compiling the file
"src/base/ftbase.c", whose content is:
#include <ftcalc.c>
#include <ftobjs.c>
#include <ftstream.c>
#include <ftlist.c>
#include <ftoutln.c>
#include <ftextend.c>
Similarly, each component has a single "englobing" C file to compile it
as a stand-alone object, i.e. :
......@@ -209,9 +194,39 @@ II. DETAILED COMPILATION PROCEDURE:
src/truetype/truetype.c - the TrueType font driver
src/type1/type1.c - the Type 1 font driver
Now, you can decide how to compile each module, and add the corresponding
object files to your library..
To compile one component, do the following:
- add the top-level "include" directory to your compilation include path
- add the component's path to your compilation include path too. Being
in the component's directory isn't enough !!
- compile the component "source" file (see list below).
For example, the following line can be used to compile the truetype driver
on Unix:
cd freetype2/
cc -c -Iinclude -Isrc/truetype src/truetype/truetype.c
Alternatively:
cd freetype2/src/truetype
cc -c -I../../include -I. src/truetype/truetype.c
The complete list of files to compile for a feature-complete build of
FreeType 2 is:
The directory "freetype2/include" contains all public header files that
may be included by client applications..
src/base/ftsystem.c - system-specific memory and i/o support
src/base/ftinit.c - initialisation layer
src/base/ftdebug.c - debugging component (empty in release build)
src/base/ftbase.c - the "base layer" component
src/base/ftraster.c - the standard raster (scan-converter)
src/base/ftgrays.c - the smooth raster (anti-aliased only)
src/base/ftglyph.c - optional convenience functions
src/sfnt/sfnt.c - the "sfnt" module
src/psnames/psnames.c - the "psnames" module
src/truetype/truetype.c - the TrueType font driver
src/type1/type1.c - the Type 1 font driver
LATEST CHANGES -
- light update/cleaning of the build system + changes to the sources in
order to get rid of _all_ compiler warnings with three compilers, i.e:
gcc with "-ansi -pedantic -Wall -W", Visual C++ with "/W3 /WX"
and LCC
IMPORTANT NOTE FOR WIN32-LCC USERS:
|
| It seems the C pre-processor that comes with LCC is broken, it
| doesn't recognize the ANSI standard directives # and ## correctly
| when one of the argument is a macro. Also, something like:
|
| #define F(x) print##x
|
| F(("hello"))
|
| will get incorrectly translated to:
|
| print "hello")
|
| by its pre-processor. For this reason, you simply cannot build
| FreeType 2 in debug mode with this compiler..
- yet another massive grunt work. I've changed the definition of the
EXPORT_DEF, EXPORT_FUNC, BASE_DEF & BASE_FUNC macros. These now take
an argument, which is the function's return value type.
......@@ -27,6 +51,7 @@ LATEST CHANGES -
a different signature).
- updated the tutorial (not finished though).
- updated the top-level BUILD document
- added the declaration of FT_New_Memory_Face in <freetype/freetype.h>, as
it was missing from the public header (the implementation was already
......
......@@ -17,16 +17,16 @@
# the following variables:
#
# BUILD The configuration and system-specific directory. Usually
# `freetype/config/$(PLATFORM)' but can be different if a
# specific compiler has been requested on the command line.
# `freetype/config/$(PLATFORM)' but can be different for
# custom builds of the library.
#
# The following variables must be defined in system specific `detect.mk'
# files:
#
# PLATFORM The detected platform. This will default to `ansi' if
# auto-detection fails.
# CONFIG_FILE The Makefile to use. This usually depends on the compiler
# defined in the `CC' environment variable.
# CONFIG_FILE The configuration sub-makefile to use. This usually depends
# on the compiler defined in the `CC' environment variable.
# DELETE The shell command used to remove a given file.
# COPY The shell command used to copy one file.
# SEP The platform-specific directory separator.
......@@ -44,7 +44,7 @@ TOP := .
endif
# Set auto-detection default to `ansi'.
# Note that we delay the evaluation of $(CONFIG_), $(BUILD), and
# Note that we delay the evaluation of $(BUILD_CONFIG_), $(BUILD), and
# $(CONFIG_RULES).
#
PLATFORM := ansi
......@@ -52,9 +52,9 @@ DELETE := $(RM)
COPY := cp
SEP := /
CONFIG_ = $(TOP)$(SEP)config$(SEP)
BUILD = $(CONFIG_)$(PLATFORM)
CONFIG_RULES = $(BUILD)$(SEP)$(CONFIG_FILE)
BUILD_CONFIG_ = $(TOP)$(SEP)config$(SEP)
BUILD = $(BUILD_CONFIG_)$(PLATFORM)
CONFIG_RULES = $(BUILD)$(SEP)$(CONFIG_FILE)
# We define the BACKSLASH variable to hold a single back-slash character.
# This is needed because a line like
......@@ -74,7 +74,7 @@ BACKSLASH := $(strip \ )
# directories. Note that the calling order of the various `detect.mk' files
# isn't predictable.
#
include $(wildcard $(CONFIG_)*/detect.mk)
include $(wildcard $(BUILD_CONFIG_)*/detect.mk)
# In case no detection rule file was successful, use the default.
#
......@@ -86,7 +86,7 @@ endif
# The following targets are equivalent, with the exception that they use
# slightly different syntaxes for the `echo' command.
#
# std_setup: defined for most platforms
# std_setup: defined for most (i.e. Unix-like) platforms
# dos_setup: defined for Dos-ish platforms like Dos, Windows & OS/2
#
.PHONY: std_setup dos_setup
......
......@@ -13,11 +13,6 @@
# fully.
# This configuration file to be used depends on the value of the CC
# environment variable which is set below according to the compiler name
# given as a parameter to make.
# We test for the COMSPEC environment variable, then run the `ver'
# command-line program to see if its output contains the word `Dos'.
#
......
......@@ -13,11 +13,6 @@
# fully.
# This configuration file to be used depends on the value of the CC
# environment variable which is set below according to the compiler name
# given as a parameter to make.
ifeq ($(PLATFORM),ansi)
ifdef OS2_SHELL
......
......@@ -13,7 +13,7 @@
# fully.
# This will probably change a lost in the future if we are going to use
# This will probably change a lot in the future if we are going to use
# Automake/Autoconf...
......
......@@ -13,11 +13,6 @@
# fully.
# This configuration file to be used depends on the value of the CC
# environment variable which is set below according to the compiler name
# given as a parameter to make.
ifeq ($(PLATFORM),ansi)
# Detecting Windows NT is easy, as the OS variable must be defined and
......
......@@ -128,7 +128,7 @@ distclean_freetype: distclean_freetype_dos
DIR_OBJ := $(subst /,\\,$(OBJ_DIR))
$(FT_LIBRARY): $(OBJECTS_LIST)
lcclnk -o $(subst /,\\,$@) $(subst /,\\,$<)
lcclnk -o $(subst /,\\,$@) $(subst /,\\,$(OBJECTS_LIST))
endif
......
......@@ -84,6 +84,7 @@ else
LINK = $(CC) $T$@ $< $(FTLIB) $(EFENCE) $(LDFLAGS)
COMMON_LINK = $(LINK) $(COMMON_OBJ)
GRAPH_LINK = $(COMMON_LINK) $(GRAPH_LIB)
GRAPH_LINK2 = $(GRAPH_LINK) $(EXTRA_GRAPH_OBJS)
.PHONY: exes clean distclean
......@@ -187,6 +188,8 @@ else
$(OBJ_)ftgrays2.$O: $(SRC_DIR_)ftgrays2.c
$(COMPILE) $T$@ $<
EXTRA_GRAPH_OBJS := $(OBJ_)ftrast.$O $(OBJ_)ftrast2.$O
$(OBJ_)ftrast.$O: $(SRC_DIR_)ftrast.c
$(COMPILE) $T$@ $<
......@@ -268,7 +271,7 @@ else
$(BIN_)ftview$E: $(OBJ_)ftview.$O $(FTLIB) $(GRAPH_LIB) $(COMMON_OBJ) $(OBJ_)ftrast2.$O $(OBJ_)ftrast.$O
$(GRAPH_LINK) $(OBJ_)ftrast2.$O $(OBJ_)ftrast.$O
$(GRAPH_LINK2)
$(BIN_)ftstring$E: $(OBJ_)ftstring.$O $(FTLIB) $(GRAPH_LIB) $(COMMON_OBJ)
$(GRAPH_LINK)
......
......@@ -46,6 +46,7 @@ LINK_ROOT = lcclnk -o $(subst /,\\,$@) $(subst /,\\,$<)
LINK = $(LINK_ROOT) $(subst /,\\,$(FTLIB))
COMMON_LINK = $(LINK_ROOT) $(subst /,\\,$(COMMON_OBJ)) $(subst /,\\,$(FTLIB))
GRAPH_LINK = $(LINK_ROOT) $(subst /,\\,$(COMMON_OBJ)) $(subst /,\\,$(GRAPH_LIB)) $(subst /,\\,$(FTLIB))
GRAPH_LINK2 = $(GRAPH_LINK) $(subst /,\\,$(EXTRA_GRAPH_OBJS))
endif
endif
......@@ -257,14 +257,6 @@
(( sizeof(TProfile)+sizeof(long)-1 ) / sizeof(long))
/* Left fill bitmask */
static const Byte LMask[8] =
{ 0xFF, 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x03, 0x01 };
/* Right fill bitmask */
static const Byte RMask[8] =
{ 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFF };
#ifdef TT_STATIC_RASTER
......@@ -1815,7 +1807,7 @@
{
Long pitch = ras.target.pitch;
(void)max;
UNUSED(max);
ras.traceIncr = (Short)- pitch;
ras.traceOfs = - *min * pitch;
......@@ -1838,9 +1830,9 @@
Byte f1, f2;
Byte* target;
(void)y;
(void)left;
(void)right;
UNUSED(y);
UNUSED(left);
UNUSED(right);
/* Drop-out control */
......@@ -2015,9 +2007,9 @@
static void Horizontal_Sweep_Init( RAS_ARGS Short* min, Short* max )
{
/* nothing, really */
(void)raster;
(void)min;
(void)max;
UNUSED(raster);
UNUSED(min);
UNUSED(max);
}
......@@ -2031,8 +2023,8 @@
PByte bits;
Byte f1;
(void)left;
(void)right;
UNUSED(left);
UNUSED(right);
if ( x2-x1 < ras.precision )
{
......@@ -2173,7 +2165,7 @@
static void Horizontal_Sweep_Step( RAS_ARG )
{
/* Nothing, really */
(void)raster;
UNUSED(raster);
}
......@@ -2285,12 +2277,12 @@
PProfile right )
{
/* nothing, really */
(void)raster;
(void)y;
(void)x1;
(void)x2;
(void)left;
(void)right;
UNUSED(raster);
UNUSED(y);
UNUSED(x1);
UNUSED(x2);
UNUSED(left);
UNUSED(right);
}
static void Horizontal_Gray_Sweep_Drop( RAS_ARGS Short y,
......
......@@ -95,6 +95,13 @@
#define FT_ALIGNMENT 8
/* UNUSED is a macro used to indicate that a given parameter is not used */
/* this is only used to get rid of unpleasant compiler warnings.. */
#ifndef UNUSED
#define UNUSED( arg ) ( (arg)=(arg) )
#endif
/*************************************************************************/
/* */
......
......@@ -170,7 +170,7 @@
/* Don't define any of these macros to compile in `release' mode. */
/* */
#undef FT_DEBUG_LEVEL_ERROR
#define FT_DEBUG_LEVEL_TRACE
#undef FT_DEBUG_LEVEL_TRACE
/*************************************************************************/
......
......@@ -51,6 +51,11 @@
#endif
/* A very stupid pre-processor trick. See K&R version 2 */
/* section A12.3 for details.. */
#define FT_CAT(x,y) x ## y
#define FT_XCAT(x,y) FT_CAT(x,y)
#ifdef FT_DEBUG_LEVEL_TRACE
......@@ -78,15 +83,6 @@
trace_ttextend,
trace_ttdriver,
#if 0
/* define an enum for each TrueDoc driver component */
trace_tdobjs,
trace_tdload,
trace_tdgload,
trace_tdhint,
trace_tddriver,
#endif
/* define an enum for each Type1 driver component */
trace_t1objs,
trace_t1load,
......@@ -120,7 +116,7 @@
do \
{ \
if ( ft_trace_levels[FT_COMPONENT] >= level ) \
FT_Message##varformat; \
FT_XCAT( FT_Message, varformat ); \
} while ( 0 )
......@@ -174,7 +170,7 @@
/* print a message and exit */
EXPORT_DEF(void) FT_Panic ( const char* fmt, ... );
#define FT_ERROR( varformat ) FT_Message##varformat
#define FT_ERROR(varformat) do { FT_XCAT( FT_Message, varformat ) } while(0)
#endif /* FT_DEBUG_LEVEL_TRACE || FT_DEBUG_LEVEL_ERROR */
......
......@@ -46,7 +46,7 @@
#endif
#ifndef UNUSED
#define UNUSED( arg ) ( (void)(arg) )
#define UNUSED( arg ) ( (void)(arg)=(arg) )
#endif
......
......@@ -1151,7 +1151,7 @@ int check_sort( PCell cells, int count )
TScan x, y, cover, area;
PCell start, cur, limit;
(void)target;
target=target;
cur = ras.cells;
limit = cur + ras.num_cells;
......
......@@ -88,8 +88,10 @@ const FT_DriverInterface* ft_default_drivers[] =
error = FT_Add_Driver( library, *cur );
/* notify errors, but don't stop */
if ( error )
{
FT_ERROR(( "FT.Default_Drivers: Cannot install `%s', error = %x\n",
(*cur)->driver_name, error ));
}
cur++;
}
}
......
......@@ -66,8 +66,8 @@
#include <freetype/internal/ftdebug.h>
#endif
#ifndef EXPORT_FUNC
#define EXPORT_FUNC /* nothing */
#ifndef UNUSED
#define UNUSED( arg ) ( (arg)=(arg) )
#endif
#undef FT_COMPONENT
......@@ -279,7 +279,7 @@
/* `->' */
#define ras (*raster)
#define UNUSED_RASTER (void)raster;
#define UNUSED_RASTER (raster=raster);
/*************************************************************************/
/* */
......
......@@ -66,7 +66,7 @@
void* ft_alloc( FT_Memory memory,
long size )
{
(void)memory;
UNUSED(memory);
return malloc(size);
}
......@@ -110,8 +110,8 @@
long new_size,
void* block )
{
(void)memory;
(void)cur_size;
UNUSED(memory);
UNUSED(cur_size);
return realloc( block, new_size );
}
......@@ -140,7 +140,7 @@
void ft_free( FT_Memory memory,
void* block )
{
(void)memory;
UNUSED(memory);
free( block );
}
......
......@@ -233,7 +233,11 @@
100, /* driver version */
200, /* driver requires FreeType 2 or above */
(void*)&psnames_interface
(void*)&psnames_interface,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0,
};
#else
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment