#
# $Id$
#

#
# Makefile for Harbour Project for Microsoft Visual C (32 bits)
#

#
# NOTE: You can use these envvars to configure the make process:
#       (note that these are all optional)
#
#       CFLAGS       - Extra C compiler options for libraries and for 
#                      executables
#       C_USR        - Extra C compiler options for libraries and for 
#                      executables (GNU make compatible envvar)
#       CLIBFLAGS    - Extra C compiler options for the libraries
#       HARBOURFLAGS - Extra Harbour compiler options
#       PRG_USR      - Extra Harbour compiler options
#                      (GNU make compatible envvar)
#       HB_GT_LIB    - To override the default GT driver
#                      (search for HB_GT_LIBS for a list of values)
#

#
# Notes about this makefile:
#
# 1. To add new files to a dependancy list, add an obj name to one of the
#    OBJ lists for the appropriate library.
#    NOTE: put .prg related obj's last in the lib list.
#
# 2. This is a recursive script.  If you change the name of this file,
#    be sure to change MK_FILE (a few lines down) to the new name as well.
#
# 3. Recurrsion rules are quite simple:
#     If you specifiy /a on the command line, files in the obj\vc dir
#     will be deleted, and when nmake recurses, it's without the /a flag
#
#     If a .prg.obj rule is fired, nmake will execute this script with
#     a specific target as a parameter immediatley after compiling a given
#     set of prg files.
#      ie: Harbour $<
#          nmake /fmakefile.vc obj\vc\rtl.lib2
#     which will simply get make to re-evaluate the dependancy list for the
#     lib, and as a result, it will execute the C compiler using the .c.obj
#     rule below to create the obj's for the prg's that were created just
#     prior to the recurrsive call. Once the obj's are created, the
#     recurrsion is complete.
#     See additional notes under RTL.LIB below.
#

MK_FILE      = makefile.vc
MK_FLAGS     = $(MAKEFLAGS: =)

BIN_DIR      = bin\vc
LIB_DIR      = lib\vc
OBJ_DIR      = obj\vc

#
# Directory macros. These should never have to change.
#

INCLUDE_DIR  = include
COMMON_DIR   = source\common
COMPILER_DIR = source\compiler
DEBUG_DIR    = source\debug
LANG_DIR     = source\lang
MACRO_DIR    = source\macro
PP_DIR       = source\pp
RDD_DIR      = source\rdd
RTL_DIR      = source\rtl
VM_DIR       = source\vm
HBRUN_DIR    = utils\hbrun
HBTEST_DIR   = utils\hbtest
HBDOC_DIR    = utils\hbdoc
HBPP_DIR     = utils\hbpp

#
# C compiler definition and C flags. These should never have to change.
#

AS             = masm
CFLAGS         = -I$(INCLUDE_DIR) -TP -W3 -nologo $(C_USR) $(CFLAGS)
CLIBFLAGS      = -c $(CFLAGS) $(CLIBFLAGS)
CLIBFLAGSDEBUG = -Zi $(CLIBFLAGS)
HARBOURFLAGS   = -i$(INCLUDE_DIR) -n -q0 -w -es2 -gc0 $(PRG_USR) $(HARBOURFLAGS)
LDFLAGS        = $(LDFLAGS)

#
# Macros to access our library names
#

COMMON_LIB   = $(LIB_DIR)\common.lib
DBFCDX_LIB   = $(LIB_DIR)\dbfcdx.lib
DBFNTX_LIB   = $(LIB_DIR)\dbfntx.lib
DEBUG_LIB    = $(LIB_DIR)\debug.lib
LANG_LIB     = $(LIB_DIR)\lang.lib
MACRO_LIB    = $(LIB_DIR)\macro.lib
NULSYS_LIB   = $(LIB_DIR)\nulsys.lib
PP_LIB       = $(LIB_DIR)\pp.lib
RDD_LIB      = $(LIB_DIR)\rdd.lib
RTL_LIB      = $(LIB_DIR)\rtl.lib
VM_LIB       = $(LIB_DIR)\vm.lib

GTPCA_LIB    = $(LIB_DIR)\gtpca.lib
GTSTD_LIB    = $(LIB_DIR)\gtstd.lib
GTWIN_LIB    = $(LIB_DIR)\gtwin.lib

HARBOUR_EXE  = $(BIN_DIR)\harbour.exe
HBPP_EXE     = $(BIN_DIR)\hbpp.exe
HBRUN_EXE    = $(BIN_DIR)\hbrun.exe
HBTEST_EXE   = $(BIN_DIR)\hbtest.exe
HBDOC_EXE    = $(BIN_DIR)\hbdoc.exe

