#
# VNPForth - Compiled native Forth for IA32 Linux systems
# Copyright (C) 2000  Simon Baldwin (simonb@sco.com)
#
# This program 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
# of the License, or (at your option) any later version.
#
# This program 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#

# release number
RELEASE		= 1.0

# distribution and temporary directory, man, bin, and lib directories
DISTDIR		= distribution
TEMPDIR		= vnpforth-$(RELEASE)
MANDIR		= /usr/local/man
LIBDIR		= /lib
USRLIBDIR	= /usr/lib
USRBINDIR	= /usr/bin

default: all

#
# Top level makefile - descends into subdirectories and executes the make in
# these one at a time.  For obvious reasons, the compiler must be built
# first, the runtime libraries next, and the example programs last.
#

all clean:
	make -C compiler $@
	make -C runtime $@
	make -C forth $@

verify:
	make -C forth $@

clobber: clean

#
# Install and uninstall targets
#
install: all
	cp compiler/forthc		$(USRBINDIR)
	strip $(USRBINDIR)/forthc
	gzip -c compiler/forthc.1	>$(MANDIR)/man1/forthc.1.gz
	cp runtime/libforth.so		$(LIBDIR)
	cp runtime/libforth.a		$(LIBDIR)
	cp runtime/forthrt1.o		$(USRLIBDIR)
	gzip -c runtime/libforth.3	>$(MANDIR)/man3/libforth.3.gz

uninstall:
	rm -f $(USRBINDIR)/forthc $(MANDIR)/man1/forthc.1.gz
	rm -f $(LIBDIR)/libforth.so $(LIBDIR)/libforth.a \
						$(MANDIR)/man3/libforth.3.gz
	rm -f $(USRLIBDIR)/forthrt1.o

#
# Distribution build target
#
distribution: clean
	rm -rf $(DISTDIR) $(TEMPDIR)
	mkdir $(DISTDIR); mkdir $(TEMPDIR)
	for i in COPYING README Makefile compiler runtime forth; do	\
		ln -s `pwd`/$$i $(TEMPDIR);				\
	done
	tar cvhf $(DISTDIR)/vnpforth-$(RELEASE).tar $(TEMPDIR)/*
	gzip -9 $(DISTDIR)/vnpforth-$(RELEASE).tar
	cd $(DISTDIR); mv vnpforth-$(RELEASE).tar.gz vnpforth-$(RELEASE).tgz
	rm -rf $(TEMPDIR)

floppy: distribution
	cd $(DISTDIR); tar cvf /dev/fd0 vnpforth-$(RELEASE).tgz
