# @(#) $Header: /cvsroot/aolserver/aolserver3/nssybpd/Makefile,v 1.5 2000/04/05 16:26:33 kriston Exp $
#
# Makefile for AOLserver external Sybase proxy daemon.
#
# Tested on Solaris 7 with gcc 2.95.1 and IRIX 6.2 under Cygnus gcc.
# Since the Solaris libraries I have are only in -n32 format, there
# is no way to check this out in an Irix -o32 environment.
#

DIRNAME=nssybpd

ifndef SRCBASE
    SRCBASE=$(shell cd ..; pwd)
endif

include ../include/Makefile.global

#
# We hope to pick up the definition of SYBASE from the environment,
# but this might work if the environment variable isn't there.
#
ifndef SYBASE
    SYBASE=/dci/sybase
endif

#
# Location of Sybase libraries.
#
SYBLIB=$(SYBASE)/lib
#
# Location of Sybase include files
#
SYBINC=$(SYBASE)/include
CFLAGS += -I$(SYBINC)


#
# We can link in most of the libraries in the normal way, but we need
# to make sure we pick up the Sybase Tcl library, so it has to be linked
# explicitly.
#
SYBLIBS=-L$(SYBLIB) -lcs -lct $(SYBLIB)/libtcl.a -lintl -lcomn

#
# Define the output files
#

LIB = nssybpd

#
# Set the libraries
#
LIBS=-L../nspd -lnspd  $(SYBLIBS)

#
# Platform-specific stuff
#
ifeq ($(PLATFORM), HP-UX.10.20)
endif
ifeq ($(PLATFORM), irix)
    CFLAGS +=-D_OLD_TERMIOS
    ifeq ($(CC), gcc)
	LIBS += -rpath $(SYBLIB)
	LIBS += -rpath /usr/local/sybase/lib
	LIBS += -rpath /data/sybase/lib
    endif
endif
ifeq ($(PLATFORM), solaris)
    #
    # Establish a shared library search path so users don't have to
    # set LD_LIBRARY_PATH, if possible.
    #
    LIBS += -R $(SYBLIB):/usr/local/sybase/lib:/data/sybase/lib
    LIBS += -lsocket -lnsl -ldl
endif
ifeq ($(PLATFORM), OSF1)
    LIBS += -ldnet_stub -lsdna -lm
endif

#
# Set the objects to build
#

OBJS = nssybpd.o

#
# Let the building begin!
#

all: $(LIB)

%.o: %.c
	$(CC) -c $(CFLAGS) $(SRCBASE)/$(DIRNAME)/$< -o $@

#
# Build the final target(s)
#

$(LIB): $(OBJS)
	$(CC) $(LDFLAGS) -o $(LIB) $(OBJS) $(LIBS)

install: all
	$(CP) $(LIB) $(INSTBIN)


clean:
	$(RM) $(OBJS) $(LIB) so_locations

clobber: clean
	$(RM) *.so *.o *.a *~

distclean: clobber
	$(RM) TAGS core
