INSTALL_DIR=/usr/local/DQS/bin
BIN_DIR=/usr/local/DQS/bin
CONF_DIR=/usr/local/DQS/common/conf
DOC_DIR=/usr/local/DQS/common/doc
LIB_DIR=/usr/local/DQS/local/lib
MAN1_DIR=/usr/local/DQS/man/man1
MAN3_DIR=/usr/local/DQS/man/man3
ROOT=0
DQS_ROOT=0
SYSGRP=0
DQS_SYSGRP=0
CC=cc
CFLAGS=-g
LFLAGS=
# the next line is a "majic-cookie" - don't remove it
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# sets up an arc dependant subdirectory under DQS/ARCS
# ans builds the default distribution

default	:
	UTIL/make_arcs make CC=$(CC) -f Makefile

#******************************************************
# dirs - Make Install Directories

dirs:
	-mkdir -p $(INSTALL_DIR) $(ARC_DIR) $(BIN_DIR)
	-mkdir -p $(DOC_DIR) $(LIB_DIR) $(MAN1_DIR) $(MAN3_DIR)
	-mkdir -p $(CONF_DIR)
	-chmod 755 $(CONF_DIR)

#******************************************************
# config - Configure DQS

config:
	cd CONFIG;make clean;make CC=$(CC);./config;cd ..

#******************************************************
# config - Configure DQS

host_ck:
	$(CC) -o CONFIG/host_ck CONFIG/host_ck.c;CONFIG/host_ck

#******************************************************
# unconfig - Unconfigure DQS

unconfig:
	cd CONFIG;make clean;make CC=$(CC);./config -u;cd ..

#******************************************************
# sets up an arc dependant subdirectory under DQS/ARCS
# ans builds the DQS checpointing library

ckpt:
	UTIL/make_arcs make CC=$(CC) -f Makefile $@

#******************************************************
# install the default distribution

installbin: dirs
	UTIL/make_arcs make CC=$(CC) -f Makefile $@ \
	BIN_DIR=$(BIN_DIR) DQS_ROOT=$(DQS_ROOT) \
	DQS_SYSGRP=$(DQS_SYSGRP)

#******************************************************
# install the sample conf files

installconf: dirs
	UTIL/install -o $(DQS_ROOT) -g $(DQS_SYSGRP) \
	-m 744 SRC/conf_file $(CONF_DIR)/conf_file
	UTIL/install -o $(DQS_ROOT) -g $(DQS_SYSGRP) \
	-m 744 SRC/resolve_file $(CONF_DIR)/resolve_file
	UTIL/install -o $(DQS_ROOT) -g $(DQS_SYSGRP) \
	-m 700 SRC/key_file $(CONF_DIR)/key_file

#******************************************************
# installall

installall: installbin installconf


#******************************************************
clean:
	rm -r -f ARCS
	cd CONFIG;	make -f Makefile clean
	cd SRC;         make -f Makefile clean
	cd UTIL;        make -f Makefile clean
	cd UTIL/TEST;   make -f Makefile clean
	rm -f *~ manifest *.out Part* *.tar *.Z *.gz OUT core typescript
	rm -r -f CVS.tar.gz CONFIG/usr

######################################################
######################################################
######################################################
# multi-architecture makes 

#******************************************************
# pall - Parrallel Make
# uses "rsh" to make binaries for multiple arcs concurrently
# see .PMakefile
# output from all makes placed in the file OUT
# ex:
# make pall
# make pdirs
# make pinstallbin
# make pinstallall

pall:
	@$(MAKE) -f Makefile rdist
	@cd UTIL;$(MAKE) -f Makefile pmake
	UTIL/pmake .PMakefile OUT

#******************************************************
# pdirs - Parallel Make Dirs

pdirs:
	@cd UTIL;$(MAKE) -f Makefile pmake
	UTIL/pmake .PMakefile OUT dirs

#******************************************************
#pinstallbin - Parallel Install Bin

pinstallbin:
	@cd UTIL;$(MAKE) -f Makefile pmake
	UTIL/pmake .PMakefile OUT installbin

#******************************************************
# pinstallall - Parallel Installal

pinstallall:
	@cd UTIL;$(MAKE) -f Makefile pmake
	UTIL/pmake .PMakefile OUT installall

######################################################
######################################################
######################################################
# the rest of these are for development only
# read the disclaimers before using them!

#******************************************************
# builds the user_interface and design docs.
# also builds a set of DQS function man pages
# and reference docs.
# DON'T DO THIS UNLESS YOU HAVE LATEX and DVIPS!
# otherwise you will trash the preformatted docs!

doc:
	cd SRC; make -f Makefile $@

#******************************************************
# make the readme file(already done for distribution)
# DON'T DO THIS UNLESS YOU HAVE LATEX and DVIPS!
# otherwise you will trash the preformatted docs!

readme:
	cd DOC/readme; make CC=$(CC) -f Makefile $@

#******************************************************
# this is really just for development
# DON'T DO THIS UNLESS YOU HAVE LATEX and DVIPS!
# otherwise you will trash the preformatted docs!

everything:	dqs ckpt installbin	\
		installlib installman1	\
		installman3 installdoc

#******************************************************
# this is really just for development
# DON'T DO THIS UNLESS YOU HAVE LATEX and DVIPS!
# otherwise you will trash the preformatted docs!

distribution:   readme doc clean

#******************************************************

backup:	gzip
	cp DQS.tar.gz /ds9/a/users/queuing/DQS.tar.gz.`date +%m.%d.%y.%H:%M`

#******************************************************

backupcvs:
	cd /margit/c/users/dqs;tar -cvf CVS.tar CVS; \
	rm -f CVS.tar.gz; /usr/local/bin/gzip CVS.tar; \
	cp CVS.tar.gz /ds9/a/users/queuing/CVS.tar.gz.`date +%m.%d.%y.%H:%M`

#******************************************************

rdist:	clean
	cd .. ;/usr/ucb/rdist -f DQS/.distfile

#******************************************************

manifest: clean
	cd ..;/usr/local/bin/findsrc -dy -oDQS/manifest DQS;

#******************************************************

tar:	manifest
	cd ..;tar -cvf DQS.tar DQS; mv DQS.tar DQS; \
	cd DQS;compress DQS.tar

#******************************************************

gzip:	manifest
	cd ..;tar -cvf DQS.tar DQS; mv DQS.tar DQS; \
	cd DQS;/usr/local/bin/gzip DQS.tar

#******************************************************

fd0:	gzip
	gnutar -cvMf /dev/fd0 DQS.tar.gz

#******************************************************

fd1:	gzip
	gnutar -cvMf /dev/fd1 DQS.tar.gz

#******************************************************

cvsfd0:
	rm -f CVS.tar.gz
	gnutar -czvf CVS.tar.gz /margit/c/users/dqs/CVS 
	gnutar -cvMf /dev/fd0 CVS.tar.gz