!ifndef HB_GT_LIB
HB_GT_LIB = $(GTWIN_LIB)
!else
HB_GT_LIB = $(LIB_DIR)\$(HB_GT_LIB).lib
!endif

#
# Rules
#

.SUFFIXES: .prg .lib .c .obj .asm

# override builtin

.c.obj::
   $(CC) $(CLIBFLAGS) -Fo$(OBJ_DIR)\ $<

#
#
#

# TODO: Add GTSLN and GTCRS

LIBLIST = \
   $(RTL_LIB) \
   $(COMMON_LIB) \
   $(DEBUG_LIB) \
   $(MACRO_LIB) \
   $(PP_LIB) \
   $(LANG_LIB) \
   $(RDD_LIB) \
   $(DBFCDX_LIB) \
   $(DBFNTX_LIB) \
   $(NULSYS_LIB) \
   $(VM_LIB) \
   $(HB_GT_LIB)

#
# macro.lib needs to be listed twice
#

LIBS = \
   $(LIBLIST) \
   $(MACRO_LIB)

#
# programs that require user32.lib (for OemToAnsi)
#

LIBS2 = \
   $(LIBS) \
   user32.lib

#
# RTL.LIB rules
#
# how this works:
#
#  {target>.prg{objdir}.obj
#  Harbour (flags) -oobjdir\ $<
#    The list of dependant prgs is sent to the harbour compiler
#    Since the rule is .prg to .obj and the compiler spits out
#    C code (as we use it), we need to get those into obj format.
#    Since $(<:.prg=.c) doesn't work, we execute this script again
#    with a specific target via:
#  nMake /fmakefile.vc target.lib2
#    If you view that target at the bottom of this file, all it does
#    is cause make to evaluate the obj list of dependants which then
#    causes the .c.obj rule above to fire. (by inference)

{$(RTL_DIR)}.c{$(OBJ_DIR)}.obj::
   $(CC) $(CLIBFLAGS) -Fo$(OBJ_DIR)\ $<

{$(RTL_DIR)}.prg{$(OBJ_DIR)}.obj::
   $(HARBOUR_EXE) $(HARBOURFLAGS) -o$(OBJ_DIR)\ $<
   $(MAKE) -nologo /$(MK_FLAGS) /f$(MK_FILE) $(RTL_LIB)2

