#******************************************************************************
#                              PACOR II SOFTWARE
#                      Property of the U.S. Government
#                              NASA/GSFC/Code 560
#******************************************************************************
#
#    UNIT NAME:
#	Makefile2
#
#    PURPOSE:
#	To compile the sources in the dbxLib directory and make a library
#
#    INVOCATION METHOD:
#		Called only from dbxLib/Makefile
#
#    EXTERNAL VARIABLES:
#
#       SOURCE		NAME		TYPE	USE	DESCRIPTION
#       ------		----		----	---	--------------------
#	Makefile	INCLUDES	macro	I	List of *.h include in  
#							  xxxInclude, and dbxInclude
#							  directories
#	Makefile	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
#	.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         TRACE R1.0 03/27/96   Original Implementation
#       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../dbxInclude -I../xxxInclude
LINTFLAGS=

LIBRARY= libdbx.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 dbx_dbx_$(LIBRARY)_$(BXRY) -force -language solaris_Xt -pp_opt "$(CPPFLAGS)" -sclnote SCL-note


#******************************************************************************
#
#	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=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)	# 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 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)
