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

ifneq ($(MAKECMDGOALS),clean)
-include version.mk
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_GMJOBS_LIBS} -lpthread
CPPLIBS=-lstdc++
INCLUDES=-I${GLOBUS_INCLUDES}
CC=gcc
CPP=g++
LD=ld
AR=ar r
PROGRAMS=gm-jobs
LIBRARIES=
CFLAGS=-g -O0 -ansi
OBJECTS=../files/info_files.o ../files/info_types.o \
        ../misc/canonical_dir.o ../misc/log_time.o ../misc/delete.o \
        ../misc/stringtoint.o ../misc/inttostring.o ../misc/substitute.o \
        ../misc/url_options.o ../misc/escaped.o ../misc/job_log.o \
        ../mail/send_mail.o \
        ../config/config.o ../config/config_file.o ../config/environment.o \
        ../config/gridmap.o \
        ../jobs/users.o ../jobs/states.o ../jobs/job.o \
        ../rsl/parse_rsl.o ../rsl/subst_rsl.o \
        ../transfer/replica_utils.o \
        ../run/run.o

all: ${PROGRAMS} ${LIBRARIES}

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_GMJOBS_LIBS/' \
	>globus_makefile.mk ; \
	RESULT=$$? ; \
	if [ $$RESULT -ne 0 ] ; then rm -f globus_makefile.mk ; fi ; \
	exit $$RESULT

gm-jobs: ${OBJECTS} gm_jobs.o
	${CC} -o gm-jobs gm_jobs.o ${OBJECTS} ${LIBS} -Wl,-Bstatic ${CPPLIBS} -Wl,-Bdynamic

clean:
	@rm -f ${PROGRAMS} ${LIBRARIES} ${OBJECTS} gm_jobs.o globus_makefile.mk

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