#*=====================================================================*/
#*    serrano/prgm/project/bigloo/bmacs/Makefile                       */
#*    -------------------------------------------------------------    */
#*    Author      :  Manuel Serrano                                    */
#*    Creation    :  Mon Jun  8 08:36:43 1998                          */
#*    Last change :  Wed May 24 17:01:25 2000 (serrano)                */
#*    Copyright   :  1998-2000 Manuel Serrano, see LICENSE file        */
#*    -------------------------------------------------------------    */
#*    The Makefile for the Unified Development environment.            */
#*=====================================================================*/

#*---------------------------------------------------------------------*/
#*    The default configuration                                        */
#*---------------------------------------------------------------------*/
include ../Makefile.config

#*---------------------------------------------------------------------*/
#*    Compilers, Tools and Destinations                                */
#*---------------------------------------------------------------------*/
# emacs compiler
EMACS		= xemacs
# emacs compilation flags
EFLAGS		= -batch -q -no-site-file \
                  -eval '(setq load-path \
                               (append (list "ude" \
                                             "bee" \
                                             "cee" \
                                             "lee" \
                                             "dbg") \
                                         load-path))' \
                  -eval "(setq byte-compile-warnings '(free-vars))" \
                  -f batch-byte-compile
# the shell to be used
SHELL           = /bin/sh
# etags and etags file name
ETAGS		= etags
TAGSFILE	= .etags

#*---------------------------------------------------------------------*/
#*    Sources and Objects                                              */
#*---------------------------------------------------------------------*/
UDE_FILE	= ude-autoload ude-config ude-custom ude-icon ude-tools \
                  ude-error ude-root ude-compile ude-info ude-repl \
                  ude-paren ude-docline ude-ident ude-makefile \
                  ude-mouse ude-toolbar ude-profile ude-version \
                  ude-balloon ude-about ude-html \
                  etags id-select plugin

BEE_FILE	= bee-autoload bee-config bee-toolbar bee-indent \
                  bee-mode bee-keymap bee-expand bee-flock bee-module \
                  bee-repl bee-tags bee-profile bee-usage bee-bdb \
                  bee-about-icon bee-ibuilder bee-browse bee-begoo \
                  bee-kbdb

CEE_FILE	= cee-autoload cee-config cee-toolbar cee-indent \
                  cee-profile cee-gdb cee-flock cee-hook cee-keymap \
                  cee-tags cee-profile cee-kbdb

LEE_FILE	= lee-autoload lee-config lee-toolbar lee-keymap \
                  lee-flock lee-hook lee-indent lee-tags

DBG_FILE	= dbg-args dbg-config dbg-filter dbg-stack \
                  dbg-autoload dbg-connect dbg-locals dbg-toolbar \
                  dbg-console dbg-mode dbg \
                  dbg-breakpoint dbg-display dbg-process dbg-complete \
                  dbg-docline dbg-source dbg-about-icon

EMACS_DIST_FILE	= $(UDE_FILE:%=ude/%) \
                  $(BEE_FILE:%=bee/%) \
                  $(CEE_FILE:%=cee/%) \
                  $(DBG_FILE:%=dbg/%)

EMACS_FILE	= $(EMACS_DIST_FILE) \
                  $(LEE_FILE:%=lee/%)

EMACS_DIST_NODIR= $(UDE_FILE:%=%.elc) \
                  $(BEE_FILE:%=%.elc) \
                  $(CEE_FILE:%=%.elc) \
                  $(DBG_FILE:%=%.elc)

EMACS_DIST_OBJ	= $(EMACS_DIST_FILE:%=%.elc)
EMACS_OBJ	= $(EMACS_FILE:%=%.elc)
EMACS_SOURCES	= $(EMACS_FILE:%=%.el)

#*---------------------------------------------------------------------*/
#*    Population                                                       */
#*---------------------------------------------------------------------*/
POPULATION	= Makefile README $(EMACS_SOURCES) etc

#*---------------------------------------------------------------------*/
#*     Suffixes ...                                                    */
#*---------------------------------------------------------------------*/
.SUFFIXES:
.SUFFIXES: .scm .o .el .elc

#*---------------------------------------------------------------------*/
#*    all                                                              */
#*---------------------------------------------------------------------*/
all: $(EMACS_OBJ)

#*---------------------------------------------------------------------*/
#*    compile-bee:                                                     */
#*---------------------------------------------------------------------*/
compile-bee: $(EMACS_DIST_OBJ)

#*---------------------------------------------------------------------*/
#*    uninstall                                                        */
#*---------------------------------------------------------------------*/
uninstall:
	-if [ "$(EMACSDIR) " != " " ]; then \
          rm -f $(EMACSDIR)/$(EMACS_DIST_NODIR); \
        fi

#*---------------------------------------------------------------------*/
#*    install ...                                                      */
#*---------------------------------------------------------------------*/
install:
	if [ "$(EMACSDIR) " != " " ]; then \
	  cp $(EMACS_DIST_OBJ) $(EMACSDIR); \
        fi

#*---------------------------------------------------------------------*/
#*    touchall                                                         */
#*---------------------------------------------------------------------*/
touchall:
	touch $(EMACS_SOURCES)

#*---------------------------------------------------------------------*/
#*    ude                                                              */
#*---------------------------------------------------------------------*/
.PHONY: ude
ude:
	@ $(ETAGS) $(EMACS_SOURCES) -o $(TAGSFILE)

#*---------------------------------------------------------------------*/
#*     clean ...                                                       */
#*---------------------------------------------------------------------*/
.PHONY: clean cleanall distclean

clean: 
	@- rm -f $(OBJECTS)
	@ find . \( -name '*[~%]' \
                       -o -name '.??*[~%]' \
                       -o -name '#*#' \
                       -o -name '?*#' \
                       -o -name \*core \) \
                     -type f -exec rm {} \;   
	@ echo "cleanup done..."
	@ echo "-------------------------------"

cleanall: clean
	@ rm -f $(TAGSFILE)

distclean: cleanall

#*---------------------------------------------------------------------*/
#*    distrib                                                          */
#*    -------------------------------------------------------------    */
#*    Prepare Cigloo for a distribution                                */
#*---------------------------------------------------------------------*/
distrib:
	@ if [ `pwd` = $(BOOTDIR)/bmacs ]; then \
             echo "*** ERROR:Illegal dir to make a distrib `pwd`"; \
             exit 1; \
          fi
	@ /bin/rm -rf lee

#*---------------------------------------------------------------------*/
#*    pop                                                              */
#*    -------------------------------------------------------------    */
#*    This entry is used by the bigloo/Makefile (the main Bigloo       */
#*    makefile) to get the list of file that populate a revision.      */
#*---------------------------------------------------------------------*/
.PHONY: pop
pop:
	@ echo $(POPULATION:%=bmacs/%)

#*---------------------------------------------------------------------*/
#*    .el --> .elc                                                     */
#*---------------------------------------------------------------------*/
.el.elc:
	@ echo --- $*.el ------------------------------------------
	@ \rm -f $*.elc
	$(EMACS) $(EFLAGS) $*.el
