################################################################################
#  Revision History
#  ~~~~~~~~~~~~~~~~
#
#  fl	  10/26/99	IT00611Q		Created
#
################################################################################
#                        BUILD INSTRUCTIONS
#
#  Note that building with "clearmake" performs dependency checking.
#  Make does not do dependency checking, therefore all .a's and .o's
#  are removed before building with make.
#
#  >clearmake optimize
#  >make optimize
#        This will make the executable, library, and resource file.
#        All files which are compiled use the optimized compile options and
#        the optimized preprocessor defines.
#        The optimize library directory will be used.
#
#  >clearmake debug
#  >make debug
#        This will make the executable, library, and resource file.
#        All files which are compiled use the debugger compile options and
#        the debugger preprocessor defines.
#        The debug library directory will be used.
#
#  >make insure                           
#        This will make the executable, library, and resource file.
#        Code is compiled and linked using insure (the software quality
#        testing tools).
#        All files which are compiled use the insure compile options and
#        the insure preprocessor defines.
#        The insure library directory will be used.
#        DO NOT USE "clearmake insure" - it is a waste of time because
#        clearmake automatically rebuilds all insure objects.
#  
#  >clearmake resources
#  >make resources
#        These will make the resource file.
#
###############################################################################

###############################################################################
#
#                    MAKEFILE EDITING INSTRUCTIONS
#
#  FOLLOW THE STEPS (1) .. (7) AND FILL IN THE ASSOCIATED INFORMATION
#  
###############################################################################


###############################################################################
#                                                                             #
#      THIS IS THE BEGINNING OF THE EDITABLE SECTION OF THE MAKEFILE          #
#                                                                             #
###############################################################################

#
# (1) DEFINE YOUR APPLICATION AND LIBRARY NAMES
#
LIBNAME		= libImgProcess.a

#
# (2) DEFINE YOUR INCLUDE PATHS
#

INCLUDE_PATHS_SUN4U	=	-I${DEV_DIR}/include \
				-I/usr/openwin/include \
				-I/usr/openwin/include/X11/GLw \
				-I/opt/ICS/Motif/usr/include \
				-I/opt/SUNWspro/SC4.2/include/cc 

INCLUDE_PATHS_SUN4M	=	-I${DEV_DIR}/include \
				-I/usr/openwin/include \
				-I/opt/ICS/Motif/usr/include \
				-I/opt/SUNWspro/SC4.2/include/cc 

#
# (4) DEFINE THE FILES TO BE COMPILED
#
C_LIBSRCS	=	ppm.c \
                        SharpenImage.c

#
# (6) DEFINE THE COMPILIATION FLAGS
#
OPT_CCFLAGS  =       -O4 -xtarget=native -libmil
#OPT_CCFLAGS  =       -O4 -libmil -inline
INS_CCFLAGS  =       -g +w -mt
DBG_CCFLAGS  =       -g +w -mt

C_OPT_DEFINES	=	-DFUNCPROTO -D${ARCH} -D${VISUAL}
C_INS_DEFINES	=	-DFUNCPROTO -D${ARCH} -D${VISUAL}
C_DBG_DEFINES	=	-DFUNCPROTO -D${ARCH} -D${VISUAL}

OPT_LDFLAGS		=
INS_LDFLAGS		=
DBG_LDFLAGS		=

#
# (7) END
#


###############################################################################
#                                                                             #
#         THIS IS THE END OF THE EDITABLE SECTION OF THE MAKEFILE             #
#                                                                             #
###############################################################################

C_LIB_OBJS	=	${C_LIBSRCS:.c=.o}

SHELL		=	/bin/sh
CC		=	CC
INSURE		=	insure
RM_ALL 		=	/usr/bin/rm -f
ARFLAGS		=	rv



###############################################################################
#
#                         COMPILING 
#
###############################################################################

default:
	@${MAKE} DO_DBG='true' args

clean:
	${RM_ALL} *.a *.o

debug:
	@${MAKE} DO_DBG='true' args

insure:
	@${MAKE} DO_INS='true' args

optimize:
	@${MAKE} DO_OPT='true' args

.c.o:
	${COMPILER} ${CCFLAGS} ${INCLUDE_PATHS} -c $*.c



