REM this example runs only if any compiler is present.
REM On test the microsoft visual studio Version 6 (1998) was used.
REM The followed called batch file sets the PATHs to the visual studio.
REM and sets the environment variable MSC6PATH to the start directory.
REM replace it with any compiler installation to test.
REM MSC6PATH as env variable should be known in generation of script!
call msc6setpath.bat

REM delete the result file to check whether it is generated newly
del _gen.bat

REM it is the recommended form: call a script named jzcmd (unix) or jzcmd.bat (Windows) with this file name and -t:OUTFILE
jzcmd exampleCcompile.jz.bat -t:_gen.bat

REM if all is successfull the execution does not reach this line in Windows because jzcmd.bat does not return (not a call).
REM on Unix the exit is necessary.

REM if nothing is installed, call that script in the local relative file tree
if not exist _gen.bat call ..\..\zbnfjax\batch_template\zbnfjax jzcmd exampleCcompile.jz.bat -t:_gen.bat
if not exist _gen.bat pause
 
::java -cp ../../ZBNF/sf/ZBNF/zbnfjax/zbnf.jar org.vishia.zcmd.JZcmd gen_toolsPc.jz.bat -t:_gen.bat
call _gen.bat
exit /B

==JZcmd==

##The included file is the ZmakeGenCtrl file. It contains the sub routines for make with the details.
include zmakeMsc6.jzcmd;

currdir = <:><&scriptdir><.>;  //The directory where C_source are found.

##The files which are necessary to build the executable.
Fileset srcfiles =
( commonpath=C_source
, src:hello.c
, src:hellosub.c
);

  
##The includ path consists of some path, which are written as Fileset too.
##Here relative path are used. Lastly absolute ones can be build with them. Base for relative to absolute is the currdir.
##  
Fileset incPathSet =
( commonpath=C_source
, inc
);


Filepath objfiles = "test/obj/*.obj";

##The main routine, can have some maybe commented call subroutine for flexibility.
main(){
  del <:><&scriptdir>/obj/*<.>; 
  call openDependencyCheck( cfgfile = Filepath "cfgCheckDep.cfg" , depfile = Filepath dependencies.txt);
  call makeExampleBatch();
  //call makeExampleJZcmd();
  call closeDependencyCheck();
}


##One of the zmake user routines.
sub makeExampleBatch(){
  <+>@echo off
    echo batch file generated by JZcmd
  <.+>
  <+>
    call msc6setpath.bat
  <.+>  ;

  zmake test/test.exe := c2exeBatch(..:&srcfiles, incPathSet = Fileset ..:&incPathSet, objDirExt= Filepath obj/*.obj);

  <+>
    ::pause
  <.+close>  
  Stringjar msg;
  <+out>Calctime before cmd: <&jzcmd.calctime()> <.+n>
  msg += cmd cmd.exe /C start cmd.exe /C _gen.bat;
  if errorlevel 1 {
    <+out><&error><.n+>
  }
  Num calctime = &jzcmd.calctime();
  <+out><&msg><.+n>
  <+out>Calculation time: <&calctime> <.+n>
  
}


##One of the zmake user routines.
sub makeExampleJZcmd(){

  zmake test/test.exe := c2exejz(..:&srcfiles, incPathSet = Fileset ..:&incPathSet, objDirExt= Filepath obj/*.obj);
  Num calctime = &jzcmd.calctime();
  <+out>Calculation time: <&calctime> <.+n>

}

