##########################################################################
#
# $Id: makemeta,v 1.9 93/05/12 10:32:54 chrisg Exp Locker: chrisg $
#
##########################################################################
pragma +m4096

ifndef $(SAS6OPTIONS)
    SAS6OPTIONS=
endif

ifndef $(ONEPROTOPERFILE)
    ONEPROTOPERFILE=
endif

ifndef $(SUBSYSNAME)
    SUBSYSNAME=
endif

ifndef $(SAS5OPTIONS)
    SAS5OPTIONS=
endif

ifndef $(COMPILER_DEFINES)
    COMPILER_DEFINES=
endif

ifndef $(NONRCS_FILES)
    NONRCS_FILES=
endif

ifndef $(PRE_COMPILE)
    PRE_COMPILE=
endif


ifndef $(PRE_INTERNAL)
    PRE_INTERNAL=
endif

ifndef $(POST_INTERNAL)
    POST_INTERNAL=
endif

ifndef $(SUBSYSTEMS)
    SUBSYSTEMS=
endif

ifndef $(PROTOINC)
    PROTOINC=
endif
ifndef $(PROTOINC2)
    PROTOINC2=
endif
ifndef $(AFILES)
    AFILES=
endif
ifndef $(AFILES2)
    AFILES2=
endif
ifndef $(AFILES3)
    AFILES3=
endif
ifndef $(ASMOPTS)
    ASMOPTS=
endif
ifndef $(CFILES)
    CFILES=
endif
ifndef (HFILES)
    HFILES=
endif
ifndef $(HOMEDIR)
    HOMEDIR=
endif
ifndef $(HOMEINCL)
    HOMEINCL=
endif
ifndef $(INFILES)
    INFILES=
endif
ifndef $(STARTUP_OBJECT)
    STARTUP_OBJECT=
endif
ifndef $(INCLUDEDIR)
    INCLUDEDIR=
endif
ifndef$(LIBFILES)
    LIBFILES=
endif

ifndef $(LINKERLIBS)
    LINKERLIBS=lib:amiga.lib
endif
ifndef $(LINKEROPTS)
    LINKEROPTS=
endif
ifndef $(TEMPDIR)
    TEMPDIR=
endif
ifndef $(ASM_PREPROCESSOR)
    ASM_PREPROCESSOR=
endif

ifndef $(CVERSION)
    CVERSION=
endif

if eq($(CVERSION),6)
	DEFAULTLINKER= slink
else
	DEFAULTLINKER= blink
endif

ifndef$(LINKER)
    LINKER=$(DEFAULTLINKER)
endif



if eq($(HOMEDIR),)
	HOMEDIR=v$(VERSION):src/$(MODULETYPE)/$(SYSTEM)
endif

ifndef$(HOMESFD)
	HOMESFD=v$(VERSION):lib/sfd
endif

ifndef$(HOMEDOC)
	HOMEDOC=v$(VERSION):doc
endif

if neq($(SUBSYSNAME),)
 LOCDIR=$(HOMEDIR)/$(SUBSYSNAME)
 MAINFILE=/$(SUBSYSNAME).lib
 SUBDOCS=
else
 LOCDIR=$(HOMEDIR)
 MAINFILE=$(SYSTEM).ld
 LIBFILES=${addsuffix .lib,$(SUBSYSTEMS)}
 SUBDOCS=${addsuffix /autodoc.doc,$(SUBSYSTEMS)}
endif

 RCSDIR=$(LOCDIR)/RCS/


all: $(MAINFILE)

.PHONY: all

.include dependencies

if eq($(TEMPDIR),)
    TEMPDIR=t:
endif

if eq($(INCLUDEDIR),)
    INCLUDEDIR=include:
endif

if eq($(ASMOPTS),)
    ASMOPTS=OPTIMON 0xfdc00000 ADDSYM DEBUG
endif

if eq($(LINKER),)
    LINKER=blink
endif




if eq($(HOMEINCL),)
	HOMEINCL=v$(VERSION):include/$(SYSTEM)
endif


OFILES=${addsuffix .obj,${basename $(AFILES)}} ${addsuffix .obj,${basename $(CFILES)}} ${addsuffix .obj,${basename $(AFILES2)}} ${addsuffix .obj,${basename $(AFILES3)}}

rev:
	bumprev $(VERSION) $(SYSTEM)_rev


RCS_Link:
	echo >RCS_LINK $(RCSDIR)

