#*---------------------------------------------------------------------*/
#*   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/examples/Embedded/Makefile           */
#*    -------------------------------------------------------------    */
#*    Author      :  Manuel Serrano                                    */
#*    Creation    :  Tue Jan 30 15:19:19 1996                          */
#*    Last change :  Thu Jul  2 08:41:57 1998 (serrano)                */
#*    -------------------------------------------------------------    */
#*    An example of embedded bigloo program.                           */
#*=====================================================================*/

#*---------------------------------------------------------------------*/
#*    flags                                                            */
#*---------------------------------------------------------------------*/
BIN             = ../../bin
BIGLOO          = $(BIN)/bigloo
BGLOPTFLAGS	= -O +rm
BGLFLAGS	= $(BGLOPTFLAGS)                                        \
                  -copt "-DBIGLOO_MAIN=bigloo_initialize -DBIGLOO_EXIT='BUNSPEC,'"
BGLLIB		= `$(BIGLOO) -query | grep "\*lib-dir[ ]*\*" | sed 's/\*lib-dir\*[ ]*:[ ]*//'`

CC 		= gcc
CFLAGS 		= -g
LDFLAGS		= 
LBIGLOO		= `$(BIGLOO) -eval '(begin (print *bigloo-lib*) (exit 0))'`
LIBFLAGS	= -L$(BGLLIB) -lgc -l$(LBIGLOO) -lm

DEST		= embedded

#*---------------------------------------------------------------------*/
#*    Objects and sources                                              */
#*---------------------------------------------------------------------*/
#*--- c ---------------------------------------------------------------*/
C_FILE		= c-main

C_OBJ	= $(C_FILE:%=%.o)
C_SRC 	= $(C_OBJ:%.o=%.c)

#*--- scm -------------------------------------------------------------*/
SCM_FILE	= scm-main fib

SCM_OBJ		= $(SCM_FILE:%=%.o)
SCM_SRC		= $(SCM_OBJ:%.o=%.scm)

#*---------------------------------------------------------------------*/
#*    All objects and sources                                          */
#*---------------------------------------------------------------------*/
OBJ		= $(C_OBJ) $(SCM_OBJ)
SRC		= $(C_SRC) $(SCM_SRC)

POPULATION      = $(SRC:%=examples/Embedded/%) examples/Embedded/Makefile

#*---------------------------------------------------------------------*/
#*    the goals.                                                       */
#*---------------------------------------------------------------------*/
$(DEST): $(OBJ) 
	$(CC) $(LDFLAGS) $(OBJ) $(CFLAGS) -o $(DEST) $(LIBFLAGS)

test: $(DEST)
	$(DEST) 20

pop:
	@ echo $(POPULATION)

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

#*---------------------------------------------------------------------*/
#*    Suffixes                                                         */
#*---------------------------------------------------------------------*/
.SUFFIXES:
.SUFFIXES: .scm .c .o

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

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

