# USAGE:  make S.so   (otherwise it defaults to some strange oracle lib!?)

# NOTE: Make sure you have the define and exported the following shell vars:
#       SHOME 
#       ORACLE_HOME

# For Oracle 8.x use the following
include $(ORACLE_HOME)/precomp/lib/env_precomp.mk  # ProC/C++ stuff

# For Oracele 7.x use the following
#include $(ORACLE_HOME)/precomp/env_precomp.mk

include $(SHOME)/library/S_FLAGS

SHELL = /bin/ksh      # needed by the $( ...) construct
CC    = cc
TAR   = gtar

# NOTE: if you use Splus 6+, you'll need to define the 
# macro S_COMPATIBILITY to 10 (see Splus Programmer's Manual, 341-342)

SRC   = RS-DBI.h RS-DBI.c RS-Oracle.h RS-Oracle.pc S4R.h
OBJ   = RS-DBI.o RS-Oracle.o
S_SRC = DBI.S Oracle.S OraSupport.S
OTHER = README Installation VERSION RS-DBI.pdf Copyrights LGPL TODO help
DIST  = SOracle_$$(cat VERSION).tar.gz

# if using Splus 6 make sure you also define -DSPLUS6 below
Scmd  = Splus6        

# Use LOCAL_CFLAGS to add arguments for the C compliler
LOCAL_CFLAGS = -DSPLUS6

# Use LOCAL_LIBS to add arguments or additional libraries to the linker
LOCAL_LIBS = -L$(ORACLE_HOME)/lib -L$(ORACLE_HOME)/network/lib $(PROLDLIBS)

# The *.pc suffix is the Oracle preCompiler for SQL embeding.
# Note that the default option "PARSE=FULL" breaks the POUND macros
# defined by MathSoft, thus we need to set PARSE to "PARTIAL".
# Be prepare to see a fair amount of warnings by the precompiler in
# the proc.log file, but they're harmless (?) as far as I can tell. 
# If you know how to please the precompiler, please let us know!

S.so:  $(OBJ) 
	$(SHOME)/cmd/Splus LIBRARY S.so  $(OBJ) $(LOCAL_LIBS)

RS-Oracle.c: RS-Oracle.pc RS-Oracle.h
	proc CODE=ANSI_C INCLUDE=$(SHOME)/include PARSE=PARTIAL RS-Oracle.pc > proc.log

dump:
	@if test -d ./.Data; then $(SHOME)/cmd/Splus dumpChapter $(SRC); fi

boot:
	@if test -s all.Sdata; 	  then \
	(BOOTING_S="TRUE" export BOOTING_S;  \
	echo "terminate\(should have been booting S\)"|$(SHOME)/cmd/$(Scmd) ) ;\
	fi
	@cp help/sgml/*.sgm .Data/__Shelp   # need to do ourselves!
clean:
	-rm $(OBJ) RS-Oracle.c

dist:   dump
	$(TAR) czf $(DIST) $(S_SRC) $(OTHER) $$(cat DUMP_FILES)

$(DIST): DUMP_FILES

DUMP_FILES: dump

panic: 
	rm -rf .Data 
	$(Scmd) CHAPTER
	$(Scmd) < DBI.S
	$(Scmd) < Oracle.S
	$(Scmd) < OraSupport.S
	cp help/sgml/*.sgm  .Data/__Shelp

