include ../Make.inc
include ../Make.rules

ifneq ($(MAKECMDGOALS),clean)
ifneq (,$(USE_GLOBUS_GPT))
-include globus_makefile.mk
else
include globus_makefile.mk.pre
endif
endif

INSTALL_BASE=${NORDUGRID_LOCATION}
LIBS=-L${GLOBUS_LIBS} ${GLOBUS_RSL_LIBS} -lpthread
#LIBS=
CPPLIBS=-lstdc++
INCLUDES=-I${GLOBUS_INCLUDES}
PROGRAMS=print-rsl
OBJECTS=parse_rsl.o ../files/info_files.o \
        ../files/info_types.o ../jobs/users.o ../run/run.o \
        ../config/config.o ../config/environment.o \
        ../misc/canonical_dir.o ../transfer/replica_utils.o \
        ../misc/delete.o ../config/config_pre.o ../misc/stringtoint.o \
        ../config/gridmap.o ../misc/substitute.o ../misc/inttostring.o \
        subst_rsl.o ../misc/url_options.o ../misc/escaped.o ../misc/log_time.o
OTHER_OBJECTS=ng_parse_rsl.o print_rsl.o

all: ${PROGRAMS}

globus_makefile.mk:
	@export GLOBUS_LOCATION=$(GLOBUS_LOCATION) ; \
	${USE_GLOBUS_GPT} \
	-flavor=${GLOBUS_FLAVOR} globus_rsl globus_common | \
	grep '^GLOBUS_PKG_LIBS' | sed 's/^GLOBUS_PKG_LIBS/GLOBUS_RSL_LIBS/' \
	>globus_makefile.mk ; \
	RESULT=$$? ; \
	if [ $$RESULT -ne 0 ] ; then rm -f globus_makefile.mk ; fi ; \
	exit $$RESULT


print-rsl: ${OBJECTS} print_rsl.o 
	${CC} -o print-rsl print_rsl.o ${OBJECTS} ${LIBS} -Wl,-Bstatic ${CPPLIBS} -Wl,-Bdynamic

clean:
	@rm -f ${PROGRAMS} ${OBJECTS} ${OTHER_OBJECTS}

install: ${PROGRAMS} 
	@echo "Actual installation is performed in base directory"
