# CL_WIN.PM
#
# Copyright (c) 1997-1999 Symbian Ltd.  All rights reserved.
#


package Cl_win;

# declare variables global for module
my @Win32LibList=();
my $BaseAddressFlag;
my $NoBrowseInfo;
my $Win32Resrc;

require Exporter;
@ISA=qw(Exporter);
@EXPORT=qw(
	PMHelp_Mmp
	PMPlatProcessMmp

		PMGetCleanFileList
		PMGetWorkPathList

	PMStartBldList
		PMBld
	PMStartSubPrjList
		PMStartSubPrj
			PMStartSubPrjSrc
			PMSubPrjSrcDepend
				PMSubPrjSrcBldDepend
				PMEndSubPrjSrcBld
			PMEndSubPrjSrc
			PMStartSubPrjResrc
			PMSubPrjResrcDepend
				PMSubPrjResrcBld
			PMEndSubPrjResrc
			PMStartSubPrjBitMapTrg
				PMSubPrjBitMapTrgBld
			PMStartSubPrjAif
				PMSubPrjAifBld
	PMEndSubPrjList
);

use Winutl;

sub PMHelp_Mmp {
	&Winutl_Help_Mmp;
}

sub PMPlatProcessMmp {

	&Winutl_DoMmp;
	$BaseAddressFlag=&Winutl_BaseAddress;
	$BaseAddressFlag=~s/^(.+$)$/ \/base:$1/o;
	$NoBrowseInfo=&Winutl_NoBrowseInfo;
	@Win32LibList=&Winutl_Win32LibList;
	$Win32Resrc=&Winutl_Win32Resrc;
}

sub PMGetCleanFileList {
	my $Aif=&main::Aif;
	my @BaseResrcList=&main::BaseResrcList;
	my @BaseSysResrcList=&main::BaseSysResrcList;
	my $BaseTrg=&main::BaseTrg;
	my @BitMapTrgList=&main::BitMapTrgList;
	my $BldPath=&main::BldPath;
	my $DataPath=&main::DataPath;
	my $DefBaseExt=&main::DefBaseExt;
	my $GenHdrPath=&main::GenHdrPath;
	my @LangList=&main::LangList;
	my $RelPath=&main::RelPath;
	my $TrgPath=&main::TrgPath;

	my @List=&Winutl_GetCleanFileList;
	my $BaseResrc;
	foreach $BaseResrc (@BaseSysResrcList,@BaseResrcList) {
		push @List, "$GenHdrPath$BaseResrc.RSG";
	}
	my $Lang;
	foreach $BaseResrc (@BaseSysResrcList) {
		foreach $Lang (@LangList) {
			push @List, "$RelPath$DataPath$BaseResrc.R$Lang";
		}
	}
	foreach $BaseResrc (@BaseResrcList) {
		foreach $Lang (@LangList) {
			push @List, "$RelPath$TrgPath$BaseResrc.R$Lang";
		}
	}
	if ($Aif) {
		push @List, "$RelPath$TrgPath$Aif";
	}
	foreach (@BitMapTrgList) {
		push @List, "$RelPath$TrgPath$_";
	}
	push @List, "$BldPath$BaseTrg$DefBaseExt.def";
	@List;
}

sub PMGetWorkPathList {
	&Winutl_GetWorkPathList;
}


