#
#	This makefile makes the Framework Forms Editor
#
#	If you are using this makefile as a template for a new subsystem makefile,
#	sections which need to be changed are preceded by '#####'.
#	NOTE: This makefile only contains the rules for building a (minimal framework)
#	application. If your new subsystem is building something else (e.g. dumpfiles
#	or a library), find a different makefile (e.g. in :inc:mac or :src:framewrk:)
#	to use as your template.
#

#	Location of the Layers project
L	= {LAYERS}

#	Location of the Layers Source Include directory
I	= {L}inc:

#	Location of the Demilayr directory
D	= {L}src:demilayr:

#	Location of the FrameWork directory
F	= {L}src:framewrk:

#	Sibling-invariant name of this directory
H	= {L}tools:formedit:exe:

#	Directory where objects (and final target) will go
O	= {OBJDIR}


#####	Directories for different versions of final target
DBGDIR	= {L}tools:formedit:exe.dbg:
TSTDIR	= {L}tools:formedit:exe.tst:
SHPDIR	= {L}tools:formedit:exe.shp:
PRODIR	= {L}tools:formedit:exe.pro:


#####	Files on which every file of a given type depends
FPP	= "{MPW}Our Tools:formpp"
INCLS_CXX	=	{DMP}FramHead.dmp {H}formedit.hxx {H}llst.hxx 
				{O}control.frm {O}control.hxx {O}strings.h
INCLS_DES	=	{O}forms.map {FPP} "{MPW}Our Tools:fmtp.tpl"

#####	Component files for final target
OBJS_CXX_SHP	=	{O}_vtables.grp.obj 
					{O}formedit.obj {O}formedt2.obj {O}feinter.obj {O}feinter2.obj 
					{O}llst.obj {O}fewin.obj {O}taborder.obj {O}iosm.obj {O}browse.obj

OBJS_CXX_DBG	=	

FORM_MAPS		=	{I}myforms.map {H}myforms.map

DES_SHP			=	{H}control.des {H}control2.des {H}control3.des {H}control4.des 
					{H}dialog.des {H}status.des

#	Groupings of component files
OBJS_CXX		=	{OBJS_CXX_SHP} {OBJS_CXX_DBG}

OBJS_SHP		=	{OBJS_CXX_SHP}
# OBJS_DBG is specifically overridden to be "" for test/ship/proff
OBJS_DBG		=	{OBJS_CXX_DBG}

OBJS_TARGET		=	{OBJS_SHP} {OBJS_DBG} {LIBS}

#####	Common commands
do_build	= BuildProgram -n "{MAKEFLAGS}" -f "{H}MACFILE" target
do_clean	= Delete -i {O}.map; Delete -i {O}.hxx; Delete -i {O}.frm; Delete -i {O}.obj; Delete -i {O}.tmp
do_clobber	= Delete -i {O}

#	Rules to live by
goal			debug
both			debug_build ship_build
all				debug_build test_build ship_build proff_build
clean			clean_all
clobber			clobber_all

debug		 debug_build
test		 test_build
ship		 ship_build
proff		 proff_build

debug_build	 debug_dir debug_flags
	{do_build}
test_build	 test_dir test_flags
	{do_build}
ship_build	 ship_dir ship_flags
	{do_build}
proff_build	 proff_dir proff_flags
	{do_build}

debug_flags		
	Set	MAKEFLAGS ""
	Set	DMP	"{I}Mac:dmp.dbg:"
	Set LIBS "{D}lib.dbg:demilayr.lib {F}lib.dbg:framewrk.lib"
	Set DEFS2 "-d DEBUG -d MINTEST"
	Set	CFLAGS2 ""
	Set	LINKFLAGS2 ""
	Export DMP LIBS DEFS2 CFLAGS2 LINKFLAGS2

