mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-10 10:50:40 +03:00
There needs to be an easy way to validate that the examples provided in the man pages compile without errors. This PR provides a new executable examples-code-check that can be run against the .txt.in files that are in the man directory. It abstracts the code for each example and then runs the compiler against that stub code reporting errors and warnings as appropriate for subsequent fixing in the man page. .gitignore: Ignore the new executable and the files it generates. Makefile.am: configure.ac: Remove MAN_DIR and hard code in the man directory so that examples-code-check is always built. autogen.sh: Make sure that all the temporary stub code files are cleaned up. man/Makefile.am: Support building and clean-up of the new examples-code-check. man/examples-code-check.c: (new) The code that parses the man pages, looking for examples and the gets the examples compiled, testing for errors. The function definitions in the SYNOPSIS section are also included in the compilation of the examples. scripts/build.sh: If WITH_TESTS is set, check that the man page examples compile. man/coap_encryption.txt.in: man/coap_io.txt.in: man/coap_observe.txt.in: man/coap_pdu_setup.txt.in: man/coap_resource.txt.in: man/coap_session.txt.in: Correct the SYNOPSIS function definitions.
119 lines
3.5 KiB
Makefile
119 lines
3.5 KiB
Makefile
# man/Makefile.am
|
|
#
|
|
# Copyright (C) 2018-2020 Jon Shallow <supjps-libcoap@jpshallow.com>
|
|
#
|
|
# This file is part of the CoAP C library libcoap. Please see README and
|
|
# COPYING for terms of use.
|
|
|
|
# picking up the default warning CFLAGS into AM_CFLAGS
|
|
AM_CFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include \
|
|
-I$(top_srcdir)/include/coap$(LIBCOAP_API_VERSION) \
|
|
$(WARNING_CFLAGS) $(DTLS_CFLAGS) -std=c99
|
|
|
|
# Build, not install
|
|
noinst_PROGRAMS = examples-code-check
|
|
|
|
# build manuals only if 'BUILD_MANPAGES' is defined
|
|
if BUILD_MANPAGES
|
|
|
|
# building the manpages
|
|
|
|
TXT3 = coap_attribute.txt \
|
|
coap_context.txt \
|
|
coap_encryption.txt \
|
|
coap_handler.txt \
|
|
coap_io.txt \
|
|
coap_keepalive.txt \
|
|
coap_logging.txt \
|
|
coap_observe.txt \
|
|
coap_pdu_setup.txt \
|
|
coap_recovery.txt \
|
|
coap_resource.txt \
|
|
coap_session.txt \
|
|
coap_tls_library.txt
|
|
|
|
MAN3 = $(TXT3:%.txt=%.3)
|
|
|
|
man3_MANS = $(MAN3)
|
|
|
|
TXT5 = coap-client.txt \
|
|
coap-rd.txt \
|
|
coap-server.txt
|
|
|
|
MAN5 = $(TXT5:%.txt=%.5)
|
|
|
|
man5_MANS = $(MAN5)
|
|
|
|
TXT7 = coap.txt
|
|
|
|
MAN7 = $(TXT7:%.txt=%.7)
|
|
|
|
man7_MANS = $(MAN7)
|
|
|
|
.txt.3:
|
|
$(A2X) --doctype manpage --format manpage $<
|
|
$(A2X) --doctype manpage --format xhtml $<
|
|
|
|
.txt.5:
|
|
$(A2X) --doctype manpage --format manpage $<
|
|
$(A2X) --doctype manpage --format xhtml $<
|
|
|
|
.txt.7:
|
|
$(A2X) --doctype manpage --format manpage $<
|
|
$(A2X) --doctype manpage --format xhtml $<
|
|
|
|
# Man pages built byt a2x based on the NAMES section of the .txt file
|
|
A2X_EXTRA_PAGES = @DOLLAR_SIGN@(shell for fil in $(TXT3) ; do sed -ne '/^NAME/,/^SYNOPSIS/p;/^SYNOPSIS/q' $${fil} | \
|
|
sed -ne '/coap_/{ s/ *, */\n/g; p }' | sed -ne 's/^\(coap_[a-zA-Z_0-9]\+\).*$$/\1.3/p' ; done)
|
|
|
|
# Extra man pages that need to be installed due to limit of 10
|
|
# names built by a2x
|
|
#
|
|
# These files are created in install-man
|
|
#
|
|
EXTRA_PAGES = \
|
|
coap_context_set_pki_root_cas.3 \
|
|
coap_add_data_blocked_response.3 \
|
|
coap_encode_var_bytes.3 \
|
|
coap_split_path.3 \
|
|
coap_split_query.3 \
|
|
coap_session_get_app_data.3 \
|
|
coap_session_set_app_data.3 \
|
|
coap_is_tcp_supported.3 \
|
|
coap_endpoint_str.3 \
|
|
coap_session_str.3
|
|
|
|
# a2x builds alternative .3 files up to a limit of 10 names from the
|
|
# NAME section, so that 'man' works against the alternative different
|
|
# function names.
|
|
#
|
|
# However, if there are more alternative names, they need to be defined
|
|
# as per below as well as in EXTRA_PAGES above.
|
|
#
|
|
# Then all the alternative names as well as the extras defined below need
|
|
# to be cleaned up in a 'make unistall'.
|
|
install-man: install-man3 install-man5 install-man7
|
|
@echo ".so man3/coap_context.3" > coap_context_set_pki_root_cas.3
|
|
@echo ".so man3/coap_pdu_setup.3" > coap_add_data_blocked_response.3
|
|
@echo ".so man3/coap_pdu_setup.3" > coap_encode_var_bytes.3
|
|
@echo ".so man3/coap_pdu_setup.3" > coap_split_path.3
|
|
@echo ".so man3/coap_pdu_setup.3" > coap_split_query.3
|
|
@echo ".so man3/coap_session.3" > coap_session_get_app_data.3
|
|
@echo ".so man3/coap_session.3" > coap_session_set_app_data.3
|
|
@echo ".so man3/coap_session.3" > coap_is_tcp_supported.3
|
|
@echo ".so man3/coap_logging.3" > coap_endpoint_str.3
|
|
@echo ".so man3/coap_logging.3" > coap_session_str.3
|
|
$(INSTALL_DATA) $(EXTRA_PAGES) $(A2X_EXTRA_PAGES) "$(DESTDIR)$(man3dir)"
|
|
|
|
# As well as removing the base 'man' pages, remove other .3 files built by
|
|
# a2x, as well as build by install-man specials.
|
|
uninstall-man: uninstall-man3 uninstall-man5 uninstall-man7
|
|
-(cd $(DESTDIR)$(man3dir) ; rm -f $(EXTRA_PAGES) $(A2X_EXTRA_PAGES) )
|
|
|
|
endif # BUILD_MANPAGES
|
|
|
|
CLEANFILES = *.3 *.5 *.7 *.xml *.html docbook-xsl.css *.o examples-code-check
|
|
|
|
clean-local:
|
|
-rm -rf tmp
|