RTL_LIB_OBJS = \
   $(OBJ_DIR)\abs.obj \
   $(OBJ_DIR)\accept.obj \
   $(OBJ_DIR)\ampm.obj \
   $(OBJ_DIR)\at.obj \
   $(OBJ_DIR)\binnum.obj \
   $(OBJ_DIR)\binnumx.obj \
   $(OBJ_DIR)\box.obj \
   $(OBJ_DIR)\chrasc.obj \
   $(OBJ_DIR)\colorind.obj \
   $(OBJ_DIR)\console.obj \
   $(OBJ_DIR)\copyfile.obj \
   $(OBJ_DIR)\datec.obj \
   $(OBJ_DIR)\dates.obj \
   $(OBJ_DIR)\dateshb.obj \
   $(OBJ_DIR)\datesx.obj \
   $(OBJ_DIR)\defpath.obj \
   $(OBJ_DIR)\descend.obj \
   $(OBJ_DIR)\dir.obj \
   $(OBJ_DIR)\dirdrive.obj \
   $(OBJ_DIR)\diskspac.obj \
   $(OBJ_DIR)\do.obj \
   $(OBJ_DIR)\empty.obj \
   $(OBJ_DIR)\errorapi.obj \
   $(OBJ_DIR)\filesys.obj \
   $(OBJ_DIR)\fkmax.obj \
   $(OBJ_DIR)\fnsplit.obj \
   $(OBJ_DIR)\fssize.obj \
   $(OBJ_DIR)\fstemp.obj \
   $(OBJ_DIR)\gete.obj \
   $(OBJ_DIR)\gt.obj \
   $(OBJ_DIR)\gtapi.obj \
   $(OBJ_DIR)\gx.obj \
   $(OBJ_DIR)\hardcr.obj \
   $(OBJ_DIR)\inkey.obj \
   $(OBJ_DIR)\is.obj \
   $(OBJ_DIR)\isprint.obj \
   $(OBJ_DIR)\langapi.obj \
   $(OBJ_DIR)\left.obj \
   $(OBJ_DIR)\len.obj \
   $(OBJ_DIR)\lennum.obj \
   $(OBJ_DIR)\math.obj \
   $(OBJ_DIR)\maxrow.obj \
   $(OBJ_DIR)\memofile.obj \
   $(OBJ_DIR)\memoline.obj \
   $(OBJ_DIR)\minmax.obj \
   $(OBJ_DIR)\mlcount.obj \
   $(OBJ_DIR)\mlpos.obj \
   $(OBJ_DIR)\mod.obj \
   $(OBJ_DIR)\mouseapi.obj \
   $(OBJ_DIR)\mousex.obj \
   $(OBJ_DIR)\mtran.obj \
   $(OBJ_DIR)\natmsg.obj \
   $(OBJ_DIR)\net.obj \
   $(OBJ_DIR)\oemansi.obj \
   $(OBJ_DIR)\oldbox.obj \
   $(OBJ_DIR)\oldclear.obj \
   $(OBJ_DIR)\pad.obj \
   $(OBJ_DIR)\padc.obj \
   $(OBJ_DIR)\padl.obj \
   $(OBJ_DIR)\padr.obj \
   $(OBJ_DIR)\philes.obj \
   $(OBJ_DIR)\philes53.obj \
   $(OBJ_DIR)\philesx.obj \
   $(OBJ_DIR)\rat.obj \
   $(OBJ_DIR)\replic.obj \
   $(OBJ_DIR)\right.obj \
   $(OBJ_DIR)\round.obj \
   $(OBJ_DIR)\run.obj \
   $(OBJ_DIR)\samples.obj \
   $(OBJ_DIR)\saverest.obj \
   $(OBJ_DIR)\scroll.obj \
   $(OBJ_DIR)\seconds.obj \
   $(OBJ_DIR)\set.obj \
   $(OBJ_DIR)\setcolor.obj \
   $(OBJ_DIR)\setcurs.obj \
   $(OBJ_DIR)\setpos.obj \
   $(OBJ_DIR)\setposbs.obj \
   $(OBJ_DIR)\shadow.obj \
   $(OBJ_DIR)\soundex.obj \
   $(OBJ_DIR)\space.obj \
   $(OBJ_DIR)\str.obj \
   $(OBJ_DIR)\strcase.obj \
   $(OBJ_DIR)\strings.obj \
   $(OBJ_DIR)\strmatch.obj \
   $(OBJ_DIR)\strtran.obj \
   $(OBJ_DIR)\strzero.obj \
   $(OBJ_DIR)\stuff.obj \
   $(OBJ_DIR)\substr.obj \
   $(OBJ_DIR)\tone.obj \
   $(OBJ_DIR)\trace.obj \
   $(OBJ_DIR)\transfrm.obj \
   $(OBJ_DIR)\trim.obj \
   $(OBJ_DIR)\type.obj \
   $(OBJ_DIR)\val.obj \
   $(OBJ_DIR)\valtostr.obj \
   $(OBJ_DIR)\valtype.obj \
   $(OBJ_DIR)\version.obj \
   $(OBJ_DIR)\word.obj \
   $(OBJ_DIR)\xhelp.obj \
   $(OBJ_DIR)\xsavescr.obj \
   \
   $(OBJ_DIR)\achoice.obj \
   $(OBJ_DIR)\adir.obj \
   $(OBJ_DIR)\alert.obj \
   $(OBJ_DIR)\browdb.obj \
   $(OBJ_DIR)\browdbx.obj \
   $(OBJ_DIR)\browse.obj \
   $(OBJ_DIR)\dbedit.obj \
   $(OBJ_DIR)\devoutp.obj \
   $(OBJ_DIR)\dircmd.obj \
   $(OBJ_DIR)\dummy.obj \
   $(OBJ_DIR)\errorsys.obj \
   $(OBJ_DIR)\fieldbl.obj \
   $(OBJ_DIR)\getlist.obj \
   $(OBJ_DIR)\getsys.obj \
   $(OBJ_DIR)\input.obj \
   $(OBJ_DIR)\memoedit.obj \
   $(OBJ_DIR)\memvarbl.obj \
   $(OBJ_DIR)\menuto.obj \
   $(OBJ_DIR)\objfunc.obj \
   $(OBJ_DIR)\readkey.obj \
   $(OBJ_DIR)\readvar.obj \
   $(OBJ_DIR)\setfunc.obj \
   $(OBJ_DIR)\setkey.obj \
   $(OBJ_DIR)\setta.obj \
   $(OBJ_DIR)\tbcolumn.obj \
   $(OBJ_DIR)\tbrowse.obj \
   $(OBJ_DIR)\tclass.obj \
   $(OBJ_DIR)\teditor.obj \
   $(OBJ_DIR)\terror.obj \
   $(OBJ_DIR)\text.obj \
   $(OBJ_DIR)\tget.obj \
   $(OBJ_DIR)\tgetlist.obj \
   $(OBJ_DIR)\tlabel.obj \
   $(OBJ_DIR)\treport.obj \
   $(OBJ_DIR)\typefile.obj \
   $(OBJ_DIR)\wait.obj