diff:
	@if neq($(CFILES),)
		rcsdiff $(CFILES)
	@endif
	@if neq($(AFILES),)
		rcsdiff $(AFILES)
	@endif
	@if neq($(AFILES2),)
		rcsdiff $(AFILES2)
	@endif
	@if neq($(AFILES3),)
		rcsdiff $(AFILES3)
	@endif
	@if neq($(HFILES),)
		rcsdiff $(HFILES)
	@endif
	@if neq($(INFILES),)
		rcsdiff $(INFILES)
	@endif
	@if neq($(SUBSYSTEMS),)
		@echo >t:d1 foreach i in $(SUBSYSTEMS)
		@echo >>t:d1 cd $$i
		@echo >>t:d1 bmake diff
		@echo >>t:d1 cd /
		@echo >>t:d1 end
		@execute t:d1
		@delete t:d1 quiet
 	@endif


checkout: RCS_Link
	@if neq($(CFILES),)
		co $(CFILES)
	@endif
	@if neq($(NONRCS_FILES),)
		@echo >t:c1 foreach i in $(NONRCS_FILES)
		@echo >>t:c1 copy  $(LOCDIR)/ noline
		@echo >>t:c1 "$$i *"*""
		@echo >>t:c1 end
		@execute t:c1
		@delete t:c1
	@endif
	@if neq($(AFILES),)
		co $(AFILES)
	@endif
	@if neq($(AFILES2),)
		co $(AFILES2)
	@endif
	@if neq($(AFILES3),)
		co $(AFILES3)
	@endif
	@if neq($(HFILES),)
		co $(HFILES)
	@endif
	@if neq($(INFILES),)
		co $(INFILES)
	@endif
	@if neq($(OTHERFILES),)
		co $(OTHERFILES)
	@endif
	@if neq($(SUBSYSTEMS),)
		@echo >t:x1 foreach i in $(SUBSYSTEMS)
		@echo >>t:x1  if not exists $$i
		@echo >>t:x1   makedir $$i
		@echo >>t:x1 endif
		@echo >>t:x1 cd $$i
		@echo >>t:x1 echo '*N' >dependencies
		@echo >>t:x1 echo >RCS_Link $(HOMEDIR)/ noline
		@echo >>t:x1 $$i/RCS/
		@echo >>t:x1 co makefile
		@echo >>t:x1 bmake checkout
		@echo >>t:x1 cd /
		@echo >>t:x1 end
		@execute t:x1
 	@endif

checkoutlock: RCS_Link
	@if neq($(CFILES),)
		co -l $(CFILES)
	@endif
	@if neq($(NONRCS_FILES),)
		@echo >t:c1 foreach i in $(NONRCS_FILES)
		@echo >>t:c1 copy  $(LOCDIR)/ noline
		@echo >>t:c1 "$$i *"*""
		@echo >>t:c1 end
		@execute t:c1
		@delete t:c1
	@endif
	@if neq($(AFILES),)
		co -l $(AFILES)
	@endif
	@if neq($(AFILES2),)
		co -l $(AFILES2)
	@endif
	@if neq($(AFILES3),)
		co -l $(AFILES3)
	@endif
	@if neq($(HFILES),)
		co -l $(HFILES)
	@endif
	@if neq($(INFILES),)
		co -l $(INFILES)
	@endif
	@if neq($(OTHERFILES),)
		co -l $(OTHERFILES)
	@endif
	@if neq($(SUBSYSTEMS),)
		@echo >t:x1 foreach i in $(SUBSYSTEMS)
		@echo >>t:x1  if not exists $$i
		@echo >>t:x1   makedir $$i
		@echo >>t:x1 endif
		@echo >>t:x1 cd $$i
		@echo >>t:x1 echo >RCS_Link $(HOMEDIR)/ noline
		@echo >>t:x1 $$i/RCS/
		@echo >>t:x1 co makefile
		@echo >>t:x1 bmake checkoutlock
		@echo >>t:x1 cd /
		@echo >>t:x1 end
		@execute t:x1
 	@endif

%.asm: .INVISIBLE
	@if nexists($@)
		co -u $@
	@endif

%.c: .INVISIBLE
	@if nexists($@)
		co -u $@
	@endif

%.obj:%.asm
	@if neq($(ASM_PREPROCESSOR),)
		@$(ASM_PREPROCESSOR) $*.asm >t:tmp1.asm
		hx68 from t:tmp1.asm TO $*.obj INCDIR $(INCLUDEDIR) $(ASMOPTS) QUIET
	@else
		hx68 from $*.asm to $*.obj INCDIR $(INCLUDEDIR) $(ASMOPTS) QUIET
	@endif

