.silent   :
.suffix   : .c .def .lnk .nlm

#=============================================================================
# Makefile for freetype2
# Copyright 1996-2000 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 is the NetWare-loadable Module (NLM) makefile which produces a binary,
# libft2.nlm, that can be uploaded to any NetWare 5.1 or later server (a few more
# caveats apply: NetWare 5.1 SP7, NetWare v6 SP4, NetWare 6.5SP1 or later).
#
# This makefile is for use with GNU Make.
#
# 12 November 2002, 9. March 2004 Ulrich Neumann
#=============================================================================

NOVELLLIBC = C:/novell/ndk/libc

ifndef METROWERKS
METROWERKS = C:\Program Files\Metrowerks\CodeWarrior
endif

ifndef MWCIncludes
MWCIncludes = C:\novell\ndk\libc\include
endif

ifndef BUILD_MODE
BUILD_MODE = Optimize
endif

DESCRIPTION	= "The FreeType Project font engine Version 2.1.7 (LibC)"
COPYRIGHT	= "Copyright (c) 1996-2003 by David Turner Robert Wilhelm and Werner Lemberg.      NetWare Port 2004 by Ulrich Neumann (http://neumann.gne.de)"

VERSION		= 2,1,7

OBJS		= autohint.o bdf.o cff.o ftbase.o ftcache.o ftglyph.o ftinit.o \
		  ftmm.o ftsystem.o pcf.o pfr.o psaux.o pshinter.o psmodule.o \
		  raster.o sfnt.o smooth.o truetype.o type1.o type1cid.o type42.o \
		  winfnt.o infutil.o ftgzip.o ftpfr.o ftstroke.o ftsynth.o \
		  fttype1.o ftwinfnt.o ftxf86.o ftbbox.o

#- Tools ----------------------------------------------------------------------
# Tools from Metrowerks CodeWarrior (command-line versions) Novell and GNU.
#
ENTRY		= -entry _LibCPrelude
ENTRY		= -entry _LibCPrelude
EXTRA_OBJS	= dllmain.o
EXTRA_TARG	= nlm.def dllmain.o
LIBC_OBJS	= "${NOVELLLIBC}/imports/libcpre.o"
OUT		= -o $@
NOVEXT		= nlm
CC		= mwccnlm.exe
LD		= mwldnlm.exe
MPKLISTER	= mpkxdc.exe
#------------------------------------------------------------------------------


#- Compilation ----------------------------------------------------------------
# Definitions and rule for compiling C source code.
CFLAGS  = -c -nosyspath -Cpp_exceptions off -RTTI off -align 1 -w nocmdline -proc PII
LDFLAGS = -w nocmdline -exit _LibCPostlude -stacksize 32768 -flags pseudo -nlmversion $(VERSION) -copy $(COPYRIGHT) -commandfile nlm.def
LDFLAGS_APP = -w nocmdline -exit _LibCPostlude -stacksize 32768 -flags pseudo -commandfile app.def -nlmversion $(VERSION) -copy $(COPYRIGHT)
ifeq "$(BUILD_MODE)" "Optimize"
CFLAGS 	+= -opt speed, level=4
else
CFLAGS 	+= -g -DDEBUG
endif

INCLUDES = -I. -I${NOVELLLIBC}/include  -I../../include -I../../src/autohint \
	   -I../../src/base -I../../src/bdf -I../../src/cache -I../../src/cff \
	   -I../../src/cid -I../../src/otlayout -I../../src/pcf -I../../src/pfr \
	   -I../../src/psaux -I../../src/pshinter -I../../src/psnames \
	   -I../../src/raster -I../../src/sfnt -I../../src/smooth -I../../src/tools \
	   -I../../src/truetype -I../../src/type1 -I../../src/type42 -I../../src/winfonts \
	   -I../../src/autofit -I../../src/gzip -include config.h
CFLAGS 	+= $(INCLUDES)

#- Compilation rule -----------------------------------------------------------
# Rule to compile C source code using Metrowerks CodeWarrior C/C++ compiler.
#
.c.o:
	$(CC) $(CFLAGS) $<
#------------------------------------------------------------------------------


#- Linking --------------------------------------------------------------------
# Rule and target to link the library. This is the first (default) target. The
# command, "make link," causes only the link portion of the process to run and
# is useful only if you are certain that all the intermediate objects are in
# order. Because of the sheer lethargy of GNU Make, this target was created as
# useful. It is the perfect command after performing a "make delbin."
#
all: libft2 test_bbox test_trig
	@echo ------------------------------------------------------------
	@echo All build !

libft2: $(EXTRA_TARG) $(OBJS)
	$(LD) $(LDFLAGS) $(ENTRY) $(OUT).$(NOVEXT) $(OBJS) $(EXTRA_OBJS) $(LIBC_OBJS)
	@echo ------------------------------------------------------------
	@echo freetype 2 build finished...