#
# LANG.LIB rules
#

{$(LANG_DIR)}.c{$(OBJ_DIR)}.obj::
   $(CC) $(CLIBFLAGS) -Fo$(OBJ_DIR)\ $<

LANG_LIB_OBJS = \
   $(OBJ_DIR)\msgca.obj \
   $(OBJ_DIR)\msgen.obj \
   $(OBJ_DIR)\msges.obj \
   $(OBJ_DIR)\msgeu.obj \
   $(OBJ_DIR)\msgfr.obj \
   $(OBJ_DIR)\msggl.obj \
   $(OBJ_DIR)\msghe862.obj \
   $(OBJ_DIR)\msghewin.obj \
   $(OBJ_DIR)\msghu852.obj \
   $(OBJ_DIR)\msghucwi.obj \
   $(OBJ_DIR)\msghuwin.obj \
   $(OBJ_DIR)\msgis850.obj \
   $(OBJ_DIR)\msgpt.obj \
   $(OBJ_DIR)\msgro.obj 

#
# MACRO.LIB rules
#

{$(MACRO_DIR)}.c{$(OBJ_DIR)}.obj::
   $(CC) $(CLIBFLAGS) -Fo$(OBJ_DIR)\ $<

MACRO_LIB_OBJS = \
   $(OBJ_DIR)\macrol.obj \
   $(OBJ_DIR)\macroy.obj \
   $(OBJ_DIR)\macroa.obj \
   $(OBJ_DIR)\macrob.obj \
   $(OBJ_DIR)\macroc.obj

#
# RDD.LIB rules
#

{$(RDD_DIR)}.c{$(OBJ_DIR)}.obj::
   $(CC) $(CLIBFLAGS) -Fo$(OBJ_DIR)\ $<

{$(RDD_DIR)}.prg{$(OBJ_DIR)}.obj::
   $(HARBOUR_EXE) $(HARBOURFLAGS) -o$(OBJ_DIR)\ $<
   $(MAKE) -nologo /$(MK_FLAGS) /f$(MK_FILE) $(RDD_LIB)2

RDD_LIB_OBJS = \
   $(OBJ_DIR)\dbcmd.obj \
   $(OBJ_DIR)\dbf1.obj \
   $(OBJ_DIR)\dbnubs.obj \
   $(OBJ_DIR)\delim1.obj \
   $(OBJ_DIR)\sdf1.obj \
   \
   $(OBJ_DIR)\dbf0.obj \
   $(OBJ_DIR)\dbstrux.obj \
   $(OBJ_DIR)\delim0.obj \
   $(OBJ_DIR)\rddord.obj \
   $(OBJ_DIR)\rddsys.obj \
   $(OBJ_DIR)\sdf0.obj


#
# NULSYS.LIB rules
#

{$(RDD_DIR)\nulsys}.c{$(OBJ_DIR)}.obj::
   $(CC) $(CLIBFLAGS) -Fo$(OBJ_DIR)\ $<

{$(RDD_DIR)\nulsys}.prg{$(OBJ_DIR)}.obj::
   $(HARBOUR_EXE) $(HARBOURFLAGS) -o$(OBJ_DIR)\ $<
   $(MAKE) -nologo /$(MK_FLAGS) /f$(MK_FILE) $(NULSYS_LIB)2

NULSYS_LIB_OBJS = \
   $(OBJ_DIR)\nulsys.obj


#
# DBFNTX.LIB rules
#

{$(RDD_DIR)\dbfntx}.c{$(OBJ_DIR)}.obj::
   $(CC) $(CLIBFLAGS) -Fo$(OBJ_DIR)\ $<

{$(RDD_DIR)\dbfntx}.prg{$(OBJ_DIR)}.obj::
   $(HARBOUR_EXE) $(HARBOURFLAGS) -o$(OBJ_DIR)\ $<
   $(MAKE) -nologo /$(MK_FLAGS) /f$(MK_FILE) $(DBFNTX_LIB)2

