#*---------------------------------------------------------------------*/
#*   A pratical implementation for the Scheme programming language     */
#*                                                                     */
#*                                    ,--^,                            */
#*                              _ ___/ /|/                             */
#*                          ,;'( )__, ) '                              */
#*                         ;;  //   L__.                               */
#*                         '   \\   /  '                               */
#*                              ^   ^                                  */
#*                                                                     */
#*   Copyright (c) 1992-1999 Manuel Serrano                            */
#*                                                                     */
#*     Bug descriptions, use reports, comments or suggestions are      */
#*     welcome. Send them to                                           */
#*       bigloo-request@kaolin.unice.fr                                */
#*       http://kaolin.unice.fr/bigloo                                 */
#*                                                                     */
#*   This program is free software; you can redistribute it            */
#*   and/or modify it under the terms of the GNU General Public        */
#*   License as published by the Free Software Foundation; either      */
#*   version 2 of the License, or (at your option) any later version.  */
#*                                                                     */
#*   This program is distributed in the hope that it will be useful,   */
#*   but WITHOUT ANY WARRANTY; without even the implied warranty of    */
#*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     */
#*   GNU General Public License for more details.                      */
#*                                                                     */
#*   You should have received a copy of the GNU General Public         */
#*   License along with this program; if not, write to the Free        */
#*   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,   */
#*   MA 02111-1307, USA.                                               */
#*---------------------------------------------------------------------*/
#*=====================================================================*/
#*    serrano/prgm/project/bigloo/bmacs/Makefile                       */
#*    -------------------------------------------------------------    */
#*    Author      :  Manuel Serrano                                    */
#*    Creation    :  Mon Jun  8 08:36:43 1998                          */
#*    Last change :  Wed Jan 27 09:21:45 1999 (serrano)                */
#*    -------------------------------------------------------------    */
#*    The Makefile for the Unified Development environment.            */
#*=====================================================================*/

#*---------------------------------------------------------------------*/
#*    Compilers, Tools and Destinations                                */
#*---------------------------------------------------------------------*/
# which C compiler to be used
CC              = gcc               
# the directory where to install emacs emacs files
EMACSDIR	= /usr/local/xemacs/site-lisp
# The BMASK
BMASK		= 755
# 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
# how to clean
CLEAN           = clean
# etags and etags file name
ETAGS		= etags
TAGSFILE	= .etags

#*---------------------------------------------------------------------*/
#*    Backups and revisions                                            */
#*---------------------------------------------------------------------*/
TAR             = tar
TARCOPT         = cf
TARXOPT         = xfp
GZIP            = gzip
BACKUPDIR       = $$HOUSE/backup
BACKUPNAME      = bmacs

#*---------------------------------------------------------------------*/
#*    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

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

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

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/%)                                   \
                  $(DBG_FILE:%=dbg/%)

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

EMACS_DIST_NODIR= $(UDE_FILE:%=%.elc)                                   \
                  $(BEE_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)

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

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

#*---------------------------------------------------------------------*/
#*    uninstall                                                        */
#*---------------------------------------------------------------------*/
uninstall:
	-rm -f $(EMACSDIR)/$(EMACS_DIST_NODIR)

#*---------------------------------------------------------------------*/
#*    install ...                                                      */
#*---------------------------------------------------------------------*/
install:
	cp $(EMACS_OBJ) $(EMACSDIR)

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

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

#*---------------------------------------------------------------------*/
#*     clean ...                                                       */
#*---------------------------------------------------------------------*/
.PHONY: Clean clean fast-clean

clean-emacs: 
	@- rm -f $(EMACS_OBJ)

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

clean: fast-clean

clean-all: clean
	@ rm $(TAGSFILE)

Dclean: clean
DClean: Clean

#*---------------------------------------------------------------------*/
#*    distrib                                                          */
#*    -------------------------------------------------------------    */
#*    Prepare Cigloo for a distribution                                */
#*---------------------------------------------------------------------*/
distrib:
	@ if [ `pwd` = $$HOME/prgm/project/bigloo/bmacs ]; then      \
             echo "*** ERROR:Illegal dir to make a distrib `pwd`";   \
             exit 1;                                                 \
          fi
	@ $(MAKE) $(CLEAN)
	@ $(MAKE) Dmakefile
	@ $(BIN)/copyright $(POPULATION)
	@ /bin/rm -rf lee
	@ /bin/rm -rf cee

#*---------------------------------------------------------------------*/
#*    backup                                                           */
#*---------------------------------------------------------------------*/
backup:
	@ echo "Backuping in: $(BACKUPDIR)/$(BACKUPNAME)"
	@ (\rm -f $(BACKUPDIR)/$(BACKUPNAME).tar.gz;                   \
	   cleanup;                                                    \
           tar cf $(BACKUPDIR)/$(BACKUPNAME).tar $(POPULATION);        \
           gzip $(BACKUPDIR)/$(BACKUPNAME).tar)
	@ echo "done..."
	@ echo "-------------------------------"

#*---------------------------------------------------------------------*/
#*    restore ...                                                      */
#*---------------------------------------------------------------------*/
restore:
	@ echo "Restoring from: $(BACKUPDIR)/$(BACKUPNAME)"
	@ (gzip -d --to-stdout $(BACKUPDIR)/$(BACKUPNAME).tar.gz | tar xfp -)
	@ echo "done..."
	@ echo "-------------------------------"

#*---------------------------------------------------------------------*/
#*    Dmakefile                                                        */
#*---------------------------------------------------------------------*/
Dmakefile: Makefile
	@- rm -f $@
	@ echo "# !!! This is a generated file, don't edit !!!" > $@
	@ echo "EMACS=xemacs" >> $@
	@ echo "EFLAGS=-batch -q -no-site-file                        \\" >> $@
	@ echo "  -eval '(setq load-path                              \\" >> $@
	@ echo "                (append (list \"ude\"                 \\" >> $@
	@ echo "                              \"bee\"                 \\" >> $@
	@ echo "                              \"dbg\")                \\" >> $@
	@ echo "                        load-path))'                  \\" >> $@
	@ echo "  -eval \"(setq byte-compile-warnings '())\"          \\" >> $@
	@ echo "   -f batch-byte-compile" >> $@
	@ echo "shell=sh" >> $@
	@ echo "EMACSDIR=/usr/local/lib/xemacs/site-lisp" >> $@
	@ echo "" >> $@
	@ echo "OBJECTS=$(EMACS_DIST_OBJ)" >> $@
	@ echo "" >> $@
	@ echo 'all: $$(OBJECTS)' >> $@
	@ echo "" >> $@
	@ echo "clean:" >> $@
	@ echo '	@- rm -f $$(OBJECTS)' >> $@
	@ echo '	@- rm -f $$(CIGLOO_DEST)' >> $@
	@ echo "" >> $@
	@ echo "%.elc: %.el" >> $@
	@ echo '	@ \rm -f $$*.elc' >> $@
	@ echo '	$$(EMACS) $$(EFLAGS) $$*.el' >> $@
	@ echo "" >> $@
	@ echo "uninstall:" >> $@
	@ echo '	for f in $$(OBJECTS); do ' >> $@
	@ echo '	  rm -f $$(EMACSDIR)/`basename $$f`;' >> $@
	@ echo '	done' >> $@

#*---------------------------------------------------------------------*/
#*    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:%=$(BACKUPNAME)/%)

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