#
# SUMMARY:      Build OO-Browser directories and distributions.
#
# AUTHOR:       Bob Weiner
#
# ORIG-DATE:     6-Oct-94 at 03:42:38
# LAST-MOD:     14-Apr-95 at 17:48:38 by Bob Weiner
#
# Copyright (C) 1994-1995  Free Software Foundation, Inc.
# See the file BR-COPY for license information.
#
# This file is part of the OO-Browser.
#
# DESCRIPTION:  
#
# USAGE:        Before doing your first make, edit the CONFIGURABLE SECTION
#               in the "Makefile".  The only change you have to make is to
#               set the EMACS variable to point to the Emacs executable that
#               you want to use to byte-compile the OO-Browser Lisp files.
#               Make this change now and save the file.
#
#               If you are running Emacs V18 or Epoch, you must first rebuild
#               all byte-compiled Lisp files.  Use:
#                    make all-elc
#
#               Then, whatever Emacs version you use, invoke:
#   	             make
#
#               Use these commands if you want to build graphical interfaces
#               to the OO-Browser:
#                    Build the X OO-Browser:        make xoobr
#
#                    If you want to rebuild the NEXTSTEP OO-Browser below the
#                    "tree-nx" directory, you must use NeXT's ProjectBuilder.
#
#               Now the OO-Browser should be ready for use if you have
#               followed the installation instructions in "BR-README".
#
#   -----------------
#
#               If you ever want to just rebuild out of data Lisp files, use:
#                    make elc
#    
#               To force rebuilding of all .elc files, even ones that are not
#               out of date:
#                    make all-elc
#
# DESCRIP-END.

##########################################################################
#                         CONFIGURABLE SECTION                           #
##########################################################################

# Binaries for various versions of Emacs.  Set 'EMACS' below to the one you
# want to use to byte-compile Lisp files.
EMACS19 = emacs19
EMACS18 = emacs
EPOCH = epoch
INFODOCK = infodock.bin
XEMACS = xemacs

# Emacs version used to byte-compile .el files into .elc's.
EMACS = $(XEMACS)

# Site-specific Emacs Lisp libraries to load before byte-compiling any files
# from this package.  Typically the only reason to set this is to get Emacs
# to include the directory of this package into its load-path variable, which
# determines where it will find Lisp library files to load.
#
# InfoDock and XEmacs 19.12 or higher include this package and automatically
# add its directory to load-path.  Under Emacs 19, if you add this directory
# to load-path in your site-lisp/site-start.el file, then you need not change
# this setting since site-start is automatically loaded whenever Emacs starts
# up.  If, however, you set load-path in your personal ~/.emacs file, you
# must add that to this setting.
#
# You must include the .el or .elc file suffix on each library name and each
# must be preceded by the `-l ' command-line flag.  If the directory in which
# the library is stored will not be in your Emacs load-path when Emacs
# attempts to load the library, you must include the full pathname to the
# library.  Here is an example setting.
#
# SITE-PRELOADS = -l ~/.emacs -l set-load-path.el
#
SITE-PRELOADS =

# Temp file to use to build .elc files.
ELISP-TO-COMPILE = /tmp/elc-${USER}

# Shell used to process this Makefile.  Bourne shell syntax is required.
SHELL = /bin/sh

# UNIX commands you may want to change for your particular system.
CP = \cp -p
DVIPS = \dvips
ETAGS = etags
RM = \rm -f
MAKE = make
MAKEINFO = \makeinfo --fill-column 74 
MV = \mv -f
MKDIR = mkdir
TAR = tar clf

# Directory in which to create new distributions of the OO-Browser.
DIST-DIR = /var/tmp

##########################################################################
#                     NO CHANGES REQUIRED BELOW HERE                     #
##########################################################################

MAN-DIR = man

# Libraries that must be pre-loaded before trying to byte-compile anything.
PRELOADS = $(SITE-PRELOADS) -l ./br-start.el

# Compile in batch mode. Under Emacs 19 and XEmacs, load
# site-lisp/site-start.el, which may set load-path.
BATCHFLAGS = -batch

# Directories other than the current directory in which to find files.
# This doesn't seem to work in all versions of make, so we also add hypb/
# explicitly to those files which need it.
VPATH = hypb

HYPB-EL   = hypb/h-skip-bytec.lsp hypb/hact.el hypb/hargs.el \
	    hypb/hhist.el hypb/hmouse-drv.el \
	    hypb/hmouse-key.el hypb/hmous-info.el \
	    hypb/hmouse-reg.el hypb/hmouse-sh.el \
	    hypb/hpath.el hypb/hui-mouse.el \
	    hypb/hui-window.el hypb/hvar.el \
	    hypb/hversion.el hypb/hypb.el hypb/set.el

HYPB-ELC  = hypb/hact.elc hypb/hargs.elc \
	    hypb/hhist.elc hypb/hmouse-drv.elc \
	    hypb/hmouse-key.elc hypb/hmous-info.elc \
	    hypb/hmouse-reg.elc hypb/hmouse-sh.elc \
	    hypb/hpath.elc hypb/hui-mouse.elc \
	    hypb/hui-window.elc hypb/hvar.elc \
	    hypb/hversion.elc hypb/hypb.elc hypb/set.elc

# Files from Hyperbole necessary for OO-Browser mouse support.
HYPERBOLE = $(HYPB-EL) $(HYPB-ELC)

