#******************************************************************************
#                              PACOR II SOFTWARE
#                      Property of the U.S. Government
#                              NASA/GSFC/Code 560
#******************************************************************************
#
#    UNIT NAME:
#	Makefile2
#
#    PURPOSE:
#	To compile the sources in the ixxLib directory and make a library
#
#    INVOCATION METHOD:
#		Called only from ixxLib/Makefile
#
#    EXTERNAL VARIABLES:
#
#       SOURCE		NAME		TYPE	USE	DESCRIPTION
#       ------		----		----	---	--------------------
#	Makefile	INCLUDES	macro	I	List of *.h include in 
#							  dbxInclude and 
#							  xxxInclude
#							  directories
#       Makeksh         MYCFLAGS        macro   I       CFLAGS options
#	Makefile	SOURCES		macro	I	List of *.c files
#	Makefile	TASK		macro	I	name of task
#	.cshrc		ORACLE_HOME	macro	I	Path to oracle directory
#
#    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         R0B1       07/08/93   Original Implementation
#	Hassett       N/A         R0         09/93      Deleted Solaris 1.1 specific
#							flags and commands
#	J. Kerich     N/A         R1B2       09/17/93   Upgrade cadre option command
#							and pc rule
#       I. Horowitz   N/A         ACE R1.0   11/21/95   Ported to HP; added HP_VERSION to
#							 CPPFLAGS, setup for Oracle 7.1.3
#       C. DeMeter    ACE         R1.0       02/22/96   Update for ORACLE 7.2.2
#       C. DeMeter    TRACE       R1.0       04/29/96   Update to work on IRIX
#       R. Wiechert   WIND970001  R1.0       06/16/97   Upgraded for SUN/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 ixxLib.
#
#******************************************************************************

CPPFLAGS= -DSUN_VERSION -I$$PACOR2HOME/xxxInclude -I$$PACOR2HOME/dbxInclude  -I$$PICSHOME/ixxInclude -I$$PICSHOME/irp/Include -I$$PICSHOME/ist/Include
LINTFLAGS=

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

#  model name example for psc task is "xxx_xxx_libxxx.a_B2_R1"
BMDL_OPTION= -model xxx_xxx_$(LIBRARY)_$(BXRY) -language sun4_5cc -pp_opt "$(CPPFLAGS)"


#******************************************************************************
#
#	Oracle directories
#
#******************************************************************************
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= -Bdynamic $(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=132 oreclen=132 select_error=no mode=ANSI code=ANSI_C DBMS=V7
PCCFLAGS=include=$(PCCINC) ireclen=132 oreclen=132 select_error=no

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

.SUFFIXES: .pc .c .o .ln

.KEEP_STATE:

.PRECIOUS: $(LIBRARY)

SHELL = /usr/bin/sh
CFLAGS= $(MYCFLAGS) $(CPPFLAGS) # SUN settings

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 ruv $(LIBRARY) $?

$(OBJECTS):$(INCLUDES)

.c.ln:
	$(LINT.c) -c $<

lint: $(SOURCES) $(LINTFILES)
	$(LINT.c) $(LINTFILES)
	$(LINT.c) -Cixx $(SOURCES)

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