DBFNTX_LIB_OBJS = \
   $(OBJ_DIR)\dbfntx1.obj \
   \
   $(OBJ_DIR)\dbfntx0.obj

#
# DBFCDX.LIB rules
#

{$(RDD_DIR)\dbfcdx}.c{$(OBJ_DIR)}.obj::
   $(CC) $(CLIBFLAGS) -Fo$(OBJ_DIR)\ $<

{$(RDD_DIR)\dbfcdx}.prg{$(OBJ_DIR)}.obj::
   $(HARBOUR_EXE) $(HARBOURFLAGS) -o$(OBJ_DIR)\ $<
   $(MAKE) -nologo /$(MK_FLAGS) /f$(MK_FILE) $(DBFCDX_LIB)2

DBFCDX_LIB_OBJS = \
   $(OBJ_DIR)\dbfcdx1.obj \
   \
   $(OBJ_DIR)\dbfcdx0.obj

#
# PP.LIB rules
#

{$(PP_DIR)}.c{$(OBJ_DIR)}.obj::
   $(CC) $(CLIBFLAGS) -Fo$(OBJ_DIR)\ $<

PP_LIB_OBJS = \
   $(OBJ_DIR)\ppcore.obj \
   $(OBJ_DIR)\ppcomp.obj \
   $(OBJ_DIR)\pplib.obj \
   $(OBJ_DIR)\pptable.obj

#
# DEBUG.LIB rules
#

{$(DEBUG_DIR)}.c{$(OBJ_DIR)}.obj::
   $(CC) $(CLIBFLAGS) -Fo$(OBJ_DIR)\ $<

{$(DEBUG_DIR)}.prg{$(OBJ_DIR)}.obj::
   $(HARBOUR_EXE) $(HARBOURFLAGS) -o$(OBJ_DIR)\ $<
   $(MAKE) -nologo /$(MK_FLAGS) /f$(MK_FILE) $(DEBUG_LIB)2

DEBUG_LIB_OBJS = \
   $(OBJ_DIR)\dbgmenu.obj \
   $(OBJ_DIR)\dbgtmenu.obj \
   $(OBJ_DIR)\dbgtwin.obj \
   $(OBJ_DIR)\debugger.obj \
   $(OBJ_DIR)\tbrwtext.obj

#
# COMMON.LIB rules
#

{$(COMMON_DIR)}.c{$(OBJ_DIR)}.obj::
   $(CC) $(CLIBFLAGS) -Fo$(OBJ_DIR)\ $<

COMMON_LIB_OBJS = \
   $(OBJ_DIR)\hbfsapi.obj \
   $(OBJ_DIR)\hbstr.obj \
   $(OBJ_DIR)\hbtrace.obj \
   $(OBJ_DIR)\hbver.obj \
   $(OBJ_DIR)\expropt1.obj \
   $(OBJ_DIR)\expropt2.obj \
   $(OBJ_DIR)\reserved.obj

#
# VM.LIB rules
#

{$(VM_DIR)}.asm{$(OBJ_DIR)}.obj:
   $(AS) $< $@ nul nul

{$(VM_DIR)}.c{$(OBJ_DIR)}.obj::
   $(CC) $(CLIBFLAGS) -Fo$(OBJ_DIR)\ $<

{$(VM_DIR)}.prg{$(OBJ_DIR)}.obj::
   $(HARBOUR_EXE) $(HARBOURFLAGS) -o$(OBJ_DIR)\ $<
   $(MAKE) -nologo /$(MK_FLAGS) /f$(MK_FILE) $(VM_LIB)2

VM_LIB_OBJS = \
   $(OBJ_DIR)\arrays.obj \
   $(OBJ_DIR)\arrayshb.obj \
   $(OBJ_DIR)\asort.obj \
   $(OBJ_DIR)\break.obj \
   $(OBJ_DIR)\classes.obj \
   $(OBJ_DIR)\cmdarg.obj \
   $(OBJ_DIR)\codebloc.obj \
   $(OBJ_DIR)\debug.obj \
   $(OBJ_DIR)\dynsym.obj \
   $(OBJ_DIR)\eval.obj \
   $(OBJ_DIR)\extend.obj \
   $(OBJ_DIR)\fm.obj \
   $(OBJ_DIR)\hvm.obj \
   $(OBJ_DIR)\initexit.obj \
   $(OBJ_DIR)\initsymb.obj \
   $(OBJ_DIR)\itemapi.obj \
   $(OBJ_DIR)\macro.obj \
   $(OBJ_DIR)\maindll.obj \
   $(OBJ_DIR)\mainstd.obj \
   $(OBJ_DIR)\mainwin.obj \
   $(OBJ_DIR)\memvars.obj \
   $(OBJ_DIR)\memvclip.obj \
   $(OBJ_DIR)\pcount.obj \
   $(OBJ_DIR)\proc.obj \
   $(OBJ_DIR)\pvalue.obj \
   $(OBJ_DIR)\runner.obj \
   \
   $(OBJ_DIR)\symbols.obj \
   \
   $(OBJ_DIR)\harbinit.obj

