# $Id: s.Makefile.in 1.38 01/03/24 21:46:03+01:00 neumann@somewhere.wu-wien.ac.at $
prefix = 	@prefix@
exec_prefix=	@execPrefix@

## for bitkeeper
GET=bk get -S

# In order to use DMALLOC, uncomment the following lines
#DMALLOC_DEFINES = -DDMALLOC
#DMALLOC_LIB     = -ldmalloc
#
# AOLSERVER
#AOL_DEFINES	= -DAOL_SERVER -DUSE_TCL8X -I/usr/local/aolserver/include
AOL_DEFINES	= @AOL_DEFINES@
#
#STUB_DEFINES	= -DUSE_TCL_STUBS
#
# try ./configure first to fill in all the definitions corresponding
# to your system, but you always can edit the sections below manually.
CC=		@CC@
CFLAGS=		@CFLAGS@ @CFLAGS_DEBUG@ -Wall \
			-DXOLIBPKG=\"$(INST_XOLIBPKG)\" \
			-DXOTCLVERSION=\"$(XOTCLVERSION)\"  \
			$(DMALLOC_DEFINES) $(AOL_DEFINES) $(STUB_DEFINES)
RANLIB= 	@RANLIB@
INSTALL=	@INSTALL@
#
# where to find tcl/tk source (for includes) and binaries (for libraries)
TCLINC=		-I@TCLINCDIR@
TCLLIB=		@TCL_LIB_SPEC@
TKINC=		-I@TKINCDIR@
TKLIB=		@TK_LIB_SPEC@

#
# X11 and other libraries from tcl/tk make as needed to link tclsh and wish
#
XINC=		@XINC@
XLIB=		@XLIB@
OTHER_TCL_LIBS=	@OTHER_TCL_LIBS@
OTHER_TK_LIBS=	@OTHER_TK_LIBS@

#
# how to compile, link, and name shared libraries
#
SHLIB_LD=	@SHLIB_LD@
SHLIB_CFLAGS=	@SHLIB_CFLAGS@
SHLIB_SUFFIX=	@SHLIB_SUFFIX@
SHLD_FLAGS=	@SHLD_FLAGS@
LD_FLAGS=	@LD_FLAGS@
DL_LIBS=	@DL_LIBS@

#
# where to install shells, libraries, and includes
#
INST_XOTCLSH=	$(exec_prefix)/bin
INST_XOWISH=	$(exec_prefix)/bin
INST_XOINC=	$(prefix)/include
INST_XOLIB=	$(prefix)/lib
INST_XOLIBPKG=	$(prefix)/lib/xotcl-$(XOTCLVERSION)
XOTCLSHF=       $(INST_XOTCLSH)/xotclsh-$(XOTCLVERSION)
XOTCLSH=        $(INST_XOTCLSH)/xotclsh
XOWISHF=        $(INST_XOTCLSH)/xowish-$(XOTCLVERSION)
XOWISH=         $(INST_XOTCLSH)/xowish

XOTCL= xotcl
XOTCLVERSION= @XOTCLVERSION@
MAKE_XOWISH= @MAKE_XOWISH@
INSTALL_XOWISH= @INSTALL_XOWISH@

#
# ------------ you shouldn't need to configure below here -----------------
#
MAKEXOTCL = ../lib/system/make.xotcl
LIBS= lib$(XOTCL)$(SHLIB_SUFFIX) lib$(XOTCL).a
INCLUDES= -I. $(TCLINC) $(TKINC) $(XINC) 
XOTCLLIB= -L. -l$(XOTCL)

SRCS =	xotclError.c xotclTrace.c xotclProfile.c \
	xotclReference.c xotclMetaData.c xotcl.c aolstub.c
OBJS =	o/xotclError.o o/xotclTrace.o o/xotclProfile.o \
	o/xotclReference.o o/xotclMetaData.o o/xotcl.o o/aolstub.o
SOBJS = so/xotclError.o so/xotclTrace.o so/xotclProfile.o \
	so/xotclReference.o so/xotclMetaData.o so/xotcl.o so/aolstub.o
STOBJS =st/xotclError.o st/xotclTrace.o st/xotclProfile.o \
	st/xotclReference.o st/xotclMetaData.o st/xotcl.o st/aolstub.o


all : xotclsh $(MAKE_XOWISH) $(LIBS) libxotclstub$(SHLIB_SUFFIX)
libs:  $(LIBS)

o/%.o: %.c 
	@if test ! -d o; then mkdir o; fi
	$(CC) -c -o $@ $(CFLAGS) $(INCLUDES) $<
so/%.o: %.c
	@if test ! -d so; then mkdir so; fi
	$(CC) -c -o $@ $(CFLAGS) $(SHLIB_CFLAGS) $(INCLUDES) $<
st/%.o: %.c
	@if test ! -d st; then mkdir st; fi
	$(CC) -c -o  $@ -DUSE_TCL_STUBS $(CFLAGS) $(SHLIB_CFLAGS) $(INCLUDES) $<
%.o: %.c
	$(CC) -c -o $@ $(CFLAGS) $(INCLUDES) $<

