include $(top_srcdir)/config/subdir.am

SUBDIRS = database


cfgfiles_IN = \
    authproxy-config.in \
    authrules.xml.in \
    callresolver-config.in \
    proxy-config.in \
    forwardingrules.xml.in

EXTRA_DIST = \
    sipproxy.process.xml.in \
    sipauthproxy.process.xml.in \
    $(cfgfiles_IN)

CFG_FILES = $(foreach file,$(cfgfiles_IN),$(DESTDIR)/$(sysconfdir)/sipxpbx/$(file))
install-exec-hook : \
	$(DESTDIR)$(SIPX_PROCDIR)/sipproxy.process.xml \
	$(DESTDIR)$(SIPX_PROCDIR)/sipauthproxy.process.xml \
	$(CFG_FILES) \
        upgrade-auth-rules

$(foreach file,$(cfgfiles_IN),$(DESTDIR)/$(sysconfdir)/sipxpbx/$(file)) : $(DESTDIR)/$(sysconfdir)/sipxpbx/% : %
	if ! test -f $@; \
	then \
		echo "Installing default $@"; \
		$(INSTALL) -D -m 644 $< $@; \
	else \
		diff $< $@ > /dev/null 2>&1 \
		|| (  echo "Using existing $@ - new file is $@.NEW" \
		    ; $(INSTALL) -D -m 644 $< $@.NEW; \
			); \
	fi

.PHONY: upgrade-auth-rules
upgrade-auth-rules:
	echo "        Checking/updating schema for $(sysconfdir)/sipxpbx/authrules.xml.in"
	perl -pi \
	-e 's|<mappings>|<mappings xmlns="http://www.sipfoundry.org/sipX/schema/xml/urlauth-00-00">|' \
	$(DESTDIR)$(sysconfdir)/sipxpbx/authrules.xml.in



syntax highlighted by Code2HTML, v. 0.9.1