# Top-level script fragment to build everything for MPW.

Set savedir "`Directory`"

#Set Echo 1

Set ThisScript "{0}"

Set verify 0		# set this to 1 for debug

# Parse arguments.

Loop
        Break If {#} == 0
                Set BuildTarget "{1}"
        Shift 1
End Loop

If "{BuildTarget}" == ""
        Echo Must specify a build target
        Exit
End If

If {verify} == 1
        Echo "#" Doing "{ThisScript}" "{BuildTarget}" in "`Directory`" ... 
End If

Set ranmake 0

If "`Exists Makefile.mpw`" != ""
        Echo "Set Echo 1" >{BuildTarget}.makeout
        Make -f Makefile.mpw {BuildTarget} >>{BuildTarget}.makeout
        {BuildTarget}.makeout
        Delete {BuildTarget}.makeout
        Set ranmake 1
End If

#only PPC is supported
#
#If "`Exists Makefile.PPC.mpw`" != ""
#        Echo "Set Echo 1" >{BuildTarget}.makeout.ppc
#        Make -f Makefile.PPC.mpw {BuildTarget} >>{BuildTarget}.makeout.ppc
#        {BuildTarget}.makeout.ppc
#        Delete {BuildTarget}.makeout.ppc
#        Set ranmake 1
#End If

If {ranmake} == 1
        Exit
End If

# ABI_ROOT is the initial directory
Set ABI_ROOT {savedir}
Export ABI_ROOT

# Dispatch on various pseudo-targets.


SetDirectory "{ABI_ROOT}src:af:ev:xp"
"{ABI_ROOT}{ThisScript}" {BuildTarget}
SetDirectory "{ABI_ROOT}src:af:ev:mac"
"{ABI_ROOT}{ThisScript}" {BuildTarget}
SetDirectory "{ABI_ROOT}src:af:gr:xp"
"{ABI_ROOT}{ThisScript}" {BuildTarget}
SetDirectory "{ABI_ROOT}src:af:gr:mac"
"{ABI_ROOT}{ThisScript}" {BuildTarget}
SetDirectory "{ABI_ROOT}src:af:util:xp"
"{ABI_ROOT}{ThisScript}" {BuildTarget}
SetDirectory "{ABI_ROOT}src:af:util:mac"
"{ABI_ROOT}{ThisScript}" {BuildTarget}
SetDirectory "{ABI_ROOT}src:af:xap:xp"
"{ABI_ROOT}{ThisScript}" {BuildTarget}
SetDirectory "{ABI_ROOT}src:af:xap:mac"
"{ABI_ROOT}{ThisScript}" {BuildTarget}
SetDirectory "{ABI_ROOT}src:text:fmt:xp"
"{ABI_ROOT}{ThisScript}" {BuildTarget}
SetDirectory "{ABI_ROOT}src:text:ptbl:xp"
"{ABI_ROOT}{ThisScript}" {BuildTarget}
SetDirectory "{ABI_ROOT}src:wp:ap:xp"
"{ABI_ROOT}{ThisScript}" {BuildTarget}
SetDirectory "{ABI_ROOT}src:wp:ap:mac"
"{ABI_ROOT}{ThisScript}" {BuildTarget}
SetDirectory "{ABI_ROOT}src:other:spell"
"{ABI_ROOT}{ThisScript}" {BuildTarget}
SetDirectory "{ABI_ROOT}src:wp:impexp:xp"
"{ABI_ROOT}{ThisScript}" {BuildTarget}
SetDirectory "{ABI_ROOT}src:wp:main:xp"
"{ABI_ROOT}{ThisScript}" {BuildTarget}
SetDirectory "{ABI_ROOT}src:wp:main:mac"
"{ABI_ROOT}{ThisScript}" {BuildTarget}

SetDirectory "{savedir}"