test_bbox: test_bbox.o
	$(LD) $(LDFLAGS_APP) $(ENTRY) $(OUT).$(NOVEXT) test_bbox.o $(LIBC_OBJS)
	@echo ------------------------------------------------------------
	@echo test_bbox build finished...

test_trig: test_trig.o
	$(LD) $(LDFLAGS_APP) $(ENTRY) $(OUT).$(NOVEXT) test_trig.o $(LIBC_OBJS)
	@echo ------------------------------------------------------------
	@echo test_trig build finished...

#- Link-definition file -------------------------------------------------------
# Target to build the link definition file which will direct the linker.
#
nlm.def: nlm.xdc app.def
	@echo Creating link parameters in nlm.def...
	@echo Module		LIBC.NLM					>  nlm.def
	@echo Description	'$(DESCRIPTION)'				>> nlm.def
	@echo XDCData		nlm.xdc						>> nlm.def
	@echo PseudoPreemption							>> nlm.def
	@echo FLAG_ON		0x00400000					>> nlm.def
	@echo Import		'@C:\novell\ndk\libc\imports\netware.imp'	>> nlm.def
	@echo Import		'@C:\novell\ndk\libc\imports\libc.imp'		>> nlm.def
	@echo Export		@libft2.imp					>> nlm.def

app.def:
	@echo Creating link parameters in app.def...
	@echo Module		LIBC.NLM LIBFT2.NLM				>  app.def
	@echo Description	'$(DESCRIPTION)'				>> app.def
	@echo PseudoPreemption							>> app.def
	@echo XDCData		nlm.xdc						>> app.def
	@echo FLAG_ON           0x00400000                                      >> app.def
	@echo Import		'@C:\novell\ndk\libc\imports\netware.imp'	>> app.def
	@echo Import		'@C:\novell\ndk\libc\imports\libc.imp'		>> app.def
	@echo Import            '@libft2.imp'					>> app.def

dll:
	@echo Creating DllMain code...
	@echo '#include <library.h>'						>  dllmain.c
	@echo '#include <windows.h>'						>> dllmain.c
	@echo 'int DllMain (void *hinstDLL, unsigned long fdwReason, void *lvpReserved)' >>dllmain.c
	@echo {									>> dllmain.c
	@echo '#pragma unused(lvpReserved)'					>> dllmain.c
	@echo 'switch (fdwReason)'						>> dllmain.c
	@echo {									>> dllmain.c
	@echo 'default:'							>> dllmain.c
	@echo 'return FALSE;'							>> dllmain.c
	@echo 'case DLL_NLM_STARTUP:'						>> dllmain.c
	@echo 'register_destructor((int) hinstDLL, (int (*)(void *)) NULL);'	>> dllmain.c
	@echo 'return TRUE;'							>> dllmain.c
	@echo case DLL_NLM_SHUTDOWN:						>> dllmain.c
	@echo case DLL_PROCESS_ATTACH:						>> dllmain.c
	@echo case DLL_PROCESS_DETACH:						>> dllmain.c
	@echo case DLL_THREAD_ATTACH:						>> dllmain.c
	@echo case DLL_THREAD_DETACH:						>> dllmain.c
	@echo case DLL_ACTUAL_DLLMAIN:						>> dllmain.c
	@echo 'return TRUE;'							>> dllmain.c
	@echo }									>> dllmain.c
	@echo 'return FALSE;'							>> dllmain.c
	@echo }									>> dllmain.c
#------------------------------------------------------------------------------


#- Cross-domain data ----------------------------------------------------------
# Target to produce MPK-unsafe lists when warranted or, in the normal case, an
# XDC record that signals MPK that all functions in the NLM are completely
# MP-safe. These indications are placed in the cross-domain data (XDC) of the
# NLM.
#
# The list or MP-safe record is produced by MPKXDC.Exe and supplied as XDC data
# at link time. The -n switch will mean that all interfaces are MP-safe.
#
nlm.xdc:
	@echo ------------------------------------------------------------
	@echo Designating libft2.nlm as multiprocessor-safe...
	@$(MPKLISTER) -n $@
#-----------------------------------------------------------------------------


#- Clean up ------------------------------------------------------------------
clean   :
	@echo Cleanung Up...
	cmd /C del *.o
	cmd /C del nlm.def	
	cmd /C del app.def
	cmd /C del *.xdc
	cmd /C del libmain.c
	cmd /C del dllmain.c
#-----------------------------------------------------------------------------


#- Install -------------------------------------------------------------------
install:
	@echo Installing libft2...
	cmd /C 'copy libft2.nlm ..\..\..\..\..\lib'
	cmd /C 'copy libft2.imp ..\..\..\..\local\imports'
#-----------------------------------------------------------------------------


#- Object dependence ---------------------------------------------------------
dllmain.o: dll
	$(CC) $(CFLAGS) dllmain.c
	
libmain.o: lib
	$(CC) $(CFLAGS) libmain.c