#
# GTPCA.LIB rules
#

{$(RTL_DIR)\gtpca}.c{$(OBJ_DIR)}.obj::
   $(CC) $(CLIBFLAGS) -Fo$(OBJ_DIR)\ $<

GTPCA_LIB_OBJS = \
   $(OBJ_DIR)\gtpca.obj \
   $(OBJ_DIR)\mousepca.obj 

#
# GTSTD.LIB rules
#

{$(RTL_DIR)\gtstd}.c{$(OBJ_DIR)}.obj::
   $(CC) $(CLIBFLAGS) -Fo$(OBJ_DIR)\ $<

GTSTD_LIB_OBJS = \
   $(OBJ_DIR)\gtstd.obj \
   $(OBJ_DIR)\mousestd.obj 

#
# GTWIN.LIB rules
#

{$(RTL_DIR)\gtwin}.c{$(OBJ_DIR)}.obj::
   $(CC) $(CLIBFLAGS) -Fo$(OBJ_DIR)\ $<

GTWIN_LIB_OBJS = \
   $(OBJ_DIR)\gtwin.obj \
   $(OBJ_DIR)\mousewin.obj 

#
# Our default target
#


!if ( "$(MK_FLAGS)"=="A" )

all: zot \
   $(COMMON_LIB) \
   $(PP_LIB) \
   $(HARBOUR_EXE) \
   $(VM_LIB) \
   $(RTL_LIB) \
   $(MACRO_LIB) \
   $(DEBUG_LIB) \
   $(LANG_LIB) \
   $(RDD_LIB) \
   $(NULSYS_LIB) \
   $(DBFNTX_LIB) \
   $(DBFCDX_LIB) \
   $(GTPCA_LIB) \
   $(GTSTD_LIB) \
   $(GTWIN_LIB) \
   $(HBRUN_EXE) \
   $(HBPP_EXE) \
   $(HBTEST_EXE) \
   $(HBDOC_EXE)

MK_FLAGS = $(MK_FLAGS:A=)

zot:
   -@if exist $(OBJ_DIR)\*.obj del $(OBJ_DIR)\*.obj > nul
   -@if exist $(OBJ_DIR)\*.c del $(OBJ_DIR)\*.c > nul
   -@if exist $(OBJ_DIR)\*.h del $(OBJ_DIR)\*.h > nul
   -@if exist $(BIN_DIR)\*.exe del $(BIN_DIR)\*.exe > nul
   -@if exist $(BIN_DIR)\*.map del $(BIN_DIR)\*.map > nul

!else

all: \
   $(COMMON_LIB) \
   $(PP_LIB) \
   $(HARBOUR_EXE) \
   $(VM_LIB) \
   $(RTL_LIB) \
   $(MACRO_LIB) \
   $(DEBUG_LIB) \
   $(LANG_LIB) \
   $(RDD_LIB) \
   $(NULSYS_LIB) \
   $(DBFNTX_LIB) \
   $(DBFCDX_LIB) \
   $(GTPCA_LIB) \
   $(GTSTD_LIB) \
   $(GTWIN_LIB) \
   $(HBRUN_EXE) \
   $(HBPP_EXE) \
   $(HBTEST_EXE) \
   $(HBDOC_EXE)

!endif

$(HBPP_EXE) : \
   $(HBPP_DIR)\hbpp.c
   $(CC) $(CFLAGS) -Fo$(OBJ_DIR)\ $** -o $(HBPP_EXE) /link $(LDFLAGS) $(PP_LIB) $(COMMON_LIB)

#
# HBRUN.EXE rules
#

$(HBRUN_EXE) : \
   $(HBRUN_DIR)\hbrun.prg \
   $(HBRUN_DIR)\external.prg
   $(HARBOUR_EXE) $(HARBOURFLAGS) -o$(OBJ_DIR)\ $**
   $(CC) $(CFLAGS) -Fo$(OBJ_DIR)\ $(OBJ_DIR)\hbrun.c $(OBJ_DIR)\external.c -o $(HBRUN_EXE) /link $(LDFLAGS) $(LIBS2)

