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


package Cl_arm;

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
);


sub PMHelp_Mmp {
}

sub PMPlatProcessMmp {

	my $MMPFILE=&main::MmpFile;

	# set up START MARM ... END block module variables
	my @MmpWarn=();
	my $Line;
	LINE: foreach $Line (&main::PlatTxt) {
		my $LineNum=shift @$Line;
		$_=shift @$Line;
		push @MmpWarn, "$LineNum: Unrecognised Keyword \"$_\"\n";
	}

	undef $Line;
	if (@MmpWarn) {
		warn
			"\nMMPFILE \"",$MMPFILE,"\"\n",
			"START .. END BLOCK WARNINGS(S)\n",
			@MmpWarn,
			"\n"
		;
	}
	undef @MmpWarn;
}

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

	my @MyList;

	push @MyList, "$RelPath$Trg","$RelPath$BaseTrg.map", "$BldPath$BaseTrg.in","$BldPath$BaseTrg.bas","$RelPath$BaseTrg.sym";
	my $BaseResrc;
	foreach $BaseResrc (@BaseSysResrcList,@BaseResrcList) {  # do sys resrcs first always
		my $Lang;
		foreach $Lang (@LangList) {
			push @MyList, "$RelPath$BaseResrc.R$Lang";
		}
		push @MyList, "$GenHdrPath$BaseResrc.rsg";
	}
	if ($Aif) {
		push @MyList, "$RelPath$Aif";
	}
	foreach (@BitMapTrgList) {
		push @MyList, "$RelPath$_";
	}
	push @MyList,"$RelPath$BaseTrg.lib";
	foreach (@BaseSrcList) {
		push @MyList,"$BldPath$_.o";
	}
	push @MyList, "$BldPath$BaseTrg$DefBaseExt.def";
	if (&main::TrgType=~/^LIB$/o) {
		push @MyList, "$RelPath$BaseTrg.o";
	}
	@MyList;
}

sub PMGetWorkPathList {
	
	(&main::RelPath,&main::BldPath);
}

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 @ChopRTWSysIncPaths=&main::Path_ChopPath(&main::Path_RltToWork(&main::SysIncPaths));
	my @ChopRTWUserIncPaths=&main::Path_ChopPath(&main::Path_RltToWork(&main::UserIncPaths));
	my @LangList=&main::LangList;
	my @MacroList=&main::MacroList;
	my $RTWBldPath=&main::Path_RltToWork(&main::BldPath);
	my $RTWRelPath=&main::Path_RltToWork(&main::RelPath);
	my $Trg=&main::Trg;
	my $TrgType=&main::TrgType;



	&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  ="
	);
	foreach (@ChopRTWUserIncPaths) {
		&main::Output(
			" -I \"$_\""
		);
	}
	&main::Output(
		" -I-"
	);
	foreach (@ChopRTWSysIncPaths) {
		&main::Output(
			" -I \"$_\""
		);
	}
	&main::Output(
		"\n",
		"\n"
	);

	&main::Output(
		"GCCFLAGS=-c -nostdinc -Wall -Wno-ctor-dtor-privacy -mcpu-arm710 -mapcs-32 \\\n",
		"\t\t-mshort-load-bytes -msoft-float -O -fcheck-new -fvtable-thunks\n",
		"\n"
	);

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

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

	foreach (@BldList) {
		&main::Output(
			"GCC$_ = gcc"
		);
		if (/^U?REL$/o) {
			&main::Output(
				' -s -fomit-frame-pointer'
			);
		}
		elsif (/^U?DEB$/o) {
			&main::Output(
				' -g'
			);
		}
		&main::Output(
			' $(GCCFLAGS)'
		);
		foreach (&main::MacroList($_)) {
			&main::Output(
				' -D',$_
			);
		}
		&main::Output(
			' $(GCCDEFS)',"\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$_)\\$BitMapTrg\""
			);
		}
		undef $BitMapTrg;

		my $BaseResrc;
		foreach $BaseResrc (@BaseSysResrcList,@BaseResrcList) { # do sys resrcs first always
			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$_)\\",$BaseResrc,".R$Lang\""
				);
			}
		}

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

		&main::Output (
			" \\\n"
		);
		if (not &main::GenTrgType=~/^LIB$/o) {
			&main::Output(
				"\t\"\$(EPOCTRG$_)\\",$Trg,"\""
			);
		}
		else {
			&main::Output(
				"\t\"\$(EPOCTRG$_)\\",$BaseTrg,".lib\""
			);
		}
		&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 $DefFile=&main::DefFile;
	my $DefBaseExt=&main::DefBaseExt;
	my $GenTrgType=&main::GenTrgType;
	my @LibList=&main::LibList;
	my $LinkAs=&main::LinkAs;
	my $RelPath=&main::RelPath;
	my $Trg=&main::Trg;
	my $TrgType=&main::TrgType;

