#(@) $Id: Makefile,v 1.21 2000/12/05 20:43:36 juanco Exp $

#NOTE: There are bugs in versions of Borland Make prior to v 5.2 that
#       won't let this makefile run.
#       Try getting a Make V5.2 or higher from the Borland Web site, 
#       or from a recent distribution of a Borland compiler.

# this is the version that will be used for the distribution file
VERSION=3.2.5.0
DISTDIR=.\dist
ZIPFILE=$(DISTDIR)\dunit-$(VERSION).zip

DOC_FILES=*.html *.htm *.hlp *.pnp *.gif *.jpg *.jpeg *.txt ChangeLog
PASCAL_FILES=*.pas *.dpr *.inc *.dfm *.res Makefile $(DOC_FILES)

ROOT=.
!include "Rules.mak"

dist: test compile_all bin doc zip

zip:
  -md $(DISTDIR) > nul
  if exist $(ZIPFILE) $(DEL) $(ZIPFILE)
  $(ZIP) -r $(ZIPFILE) $(SRC_DIR)\* $(TESTS_DIR)\* -i $(PASCAL_FILES)
  $(ZIP) $(ZIPFILE) examples\* $(DOC_FILES)
  $(ZIP) -r $(ZIPFILE) examples\collection\* -i $(PASCAL_FILES) -x CVS
  $(ZIP) -r $(ZIPFILE) examples\registration\* -i $(PASCAL_FILES) -x CVS
  $(ZIP) -r $(ZIPFILE) examples\registry\* -i $(PASCAL_FILES) -x CVS
  $(ZIP) -r $(ZIPFILE) examples\structure\* -i $(PASCAL_FILES) -x CVS
  $(ZIP) -r $(ZIPFILE) examples\TListTest\* -i $(PASCAL_FILES) -x CVS
  $(ZIP) -r $(ZIPFILE) Contrib\XPGen\* -i $(PASCAL_FILES) -x CVS
  $(ZIP) -r $(ZIPFILE) $(DOC_DIR)\* -i $(DOC_FILES) -x CVS
  $(ZIP) $(ZIPFILE) Makefile $(DOC_FILES) 
  $(ZIP) $(ZIPFILE) $(FWK_DIR)\* $(BIN_DIR)\UnitTests.exe $(BIN_DIR)\dunit.ini
  @echo.

fullchangelog:
  bash $(ROOT)\tools\cvs2cl.pl --file FullChangeLog  --tags --utc --window 604800 --prune

changelogs:
  bash $(ROOT)\tools\cvs2cl.pl --distributed --tags --utc --window 604800 --hide-filenames --prune
  
compile_all: framework unit_tests contrib examples

contrib: xpgen

framework:  
  @echo.
  @echo [ Building the Framework ]
  -md $(FWK_DIR)
  @cd $(SRC_DIR)
  $(BMAKE)
  @cd ..
  $(COPY) $(SRC_DIR)\GUITestRunner.dfm $(FWK_DIR)
  @echo.

test: framework unit_tests
  @echo.
  @echo [ Testing the Framework ]
  @cd $(TESTS_DIR)
  $(BMAKE) test
  @cd ..
  @echo.

bin: framework 
  @echo.
  @echo [ Building TestSuite Binary ]
  @cd $(TESTS_DIR) 
  $(BMAKE) bin
  @cd ..
  $(COPY) $(TESTS_DIR)\dunit.ini $(BIN_DIR)\dunit.ini 
  @echo.


run: bin
  -$(BIN_DIR)\UnitTests.exe

doc:
  @echo.
  @echo [ Copying API Documentation ]
  @cd helpsrc
  $(BMAKE)
  @cd ..
  @echo.

xpgen: framework
  @echo [ Compiling Contrib: XPGen ]
  @cd contrib\XPGen
  $(BMAKE)
  @cd ..\..
  @echo.

unit_tests: framework
  @echo.
  @echo [ Compiling Unit Tests ]
  @cd tests
  $(BMAKE)
  @cd ..
  @echo.

examples:  registration collection registry tlist structure

registration: framework
  @echo [ Compiling Example: Registration ]
  @cd examples\registration
  $(BMAKE)
  @cd ..\..
  @echo.

collection: framework  
  @echo [ Compiling Example: Collection ]
  @cd examples\collection
  $(BMAKE)
  @cd ..\..
  @echo.

registry: framework
  @echo [ Compiling Example: Registry ]
  @cd examples\registry
  $(BMAKE)
  @cd ..\..
  @echo.

tlist: framework
  @echo [ Compiling Example: TListTest ]
  @cd examples\TListTest
  $(BMAKE)
  @cd ..\..
  @echo.

structure: framework
  @echo [ Compiling Example: Structure ]
  @cd examples\structure
  $(BMAKE)
  @cd ..\..
  @echo.

