#	@(#)Makefile	1.13	4/6/93
#

CC = cc
# where to find uperl.o
PERLSRC = ../perl-4.036
# where to find the sybase .h files
SYBINCS = /usr/sybase/include
# other includes ?
LOCINCS =
# Sybase libraries
SYBLIBDIR = /usr/sybase/lib
# db-library
SYBLIBS = -lsybdb
# Uncomment this if you are compiling sybperl for Perl version 3.xx

# PERL_VERSION = -DVERSION3

# The Perl/Sybase savestr() conflict.
# Both Perl and Sybase DB-Library have a function called savestr(),
# and this creates a problem when using functions such as dbcmd().
# There are several ways around this.
# You can:
#
#	- Recompile uperl.o with a -Dsavestr=psvestr (or something similar).
#	- Edit an existing uperl.o and change _savestr to _psvestr.
#
#
# To use the first option, you have to reconfigure & recompile Perl
# manually, and then set compile sybperl with the following line
# uncommented:
# UPERL = $(PERLSRC)/uperl.o
#
# The default is to use the third solution:
UPERL = uperl2.o

# Remove this if you don't
# have Perl 4 patchlevel 18
# User defined, perl based
# error/message handlers are
# not possible without this, however.
HAS_CALLBACK= -DHAS_CALLBACK

# some backward compatibility stuff.
OLD_SYBPERL= -DOLD_SYBPERL

# Comment this if your version
# of DBlib is older than
# version 4.2
#DBLIB42 = -DDBLIB42

# Uncomment this if you wish
# to get a fatal error message
# if you attempt to set on of
# Sybperl's variables from a
# script. Normally such
# actions are silently ignored.
#SET_VAL = -DUSERVAL_SET_FATAL

# Uncomment this to get
# 'undef' values returned by
# &dbnextrow when NULL values
# are retrieved. Otherwise,
# the string 'NULL' is returned.
#NULL_UNDEF = -DNULL_IS_UNDEF

CFLAGS = -O
CPPFLAGS = -I$(PERLSRC)  -I$(SYBINCS) $(PERL_VERSION) \
		$(SAVESTR) $(HAS_CALLBACK) $(OLD_SYBPERL) $(DBLIB42) \
		$(SET_VAL)
# where does the executable go
BINDIR = /usr/local/bin

# where does lib/sybperl.pl
# and lib/sybdb.ph go
PERLLIB = /usr/local/lib/perl
# where do we put the manual page
MANDIR = /usr/local/man
MANEXT = l


sybperl: $(UPERL) sybperl.o
	$(CC) $(CFLAGS) -L$(SYBLIBDIR) $(UPERL) sybperl.o $(SYBLIBS) -lm -o sybperl

sybperl.o: sybperl.c
	$(CC) -c $(CFLAGS) $(CPPFLAGS) sybperl.c

# Create uperl.o IF you wish to use the 3rd way of resolving the
# Perl/Sybase savestr conflict.
$(UPERL): $(PERLSRC)/uperl.o
	cp $(PERLSRC)/uperl.o $(UPERL)
	perl -p -i.bak -e 's/savestr/psvestr/g;' $(UPERL)
	rm -f $(UPERL).bak


clean:
	rm -f sybperl *.o *~ core

install: sybperl
	install -s -m 775 sybperl $(BINDIR)
	cp lib/syb*.p? $(PERLLIB)
	cp sybperl.1 $(MANDIR)/man$(MANEXT)/sybperl.$(MANEXT)

shar:
	rm -f sybperl.shar
	shar.pl README PACKING.LST BUGS CHANGES Makefile sybperl.c \
	sybperl.1 patchlevel.h lib/sybperl.pl lib/sybdb.ph t/sbex.pl \
	eg/sql.pl eg/space.pl eg/capture.pl eg/report.pl \
	eg/dbschema.pl eg/dbtext.pl eg/README >sybperl.shar


tar:
	rm -f sybperl.tar
	tar cvfB sybperl.tar README PACKING.LST BUGS CHANGES Makefile sybperl.c \
	sybperl.1 patchlevel.h lib/sybperl.pl lib/sybdb.ph t/sbex.pl \
	eg/sql.pl eg/space.pl eg/capture.pl eg/report.pl \
	eg/dbschema.pl eg/dbtext.pl eg/README