${LIBNAME}:	${C_LIB_OBJS}
	${AR} ${ARFLAGS} $@ ${C_LIB_OBJS}
	@echo " "



do_it:	${LIBNAME}
	-@if test -r "${DEV_DIR}/lib_private/${LIBNAME}" ; then		   \
		rm ${DEV_DIR}/lib_private/${LIBNAME} ;                     \
	fi
	mv ${LIBNAME} ${DEV_DIR}/lib_private
	@echo ${LIBNAME} is up to date.

sun4m:
	@if test -n "${DO_DBG}" ; then                                       \
		${MAKE}                                                       \
		COMPILER='${CC}' LINKER='${CC}'                               \
		INCLUDE_PATHS='${INCLUDE_PATHS_SUN4M}'			   \
		C_DEFINES='${C_DBG_DEFINES}'                                  \
		CCFLAGS='${DBG_CCFLAGS} ${C_DBG_DEFINES}'                      \
                MAKECMD='debug' do_it ;              \
	elif test -n "${DO_OPT}" ; then                                       \
		${MAKE}                                                       \
		COMPILER='${CC}' LINKER='${CC}'                               \
		INCLUDE_PATHS='${INCLUDE_PATHS_SUN4M}'			   \
		C_DEFINES='${C_OPT_DEFINES}'                                  \
		CCFLAGS='${OPT_CCFLAGS} ${C_OPT_DEFINES}'                      \
                MAKECMD='optimize' do_it ;           \
	elif test -n "${DO_INS}" ; then                                       \
		${MAKE}                                                       \
		COMPILER='${INSURE}' LINKER='${INSURE}'                       \
		INCLUDE_PATHS='${INCLUDE_PATHS_SUN4M}'	 		   \
		C_DEFINES='${C_INS_DEFINES}'                                  \
		CCFLAGS='${INS_CCFLAGS} ${C_INS_DEFINES}'                      \
                MAKECMD='insure' do_it ;             \
	fi

sun4u:
	@if test -n "${DO_DBG}" ; then                                       \
		${MAKE}                                                       \
		COMPILER='${CC}' LINKER='${CC}'                               \
		INCLUDE_PATHS='${INCLUDE_PATHS_SUN4U}'			   \
		C_DEFINES='${C_DBG_DEFINES}'                                  \
		CCFLAGS='${DBG_CCFLAGS} ${C_DBG_DEFINES}'                      \
                MAKECMD='debug' do_it ;              \
	elif test -n "${DO_OPT}" ; then                                       \
		${MAKE}                                                       \
		COMPILER='${CC}' LINKER='${CC}'                               \
		INCLUDE_PATHS='${INCLUDE_PATHS_SUN4U}'			   \
		C_DEFINES='${C_OPT_DEFINES}'                                  \
		CCFLAGS='${OPT_CCFLAGS} ${C_OPT_DEFINES}'                      \
                MAKECMD='optimize' do_it ;           \
	elif test -n "${DO_INS}" ; then                                       \
		${MAKE}                                                       \
		COMPILER='${INSURE}' LINKER='${INSURE}'                       \
		INCLUDE_PATHS='${INCLUDE_PATHS_SUN4U}'			   \
		C_DEFINES='${C_INS_DEFINES}'                                  \
		CCFLAGS='${INS_CCFLAGS} ${C_INS_DEFINES}'                      \
                MAKECMD='insure' do_it ;             \
	fi

args:
	-@if test "${MAKE}" != "clearmake" ; then                             \
		echo "Not using clearmake:   Removing objects and libraries.";\
		${RM_ALL} *.a *.o ;                                           \
	fi
	@if test `uname -m` = "sun4m"  ; then                                 \
		echo "******     SUN MicroSparc    ********" ;            \
		${MAKE} ARCH=SUN4M sun4m ;                                    \
	elif test `uname -m` = "sun4u"  ; then                             \
		echo "******     SUN Ultra    ********" ;                  \
		${MAKE} ARCH=SUN4U sun4u ;                                    \
	else                                                                  \
		echo Cannot determine correct compiler flags. ;               \
		exit 1 ;                                                      \
	fi
