# 
# Copyright 1986, 1987, 1988, 1989 University of Wisconsin
# 
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose and without fee is hereby granted,
# provided that the above copyright notice appear in all copies and that
# both that copyright notice and this permission notice appear in
# supporting documentation, and that the name of the University of
# Wisconsin not be used in advertising or publicity pertaining to
# distribution of the software without specific, written prior
# permission.  The University of Wisconsin makes no representations about
# the suitability of this software for any purpose.  It is provided "as
# is" without express or implied warranty.
# 
# THE UNIVERSITY OF WISCONSIN DISCLAIMS ALL WARRANTIES WITH REGARD TO
# THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS. IN NO EVENT SHALL THE UNIVERSITY OF WISCONSIN  BE LIABLE FOR
# ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
# 
# Authors:  Allan Bricker and Michael J. Litzkow,
# 	         University of Wisconsin, Computer Sciences Dept.
# 
# 




#
# The following variables must be passed in to this makefile:
#
#	SRCDIR	=	The pathname (relative or absolute) of the source
#				directory (eg. ../src, /var/home/condor/CONDOR/src)
#
#	DSTDIR	=	The pathname (relative or absolute) of the directory
#				which will contain the installed binaries and libraries.
#				There must be "bin" and "lib" subdirectories within DSTDIR.
#
#	COPTS	=	Default flags to cc (eg -O, -g)
#
#	IDENT	=	Any #defines which are not automatically supplied
#				by cpp (eg. -Dsunos40 or -Dsunos32).  Note that
#				cpp provides definitions for architectures (eg.
#				vax, sun, mc68020, sparc)
#

DIRECTORY=util_lib

PDIR=$(SRCDIR)/$(DIRECTORY)
CFLAGS=$(COPTS) -I$(SRCDIR)/h $(IDENT)

#
#	Options to 'ctags'
#
TFLAGS=-dt

#
#	Each file in the CSRC list should be prepended by $(PDIR).
#
CSRC= \
	$(PDIR)/blankline.c \
	$(PDIR)/config.c \
	$(PDIR)/condor_config.c \
	$(PDIR)/ctrace.c \
	$(PDIR)/do_connect.c \
	$(PDIR)/dprintf.c \
	$(PDIR)/dprintf_config.c \
	$(PDIR)/except.c \
	$(PDIR)/history.c \
	$(PDIR)/job_queue.c \
	$(PDIR)/ltrunc.c \
	$(PDIR)/mkargv.c \
	$(PDIR)/proc.c \
	$(PDIR)/signames.c \
	$(PDIR)/strdup.c \
	$(PDIR)/status.c \
	$(PDIR)/stricmp.c \
	$(PDIR)/expr.c \
	$(PDIR)/perror.c \
	$(PDIR)/condor_errlst.c \
	$(PDIR)/detach.c

SSRC=

SRC=$(CSRC) $(SSRC)

OBJ = blankline.o config.o do_connect.o dprintf.o dprintf_config.o except.o \
	  history.o job_queue.o ltrunc.o mkargv.o proc.o signames.o \
	  strdup.o stricmp.o expr.o perror.o condor_errlst.o condor_config.o \
	  ctrace.o status.o detach.o
# 	 ndbm.o 

LIB=../util_lib/util_lib.a ../xdr_lib/xdr_lib.a

PROGRAMS=util_lib.a
CLEANUP=$(OBJ) $(PROGRAMS) $(PDIR)/Makefile.bak

all: $(PROGRAMS)

ALWAYS:

release: $(PROGRAMS)
	@echo No installation for: $(PROGRAMS)

lint: ALWAYS
	lint -Cutil -DLINT -I$(SRCDIR)/h $(IDENT) $(CSRC)

clean: ALWAYS
	rm -f $(CLEANUP)

tags: ALWAYS
	cd $(PDIR) ; ctags $(TFLAGS) $(CSRC)

#############################################################################
# Put program specific things here
#############################################################################

util_lib.a: $(OBJ)
	rm -f util_lib.a
	ar r util_lib.a $(OBJ)
	ranlib util_lib.a

perror.o: $(PDIR)/perror.c
	cc -c $(CFLAGS) $(PDIR)/perror.c

detach.o: $(PDIR)/detach.c
	cc -c $(CFLAGS) $(PDIR)/detach.c

condor_errlst.o: $(PDIR)/condor_errlst.c
	cc -c $(CFLAGS) $(PDIR)/condor_errlst.c

blankline.o: $(PDIR)/blankline.c
	cc -c $(CFLAGS) $(PDIR)/blankline.c

config.o: $(PDIR)/config.c
	cc -c $(CFLAGS) $(PDIR)/config.c

