#
# This file is a Makefile for Neo, the NeoSoft extensions to Tcl.
# If it has the name "Makefile.in" then it is a template for a
# Makefile;  to generate the actual Makefile, run "./configure",
# which is a configuration script generated by the "autoconf" program
# (constructs like "@foo@" will get replaced in the actual Makefile.
#

VERSION = @NEO_VERSION@
LIBNAME = @NEO_SHARED_LIB_FILE@

# Default top-level directories in which to install architecture-
# specific files (exec_prefix) and machine-independent files such
# as scripts (prefix).  The values specified here may be overridden
# at configure-time with the --exec-prefix and --prefix options
# to the "configure" script.

prefix =        @prefix@
exec_prefix =       @exec_prefix@

# The following definition can be set to non-null for special systems
# like AFS with replication.  It allows the pathnames used for installation
# to be different than those used for actually reference files at
# run-time.  DESTDIR is prepended to $prefix and $exec_prefix
# when installing files.
DESTDIR =

# Directory in which to search for tcl libraries
NEO_LIBRARY	= $(exec_prefix)/lib/ldaptcl$(VERSION)

# Directory in which to install the ldaptcl binary:
BIN_INSTALL_DIR = $(DESTDIR)$(exec_prefix)/bin

# Directory in which to install the .a or .so binary for the Neo library:
LIB_INSTALL_DIR = $(DESTDIR)$(exec_prefix)/lib

# Path to use at runtime to refer to LIB_INSTALL_DIR:
LIB_RUNTIME_DIR =	$(exec_prefix)/lib

# Top-level directory for man entries:
MANN_INSTALL_DIR =	$(DESTDIR)$(prefix)/man/mann


# The symbols below provide support for dynamic loading and shared
# libraries.  The values of the symbols are normally set by the
# configure script.  You shouldn't normally need to modify any of
# these definitions by hand.

SHLIB_CFLAGS = @NEO_SHLIB_CFLAGS@

NEO_LIB_FILE = @NEO_LIB_FILE@

NEO_SHARED_LIB_FILE = @NEO_SHARED_LIB_FILE@

# The directory containing the Tcl sources and headers appropriate
# for this version of Neo ("srcdir" will be replaced or has already
# been replaced by the configure script):
TCL_GENERIC_DIR =   @TCL_SRC_DIR@/generic

# The top of the TclX directory tree
TCLX_TOP_DIR	=	@TCLX_TOP_DIR@

# The directory where tclExtend.h will be:
TCLX_TCL_GEN_DIR =	${TCLX_TOP_DIR}/tcl/generic

# The directory where tclXunixPort.h will be:
TCLX_TCL_UNIX_DIR =	${TCLX_TOP_DIR}/tcl/unix

# The path to tclX the runtcl script:
TCLX_RUNTCL	=	${TCLX_TOP_DIR}/unix/runtcl

# The directory containing the Tcl library archive file appropriate
# for this version of Neo:
TCL_BIN_DIR =       @TCL_BIN_DIR@


# The symbol below provides support for dynamic loading and shared
# libraries.  See configure.ac for a description of what it means.
# The values of the symbolis normally set by the configure script.

SHLIB_LD = @SHLIB_LD@

# Set to the options to include libldap.a and liblber.a 
# (eg. -L../tools/blah -lldap -llber)

LDAP_LIBFLAGS	= @ldaplibflags@
LDAP_CFLAGS	= @ldapinclude@
LDAP_INCDIR	= @ldapincdir@
LDAP_BUILD	= @ldapbuild@
LDAP_DIR	= @ldapdir@


#----------------------------------------------------------------
# The information below is modified by the configure script when
# Makefile is generated from Makefile.in.  You shouldn't normally
# modify any of this stuff by hand.
#----------------------------------------------------------------

AC_FLAGS =      @DEFS@
INSTALL=	@INSTALL@
INSTALL_PROGRAM =   @INSTALL_PROGRAM@
INSTALL_DATA =      @INSTALL_DATA@
RANLIB =        @RANLIB@
SRC_DIR =       @srcdir@/..
TOP_DIR =       @srcdir@/..
GENERIC_DIR =       $(TOP_DIR)/generic

#----------------------------------------------------------------
# The information below should be usable as is.  The configure
# script won't modify it and you shouldn't need to modify it
# either.
#----------------------------------------------------------------


