#########################################################################
#
#       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-10-31 16:27:28 -0500 (Tue, 31 Oct 2006) $ 		$Revision: 17922 $
#########################################################################

CUR_REL_PATH = libs/uxsig

include ../../config.mk

LIB = libuxsig.a

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}

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

ERRDIAG		= errdiag
SIGXBELL        = sigxbell
LANGUAGE        = ANSI C
EXECUTABLE	= uxutils
MAIN		= uxutils.c

INTERFACES	= uxutilsshell.c \
	uxprinter_setup.c \
	uxmsgbox.c \
	uxfileselbox.c \
	uxselbox.c \
	uxpromptbox.c \
	uxAddRemoveDiag.c \
	uxDualSysSelDiag.c


# Announce all rule to make sure it is the first
all:

uxutilsshell.o    : uxutilsshell.c
	${CC} ${CFLAGS_RELAXED} uxutilsshell.c
uxprinter_setup.o : uxprinter_setup.c
	${CC} ${CFLAGS_RELAXED} uxprinter_setup.c
uxmsgbox.o        : uxmsgbox.c
	${CC} ${CFLAGS_RELAXED} uxmsgbox.c
uxfileselbox.o    : uxfileselbox.c
	${CC} ${CFLAGS_RELAXED} uxfileselbox.c
uxselbox.o        : uxselbox.c
	${CC} ${CFLAGS_RELAXED} uxselbox.c
uxpromptbox.o     : uxpromptbox.c
	${CC} ${CFLAGS_RELAXED} uxpromptbox.c
uxAddRemoveDiag.o : uxAddRemoveDiag.c
	${CC} ${CFLAGS_RELAXED} uxAddRemoveDiag.c
uxDualSysSelDiag.o : uxDualSysSelDiag.c
	${CC} ${CFLAGS_RELAXED} uxDualSysSelDiag.c

APPL_SRCS       = printer_setup.c \
		  xfunc.c \
		  uxcommon_cbf.c\
                  output_file_format.c\
		  UxXt.c \
                  UxMethod.c
APPL_OBJS = ${APPL_SRCS:.c=.o}

UxMethod.o        : UxMethod.c
	${CC} ${CFLAGS_RELAXED} UxMethod.c

APPL_CXX_SRCS    = UxInterf.C
APPL_CXX_OBJS = ${APPL_CXX_SRCS:.C=.o}

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

C_ERRDIAG_SRCS	= errdiag.c
C_ERRDIAG_OBJS	= ${C_ERRDIAG_SRCS:.c=.o}

C_SIGXBELL_SRCS = sigxbell.c
C_SIGXBELL_OBJS = ${C_SIGXBELL_SRCS:.c=.o}

LLIBS            = -lXpm -lXm -lXt -lX11 -luser \
                    -lfileformats ${LTIFF} ${LJPEG} -lm ${LSEARCH_BSD}

MKDEPEND_CSRCS = ${C_SRCS} ${APPL_CXX_SRCS} ${C_ERRDIAG_SRCS} ${C_SIGXBELL_SRCS}


all: ${LIB_DIR} $(EXECUTABLE) $(LIB_DIR)/$(LIB) $(ERRDIAG) $(SIGXBELL)

depend: makefile.d

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

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

$(ERRDIAG): $(C_ERRDIAG_OBJS)
	$(CXX) $(LD_OPT) $(LDFLAGS) $(LLIBS) $^ -o $@

$(SIGXBELL): $(C_SIGXBELL_OBJS)
	$(CXX) $(LD_OPT) $(LDFLAGS) $(LLIBS) $^ -o $@

cleanexe:
	rm -f $(EXECUTABLE) $(ERRDIAG) $(SIGXBELL) core

cleanux:
	rm -f UxXt.h

clean:		cleanexe cleanux
		rm -f *.o *~ *.a *.d *.d.bak ${LIB_DIR}/${LIB}

install: all ${IRIS_BIN} ${IRIS_APP_DEFAULTS} ${IRIS_LIB}
	install -m 0664 -o ${IRIS_USER} -g ${IRIS_GROUP} ${LIB} ${IRIS_LIB}
	install -m 0664 -o ${IRIS_USER} -g ${IRIS_GROUP} \
	${EXECUTABLE}.rf ${IRIS_APP_DEFAULTS}/${EXECUTABLE}
	install -m 0775 -o ${IRIS_USER} -g ${IRIS_GROUP} -s ${EXECUTABLE} ${ERRDIAG} ${SIGXBELL} ${IRIS_BIN}
	install -m 0664 ${EXECUTABLE}.rf ${SYS_APP_DEFAULTS}/${EXECUTABLE}

uninstall:
	cd ${IRIS_BIN}; rm -f ${EXECUTABLE} ${ERRDIAG} ${SIGXBELL}
	cd ${SYS_APP_DEFAULTS}; rm -f ${EXECUTABLE}
	cd ${IRIS_APP_DEFAULTS}; rm -f ${EXECUTABLE}
	cd ${IRIS_LIB}; rm -f ${LIB}

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

uninstall_src:
	rm -rf ${INST_SRC_DIR}

${LIB}: $(INTERFACES:.c=.o) $(APPL_OBJS) $(APPL_CXX_OBJS)
	rm -f $@; $(AR) -rsc $@ $^

-include makefile.d
