#	BuildCommands - show build commands
#
#	Usage:
#		BuildCommands program [options…] > commands
#
#	The BuildCommands script writes the build commands for the specified
#	program (or target) to standard output.
#
#	Make is used to generate the build commands.  If file <program>.make
#	exists it is used as the makefile.	If not, file MakeFile is used.
#
#	The options specified are passed directly to Make, and control the
#	generation of the build commands.
#
#
#	Copyright Apple Computer, Inc. 1987 - 1990
#	All rights reserved.

#	Find the program parameter.

Unset program
For i In {"Parameters"}
	If "{i}" !~ /-≈/
		Set program "{i}"
		Break
	End
End
If "{program}" == ""
	Echo "### {0} - Specify a program to build." > Dev:StdErr
	Echo "# Usage - {0} program [options…]" > Dev:StdErr
	Exit 1
End

#	Select the makefile.

Set makefile `(Files -t TEXT "{program}".make || ∂
	Files -t TEXT MakeFile || Echo '""') ≥ Dev:Null`
If "{makefile}" == ""
	Echo "### {0} - No makefile exists for {program}." > Dev:StdErr
	Exit 1
End

#	Run Make.

Echo "# `Date -t` ----- Build commands for {program}."
Make {"Parameters"} -f "{makefile}"
