########################################################################
#
########################################################################

CFLAGS_ALL	= -D${MACH_OS} -DMOTIF -DSYSV -DXT_CODE -DXOPEN_CATALOG \
                  -I./  -I../../include -I${IRIS_ROOT}/include

CFLAGS		= -c ${DEBUGFLAG} ${C_OPT}  ${CFLAGS_ALL}
CXXFLAGS        = -c ${DEBUGFLAG} ${CC_OPT} ${CFLAGS_ALL}
CCFLAGS = ${CXXFLAGS}

LDFLAGS         = -L./ \
		  -L../../libs/lib -L${IRIS_ROOT}/libs/lib ${LPATH_X11}

RTDISP		= rtdisp
RTD_INSERT	= rtd_insert

all : all_	# Just to insure that it's first

RTDISP_CC_SRCS =	rtdisp.C \
			color.C \
			colorDiag.C \
			overlay.C \
			overlayDiag.C \
			rng.C \
			rngDiag.C \
			rhiOpt.C \
			rhiOptDiag.C \
			rtdAS.C \
			rtdApplShell.C \
			siteStat.C \
			siteStatDiag.C \
			rtdFunc.C \
			sharedMem.C
RTDISP_CC_OBJS		= $(RTDISP_CC_SRCS:.C=.o)

RTD_INSERT_CC_SRCS =	rtdInsert.C \
			sharedMem.C
RTD_INSERT_CC_OBJS	= $(RTD_INSERT_CC_SRCS:.C=.o)


LLIBS		= -luxsig -ltvsubs -lXpm -lbxutils -lXm -lXt -lX11 \
	          -lconfig -lmaps -lmisc -lvtv -lfileformats ${LTIFF} ${LJPEG} \
		  -lhimath -luser -lXmu -lm

all_ :          $(RTDISP) $(RTD_INSERT)

MKDEPEND_CSRCS = ${RTDISP_CC_SRCS} ${RTD_INSERT_CC_SRCS}
depend: makefile.d

makefile.d:
	touch makefile.d
	makedepend -fmakefile.d -- ${CFLAGS} -- ${MKDEPEND_CSRCS}

$(RTDISP): $(RTDISP_CC_OBJS)
	$(CXX) $(LD_OPT) $(RTDISP_CC_OBJS) $(LDFLAGS) $(LLIBS) -o $(RTDISP)
	@strip ${RTDISP}
	@rootchown operator $(RTDISP)
	@rootchmod 775 $(RTDISP)
	@rootchown operator *.rf
	@rootchmod 664 *.rf

$(RTD_INSERT):	$(RTD_INSERT_CC_OBJS)
	$(CXX) $(LD_OPT) $(RTD_INSERT_CC_OBJS) $(LDFLAGS) $(LLIBS) -o $(RTD_INSERT)
	strip ${RTD_INSERT}
	@rootchown operator $(RTD_INSERT)
	@rootchmod 775 $(RTD_INSERT)

install:	$(RTDISP) $(RTD_INSERT)
		rootcp -p $(RTDISP) ${IRIS_BIN}
		rootcp -p $(RTD_INSERT) ${IRIS_BIN}
		rootcp -p rtdisp.rf $(IRIS_APP_DEFAULTS)$(RTDISP)
		rootcp -p rtdisp.rf /usr/lib/X11/app-defaults/$(RTDISP)
		( cd ${IRIS_BIN} ; \
		 rootchown operator ${RTDISP} ; rootchmod 775 ${RTDISP} ; \
		 rootchown operator ${RTD_INSERT} ; rootchmod 775 ${RTD_INSERT} )
		( cd ${IRIS_APP_DEFAULTS} ; \
		 rootchown operator ${RTDISP} ; rootchmod 664 ${RTDISP} )
		( cd /usr/lib/X11/app-defaults ; \
		 rootchown operator ${RTDISP} ; rootchmod 664 ${RTDISP} )


cleanexe:;	rm -f $(RTDISP) $(RTD_INSERT) core
clean:		cleanexe 
		rm -f *.o *.d *.d.bak


-include makefile.d