sub PMStartBldList {
	my $Aif=&main::Aif;
	my @BaseResrcList=&main::BaseResrcList;
	my @BaseSysResrcList=&main::BaseSysResrcList;
	my $BaseTrg=&main::BaseTrg;
	my @BitMapTrgList=&main::BitMapTrgList;
	my @BldList=&main::BldList;
	my $BldPath=&main::BldPath;
	my $ChopDataPath=&main::Path_ChopPath(&main::DataPath);
	my @ChopSysIncPaths=&main::Path_ChopPath(&main::SysIncPaths);
	my $ChopTrgPath=&main::Path_ChopPath(&main::TrgPath);
	my @ChopUserIncPaths=&main::Path_ChopPath(&main::UserIncPaths);
	my $GenTrgType=&main::GenTrgType;
	my @LangList=&main::LangList;
	my @MacroList=&main::MacroList;
	my $RelPath=&main::RelPath;
	my $Trg=&main::Trg;

	&main::Output(
		"\n",
		"!if \"\$(OS)\" == \"Windows_NT\"\n",
		"ERASE = \@erase 2>>nul\n",
		"!else\n",
		"ERASE = \@erase\n",
		"!endif\n",
		"\n",
		"\n",
		"# EPOC DEFINITIONS\n",
		"\n"
	);

	&main::Output(
		"INCDIR  ="
	);
	if (@ChopUserIncPaths) {
		foreach (@ChopUserIncPaths) {
			&main::Output(
				" /I \"$_\""
			);
		}
	}
	foreach (@ChopSysIncPaths) {
		&main::Output(
			" /I \"$_\""
		);
	}
	&main::Output(
		"\n",
		"\n"
	);

	&main::Output(
		"CLFLAGS = /nologo /Zp4 /W4"
	);
	if (not @Win32LibList) {
		&main::Output(
			" /X"
		);
	}
	&main::Output(
		"\n",
		"\n"
	);

	&main::Output(
		"CLDEFS  ="
	);
	foreach(@MacroList) {
		&main::Output(
			" /D \"$_\""
		);
	}
	&main::Output(
		" \$(USERDEFS)\n",
		"\n"
	);

	foreach (@BldList) {
		&main::Output(
			"EPOCBLD$_ = ",$BldPath,"$_\n",
			"EPOCTRG$_ = ",$RelPath,"$_\n",
			"\n"
		);
	}
	&main::Output(
		"\n"
	);

	if ($ChopTrgPath) {
		&main::Output(
			"TRGDIR = ",$ChopTrgPath,"\n",
			"\n"
		);
	}

	&main::Output(
		"DATADIR = ",$ChopDataPath,"\n",
		"\n"
	);
	foreach (@BldList) {
		&main::Output(
			"CL$_ = cl.exe "
		);
		if ($GenTrgType=~/^EXE$/o) {
			&main::Output(
				' /ML'
			);
		}
		elsif ($GenTrgType=~/^(DLL|LIB)$/o) {
			&main::Output(
				' /MD'
			);
		}
		if (/^U?DEB$/o) {
			&main::Output(
				'd'
			);
		}
		if (/^U?DEB$/o) {
			&main::Output(
				' /Zi /Od'
			);
		}
		elsif (/^U?REL$/o) {
			&main::Output(
				' /O1 /Ob1'
			);
		}
		&main::Output(
			' $(CLFLAGS)'
		);
		if (/^U?DEB$/o) {
			if (not $NoBrowseInfo) {
				&main::Output(
					" /FR\"\$(EPOCBLD",$_,")/\""
				);
			}
			&main::Output(
				" /Fd\"\$(EPOCTRG",$_,")\\",$BaseTrg,".pdb\""
			);
		}
		foreach (&main::MacroList($_)) {
			&main::Output(
				' /D ',$_
			);
		}
		&main::Output(
			' $(CLDEFS) $(INCDIR)',"\n"
		);
	}
	&main::Output(
		"\n",
		"\n"
	);
	

	&main::Output(
		"# EPOC PSEUDOTARGETS\n",
		"\n"
	);
	foreach(@BldList) {
		&main::Output(
			"$_ :"
		);

		&main::Output(
			" \\\n",
			"\tMAKEWORK",$_
		);

		my $BitMapTrg;
		foreach $BitMapTrg (@BitMapTrgList) {
			&main::Output(
				" \\\n",
				"\t\"\$(EPOCTRG$_)\\"
		);
			if ($ChopTrgPath) {
				&main::Output(
					"\$(TRGDIR)\\"
				);
			}
			&main::Output(
				"$BitMapTrg\""
			);
		}
		undef $BitMapTrg;

		my $BaseResrc;
		foreach $BaseResrc (@BaseSysResrcList) { # system resources first
			my $Lang;
			foreach $Lang (@LangList) {
				&main::Output(	# must come before main target because source for target will depend on the
				" \\\n",						# *.rsg file in \epoc32\include
				"\t\"\$(EPOCTRG$_)\\\$(DATADIR)\\$BaseResrc.R$Lang\""
				);
			}
		}
		foreach $BaseResrc (@BaseResrcList) { # system resources first
			my $Lang;
			foreach $Lang (@LangList) {
				&main::Output(	# must come before main target because source for target will depend on the
				" \\\n",						# *.rsg file in \epoc32\include
				"\t\"\$(EPOCTRG$_)\\"
				);
				if ($ChopTrgPath) {
					&main::Output(
						"\$(TRGDIR)\\"
					);
				}
				&main::Output(
					"$BaseResrc.R$Lang\""
				);
			}
		}

		if ($Aif) {
			&main::Output(
				" \\\n",
				"\t\"\$(EPOCTRG$_)\\"
			);
			if ($ChopTrgPath) {
				&main::Output(
					"\$(TRGDIR)\\"
				);
			}
			&main::Output(
				$Aif,"\""
			);
		}

		&main::Output (
			" \\\n",
			"\t\"\$(EPOCTRG$_)\\",
		);
		if ($ChopTrgPath) {
			&main::Output(
				"\$(TRGDIR)\\",
			);
		}
		if (not $GenTrgType=~/^LIB$/o) {
			&main::Output(
				$Trg,"\""
			);
		}
		else {
			&main::Output(
				"$BaseTrg.lib\""
			);
		}

		if (($_=~/^U?DEB$/o) && (not $NoBrowseInfo)) {
			&main::Output (
				" \\\n",
				"\t\"\$(EPOCTRG$_)\\",$BaseTrg,".bsc\""
			);
		}

		&main::Output(
			"\n",
			"\n"
		);
	}
	&main::Output(
		"\n"
	);

	&main::Output(
		"CLEAN :"
	);
	foreach (@BldList) {
		&main::Output(
			" CLEAN",$_
		);
	}
	&main::Output(
		"\n",
		"\n"
	);

	&main::Output(
		"MAKEWORK :"
	);
	foreach (@BldList) {
		&main::Output(
			" MAKEWORK",$_
		);
	}

	&main::Output(
		"\n",
		"\n",
		"\n"
	);
}

