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

CFLAGS		= -c ${DEBUGFLAG} ${C_OPT}  ${CFLAGS_ALL}

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

CFLAGS_RELAXED	= -c ${DEBUGFLAG} ${C_OPT_RELAXED}  ${CFLAGS_ALL}
CCFLAGS_RELAXED = -c ${DEBUGFLAG} ${CC_OPT_RELAXED} ${CFLAGS_ALL}

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

SCRIPTS =	emacsall \
		iris_grep \
		iris_src \
		mk_iris_dir \
		mkmf_msg \
		ps_iris \
		ps_wm \
		sig_lpstat \
		sig_uname_filter \
		sigmet_env \
		sigterm \
		structmap

EXES =		iris_servers \
		makeAsciiSetups \
		modtime \
		modtimediff \
		nfl_to_overlay \
		show_machine_code

MKDEPEND_CSRCS = \
		iris_servers.C \
		makeAsciiSetups.C \
		modtime.C \
		modtimediff.C \
		nfl_to_overlay.C \
		show_machine_code.C

all : ${SCRIPTS} ${EXES} compall

depend: makefile.d

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

iris_servers : iris_servers.o
		${CXX} ${LD_OPT} -o iris_servers iris_servers.o \
		${LDFLAGS} ${LNSL} -luser -lm
		rootchmod 775 iris_servers ; rootchown operator iris_servers

makeAsciiSetups : makeAsciiSetups.o
		${CXX} ${LD_OPT} -o makeAsciiSetups makeAsciiSetups.o \
		${LDFLAGS} -lconfig -luser
		rootchown operator makeAsciiSetups

modtime :	modtime.o
		${CXX} ${LD_OPT} -o modtime modtime.o \
		${LDFLAGS} 
		rootchmod 775 modtime ; rootchown operator modtime

modtimediff :	modtimediff.o
		${CXX} ${LD_OPT} -o modtimediff modtimediff.o \
		${LDFLAGS} 
		rootchown root modtimediff ; rootchmod 6775 modtimediff

nfl_to_overlay : nfl_to_overlay.o
		${CXX} ${LD_OPT} -o nfl_to_overlay nfl_to_overlay.o \
			${LDFLAGS} -luser -lm ${LSEARCH_BSD}
		rootchmod 775 nfl_to_overlay ; rootchown operator nfl_to_overlay

show_machine_code: show_machine_code.o
		${CXX} ${LD_OPT} show_machine_code.o ${LIBDIRS} \
			${LDFLAGS} -lprivate -lmisc -lconfig -luser -lm ${SEARCH_BSD} \
			-o show_machine_code
		rootchown operator show_machine_code ; rootchmod 6775 show_machine_code

sig_system : sig_system.o
		${CXX} ${LD_OPT} -o sig_system sig_system.o \
		${LDFLAGS} ${LNSL} -luser -lm
		rootchmod 775 iris_servers ; rootchown operator sig_system

install : all
		rootchmod 775      ${SCRIPTS} compall
		rootchown operator ${SCRIPTS} compall
		rootcp -p ${SCRIPTS} ${IRIS_BIN}

		# Don't overwrite the compall script if it looks like we're
		# running from it.  However, don't complain unnecessarilly
		# if the file has not changed anyway.
		#
		if [ -r compall_lock -a -r ${IRIS_BIN}/compall ] ; then \
		  diff compall ${IRIS_BIN}/compall > /dev/null 2> /dev/null ; \
		  if [ "$${?}" != 0 ] ; then \
		    echo "Can't overwrite 'compall' -- Please 'make install' instead" 1>&2 ; \
		  fi ; \
		else \
		  rootcp -p compall ${IRIS_BIN} ; \
		fi

		( case `uname -s` in \
		    HP-UX ) \
		      cp gnutar_hpux      ${IRIS_BIN}gnutar.uu  ; \
		      cp gnufind_hpux     ${IRIS_BIN}gnufind.uu ; \
		      ;; \
		    Linux ) \
		      cp gnutar_linux     ${IRIS_BIN}gnutar.uu  ; \
		      cp gnufind_linux    ${IRIS_BIN}gnufind.uu ; \
		      cp makedepend_linux ${IRIS_BIN}makedepend.uu ; \
		      ;; \
		    IRIX|IRIX64 ) \
		      cp gnutar_irix      ${IRIS_BIN}gnutar.uu  ; \
		      cp gnufind_irix     ${IRIS_BIN}gnufind.uu ; \
		      ;; \
		  esac ; \
		  cd ${IRIS_BIN} ; \
		  if [ -r gnutar.uu ] ; then \
		    rm -f gnutar gnutar.gz    ; uudecode gnutar.uu ; \
		    gunzip gnutar.gz          ; rm -f gnutar.uu ; \
		    rootchown operator gnutar ; rootchmod 775 gnutar ; \
		  fi ; \
		  if [ -r gnufind.uu ] ; then \
		    rm -f gnufind gnufind.gz   ; uudecode gnufind.uu ; \
		    gunzip gnufind.gz          ; rm -f gnufind.uu ; \
		    rootchown operator gnufind ; rootchmod 775 gnufind ; \
		  fi ; \
		  if [ -r makedepend.uu ] ; then \
		    rm -f makedepend makedepend.gz ; uudecode makedepend.uu ; \
		    gunzip makedepend.gz           ; rm -f makedepend.uu ; \
		    rootchown operator makedepend  ; rootchmod 775 makedepend ; \
		  fi ; \
		)

		rootcp -p ${EXES} ${IRIS_BIN}

		( cd ${IRIS_BIN} ; strip ${EXES} ; \
		  rootchown operator ${EXES} ; rootchmod 775 ${EXES} ; \
		  rootchmod 6775 show_machine_code ; \
		  rm -f IRIS ; ln ps_iris IRIS ; \
		)

cleanexe:;	rm -f ${EXES} core
clean:		cleanexe
		rm -f *.o *.usg *.cat* *.d *.d.bak

-include makefile.d
