#
# Copyright (C) 1991 Texas Instruments Incorporated.
#
# Permission is granted to any individual or institution to use, copy, modify,
# and distribute this software, provided that this complete copyright and
# permission notice is maintained, intact, in all copies and supporting
# documentation.
#
# Texas Instruments Incorporated provides this software "as is" without
# express or implied warranty.
#

help:
	# Usage:  cd ice;  make -f util/Makefile_tar <option>
	# where <option>  is one of the following:
	# help		-- Display this message
	# tar_cool	-- Create tar file of cool for building purposes.
	# tarfile_cool	-- Create a tar file of cool for build purposes.
	# tar_ice	-- Copy ice directory structure to tape
	#		   including executables and object files
	# tarfile_ice	-- Create a tar file of  ice directory structure.
	#		   including executables and object files
	# copy_ice	-- Copy ice & cool files into /epoch/misc/ice.

ICEDIR = .

# This will copy off all the necessary cool directories for the purpose of
# rebuilding or using the COOL library.  
# No links are followed, thus they must be made by the top level make link.
# Usage:  cd ice;  make util/Makefile_tar

tar_cool: /tmp/uncool
	cd $(ICEDIR)/..;\
	tar XcofBFFv /tmp/uncool /dev/rst8 ice
	rm /tmp/uncool

tarfile_cool: /tmp/uncool
	cd $(ICEDIR)/..;\
	tar XcofBFF /tmp/uncool /tmp/cool.tar ice
	compress -v /tmp/cool.tar
	uuencode /tmp/cool.tar.Z cool.tar.Z > $(HOME)/cool.uue"
	echo "COOL tar file is in your home directory in ~/cool.uue"
	rm /tmp/uncool /tmp/cool.tar.Z

# note: make turns $$ into $
/tmp/uncool:
	cd $(ICEDIR)/..; find ice -print > /tmp/coolfiles
	# don't copy *.o *.a *.s *.i *..c *.bak *.out *.imp
	egrep "^.*\.(o|a|s|i|\.c|bak|out|imp)$$" /tmp/coolfiles > /tmp/uncool
	# don't copy */core */.?* *# *~
	egrep ".*/core$$|.*/\..+|.*#$$|.*~$$" /tmp/coolfiles >> /tmp/uncool
	# don't copy program executables, except for util and scripts dirs
	cd $(ICEDIR)/..; find ice -perm -0111 -type f -print | egrep -v 'util' | egrep -v 'scripts' >> /tmp/uncool;
	# don't copy RCS directories
	# cd $(ICEDIR)/..; find ice -name 'RCS' -print  >> /tmp/uncool;
	# don't include certain directories
	echo "ice/bin" >> /tmp/uncool
	echo "ice/buglist" >> /tmp/uncool
	echo "ice/foils" >> /tmp/uncool
	echo "ice/include" >> /tmp/uncool
	echo "ice/lib" >> /tmp/uncool
	echo "ice/id_comp" >> /tmp/uncool
	echo "ice/iv" >> /tmp/uncool
	echo "ice/utilold" >> /tmp/uncool
	echo "ice/coollite" >> /tmp/uncool
	sort /tmp/uncool > /tmp/uncoolsorted
	mv /tmp/uncoolsorted /tmp/uncool
	rm /tmp/coolfiles

tar_ice: /tmp/notcool
	cd $(ICEDIR)/..;\
	tar XhcfBFFv /tmp/uncoolsorted /dev/rst8 ice
	rm /tmp/uncool /tmp/uncoolsorted

tarfile_ice: /tmp/notcool
	cd $(ICEDIR)/..;\
	tar XhcfBFFv /tmp/uncoolsorted /tmp/ice.tar ice
	compress -v /tmp/ice.tar
	uuencode /tmp/cool.tar.Z ice.tar.Z > $(HOME)/ice.uue"
	echo "ICE tar file is in your home directory in ~/ice.uue"
	rm /tmp/uncool /tmp/uncoolsorted /tmp/cool.tar.Z

/tmp/notcool:
	cd $(ICEDIR)/.. ;\
	find ice -name '.?*' -print   > /tmp/uncool; \
	find ice -name '*~' -print   >> /tmp/uncool; \
	find ice -name '#*#' -print  >> /tmp/uncool; \
	find ice -name '*.o' -print  >> /tmp/uncool; \
	find ice -name '*.i' -print  >> /tmp/uncool; \
	find ice -name '*..c' -print >> /tmp/uncool; \
	find ice -name 'core' -print >> /tmp/uncool; \
	find ice -name 'RCS' -print  >> /tmp/uncool; \
	echo "ice/buglist" >> /tmp/uncool;
	echo "ice/foils" >> /tmp/uncool;
	echo "ice/iv" >> /tmp/uncool;
	echo "ice/utilold" >> /tmp/uncool;
	echo "ice/id_comp" >> /tmp/uncool;
	sort /tmp/uncool > /tmp/uncoolsorted;

copy_machine = osage
copy_path = /epoch/misc/ice
copy_ice:
	cd $(ICEDIR)/.. ;\
	util/copy_ice $(copy_machine) $(copy_path);
