# ---------------------------------------------------------------------------
# Makefile -- install the fonts in Font Collection 1.0
# 
# Copyright (c) 1991 Doug Brenner
# 
#    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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA, or send
#    electronic mail to the the author.
# 
# This Makefile is an attempt to allow easy font installation under NeXT
# Software Release 1.0 and 2.0.  The fonts are copied into the correct
# locations and buildafmdir is run to update the font index.
#
# Running applications may have to be closed and restarted before the new
# font information is available to them.
# 
# See the package target below for another means of font distribution and
# installation.  (Everything but the buildafmdir can be done without going
# into a shell.)
#
# Doug Brenner <dbrenner@umaxc.weeg.uiowa.edu>
# ---------------------------------------------------------------------------

# Change INSTALLDIR to indicate where the fonts should be installed.  The
# only suggested choices are $(HOME)/Library/Fonts and /LocalLibrary/Fonts.

INSTALLDIR	= $(HOME)/Library/Fonts

# These are for creating an Installer package out of the fonts.  (This is
# an interesting means of distribution, but not without its problems.)

PACKAGEPGM	= /NextApps/Installer.app/package
PACKAGEDIR	= FontCollection-1.0-free
PACKAGEINFO	= $(PACKAGEDIR).info
PACKAGETIFF	= $(PACKAGEDIR).tiff

# Shell command to collect font names from $(PACKAGEDIR).

FONTS		= `(cd $(PACKAGEDIR); ls -d *.font | sed 's/\.font$$//')`

# ---------------------------------------------------------------------------

# I'm not certain if there is a better way to determine which version of the
# OS is active, or if there is a better way of invoking install1.0/2.0
# without calling make again.

install:	$(PACKAGEDIR)
		@if test -d /NextLibrary/Packages; then make install2.0; \
		else make install1.0; fi

# Install procedure for Software Release 1.0 (maybe 0.9 too).  The AFM files
# go into $(INSTALLDIR)/afm; the PostScript files into $(INSTALLDIR)/outline.
# Please note that the Macintosh bit-maps and "readme" files are not copied.
# (There is no place for them unless new directories are created.)

install1.0:	$(INSTALLDIR)/afm $(INSTALLDIR)/outline
		@echo 'Installing fonts for 1.0 in $(INSTALLDIR)...'
		@for i in $(FONTS); \
		   do echo $$i; \
		   cp $(PACKAGEDIR)/$$i.font/$$i $(INSTALLDIR)/outline; \
		   cp $(PACKAGEDIR)/$$i.font/$$i.afm $(INSTALLDIR)/afm; \
		done
		buildafmdir $(INSTALLDIR)

# Install procedure for Software Release 2.0.  While the 1.0 scheme is
# supported with version 2.0, this procedure uses the new method using one
# font directory for each font.  This allows the Macintosh bit-maps and
# "readme" files to be included with the font.

install2.0:	$(INSTALLDIR)
		@echo 'Installing fonts for 2.0 in $(INSTALLDIR)...'
		@for i in $(FONTS); \
		   do echo $$i; \
		   cp -r $(PACKAGEDIR)/$$i.font $(INSTALLDIR); \
		done
		buildafmdir $(INSTALLDIR)
		@echo ''
		@echo 'To reduce the used space in $(INSTALLDIR), you can'
		@echo '"make deletebitmaps".  This removes the Macintosh'
		@echo 'bit-maps which were included for completeness. (~1 Mb).'

# Create any missing directories for Software Release 1.0 or 2.0.

$(INSTALLDIR) $(INSTALLDIR)/afm $(INSTALLDIR)/outline:
		mkdirs $@

# Remove Macintosh bit-maps distributed with the files.  (~1 Mb)  This
# is only useful under Software Release 2.0.

deletebitmaps:	$(INSTALLDIR)
		@echo 'Deleting Macintosh bit-maps from $(INSTALLDIR)...'
		find $(INSTALLDIR) -name '*.bmap' -print \
		   -exec rm -f \{\} \;

# Remove informational files distributed with the files.  (~64 Kb)  This
# is only useful under Software Release 2.0.

deletereadmes:	$(INSTALLDIR)
		@echo 'Deleting "readme" files from $(INSTALLDIR)...'
		find $(INSTALLDIR) -name '*.readme' -print \
		   -exec rm -f \{\} \;

# This procedure creates an Installer package that can be used to distribute
# these fonts.  This is an interesting means of giving the fonts to others,
# but I think it has a few problems yet.  If you plan on futher distribution
# of these fonts via floppy or OD, you might try "make package".  Then you
# need only give people the resulting *.pkg file.

package:	$(PACKAGEPGM) $(PACKAGEDIR) $(PACKAGEINFO) $(PACKAGETIFF)
		@echo 'Deleting "stupid files" from $(PACKAGEDIR)...'
		@find $(PACKAGEDIR) -name '.places' -print \
		   -exec rm -f \{\} \;
		@find $(PACKAGEDIR) -name '.list' -print \
		   -exec rm -f \{\} \;
		@find $(PACKAGEDIR) -name '.dir.wmd' -print \
		   -exec rm -f \{\} \;
		$(PACKAGEPGM) $(PACKAGEDIR) $(PACKAGEINFO) $(PACKAGETIFF)
