#
# $Id: Makefile,v 0.10 1994/07/30 02:16:19 zhao Exp $
#
# Makefile for the entire XFORMs tree. 
#
#  usage: make [form|desgin|demo|install|doc|all|clean]
#      form: making only the library (default)
#    desgin: form + form designer
#     shlib: make shared library
#   install: copy the library and head file to standard directories.
#       all: all of the above
#      demo: form + demo
#     clean: remove all .o files
#     empty: clean + removal of all executibles and libraries
#      doc:  documentation
#

SYSLIB=-lX11 -lm

# All changes should be made in mkconfig.h

##### don't change anything after this line ####
AUTO=.mkconfig
SHELL=/bin/sh

form: prepare xpm
	@if [ ! -f mkconfig.h ]; then make config;\
	else cd FORMS; make; fi
forms:form
	@if [ ! -f mkconfig.h ]; then make config;\
        else cd FORMS; make; fi
xforms:form
	@if [ ! -f mkconfig.h ]; then make config;\
        else cd FORMS; make; fi
shlib:
	@if [ ! -f mkconfig.h ]; then make config;\
        else cd FORMS; make shlib; fi

# comment out this line and uncomment next if xpm lib is on the system
xpm: ; (cd xpm; make )
#xpm:; @echo using system xpm


design: form
	@(cd DESIGN; make) 

fdesign:form
	@(cd DESIGN; make) 

fdps: form
	@(cd fd2ps; make)

demo: form
	@(cd DEMOS; make) 


all: design fdps

doc:
	(cd DOC; make) 

config:
	@chmod u+x $(AUTO); ./$(AUTO);

prepare:
	@if [ ! -f mkconfig.h ]; then make config;fi


install: forms design
	(cd FORMS; make $@)
	(cd DESIGN; make $@)
	(cd DOC; make $@)

# for testing
xt: form
	(cd FORMS;make $@)

clean:
	@touch mkconfig.h
	(cd  FORMS; make $@)
	(cd  DESIGN; make $@)
	(cd  DEMOS; make $@)
	(cd  xpm; make $@)
	/bin/rm -f elog mlog mkconfig.h
#	-(cd  DOC; make $@)
empty:
	@touch mkconfig.h
	(cd  FORMS; make $@)
	(cd  DESIGN; make $@)
	(cd  DEMOS; make $@)
	(cd  fd2ps; make $@)
	(cd  test; make $@)
	(cd  xpm; make $@)
	 /bin/rm -f elog mlog mkconfig.h
#	-(cd  DOC; make $@)

DPNAME=xform.tar
CDPNAME=xform.tgz

TOP=xforms
MISCF=$(TOP)/Makefile $(TOP)/Bugs $(TOP)/Readme $(TOP)/Copyright $(TOP)/Changes
PLAT=$(TOP)/Imakefile.os2 $(TOP)/README.OS2 $(TOP)/porters_readme\
     $(TOP)/os2move.cmd $(TOP)/vms
FORM=$(TOP)/FORMS
DESIGN=$(TOP)/DESIGN
FD2PS=$(TOP)/fd2ps

dist: empty
	-@mv FORMS/RCS fmRCS
	-@mv DESIGN/RCS deRCS
	-@mv DEMOS/RCS dmRCS
	-@mv fd2ps/RCS fdRCS
	-(cd ..;tar cvf $(TOP)/$(DPNAME) $(MISCF) $(PLAT) $(TOP)/FORMS\
	 $(DESIGN) $(TOP)/DEMOS $(TOP)/fd2ps $(TOP)/$(AUTO) $(TOP)/contrib\
	 $(TOP)/.mkconfig.csh\
	 $(TOP)/xpm $(TOP)/bmake $(TOP)/breadme $(TOP)/pmflags\
	 $(TOP)/.fixbsd $(TOP)/.fixsgi $(TOP)/test )
	-@mv fmRCS FORMS/RCS
	-@mv deRCS DESIGN/RCS
	-@mv dmRCS DEMOS/RCS
	-@mv fdRCS fd2ps/RCS
	gzip -c -8 $(DPNAME) > $(CDPNAME)
	-rm $(DPNAME)
