###################### VARIABLES ##########################
# Compiler
CC=g++

EXTERNAL=${GLITE_LOCATION}/externals/
ARES=${EXTERNAL}/ares-1.1.1/

CFLAGS=-I$(GLITE_LOCATION)/include \
	-I$(EXTERNAL)/include \
	-I$(EXTERNAL)/include/boost \
	-I$(ARES)/include 

GLOBUS_FLAVOR_THREADS=gcc32pthr

# Linker
LD=gcc
GLOBUS_FLAVOR_THREADS=gcc32pthr
LFLAGS=-L$(GLOBUS_LOCATION)/lib \
		-lglite_lb_clientpp_gcc32 \
		-lglobus_gsi_proxy_core_$(GLOBUS_FLAVOR_THREADS) \
		-lglobus_gsi_credential_$(GLOBUS_FLAVOR_THREADS) \
		-lglobus_gsi_callback_$(GLOBUS_FLAVOR_THREADS) \
		-lglobus_oldgaa_$(GLOBUS_FLAVOR_THREADS) \
		-lglobus_gsi_sysconfig_$(GLOBUS_FLAVOR_THREADS) \
		-lglobus_gsi_cert_utils_$(GLOBUS_FLAVOR_THREADS) \
		-lglobus_openssl_$(GLOBUS_FLAVOR_THREADS) \
		-lglobus_proxy_ssl_$(GLOBUS_FLAVOR_THREADS) \
		-lglobus_openssl_error_$(GLOBUS_FLAVOR_THREADS) \
		-lglobus_ftp_client_$(GLOBUS_FLAVOR_THREADS) \
		-lssl_$(GLOBUS_FLAVOR_THREADS) \
		-lcrypto_$(GLOBUS_FLAVOR_THREADS) \
		-lglobus_gss_assist_$(GLOBUS_FLAVOR_THREADS) \
		-lglobus_gssapi_gsi_$(GLOBUS_FLAVOR_THREADS) \
		-lglobus_common_$(GLOBUS_FLAVOR_THREADS) \
		-L$(GLITE_LOCATION)/lib \
		-lglite_lb_common_gcc32 \
		-lglite_lb_client_gcc32 \
		-lglite_wms_checkpointing \
		-lglite_wms_util \
		-lglite_wms_jdl \
		-lglite_wms_logger \
		-lglite_wmsui_client \
		-lglite_wmsui_native \
		-lglite_wms_util \
		-lglite_wmsutils_jobid \
		-lglite_wmsutils_cjobid \
		-lglite_wmsutils_exception \
		-lglite_dgas_jobAuthClient \
		-lglite_dgas_xmlutil \
		-lglite_wmsui_partitioner \
		-lglite_wmsutils_tls_socket_pp \
		-lglite_wmsutils_tls_gsisocket_pp \
		-lglite_wms_globus_ftp_util \
		-L$(EXTERNAL)/lib \
		-lvomsapi \
		-lboost_fs \
		-lboost_thread \
		-lboost_signals \
		-lboost_regex \
		-lclassad \
		-L${ARES}/lib \
		-lares 

# Default program to compile (use "make PROGRAM=your_name" to override)
PROGRAM=jobsubmit
SOURCES=$(PROGRAM).cpp
OBJECTS=$(PROGRAM).o


####################### TARGETS ###########################
# Default
all: LINK $(SOURCES)

# Linking...
LINK: $(OBJECTS) $(SOURCES)
	$(LD) $(CFLAGS) -o $(PROGRAM) $(LFLAGS) $<

# Compiling...
%.o: %.cpp
	$(CC) -c $(CFLAGS) $<

clean:
	rm $(PROGRAM) $(OBJECTS)
