################################################################
# args
AMQP_QUEUE ?= vlkbdevel
# if amqp_host_name empty -> uses ExecCmd vlkb for cutout (not AMQP+vlkbd)

# Resolver DB: <none> localhost pasquale pasqule-devel
# DBMS ?= localhost
# if <none> uses ResolverById

# test prod
#FITSDB ?= test

CONTEXT_ROOT ?= vlkb/datasets

# <empty> ia2token garrtoken basic
AUTH ?=

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

all: authpolicy.properties cutout.properties context.xml web.xml

web.xml:
	cat web-xml/web.xml-begining web-xml/web.xml-$(AUTH)-filter web-xml/web.xml-authz-filter web-xml/web.xml-servlets web-xml/web.xml-ending > web.xml

authpolicy.properties: dbms.conf-$(DBMS)
	cp dbms.conf-$(DBMS) $@

# DB needed for ResolverByObsCore (VLKB-only)
cutout.properties: cutout.properties.in
	cat dbms.conf-$(DBMS) cutout.properties.in > cutout.properties
	sed -i 's/AMQP_QUEUE/$(AMQP_QUEUE)/' cutout.properties
	#sed -i 's/FITSDB/$(FITSDB)/' cutout.properties
	sed -i 's|CONTEXT_ROOT|$(CONTEXT_ROOT)|' cutout.properties

context.xml: context.xml.in
	cp context.xml.in context.xml
	#sed -i 's/FITSDB/$(FITSDB)/' context.xml


.PHONY:
clean:
	-rm authpolicy.properties context.xml web.xml cutout.properties