sub PMBld {

	my $BaseFirstObj=&main::BaseFirstObj;
	my @BaseObjList=&main::BaseObjList;
	my @BaseSrcList=&main::BaseSrcList;
	my $BaseTrg=&main::BaseTrg;
	my $Bld=&main::Bld;
	my $DefBaseExt=&main::DefBaseExt;
	my $DefFile=&main::DefFile;
	my $GenTrgType=&main::GenTrgType;
	my @LibList=&main::LibList;
	my $Trg=&main::Trg;
	my $TrgPath=&main::TrgPath;
	my $TrgType=&main::TrgType;


	# REAL TARGETS
	#-------------
	&main::Output(
		"# REAL TARGET - BUILD VARIANT ",$Bld,"\n",
		"\n"
	);

	&main::Output(
		"CLEAN",$Bld," : \n",
	);
	foreach (&PMGetCleanFileList) {
		&main::Output(
			"\t-\$(ERASE) \"",$_,"\"\n"
		);
	}
	&main::Output(
		"\n",
		"\n"
	);

	&main::Output(
		'MAKEWORK',$Bld," :"
	);
	foreach (&PMGetWorkPathList) {
		&main::Output(
			" \"",&main::Path_ChopPath($_),"\""
		);
	}
	&main::Output(
		"\n",
		"\n"
	);
	foreach (&PMGetWorkPathList) {
		&main::Output(
			"\"",&main::Path_ChopPath($_),"\" : \n"
		);
		foreach (&main::Path_ChopPath(&main::Path_StepDirs($_))) {
			&main::Output(
				"\t\@if not exist ","\"$_\" md \"$_\"\n"
			);
		}
		&main::Output(
			"\n"
		);
	}
	&main::Output(
		"\n"
	);

	if (($Bld=~/^U?DEB$/o) && (not $NoBrowseInfo)) {
		&main::Output(
			"BSC32_SBRS="
		);
		foreach (@BaseSrcList) {
			&main::Output(
				" \\\n",
				"\t\"\$(EPOCBLD",$Bld,")\\$_.sbr\""
			);
		}
		&main::Output(
			"\n",
			"\n",
		"\"\$(EPOCTRG",$Bld,")\\",$BaseTrg,".bsc\" : \$(BSC32_SBRS)\n",
		"\tbscmake.exe \@<<\n",
		"\t/nologo /o\$\@ \$(BSC32_SBRS)\n",
		"<<\n",
		"\n",
		"\n"
		);
	}

	&main::Output(
		"LIBS="
	);
	if (not $GenTrgType=~/^LIB$/o) {
		foreach (@LibList) {
			&main::Output(
				" \\\n\t\"\$(EPOCTRG",$Bld,")\\$_\""
			);
		}
	}
	&main::Output(
		"\n",
		"\n"
	);

	&main::Output(
		"LINK_OBJS="
	);
	foreach (@BaseSrcList) {
		&main::Output(
			" \\\n",
			"\t\"\$(EPOCBLD",$Bld,")\\$_.obj\""
		);
	}
	if ($Win32Resrc) {
		&main::Output(
			" \\\n",
			"\t\"\$(EPOCBLD",$Bld,")\\",&main::Path_Split('Base',$Win32Resrc),".res\""
		);
	}
	&main::Output(
		"\n",
		"\n"
	);


	# do the lib creation stage only if necessary
	if ($GenTrgType=~/^LIB$/o) {
		&main::Output(
			"LINK_FLAGS=/nologo /out:\"\$(EPOCTRG",$Bld,")\\",$BaseTrg,".lib\"\n",
			"\n",
			"\n"
		);
		&main::Output(
			"\"\$(EPOCTRG",$Bld,")\\",$BaseTrg,".lib\" :"
		);
		foreach (@BaseObjList) {
			&main::Output(
				" \"\$(EPOCTRG",$Bld,")\\",$_,".obj\""
			);
		}
		&main::Output(
			" \$(LINK_OBJS) \n",
			"\tlink.exe -lib \@<<\n",
			"\t\t\$(LINK_FLAGS) \$(LINK_OBJS)\n",
			"<<\n"
		);
# hack here until I work this out properly
		if ($TrgType=~/^LIB$/o) {	# this is nonsense really
			&main::Output(
				"\tcopy \"\$(EPOCBLD",$Bld,")\\",$BaseSrcList[0],".obj\" \"\$(EPOCTRG",$Bld,")\\",$BaseTrg,".obj\"\n"
			);
		}
		&main::Output(
			"\n",
			"\n"
		);
	}

	else {
		if ($GenTrgType=~/^DLL$/o) {
			&main::OutFormat(
				"STAGE1_LINK_FLAGS="
			);
			&main::OutFormat(
				" \"\$(EPOCTRG",$Bld,")\\$BaseFirstObj.obj\""
			);
			foreach (@BaseObjList) {
				&main::OutFormat(
					" \"\$(EPOCTRG",$Bld,")\\",$_,".obj\""
				);
			}
			foreach (@Win32LibList) {
				&main::OutFormat(
					' ',lc $_
				);
			}
			&main::OutFormat(
				" \$(LIBS) /nologo /subsystem:windows /nodefaultlib"
			);
			&main::OutFormat(
				" /WARN:3 $BaseAddressFlag /incremental:no"
			);
			if ($Bld=~/^U?DEB$/o) {
				&main::OutFormat(
					" /debug /pdb:\"\$(EPOCTRG",$Bld,")\\",$BaseTrg,".pdb\"",
				);
			}
			&main::OutFormat(
				" /entry:\"_E32Dll\""
			);
			&main::OutFormat(
				" /dll /implib:\"\$(EPOCTRG",$Bld,")\\",$BaseTrg,".lib\"",
				" /out:\"\$(EPOCBLD",$Bld,")\\",$Trg,"\""
			);
			&main::Output(
				"\n"
			);

			# code to create lib file from deffile
			&main::OutFormat(
				"LIB_FLAGS= /nologo /machine:i386 /nodefaultlib /name:\"$Trg\" /def:\"\$(EPOCBLD",$Bld,")\\",$BaseTrg,$DefBaseExt,".def\" /out:\"\$(EPOCTRG",$Bld,")\\",$BaseTrg,".lib\""
			);
			&main::Output(
				"\n"
			);
		}

		&main::OutFormat(
			'LINK_FLAGS='
		);
		&main::OutFormat(
			" \"\$(EPOCTRG$Bld)\\$BaseFirstObj.obj\""
		);
		foreach (@BaseObjList) {
			&main::OutFormat(
				" \"\$(EPOCTRG",$Bld,")\\",$_,".obj\""
			);
		}
		foreach (@Win32LibList) {
			&main::OutFormat(
				' ',lc $_
			);
		}
		&main::OutFormat(
			' $(LIBS) /nologo'
		);
		if (&main::Plat=~/^WINC$/o && $GenTrgType=~/^EXE$/o) {
			&main::OutFormat(
				' /subsystem:console'
			);
		}
		else {
			&main::OutFormat(
				' /subsystem:windows /nodefaultlib'
			);
		}
		&main::OutFormat(
			" /WARN:3 $BaseAddressFlag"
		);
		if ($Bld=~/^U?REL$/o) {
			&main::OutFormat(
				' /incremental:no'
			);
		}
		elsif ($Bld=~/^U?DEB$/o) {
			&main::OutFormat(
				" /incremental:yes /debug /pdb:\"\$(EPOCTRG",$Bld,")\\",$BaseTrg,".pdb\""
			);
		}
		if ($GenTrgType=~/^EXE$/o) {
			&main::OutFormat(
				" /entry:\"_E32Startup\""
			);
		}
		if ($GenTrgType=~/^DLL$/o) {
			&main::OutFormat(
				" /entry:\"_E32Dll\" /dll  \"\$(EPOCTRG",$Bld,")\\",$BaseTrg,".exp\""
			);
		}
		&main::OutFormat(
			" /out:\"\$(EPOCTRG",$Bld,")\\"
		);
		if ($TrgPath) {
			&main::OutFormat(
				"\$(TRGDIR)\\"
			);
		}
		&main::OutFormat(
			$Trg,"\""
		);
		&main::Output(
			"\n"
		);

		&main::Output(
			"\"\$(EPOCTRG",$Bld,")\\"
		);
		if ($TrgPath) {
			&main::Output(
				"\$(TRGDIR)\\"
			);
		}
		&main::Output(
			$Trg,"\" :"
		);
		if ($DefFile) {
			&main::Output(
				" \"$DefFile\""
			);
		}
		&main::Output(
			" \"\$(EPOCTRG",$Bld,")\\$BaseFirstObj.obj\""
		);
		foreach (@BaseObjList) {
			&main::Output(
				" \"\$(EPOCTRG",$Bld,")\\",$_,".obj\""
			);
		}
		&main::Output(
			" \$(LIBS) \$(LINK_OBJS) \n"
		);


		#	Link by name first time round for dlls

		if ($GenTrgType=~/^DLL$/o) {

			&main::Output(
				"\tlink.exe \@<<\n",
				"\t\t\$(STAGE1_LINK_FLAGS) \$(LINK_OBJS)\n",
				"<<\n"
			);

			&main::Output(
				"\tdefmake"
			);
			if ($DefFile) {
				&main::Output(
					" /z\"$DefFile\""
				);
			}
			elsif ($TrgType=~/^APP$/o) {
				&main::Output(
					' /1?NewApplication@@YAPAVCApaApplication@@XZ'
				);
			}
			elsif ($TrgType=~/^FSY$/o) {
				&main::Output(
					' /1CreateFileSystem'
				);
			}
			elsif ($TrgType=~/^LDD$/o) {
				&main::Output(
					' /1?CreateLogicalDevice@@YAPAVDLogicalDevice@@XZ'
				);
			}
			elsif ($TrgType=~/^PDD$/o) {
				&main::Output(
					' /1?CreatePhysicalDevice@@YAPAVDPhysicalDevice@@XZ'
				);
			}
			&main::Output(
				" \"\$(EPOCBLD",$Bld,")\\",$Trg,"\" \"\$(EPOCBLD",$Bld,")\\",$BaseTrg,$DefBaseExt,".def\" \n",
			);

			# create the lib file from the deffile
			&main::Output(
				"\tlib.exe \$(LIB_FLAGS)\n"
			);
		}

		&main::Output(
			"\tlink.exe \@<<\n",
			"\t\t\$(LINK_FLAGS) \$(LINK_OBJS)\n",
			"<<\n"
		);

		if ($GenTrgType=~/^DLL$/o) {

			&main::Output(
				"\tdel \"\$(EPOCTRG",$Bld,")\\",$BaseTrg,".exp\"\n",
				"\tdel \"\$(EPOCBLD",$Bld,")\\",$Trg,"\" \n",
				"\n"
			);
		}

		&main::Output(
			"\n"
		);
	}
}