test_flags		
	Set	MAKEFLAGS "-d OBJS_DBG=''"
	Set	DMP	"{I}Mac:dmp.tst:"
	Set LIBS "{D}lib.tst:demilayr.lib {F}lib.tst:framewrk.lib"
	Set DEFS2 "-d MINTEST"
	Set	CFLAGS2 ""
	Set	LINKFLAGS2 ""
	Export DMP LIBS DEFS2 CFLAGS2 LINKFLAGS2

ship_flags		
	Set	MAKEFLAGS "-d OBJS_DBG=''"
	Set	DMP	"{I}Mac:dmp.shp:"
	Set LIBS "{D}lib.shp:demilayr.lib {F}lib.shp:framewrk.lib"
	Set DEFS2 ""
	Set	CFLAGS2 "-mbg off"
	Set	LINKFLAGS2 ""
	Export DMP LIBS DEFS2 CFLAGS2 LINKFLAGS2

proff_flags		
	Set	MAKEFLAGS "-d OBJS_DBG=''"
	Set	DMP	"{I}Mac:dmp.pro:"
	Set LIBS "{D}lib.pro:demilayr.lib {F}lib.pro:framewrk.lib {Libraries}proff.o"
	Set DEFS2 "-u USEDUMP"
	Set	CFLAGS2 "-sym full -opt nodelink -trace on"
	Set	LINKFLAGS2 "-sym full"
	Export DMP LIBS DEFS2 CFLAGS2 LINKFLAGS2

debug_dir	
	Set OBJDIR "{DBGDIR}"
test_dir	
	Set OBJDIR "{TSTDIR}"
ship_dir	
	Set OBJDIR "{SHPDIR}"
proff_dir	
	Set OBJDIR "{PRODIR}"

clean_all		errors_ok debug_clean test_clean ship_clean 
				proff_clean errors_not_ok
clean_both		errors_ok debug_clean ship_clean errors_not_ok

clean_debug		errors_ok debug_clean errors_not_ok
clean_test		errors_ok test_clean errors_not_ok
clean_ship		errors_ok ship_clean errors_not_ok
clean_proff		errors_ok proff_clean errors_not_ok

debug_clean  debug_dir
	{do_clean}
test_clean  test_dir
	{do_clean}
ship_clean  ship_dir
	{do_clean}
proff_clean  proff_dir
	{do_clean}

clobber_all		errors_ok debug_clobber test_clobber ship_clobber 
				proff_clobber errors_not_ok
clobber_both		errors_ok debug_clobber ship_clobber errors_not_ok

clobber_debug		errors_ok debug_clobber errors_not_ok
clobber_test		errors_ok test_clobber errors_not_ok
clobber_ship		errors_ok ship_clobber errors_not_ok
clobber_proff		errors_ok proff_clobber errors_not_ok

debug_clobber  debug_dir
	{do_clobber}
test_clobber  test_dir
	{do_clobber}
ship_clobber  ship_dir
	{do_clobber}
proff_clobber  proff_dir
	{do_clobber}

errors_ok		
	Set Exit 0

errors_not_ok	
	Set Exit 1

#	Compiler and assembler flags

CXX_FLAGS = -mf -n -b2 -opt full -i {O} -i {H}Mac: -i {H} -i {I}Mac: -i {I}
CXX_DEFS  = -d c_plusplus

CFLAGS	= -b2 -opt full -warnings on -i {H}Mac: -i {H} -i {I}Mac: -i {I}
CDEFS	= -d MAC

#	Temporary files
T1	= {TMP}caz1.tmp
T2	= {TMP}caz2.tmp
T3	= {TMP}caz3.tmp


#	Common build rules

{O}			{H}Mac: {H}

# simple compile line for files which don't use GROUPS pseudomacro
# defs are included in dump file -- make sure to build "clean" if you change them!
.obj			.cxx
		CPlus {DepDir}{Default}.cxx -s {Default} {CXX_FLAGS} {CFLAGS2} -load "{TMP}FramHead.dmp" -o {Targ}

