SYSTEM=BSD

BINDIR=/usr/local/bin		# where the driver executables (tx, ux) go
DOCDIR=/usr/local/share/doc/t3x	# where the documents reside
EXMDIR=/usr/local/share/examples/t3x	# where the examples go
TXBASE=/usr/local/t3x		# the T3X base directory for `make install'
TXDIR=$(TXBASE)/r5		# the T3X base dir for release 5
MANDIR=/usr/local/man/man1	# where the manual pages go
CATDIR=/usr/local/man/cat1	# where the preformatted manual pages go

default:
	@echo
	@echo "First read the file INSTALL.DOC, then type 'make all'".
	@echo

# You might comment out Cross86 and/or Extensions.
# Extensions should be commented out, if X11 is not installed.
# At least etxx/txx/Makefile.BSD should be edited in this case.

all:	Build Compiler Native Cross86 Extensions

Build:
	(cd build; make -f Makefile.$(SYSTEM))

Compiler:
	(cd compiler; make -f Makefile.$(SYSTEM))

Native:
	(cd native; make -f Makefile.$(SYSTEM))

Cross86:
	(cd s86kit; make -f Makefile.$(SYSTEM))

Extensions:
	(cd etxx/txx; make -f Makefile.$(SYSTEM))

clean:
	(cd build; make -f Makefile.$(SYSTEM) clean)
	(cd compiler; make -f Makefile.$(SYSTEM) clean)
	(cd native; make -f Makefile.$(SYSTEM) clean)
	(cd s86kit; make -f Makefile.$(SYSTEM) clean)
	(cd etxx/txx; make -f Makefile.$(SYSTEM) clean)

clobber:
	(cd build; make -f Makefile.$(SYSTEM) clobber)
	(cd compiler; make -f Makefile.$(SYSTEM) clobber)
	(cd native; make -f Makefile.$(SYSTEM) clobber)
	(cd s86kit; make -f Makefile.$(SYSTEM) clobber)
	(cd etxx/txx; make -f Makefile.$(SYSTEM) clobber)
	rm -f t3xr5C.zip t3x-r5-12.tar.gz

# If your install utility does not support the
#	install -d directory
# syntax (like pre-2.2 FreeBSDs'), use
#	-mkdir directory
# instead.

install:
	install -o bin -g bin -d -m 0755 $(TXBASE)
	install -o bin -g bin -d -m 0755 $(TXDIR)
	install -o bin -g bin -d -m 0755 $(TXDIR)/bin
	install -o bin -g bin -d -m 0755 $(TXDIR)/lib
	install -o bin -g bin -d -m 0755 $(TXDIR)/inc
	install -o bin -g bin -d -m 0755 $(DOCDIR)
	install -o bin -g bin -d -m 0755 $(EXMDIR)
	# -mkdir $(TXDIR)
	# -mkdir $(TXDIR)/bin
	# -mkdir $(TXDIR)/lib
	# -mkdir $(TXDIR)/inc
	# -mkdir $(DOCDIR)
	# -mkdir $(EXMDIR)
	install -o bin -g bin -C -m 0755 compiler/tx.sh $(TXDIR)/bin/tx
	install -o bin -g bin -C -m 0755 compiler/txx-static $(TXDIR)/bin/txx
	install -o bin -g bin -C -m 0755 compiler/ux $(TXDIR)/bin
	install -o bin -g bin -C -m 0755 compiler/txinfo $(TXDIR)/bin
	install -o bin -g bin -C -m 0755 native/txtrn $(TXDIR)/bin
	install -o bin -g bin -C -m 0755 native/txopt $(TXDIR)/bin
	install -o bin -g bin -C -m 0755 native/txpp $(TXDIR)/bin
	install -o bin -g bin -C -m 0755 native/txcg386 $(TXDIR)/bin
	install -o bin -g bin -C -m 0755 native/txcg386e $(TXDIR)/bin
	install -o bin -g bin -C -m 0755 native/txcg86a $(TXDIR)/bin
	install -o bin -g bin -C -m 0755 native/txcg86t $(TXDIR)/bin
	install -o bin -g bin -C -m 0755 native/txcgc $(TXDIR)/bin
	install -o bin -g bin -C -m 0755 native/libtx.a $(TXDIR)/lib
	install -o bin -g bin -C -m 0644 native/txcgc_wrap $(TXDIR)/lib
	install -o bin -g bin -C -m 0644 inc/basic.inc $(TXDIR)/inc
	install -o bin -g bin -C -m 0644 inc/ios.inc $(TXDIR)/inc
	install -o bin -g bin -C -m 0644 inc/mem.inc $(TXDIR)/inc
	install -o bin -g bin -C -m 0644 doc/t3x-ref.html $(DOCDIR)
	install -o bin -g bin -C -m 0644 doc/t3x-user.html $(DOCDIR)
	install -o bin -g bin -C -m 0644 doc/tcode.html $(DOCDIR)
	install -o bin -g bin -C -m 0644 doc/txpp.html $(DOCDIR)
	install -o bin -g bin -C -m 0644 examples/*.t $(EXMDIR)
	ln -fs $(TXDIR)/bin/tx $(BINDIR)/tx
	ln -fs $(TXDIR)/bin/ux $(BINDIR)/ux
	ln -fs $(TXDIR)/bin/txinfo $(BINDIR)/txinfo
	ln -fs $(TXDIR)/bin/txx $(BINDIR)/txx
	ln -fs $(TXDIR)/bin/txpp $(BINDIR)/txpp
	(cd s86kit; make -f Makefile.$(SYSTEM) TXDIR=$(TXDIR) \
		BINDIR=$(BINDIR) CATDIR=$(CATDIR) install)
	(cd etxx/txx; make -f Makefile.$(SYSTEM) TXDIR=$(TXDIR) \
		BINDIR=$(BINDIR) DOCDIR=$(DOCDIR) EXMDIR=$(EXMDIR) install)

arc:
	rm -f t3xr5C.zip
	zip -r9@ t3xr5C.zip <Manifest

cp:
	mount -t msdos /dev/fd0 /mnt
	cp t3xr5C.zip /mnt/t3xr5C.zip
	cp t3xr5C.zip /mnt/t3xr5C.b
	umount /dev/fd0