EL-COMPILE  = br-c++-ft.el br-c++.el br-clos-ft.el \
	      br-clos.el br-compl.el \
              br-eif-ft.el br-eif.el br-env.el br-ftr.el br-info.el \
              br-init.el br-lib.el br-menu.el br-objc-ft.el \
              br-objc.el br-site.el br-vers.el \
	      br-smt.el br-start.el br-tree.el br.el c++-browse.el \
	      clos-brows.el eif-browse.el eif-calls.el eif-ise-er.el \
	      hasht.el hmouse-br.el info-brows.el \
	      objc-brows.el smt-browse.el

ELC-COMPILE = br-c++-ft.elc br-c++.elc br-clos-ft.elc \
	      br-clos.elc br-compl.elc \
              br-eif-ft.elc br-eif.elc br-env.elc br-ftr.elc br-info.elc \
              br-init.elc br-lib.elc br-menu.elc br-objc-ft.elc \
              br-objc.elc br-site.elc br-vers.elc \
	      br-smt.elc br-start.elc br-tree.elc br.elc c++-browse.elc \
	      clos-brows.elc eif-browse.elc eif-calls.elc eif-ise-er.elc \
	      hasht.elc hmouse-br.elc info-brows.elc \
	      objc-brows.elc smt-browse.elc

EL-TAGS = $(EL-COMPILE)

.SUFFIXES:            # Delete the default suffixes
.SUFFIXES: .el .elc   # Define the list of file suffixes to match to rules

# Build the OO-Browser for use in current directory.
all: elc info ps

xoobr:
	cd tree-x; make

# Install the X OO-Browser in its executable directory.
install: xoobr
	 cd tree-x; make install

# Record any .el files that need to be compiled.
.el.elc:
	@ echo $< >> $(ELISP-TO-COMPILE)

# Compile all recorded .el files.
elc: elc-init $(ELC-COMPILE) $(HYPB-ELC)
	@- \test ! -f $(ELISP-TO-COMPILE) \
            || (echo "These files will be compiled: " \
                 && echo "`cat $(ELISP-TO-COMPILE)`" \
                 && $(EMACS) $(BATCHFLAGS) $(PRELOADS) \
                       -f batch-byte-compile `cat $(ELISP-TO-COMPILE)`)
	@ $(RM) $(ELISP-TO-COMPILE)

elc-init:
	@ $(RM) $(ELISP-TO-COMPILE)

# Remove and then rebuild all byte-compiled .elc files for V19 Emacs, even
# those .elc files which do not yet exist.
all-elc:
	$(RM) *.elc
	$(EMACS) $(BATCHFLAGS) $(PRELOADS) -f batch-byte-compile $(EL-COMPILE)

# This target is used for background building of OO-Browser Environments.
# Don't change the name of the target since it is used in "br-env.el".
# Don't try to use this target manually unless you first set the following 2
# environment variables:
#    OOBR_DIR = full pathname of the directory where the OO-Browser lives
#    OOBR_ENV = full pathname of the Environment specification to build
oobr-env:
	cd $(OOBR_DIR); $(EMACS) $(BATCHFLAGS) $(PRELOADS) ${OOBR_ENV} -f br-env-batch-build

dvi: $(MAN-DIR)/oo-browser.dvi

info: $(MAN-DIR)/oo-browser.info

ps: $(MAN-DIR)/oo-browser.ps

$(MAN-DIR)/oo-browser.dvi: $(MAN-DIR)/oo-browser.info
	cd $(MAN-DIR); tex oo-browser.texi; texindex oo-browser.??; tex oo-browser.texi

$(MAN-DIR)/oo-browser.info: $(MAN-DIR)/oo-browser.texi
	cd $(MAN-DIR); $(MAKEINFO) oo-browser.texi

$(MAN-DIR)/oo-browser.ps: $(MAN-DIR)/oo-browser.texi
	make $(MAN-DIR)/oo-browser.dvi
	-$(RM) $(MAN-DIR)/oo-browser.ps
	cd $(MAN-DIR); $(DVIPS) -o oo-browser.ps oo-browser.dvi

tags: $(EL-TAGS)
	$(ETAGS) $(EL-TAGS) tree-x/*.[ch] tree-nx/*.[mh]

hypb-tags: $(EL-TAGS)
	cd $(DIST-DIR)/oobr; $(ETAGS) $(EL-TAGS) $(HYPB-EL) tree-x/*.[ch] tree-nx/*.[mh]

clean:  distclean
	$(RM) *.elc

dist: info
	echo "Ensure version # in br-vers.el, BR-VERSION, and man/oo-browser.texi is up to date."
	$(RM) -r $(DIST-DIR)/oobr
	cd ..; tar clf $(DIST-DIR)/br.tar oobr
	cd $(DIST-DIR); tar xf br.tar
	cd $(DIST-DIR)/oobr; $(RM) -r hypb man/im; make distclean; \
	mkdir hypb man/im; chmod 755 hypb man/im; \
	$(CP) /usr/local/infodock/info-local/im/oobr-* man/im
	$(CP) $(HYPERBOLE) $(DIST-DIR)/oobr/hypb
	cd $(DIST-DIR); $(RM) br.tar; $(TAR) oobr.tar oobr && \
	  echo "OO-Browser distribution created: `pwd`/oobr.tar"

distclean:
	-$(RM) $(MAN-DIR)/oo-browser.ps
	-$(RM) TAGS core $(MAN-DIR)/oo-browser.dvi \
          $(MAN-DIR)/oo-browser.?? .place* .*~ *~ *\#
	-(cd $(MAN-DIR); $(RM) .*~ *~ *\#)
