#########################################################################
#
#       MAKEFILE FOR STAND-ALONE XT CODE APPLICATION.  
#
#       EXECUTABLE      is the name of the executable to be created 
#       MAIN            is the .c file containing your main() function 
#       INTERFACES      is a list of the generated C code files
#       APP_OBJS        is a (possibly empty) list of the object code
#                       files that form the non-interface portion of
#                       your application
#
#       In the first three statements, the variables on the right 
#	of the equal sign will be replaced with their corresponding
#       values when the makefile is automatically generated.
#
#       This template is used for makefiles which do not reference 
#       the Ux runtime library.
#
#  	$Date: 2006-12-04 14:42:30 -0500 (Mon, 04 Dec 2006) $ 		$Revision: 18032 $
#########################################################################
CUR_REL_PATH := "utils/ascopex"

include ../../config.mk

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}

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

CPPMSG= -DMESSAGE_ONLY -I. -I${IRIS_ROOT}/utils/ascopex

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

LANGUAGE        = ANSI C
EXECUTABLE	= ascope
MAIN		= ascope.c

INTERFACES	= ascopeapplshell.c \
	gensetup.c \
	gaincontrol.c \
	plotparam.c \
	thresholds.c \
	noise.c \
	sampnoise.c \
	dspparamerrors.c \
	simulator.c \
	targetsim.c \
	spectra.c \
	recplay.c 

APPL_SRCS       = asrsimatod.c \
                  asrsimdata.c \
                  asrsimpram.c \
                  asrsimseries.c \
                  asoneplot.c \
                  asrealplot.c \
                  asdataplot.c \
                  asloop.c \
                  asplotalloc.c \
                  asspecacc.c \
                  asloadup.c \
                  asinitloadsave.c \
                  assimulate.c
APPL_OBJS = ${APPL_SRCS:.c=.o}

C_SRCS = $(MAIN) $(INTERFACES) $(APPL_SRCS)
C_OBJS = $(MAIN:.c=.o) $(INTERFACES:.c=.o) $(APPL_OBJS)

LLIBS  = -luxsig -lXpm -lXm -lXt -lX11 -ldsp -lantenna -lconfig -lmisc \
	-lhimath -luser -lfileformats ${LTIFF} ${LJPEG} \
	-lm ${LSEARCH_BSD} -lz

MKDEPEND_CSRCS = ${C_SRCS}

all: $(EXECUTABLE) ${MSG_CAT}

depend: makefile.d

makefile.d: ${MKDEPEND_CSRCS}
	touch makefile.d
	makedepend -fmakefile.d -- ${CFLAGS} -- ${MKDEPEND_CSRCS} 
	makedepend -fmakefile.d -a -o.usg -- ${CPPMSG} -- messages.msg

ascopeapplshell.o   : ascopeapplshell.c
	${CC} ${CFLAGS_RELAXED} ascopeapplshell.c
gensetup.o          : gensetup.c
	${CC} ${CFLAGS_RELAXED} gensetup.c
gaincontrol.o       : gaincontrol.c
	${CC} ${CFLAGS_RELAXED} gaincontrol.c
plotparam.o         : plotparam.c
	${CC} ${CFLAGS_RELAXED} plotparam.c
thresholds.o        : thresholds.c
	${CC} ${CFLAGS_RELAXED} thresholds.c
sampnoise.o         : sampnoise.c
	${CC} ${CFLAGS_RELAXED} sampnoise.c
noise.o         : noise.c
	${CC} ${CFLAGS_RELAXED} noise.c
dspparamerrors.o    : dspparamerrors.c
	${CC} ${CFLAGS_RELAXED} dspparamerrors.c
simulator.o         : simulator.c
	${CC} ${CFLAGS_RELAXED} simulator.c
targetsim.o         : targetsim.c
	${CC} ${CFLAGS_RELAXED} targetsim.c
spectra.o           : spectra.c
	${CC} ${CFLAGS_RELAXED} spectra.c
recplay.o           : recplay.c
	${CC} ${CFLAGS_RELAXED} recplay.c

$(EXECUTABLE): $(C_OBJS)
	$(CXX) $(LD_OPT) $^ $(LDFLAGS) $(LLIBS) -o $@

install: all ${IRIS_BIN} ${IRIS_APP_DEFAULTS} ${IRIS_NLS} ${EXECUTABLE}.rf
	install -m 0775 -o ${IRIS_USER} -g ${IRIS_GROUP} -s ${EXECUTABLE} ${IRIS_BIN}	
	install -m 0664 -o ${IRIS_USER} -g ${IRIS_GROUP} ${MSG_CAT} ${IRIS_NLS}
	install -m 0664 -o ${IRIS_USER} -g ${IRIS_GROUP} \
			${EXECUTABLE}.rf ${IRIS_APP_DEFAULTS}/${EXECUTABLE}
	install -m 0664 ${EXECUTABLE}.rf ${SYS_APP_DEFAULTS}/${EXECUTABLE}

uninstall:
	rm -f ${IRIS_APP_DEFAULTS}/${EXECUTABLE} ${SYS_APP_DEFAULTS}/${EXECUTABLE} ${IRIS_NLS}/${MSG_CAT}
	cd ${IRIS_BIN}; rm -f ${EXECUTABLE}

cleanexe:
	rm -f $(EXECUTABLE) core

cleanux:
	rm -f UxXt.c UxXt.h UxMethod.c

clean: cleanexe cleanux
	rm -f *.o *~ *.usg *.cat* *.d *.d.bak

install_src: ${INST_SRC_DIR}
	install -m 0664 -o ${IRIS_USER} -g ${IRIS_GROUP} Makefile *.[chi] *.msg *.rf ${INST_SRC_DIR}

uninstall_src:
	rm -rf ${INST_SRC_DIR}

-include makefile.d
