# Copyright (C) 1989, Digital Equipment Corporation
# All rights reserved.
# See the file COPYRIGHT for a full description.
#
# Last modified on Fri Jul 20 12:23:17 1990 by muller
#      modified on Fri Aug  4 13:14:00 1989 by kalsow
#****************************************************************


# For IBMR2, set CC to /bin/bsdcc; see note in util/config.dist-IBMR2 first.
# For AIX386, set CC to /usr/local/bin/hc -D_BSD -D_NO_PROTO
# or /bin/cc -D_BSD -D_NO_PROTO.
CC = /bin/cc

# For AIX386, set LIBS to -lbsd
LIBS=

TARGETS     = VAX DS3100 SPARC AP3000 AIX386 IBMR2 IBMRT HP300
CLONES      = VAX.obj DS3100.obj SPARC.obj AP3000.obj \
	      AIX386.obj IBMR2.obj IBMRT.obj HP300.obj
PORT_CLONES = cross port

all: imake FRC
	(cd system; .ROOT/util/m3fromC)
	(cd system/compiler; .ROOT/util/m3all finishCompiler)
	@for d in util libs tools doc contrib ; do \
	  (cd $$d; .ROOT/util/m3all) \
	  done

install: FRC
	@echo " "
	@cat COPYRIGHT
	@echo " "
	@echo " "
	@for d in util system libs tools contrib ; do \
	  (cd $$d; .ROOT/util/m3install) \
	  done

$(TARGETS): imake FRC
	@find . -name \*.$@ -print | awk -f .ROOT/util/config.awk | csh -x -f
	@for d in util system libs tools contrib legalese doc; do \
	  (cd $$d; .ROOT/util/m3public) \
	  done

$(CLONES): FRC
	@(cd util; $(CC) -o clone clone.c $(LIBS))
	@mv util/clone ..
	@../clone -v -w . ../$@
	@rm ../clone	

$(PORT_CLONES): FRC
	@(cd util; $(CC) -o clone clone.c $(LIBS))
	@mv util/clone ..
	@../clone -v -w . ../$@
	@rm ../clone
	@ find ../$@ -name \*.[im]c -exec /bin/rm {} \;

clean: FRC
	-@.ROOT/util/m3clean
	-@/bin/rm -f .ROOT/util/imake

tests: imake FRC
	@(cd tests; .ROOT/util/m3all test)

demos: imake FRC
	@(cd demos; .ROOT/util/m3all)

imake: FRC
	@(cd util; \
	   cpp=`cat config | sed -e 's/^CPP[ \t]*=[ \t]*//p' -e 'd'`; \
	   cc=`cat config | sed -e 's/^CC[ \t]*=[ \t]//p' -e 'd'`; \
	   sed -e s+M3_CPP+$$cpp+ imake.c > imake.foo.c; \
	   $$cc  -o imake imake.foo.c; \
	   /bin/rm -f imake.foo.c)


FRC:
