########################################################################
#                 copyright 2001, Amoco Production Company             #
#                             All Rights Reserved                      #
#                     an affiliate of BP America Inc.                  #
########################################################################

ifeq "${TARCH}" "IRIX64"
TargetArch := -IRIX32
endif

include ${DEPTROOT}/usp/etc/gmake.init

ifeq "${Vendor}" "intel"
include ${DEPTROOT}/etc/gmake.motif2.0
else
include ${DEPTROOT}/etc/gmake.motif1.2
endif

ifeq "${TArchDir}" "sun4"
CC= acc
endif
ifeq "${TArchDir}" "HP-UX"
CC= c89
endif
# ifeq "${Vendor}" "intel"
# CC= gcc
# endif

sunCLFlags	:=	-Bdynamic

# sunCCFlags		:= ${sunCCFlags} -g -DDEBUG
sunCCFlags		:= ${sunCCFlags} -O
sunCLFLags		:= ${sunCLFLags} -Bstatic
convexCCFlags		:= ${convexCCFlags} -O -DNeedFunctionPrototypes
HP-UXCCFlags		:= ${HP-UXCCFlags} -D_INCLUDE_POSIX_SOURCE
#
# - have to turn off the optimization for the Absoft compiler because of
#   problems in routine values.c
#
ifeq "${Vendor}" "intel"
ifneq "${CC}" "pgcc"
intelCCFlags += -O0
endif
endif

LIB  := ${LocalLib}/libpanels.a

ifneq "${SOLARIS}"  ""
sunLibes   :=      -lSM -lICE ${sunLibes} -lgen -lsocket -B dynamic \
			-ldl -B static -lform -lnsl -lintl
endif

CommonLibes := -larg -lXmCreateVa -lXgoodies -lXm -lXt -lX11 -lm 

ifneq "${SOLARIS}" ""
sunLibes	:= 	${sunLibes} -lgen -lsocket -lnsl -L /usr/ccs/lib \
			-B dynamic \
			-ldl -B static -lform -lintl
endif

intelLibes := ${intelLibes} -lXext

Libes	:=	${CommonLibes} ${${Vendor}Libes} ${${TArchDir}Libes}

CSrcs := dialog.c message.c values.c

${TArchDir}CSrcs := ${TArchDir}/y.tab.c ${TArchDir}/lex.c

${TArchDir}CObjs = ${patsubst ${TArchDir}/%.c, ${TArchDir}/%.o, ${${TArchDir}CSrcs}}

SafeFiles := ${AllSrcs} Makefile \
		${wildcard *.y} ${wildcard *.l} ${wildcard *.h} \
		${wildcard *.xbm}

targets: ${LIB}

${LIB}: ${CObjs} ${${TArchDir}CObjs}
	ar rv ${LIB} ${CObjs} ${${TArchDir}CObjs}
	${RANLIB} ${LIB}

${TArchDir}/y.tab.o : ${TArchDir}/y.tab.c ${TArchDir}/y.tab.h
	$(CompileC) ${TArchDir}/y.tab.c 
	${MoveObjectToTArchDir}

${TArchDir}/y.tab.h : parse.y
	yacc -t -d parse.y
	"mv" y.tab.c ${TArchDir}/y.tab.c
	"mv" y.tab.h ${TArchDir}/y.tab.h

${TArchDir}/y.tab.c : parse.y
	yacc -t -d parse.y
	"mv" y.tab.c ${TArchDir}/y.tab.c
	"mv" y.tab.h ${TArchDir}/y.tab.h

${TArchDir}/lex.c : lex.l ${TArchDir}/y.tab.h
	lex -t $< > $@ 
## 	( lex -t $< > $@ ) || "rm" $@
## 	( flex -t $< > $@ ) || "rm" $@

${TArchDir}/lex.o :  ${TArchDir}/lex.c
	$(CompileC) -I${TArchDir} $<
	${MoveObjectToTArchDir}

all:	safe targets remotes install
remotes:	RemoteCopies RemoteMakes

RemoteCopies:	${SafeFiles}
	shadowcopy -v $? && touch RemoteCopies

RemoteMakes:	${SafeFiles}
	shadowexec -v ${MAKE} && touch RemoteMakes

safe:	.safe.${jdate}.Z

.safe.${jdate}.Z:	${SafeFiles}
	${MakeSafe}

include ${TArchDir}/included.files

${TArchDir}/included.files: ${AllSrcs}
	usp_d_stamp
	${FindIncludes}


clean:
	-rm ${TArchDir}/included.files ${AllObjs} \
		date.h RemoteCopies RemoteMakes ${wildcard ShdCpy*} \
		${TArchDir}/lex.o ${TArchDir}/y.tab.o