#
# HBTEST.EXE rules
#

$(HBTEST_EXE) : \
   $(HBTEST_DIR)\hbtest.prg \
   $(HBTEST_DIR)\rt_array.prg \
   $(HBTEST_DIR)\rt_date.prg \
   $(HBTEST_DIR)\rt_file.prg \
   $(HBTEST_DIR)\rt_hvm.prg \
   $(HBTEST_DIR)\rt_hvma.prg \
   $(HBTEST_DIR)\rt_math.prg \
   $(HBTEST_DIR)\rt_misc.prg \
   $(HBTEST_DIR)\rt_str.prg \
   $(HBTEST_DIR)\rt_stra.prg \
   $(HBTEST_DIR)\rt_trans.prg
   $(HARBOUR_EXE) $(HARBOURFLAGS) -o$(OBJ_DIR)\ $**
   $(CC) $(CFLAGS) -Fo$(OBJ_DIR)\ $(OBJ_DIR)\hbtest.c $(OBJ_DIR)\rt_array.c $(OBJ_DIR)\rt_date.c $(OBJ_DIR)\rt_file.c $(OBJ_DIR)\rt_hvm.c $(OBJ_DIR)\rt_hvma.c $(OBJ_DIR)\rt_math.c $(OBJ_DIR)\rt_misc.c $(OBJ_DIR)\rt_str.c $(OBJ_DIR)\rt_stra.c $(OBJ_DIR)\rt_trans.c -o $(HBTEST_EXE) /link $(LDFLAGS) $(LIBS)

#
# HBDOC.EXE rules
#

$(HBDOC_EXE) : \
   $(HBDOC_DIR)\hbdoc.prg \
   $(HBDOC_DIR)\genos2.prg \
   $(HBDOC_DIR)\gentrf.prg \
   $(HBDOC_DIR)\genng.prg  \
   $(HBDOC_DIR)\genhtm.prg \
   $(HBDOC_DIR)\genrtf.prg \
   $(HBDOC_DIR)\genhpc.prg \
   $(HBDOC_DIR)\genasc.prg \
   $(HBDOC_DIR)\html.prg \
   $(HBDOC_DIR)\ng.prg \
   $(HBDOC_DIR)\os2.prg \
   $(HBDOC_DIR)\rtf.prg \
   $(HBDOC_DIR)\troff.prg \
   $(HBDOC_DIR)\fclass1.prg \
   $(HBDOC_DIR)\ffile1.prg \
   $(HBDOC_DIR)\ft_funcs.prg
   $(HARBOUR_EXE) $(HARBOURFLAGS) -o$(OBJ_DIR)\ $**
   $(CC) $(CFLAGS) -Fo$(OBJ_DIR)\ $(OBJ_DIR)\hbdoc.c $(OBJ_DIR)\genos2.c $(OBJ_DIR)\gentrf.c $(OBJ_DIR)\genng.c $(OBJ_DIR)\genhtm.c $(OBJ_DIR)\genrtf.c $(OBJ_DIR)\genhpc.c $(OBJ_DIR)\genasc.c $(OBJ_DIR)\html.c $(OBJ_DIR)\ng.c $(OBJ_DIR)\os2.c $(OBJ_DIR)\rtf.c $(OBJ_DIR)\troff.c $(OBJ_DIR)\fclass1.c $(OBJ_DIR)\ffile1.c $(OBJ_DIR)\ft_funcs.c -o $(HBDOC_EXE) /link $(LDFLAGS) $(LIBS2)

#
# HARBOUR.EXE rules
#

$(HARBOUR_EXE) : \
   $(COMPILER_DIR)\harbour.c \
   $(OBJ_DIR)\harboury.c \
   $(OBJ_DIR)\harbourl.c \
   $(COMPILER_DIR)\hbusage.c \
   $(COMPILER_DIR)\hbpcode.c \
   $(COMPILER_DIR)\hbfix.c \
   $(COMPILER_DIR)\hbfunchk.c \
   $(COMPILER_DIR)\cmdcheck.c \
   $(COMPILER_DIR)\hbgenerr.c \
   $(COMPILER_DIR)\genobj32.c \
   $(COMPILER_DIR)\genc.c \
   $(COMPILER_DIR)\genhrb.c \
   $(COMPILER_DIR)\genjava.c \
   $(COMPILER_DIR)\expropta.c \
   $(COMPILER_DIR)\exproptb.c \
   $(COMPILER_DIR)\exproptc.c
   -echo. > $(OBJ_DIR)\unistd.h
   $(CC) $(CFLAGS) -I$(OBJ_DIR) -Fo$(OBJ_DIR)\ -w $** -o $(HARBOUR_EXE) /link $(LDFLAGS) $(PP_LIB) $(COMMON_LIB)
   -del $(OBJ_DIR)\unistd.h