sub PMStartSubPrjList {

	&main::Output(
		"# SOURCES\n",
		"\n"
	);
}

sub PMStartSubPrj {

	my $ChopRTWSrcPath=&main::Path_ChopPath(&main::Path_RltToWork(&main::SubPrj));


	&main::Output(
		"SUBPRJ=",$ChopRTWSrcPath,"\n",
		"\n"
	);
}

sub PMStartSubPrjSrc {

	my $Src=&main::Src;

	&main::Output(
		"# Source ",$Src,"\n\n"
	);
}

sub PMSubPrjSrcDepend {
	my @BldList=&main::BldList;	
	my @DepList=&main::DepList;


	&main::Output(
		"DEPEND="
	);
	my $Dep;
	foreach $Dep (@DepList) {
		&main::Output(
		" \\\n\t\"",$Dep,"\""
		);
	}
	&main::Output(
		"\n\n"
	);
	my $Bld;
	foreach $Bld (@BldList) {
		&main::Output("DEPEND$Bld=\$(DEPEND)\n\n");
	}
	&main::Output(
		"\n"
	);
}

sub PMSubPrjSrcBldDepend {
	my $Bld=&main::Bld;

	my @DepList=&main::DepList;


	&main::Output(
		"DEPEND",$Bld,"="
	);
	foreach (@DepList) {
		&main::Output(
			" \\\n\t\"$_\""
		);
	}
	&main::Output(
		"\n",
		"\n"
	);
}

