@echo on

@if (%2)==(%3) (@goto labelusage)

@echo Clearing previously set variables ...
@if exist %srcfiles%	(unset srcfiles)
@if exist %exe%		(unset exe)
@if exist %outdir%	(unset outdir)
@if exist %exedir%	(unset exedir)
@if exist %mapfile%	(unset mapfile)
@if exist %methode%	(unset method)
@if exist %arg1%	(unset arg1)
@if exist %arg2%	(unset arg2)
@echo Done

set method=FT
@set arg1=FT
@set arg2=/ST
@set rsp=%1
@set outpath_ext=%2

call profile_config.bat %3 no_skip %outpath_ext%

@rem set outdir=%outdir%%outpath_ext%
@rem echo %outdir%

copy %exedir%%exe%.exe %outdir%
copy %mapfile% %outdir%

unset srcfiles


@rem not to be used when using an rsp file.
@rem for /f %a in (%outdir%%1) do ( @set srcfiles=%srcfiles% /INC %a)

PREP /%method% /SF _pei_primitive /OT %outdir%%exe% /OM /EXCALL @%outdir%%rsp% %outdir%%exe%

rem PREP /%method% /AT /STACK 20 /OT %outdir%%exe% /OM %outdir%%exe%
@if errorlevel == 1521 goto label1521
@echo ^n
@echo You are now ready to start the actual profiling !
goto done


@rem Error handling.

:label1521
@echo ////////////////////////////////////////////////////////////////////////
@echo ERROR: You have to include some modules (obj) which contains the functions 
@echo to be profiled. When adding obj files to the list do not use the (0-0) 
@echo as for line coverage.
@echo ////////////////////////////////////////////////////////////////////////
@goto done

:labelusage
@echo ^n
@echo usage: setup_function_timing file_list.lst path_ext ps_name
@echo where: 
@echo ^n
@echo  -file_list.lst : text file containing list of files to be profiled.
@echo  -path_ext : the relative directory path to the entity test files (umts base: \g23m\condat\ms\src\, gprs base :\g23m\condat\ms\). 
@echo  -ps_name : the name of the protocol stack (e.g. umts, gprs, gprs_wap, gprs_bt, teststack).
@echo ^n
@echo Examples: setup_function_timing.bat sndcp.lst doc\test\ gprs
@echo           setup_function_timing.bat sndcp.lst sndcp\test_usm\ umts
@echo           setup_function_timing.bat xx_tdc.lst xx_tdc\ teststack
@echo ^n
@echo For more information on how to perform the profiling please refer to the user guide: \gpf\doc\test_coverage\8434_521_test_coverage_user_guide.doc
@echo ^n
@goto done

:done