# complex compile line for files which DO use the GROUPS pseudomacro
.grp.obj		.cxx
		CPlus -e2 {DepDir}{Default}.cxx {CXX_FLAGS} {CFLAGS2} -load "{DMP}GrpsHead.dmp" > "{T1}"
		precxx {CDEFS} {DEFS2} <"{T1}" >"{O}{Default}.tmp"
		Delete "{T1}"
		Cplus -s {Default} {CXX_FLAGS} {CFLAGS2} "{O}{Default}.tmp" -load {DMP}GrpsHead.dmp -o {Targ}
		# Delete "{O}{Default}.tmp"

.obj		.c
	C {DepDir}{Default}.c -s {Default} {CFLAGS} {CDEFS} {CFLAGS2} {DEFS2} -o {Targ}

.frm		.des
	# MPW Make WILL generate both rules, so leave this one out
	#	{FPP} -dialog {H}{Default} -f {H}{Default}.frm -h {H}{Default}.hxx -m {O}forms.map

.hxx		.des
		{FPP} {CDEFS} {DEFS2} -dialog {DepDir}{Default} -f {TargDir}{Default}.frm -h {TargDir}{Default}.hxx -m {O}forms.map


##### Put subsystem-specific make rules here #####

{O}strings.h {O}strings.r		{H}strtab.s
	stringpp {Deps}
	Move -y strings.h strings.r {O}

{O}forms.map	  {FORM_MAPS} {FPP}
		{FPP} {CDEFS} {DEFS2} -merge {FORM_MAPS} -m {O}forms.map

{O}subclass.cxx	 {O}forms.map {FPP}
		{FPP} {CDEFS} {DEFS2} -class -f {Targ} -m {O}forms.map

{O}control.frm		{DES_SHP} {INCLS_DES}
		{FPP} {CDEFS} {DEFS2} -dialog {DES_SHP} -f {O}control.frm -h {O}control.hxx -m {O}forms.map

{O}control.hxx		{DES_SHP} {INCLS_DES}
	# MPW Make WILL generate both rules, so leave this one out
	#	{FPP} -dialog {DES_SHP} -f {O}control.frm -h {O}control.hxx -m {O}forms.map


copy_dmp	
	Duplicate -y {DMP}FramHead.dmp "{TMP}"

remove_dmp	
	Delete -i "{TMP}FramHead.dmp"


#####	Rules for final target
target		copy_dmp {O}FormEdit remove_dmp

{O}FormEdit			{OBJS_TARGET}
	Link -w -mf {LINKFLAGS2} 
		{Deps} 
		"{Libraries}"Runtime.o 
		"{Libraries}"Interface.o 
		"{CLibraries}"StdClib.o 
		-o {Targ}

{O}FormEdit			{O}strings.r
	Rez -a {Deps} -o {Targ}

{O}FormEdit			{H}FormEdit.rez
	Rez -a {Deps} -i {H} -i {I}Mac: -i {I} {CDEFS} {DEFS2} -o {Targ}
	SetFile {Targ} -t 'APPL' -c 'MsFE' -a Bi	# set bundle, clear inited


#####	Dependencies for final target components
#		(Put more specific ones first)

{O}_vtables.grp.obj		{INCLS_CXX} {DMP}GrpsHead.dmp {H}browse.hxx

{O}formedit.obj			{INCLS_CXX} {H}browse.hxx {H}foedrsid.h {I}fwrsid.h

{O}feinter.obj			{INCLS_CXX} {O}control.frm {O}control.hxx {O}subclass.cxx 
						{H}browse.hxx {H}foedrsid.h

{O}feinter2.obj			{INCLS_CXX} {H}browse.hxx {H}foedrsid.h

{O}fewin.obj			{INCLS_CXX} {H}foedrsid.h {I}fwrsid.h

{O}browse.obj			{INCLS_CXX} {H}browse.hxx

{OBJS_CXX}				{INCLS_CXX}