sub PMEndSubPrjSrcBld {
	my $BaseSrc=&main::BaseSrc;
	my $Bld=&main::Bld;
	my $Src=ucfirst lc &main::Src;


	&main::Output(
		"\"\$(EPOCBLD",$Bld,")\\",$BaseSrc,".obj\" \"\$(EPOCBLD",$Bld,")\\",$BaseSrc,".sbr\" : \"\$(SUBPRJ)\\",$Src,"\" \$(DEPEND",$Bld,")\n",
		"\t\$(CL",$Bld,") /Fo\"\$(EPOCBLD",$Bld,")/\" /c \"\$(SUBPRJ)\\",$Src,"\"\n\n"
	);
}

sub PMEndSubPrjSrc {

	&main::Output(
		"\n",
		"\n"
	);
}

sub PMStartSubPrjResrc {

	my $Resrc=&main::Resrc;


	&main::Output(
		"# Resource ",$Resrc,"\n\n"
	);
}

sub PMSubPrjResrcDepend {

	my @BldList=&main::BldList;	
	my @RTWDepList=&main::Path_RltToWork(&main::DepList);

	&main::Output(
		"DEPEND="
	);
	foreach (@RTWDepList) {
		&main::Output(
		" \\\n\t\"$_\""
		);
	}
	&main::Output(
		"\n\n"
	);
}

