# This file is part of the FreeType project.
#
# It builds the library and test programs for BC++ for Win32.
#
# Tested with Borland C++ v.4.02, 5.0, and Borland C++ builder 4.
# You will need Borland MAKE.
#
#
# Use this file while in the 'test' directory with the following statement:
#
#   make -farch\win32\Makefile.BC
#
#
# A DLL version of the library can be built and then used with
#
#   make -DDLL -farch/win16/Makefile.BC dll
#
# (do not forget to define DLL, otherwise the link phase will fail).
#
#
# A debug version can be obtained with
#
#   make -DDEBUG -farch\win32\Makefile.BC

ARCH = arch\win32
FT_MAKEFILE = $(ARCH)\Makefile.BC
FT_DLL = ft13_32.dll

CC = bcc32

LIBDIR = ..\lib
INCDIRS = -I$(LIBDIR);$(LIBDIR)\$(ARCH);.;$(LIBDIR)\extend
SPURIOUS_WARNINGS = -w-nak -w-par -w-use -w-aus -w-stu -w-stv -w-cln -w-sig -w-pia
CFLAGS =  -i48 $(INCDIRS) $(SPURIOUS_WARNINGS)

!ifndef DEBUG
CFLAGS = $(CFLAGS) -O2 -A
LDFLAGS = -WC
!else
CFLAGS = $(CFLAGS) -v
LDFLAGS = -v -WC
!endif

!ifdef DLL
CFLAGS = $(CFLAGS) -DFREETYPE_DLL
!endif

# Windows graphic driver
GDRIVER = $(ARCH)\gw_win32.c

DISPLAY = display.c

G1SRC = gmain.c blitter.c $(GDRIVER)
GSRC = $(DISPLAY) $(G1SRC)

GOBJ = $(GSRC:.c=.obj)
G1OBJ = $(G1SRC:.c=.obj)


SRC = arabic.c \
      common.c \
      ftdump.c \
      fterror.c \
      ftlint.c \
      ftmetric.c \
      ftsbit.c \
      ftstring.c \
      ftstrpnm.c \
      ftstrtto.c \
      fttimer.c \
      ftview.c \
      ftzoom.c

OBJ = $(SRC:.c=.obj)


.c.obj:
	$(CC) -c -o$* @&&|
	    $(CFLAGS) $<
|

EXEFILES = ftdump.exe \
           fterror.exe \
           ftlint.exe \
           ftmetric.exe \
           ftsbit.exe \
           ftstring.exe \
           ftstrpnm.exe \
           ftstrtto.exe \
           fttimer.exe \
           ftview.exe \
           ftzoom.exe

!ifndef DEBUG
# Skipped if DEBUG build
all: freetype $(EXEFILES)

dll: the_dll $(EXEFILES)

!else
# Skipped if non-DEBUG build
default_target: debug
dll: the_debug_dll $(EXEFILES)

!endif

debug: freetype_debug $(EXEFILES)

freetype:
	cd $(LIBDIR)
	make -f$(FT_MAKEFILE) all
	cd ..\test

freetype_debug:
	cd $(LIBDIR)
	make -f$(FT_MAKEFILE) -DDEBUG debug
	cd ..\test

the_dll:
	cd $(LIBDIR)
	make -f$(FT_MAKEFILE) -DDLL dll
	cd ..\test
    -copy $(LIBDIR)\$(FT_DLL)

the_debug_dll:
	cd $(LIBDIR)
	make -f$(FT_MAKEFILE) -DDEBUG -DDLL dll
	cd ..\test
    -copy $(LIBDIR)\$(FT_DLL)


# C compilers are unable to include <windows.h> in ANSI mode,
# because of the // comments...
# So we have a special rule for this file, to build it outside ANSI.
$(GDRIVER:.c=.obj):
	$(CC) -c -o$* @&&|
	    $(CFLAGS) -A- $*.c
|


# Borland versions of make are unable to use the $** variable inside
# implicit rules (like .obj.exe:). The job have to be done by hand. :-(
ftzoom.exe: $(G1OBJ) ftzoom.obj common.obj $(LIBDIR)\libttf.lib
	$(CC) $(LDFLAGS) ftzoom.obj $(G1OBJ) common.obj $(LIBDIR)\libttf.lib

ftview.exe: $(GOBJ) ftview.obj common.obj $(LIBDIR)\libttf.lib
	$(CC) $(LDFLAGS) ftview.obj $(GOBJ) common.obj $(LIBDIR)\libttf.lib

ftstring.exe: $(GOBJ) ftstring.obj common.obj $(LIBDIR)\libttf.lib
	$(CC) $(LDFLAGS) ftstring.obj $(GOBJ) common.obj $(LIBDIR)\libttf.lib

ftstrtto.exe: $(GOBJ) ftstrtto.obj common.obj arabic.obj $(LIBDIR)\libttf.lib
	$(CC) $(LDFLAGS) ftstrtto.obj $(GOBJ) common.obj arabic.obj \
	                  $(LIBDIR)\libttf.lib

fttimer.exe: $(G1OBJ) fttimer.obj common.obj $(LIBDIR)\libttf.lib
	$(CC) $(LDFLAGS) fttimer.obj $(G1OBJ) common.obj $(LIBDIR)\libttf.lib

ftlint.exe: ftlint.obj common.obj $(LIBDIR)\libttf.lib
	$(CC) $(LDFLAGS) ftlint.obj common.obj $(LIBDIR)\libttf.lib

ftdump.exe: ftdump.obj common.obj $(LIBDIR)\libttf.lib
	$(CC) $(LDFLAGS) ftdump.obj common.obj $(LIBDIR)\libttf.lib

ftstrpnm.exe: ftstrpnm.obj common.obj $(LIBDIR)\libttf.lib
	$(CC) $(LDFLAGS) ftstrpnm.obj common.obj $(LIBDIR)\libttf.lib

ftsbit.exe: ftsbit.obj common.obj $(LIBDIR)\libttf.lib
	$(CC) $(LDFLAGS) ftsbit.obj common.obj $(LIBDIR)\libttf.lib

ftmetric.exe: ftmetric.obj common.obj $(LIBDIR)\libttf.lib
	$(CC) $(LDFLAGS) ftmetric.obj common.obj $(LIBDIR)\libttf.lib

fterror.exe: fterror.obj common.obj $(LIBDIR)\libttf.lib
	$(CC) $(LDFLAGS) fterror.obj common.obj $(LIBDIR)\libttf.lib


clean: do_clean
	cd $(LIBDIR)
	make -f$(FT_MAKEFILE) clean
	cd ..\test

distclean: do_clean
	cd $(LIBDIR)
	make -f$(FT_MAKEFILE) distclean
	cd ..\test
	-del *.exe
	-del *.dll

do_clean:
	-del *.obj
	-del $(ARCH)\*.obj
	-del *.tds

!include "$(ARCH)\depend.win"

# end of Makefile
