1# doc/Makefile.am 2# 3# Copyright (C) 2015-2018 Carsten Schoenert <c.schoenert@t-online.de> 4# 2018 Jon Shallow <supjps-libcoap@jpshallow.com> 5# 6# SPDX-License-Identifier: BSD-2-Clause 7# 8# This file is part of the CoAP C library libcoap. Please see README and 9# COPYING for terms of use. 10 11 12# We can only perfom the targets in this directory if doxygen is present. 13 14CLEANFILES = \ 15 doxygen_sqlite3.db 16 17EXTRA_DIST = \ 18 docbook.local.css \ 19 upgrade_4.2.1_4.3.0.txt \ 20 main.md 21 22if HAVE_DOXYGEN 23 24man-page-cleanup: 25 @rm -f $(top_builddir)/doc/DoxygenLayout.xml 26 @rm -rf $(top_builddir)/doc/man_tmp 27 @rm -rf $(top_builddir)/doc/man_html 28 29man-page-prepare: man-page-cleanup 30 @$(MKDIR_P) $(top_builddir)/doc/man_tmp 31 @$(MKDIR_P) $(top_builddir)/doc/man_html 32 33man-page-start: man-page-prepare 34 ## Setup the man page tab 35 @echo ' <tab type="usergroup" visible="yes" url="@ref manpage" title="Manual Pages">' > $(top_builddir)/doc/insert_file 36 @echo '/** @page manpage Manual Pages' > $(top_builddir)/doc/man_tmp/manpage.dox 37 @echo ' Here is a list of libcoap API manual pages, some of which have code examples:' >> $(top_builddir)/doc/man_tmp/manpage.dox 38 @echo ' <table class="directory">' >> $(top_builddir)/doc/man_tmp/manpage.dox 39 ## Setup the upgrading tab 40 @echo '/** @page upgrading Upgrading' > $(top_builddir)/doc/man_tmp/upgrading.dox 41 @echo ' Upgrading between libcoap versions:' >> $(top_builddir)/doc/man_tmp/upgrading.dox 42 @echo ' <table class="directory">' >> $(top_builddir)/doc/man_tmp/upgrading.dox 43 44man-page-build: upg-page-build man-page-start 45 @MAN_FILES=`find $(top_srcdir)/man/ -type f -name "coap.txt.in" ; find $(top_srcdir)/man/ -type f -name "coap_*.in" | ALL=C sort ; find $(top_srcdir)/man/ -type f -name "coap-*.in" | LC_ALL=C sort` ;\ 46 UPG_FILES=`find $(top_srcdir)/doc/ -type f -name "upgrade_*.txt" | ALL=C sort` ;\ 47 HTML_FILES=`find $(top_builddir)/man/ -type f -name "*.html"` ;\ 48 COUNT_MAN_FILES=`echo $${MAN_FILES} | wc -w` ;\ 49 COUNT_HTML_FILES=`echo $${HTML_FILES} | wc -w` ;\ 50 ## We need the HTML files from the Asciidoc source files, check if they around, otherwise build them. 51 if [ "$${COUNT_MAN_FILES}" != "$${COUNT_HTML_FILES}" ]; then \ 52 $(MAKE) -C ../man ;\ 53 fi ;\ 54 for FILE in $${MAN_FILES} ; do \ 55 BASE=`basename $${FILE} | cut -d. -f 1` ;\ 56 MANUAL=`egrep -B 1 "^====" $${FILE} | head -1` ;\ 57 SUMMARY=`egrep -B 2 "^SYNOPSIS" $${FILE} | sed 's/coap-//g' | cut -d\- -f2 | cut -c2- | head -1` ;\ 58 ## Build the manual insert page 59 echo "/// @page man_$${BASE} $${MANUAL}" > $(top_builddir)/doc/man_tmp/$${MANUAL}.dox ;\ 60 echo "/// @htmlinclude $${BASE}.html $${MANUAL}" >> $(top_builddir)/doc/man_tmp/$${MANUAL}.dox ;\ 61 ## Update insert_file 62 echo " <tab type=\"user\" visible=\"yes\" url=\"@ref man_$${BASE}\" title=\"$${MANUAL} - $${SUMMARY}\" intro=\"\"/>" >> $(top_builddir)/doc/insert_file ;\ 63 ## Update the summary man page 64 echo " <tr id=\"row_$${ID}_\"$${ROW_EVEN}>" >> $(top_builddir)/doc/man_tmp/manpage.dox ;\ 65 echo " <td class=\"entry\" align=\"left\"> @ref man_$${BASE} </td><td class=\"desc\" align=\"left\">$${MANUAL} - $${SUMMARY}</td>" >> $(top_builddir)/doc/man_tmp/manpage.dox ;\ 66 echo " </tr>" >> $(top_builddir)/doc/man_tmp/manpage.dox ;\ 67 if [ -z $${ROW_EVEN} ] ; then \ 68 ROW_EVEN=" class=\"even\"" ;\ 69 else \ 70 ROW_EVEN= ;\ 71 fi \ 72 done ;\ 73 ## Close off the man page file 74 echo ' </table>' >> $(top_builddir)/doc/man_tmp/manpage.dox ;\ 75 echo ' */' >> $(top_builddir)/doc/man_tmp/manpage.dox ;\ 76 echo ' </tab>' >> $(top_builddir)/doc/insert_file ;\ 77 ## Add in the deprecated tab 78 echo ' <tab type="user" visible="yes" url="@ref deprecated" title="Deprecated Items" intro=""/>' >> $(top_builddir)/doc/insert_file ;\ 79 ## Start the upgrade tab 80 echo ' <tab type="usergroup" visible="yes" url="@ref upgrading" title="Upgrading">' >> $(top_builddir)/doc/insert_file ;\ 81 for FILE in $${UPG_FILES} ; do \ 82 BASE=`basename $${FILE} | $(SED) "s/\.txt$$//g"`; \ 83 UPGRADE=`echo $${BASE} | $(SED) "s/^upgrade_//g"`; \ 84 CUPGRADE=`echo $${UPGRADE} | $(SED) "s/\./-/g"`; \ 85 SUMMARY=`head -1 $${FILE} | sed 's/^= //g'` ;\ 86 ## Build the upgrade insert page 87 echo "/// @page upg_$${CUPGRADE} $${UPGRADE}" > $(top_builddir)/doc/man_tmp/$${UPGRADE}.dox ;\ 88 echo "/// @htmlinclude $${BASE}.html $${UPGRADE}" >> $(top_builddir)/doc/man_tmp/$${UPGRADE}.dox ;\ 89 ## Update insert_file 90 echo " <tab type=\"user\" visible=\"yes\" url=\"@ref upg_$${CUPGRADE}\" title=\"$${SUMMARY}\" intro=\"\"/>" >> $(top_builddir)/doc/insert_file ;\ 91 ## Update the upgrading page 92 echo " <tr id=\"row_$${ID}_\"$${ROW_EVEN}>" >> $(top_builddir)/doc/man_tmp/upgrading.dox ;\ 93 echo " <td class=\"entry\" align=\"left\"> @ref upg_$${CUPGRADE} </td><td class=\"desc\" align=\"left\">$${SUMMARY}</td>" >> $(top_builddir)/doc/man_tmp/upgrading.dox ;\ 94 echo " </tr>" >> $(top_builddir)/doc/man_tmp/upgrading.dox ;\ 95 if [ -z $${ROW_EVEN} ] ; then \ 96 ROW_EVEN=" class=\"even\"" ;\ 97 else \ 98 ROW_EVEN= ;\ 99 fi ;\ 100 if [ -f $(top_builddir)/doc/$${BASE}.html ]; then \ 101 cp -f $(top_builddir)/doc/$${BASE}.html $(top_builddir)/doc/man_html/$${BASE}.html ;\ 102 ## Correct case sensitive Name and Synopsis 103 $(SED) -i 's^<div class="toc"><p><strong>^<div class="section"><p><strong>^' $(top_builddir)/doc/man_html/$${BASE}.html ;\ 104 else \ 105 echo "ERROR: $(top_builddir)/doc/$${BASE}.html not found!";\ 106 exit 1 ;\ 107 fi \ 108 done ;\ 109 ## Close off the upgrading tab 110 echo ' </table>' >> $(top_builddir)/doc/man_tmp/upgrading.dox ;\ 111 echo ' */' >> $(top_builddir)/doc/man_tmp/upgrading.dox ;\ 112 echo ' </tab>' >> $(top_builddir)/doc/insert_file ;\ 113 ## Create and Update the DoxygenLayout.xml file 114 $(DOXYGEN) -l ;\ 115 $(SED) -i 's/<tab type="pages" visible="yes" /<tab type="pages" visible="no" /g' $(top_builddir)/doc/DoxygenLayout.xml ;\ 116 $(SED) -i '/<tab type="examples" visible=.*/r insert_file' $(top_builddir)/doc/DoxygenLayout.xml ;\ 117 $(RM) $(top_builddir)/doc/insert_file ;\ 118 ## Fix up man html files, fixing links, UC Name and Synopsis 119 for FILE in $${MAN_FILES} ; do \ 120 BASE=`basename $${FILE} | cut -d . -f1` ;\ 121 if [ -f $(top_builddir)/man/$${BASE}.html ]; then \ 122 cp -f $(top_builddir)/man/$${BASE}.html $(top_builddir)/doc/man_html/$${BASE}.html ;\ 123 ## Correct case sensitive Name and Synopsis 124 $(SED) -i 's^<h2>Name</h2>^<h2>NAME</h2>^g' $(top_builddir)/doc/man_html/$${BASE}.html ;\ 125 $(SED) -i 's^<h2>Synopsis</h2>^<h2>SYNOPSIS</h2>^g' $(top_builddir)/doc/man_html/$${BASE}.html ;\ 126 else \ 127 echo "ERROR: $(top_builddir)/man/$${BASE}.html not found!";\ 128 exit 1 ;\ 129 fi ;\ 130 for ENTRY in $${MAN_FILES} ; do \ 131 EBASE=`basename $${ENTRY} | cut -d . -f1` ;\ 132 MANUAL=`egrep -B 1 "^====" $${ENTRY} | head -1` ;\ 133 SECTION=`echo $${MANUAL} | cut -d\( -f2 | cut -d\) -f1` ;\ 134 $(SED) -i "s^<span class=\"strong\"><strong>$${EBASE}</strong></span>($${SECTION})^<a href=\"man_$${EBASE}.html\" target=\"_self\"><span class=\"strong\"><strong>$${EBASE}</strong></span>($${SECTION})</a>^g" $(top_builddir)/doc/man_html/$${BASE}.html ;\ 135 done ;\ 136 echo "finalized addition $${BASE}.html" ;\ 137 done 138 139if BUILD_MANPAGES 140UPG_LIST = upgrade_4.2.1_4.3.0.txt 141 142upg-page-build: 143 @for FILE in $(UPG_LIST) ; do \ 144 $(A2X) -d article --format xhtml -D $(top_builddir)/doc/ $(top_srcdir)/doc/$${FILE} ;\ 145 done 146 147all: man-page-build 148 $(DOXYGEN) Doxyfile 149 @cp -f $(top_srcdir)/doc/docbook.local.css $(top_builddir)/doc/html/docbook-xsl.css 150 151else 152# 153# Need to make sure the man directories are in place, but empty 154all: man-page-prepare 155 $(DOXYGEN) Doxyfile 156endif # BUILD_MANPAGES 157 158clean-local: 159 -rm -rf $(top_builddir)/doc/html $(top_builddir)/doc/man_tmp $(top_builddir)/doc/man_html $(top_builddir)/doc/DoxygenLayout.xml $(top_builddir)/doc/docbook-xsl.css $(top_builddir)/doc/*.html 160 161distclean-local: clean-local 162 163endif # HAVE_DOXYGEN 164 165install-data-hook: 166if HAVE_DOXYGEN 167 @if [ ! -d $(top_builddir)/doc/html ]; then \ 168 echo ;\ 169 echo " No install data in '$(top_builddir)/doc/html'found! Please run 'make all' first." ;\ 170 echo ;\ 171 exit 1 ;\ 172 fi 173 $(MKDIR_P) $(DESTDIR)$(htmldir)/html || exit 1 174 cp -a -f $(top_builddir)/doc/html $(DESTDIR)$(htmldir) 175 find $(DESTDIR)$(htmldir) -type f -name "*.md5" -delete 176endif # HAVE_DOXYGEN 177if BUILD_LICENSE_INSTALL 178 $(MKDIR_P) $(DESTDIR)$(docdir) || exit 1 179 $(INSTALL_DATA) $(top_srcdir)/LICENSE $(DESTDIR)$(docdir) 180 $(INSTALL_DATA) $(top_srcdir)/COPYING $(DESTDIR)$(docdir) 181 $(INSTALL_DATA) $(top_srcdir)/README $(DESTDIR)$(docdir) 182endif # BUILD_LICENSE_INSTALL 183 184uninstall-hook: 185if BUILD_LICENSE_INSTALL 186 @if [ -d $(DESTDIR)$(docdir) ] ; then \ 187 (cd $(DESTDIR)$(docdir) ; rm -f LICENSE README COPYING) ; \ 188 fi 189endif # BUILD_LICENSE_INSTALL 190if HAVE_DOXYGEN 191 -rm -rf $(DESTDIR)$(htmldir)/html 192endif # HAVE_DOXYGEN 193 194.PHONY: man-page-cleanup man-page-prepare man-page-start man-page-build 195