#
# Library dependencies and build rules
#

$(RTL_LIB) : $(RTL_LIB_OBJS)
   lib /out:$@ $**

$(COMMON_LIB) : $(COMMON_LIB_OBJS)
   lib /out:$@ $**

$(DEBUG_LIB) : $(DEBUG_LIB_OBJS)
   lib /out:$@ $**

$(MACRO_LIB) : $(MACRO_LIB_OBJS)
   lib /out:$@ $**

$(PP_LIB) : $(PP_LIB_OBJS)
   lib /out:$@ $**

$(LANG_LIB) : $(LANG_LIB_OBJS)
   lib /out:$@ $**

$(RDD_LIB) : $(RDD_LIB_OBJS)
   lib /out:$@ $**

$(DBFCDX_LIB) : $(DBFCDX_LIB_OBJS)
   lib /out:$@ $**

$(DBFNTX_LIB) : $(DBFNTX_LIB_OBJS)
   lib /out:$@ $**

$(NULSYS_LIB) : $(NULSYS_LIB_OBJS)
   lib /out:$@ $**

$(VM_LIB) : $(VM_LIB_OBJS)
   lib /out:$@ $**

$(GTPCA_LIB) : $(GTPCA_LIB_OBJS)
   lib /out:$@ $**

$(GTSTD_LIB) : $(GTSTD_LIB_OBJS)
   lib /out:$@ $**

$(GTWIN_LIB) : $(GTWIN_LIB_OBJS)
   lib /out:$@ $**

#
# HARBOUR.EXE dependencies
#

$(OBJ_DIR)\harboury.c : $(COMPILER_DIR)\harbour.y
   bison -d -o$(OBJ_DIR)\harboury.c $(COMPILER_DIR)\harbour.y

$(OBJ_DIR)\harbourl.c : $(COMPILER_DIR)\harbour.l
   flex -i -8 -o$(OBJ_DIR)\harbourl.c $(COMPILER_DIR)\harbour.l

#
# MACRO.LIB dependencies
#

$(OBJ_DIR)\macroy.c : $(MACRO_DIR)\macro.y
   bison -d -p hb_comp -o$(OBJ_DIR)\macroy.c $(MACRO_DIR)\macro.y

$(OBJ_DIR)\macrol.c : $(OBJ_DIR)\macroy.c $(MACRO_DIR)\macro.l
   flex -i -8 -Phb_comp -o$(OBJ_DIR)\macrol.c $(MACRO_DIR)\macro.l

$(OBJ_DIR)\macroy.obj : $(OBJ_DIR)\macroy.c
   $(CC) $(CLIBFLAGS) -w -Fo$@ $**

$(OBJ_DIR)\macrol.obj : $(OBJ_DIR)\macrol.c
   -echo. > $(OBJ_DIR)\unistd.h
   $(CC) $(CLIBFLAGS) -I$(OBJ_DIR) -w -Fo$@ $**
   -del $(OBJ_DIR)\unistd.h


# dummy targets used for prg to c creation

$(RTL_LIB)2    : $(RTL_LIB_OBJS)
$(COMMON_LIB)2 : $(COMMON_LIB_OBJS)
$(DEBUG_LIB)2  : $(DEBUG_LIB_OBJS)
$(MACRO_LIB)2  : $(MACRO_LIB_OBJS)
$(PP_LIB)2     : $(PP_LIB_OBJS)
$(RDD_LIB)2    : $(RDD_LIB_OBJS)
$(DBFCDX_LIB)2 : $(DBFCDX_LIB_OBJS)
$(DBFNTX_LIB)2 : $(DBFNTX_LIB_OBJS)
$(NULSYS_LIB)2 : $(NULSYS_LIB_OBJS)
$(VM_LIB)2     : $(VM_LIB_OBJS)
$(GTPCA_LIB)2  : $(GTPCA_LIB_OBJS)
$(GTSTD_LIB)2  : $(GTSTD_LIB_OBJS)
$(GTWIN_LIB)2  : $(GTWIN_LIB_OBJS)