# UIDs now build dependent
	my @UidList;
	if ($Bld=~/^U/o) {
		@UidList=&main::UnicodeUidList;
	}
	else {
		@UidList=&main::UidList;
	}


# set up $LinkAs
	$UidList[2]=~/^0x(.*)$/o;
	# have to make sure than series of noughts in brackets doesn't appear in name for null uids
	if ($1 ne '00000000') {
		$LinkAs=join '', &main::Path_Split('Base',$LinkAs),"[$1]",&main::Path_Split('Ext',$LinkAs);
	}


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

	&main::Output(
		"CLEAN",$Bld," : \n",
	);
	foreach (&PMGetCleanFileList) {
		&main::Output(
			"\t-\$(ERASE) \"",&main::Path_RltToWork($_),"\"\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 ($GenTrgType=~/^LIB$/o) {
		&main::Output(
			"\"\$(EPOCTRG",$Bld,")\\",$BaseTrg,".lib\" :"
		);
		if ($DefFile) {
			&main::Output(
				" \"$DefFile\""
			);
		}
		&main::Output(
			" \"\$(EPOCBLD",$Bld,")\\",$BaseTrg,".in\"\n"
		);

		if ($TrgType=~/^IMPLIB$/o) {
			&main::Output(
				"\tdlltool --output-def \"\$(EPOCBLD",$Bld,")\\",$BaseTrg,$DefBaseExt,".def\" \"\$(EPOCBLD",$Bld,")\\",$BaseTrg,".in\"\n",
				"\tdeftool"
			);
			if ($DefFile) {
				&main::Output(
					" -z \"$DefFile\""
				);
			}
			&main::Output(
				" \"\$(EPOCBLD",$Bld,")\\",$BaseTrg,$DefBaseExt,".def\"\n"
			);
		}
		&main::Output(
			"\tdlltool --output-lib \"\$(EPOCTRG",$Bld,")\\",$BaseTrg,".lib\"",
		);
		if ($TrgType=~/^IMPLIB$/o) {
			&main::Output(
				" \\\n",
				"\t\t--def \"\$(EPOCBLD",$Bld,")\\",$BaseTrg,$DefBaseExt,".def\""
			);
		}
		&main::Output(
			" \\\n",
			"\t\t--dllname \"",$LinkAs,"\" \\\n",
			"\t\t\"\$(EPOCBLD",$Bld,")\\",$BaseTrg,".in\"\n"
		);
# hack here until I work this out properly
		if ($TrgType=~/^LIB$/o) {
			&main::Output(
				"\tcopy \"\$(EPOCBLD",$Bld,")\\",$BaseSrcList[0],".o\" \"\$(EPOCTRG",$Bld,")\\",$BaseTrg,".o\"\n"
			);
		}
		&main::Output(
			"\n"
		);
	}
	else {
		&main::Output(
			"LIBS="
		);
		foreach (@LibList) {
			&main::Output(
				" \\\n",
				"\t\"\$(EPOCTRG",$Bld,")\\$_\""
			);
		}
		&main::Output(
			"\n",
			"\n"
		);

		&main::Output(
			"\"\$(EPOCTRG",$Bld,")\\",$Trg,"\" :"
		);
		&main::Output(
			" \"\$(EPOCTRG",$Bld,")\\$BaseFirstObj.o\""
		);
		&main::Output(
			" \"\$(EPOCBLD",$Bld,")\\",$BaseTrg,".in\""
		);
			&main::Output(
				" \$(LIBS)"
			);
		if ($GenTrgType=~/^DLL$/o || $TrgType=~/^EXEDLL$/o) {
			if ($DefFile) {
				&main::Output(
					" \"$DefFile\""
				);
			}
		}
		&main::Output(
			"\n"
		);

		if ($GenTrgType=~/^DLL$/o || $TrgType=~/^EXEDLL$/o) {
			&main::Output(
				"\tdlltool --output-def \"\$(EPOCBLD",$Bld,")\\",$BaseTrg,$DefBaseExt,".def\" \"\$(EPOCBLD",$Bld,")\\",$BaseTrg,".in\"\n",
				"\tdeftool"
			);
			if ($DefFile) {
				&main::Output(
					" -z \"$DefFile\""
				);
			}
			elsif ($TrgType=~/^APP$/o) {
				&main::Output(
					' -1 NewApplication__Fv'
				);
			}
			elsif ($TrgType=~/^FSY$/o) {
				&main::Output(
					' -1 CreateFileSystem'
				);
			}
			elsif ($TrgType=~/^LDD$/o) {
				&main::Output(
					' -1 CreateLogicalDevice__Fv'
				);
			}
			elsif ($TrgType=~/^PDD$/o) {
				&main::Output(
					' -1 CreatePhysicalDevice__Fv'
				);
			}
			&main::Output(
				" \"\$(EPOCBLD",$Bld,")\\",$BaseTrg,$DefBaseExt,".def\"\n"
			);
		}

		&main::Output(
			"\tld"
		);
		if ($Bld=~/^U?REL$/o) {
			&main::Output(
				" -s"
			);	
		}
		if ($GenTrgType=~/^DLL$/o) {
			&main::Output(
				" -e _E32Dll --dll \\\n"
			);
		}
		elsif ($GenTrgType=~/^EXE$/o) {
			&main::Output(
				" -e _E32Startup \\\n"
			);
		}
		&main::Output(
			"\t\t--base-file \"\$(EPOCBLD",$Bld,")\\",$BaseTrg,".bas\" \\\n",
			"\t\t-o \"\$(EPOCBLD",$Bld,")\\",$Trg,"\""
		);
		&main::Output(
			" \"\$(EPOCTRG",$Bld,")\\$BaseFirstObj.o\""
		);
		&main::Output(
			" \\\n",
			"\t\t--whole-archive \"\$(EPOCBLD",$Bld,")\\",$BaseTrg,".in\" \\\n",
			"\t\t--no-whole-archive \$(LIBS)\n"
		);

		&main::Output(
			"\tdlltool "
		);
		# && $DefFile below so that exedlls which don't export when they are exes don't pass an
		# empty deffile to dlltool which will make dlltool return an error - take out when dlltool and deftool are fixed
		if ($GenTrgType=~/^DLL$/o || ($TrgType=~/^EXEDLL$/o && $DefFile)) {
			&main::Output(
				"--output-lib \"\$(EPOCTRG",$Bld,")\\",$BaseTrg,".lib\" \\\n",
				"\t\t--def \"\$(EPOCBLD",$Bld,")\\",$BaseTrg,$DefBaseExt,".def\" \\\n",
				"\t\t--dllname \"",$LinkAs,"\" \\\n",
				"\t\t"
			);
		}
		&main::Output(
			"--output-exp \"",$BaseTrg,".exp\" \\\n",
			"\t\t--base-file \"\$(EPOCBLD",$Bld,")\\",$BaseTrg,".bas\" \\\n",
			"\t\t"
		);
		&main::Output(
			"\"\$(EPOCTRG",$Bld,")\\$BaseFirstObj.o\""
		);
		&main::Output(
			" \"\$(EPOCBLD",$Bld,")\\",$BaseTrg,".in\"  \$(LIBS)\n"
		);

		&main::Output(
			"\tld"
		);
		if ($Bld=~/^U?REL$/o) {
			&main::Output(
				" -s"
			);
		}
		if ($GenTrgType=~/^DLL$/o) {
			&main::Output(
				" -e _E32Dll --dll \\\n"
			);
		}
		elsif ($GenTrgType=~/^EXE$/o) {
			&main::Output(
				" -e _E32Startup \\\n"
			);
		}
		&main::Output(
			"\t\t-Map \"\$(EPOCTRG",$Bld,")\\",$BaseTrg,".map\" \\\n",
			"\t\t-o \"\$(EPOCBLD",$Bld,")\\",$Trg,"\" \"",$BaseTrg,".exp\" \\\n"
		);
		&main::Output(
			"\t\t\"\$(EPOCTRG",$Bld,")\\$BaseFirstObj.o\" \\\n"
		);
		&main::Output(
			"\t\t--whole-archive \"\$(EPOCBLD",$Bld,")\\",$BaseTrg,".in\" \\\n",
			"\t\t--no-whole-archive \$(LIBS)\n"
		);

		if ($Bld=~/^U?DEB$/o) {
			&main::Output(
				"\tobjcopy -X \"\$(EPOCBLD",$Bld,")\\",$Trg,"\" \"\$(EPOCTRG",$Bld,")\\",$BaseTrg,".sym\"\n"
			);
		}

		&main::Output(
			"\tpetran \"\$(EPOCBLD",$Bld,")\\",$Trg,"\" \$\@ \\\n",
			"\t\t"
		);
		if (&main::AllowDllData) {
			&main::Output(
				' -allow'
			);
		}
		if (not &main::CallDllEntryPoints) {
			&main::Output(
				' -nocall'
			);
		}
		if (&main::DataLinkAddress) {
			&main::Output(
				' -datalinkaddress ',&main::DataLinkAddress
			);
		}
		if (&main::FixedProcess) {
			&main::Output(
				' -fixed'
			);
		}
		if (&main::HeapSize) {
			my %HeapSize=&main::HeapSize;
			&main::Output(
				' -heap ',$HeapSize{Min},' ',$HeapSize{Max}
			);
		}
		if (&main::ProcessPriority) {
			&main::Output(
				' -priority ',&main::ProcessPriority
			);
		}
		if (&main::StackSize) {
			&main::Output(
				' -stack ',&main::StackSize
			);
		}
		my $i=1;
		foreach (@UidList) {
			&main::Output(
				" -uid$i $_"
			);
			$i++;
		}
		&main::Output(
			"\n"
		);
		&main::Output(
			"\tdel \"",$BaseTrg,".exp\"\n", # note - exp created in current dir coz dlltool can't handle the path
			"\tdel \"\$(EPOCBLD",$Bld,")\\",$Trg,"\"\n",
			"\n"
		);
	}

	# TARGET *.IN
	#------------
	&main::Output(
		"OBJECTS="
	);
	foreach (@BaseSrcList) {
		&main::Output(
			" \\\n\t\$(EPOCBLD",$Bld,")\\$_.o"
		);	# would have quotes round these for longfilenames if ar didn't complain.  OK because not referred to as having quotes
	}
	&main::Output(
		"\n",
		"\n"
	);
	&main::Output(
		"\"\$(EPOCBLD",$Bld,")\\",$BaseTrg,".in\" : \$(OBJECTS)\n",	# MUST have quotes round .in file else file not thought of as a depend
		"\tif exist \$\@ del \$\@\n",
		"\tcd \"\$(EPOCBLD",$Bld,")\"\n",
		"\tar -M < <<\n",
		"CREATE \$(\@F)\n",
		"ADDMOD \$(**F)\n"
	);
	foreach (@BaseObjList) {
		$_=$RelPath.$_.'.O';
		tr-\\-/-;
		&main::Output(
		"ADDMOD $_\n"
		);
	}
	&main::Output(	
		"SAVE\n",
		"END\n",
		"<<\n",
		"\tranlib \$(\@F)\n",
		"\tcd \"\$(MAKEDIR)\"\n",	# cd back to the directory where NMAKE was invoked
		"\n\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 @RTWDepList=&main::Path_RltToWork(&main::DepList);


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

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

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


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

sub PMEndSubPrjSrcBld {
	my $BaseSrc=&main::BaseSrc;
	my $Bld=&main::Bld;
	my $Src=ucfirst lc &main::Src;
	my $RTWSubPrj=&main::Path_RltToWork(&main::SubPrj);


	&main::Output(
		"\"\$(EPOCBLD",$Bld,")\\",$BaseSrc,".o\": \"\$(SUBPRJ)\\",$Src,"\" \$(DEPEND",$Bld,")\n",
		"\t\$(GCC",$Bld,") -I \"\$(SUBPRJ)\\\" \$(INCDIR) -o \$\@ \"\$(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 @LangList=&main::LangList;
	my $Resrc=&main::Resrc;
	my $ResrcHdr=&main::ResrcHdr;
	my $SubPrj=&main::SubPrj;
	my $RTWSubPrj=&main::Path_RltToWork($SubPrj);

	my $Lang;
	foreach $Lang (@LangList) {
		&main::Output(
			"\"\$(EPOCTRG",$Bld,")\\",$BaseResrc,".R",$Lang,"\": \"\$(SUBPRJ)\\",$Resrc,"\" \$(DEPEND)\n",
			"\tcpp -I \"\$(SUBPRJ)\\\" \$(INCDIR) -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;

	&main::Output(
		"\"\$(EPOCTRG",$Bld,")\\",$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;

	&main::Output(
		"\"\$(EPOCBLD",$Bld,")\\",$Aif,"\": \"\$(SUBPRJ)\\",$Aif,"\"\n",
		"\tcopy \"\$(SUBPRJ)\\",$Aif,"\" \$\@\n",
		"\n"
	);
}

1;