# create a predefined .h file from an .xotcl file.
# for development only, .h file included in distrbution
predefined.h: mk_predefined.xotcl predefined.xotcl
	./xotclsh mk_predefined.xotcl > predefined.h

#
# compile an appinit with tcl and xotcl and link against
# libxotcl.a plus required tcl libs to give a standalone binary
xotclsh: xotclAppInit.o lib$(XOTCL).a
	$(CC) $(LD_FLAGS) -o xotclsh xotclAppInit.o lib$(XOTCL).a \
		$(CFLAGS) $(TCLLIB) $(DL_LIBS) \
		$(OTHER_TCL_LIBS) $(DMALLOC_LIB)

# compile an appinit with tcl/tk and xotcl and link against
# libxotcl.a plus required tcl/tk libs to give a standalone binary
xowish: xotkAppInit.o  lib$(XOTCL).a
	$(CC) $(LD_FLAGS) -o xowish xotkAppInit.o lib$(XOTCL).a $(CFLAGS) \
		$(TKLIB) $(TCLLIB) $(XLIB) $(DL_LIBS) \
		$(OTHER_TK_LIBS) $(OTHER_TCL_LIBS) $(DMALLOC_LIB)

#
# compile xotcl.c and link it into a library archive
# INCLUDES give a path to tclInt.h (plus tk and X11)
lib$(XOTCL).a: $(OBJS)
	ar cr $@ $(OBJS)
	$(RANLIB) $@

libxotclstub$(SHLIB_SUFFIX): $(STOBJS)
	$(SHLIB_LD) -o $@ $(SOBJS)

#
# compile xotcl.c and link it into a shared object
# INCLUDES give a path to tclInt.h (plus tk and X11)
lib$(XOTCL)$(SHLIB_SUFFIX): $(SOBJS)
	$(SHLIB_LD) -o $@ $(SOBJS)


install: install_xotclsh $(INSTALL_XOWISH)

install_xotclsh: xotclsh lib$(XOTCL).a lib$(XOTCL)$(SHLIB_SUFFIX) $(INST_XOTCLSH) $(INST_XOLIBPKG) $(INST_XOINC)
	$(INSTALL) -s xotclsh $(XOTCLSHF)
	ln -sf $(XOTCLSHF) $(XOTCLSH)
	$(INSTALL) lib$(XOTCL).a $(INST_XOLIBPKG) 
	$(INSTALL) lib$(XOTCL)$(SHLIB_SUFFIX) $(INST_XOLIBPKG)
	$(INSTALL) lib$(XOTCL)stub$(SHLIB_SUFFIX) $(INST_XOLIBPKG)
	$(INSTALL) xotcl.h xotclInt.h $(INST_XOINC)
	./xotclsh $(MAKEXOTCL) -target $(INST_XOLIBPKG) -install.index  

install_xowish: xowish lib$(XOTCL).a lib$(XOTCL)$(SHLIB_SUFFIX) $(INST_XOWISH) $(INST_XOLIBPKG) $(INST_XOINC)
	$(INSTALL) -s xowish $(XOWISHF)
	ln -sf $(XOWISHF) $(XOWISH)
	$(INSTALL) lib$(XOTCL).a $(INST_XOLIBPKG)
	$(INSTALL) lib$(XOTCL)$(SHLIB_SUFFIX) $(INST_XOLIBPKG)
	$(INSTALL) xotcl.h xotclInt.h $(INST_XOINC)

$(INST_XOWISH):
	if test ! -d $@; then mkdir $@; fi
$(INST_XOTCLSH):
	if test ! -d $@; then mkdir $@; fi
$(INST_XOLIBPKG):
	if test ! -d $@; then mkdir $@; fi
$(INST_XOINC):
	if test ! -d $@; then mkdir $@; fi

xref:
	cxref -xref-all -html32 -I $(INCLUDES) xotcl.c xotcl.h xotclInt.h xotcl*Init.c


clean:
	rm -rf xowish xotclsh lib$(XOTCL).a lib$(XOTCL)$(SHLIB_SUFFIX) \
		*.o o so config.status config.log config.cache \
		*.html xref.* \
		core so_locations gmon.out *~ \#*

binclean:
	rm -rf *.o o so config.status config.log config.cache \
		core so_locations



o/xotcl.o: xotcl.h xotclInt.h predefined.h
so/xotcl.o: xotcl.h xotclInt.h predefined.h

o/xotclMetaData.o: xotcl.h xotclInt.h
so/xotclMetaData.o: xotcl.h xotclInt.h

o/xotclTrace.o: xotcl.h xotclInt.h
so/xotclTrace.o: xotcl.h xotclInt.h

o/xotclError.o: xotcl.h xotclInt.h
so/xotclError.o: xotcl.h xotclInt.h

o/xotclProfile.o: xotcl.h xotclInt.h
so/xotclProfile.o: xotcl.h xotclInt.h

o/xotclReference.o: xotcl.h xotclInt.h
so/xotclReference.o: xotcl.h xotclInt.h

xotclAppInit.o: xotcl.h xotclInt.h
xotkAppInit.o: xotcl.h xotclInt.h