sub PMSubPrjResrcBld {

	my $BaseLangMacro=&main::BaseLangMacro;
	my $BaseResrc=&main::BaseResrc;
	my $Bld=&main::Bld;
	my @ChopRTWSysIncPaths=&main::Path_ChopPath(&main::Path_RltToWork(&main::SysIncPaths));
	my @ChopRTWUserIncPaths=&main::Path_ChopPath(&main::Path_RltToWork(&main::UserIncPaths));
	my @LangList=&main::LangList;
	my $Resrc=&main::Resrc;
	my $ResrcHdr=&main::ResrcHdr;
	my $ResrcIsSys=&main::ResrcIsSys;
	my $TrgPath=&main::TrgPath;
	
	my $Lang;
	foreach $Lang (@LangList) {
		&main::Output(
			"\"\$(EPOCTRG",$Bld,")\\"
		);
		if ($ResrcIsSys) {
			&main::Output(
				"\$(DATADIR)\\"
			);
		}
		elsif ($TrgPath) {
			&main::Output(
				"\$(TRGDIR)\\"
			);
		}
		&main::Output(
			$BaseResrc,".r",$Lang,"\" : \"\$(SUBPRJ)\\",$Resrc,"\" \$(DEPEND)\n",
			"\tcpp -I \"\$(SUBPRJ)\\\""
		);
		foreach (@ChopRTWUserIncPaths) {
			&main::Output(
				" -I \"$_\""
			);
		}
		&main::Output(
			" -I-"
		);
		foreach (@ChopRTWSysIncPaths) {
			&main::Output(
				" -I \"$_\""
			);
		}
		&main::Output(
			" -D",$BaseLangMacro,$Lang
		);
		if ($Bld=~/^U/o) {
			&main::Output(
				" -D_UNICODE"
			);
		}
		&main::Output(
			" < \"\$(SUBPRJ)\\",$Resrc,"\" > \"\$(SUBPRJ)\\",$BaseResrc,".rpp\"\n",
			"\trcomp"
		);
		if ($Bld=~/^U/o) {
			&main::Output(
				' -u'
			);
		}
		&main::Output(
			" -o\$\@ -h\"\$(SUBPRJ)\\",$BaseResrc,".rs~\" -i\$(SUBPRJ)\\",$Resrc," -s\"\$(SUBPRJ)\\",$BaseResrc,".rpp\"\n",
			"\tdel \"\$(SUBPRJ)\\",$BaseResrc,".rpp\"\n",
			"\tcall <<\"MayRewriteHdr.bat\"\n",
			"\t\@echo off\n",
			"\tfc4bat \"\$(SUBPRJ)\\",$BaseResrc,".rs~\" \"",$ResrcHdr,"\"\n",
			"\tif errorlevel==1 copy \"\$(SUBPRJ)\\",$BaseResrc,".rs~\" \"",$ResrcHdr,"\"\n",
			"<<\n",
			"\tdel \"\$(SUBPRJ)\\",$BaseResrc,".rs~\"\n",
			"\n"
		);
	}
}

