#******************************************************************************
#                              PACOR II SOFTWARE
#                      Property of the U.S. Government
#                              NASA/GSFC/Code 560
#******************************************************************************
#
#    UNIT NAME:
#	Makefile2
#
#    PURPOSE:
#	To compile the sources in the dbpLib directory and make a library
#
#    INVOCATION METHOD:
#		Called only from dbpLib/Makefile
#
#    EXTERNAL VARIABLES:
#
#       SOURCE		NAME		TYPE	USE	DESCRIPTION
#       ------		----		----	---	--------------------
#	Makefile	INCLUDES	macro	I	List of *.h include in  
#							  xxxInclude, dbxInclude, dbpInclude
#							  directories
#	Makefile	SOURCES		macro	I	List of *.c files
#	Makefile	TASK		macro	I	name of task
#	.cshrc		ORACLE_HOME	macro	I	Path to oracle directory
#	.cshrc		BXRY		macro	I	Build and Release numbers used
#							  in building cadre model name
#
#    EXTERNAL FILE/RECORD REFERENCES:
#
#       NAME		USE	DESCRIPTION
#       ----		---	-------------------------------------
# 	none
#
#    EXTERNAL UNIT/MACRO/PROCEDURE/FUNCTION REFERENCES:
#
#       NAME		PURPOSE
#       ------------	----------------------------------------------
#	none
#
#    ABNORMAL TERMINATION CONDITIONS, ERROR MESSAGES:
#	none
#
#    ASSUMPTIONS, CONSTRAINTS, RESTRICTIONS:
#	none
#
#    DEVELOPMENT HISTORY:
#
#    	Author	      Change-ID	  Release      Date     Description of Change
#    	-----------   ---------	  --------   --------   -----------------------
#	J. Kerich     N/A         R3.0       09/11/95   Original Implementation
#	I. Horowitz   n/a         ACE R1.0   02/07/96   Updated to use Oracle 7.2.2
#       R. Wiechert   WIND970001  R1.0       06/16/97   Upgraded for Oracle 7.3.2
#
#    NOTES:
#	This uses the environment variable INCLUDES and SOURCES set 
#	up by Makefile to determine how to do the compile and library archive.
#
#	The ORACLE_HOME path must be set in the user's .cshrc before you can 
#	compile the PDPS system.
#
#******************************************************************************

CPPFLAGS= -DSUN_VERSION -I../xxxInclude -I../dbxInclude -I../dbpInclude
LINTFLAGS=

LIBRARY= libdbp.a
LINTFILES= $(SOURCES:.c=.ln)		# lint files
OBJECTS= $(SOURCES:.c=.o)		# object files

#  model name example for dbp task is "dbp_dbp_libdbp.a_B2_R1"
BMDL_OPTION= -model dbp_dbp_$(LIBRARY)_$(BXRY) -force -language solaris_Xt -pp_opt "$(CPPFLAGS)" -sclnote SCL-note


#******************************************************************************
#
#	Oracle directories
#
#******************************************************************************
LD_LIBRARY_PATH= $(ORACLE_HOME)/lib	

ORACLE_LIB= $(ORACLE_HOME)/lib
ORACLE_PROC= $(ORACLE_HOME)/bin/proc
 
# Oracle 7.3.2   Pro*C 2.2.2
NETLIBS= -lsqlnet -lncr -lsqlnet
LLIBORA= -lclient -lcommon -lgeneric
CORELIBS= -lnlsrtl3 -lc3v6 -lcore3 -lnlsrtl3 -lcore3 -lnlsrtl3
TTLIBS= $(NETLIBS) $(LLIBORA) $(NETLIBS) $(LLIBORA) -lepc $(CORELIBS)
PROLDLIBS= -lclntsh -lsql $(TTLIBS)
OTHERLIBS= `cat $(ORACLE_HOME)/rdbms/lib/sysliblist`
ORACLE_LIBS= $(PROLDLIBS) $(OTHERLIBS)
 
ORACLE_LDFLAGS= -L$(ORACLE_LIB)
 
#NETLIBS   = $(ORACLE_HOME)/lib/osntab.o -lsqlnet
#ORACLE_LIBS= ((-Bdynamic)) $(PROLDLIBS) $(OTHERLIBS) ((-lm -lthread))
#******************************************************************************
#
#	Oracle precompile information
#
#******************************************************************************
PROFLAGS=ireclen=160 oreclen=160 select_error=no mode=ANSI code=ANSI_C DBMS=V7
PCCFLAGS=include=$(PCCINC) ireclen=160 oreclen=160 select_error=no

################################################################################
#
#	Dependency entries.
#
################################################################################

.SUFFIXES: .pc .c .o .ln

.KEEP_STATE:

.PRECIOUS: $(LIBRARY)

SHELL = /usr/bin/sh
CFLAGS = $(MYCFLAGS) $(CPPFLAGS)
LINT.c= lint $(LINTFLAGS) $(MYCFLAGS) $(CPPFLAGS)

debug nodebug optimize gprof tcov: $(OBJECTS) $(LIBRARY)

.pc.c:
	rm -f $*.c; cp $*.pc $*.c
	chmod u+w $*.c
	$(CC) -P -D_NO_LONGLONG $(CPPFLAGS) $*.c
	sed "/#ident/d" $*.i > $*.ipc
	$(ORACLE_PROC) iname=$*.ipc $(PROFLAGS)
	rm $*.ipc $*.i

.c.o:
	-@if [ -f $*.pc ]; then \
	rm -f $*.c; cp $*.pc $*.c; \
	chmod u+w $*.c; \
	$(CC) -P -D_NO_LONGLONG $(CPPFLAGS) $*.c; \
	sed "/#ident/d" $*.i > $*.ipc; \
	$(ORACLE_PROC) iname=$*.ipc $(PROFLAGS); \
	rm $*.ipc $*.i; \
	fi
	$(CC) -c $(CFLAGS) $*.c

SOURCESC:

$(LIBRARY): $(OBJECTS)
	ar cru $(LIBRARY) $?

$(OBJECTS):$(INCLUDES)

.c.ln:
	$(LINT.c) -c $<
 
lint: $(SOURCES) $(LINTFILES)
	$(LINT.c) $(LINTFILES)
	$(LINT.c) -c $(SOURCES)

cadre: bmdl.run
bmdl.run: $(SOURCES) $(INCLUDES)
	bmdl -files $(SOURCES) $(INCLUDES) $(BMDL_OPTION)
