#
# doc/user
#

user_RSTFILES = \
	doc/user/affinitymap.rst \
	doc/user/babeld.rst \
	doc/user/ldpd.rst \
	doc/user/basic.rst \
	doc/user/bgp.rst \
	doc/user/bmp.rst \
	doc/user/bugs.rst \
	doc/user/conf.py \
	doc/user/eigrpd.rst \
	doc/user/evpn.rst \
	doc/user/extlog.rst \
	doc/user/fabricd.rst \
	doc/user/filter.rst \
	doc/user/frr-reload.rst \
	doc/user/glossary.rst \
	doc/user/grpc.rst \
	doc/user/index.rst \
	doc/user/installation.rst \
	doc/user/ipv6.rst \
	doc/user/isisd.rst \
	doc/user/kernel.rst \
	doc/user/nexthop_groups.rst \
	doc/user/nhrpd.rst \
	doc/user/ospf6d.rst \
	doc/user/ospfd.rst \
	doc/user/ospf_fundamentals.rst \
	doc/user/about.rst \
	doc/user/packet-dumps.rst \
	doc/user/pathd.rst \
	doc/user/pim.rst \
	doc/user/pimv6.rst \
	doc/user/ripd.rst \
	doc/user/pbr.rst \
	doc/user/ripngd.rst \
	doc/user/routemap.rst \
	doc/user/routeserver.rst \
	doc/user/rpki.rst \
	doc/user/scripting.rst \
	doc/user/setup.rst \
	doc/user/sharp.rst \
	doc/user/snmp.rst \
	doc/user/snmptrap.rst \
	doc/user/static.rst \
	doc/user/vnc.rst \
	doc/user/vrrp.rst \
	doc/user/vtysh.rst \
	doc/user/zebra.rst \
	doc/user/bfd.rst \
	doc/user/flowspec.rst \
	doc/user/watchfrr.rst \
	doc/user/wecmp_linkbw.rst \
	doc/user/mgmtd.rst \
	doc/user/sbfd.rst \
	# end

EXTRA_DIST += \
	$(user_RSTFILES) \
	doc/user/Useful_Sysctl_Settings.md \
	doc/user/_static/overrides.css \
	doc/user/_static/overrides.js \
	# end

USERBUILD = doc/user/_build
$(USERBUILD)/.doctrees/environment.pickle: $(user_RSTFILES)

#
# automake integration (things that should be built in "all")
#

if DOC
nodist_noinst_DATA += $(USERBUILD)/texinfo/frr.info
endif
if DOC_HTML
nodist_noinst_DATA += $(USERBUILD)/html/.buildinfo
endif

#
# standard targets
#

.PHONY: info html pdf
info: $(USERBUILD)/texinfo/frr.info
html: $(USERBUILD)/html/.buildinfo
pdf:  $(USERBUILD)/latexpdf

#
# hook-ins for clean / install / doc
#

.PHONY: clean-userdocs
clean-local: clean-userdocs
clean-userdocs:
	-rm -rf "$(USERBUILD)"

# INSTALL_INFO=install-info
.PHONY: install-info uninstall-info install-html uninstall-html

install-info: $(USERBUILD)/texinfo/frr.info
	$(MKDIR_P) "$(DESTDIR)$(infodir)"
	$(INSTALL_DATA) "$<" "$(DESTDIR)$(infodir)"
	[ -z "${DESTDIR}" ] && $(INSTALL_INFO) --info-dir="$(DESTDIR)$(infodir)" "$<" || true
uninstall-info: $(USERBUILD)/texinfo/frr.info
	-rm -f "$(DESTDIR)$(infodir)/$<"
	[ -z "${DESTDIR}" ] && $(INSTALL_INFO) --delete --info-dir="$(DESTDIR)$(infodir)" "$<" || true

install-html: $(USERBUILD)/html/.buildinfo
	$(MKDIR_P) "$(DESTDIR)$(htmldir)"
	cp -r "$(USERBUILD)/html" "$(DESTDIR)$(htmldir)"
uninstall-html:
	-rm -rf "$(DESTDIR)$(htmldir)/html"

.PHONY: install-data-local uninstall-local
if DOC
DOC_INFO=info
TARGET_INSTALL_INFO=install-info
TARGET_UNINSTALL_INFO=uninstall-info
endif
if DOC_HTML
DOC_HTML=html
TARGET_INSTALL_HTML=install-html
TARGET_UNINSTALL_HTML=uninstall-html
endif

# leave the comments in, this was causing weird reordering issues in automake
install-data-local: $(TARGET_INSTALL_INFO) $(TARGET_INSTALL_HTML)
#
uninstall-local: $(TARGET_UNINSTALL_INFO) $(TARGET_UNINSTALL_HTML)
#
doc: $(DOC_INFO) $(DOC_HTML)
