#******************************************************************************
#                              PACOR II SOFTWARE
#                      Property of the U.S. Government
#                              NASA/GSFC/Code 560
#******************************************************************************
#
#    UNIT NAME:
#	Makefile2
#
#    PURPOSE:
#	To compile the sources in the chiLib directory and make a library
#
#    INVOCATION METHOD:
#		Called only from chiLib/Makefile
#
#    EXTERNAL VARIABLES:
#
#       SOURCE		NAME		TYPE	USE	DESCRIPTION
#       ------		----		----	---	--------------------
#	Makefile	INCLUDES	macro	I	List of *.h includes in 
#							  chiInclude, 
#							  ixxInclude, 
#							  dbxInclude, and 
#							  xxxInclude
#							  directories
#       Makefile        MYCFLAGS        macro   I       CFLAGS options
#	Makefile	SOURCES		macro	I	List of *.c files
#	Makefile	TASK		macro	I	name of task
#	.cshrc		BXRY		macro	I	Build and Release 
#							  numbers used in
#							  building cadre model
#							  name
#       .dps_compile_info               DPSMRMINC       location of Mrm Includes
#       .dps_compile_info               DPSXMINC        location of Xm Includes
#       .dps_compile_info               DPSX11INC       location of X11 Includes
#                     
#                        
#
#    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
#       J. Kerich     N/A	  TRACE R1.0 03/27/96   Upgrade to work on IRIX
#       C. DeMeter    N/A         TRACE R1.0 06/13/96   Modify to work for chiLib
#       R. Wiechert   WIND970001  R1.0       06/16/97   Upgraded for SUN Solaris 2.5
#
#    NOTES:
#	This uses the environment variables INCLUDES and SOURCES set
#	up by Makefile to determine how to do the compile and library archive.
#
#
#******************************************************************************

CPPFLAGS= \
	-DSUN_VERSION \
	-I$$PACOR2HOME/chiInclude \
	-I$$PICSHOME/ixxInclude \
	-I$$PACOR2HOME/dbxInclude \
	-I$$PACOR2HOME/xxxInclude \
	-I$$DPSMRMINC \
	-I$$DPSXMINC \
	-I$$DPSX11INC 
LINTFLAGS=

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

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

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

.SUFFIXES: .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)

.c.o:
	$(CC) -c $(CFLAGS) $*.c

SOURCESC:

$(LIBRARY): $(OBJECTS)
	ar ru $(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)
