/*
 *  Copyright (C) 1993  Petri Heinila
 *
 *  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., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 *  Author can be connected by email from Petri.Heinila@lut.fi
 */

/*
 * InsertArchive(files,dir)   - put files into packet tree into dir
 * PackArchive(name)          - pack packet tree name
 * MakeArchive(dirs)          - archive in subdirs also
 * InstallPerl(program,dest)  - intall perl (*.pl) script
 */


/********************************************************************** 
 * Archive rules
 * - set $(ATOP) before use, e.g. ATOP = /tmp/xyzzy (see PackArchive)
 **********************************************************************/

/*
 * InsertArchive - insert files to specified dir under ATOP, use this
 * in Imakefiles in all directories
 * - copy files to temporary directory, symbolic link are so get rig off
 */
#ifndef InsertArchive
#define InsertArchive(files,dir) @@\
subarchive:: @@\
	MakeDir($(ATOP)/dir) @@\
	$(CP) files $(ATOP)/dir
#endif

/*
 * PackArchive - ,use this in Imakefile in main directory
 */
#ifndef PackArchive
#define PackArchive(name)				@@\
ATOP = /tmp/name					@@\
TAR = gtar						@@\
archive: subarchive						@@\
	$(RM) name.tar.Z					@@\
	(cd $(ATOP);cd ..;\					@@\
	$(RM) name.tar name.tar.Z;\				@@\
	$(TAR) cvfhz name.tar.gz `$(BASENAME) $(ATOP)`;\	@@\
/*	$(COMPRESS) name.tar*/)				@@\
	$(MV) $(ATOP)/../name.tar.gz .			  @@\
	$(RM) -r $(ATOP)
#endif

/*
 * PackShar - use this in Imakefile in main directory
 */

#ifndef PackShar
#define PackShar(version,name,me)					@@\
shar: subarchive					@@\
	$(RM) name.version.shar.*			@@\
	(cd $(ATOP); cd ..;\				@@\
	$(RM) name.tar name.tar.Z;\			@@\
	find . -type f -print | sort | shar -S -a -s me -c -o name.version.shar -L50)	@@\
	$(MV) $(ATOP)/../name.version.shar* .		@@\
	$(RM) -r $(ATOP)
#endif

/*
 * MakeArchive - declare here subdirs to be archived, use this in
 * imake files in all directories
 */
#ifndef MakeArchive
#define MakeArchive(dirs) 						@@\
NamedTargetSubdirs(subarchive,dirs,"archiving",'ATOP=$(ATOP)',subarchive)
#endif

/*
 * InstallPerl - install a perl script.
 */
#ifndef InstallPerl
#define	InstallPerl(program,dest)					@@\
install:: program.pl						@@\
	MakeDir($(DESTDIR)dest)						@@\
	$(INSTALL) -c $(INSTBINFLAGS) program.pl $(DESTDIR)dest/program
#endif /* InstallPerl */


/*** end of config.rules ***/
