#
#ident "@(#)Makefile 1.15 01/12/20 SMI"
#
#	Copyright 12/20/01 Sun Microsystems, Inc. All Rights Reserved
#
#	Makefile for generation of  FTAM HL API programming example
#

SILENT=@

suf_LP64 = $(LP64:Y%=v9)
TMP_ARCH:sh =uname -p
LP64_CFLAGS=$(LP64:Y%=-xarch=v9)
LP64_LDFLAGS=$(LP64:Y%=-L/usr/lib/sparcv9)
LP64_LIB_SUFF=$(LP64:Y%=/sparcv9)

.KEEP_STATE:

.KEEP_STATE_FILE: .make.state$(LP64:Y%=-64bit)

TARGET_ARCH = $(TMP_ARCH:sparc%=-sparc$(suf_LP64))
BIN		= bin$(TARGET_ARCH)

PROGRAM = ${BIN}/ex_client
 
# FTAM example sources, library, includes home directory
FTAM_HOME = /opt/SUNWconn/ftam

# FTAM Library path
LIB_PATH = ${FTAM_HOME}/lib$(LP64_LIB_SUFF)

# FTAM User include path
INCL =	${FTAM_HOME}/include

SOURCES = ex_client.c

OBJECTS = \
	$(SOURCES:%.c=${BIN}/%.o)

#
# Compiler flags.
#

MYDEFS =
CFLAGS += -g -w $(LP64_CFLAGS)
CPPFLAGS += -I$(INCL) $(MYDEFS)
LDFLAGS += -L$(LIB_PATH) $(LP64_CFLAGS)
LDLIBS += -lnsl -lintl -lftam


#
# Standard targets.
#

all:	$(BIN) $(PROGRAM)

ex_client: $(BIN) $(PROGRAM)
clean:	
	rm -f $(OBJECTS) $(PROGRAM)

$(PROGRAM): $(OBJECTS)
	@echo -------------- $@ link begins --------------
	$(SILENT)$(CC) $(LDFLAGS) $(OBJECTS) $(LDLIBS) -o $@
	@echo -------------- $@ link end    --------------

$(OBJECTS): $$(@F:%.o=%.c)
	@echo -------------- $@ compilation begins -------
	$(SILENT)$(CC) $(CFLAGS) $(CPPFLAGS) -c $(@F:%.o=%.c) -o $@
	@echo -------------- $@ compilation end    -------

# Dependencies

ex_client.c: ${INCL}/ftiuser.h
	$(SILENT)touch $@

$(BIN):
	$(SILENT)test -d $@ || mkdir $@
