@echo off

rem deleting possible previous demo generated files.
if exist MON.sym del MON.sym
if exist MON.dat del MON.dat
if exist profile.txt del profile.txt
if "%OS%" == "Windows_NT" goto is_nt
if exist CTCHTML\index.html deltree /y CTCHTML
goto over
:is_nt
if exist CTCHTML rmdir /s /q CTCHTML
:over

echo.
echo In this example we have a main program (main.c), which we
echo do not instrument. The main program calls two static libraries
echo (in files strutil.c and reverse.c correspondingly), which we
echo instrument. We have a makefile for doing the builds.
echo.
echo First we clean the project by issuing command:
echo.
echo nmake clean
echo.
pause
nmake clean

echo.
echo Now we compile the main.c file without ctc, as follows:
echo.
echo cl -c main.c
echo.
pause
cl -c main.c

echo.
echo Now we compile the rest of the project files by the makefile.
echo Normally it would be done as follows
echo. 
echo nmake all
echo.
echo But we issue command:
echo.
echo ctcwrap -i m nmake all
echo.
echo instead. This makes the build as "ctc-build". Note that main.c is
echo not recompiled (i.e. it remains as uninstrumented).
echo.
pause
call ctcwrap -i m nmake all

echo.
echo As a result we have instrumented executable multilib.exe. Let's run it:
echo.

pause
echo multilib.exe

multilib.exe

echo.
pause
echo Now we run ctcpost to get profile listing to stdout
echo.
echo To do this we run command:
echo ctcpost MON.sym MON.dat -p - "|" more
echo.
pause

ctcpost MON.sym MON.dat -p - | more

echo.
pause
echo Now we generate the same listing to a file and convert it
echo to HTML form with commands:
echo.
echo ctcpost MON.sym MON.dat -p profile.txt
echo ctc2html -i profile.txt -nsb
echo.
pause

ctcpost MON.sym MON.dat -p profile.txt
call ctc2html -i profile.txt -nsb

echo.
echo HTML-browsable files can now be found from subdirectory CTCHTML.
echo Browsing starts from file index.html.
echo.
echo ---End of demo---
