#
# Makefile for kerberos
#

# These may be overridden by a host specific Makefile fragment
# Directory syntax: R=root, C=current, S=Separator, U=Up one level
R=/
C=.
S=/
U=../

# The default system to build
WHAT=unix

srcdir = $(C)

prefix = $(R)usr$(S)kerberos

exec_prefix = $(prefix)

SHELL = /bin/sh

SUBDIRS="this is set by configure"

# Not plain GZIP, since gzip looks there for extra command-line options.
GZIPPROG = gzip -v --best
GZIPEXT = gz

.NOEXPORT:
MAKEOVERRIDES=

#### Host, target, and site specific Makefile fragments come in here.
###

# These are roughly topologically sorted in order to make porting more
# streamlined.
FLAGS_TO_PASS = \
	"prefix=$(prefix)" \
	"exec_prefix=$(exec_prefix)" \
	"CC=$(CC)" \
	"DESTDIR=$(DESTDIR)"

all: all-$(WHAT)

all-unix:
	@for dir in .. ${SUBDIRS}; do \
	  if [ x$${dir} != x.. ]; then \
	    if [ -d $$dir ]; then \
	      if (cd $$dir; $(MAKE) $(FLAGS_TO_PASS) all); then \
		true; \
	      else \
		exit 1; \
	      fi; \
	    else true; fi; \
	  else true; fi; \
	done

all-: all-windows
all-windows:
	cd src
	$(MAKE)

depend install check:
	@for dir in .. ${SUBDIRS}; do \
	  if [ x$${dir} != x.. ]; then \
	    if [ -d $$dir ]; then \
	      if (cd $$dir; $(MAKE) $(FLAGS_TO_PASS) $@); then \
		true; \
	      else \
		exit 1; \
	      fi; \
	    else true; fi; \
	  else true; fi; \
	done

dist:
	@if [ x${DESTDIR} = x ]; then \
	  echo '***' Set DESTDIR before running make dist; \
	  false; \
	else true; fi
	${DESTDIR}/usr/kerberos/install/fixprot ${DESTDIR} tar
	cd ${DESTDIR}/.; tar cf - usr | $(GZIPPROG) > kerberos.tar.$(GZIPEXT)

clean mostlyclean:
	-rm -f *~ core *.o a.out 
	@for dir in .. ${SUBDIRS}; do \
	if [ x$${dir} != x.. ]; then \
	    if [ -d $$dir ]; then \
	      (cd $$dir; $(MAKE) $@); \
	    else true; fi; \
	  else true; fi; \
	done

distclean realclean: clean
	-rm -f *~ core
	-rm -f Makefile config.status 
	@for dir in .. ${SUBDIRS}; do \
	if [ x$${dir} != x.. ]; then \
	    if [ -d $$dir ]; then \
	      (cd $$dir; $(MAKE) $@); \
	    else true; fi; \
	  else true; fi; \
	done

info install-info clean-info dvi ps:
	if [ -d doc ]; then \
	  cd doc; $(MAKE) $(FLAGS_TO_PASS) $@; \
	else true; fi

unixmac:
	cd src; $(MAKE) $(FLAGS_TO_PASS) unixmac

Makefile: Makefile.in configure.in $(host_makefile_frag) $(target_makefile_frag)
	$(SHELL) config.status
