# -*- makefile -*- mode for emacs
# @(#) $Id: Makefile,v 1.36 1997/07/31 17:44:35 leavens Exp $
#
# Developer's Makefile for Larch/C++ samples
#

#########################################################################
# Macro Definitions
#########################################################################

SEP = /# Unix and DJGPP

# Directories
#
LARCHDIR	= $(HOME)/larch
LCPP_ROOT       = $(LARCHDIR)/lc++
EG_DIR		= $(LCPP_ROOT)/samples
DIST_ROOT	= $(LCPP_ROOT)/distrib
DIST_LCPP       = $(DIST_ROOT)/LCPP
DIST_EG_DIR     = $(DIST_LCPP)/samples
WWW_DIR		= $(HOME)/WWW/larchc++samples

# Removing, copying, etc.
#
RM = rm -f
# RM = del	# DOS
CP = cp -p
# CP = copy	# DOS
MV = mv -f
# MV = move	# DOS
CHMOD = chmod
CHGRP = chgrp

# Documentation files to be distributed
#
DIST_EGS	= `make -f Makefile.dist dist-subdirs`

#########################################################################
# Target Definitions
#########################################################################

all: install

www : wwwhtml

wwwhtml	: install

install	:
	make MAKEFLAGS=$(MAKEFLAGS) DIST_EG_DIR="$(WWW_DIR)" distrib
	cd $(WWW_DIR) ; \
	for d in $(DIST_EGS) ; \
	     do cd $$d ; \
		lcpp2html -q -I *.h *.lh *.lcc *.lsl ; \
		cd .. ; \
	done

distrib	: $(DIST_EG_DIR)
	for d in $(DIST_EGS) ; \
	    do if test ! -d $(DIST_EG_DIR)/$$d ; \
	       then mkdir $(DIST_EG_DIR)/$$d ; \
	       fi ; \
	    $(RM) -r $(DIST_EG_DIR)/$$d/* ; \
	    cd $$d; \
	    for f in *.lcc *.lh *.lsl README ; \
		do if test -f $$f ; then $(CP) $$f $(DIST_EG_DIR)/$$d; fi ;\
	    done ; \
	    for f in *.C *.h *.bse *.pri; \
		do if test -f $$f ; then $(CP) $$f $(DIST_EG_DIR)/$$d; fi ;\
	    done ; \
            if test -f Makefile.dist ; \
	        then $(CP) Makefile.dist $(DIST_EG_DIR)/$$d/Makefile; \
		     $(CP) Makefile.dist $(DIST_EG_DIR)/$$d/Makefile.dist; \
	        elif test -f Makefile ; \
	        then $(CP) Makefile $(DIST_EG_DIR)/$$d/Makefile; \
	    fi ; \
	    $(CHGRP) lc++ $(DIST_EG_DIR)/$$d/*; \
	    $(CHMOD) ug+w $(DIST_EG_DIR)/$$d/*; \
	    $(CHMOD) o+r $(DIST_EG_DIR)/$$d/*; \
	    cd .. ; \
	done
	$(CP) README.dist $(DIST_EG_DIR)/README
	$(CP) Makefile.dist $(DIST_EG_DIR)/Makefile.dist
	$(CP) Makefile.dist $(DIST_EG_DIR)/Makefile
	$(CP) Makefile $(DIST_EG_DIR)/Makefile.dev
	cd $(DIST_EG_DIR) ; \
	$(CHGRP) lc++ $(DIST_EG_DIR)/*; \
	$(CHMOD) ug+w $(DIST_EG_DIR)/*; \
	$(CHMOD) o+r $(DIST_EG_DIR)/*

$(DIST_EG_DIR) :
	mkdir $(DIST_EG_DIR)
	$(CHGRP) lc++ $(DIST_EG_DIR)
	$(CHMOD) ug+w $(DIST_EG_DIR)
	$(CHMOD) o+r $(DIST_EG_DIR)

check: checkallspecs checkalltraits

checkallspecs :
	make -f Makefile.dist MAKEFLAGS='$(MAKEFLAGS)' \
		LCPPFLAGS='$(LCPPFLAGS)' checkallspecs

checkalltraits :
	make -f Makefile.dist MAKEFLAGS='$(MAKEFLAGS)' \
		LCPPFLAGS='$(LSLFLAGS)' checkalltraits

clean	:
	make -f Makefile.dist MAKEFLAGS='$(MAKEFLAGS)' \
		RM='$(RM)' clean

cleanall:
	make -f Makefile.dist MAKEFLAGS='$(MAKEFLAGS)' \
		RM='$(RM)' cleanall
	$(RM) *~ Obsolete/*~ BeingDeveloped/*~
	$(RM) Obsolete/*/*~ BeingDeveloped/*/*~
