@echo on

@rem if no prameters, print usage text
@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=LV
@set arg1=LV
@set arg2=/SC
@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%

@rem 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)
@rem PREP /%method% /OT %outdir%%exe% /OM /EXCALL %srcfiles% %outdir%%exe%

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

@if errorlevel == 1622 goto label1622
@echo ^n
@echo You are now ready to start the actual profiling !
goto done


@rem Error handling.

:label1622
@echo ////////////////////////////////////////////////////////////////////////
@echo ERROR: You have to mark which line in the sourcefiles, which are to
@echo be profiled e.g. by adding (0-0) to the end of sourcefile for all lines.
@echo ////////////////////////////////////////////////////////////////////////
@goto done

:labelusage
@echo ^n
@echo usage: setup_line_coverage file_list.rsp 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_line_coverage.bat sndcp.rsp doc\test\ gprs
@echo           setup_line_coverage.bat sndcp.rsp sndcp\test_usm\ umts
@echo           setup_line_coverage.bat xx_tdc.rsp 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