%.obj:%.c
	@if neq($(ONEPROTOPERFILE),)
		sc NOGPDATA GENPROTO NOGENPROTOSTATIC DEFINE=MAKE_PROTOS INCLUDEDIRECTORY=$(INCLUDEDIR) $*.c
	@endif
	@if neq($(CVERSION),6)
		lc $(SAS5OPTIONS) ${addprefix -D,$(COMPILER_DEFINES)} -i$(INCLUDEDIR) -o$*.obj $*.c
	@else
		sc $(SAS6OPTIONS) ${addprefix DEFINE=,$(COMPILER_DEFINES)} INCLUDEDIR=$(INCLUDEDIR) OBJECTNAME=$*.obj $*.c
	@endif


%.lib:
	@echo >t:l1 cd $*
	@echo >>t:l1 "bmake"
	@echo >>t:l1 cd /
	@execute t:l1

$(MAINFILE): $(PRE_COMPILE) $(OFILES) $(LIBFILES) dependencies makefile
	@if neq($(SUBSYSNAME),)
	 join #?.obj as $(MAINFILE)
	@else
	 $(LINKER) from $(STARTUP_OBJECT) $(OFILES) to $(MAINFILE) lib $(LIBFILES) $(LINKERLIBS) $(LINKEROPTS)
    @endif


clean:
	@if exists($(MAINFILE))
		delete $(MAINFILE) quiet
	@endif
	@echo >bmake_d_temp.obj "hello"
	delete #?.obj quiet
	@if neq($(SUBSYSTEMS),)
		@echo >t:x1 foreach i in $(SUBSYSTEMS)
		@echo >>t:x1 cd $$i
		@echo >>t:x1 bmake clean
		@echo >>t:x1 cd /
		@echo >>t:x1 end
		@execute t:x1
 	@endif

doc:
	@if neq($(SUBSYSTEMS),)
		@echo >t:x1 foreach i in $(SUBSYSTEMS)
		@echo >>t:x1 cd $$i
		@echo >>t:x1 bmake doc
		@echo >>t:x1 cd /
		@echo >>t:x1 end
		@execute t:x1
 	@endif
	@if neq($(SUBSYSNAME),)
		join #?.asm #?.c as autodoc.doc
	@else
		join #?.asm #?.c $(SUBDOCS) as $(TEMPDIR)$(SYSTEM).doc
		autodoc >$(SYSTEM).doc $(TEMPDIR)$(SYSTEM).doc
		copy $(SYSTEM).doc $(HOMEDOC) nopro
		delete $(TEMPDIR)$(SYSTEM).doc
	@endif

headers:
	@if neq($(INFILES),)
		copy $(INFILES) $(HOMEINCL) nopro
	@endif
	@if neq($(HFILES),)
		copy $(HFILES) $(HOMEINCL) nopro
	@endif

protos:
	@echo >$(SUBSYSNAME).protos "// automatically generated prototypes"
	@echo >t:temp.perl "s/ /\n/g; print;"
	@echo >t:x1 ""
	@if neq($(CFILES),)
		@echo >t:flist1 "${strip $(CFILES)}"
		@perl -n t:temp.perl t:flist1 >t:flist2
		@delete t:flist1 quiet
		@echo >>t:x1  sc NOGPDATA GENPROTO NOGENPROTOSTATIC PARAMETERS=STACK DEFINE=MAKE_PROTOS INCLUDEDIRECTORY=$(INCLUDEDIR) with t:flist2
		@echo >>t:x1 join #?_protos.h as $(SUBSYSNAME).protos
	@endif
	@if neq($(AFILES),)
		@echo >>t:x1 foreach i in ${strip $(AFILES)}
		@echo >>t:x1  search $$i >>$(SUBSYSNAME).protos __asm nonum
		@echo >>t:x1 end
	@endif
	@if neq($(AFILES2),)
		@echo >>t:x1 foreach i in ${strip $(AFILES2)}
		@echo >>t:x1  search $$i >>$(SUBSYSNAME).protos __asm nonum
		@echo >>t:x1 end
	@endif
	@if neq($(AFILES3),)
		@echo >>t:x1 foreach i in ${strip $(AFILES3)}
		@echo >>t:x1  search $$i >>$(SUBSYSNAME).protos __asm nonum
		@echo >>t:x1 end
	@endif
	@protect t:x1 +s
	@t:x1
	@splat -o "^; " "" $(SUBSYSNAME).protos
	@splat -o "^;" "" $(SUBSYSNAME).protos
	@splat -o "//__asm" "" $(SUBSYSNAME).protos
	@if neq($(PROTOINC),)
		echo >>$(SUBSYSNAME).protos "$(PROTOINC)"
	@endif
	@if neq($(PROTOINC2),)
		echo >>$(SUBSYSNAME).protos "$(PROTOINC2)"
	@endif
	@if neq($(SUBSYSTEMS),)
		@echo >t:x2 foreach j in $(SUBSYSTEMS)
		@echo >>t:x2 if not exists $$j/$$j.protos
		@echo >>t:x2 echo >$$j/$$j.protos "// this is a comment"
		@echo >>t:x2 endif
		@echo >>t:x2 end
		@echo >>t:x2 foreach j in $(SUBSYSTEMS)
		@echo >>t:x2 cd $$j
		@echo >>t:x2 "bmake protos"
		@echo >>t:x2 cd /
		@echo >>t:x2 end
		@execute t:x2
 	@endif

