#
#	HARNESS G_HCORE
#	HARNESS FT_MPI
#	HARNESS STARTUP_D
#
#	Innovative Computer Laboratory,
#	University of Tennessee,
#	Knoxville, TN, USA.
#
#	harness@cs.utk.edu
#
# --------------------------------------------------------------------------
#
# Authors:	
#			Thara Angskun <angskun@cs.utk.edu> 
#
# --------------------------------------------------------------------------
#
#                              NOTICE
#
# Permission to use, copy, modify, and distribute this software and
# its documentation for any purpose and without fee is hereby granted
# provided that the above copyright notice appear in all copies and
# that both the copyright notice and this permission notice appear in
# supporting documentation.
#
# Neither the University of Tennessee nor the Authors make any
# representations about the suitability of this software for any
# purpose.  This software is provided ``as is'' without express or
# implied warranty.
#
# HARNESS, HARNESS G_HCORE and  FT_MPI was funded in part by the 
# U.S. Department of Energy.
#
#

# First to include the conf info depending on the compilers we need etc
# i.e. all options starting with IC_

include $(HARNESS_ROOT)/conf/system/makeopts-SNIPE_LITE

# For any arch type options
# i.e. anything else like, IMA_ARCH, system call flags etc

include $(HARNESS_ROOT)/conf/system/makeopts-$(HARNESS_ARCH)


# Include compliation directories
include $(HARNESS_ROOT)/conf/system/makeopts-dirs

INCLUDES = $(STDINC) -I$(hsdir) -I$(pftmpidir) -I$(ftmpidir) $(OPENSSL_CFLAGS)       
LIBS = $(libdir)/hlib.a $(SL_LIBS) $(OPENSSL_LDFLAGS) $(RL_LDFLAGS) 
LDFLAGS =
DEFINE = $(SL_FLAGS) $(RL_CFLAGS)

EXECUTABLES = $(bindir)/console

EXTERNAL_OBJ = $(svcobjdir)/ns_lib.o \
	$(shareobjdir)/snipe_lite.o \
	$(shareobjdir)/snipe_lite_s.o \
	$(shareobjdir)/msgbuf.o \
	$(shareobjdir)/msg.o \
	$(shareobjdir)/msg_s.o \
	$(pftmpidir)/$(objdir)/libstartup.o \
	$(pftmpidir)/$(objdir)/libsecure.o \
	$(pftmpidir)/$(objdir)/libsio.o \
	$(pftmpidir)/$(objdir)/libcio.o \
	$(pftmpidir)/$(objdir)/libnotifier.o \
	$(HARNESS_ROOT)/src/$(HARNESS_ARCH)/envs.o

OBJECTS = $(objdir)/console.o \
	$(objdir)/utils.o \
	$(objdir)/proc.o \
	$(objdir)/parsing.o \
	$(objdir)/ensemble.o \
	$(objdir)/services.o \
	$(EXTERNAL_OBJ)

HEADERS = param.h \
	utils.h \
	proc.h \
	parsing.h

all : $(objdir) $(bindir) $(OBJECTS) $(EXECUTABLES)


###########################################################################

$(objdir) :
	mkdir $(objdir)

$(bindir) :
	mkdir $(bindir)

###########################################################################

#.SUFFIXES: .c .o

$(objdir)/console.o : console.c $(HEADERS) 
	$(CC) $(CFLAGS) $(INCLUDES) -c console.c -o $(objdir)/console.o   $(DEFINE) 

$(objdir)/utils.o : utils.c $(HEADERS) 
	$(CC) $(CFLAGS) $(INCLUDES) -c utils.c -o $(objdir)/utils.o $(DEFINE)

$(objdir)/proc.o : proc.c $(HEADERS) 
	$(CC) $(CFLAGS) $(INCLUDES) -c proc.c -o $(objdir)/proc.o $(DEFINE)

$(objdir)/parsing.o : parsing.c $(HEADERS) 
	$(CC) $(CFLAGS) $(INCLUDES) -c parsing.c -o $(objdir)/parsing.o $(DEFINE)

$(objdir)/ensemble.o : ensemble.c $(HEADERS) 
	$(CC) $(CFLAGS) $(INCLUDES) -c ensemble.c -o $(objdir)/ensemble.o $(DEFINE)

$(objdir)/services.o : services.c $(HEADERS) 
	$(CC) $(CFLAGS) $(INCLUDES) -c services.c -o $(objdir)/services.o $(DEFINE)

###########################################################################

$(bindir)/console : $(OBJECTS) $(HEADERS)
	$(CC) $(CFLAGS) -o $(bindir)/console $(OBJECTS) $(INCLUDES) $(CGENLIB) $(LIBS) $(LDFLAGS)

clean :
	rm -f $(EXECUTABLES) $(objdir)/*.o

cleaner :
	rm -f $(EXECUTABLES) */*.o */console