condor_config.o: $(PDIR)/condor_config.c
	cc -c $(CFLAGS) $(PDIR)/condor_config.c

ctrace.o: $(PDIR)/ctrace.c
	cc -c $(CFLAGS) $(PDIR)/ctrace.c

do_connect.o: $(PDIR)/do_connect.c
	cc -c $(CFLAGS) $(PDIR)/do_connect.c

dprintf.o: $(PDIR)/dprintf.c
	cc -c $(CFLAGS) $(PDIR)/dprintf.c

dprintf_config.o: $(PDIR)/dprintf_config.c
	cc -c $(CFLAGS) $(PDIR)/dprintf_config.c

except.o: $(PDIR)/except.c
	cc -c $(CFLAGS) $(PDIR)/except.c

expr.o: $(PDIR)/expr.c
	cc -c $(CFLAGS) $(PDIR)/expr.c

history.o: $(PDIR)/history.c
	cc -c $(CFLAGS) $(PDIR)/history.c

job_queue.o: $(PDIR)/job_queue.c
	cc -c $(CFLAGS) $(PDIR)/job_queue.c

ltrunc.o: $(PDIR)/ltrunc.c
	cc -c $(CFLAGS) $(PDIR)/ltrunc.c

mkargv.o: $(PDIR)/mkargv.c
	cc -c $(CFLAGS) $(PDIR)/mkargv.c

# ndbm.o: $(PDIR)/ndbm.c
# 	cc -c $(CFLAGS) $(PDIR)/ndbm.c

proc.o: $(PDIR)/proc.c
	cc -c $(CFLAGS) $(PDIR)/proc.c

signames.o: $(PDIR)/signames.c
	cc -c $(CFLAGS) $(PDIR)/signames.c

strdup.o: $(PDIR)/strdup.c
	cc -c $(CFLAGS) $(PDIR)/strdup.c

status.o: $(PDIR)/status.c
	cc -c $(CFLAGS) $(PDIR)/status.c

stricmp.o: $(PDIR)/stricmp.c
	cc -c $(CFLAGS) $(PDIR)/stricmp.c

depend: ALWAYS
	grep '^#include' $(CSRC) $(PDIR)/Makefile | grep -v '<' | \
	      sed 's/:[^"]*"\([^"]*\)".*/: \1/' | \
	      sed 's/\.c/.o/' | \
		  sed 's;$(PDIR)/;;' | \
		  sed 's;: ;: $$\(SRCDIR)/h/;' | \
	awk ' { if ($$1 != prev) { print rec; rec = $$0; prev = $$1; } \
		else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \
		       else rec = rec " " $$2 } } \
	      END { print rec } ' > makedep
	echo '$$r makedep' >>eddep
	echo '/^# DO NOT DELETE THIS LINE/+1,$$d' >eddep
	echo '$$r makedep' >>eddep
	echo 'w' >>eddep
	/bin/cp $(PDIR)/Makefile $(PDIR)/Makefile.bak
	ed - $(PDIR)/Makefile < eddep
	rm eddep makedep

# DO NOT DELETE THIS LINE -- make depend uses it

config.o: $(SRCDIR)/h/trace.h $(SRCDIR)/h/expr.h $(SRCDIR)/h/files.h
config.o: $(SRCDIR)/h/debug.h $(SRCDIR)/h/except.h $(SRCDIR)/h/config.h
condor_config.o: $(SRCDIR)/h/trace.h $(SRCDIR)/h/expr.h $(SRCDIR)/h/files.h
condor_config.o: $(SRCDIR)/h/debug.h $(SRCDIR)/h/except.h $(SRCDIR)/h/config.h
do_connect.o: $(SRCDIR)/h/except.h $(SRCDIR)/h/debug.h
dprintf.o: $(SRCDIR)/h/condor_sys.h $(SRCDIR)/h/debug.h
dprintf_config.o: $(SRCDIR)/h/condor_sys.h $(SRCDIR)/h/debug.h $(SRCDIR)/h/except.h
except.o: $(SRCDIR)/h/condor_sys.h $(SRCDIR)/h/exit.h $(SRCDIR)/h/debug.h
history.o: $(SRCDIR)/h/except.h $(SRCDIR)/h/proc.h
job_queue.o: $(SRCDIR)/h/proc.h $(SRCDIR)/h/debug.h $(SRCDIR)/h/except.h
job_queue.o: $(SRCDIR)/h/trace.h
proc.o: $(SRCDIR)/h/proc.h
expr.o: $(SRCDIR)/h/except.h $(SRCDIR)/h/debug.h $(SRCDIR)/h/expr.h
condor_errlst.o: $(SRCDIR)/h/errno.h