sub PMEndSubPrjResrc {

	&main::Output(
		"\n",
		"\n"
	);
}

sub PMStartSubPrjBitMapTrg {

	my $BitMapTrg=&main::BitMapTrg;


	&main::Output(
		"# BitMap ",$BitMapTrg,"\n",
		"\n"
	);
}

sub PMSubPrjBitMapTrgBld {
	my $BitMapTrg=&main::BitMapTrg;
	my $Bld=&main::Bld;
	my @BitMapSrcList=&main::BitMapSrcList;
	my $TrgPath=&main::TrgPath;

	&main::Output(
		"\"\$(EPOCTRG",$Bld,")\\"
	);
	if ($TrgPath) {
		&main::Output(
			"\$(TRGDIR)\\"
		);
	}
	&main::Output(
		$BitMapTrg,"\" : "
	);
	my $BMSrc;
	foreach $BMSrc (@BitMapSrcList) {
		&main::Output(
			"\"\$(SUBPRJ)\\",$BMSrc,"\""
		);
	}
	undef $BMSrc;
	&main::Output(
		"\n",
		"\tbmconv \$\@"
	);
	foreach $BMSrc (@BitMapSrcList) {
		&main::Output(
			 " \"\$(SUBPRJ)\\",$BMSrc,"\""
		);
	}
	&main::Output(
		"\n",
		"\n"
	);
}

sub PMStartSubPrjAif {

	my $Aif=&main::Aif;


	&main::Output(
		"# Aif ",$Aif,"\n",
		"\n"
	);
}

sub PMSubPrjAifBld {
	my $Aif=&main::Aif;
	my $Bld=&main::Bld;
	my $TrgPath=&main::TrgPath;

	&main::Output(
		"\"\$(EPOCTRG",$Bld,")\\"
	);
	if ($TrgPath) {
		&main::Output(
			"\$(TRGDIR)\\"
		);
	}
	&main::Output(
		$Aif,"\" : \"\$(SUBPRJ)\\",$Aif,"\"\n",
		"\tcopy \"\$(SUBPRJ)\\",$Aif,"\" \$\@\n",
		"\n"
	);
}

sub PMEndSubPrjList {
	if ($Win32Resrc) {
		my @BldList=&main::BldList;
		my @DepList=&main::Deps_GenDependsL($Win32Resrc);

		&main::Output(
			"# Win32 Resource $Win32Resrc\n",
			"\n",
			"DEPEND="
		);
		foreach (@DepList) {
			&main::Output(
				" \\\n\t\"$_\""
			);
		}
		&main::Output(
			"\n\n"
		);
	
		my $Bld;
		foreach $Bld (@BldList) {
			&main::Output(
				"\"\$(EPOCBLD",$Bld,")\\",&main::Path_Split('Base',$Win32Resrc),".res\" : \"",$Win32Resrc,"\" \$(DEPEND)\n",
				"\trc /l 0x809 /fo\$\@ /i \"",&main::Path_ChopPath(&main::Path_Split('Path',$Win32Resrc)),"\" \"$Win32Resrc\"\n",
				"\n"
			);
		}
		&main::Output(
			"\n",
			"\n"
		);
	}
}

1;
