# This file is part of the FreeType project.
#
# It builds the library and test programs for BC++ under MSDOS, large model.
#
# Tested with Borland C++ v.3.1, 4.02, 5.0
# You will need Borland MAKE (v.3.6 and above should be OK, for oldest
# versions refer to the instructions below).
#
#
# Use this file while in the 'test' directory with the following statement:
#
#   make -farch\msdos\Makefile.BC
#
#
# Debug versions can be obtained with
#
#   make -DDEBUG -farch\msdos\Makefile.BC
#
# A special version enabled to handle big fonts (with more than 16,384
# glyphs) can be obtained with
#
#   make -DBIGFONTS -farch\msdos\Makefile.BC

ARCH = arch\msdos
FT_MAKEFILE = $(ARCH)\Makefile.BC

CC = bcc

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

# Credits go to Dave Hoo <dhoo@flash.net> for pointing out that modern
# Borland compilers (from BC++ 3.1 on) can increase the limit of
# the length of identifiers.
!if ! $d(DEBUG)
CFLAGS = -ml -A -O2 -3 -i40 $(INCDIRS) $(SPURIOUS_WARNINGS)
LDFLAGS = -ml
!else
CFLAGS = -v -N -ml -A -i40 $(INCDIRS) $(SPURIOUS_WARNINGS)
LDFLAGS = -v -ml
!endif


# full-screen MSDOS driver
GDRIVER = $(ARCH)\.\gfs_dos.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

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

!endif

debug: freetype_debug $(EXEFILES)

!if $d(BIGFONTS)
MAKEBIG = -DBIGFONTS
!endif

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

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


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

.obj.exe:
	$(CC) -e$* @&&|
	    $(LDFLAGS) $**
|

# Borland versions of make are unable to use the $** variable inside
# implicit rules (like .obj.exe:). The job has 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

do_clean:
	-del *.obj
	-del $(ARCH)\*.obj
	del time.h		# clean the ugly hack for Turbo C...

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

# end of Makefile
