
#
#  Makefile for Greg Library and control program
#  
#  Copyright (C) 1998 Free Software Foundation, Inc.
#
#  Written by:	Richard Frith-Macdonald <rfm@gnu.org>
#
#  This file is part of Greg (part of the GNUstep project)
#
#  This library is free software; you can redistribute it and/or
#  modify it under the terms of the GNU Lesser General Public
#  License as published by the Free Software Foundation; either
#  version 2.1 of the License, or (at your option) any later version.
#  
#  This library 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
#  Lesser General Public License for more details.
#  
#  You should have received a copy of the GNU Lesser General Public
#  License along with this library; if not, write to the Free Software
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#

SH = /bin/sh

CC = @CC@
CFLAGS = -g
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
libdir = @libdir@

GUILE_SCM_PATH = @GUILE_SCM_PATH@

MAJOR_VERSION = @MAJOR_VERSION@
MINOR_VERSION = @MINOR_VERSION@

VER_INFO = $(MAJOR_VERSION):$(MINOR_VERSION)

INSTALL_DATA =		$(SH) ../install-sh -c -m 0644
INSTALL_SCRIPT =	$(SH) ../install-sh -c -m 0755
LIBTOOL =		$(SH) ../libtool
MKINSTDIRS =		$(SH) ../mkinstalldirs

GUILE_CFLAGS  = @GUILE_CFLAGS@
GUILE_LDFLAGS = @GUILE_LDFLAGS@
INCLUDES = $(GUILE_CFLAGS) -I$(prefix)/include

LIB = libgreg.la

LIB_SOURCES = greg.c
LIB_OBJECTS =  greg.lo

LIB_LDFLAGS = -version-info $(VER_INFO) -export-dynamic

COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(GUILE_LDFLAGS) -o $@



all: $(LIB)

.SUFFIXES:
.SUFFIXES: .S .c .lo .o .s

.s.o:
	$(COMPILE) -c $<

.S.o:
	$(COMPILE) -c $<

.s.lo:
	$(LIBTOOL) --mode=compile $(COMPILE) -c $<

.S.lo:
	$(LIBTOOL) --mode=compile $(COMPILE) -c $<

libgreg.la: $(LIB_OBJECTS)
	$(LINK) -rpath $(libdir) $(LIB_LDFLAGS) $(LIB_OBJECTS) $(LIBS)

%.o: %.c
	@echo '$(COMPILE) -c $<'; \
	$(COMPILE) -c $<

%.lo: %.c
	@echo '$(LTCOMPILE) -c $<'; \
	$(LTCOMPILE) -c $<

install: libgreg.la
	$(MKINSTDIRS) $(INSTALL_ROOT_DIR)$(GUILE_SCM_PATH); \
	$(MKINSTDIRS) $(libdir); \
	$(MKINSTDIRS) $(bindir); \
	if test -f ${LIB}; then \
	  $(INSTALL_DATA) .libs/libgreg.so $(libdir)/libgreg.so; \
	fi; \
	$(INSTALL_DATA) greg.scm $(INSTALL_ROOT_DIR)${GUILE_SCM_PATH}/greg.scm; \
	$(INSTALL_SCRIPT) greg ${bindir}/greg;

clean:
	rm -rf core *.o *.lo *.la .libs *.log *.dbg

distclean:	clean
	rm -rf greg greg.scm config.h test.* Makefile