#
# Source code distribution
#
SDPNAME=sxform.tar
SCDPNAME=sxform.tgz
sdist: empty
	-@mv FORMS/RCS fmRCS
	-@mv DESIGN/RCS deRCS
	-@mv DEMOS/RCS dmRCS
	-@mv fd2ps/RCS fdRCS
	-(cd ..;tar cvf $(TOP)/$(SDPNAME) $(MISCF) $(PLAT) $(TOP)/FORMS\
	 $(TOP)/DESIGN $(TOP)/DEMOS $(TOP)/fd2ps $(TOP)/$(AUTO)\
	 $(TOP)/.fixbsd $(TOP)/.fixsgi\
	 $(TOP)/xpm $(TOP)/pmflags $(TOP)/bmake $(TOP)/breadme)
	-@mv fmRCS FORMS/RCS
	-@mv deRCS DESIGN/RCS
	-@mv dmRCS DEMOS/RCS
	-@mv fdRCS fd2ps/RCS
	gzip -c -8 $(SDPNAME) > $(SCDPNAME)
	/bin/rm -f $(SDPNAME)

#really scaled down packaging. For library source only
LIBONLY=xformlib.tgz
libonly: empty
	-@mv FORMS/RCS fmRCS
	-@mv DEMOS/RCS dmRCS
	-(cd ..;tar cvf $(TOP)/t.tar $(MISCF) $(PLAT) $(TOP)/FORMS\
	$(TOP)/DEMOS $(TOP)/xpm $(TOP)/pmflags $(TOP)/$(AUTO))
	-@mv fmRCS FORMS/RCS
	-@mv fdRCS fd2ps/RCS
	gzip -c -8 t.tar > $(LIBONLY)
	/bin/rm -f t.tar

#
# Binary distribution stuff
#
GZIP=gzip -8
BDNAME=bxform.tgz

bdist: form design
	cd DEMOS; make empty
	cp Makefile ori_make; cp bmake Makefile
	cp Readme ori_readme; cp breadme Readme
	-(cd ..;tar cvf $(TOP)/t.tar $(FORM)/libforms.a\
               $(FORM)/forms.h $(FORM)/xforms.5 $(FORM)/gl.c\
               $(FORM)/Readme\
               $(FD2PS)/fd2ps $(FD2PS)/fd2ps.1 $(FD2PS)/Readme\
               $(DESIGN)/fdesign $(DESIGN)/Readme $(DESIGN)/fdesign.1 \
               $(TOP)/DEMOS $(TOP)/mkconfig.h $(MISCF) $(TOP)/contrib\
         );
	-$(GZIP) t.tar; mv t.tar.gz $(BDNAME)
	cp ori_make Makefile

shbdist: form design shlib
	cd DEMOS; make empty
	cp Makefile ori_make; cp bmake Makefile
	cp Readme ori_readme; cp breadme Readme
	-(cd ..;tar cvf $(TOP)/t.tar $(FORM)/libforms.a\
               $(FORM)/forms.h $(FORM)/xforms.5 $(FORM)/gl.c\
               $(FORM)/Readme $(FORM)/`cat $(FORM)/shlib`\
               $(FD2PS)/fd2ps $(FD2PS)/fd2ps.1 $(FD2PS)/Readme\
               $(DESIGN)/fdesign $(DESIGN)/Readme $(DESIGN)/fdesign.1 \
               $(TOP)/DEMOS $(TOP)/mkconfig.h $(MISCF) $(TOP)/contrib\
         );
	-$(GZIP) t.tar; mv t.tar.gz $(BDNAME)
	cp ori_make Makefile

# also ship all *.o in  fdesgin dir

bigbdist:
	cd DEMOS; make empty
	cp Makefile ori_make; cp bmake Makefile
	cp Readme ori_readme; cp breadme Readme
	-(cd ..;tar cvf $(TOP)/t.tar $(FORM)/libforms.a $(FORM)/forms.h\
  $(FORM)/xforms.5 $(FORM)/gl.c $(FORM)/Readme \
               $(FD2PS)/fd2ps $(FD2PS)/fd2ps.1\
   $(DESIGN)/fdesign $(DESIGN)/Readme $(DESIGN)/fdesign.1 \
   $(DESIGN)/*.o\
   $(TOP)/DEMOS $(TOP)/mkconfig.h $(MISCF) $(TOP)/contrib)
	-gzip t.tar; mv t.tar.gz $(BDNAME)
	cp ori_make Makefile

