;#
;# Copyright 1998, The University of Texas at Austin ("U. T. Austin").
;# All rights reserved.
;#
;# By using this software the USER indicates that he or she has read,
;# understood and will comply with the following:
;#
;# U. T. Austin hereby grants USER permission to use, copy, modify, and
;# distribute this software and its documentation for any purpose and
;# without fee, provided that:
;#
;# 1. the above copyright notice appears in all copies of the software
;#    and its documentation, or portions thereof, and 
;# 2. a full copy of this notice is included with the software and its
;#    documentation, or portions thereof, and 
;# 3. neither the software nor its documentation, nor portions thereof,
;#    is sold for profit. Any commercial sale or license of this software,
;#    copies of the software, its associated documentation and/or
;#    modifications of either is strictly prohibited without the prior
;#    consent of U. T. Austin. 
;# 
;# Title to copyright to this software and its associated documentation
;# shall at all times remain with U. T. Austin. No right is granted to
;# use in advertising, publicity or otherwise any trademark, service
;# mark, or the name of U. T. Austin.
;# 
;# This software and any associated documentation are provided "as is,"
;# and U. T. AUSTIN MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESSED OR
;# IMPLIED, INCLUDING THOSE OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
;# PURPOSE, OR THAT USE OF THE SOFTWARE, MODIFICATIONS, OR ASSOCIATED
;# DOCUMENTATION WILL NOT INFRINGE ANY PATENTS, COPYRIGHTS, TRADEMARKS OR
;# OTHER INTELLECTUAL PROPERTY RIGHTS OF A THIRD PARTY. U. T. Austin, The
;# University of Texas System, its Regents, officers, and employees shall
;# not be liable under any circumstances for any direct, indirect, special,
;# incidental, or consequential damages with respect to any claim by USER
;# or any third party on account of or arising from the use, or inability
;# to use, this software or its associated documentation, even if U. T.
;# Austin has been advised of the possibility of those damages.
;# 
;# Submit commercialization requests to: Office of the Executive Vice
;# President and Provost, U. T. Austin, 201 Main Bldg., Austin, Texas,
;# 78712, ATTN: Technology Licensing Specialist.
;#
;# Makefile for npasswd dictionaries
;#
;# @(#)Jmakefile	1.8 08/18/98 (cc.utexas.edu)
;#
#include "../Jmake.local"

Initialize(BIN, $p_utildir)
Initialize(DICTS, $p_dictionaries)

TO_USE	= WORDS-TO-USE
PICK =	 `grep -v '^\#' $(TO_USE) | grep -v '^$$' | awk '{ print $$1 }'`

TerminalDependancy(all)

;#
;# Install dictionaries
;# If WHAT is empty, use list in "WORDS-TO-USE"
;#
Describe(install,	Make and install dict hash files)
install::
	-@if [ ! -f $(TO_USE) ]; then \
		echo Missing $(TO_USE) - see 0-README;\
		exit 0;\
	fi;\
	if [ -n "$(WHAT)" ]; then\
		files="$(WHAT)";\
	else\
		files=$(PICK);\
	fi;\
	for f in $$files; do\
		for x in '' .Z .gz; do\
			if [ -f $$f$$x ]; then\
				f=$$f$$x; ext="$$x"; break; \
			fi;\
		done;\
		if [ -r $$f ]; then\
			xd=`basename $$f`;\
			if [ -n "$$ext" ]; then xd=`basename $$xd $$ext`; fi;\
			$(MAKE) $(MFLAGS) DFILE=$$f DTARGET=$$xd $$xd.time;\
		else \
			echo Cannot find word list $$f;\
		fi;\
	done

;#
;# Remove dictionaries
;# If WHAT is empty, use list in "WORDS-TO-USE"
;#
Describe(deinstall,	Remove dict hash files)
deinstall::
	-@if [ -n "$(WHAT)"]; then\
		files="$(WHAT)";\
	else\
		files=$(PICK);\
	fi;\
	for f in $$files; do\
		xd=`basename $$f`;\
		(cd $(DICTS) || exit 1; set -x; $(RM) $$xd.hwm $$xd.pwd $$xd.pwi);\
		rm -f $$xd.time;\
	done

;#
;# Dependancy for indivdual dictonary files.
;# This is to prevent "make install" from rebuilding dictionaries if
;# the source file has not changed since the last build.
;#
$(DTARGET).time:  $(DFILE)
	@(set -x; $(BIN)/makedict -o $(DICTS)/$(DTARGET) $(DFILE))
	@chmod 0644 $(DICTS)/$(DTARGET).*
	@touch $(DTARGET).time

NoDebug()
NoDepend()
NoLint()

;#
;# End Makefile
