#   Makefile for Tcl/Objective-C interface library
#   Copyright (C) 1993,1994  R. Andrew McCallum
#
#   Written by:  R. Andrew McCallum <mccallum@cs.rochester.edu>
#   Dept. of Computer Science, U. of Rochester, Rochester, NY  14627
#
#   This file is part of the Tcl/Objective-C interface library.
#
#   This library is free software; you can redistribute it and/or
#   modify it under the terms of the GNU Library General Public
#   License as published by the Free Software Foundation; either
#   version 2 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
#   Library General Public License for more details.
#
#   You should have received a copy of the GNU Library General Public
#   License along with this library; if not, write to the Free
#   Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
#  WARNING: This Makefile is provided as-is.  You'll definitely have
#  to change it to make it work on your system.
#  I'm using GNU make, I don't think it will work with anything else.

# prefix is the base directory in which things will get installed.
# i.e. prefix=/usr/local might be a good option.

prefix = /usr/local/rbs/tcl
RANLIB = ranlib
INSTALL = /usr/bin/install
INSTALL_DATA = $(INSTALL) -m 644

AR = ar
ARFLAGS = rc

# directories in which to find the required include files
TCL_INCLUDE_FLAG = -I/usr/local/rbs/tcl/include
TCL_LIB_FLAG = -L/usr/local/rbs/tcl/lib
LIBCOLL_INCLUDE_FLAG = -I$(prefix)/include
X_INCLUDE_FLAG = -I/usr/include

# There's a chance that you might not have to change anything below this line

CC = cc
libdir = $(prefix)/lib
includedir = $(prefix)/include


INCLUDEFLAGS = -I. $(TCL_INCLUDE_FLAG) $(LIBCOLL_INCLUDE_FLAG) \
	$(X_INCLUDE_FLAG)
CFLAGS = -g -Wall $(INCLUDEFLAGS)
ALL_OBJCFLAGS = $(CFLAGS)

.SUFFIXES: .m
.m.o:
	$(CC) -c $(ALL_OBJCFLAGS) -o $@ $<

SOURCES = Tcl.m tclObjc.m tclObjcAppInit.c
OFILES = tclObjc.o Tcl.o tclObjcAppInit.o
HEADERS = Tcl.h tclObjc.h
DISTFILES = $(SOURCES) $(HEADERS) README Makefile COPYING.LIB

all: libtclobjc.a tclObjcSh

tclObjcSh: main.o libtclobjc.a
	${CC} ${CC_SWITCHES} -o tclObjcSh main.o libtclobjc.a $(TCL_LIB_FLAG) -ltcl ${MATH_LIBS} 

libtclobjc.a: $(OFILES)
	$(AR) $(ARFLAGS) libtclobjc.a $(OFILES)
	$(RANLIB) libtclobjc.a

install: libtclobjc.a
	$(INSTALL_DATA) libtclobjc.a $(libdir)/libtclobjc.a
	$(RANLIB) $(libdir)/libtclobjc.a
	$(INSTALL_DATA) $(HEADERS) $(includedir)

uninstall:
	rm -f $(libdir)/libtclobjc.a
	for i in $(HEADERS) ; do rm $(includedir)/$$i ; done

clean:
	rm -f *.o *~ tclObjcSh libtclobjc.a

dist:
	echo libtclobjc-0.1 > .fname
	rm -rf `cat .fname`
	mkdir `cat .fname`
	for file in $(DISTFILES); do \
	  ln $$file `cat .fname`/$$file ; \
	done
	tar -chvf `cat .fname`.tar `cat .fname`
	gzip `cat .fname`.tar
	rm -rf `cat .fname` .fname
