## automake - create Makefile.in from Makefile.am
## Copyright (C) 1998-2025 Free Software Foundation, Inc.

## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2, or (at your option)
## any later version.

## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.

## You should have received a copy of the GNU General Public License
## along with this program.  If not, see <https://www.gnu.org/licenses/>.

include inst-vars.am
man%SECTION%dir = $(mandir)/man%SECTION%

## ------------ ##
## Installing.  ##
## ------------ ##

## MANS primary are always installed in mandir, hence install-data
## is hard coded.

.PHONY: install-man
?INSTALL-MAN?install-data-am: install-man
?INSTALL-MAN?am__installdirs += "$(DESTDIR)$(man%SECTION%dir)"
.PHONY install-man: install-man%SECTION%
install-man%SECTION%: %DEPS%
	@$(NORMAL_INSTALL)
if %?NOTRANS_MANS%
## Handle MANS with notrans_ prefix
	@list1='%NOTRANS_SECT_LIST%'; \
?!HAVE_NOTRANS?	list2=''; \
?HAVE_NOTRANS?	list2='%NOTRANS_LIST%'; \
	test -n "$(man%SECTION%dir)" \
	  && test -n "`echo $$list1$$list2`" \
	  || exit 0; \
	echo " $(MKDIR_P) '$(DESTDIR)$(man%SECTION%dir)'"; \
	$(MKDIR_P) "$(DESTDIR)$(man%SECTION%dir)" || exit 1; \
	{ for i in $$list1; do echo "$$i"; done;  \
## Extract all items from notrans_man_MANS that should go in this section.
## This must be done dynamically to support conditionals.
	if test -n "$$list2"; then \
	  for i in $$list2; do echo "$$i"; done \
## Accept for 'man1' files like 'foo.1c' but not 'sub.1/foo.2' or 'foo-2.1.4'.
	    | sed -n '/\.%SECTION%[a-z]*$$/p'; \
	fi; \
## Extract basename of manpage, change the extension if needed.
	} | while read p; do \
## Find the file.
	  if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
	  echo "$$d$$p"; echo "$$p"; \
	done | \
## Extract the basename of the man page and change the extension if needed.
	sed 'n;s,.*/,,;p;s,\.[^%SECTION%][0-9a-z]*$$,.%SECTION%,' | \
	sed 'N;N;s,\n, ,g' | { \
## We now have a list "sourcefile basename installed-name".
	list=; while read file base inst; do \
	  if test "$$base" = "$$inst"; then list="$$list $$file"; else \
	    echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man%SECTION%dir)/$$inst'"; \
	    $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man%SECTION%dir)/$$inst" || exit $$?; \
	  fi; \
	done; \
	for i in $$list; do echo "$$i"; done | $(am__base_list) | \
	while read files; do \
	  test -z "$$files" || { \
	    echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man%SECTION%dir)'"; \
	    $(INSTALL_DATA) $$files "$(DESTDIR)$(man%SECTION%dir)" || exit $$?; }; \
	done; }
endif %?NOTRANS_MANS%
if %?TRANS_MANS%
## Handle MANS without notrans_ prefix
	@list1='%TRANS_SECT_LIST%'; \
?!HAVE_TRANS?	list2=''; \
?HAVE_TRANS?	list2='%TRANS_LIST%'; \
	test -n "$(man%SECTION%dir)" \
	  && test -n "`echo $$list1$$list2`" \
	  || exit 0; \
	echo " $(MKDIR_P) '$(DESTDIR)$(man%SECTION%dir)'"; \
	$(MKDIR_P) "$(DESTDIR)$(man%SECTION%dir)" || exit 1; \
	{ for i in $$list1; do echo "$$i"; done;  \
## Extract all items from notrans_man_MANS that should go in this section.
## This must be done dynamically to support conditionals.
	if test -n "$$list2"; then \
	  for i in $$list2; do echo "$$i"; done \
## Accept for 'man1' files like `foo.1c' but not 'sub.1/foo.2' or 'foo-2.1.4'.
	    | sed -n '/\.%SECTION%[a-z]*$$/p'; \
	fi; \
## Extract basename of manpage, change the extension if needed.
	} | while read p; do \
## Find the file.
	  if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
	  echo "$$d$$p"; echo "$$p"; \
	done | \
## Extract the basename of the man page and change the extension if needed.
	sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^%SECTION%][0-9a-z]*$$,%SECTION%,;x' \
	      -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \
	sed 'N;N;s,\n, ,g' | { \
## We now have a list "sourcefile basename installed-name".
	list=; while read file base inst; do \
	  if test "$$base" = "$$inst"; then list="$$list $$file"; else \
	    echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man%SECTION%dir)/$$inst'"; \
	    $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man%SECTION%dir)/$$inst" || exit $$?; \
	  fi; \
	done; \
	for i in $$list; do echo "$$i"; done | $(am__base_list) | \
	while read files; do \
	  test -z "$$files" || { \
	    echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man%SECTION%dir)'"; \
	    $(INSTALL_DATA) $$files "$(DESTDIR)$(man%SECTION%dir)" || exit $$?; }; \
	done; }
endif %?TRANS_MANS%


## -------------- ##
## Uninstalling.  ##
## -------------- ##

.PHONY: uninstall-man
?INSTALL-MAN?uninstall-am: uninstall-man
.PHONY uninstall-man: uninstall-man%SECTION%
uninstall-man%SECTION%:
	@$(NORMAL_UNINSTALL)
if %?NOTRANS_MANS%
## Handle MANS with notrans_ prefix
	@list='%NOTRANS_SECT_LIST%'; test -n "$(man%SECTION%dir)" || exit 0; \
	files=`{ for i in $$list; do echo "$$i"; done; \
## Extract all items from notrans_man_MANS that should go in this section.
## This must be done dynamically to support conditionals.
?HAVE_NOTRANS?	l2='%NOTRANS_LIST%'; for i in $$l2; do echo "$$i"; done | \
## Accept for 'man1' files like 'foo.1c' but not 'sub.1/foo.2' or 'foo-2.1.4'.
?HAVE_NOTRANS?	  sed -n '/\.%SECTION%[a-z]*$$/p'; \
## Extract basename of manpage, change the extension if needed.
	} | sed 's,.*/,,;s,\.[^%SECTION%][0-9a-z]*$$,.%SECTION%,'`; \
	dir='$(DESTDIR)$(man%SECTION%dir)'; $(am__uninstall_files_from_dir)
endif %?NOTRANS_MANS%
if %?TRANS_MANS%
## Handle MANS without notrans_ prefix
	@list='%TRANS_SECT_LIST%'; test -n "$(man%SECTION%dir)" || exit 0; \
	files=`{ for i in $$list; do echo "$$i"; done; \
## Extract all items from man_MANS that should go in this section.
## This must be done dynamically to support conditionals.
?HAVE_TRANS?	l2='%TRANS_LIST%'; for i in $$l2; do echo "$$i"; done | \
## Accept for 'man1' files like 'foo.1c' but not 'sub.1/foo.2' or 'foo-2.1.4'.
?HAVE_TRANS?	  sed -n '/\.%SECTION%[a-z]*$$/p'; \
## Extract basename of manpage, run it through the program rename
## transform, and change the extension if needed.
	} | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^%SECTION%][0-9a-z]*$$,%SECTION%,;x' \
	      -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
	dir='$(DESTDIR)$(man%SECTION%dir)'; $(am__uninstall_files_from_dir)
endif %?TRANS_MANS%
