#*---------------------------------------------------------------------*/
#*    serrano/prgm/project/bigloo/recette/Makefile                     */
#*                                                                     */
#*    Author      :  Manuel Serrano                                    */
#*    Creation    :  Mon Nov  2 17:38:43 1992                          */
#*    Last change :  Thu Apr 11 14:24:01 1996 (serrano)                */
#*                                                                     */
#*    Le make pour construire la recette de `Bigloo' ...               */
#*---------------------------------------------------------------------*/

#*---------------------------------------------------------------------*/
#*     Les flags ...                                                   */
#*---------------------------------------------------------------------*/
MACH        	= `arch`
PWD         	= `pwd`
CC          	= gcc
VERSION		= 1.8
#* BIGLOO          = ../bin/bigloo$(VERSION)                           */
BIGLOO          = bigloo
INCLUDE     	= -I.
CFLAGS      	= $(INCLUDE) -O -g
C_FILES     	= $(PWD)/C-files
LINTFLAGS	= -u -v $(INCLUDE)

#*---------------------------------------------------------------------*/
#*  !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!!  WARNING !!!   */
#*    -------------------------------------------------------------    */
#*  The recette can't be compiled in `-unsafe' mode (due to try forms) */
#*    -------------------------------------------------------------    */
#*  The recette can't be compiled with the `-fsharing' option          */
#*---------------------------------------------------------------------*/
BG_FLAGS        = -cg -rm -g -O3 -cc $(CC) -q -eval "(set! *indent* \#f)" -copt ""
BEEP            = ../tools/beep

#*---------------------------------------------------------------------*/
#*    Les objects destinations                                         */
#*---------------------------------------------------------------------*/
OBJECTS		= vital.o bool.o list.o vector.o struct.o print.o       \
                  string.o kwote.o case.o bexit.o vararity.o apply.o    \
                  globalis.o filtre.o rgc-trap.o rgc-jm.o port.o        \
                  read.o callcc.o fringe.o tail.o foreign.o big-file.o  \
                  sqic.o eval.o inline.o match.o letrec.o macro.o       \
                  flonum.o number.o char.o define.o error.o cse.o       \
                  kapture.o include.o 0cfa.o alias.o alias-aux.o main.o \
                  rgc-eval.o rgc.o hash.o module.o import1.o import2.o

OBJECT_C_FOREIGN= c-file.o

LN_OBJECTS	= vital.ln bool.ln list.ln vector.ln struct.ln print.ln       \
                  string.ln kwote.ln case.ln bexit.ln vararity.ln apply.ln    \
                  globalis.ln filtre.ln rgc-trap.ln rgc-jm.ln port.ln         \
                  read.ln callcc.ln fringe.ln tail.ln foreign.ln big-file.ln  \
                  sqic.ln eval.ln inline.ln match.ln letrec.ln macro.ln       \
                  flonum.ln number.ln char.ln define.ln error.ln cse.ln       \
                  kapture.ln include.ln 0cfa.ln alias.ln alias-aux.ln main.ln \
                  rgc-eval.ln rgc.ln hash.ln module.ln import1.ln import2.ln

#*---------------------------------------------------------------------*/
#*    recette                                                          */
#*---------------------------------------------------------------------*/
recette: $(OBJECTS) $(OBJECT_C_FOREIGN) 
	$(BIGLOO) $(BG_FLAGS) -o recette $(OBJECT_C_FOREIGN) $(OBJECTS)
	@ echo "Recette Done..."
	@ $(BEEP)
	@ echo "-------------------------------"

#*---------------------------------------------------------------------*/
#*     Les suffixes ...                                                */
#*---------------------------------------------------------------------*/
.SUFFIXES:
.SUFFIXES: .o .scm .c .ln

#*---------------------------------------------------------------------*/
#*    .scm.o                                                           */
#*---------------------------------------------------------------------*/
.scm.o:
	$(BIGLOO) $(BG_FLAGS) -c $*.scm

#*---------------------------------------------------------------------*/
#*    Certains fichiers doivent etre compiles avec des flags           */
#*    supplementaires. On les rajoute maintenant                       */
#*---------------------------------------------------------------------*/
callcc.o: callcc.scm
	$(BIGLOO) $(BG_FLAGS) -c -call/cc callcc.scm
	
fringe.o: fringe.scm
	$(BIGLOO) $(BG_FLAGS) -c -call/cc fringe.scm

#*---------------------------------------------------------------------*/
#*    .c.o                                                             */
#*---------------------------------------------------------------------*/
.c.o:
	@ echo "$*.c:"
	@ $(CC) $(CFLAGS) -c -o $*.o $*.c

#*---------------------------------------------------------------------*/
#*    .c.ln                                                            */
#*---------------------------------------------------------------------*/
.c.ln:
	@ echo "$*.c:"
	@ $(LINT) $(LINTFLAGS) $*.c > $*.ln

#*---------------------------------------------------------------------*/
#*     touchall ...                                                    */
#*---------------------------------------------------------------------*/
touchall:
	@ touch *.scm c-file.c
	@ echo "touch done..."
	@ $(BEEP)
	@ echo "-------------------------------"

#*---------------------------------------------------------------------*/
#*    clean                                                            */
#*---------------------------------------------------------------------*/
clean: cleanlint
	@- \rm -f *.o
	@- \rm -f recette
	@- \rm -f *.tree
	@- \rm -f *.ast
	@- \rm -f *.escm
	@ echo "Clean up done..."
	@ $(BEEP)
	@ echo "-------------------------------"

#*---------------------------------------------------------------------*/
#*    wc                                                               */
#*---------------------------------------------------------------------*/
wc:
	@ wc *.scm
	@ echo "wc done..."
	@ $(BEEP)
	@ echo "-------------------------------"
	
#*---------------------------------------------------------------------*/
#*    lint                                                             */
#*---------------------------------------------------------------------*/
lint: all.lint
	@ echo "lint done..."
	@ $(BEEP)
	@ echo "-------------------------------"

all.lint: $(LN_OBJECTS)
	@- \rm -f all.lint
	@- touch all.lint
	@ ( for p in *.ln;                 \
            do echo "   " $$p >> all.lint; \
            cat $$p >> all.lint;           \
            done )
#*---------------------------------------------------------------------*/
#*    cleanlint                                                        */
#*---------------------------------------------------------------------*/
cleanlint:
	@- \rm -f *.ln
	@- \rm -f all.lint
	
