#*---------------------------------------------------------------------*/
#*   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/Lib/Makefile                */
#*    -------------------------------------------------------------    */
#*    Author      :  Manuel Serrano                                    */
#*    Creation    :  Sat Dec 19 12:58:58 1998                          */
#*    Last change :  Mon Dec 21 06:57:45 1998 (serrano)                */
#*    -------------------------------------------------------------    */
#*    The Makefile to build the point library                          */
#*=====================================================================*/

# bigloo flags
BIGLOO		= bigloo
BHEAPFLAGS	= -unsafe -q -mkaddheap -mkaddlib -v2
BCOMMONFLAGGS	= -mkaddlib -fsharing -q $(VERBOSE)        \
                  -copt '$(CCOMMONFLAGS)' -cc $(CC)
BSAFEFLAGS	= $(BCOMMONFLAGGS) -cg -O3 -g -cg -unsafev \
                  -eval '(set! *indent* 4)' -rm
BUNSAFEFLAGS	= $(BCOMMONFLAGS) -O4 -unsafe

# cigloo flags
CIGLOO		= cigloo

# cflags
CC		= gcc
CCOMMONFLAGS	= -I.
CSAFEFLAGS	= $(CCOMMONFLAGS)
CUNSAFEFLAGS	= $(CCOMMONFLAGS) -O2

# library objects
SAFE_OBJECT	= olib/scm-point.o olib/point.o
UNSAFE_OBJECT	= olib_u/scm-point.o olib_u/point.o

# Population
POPULATION	= Makefile                \
                  point.init make-lib.scm \
                  point.h point.c         \
                  scm-point.scm           \
                  example.scm

all: heap lib example

heap: point.heap

point.heap: point.sch scm-point.scm
	$(BIGLOO) $(BHEAPFLAGS) make-lib.scm -addheap point.heap

lib: lib_u lib.a

lib.a: olib $(SAFE_OBJECT)
	ar qcv libpoint.a $(SAFE_OBJECT) 

lib_u: olib_u $(UNSAFE_OBJECT)
	ar qcv libpoint_u.a $(UNSAFE_OBJECT) 

olib:
	mkdir olib

olib_u:
	mkdir olib_u

olib_u/scm-point.o olib/scm-point.o: scm-point.scm
	$(BIGLOO) $(BSAFEFLAGS) $(<F) -o $*.o -c

olib_u/point.o olib/point.o: point.c
	$(CC) $(CSAFEFLAGS) $(<F) -o $*.o -c

point.sch: point.h point.c
	cigloo $^ > point.sch

example: heap lib
	$(BIGLOO) -v2 -L . -library point -static-bigloo example.scm -o example

clean:
	-/bin/rm -f point.heap
	-/bin/rm -f point.sch scm-point.c
	-/bin/rm -fr olib olib_u
	-/bin/rm -f example example.c example.o
	-/bin/rm -f libpoint.a libpoint_u.a

test: example
	./example

pop: 
	echo $(POPULATION:%=examples/Lib/%)