autohint.o:	../../src/autohint/autohint.c
	$(CC) $(CFLAGS) ../../src/autohint/autohint.c

bdf.o:		../../src/bdf/bdf.c
	$(CC) $(CFLAGS) ../../src/bdf/bdf.c

cff.o:		../../src/cff/cff.c
	$(CC) $(CFLAGS) ../../src/cff/cff.c

ftbase.o:	../../src/base/ftbase.c
	$(CC) $(CFLAGS) ../../src/base/ftbase.c

ftbbox.o:	../../src/base/ftbbox.c
	$(CC) $(CFLAGS) ../../src/base/ftbbox.c

ftstroke.o:	../../src/base/ftstroke.c
	$(CC) $(CFLAGS) ../../src/base/ftstroke.c

ftxf86.o:	../../src/base/ftxf86.c
	$(CC) $(CFLAGS) ../../src/base/ftxf86.c

ftsynth.o:	../../src/base/ftsynth.c
	$(CC) $(CFLAGS) ../../src/base/ftsynth.c

fttype1.o:	../../src/base/fttype1.c
	$(CC) $(CFLAGS) ../../src/base/fttype1.c

ftwinfnt.o:	../../src/base/ftwinfnt.c
	$(CC) $(CFLAGS) ../../src/base/ftwinfnt.c

ftcache.o:	../../src/cache/ftcache.c
	$(CC) $(CFLAGS) ../../src/cache/ftcache.c

ftglyph.o:	../../src/base/ftglyph.c
	$(CC) $(CFLAGS) ../../src/base/ftglyph.c

ftinit.o:	../../src/base/ftinit.c
	$(CC) $(CFLAGS) ../../src/base/ftinit.c

ftmm.o:		../../src/base/ftmm.c
	$(CC) $(CFLAGS) ../../src/base/ftmm.c

ftsystem.o:	../../src/base/ftsystem.c
	$(CC) $(CFLAGS) ../../src/base/ftsystem.c

pcf.o:		../../src/pcf/pcf.c
	$(CC) $(CFLAGS) ../../src/pcf/pcf.c

ftpfr.o:	../../src/base/ftpfr.c
	$(CC) $(CFLAGS) ../../src/base/ftpfr.c

pfr.o:		../../src/pfr/pfr.c
	$(CC) $(CFLAGS) ../../src/pfr/pfr.c

psaux.o:	../../src/psaux/psaux.c
	$(CC) $(CFLAGS) ../../src/psaux/psaux.c

pshinter.o:	../../src/pshinter/pshinter.c
	$(CC) $(CFLAGS) ../../src/pshinter/pshinter.c

psmodule.o:	../../src/psnames/psmodule.c
	$(CC) $(CFLAGS) ../../src/psnames/psmodule.c

raster.o:	../../src/raster/raster.c
	$(CC) $(CFLAGS) ../../src/raster/raster.c

sfnt.o:		../../src/sfnt/sfnt.c
	$(CC) $(CFLAGS) ../../src/sfnt/sfnt.c

smooth.o:	../../src/smooth/smooth.c
	$(CC) $(CFLAGS) ../../src/smooth/smooth.c

truetype.o:	../../src/truetype/truetype.c
	$(CC) $(CFLAGS) ../../src/truetype/truetype.c

type1.o:	../../src/type1/type1.c
	$(CC) $(CFLAGS) ../../src/type1/type1.c

type1cid.o:	../../src/cid/type1cid.c
	$(CC) $(CFLAGS) ../../src/cid/type1cid.c

type42.o:	../../src/type42/type42.c
	$(CC) $(CFLAGS) ../../src/type42/type42.c

winfnt.o:	../../src/winfonts/winfnt.c
	$(CC) $(CFLAGS) ../../src/winfonts/winfnt.c

otlbase.o:	../../src/otlayout/otlbase.c
	$(CC) $(CFLAGS) ../../src/otlayout/otlbase.c

afangles.o:	../../src/autofit/afangles.c
	$(CC) $(CFLAGS) ../../src/autofit/afangles.c

afhints.o:	../../src/autofit/afhints.c
	$(CC) $(CFLAGS) ../../src/autofit/afhints.c

aflatin.o:	../../src/autofit/aflatin.c
	$(CC) $(CFLAGS) ../../src/autofit/aflatin.c

infutil.o:	../../src/gzip/infutil.c
	$(CC) $(CFLAGS) ../../src/gzip/infutil.c

ftgzip.o:	../../src/gzip/ftgzip.c
	$(CC) $(CFLAGS) ../../src/gzip/ftgzip.c
	
test_bbox.o:	../../src/tools/test_bbox.c
	$(CC) $(CFLAGS) ../../src/tools/test_bbox.c

test_trig.o:	../../src/tools/test_trig.c
	$(CC) $(CFLAGS) ../../src/tools/test_trig.c
#------------------------------------------------------------------------------