$(SUBSYSNAME).protos :

.phony: $(SUBSYSNAME).protos


depend:
 	@echo $(AFILES)
	 @echo >maked0 ""
	 @if neq($(AFILES),)
	  @echo >>maked0 $(AFILES)
	 @endif
	 @if neq($(AFILES2),)
	  @echo >>maked0 $(AFILES2)
	 @endif
	 @if neq($(AFILES3),)
	  @echo >>maked0 $(AFILES3)
	 @endif
	 @if neq($(CFILES),)
	  @echo >>maked0 $(CFILES)
	 @endif
	 @splat -o "[\t ]+" "\n" maked0
	 @splat -o "^..+" "dep1 &" maked0
	 @echo >t:maked1 "alias dep1 depend [] makedx"
	 @join t:maked1 maked0 as maked1
	 @splat -o "\x0d" "" maked1
	 @execute maked1
	 @splat -o "\.o" ".obj" makedx
	 @copy makedx dependencies
	 @echo >>dependencies ""
	 @delete maked1
	 @delete maked0
	 @delete makedx
	@if neq($(SUBSYSTEMS),)
		@echo >t:x2 foreach j in $(SUBSYSTEMS)
		@echo >>t:x2 cd $$j
		@echo >>t:x2 bmake depend
		@echo >>t:x2 cd /
		@echo >>t:x2 end
		@execute t:x2
 	@endif

toremote:
	@if neq($(CFILES),)
		copy $(CFILES) $(LOCDIR) nopro
	@endif
	@if neq($(NONRCS_FILES),)
		copy $(NONRCS_FILES) $(LOCDIR) nopro
	@endif
	@if neq($(AFILES),)
		copy $(AFILES) $(LOCDIR) nopro
	@endif
	@if neq($(AFILES2),)
		copy $(AFILES2) $(LOCDIR) nopro
	@endif
	@if neq($(AFILES3),)
		copy $(AFILES3) $(LOCDIR) nopro
	@endif
	@if neq($(HFILES),)
		copy $(HFILES) $(LOCDIR) nopro
	@endif
	@if neq($(INFILES),)
		copy $(INFILES) $(LOCDIR) nopro
	@endif
	@if neq($(OTHERFILES),)
		copy $(OTHERFILES) $(LOCDIR) nopro
	@endif
	copy $(MAINFILE) $(LOCDIR) nopro

internal: $(PRE_INTERNAL) $(MAINFILE) toremote $(POST_INTERNAL)
	@if neq($(SUBSYSTEMS),)
		@echo >t:x2 foreach j in $(SUBSYSTEMS)
		@echo >>t:x2 cd $$j
		@echo >>t:x2 bmake toremote
		@echo >>t:x2 cd /
		@echo >>t:x2 end
		@execute t:x2
	@endif
	@if exists($(SYSTEM)_lib.sfd)
		copy $(SYSTEM)_lib.sfd $(HOMESFD)  nopro
	@endif

release: internal headers doc

