<?xl version="0.1" encoding="UTF-8"?>


<Define> ^file-list () </Define>
<Define> ^mac-machine-file-list () </Define>
<Define> ^app (Arg 1) </Define>

<Define> ^insert-file ()
<Arguments>
	^type
	^accesspath
	^path
</Arguments>
<Sequence> ()
	<Define> ^target
		(CutString 
			(+ (GE accesspath 1)
				(CutString (GE path 1) 1 1000))
			1 10000)
	</Define>
	<Define> ^mode ^'start </Define>
	<Define> ^result ^"" </Define>
	<RegSwitch> ^target
	<Case rex=":">
		<If> (= mode 'start)
		<Then>
			<set> ^result (+ result "../") </set>
		</Then><Else>
			<set> ^result (+ result "/") </set>
		</Else></If>
	</Case>
	<Case rex="([0-9]|[A-Z]|[a-z]|\-|\.|_)*">
		<set> ^result (+ result pattern) </set>
		<set> ^mode ^'phase1 </set>
	</Case>
	</RegSwitch>
	<If> (= (CutString result
			(- (StringLength result) 2)
			2)
		".h")
	<Else>
		<set> ^result (+ result " ") </set>
		(PrintStd result)
		<set> ^file-list (cons
			result
			file-list)
		</set>
		<If> (= (CutString result 
				0
				(StringLength "../../src/arch/mac"))
			"../../src/arch/mac")
		<Then>
		<set> ^mac-machine-file-list (cons
			result
			mac-machine-file-list)
		</set>
		</Then></If>
				
	</Else>
	</If>
</Sequence></Define>

<Define> ^eval-output ()
<Arguments/>
<Sequence> ()
<Define> ^arg
	<Append>
	<List>
		^'[Shell cmdout="on" pipe="on"]
		^"mversion "
		^"-current ../current.ver "
		^"-except ../../src/version work "
		^"-code ap_version AP.code "
		^"-log ../../../../cvs.log gbs/env/src/ ../../src/ "
		^"-app  " ^app ^" "
		^"-work ../version/" ^app ^".mac.carbon.ver "
		^"-c ../../src/version/" ^app ^".mac.carbon.ver.c "
		^"-msg GLOBALBASE client "
		^"-source "
	</List>
		^file-list
	</Append>
</Define>
<Eval> (CurrentEnvironment) ^arg </Eval>
<If> (= app "cosmos") <Then>
<Define> ^arg
	<Append>
	<List>
		^'[Shell cmdout="on" pipe="on"]
		^"mversion "
		^"-current ../current.ver "
		^"-except ../../src/version work "
		^"-code machine_code_version MA.code "
		^"-log ../../../../cvs.log gbs/env/src/ ../../src/ "
		^"-app Mac.Carbon.Interface "
		^"-work ../version/machine.mac.carbon.lib.ver "
		^"-c ../../src/version/machine.mac.carbon.lib.ver.c "
		^"-msg machine \(Mac Carbon\) dependent library "
		^"-source "
	</List>
		^mac-machine-file-list
	</Append>
</Define>
<Eval> (CurrentEnvironment) ^arg </Eval>
</Then></If>
()
</Sequence>
</Define>


<!------ Parsiing functions ---->

<Define Order="Normal"> ^?codewarrior ^sym ^sym </Define>

<Define> ^PROJECT
	(NewEnvironment (CurrentEnvironment))
</Define>

<PROJECT type="raw">
<Define> ^TARGETLIST
	(NewEnvironment (CurrentEnvironment))
</Define>

<TARGETLIST type="raw">
<Define> ^TARGET
	(NewEnvironment (CurrentEnvironment))
</Define>

<TARGET type="raw">
	<Define Order="Normal"> ^NAME ^sym ^sym </Define>
	<Define Order="Normal"> ^SETTINGLIST ^sym ^sym </Define>
	<Define> ^FILELIST
		(NewEnvironment (CurrentEnvironment))
	</Define>

	<FILELIST type="raw">
		<Define Order="Normal"> ^FILE ^sym <Sequence> ()
		<If> (= (GE(GE sym 'PATHROOT) 1)
				"Project")
		<Then>
			(insert-file "FILE"
				(GE sym 'ACCESSPATH)
				(GE sym 'PATH))
		</Then></If>
		</Sequence>
		</Define>
	</FILELIST>

	<Define> ^LINKORDER
		(NewEnvironment (CurrentEnvironment))
	</Define>

	<LINKORDER type="raw">
		<Define Order="Normal"> ^FILEREF ^sym <Sequence> ()
			(eval-output)
			<Exit/>
		</Sequence>
		</Define>
	</LINKORDER>

</TARGET>
</TARGETLIST>

<Define Order="Normal"> ^TARGETORDER ^sym ^sym </Define>

<Define> ^GROUPLIST
	(NewEnvironment (CurrentEnvironment))
</Define>

<GROUPLIST type="raw">
<Define> ^GROUP
	(NewEnvironment (CurrentEnvironment))
</Define>

<GROUP type="raw">
	<Define Order="Normal"> ^NAME ^sym ^sym </Define>
	<Define Order="Normal"> ^FILEREF ^sym <Sequence> ()
	<If> (= (GE(GE sym 'PATHROOT) 1)
			"Project")
	<Then>
		(insert-file "GROUP:FILEREF"
			(GE sym 'ACCESSPATH)
			(GE sym 'PATH))
	</Then></If>
	</Sequence>
	</Define>
</GROUP>
</GROUPLIST>
</PROJECT>


<Load option="exec"> (+ app ".mcp.xml") </Load>

<!--
(PrintStd "FILE=LIST")
(PrintStd file-list)

(PrintStd "FILEREF=LIST")
(PrintStd fileref-list)
-->