OBJS= neoXldap.o

LIBDIR=$(exec_prefix)/lib
INCDIR=$(prefix)/include

LIBS= @LIBS@ @TCLX_LIB_SPEC@ @TCL_LIB_SPEC@ @TCL_LIBS@ $(LDAP_LIBFLAGS) -lc
TK_LIBS=@TKX_LIB_SPEC@ @TK_LIB_SPEC@ @TK_LIBS@
TK_VERSION=@TK_VERSION@

CC =        @CC@
CC_SWITCHES =   ${CFLAGS} @NEO_SHLIB_CFLAGS@ -I. \
-I@prefix@/include ${AC_FLAGS} ${PROTO_FLAGS} \
${SECURITY_FLAGS} ${MEM_DEBUG_FLAGS} ${KEYSYM_FLAGS} \
-DNEO_LIBRARY=\"${NEO_LIBRARY}\" -DVERSION=\"${VERSION}\" 

TK_SWITCHES = ${CC_SWITCHES} @TK_XINCLUDES@

.c.o:
	$(CC) -c $(CC_SWITCHES) $<

all:	@NEO_LIB_FILE@ ldaptclsh @LDAPWISH@

@NEO_LIB_FILE@:	$(OBJS)
	rm -f @NEO_LIB_FILE@
	@MAKE_LIB@
	$(RANLIB) @NEO_LIB_FILE@

neoXldap.o: neoXldap.c ldaptclerr.h
	$(CC) -c $(LDAP_CFLAGS) $(CC_SWITCHES) neoXldap.c

ldaptclerr.h: ldaperr.tcl
	tcl ldaperr.tcl $(LDAP_INCDIR)/ldap.h > ldaptclerr.h


clean:
	-rm -f ldaptclsh ldapwish
	-rm -f *.o *.a *.so*

distclean: clean
	rm -f Makefile pkgIndex.tcl config.cache config.log config.status \
		ldaptclerr.h

install: install-binaries install-man

install-binaries: @NEO_LIB_FILE@ ldaptclsh @LDAPWISH@
	@-mkdir -p $(BIN_INSTALL_DIR)
	$(INSTALL_PROGRAM) ldaptclsh $(BIN_INSTALL_DIR)/ldaptclsh
	@if [ -n "@LDAPWISH@" ] ; then \
	    echo $(INSTALL_PROGRAM) ldapwish $(BIN_INSTALL_DIR)/ldapwish; \
	    $(INSTALL_PROGRAM) ldapwish $(BIN_INSTALL_DIR)/ldapwish; \
	fi
	$(INSTALL_DATA) @NEO_LIB_FILE@ $(LIB_INSTALL_DIR)
	@if [ "$(NEO_LIB_FILE)" = "$(NEO_SHARED_LIB_FILE)" ] ; then \
		echo Installing pkgIndex.tcl in $(NEO_LIBRARY); \
		mkdir -p $(NEO_LIBRARY); \
		$(INSTALL_DATA) pkgIndex.tcl $(NEO_LIBRARY); \
	fi


install-man:
	@for i in ldap.n; \
	    do \
	    echo "Installing $$i"; \
	    rm -f $(MANN_INSTALL_DIR)/$$i; \
	    sed -e '/man\.macros/r man.macros' -e '/man\.macros/d' \
		    $$i > $(MANN_INSTALL_DIR)/$$i; \
	    chmod 444 $(MANN_INSTALL_DIR)/$$i; \
	done;


TCLOFILES= tclAppInit.o

ldaptclsh:$(TCLOFILES) @NEO_LIB_FILE@
	$(CC) @LD_FLAGS@ $(TCLOFILES) @NEO_BUILD_LIB_SPEC@ $(LIBS) \
	@TCL_LD_SEARCH_FLAGS@ -o ldaptclsh

tkAppInit.o: tkAppInit.c
	$(CC) -c ${TK_SWITCHES} tkAppInit.c

ldapwish:tkAppInit.o @NEO_LIB_FILE@
	$(CC) @LD_FLAGS@ tkAppInit.o @NEO_BUILD_LIB_SPEC@ $(TK_LIBS) $(LIBS) \
	@TCL_LD_SEARCH_FLAGS@ -o ldapwish