Who :
	@echo >t:x1 ""
	@if neq($(CFILES),)
		@echo >>t:x1 foreach i in ${strip $(CFILES)}
		@echo >>t:x1 "rlog -h -L $$i | *"" noline
		@echo >>t:x1 "'ExecIO STEM FileLines.'; USER='';" noline
		@echo >>t:x1 "DO Line=1 to FileLines.0;" noline
		@echo >>t:x1 "IF INDEX(FileLines.Line,'Working file:')>0 THEN DO; PARSE VAR FileLines.Line 'Working file:'FileName; FileName=STRIP(FileName); END;" noline
		@echo >>t:x1 "IF INDEX(FileLines.Line,'locks:')>0 THEN DO; PARSE VAR FileLines.Line 'locks:' User ':'; User=STRIP(User); END; END ; "noline
		@echo >>t:x1 "IF LENGTH(USER)>0 THEN DO; fl='t:Locks.'||User; IF ~exists(fl) THEN 'echo > 'fl' *"*"**NFiles owned by 'User'*"*"'" noline
		@echo >>t:x1 "; 'echo >>'fl '" noline
		@echo >>t:x1 "*"*"    'FileName'*"*"'" noline
		@echo >>t:x1 "; END"
		@echo >>t:x1 end
	@endif
	@if neq($(AFILES),)
		@echo >>t:x1 foreach i in ${strip $(AFILES)}
		@echo >>t:x1 "rlog -h -L $$i | *"" noline
		@echo >>t:x1 "'ExecIO STEM FileLines.'; USER='';" noline
		@echo >>t:x1 "DO Line=1 to FileLines.0;" noline
		@echo >>t:x1 "IF INDEX(FileLines.Line,'Working file:')>0 THEN DO; PARSE VAR FileLines.Line 'Working file:'FileName; FileName=STRIP(FileName); END;" noline
		@echo >>t:x1 "IF INDEX(FileLines.Line,'locks:')>0 THEN DO; PARSE VAR FileLines.Line 'locks:' User ':'; User=STRIP(User); END; END ; "noline
		@echo >>t:x1 "IF LENGTH(USER)>0 THEN DO; fl='t:Locks.'||User; IF ~exists(fl) THEN 'echo > 'fl' *"*"**NFiles owned by 'User'*"*"'" noline
		@echo >>t:x1 "; 'echo >>'fl '" noline
		@echo >>t:x1 "*"*"    'FileName'*"*"'" noline
		@echo >>t:x1 "; END"
		@echo >>t:x1 end
	@endif
	@if neq($(AFILES2),)
		@echo >>t:x1 foreach i in ${strip $(AFILES2)}
		@echo >>t:x1 "rlog -h -L $$i | *"" noline
		@echo >>t:x1 "'ExecIO STEM FileLines.'; USER='';" noline
		@echo >>t:x1 "DO Line=1 to FileLines.0;" noline
		@echo >>t:x1 "IF INDEX(FileLines.Line,'Working file:')>0 THEN DO; PARSE VAR FileLines.Line 'Working file:'FileName; FileName=STRIP(FileName); END;" noline
		@echo >>t:x1 "IF INDEX(FileLines.Line,'locks:')>0 THEN DO; PARSE VAR FileLines.Line 'locks:' User ':'; User=STRIP(User); END; END ; "noline
		@echo >>t:x1 "IF LENGTH(USER)>0 THEN DO; fl='t:Locks.'||User; IF ~exists(fl) THEN 'echo > 'fl' *"*"**NFiles owned by 'User'*"*"'" noline
		@echo >>t:x1 "; 'echo >>'fl '" noline
		@echo >>t:x1 "*"*"    'FileName'*"*"'" noline
		@echo >>t:x1 "; END"
		@echo >>t:x1 end
	@endif
	@if neq($(AFILES3),)
		@echo >>t:x1 foreach i in ${strip $(AFILES3)}
		@echo >>t:x1 "rlog -h -L $$i | *"" noline
		@echo >>t:x1 "'ExecIO STEM FileLines.'; USER='';" noline
		@echo >>t:x1 "DO Line=1 to FileLines.0;" noline
		@echo >>t:x1 "IF INDEX(FileLines.Line,'Working file:')>0 THEN DO; PARSE VAR FileLines.Line 'Working file:'FileName; FileName=STRIP(FileName); END;" noline
		@echo >>t:x1 "IF INDEX(FileLines.Line,'locks:')>0 THEN DO; PARSE VAR FileLines.Line 'locks:' User ':'; User=STRIP(User); END; END ; "noline
		@echo >>t:x1 "IF LENGTH(USER)>0 THEN DO; fl='t:Locks.'||User; IF ~exists(fl) THEN 'echo > 'fl' *"*"**NFiles owned by 'User'*"*"'" noline
		@echo >>t:x1 "; 'echo >>'fl '" noline
		@echo >>t:x1 "*"*"    'FileName'*"*"'" noline
		@echo >>t:x1 "; END"
		@echo >>t:x1 end
	@endif
	@if neq($(HFILES),)
		@echo >>t:x1 foreach i in ${strip $(HFILES)}
		@echo >>t:x1 "rlog -h -L $$i | *"" noline
		@echo >>t:x1 "'ExecIO STEM FileLines.'; USER='';" noline
		@echo >>t:x1 "DO Line=1 to FileLines.0;" noline
		@echo >>t:x1 "IF INDEX(FileLines.Line,'Working file:')>0 THEN DO; PARSE VAR FileLines.Line 'Working file:'FileName; FileName=STRIP(FileName); END;" noline
		@echo >>t:x1 "IF INDEX(FileLines.Line,'locks:')>0 THEN DO; PARSE VAR FileLines.Line 'locks:' User ':'; User=STRIP(User); END; END ; "noline
		@echo >>t:x1 "IF LENGTH(USER)>0 THEN DO; fl='t:Locks.'||User; IF ~exists(fl) THEN 'echo > 'fl' *"*"**NFiles owned by 'User'*"*"'" noline
		@echo >>t:x1 "; 'echo >>'fl '" noline
		@echo >>t:x1 "*"*"    'FileName'*"*"'" noline
		@echo >>t:x1 "; END"
		@echo >>t:x1 end
	@endif
	@if neq($(INFILES),)
		@echo >>t:x1 foreach i in ${strip $(INFILES)}
		@echo >>t:x1 "rlog -h -L $$i | *"" noline
		@echo >>t:x1 "'ExecIO STEM FileLines.'; USER='';" noline
		@echo >>t:x1 "DO Line=1 to FileLines.0;" noline
		@echo >>t:x1 "IF INDEX(FileLines.Line,'Working file:')>0 THEN DO; PARSE VAR FileLines.Line 'Working file:'FileName; FileName=STRIP(FileName); END;" noline
		@echo >>t:x1 "IF INDEX(FileLines.Line,'locks:')>0 THEN DO; PARSE VAR FileLines.Line 'locks:' User ':'; User=STRIP(User); END; END ; "noline
		@echo >>t:x1 "IF LENGTH(USER)>0 THEN DO; fl='t:Locks.'||User; IF ~exists(fl) THEN 'echo > 'fl' *"*"**NFiles owned by 'User'*"*"'" noline
		@echo >>t:x1 "; 'echo >>'fl '" noline
		@echo >>t:x1 "*"*"    'FileName'*"*"'" noline
		@echo >>t:x1 "; END"
		@echo >>t:x1 end
	@endif
	@if neq($(OTHERFILES),)
		@echo >>t:x1 foreach i in ${strip $(OTHERFILES)}
		@echo >>t:x1 "rlog -h -L $$i | *"" noline
		@echo >>t:x1 "'ExecIO STEM FileLines.'; USER='';" noline
		@echo >>t:x1 "DO Line=1 to FileLines.0;" noline
		@echo >>t:x1 "IF INDEX(FileLines.Line,'Working file:')>0 THEN DO; PARSE VAR FileLines.Line 'Working file:'FileName; FileName=STRIP(FileName); END;" noline
		@echo >>t:x1 "IF INDEX(FileLines.Line,'locks:')>0 THEN DO; PARSE VAR FileLines.Line 'locks:' User ':'; User=STRIP(User); END; END ; "noline
		@echo >>t:x1 "IF LENGTH(USER)>0 THEN DO; fl='t:Locks.'||User; IF ~exists(fl) THEN 'echo > 'fl' *"*"**NFiles owned by 'User'*"*"'" noline
		@echo >>t:x1 "; 'echo >>'fl '" noline
		@echo >>t:x1 "*"*"    'FileName'*"*"'" noline
		@echo >>t:x1 "; END"
		@echo >>t:x1 end
	@endif
	@execute t:x1
	@if neq($(SUBSYSTEMS),)
		@echo >t:x2 foreach j in $(SUBSYSTEMS)
		@echo >>t:x2 cd $$j
		@echo >>t:x2 "bmake Who"
		@echo >>t:x2 cd /
		@echo >>t:x2 end
		@execute t:x2
		@echo >>t:locks. That's all
		@list lformat "type t:%s" t:locks.#? > t:x1
		@execute t:x1
		@delete t:locks.#?
 	@endif

.DEFAULT:
	@echo

