#******************************************************************************
#                              PACOR II SOFTWARE
#                      Property of the U.S. Government
#                              NASA/GSFC/Code 560
#******************************************************************************
#
#    UNIT NAME:
#	Makefile
#
#    PURPOSE:
#	To compile the sources in the dbxLib directory and make a library.
#
#    INVOCATION METHOD:
#		make help
#			to see this help message.
#		
#		make [ debug | nodebug | optimize | gprof | tcov ]
#			to create $(LIBRARY).
#		
#		make lint
#			to run lint on dbxx*.c and create llib-lxxx.ln.
#		
#		make cadre
#			to run reverse engineering bmdl tool on *.c files
#
#               make clean
#                  to remove *%, *.lis, core, and xxx files.
#
#               make cleaner
#                  to remove *%, *.lis, core, xxx, *.o, *.ln,  precompiled units,
#		   $(LIBRARY), *.d ,and  *.tcov.
#
#    EXTERNAL VARIABLES:
#
#       SOURCE		NAME		TYPE	USE	DESCRIPTION
#       ------		----		----	---	--------------------
#	Makefile	INCLUDES	macro	O	List of *.h include in Include, 
#							  pxxInclude, and xxxInclude
#							  directories
#	Makefile	MYCFLAGS	macro	O	CFLAGS options
#	Makefile	SOURCES		macro	O	List of *.c files
#
#    EXTERNAL FILE/RECORD REFERENCES:
#
#       NAME		USE	DESCRIPTION
#       ----		---	-------------------------------------
# 	none
#
#    EXTERNAL UNIT/MACRO/PROCEDURE/FUNCTION REFERENCES:
#
#       NAME		PURPOSE
#       ------------	----------------------------------------------
#	Makefile2	Make source file with compile rules
#
#    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   Modify MYCFLAGS for Sun
#
#    NOTES:
#	This file creates the INCLUDES and SOURCES environment variables,
#	and calls Makefile2 to do the actual work.
#
#	INCLUDES is defined by running 'ls *.h' on the directories and changing 
#		the newlines to spaces.
#
#	SOURCES is defined by running 'ls pxx*.c' and changing the newlines to spaces.
#
#       The SOURCESCPC is defined by running 'ls pxx*.pc', changing the newlines
#       to spaces, and changing .pc to .c to get a list of precompiled c units.
#
#******************************************************************************

TARGETS= debug nodebug optimize gprof tcov lint cadre
LIBRARY= libdbx.a

SHELL = /usr/bin/sh
SOURCESCPC=`ls ?*.pc 2>/dev/null | sed "s/\.pc/\.c/p" | tr '\012' '\040'`

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

help:
	@ echo "Usage:"
	@ echo "	make help"
	@ echo "		to see this help message."
	@ echo ""
	@ echo "	make [ debug | nodebug | optimize | gprof | tcov ]"
	@ echo "		to create $(LIBRARY)."
	@ echo ""
	@ echo "	make lint"
	@ echo "		to run lint on xxx*.c and create llib-lxxx.ln."
	@ echo ""
	@ echo "	make cadre"
	@ echo "		to run reverse engineering bmdl tool on *.c files"
	@ echo ""
	@ echo "	make clean"
	@ echo "		to remove *%, *~, *.lis, *.i, core, and xxx files."
	@ echo ""
	@ echo "	make cleaner"
	@ echo "		to remove *%, *~, *.lis, *.i, core, xxx, *.o, *.ln, precompiled units,"
	@ echo "		$(LIBRARY), *.d , *.tcov, and pxx."

$(TARGETS): FORCE
	@       SOURCES=`ls *.c *.pc 2>/dev/null | sed "s/\.pc/\.c/p" | uniq | tr '\012' '\040'`; export SOURCES;\
	INCLUDES=`ls ../dbxInclude/?*.h  2>/dev/null | tr '\012' '\040'`; export INCLUDES;\
	if [ $@ = "debug" ];\
	then MYCFLAGS='-Xc -xcg92 -DSVR4 -Dsun -Dsparc -Dunix -g -DDEBUG'; export MYCFLAGS; \
	elif [ $@ = "nodebug" ];\
	then MYCFLAGS='-Xc -xcg92 -DSVR4 -Dsun -Dsparc -Dunix -g'; export MYCFLAGS; \
	elif [ $@ = "optimize" ];\
	then MYCFLAGS='-Xc -xcg92 -DSVR4 -Dsun -Dsparc -Dunix -O'; export MYCFLAGS; \
	elif [ $@ = "gprof" ];\
	then MYCFLAGS='-Xc -xcg92 -DSVR4 -Dsun -Dsparc -Dunix -xpg -O'; export MYCFLAGS; \
	elif [ $@ = "tcov" ];\
	then MYCFLAGS='-Xc -xcg92 -DSVR4 -Dsun -Dsparc -Dunix -xa'; export MYCFLAGS; \
	elif [ $@ = "lint" ];\
	then MYCFLAGS=''; export MYCFLAGS; \
	else @ echo "Invalid option"; \
	fi ;\
	$(MAKE) -f Makefile2 $@

.PRECIOUS: $(LIBRARY)

clean:
	-rm -f *~ *% *.lis core xxx

cleaner: clean
	-rm -f *.o *.ln *.i *.ipc  $(SOURCESCPC) *.d *.tcov $(LIBRARY)

FORCE:
