##
## Makefile for MLDL.
##
## This file is part of MLDL,
## the HP-48 Machine Language Development Library
##
## Copyright (c) 1991, 1992, 1993, 1994 Jan Brittenson
## All Rights Reserved.
##
## This version of the MLDL is released as Free Software. The license
## under which this version of the software and manual (jointly
## refered to as the MLDL) is distributed does not apply to any other
## releases of the MLDL. The author retains all copyright titles
## and hence the right to make future releases under different
## licensing terms.
## 
## This release of the MLDL is free software; you can redistribute it
## and/or modify it under the terms of the GNU General Public License
## as published by the Free Software Foundation; either version 2, or
## (at your option) any later version.
## 
## This release of the MLDL is distributed in the hope that it will be
## useful, but WITHOUT ANY WARRANTY; without even the implied warranty
## of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
## 
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, and
## request a copy.
##

VERSION = 1.9

BIN = mldl
LIST = mldl

MANDIST=manual/Rosetta manual/cover.ps manual/instr.tex manual/instrdefs.tex manual/mldl-ref.ps manual/mldl.idx manual/mldl.tex manual/mldl.text manual/mldldefs.tex manual/regs.tex manual/regsdefs.tex manual/keybd.ps manual/mldl.ind

SRCMLDL=mldl-src
BINMLDL=mldl

FLAGS = -j

SRC = rpl.star db.star disasm.star view.star disp.star step.star \
	kb.star trailer.star stdsyms.star arg.star data.star write.star \
	read.star server.star logo.star msg.star hp48.star


# Correct source file ordering is important!

SRCORDER = ./hp48 stdsyms rpl kb db arg disasm view disp msg \
	step server read write logo trailer data

all:	mldl

# Use STAR 1.04.4. STAR 2 still has a few bugs in it.

STAR=star1044
#STAR=star

mldl:	version.star $(SRC)
	$(STAR) $(FLAGS) -il $(BIN) version $(SRCORDER)

list:	version.star $(SRC)
	$(STAR) $(FLAGS) $(BIN) $(LIST) version $(SRCORDER)


# SREAD Utility

sread:	sread.star read.star write.star srdtrail.star stdsyms.star
	$(STAR) -j sread sread ./hp48 stdsyms sread read write srdtrail

# Misc tests

kt:	kt.star kb.star kbtrailer.star stdsyms.star
	$(STAR) -j -il kt ./hp48 stdsyms kt kb kbtrailer

# Make source distribution

dist:	src-dist bin-dist

src-dist:
	+rm -rf $(SRCMLDL)-$(VERSION)
	mkdir $(SRCMLDL)-$(VERSION)
	cp README $(SRC) Makefile kt.star kbtrailer.star LICENSE $(SRCMLDL)-$(VERSION)
	+mkdir $(SRCMLDL)-$(VERSION)/manual
	cp $(MANDIST) $(SRCMLDL)-$(VERSION)/manual
	find $(SRCMLDL)-$(VERSION) -print | xargs chmod +rw
	find $(SRCMLDL)-$(VERSION) -type d -print | xargs chmod +rwx
	tar -chpf $(SRCMLDL)-$(VERSION).tar $(SRCMLDL)-$(VERSION)
	gzip $(SRCMLDL)-$(VERSION).tar
	rm -rf $(SRCMLDL)-$(VERSION)

bin-dist: mldl
	+rm -rf $(BINMLDL)-$(VERSION)
	mkdir $(BINMLDL)-$(VERSION)
	cp mldl manual/mldl.dvi LICENSE $(BINMLDL)-$(VERSION)
	find $(BINMLDL)-$(VERSION) -print | xargs chmod +rw
	find $(BINMLDL)-$(VERSION) -type d -print | xargs chmod +rwx
	tar -chpf $(BINMLDL)-$(VERSION).tar $(BINMLDL)-$(VERSION)
	gzip $(BINMLDL)-$(VERSION).tar
	rm -rf $(BINMLDL)-$(VERSION)

# Clean up

clean:
	rm -f *.list manual/*.log manual/*.dvi manual/*.aux version.star


# Create version file

version.star:	Makefile
	@echo "# version.star"
	@echo "; Created by $(LOGNAME), `date`" >version.star
	@echo Version_number = $(VERSION) >>version.star

.PHONY:	clean dist src-dist bin-dist

