###########################################################################
# Hand-built makefile for systems without Imake.  You probably do not 
# need to edit this file.
#
# Author:	David E. Smyth
# SccsID:	@(#) MakeByHand	1.14 92/10/12 08:28:19
###########################################################################
#
# To build:
#	1.	Edit the WcMake.tmpl file
#	2.	% mbh World
#
# To test distribution with Motif:
#		% cd Mri
#		% Test -rf WcAll
#		% Mri -rf Demo
#
# To test distribution with OpenLook:
#		% cd Ori
#		% Ori -rf Demo
#
# To test distribution with Athena:
#		% cd Ari
#		% Ari -rf Demo
#
# To test distribution with Cornell widgets:
#		% cd Cri
#		% Cri -rf Demo
#
# If everything is OK, then install:
#		% mbh install
#

include WcMake1.tmpl
include WcMake2.tmpl

  TARFILE = Wcl-$(WCL_VER).tar

  SUBDIRS = Wc $(WcATHENA) $(WcCORNELL) $(WcMOTIF) $(WcOPEN_LOOK) $(WcSTUFF)

# "make all" builds the library and the applications without
# installing anything.  However, "includes" must first be done!

all:
	for i in $(SUBDIRS) ;\
	do \
	(cd $$i ; echo "making" "in ./$$i..."; \
	$(MAKE) all); \
	done

# Note that the Xp includes must be always be done so Xop and Xcp
# can build XpTable
#
includes:: ./X11 $(LOCAL_STRINGS_H)
	for i in $(SUBDIRS) Xp ;\
	do \
	(cd $$i ; echo "including" "in ./$$i..."; \
	$(MAKE) includes); \
	done

./X11:
	mkdir ./X11

./strings.h:
	$(GET_LOCAL_STRINGS_H)

# Note we must install the Xp/Table include files always
#
$(DESTDIR)$(INCDIR)/Xp:
	mkdir $(DESTDIR)$(INCDIR)/Xp
	chown $(OWNER) $(DESTDIR)$(INCDIR)/Xp
	chmod $(INSTDIRFLAGS) $(DESTDIR)$(INCDIR)/Xp

install:
	for i in $(SUBDIRS) ;\
	do \
	(cd $$i ; echo "installing" "in ./$$i..."; \
	$(MAKE) install); \
	done
	echo "installing Xmp include files..."
	$(MAKE) $(DESTDIR)$(INCDIR)/Xp
	for i in Xp/COPY Xp/Table.h Xp/TableP.h ; do \
	rm -f $(DESTDIR)$(INCDIR)/$$i; \
	cp $$i $(DESTDIR)$(INCDIR)/$$i; \
	done
	chown $(OWNER) $(DESTDIR)$(INCDIR)/Xp/*
	chmod $(INSTINCFLAGS) $(DESTDIR)$(INCDIR)/Xp/*

install.man:
	for i in $(SUBDIRS) ;\
	do \
	(cd $$i ; echo "installing man pages" "in ./$$i..."; \
	$(MAKE) install.man); \
	done

clean:
	for i in $(SUBDIRS) ;\
	do \
	(cd $$i ; echo "cleaning" "in ./$$i..."; \
	$(MAKE) clean); \
	done

World:
	@echo ""
	@echo Building Release $(WCL_VER) of Wcl - the Widget Creation Library
	@echo ""
	@echo "##########################################################"
	@echo "# I trust you first edited WcMake1.tmpl and WcMake2.tmpl #"
	@echo "##########################################################"
	@echo ""
	@date
	@echo ""
	$(MAKE) clean
	$(MAKE) includes
	$(MAKE) all
	

# Done only before final distribution

DISTDIRS = Ari Cri Mri Ori Stuff Wc Xcp Xmp Xop Xp

distribution:
	$(MAKE) clean
	$(MAKE) sccsdelget
	$(MAKE) scoman
	$(MAKE) files
	$(MAKE) tar.Z

sccsdelget:
	echo "sccs delget ..."
	sccs delget -y"for $(WCL_VER) distribution" `sccs tell` 
	for i in $(DISTDIRS) ;\
	do \
	(cd $$i ; echo "sccs delget in ./$$i..."; \
	sccs delget -y"for $(WCL_VER) distribution" `sccs tell` ); \
	done

scoman:
	for i in $(DISTDIRS) ;\
	do \
	(cd $$i ; echo "making sco man pages in ./$$i..."; \
	$(MAKE) scoman); \
	done

files:
	rm -rf files.old
	mv files files.old
	ls -R . > files

# To make it easy to pass Wcl on to others

tar:
	rm -f $(TARFILE)*
	tar cf $(TARFILE) -I files
	ls -l $(TARFILE)*

tar.Z:
	$(MAKE) tar
	compress $(TARFILE)
	ls -l $(TARFILE)*

tar.Z.u:
	$(MAKE) tar.Z
	uuencode $(TARFILE).Z $(TARFILE).Z >$(TARFILE).Z.u
	ls -l $(TARFILE)*

tar.Z.u.split:
	$(MAKE) tar.Z.u
	split -790 $(TARFILE).Z.u $(TARFILE)Zu.
	ls -l $(TARFILE)*
