1c87c5fbaSopenharmony_ci# man/Makefile.am
2c87c5fbaSopenharmony_ci#
3c87c5fbaSopenharmony_ci# Copyright (C) 2018-2023 Jon Shallow <supjps-libcoap@jpshallow.com>
4c87c5fbaSopenharmony_ci#
5c87c5fbaSopenharmony_ci# This file is part of the CoAP C library libcoap. Please see README and
6c87c5fbaSopenharmony_ci# COPYING for terms of use.
7c87c5fbaSopenharmony_ci
8c87c5fbaSopenharmony_ci# picking up the default warning CFLAGS into AM_CFLAGS
9c87c5fbaSopenharmony_ciAM_CFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include \
10c87c5fbaSopenharmony_ci            -I$(top_srcdir)/include/coap$(LIBCOAP_API_VERSION) \
11c87c5fbaSopenharmony_ci            $(WARNING_CFLAGS) $(DTLS_CFLAGS) -std=c99 $(EXTRA_CFLAGS)
12c87c5fbaSopenharmony_ci
13c87c5fbaSopenharmony_ci# Build, not install
14c87c5fbaSopenharmony_cinoinst_PROGRAMS = examples-code-check
15c87c5fbaSopenharmony_ci
16c87c5fbaSopenharmony_ci# build manuals only if 'BUILD_MANPAGES' is defined
17c87c5fbaSopenharmony_ciif BUILD_MANPAGES
18c87c5fbaSopenharmony_ci
19c87c5fbaSopenharmony_ci# building the manpages
20c87c5fbaSopenharmony_ci
21c87c5fbaSopenharmony_ciTXT3 = coap_address.txt \
22c87c5fbaSopenharmony_ci	coap_async.txt \
23c87c5fbaSopenharmony_ci	coap_attribute.txt \
24c87c5fbaSopenharmony_ci	coap_block.txt \
25c87c5fbaSopenharmony_ci	coap_cache.txt \
26c87c5fbaSopenharmony_ci	coap_context.txt \
27c87c5fbaSopenharmony_ci	coap_deprecated.txt \
28c87c5fbaSopenharmony_ci	coap_endpoint_server.txt \
29c87c5fbaSopenharmony_ci	coap_encryption.txt \
30c87c5fbaSopenharmony_ci	coap_endpoint_client.txt \
31c87c5fbaSopenharmony_ci	coap_handler.txt \
32c87c5fbaSopenharmony_ci	coap_init.txt \
33c87c5fbaSopenharmony_ci	coap_io.txt \
34c87c5fbaSopenharmony_ci	coap_keepalive.txt \
35c87c5fbaSopenharmony_ci	coap_logging.txt \
36c87c5fbaSopenharmony_ci	coap_lwip.txt \
37c87c5fbaSopenharmony_ci	coap_observe.txt \
38c87c5fbaSopenharmony_ci	coap_oscore.txt \
39c87c5fbaSopenharmony_ci	coap_pdu_access.txt \
40c87c5fbaSopenharmony_ci	coap_pdu_setup.txt \
41c87c5fbaSopenharmony_ci	coap_persist.txt \
42c87c5fbaSopenharmony_ci	coap_recovery.txt \
43c87c5fbaSopenharmony_ci	coap_resource.txt \
44c87c5fbaSopenharmony_ci	coap_session.txt \
45c87c5fbaSopenharmony_ci	coap_string.txt \
46c87c5fbaSopenharmony_ci	coap_tls_library.txt \
47c87c5fbaSopenharmony_ci	coap_uri.txt \
48c87c5fbaSopenharmony_ci	coap_websockets.txt
49c87c5fbaSopenharmony_ci
50c87c5fbaSopenharmony_ciMAN3 = $(TXT3:%.txt=%.3)
51c87c5fbaSopenharmony_ci
52c87c5fbaSopenharmony_ciman3_MANS = $(MAN3)
53c87c5fbaSopenharmony_ci
54c87c5fbaSopenharmony_ciTXT5 = coap-client.txt \
55c87c5fbaSopenharmony_ci       coap-rd.txt \
56c87c5fbaSopenharmony_ci       coap-server.txt \
57c87c5fbaSopenharmony_ci       coap-oscore-conf.txt
58c87c5fbaSopenharmony_ci
59c87c5fbaSopenharmony_ciMAN5 = $(TXT5:%.txt=%.5)
60c87c5fbaSopenharmony_ci
61c87c5fbaSopenharmony_ciman5_MANS = $(MAN5)
62c87c5fbaSopenharmony_ci
63c87c5fbaSopenharmony_ciTXT7 = coap.txt
64c87c5fbaSopenharmony_ci
65c87c5fbaSopenharmony_ciMAN7 = $(TXT7:%.txt=%.7)
66c87c5fbaSopenharmony_ci
67c87c5fbaSopenharmony_ciman7_MANS = $(MAN7)
68c87c5fbaSopenharmony_ci
69c87c5fbaSopenharmony_ci.txt.3:
70c87c5fbaSopenharmony_ci	$(A2X) --doctype manpage --format manpage $<
71c87c5fbaSopenharmony_ci	@NEWLIST=`${SED} -ne '/^NAME/,/^SYNOPSIS/p;/^SYNOPSIS/q' $< | ${SED} 's/^- /\\\\\\\- /g' | egrep -v 'NAME|----|SYNOPSIS|^\$$' | tr '\n' ' '` ;\
72c87c5fbaSopenharmony_ci	NAME=`echo $< | ${SED} -ne 's/^\(coap_[a-zA-Z_0-9]\+\).*$$/\1.3/p'` ;\
73c87c5fbaSopenharmony_ci	${SED} -i '/.SH "NAME"/{n;d;}' $${NAME} ;\
74c87c5fbaSopenharmony_ci	${SED} -i "/\.SH \"NAME\"/a $${NEWLIST}" $${NAME}
75c87c5fbaSopenharmony_ci	$(A2X) --doctype manpage --format xhtml $<
76c87c5fbaSopenharmony_ci	@NEWLIST=`${SED} -ne '/^NAME/,/^SYNOPSIS/p;/^SYNOPSIS/q' $< | ${SED} 's^/^\\\\/^g' | egrep -v 'NAME|----|SYNOPSIS|^\$$' | tr '\n' ' '` ;\
77c87c5fbaSopenharmony_ci	NAME=`echo $< | ${SED} -ne 's/^\(coap_[a-zA-Z_0-9]\+\).*$$/\1.html/p'` ;\
78c87c5fbaSopenharmony_ci	${SED} -i "s^Name</h2><p>.*</p></div>^Name</h2><p>$${NEWLIST}</p></div>^" $${NAME}
79c87c5fbaSopenharmony_ci
80c87c5fbaSopenharmony_ci.txt.5:
81c87c5fbaSopenharmony_ci	$(A2X) --doctype manpage --format manpage $<
82c87c5fbaSopenharmony_ci	$(A2X) --doctype manpage --format xhtml $<
83c87c5fbaSopenharmony_ci
84c87c5fbaSopenharmony_ci.txt.7:
85c87c5fbaSopenharmony_ci	$(A2X) --doctype manpage --format manpage $<
86c87c5fbaSopenharmony_ci	$(A2X) --doctype manpage --format xhtml $<
87c87c5fbaSopenharmony_ci
88c87c5fbaSopenharmony_ci# Man pages built by a2x based on the NAMES section of the .txt file.
89c87c5fbaSopenharmony_ci# Note - this list includes all the defined entries, but a2x only builds the first 10.
90c87c5fbaSopenharmony_ciA2X_EXTRA_PAGES_3 = @DOLLAR_SIGN@(shell for fil in $(TXT3) ; do sed -ne '/^NAME/,/^SYNOPSIS/p;/^SYNOPSIS/q' $${fil} | \
91c87c5fbaSopenharmony_ci	sed -ne '/coap_/{ s/ *, */\n/g; p }' | sed -ne 's/^\(coap_[a-zA-Z_0-9]\+\).*$$/\1.3/p' ; done)
92c87c5fbaSopenharmony_ciA2X_EXTRA_PAGES_5 = @DOLLAR_SIGN@(shell for fil in $(TXT5) ; do sed -ne '/^NAME/,/^SYNOPSIS/p;/^SYNOPSIS/q' $${fil} | \
93c87c5fbaSopenharmony_ci	sed -ne '/coap-/{ s/ *, */\n/g; p }' | sed -ne 's/^\(coap-[a-zA-Z0-9-]\+\).*$$/\1.5/p' ; done)
94c87c5fbaSopenharmony_ci
95c87c5fbaSopenharmony_ci# a2x builds alternative .3 files up to a limit of 10 names from the
96c87c5fbaSopenharmony_ci# NAME section, so that 'man' works against the alternative different
97c87c5fbaSopenharmony_ci# function names.
98c87c5fbaSopenharmony_ci#
99c87c5fbaSopenharmony_ci# However, if there are more alternative names, they need to be defined
100c87c5fbaSopenharmony_ci# as per below
101c87c5fbaSopenharmony_ci#
102c87c5fbaSopenharmony_ci# Then all the alternative names as well as the extras defined below need
103c87c5fbaSopenharmony_ci# to be cleaned up in a 'make unistall'.
104c87c5fbaSopenharmony_ciinstall-man: install-man3 install-man5 install-man7
105c87c5fbaSopenharmony_ci	@echo ".so man3/coap_address.3" > coap_free_address_info.3
106c87c5fbaSopenharmony_ci	@echo ".so man3/coap_address.3" > coap_sockaddr_un.3
107c87c5fbaSopenharmony_ci	@echo ".so man3/coap_address.3" > coap_address_set_unix_domain.3
108c87c5fbaSopenharmony_ci	@echo ".so man3/coap_address.3" > coap_host_is_unix_domain.3
109c87c5fbaSopenharmony_ci	@echo ".so man3/coap_address.3" > coap_is_bcast.3
110c87c5fbaSopenharmony_ci	@echo ".so man3/coap_address.3" > coap_is_mcast.3
111c87c5fbaSopenharmony_ci	@echo ".so man3/coap_address.3" > coap_is_af_unix.3
112c87c5fbaSopenharmony_ci	@echo ".so man3/coap_cache.3" > coap_cache_get_pdu.3
113c87c5fbaSopenharmony_ci	@echo ".so man3/coap_cache.3" > coap_cache_get_app_data.3
114c87c5fbaSopenharmony_ci	@echo ".so man3/coap_cache.3" > coap_cache_set_app_data.3
115c87c5fbaSopenharmony_ci	@echo ".so man3/coap_context.3" > coap_context_get_session_timeout.3
116c87c5fbaSopenharmony_ci	@echo ".so man3/coap_context.3" > coap_context_set_csm_timeout.3
117c87c5fbaSopenharmony_ci	@echo ".so man3/coap_context.3" > coap_context_get_csm_timeout.3
118c87c5fbaSopenharmony_ci	@echo ".so man3/coap_context.3" > coap_context_set_max_token_size.3
119c87c5fbaSopenharmony_ci	@echo ".so man3/coap_deprecated.3" > coap_register_handler.3
120c87c5fbaSopenharmony_ci	@echo ".so man3/coap_deprecated.3" > coap_resource_set_dirty.3
121c87c5fbaSopenharmony_ci	@echo ".so man3/coap_deprecated.3" > coap_run_once.3
122c87c5fbaSopenharmony_ci	@echo ".so man3/coap_deprecated.3" > coap_set_event_handler.3
123c87c5fbaSopenharmony_ci	@echo ".so man3/coap_deprecated.3" > coap_write.3
124c87c5fbaSopenharmony_ci	@echo ".so man3/coap_io.3" > coap_can_exit.3
125c87c5fbaSopenharmony_ci	@echo ".so man3/coap_logging.3" > coap_log_info.3
126c87c5fbaSopenharmony_ci	@echo ".so man3/coap_logging.3" > coap_log_debug.3
127c87c5fbaSopenharmony_ci	@echo ".so man3/coap_logging.3" > coap_log_oscore.3
128c87c5fbaSopenharmony_ci	@echo ".so man3/coap_logging.3" > coap_log_dtls.3
129c87c5fbaSopenharmony_ci	@echo ".so man3/coap_logging.3" > coap_get_log_level.3
130c87c5fbaSopenharmony_ci	@echo ".so man3/coap_logging.3" > coap_set_log_level.3
131c87c5fbaSopenharmony_ci	@echo ".so man3/coap_logging.3" > coap_set_log_handler.3
132c87c5fbaSopenharmony_ci	@echo ".so man3/coap_logging.3" > coap_dtls_log.3
133c87c5fbaSopenharmony_ci	@echo ".so man3/coap_logging.3" > coap_dtls_get_log_level.3
134c87c5fbaSopenharmony_ci	@echo ".so man3/coap_logging.3" > coap_dtls_set_log_level.3
135c87c5fbaSopenharmony_ci	@echo ".so man3/coap_logging.3" > coap_package_name.3
136c87c5fbaSopenharmony_ci	@echo ".so man3/coap_logging.3" > coap_package_version.3
137c87c5fbaSopenharmony_ci	@echo ".so man3/coap_logging.3" > coap_package_build.3
138c87c5fbaSopenharmony_ci	@echo ".so man3/coap_logging.3" > coap_set_show_pdu_output.3
139c87c5fbaSopenharmony_ci	@echo ".so man3/coap_logging.3" > coap_show_pdu.3
140c87c5fbaSopenharmony_ci	@echo ".so man3/coap_logging.3" > coap_endpoint_str.3
141c87c5fbaSopenharmony_ci	@echo ".so man3/coap_logging.3" > coap_session_str.3
142c87c5fbaSopenharmony_ci	@echo ".so man3/coap_logging.3" > coap_print_addr.3
143c87c5fbaSopenharmony_ci	@echo ".so man3/coap_logging.3" > coap_print_ip_addr.3
144c87c5fbaSopenharmony_ci	@echo ".so man3/coap_oscore.3" > coap_context_oscore_server.3
145c87c5fbaSopenharmony_ci	@echo ".so man3/coap_pdu_access.3" > coap_option_filter_set.3
146c87c5fbaSopenharmony_ci	@echo ".so man3/coap_pdu_access.3" > coap_option_filter_unset.3
147c87c5fbaSopenharmony_ci	@echo ".so man3/coap_pdu_access.3" > coap_option_iterator_init.3
148c87c5fbaSopenharmony_ci	@echo ".so man3/coap_pdu_access.3" > coap_option_next.3
149c87c5fbaSopenharmony_ci	@echo ".so man3/coap_pdu_access.3" > coap_pdu_get_code.3
150c87c5fbaSopenharmony_ci	@echo ".so man3/coap_pdu_access.3" > coap_pdu_get_mid.3
151c87c5fbaSopenharmony_ci	@echo ".so man3/coap_pdu_access.3" > coap_pdu_get_token.3
152c87c5fbaSopenharmony_ci	@echo ".so man3/coap_pdu_access.3" > coap_pdu_get_type.3
153c87c5fbaSopenharmony_ci	@echo ".so man3/coap_pdu_access.3" > coap_get_uri_path.3
154c87c5fbaSopenharmony_ci	@echo ".so man3/coap_pdu_setup.3" > coap_insert_optlist.3
155c87c5fbaSopenharmony_ci	@echo ".so man3/coap_pdu_setup.3" > coap_delete_optlist.3
156c87c5fbaSopenharmony_ci	@echo ".so man3/coap_pdu_setup.3" > coap_encode_var_safe.3
157c87c5fbaSopenharmony_ci	@echo ".so man3/coap_pdu_setup.3" > coap_encode_var_safe8.3
158c87c5fbaSopenharmony_ci	@echo ".so man3/coap_pdu_setup.3" > coap_add_optlist_pdu.3
159c87c5fbaSopenharmony_ci	@echo ".so man3/coap_pdu_setup.3" > coap_add_option.3
160c87c5fbaSopenharmony_ci	@echo ".so man3/coap_pdu_setup.3" > coap_add_data.3
161c87c5fbaSopenharmony_ci	@echo ".so man3/coap_pdu_setup.3" > coap_add_data_blocked_response.3
162c87c5fbaSopenharmony_ci	@echo ".so man3/coap_pdu_setup.3" > coap_send.3
163c87c5fbaSopenharmony_ci	@echo ".so man3/coap_pdu_setup.3" > coap_split_path.3
164c87c5fbaSopenharmony_ci	@echo ".so man3/coap_pdu_setup.3" > coap_split_query.3
165c87c5fbaSopenharmony_ci	@echo ".so man3/coap_pdu_setup.3" > coap_pdu_set_mid.3
166c87c5fbaSopenharmony_ci	@echo ".so man3/coap_pdu_setup.3" > coap_pdu_set_code.3
167c87c5fbaSopenharmony_ci	@echo ".so man3/coap_pdu_setup.3" > coap_pdu_set_type.3
168c87c5fbaSopenharmony_ci	@echo ".so man3/coap_recovery.3" > coap_session_set_max_retransmit.3
169c87c5fbaSopenharmony_ci	@echo ".so man3/coap_recovery.3" > coap_session_get_max_retransmit.3
170c87c5fbaSopenharmony_ci	@echo ".so man3/coap_recovery.3" > coap_session_set_non_max_retransmit.3
171c87c5fbaSopenharmony_ci	@echo ".so man3/coap_recovery.3" > coap_session_get_non_max_retransmit.3
172c87c5fbaSopenharmony_ci	@echo ".so man3/coap_recovery.3" > coap_session_set_non_receive_timeout.3
173c87c5fbaSopenharmony_ci	@echo ".so man3/coap_recovery.3" > coap_session_get_non_receive_timeout.3
174c87c5fbaSopenharmony_ci	@echo ".so man3/coap_recovery.3" > coap_session_set_non_timeout.3
175c87c5fbaSopenharmony_ci	@echo ".so man3/coap_recovery.3" > coap_session_get_non_timeout.3
176c87c5fbaSopenharmony_ci	@echo ".so man3/coap_recovery.3" > coap_session_set_nstart.3
177c87c5fbaSopenharmony_ci	@echo ".so man3/coap_recovery.3" > coap_session_get_nstart.3
178c87c5fbaSopenharmony_ci	@echo ".so man3/coap_recovery.3" > coap_session_set_probing_rate.3
179c87c5fbaSopenharmony_ci	@echo ".so man3/coap_recovery.3" > coap_session_get_probing_rate.3
180c87c5fbaSopenharmony_ci	@echo ".so man3/coap_recovery.3" > coap_debug_set_packet_loss.3
181c87c5fbaSopenharmony_ci	@echo ".so man3/coap_resource.3" > coap_resource_set_mode.3
182c87c5fbaSopenharmony_ci	@echo ".so man3/coap_resource.3" > coap_resource_set_userdata.3
183c87c5fbaSopenharmony_ci	@echo ".so man3/coap_resource.3" > coap_resource_get_userdata.3
184c87c5fbaSopenharmony_ci	@echo ".so man3/coap_resource.3" > coap_resource_release_userdata_handler.3
185c87c5fbaSopenharmony_ci	@echo ".so man3/coap_resource.3" > coap_resource_get_uri_path.3
186c87c5fbaSopenharmony_ci	@echo ".so man3/coap_session.3" > coap_session_get_addr_remote.3
187c87c5fbaSopenharmony_ci	@echo ".so man3/coap_session.3" > coap_session_get_context.3
188c87c5fbaSopenharmony_ci	@echo ".so man3/coap_session.3" > coap_session_get_ifindex.3
189c87c5fbaSopenharmony_ci	@echo ".so man3/coap_session.3" > coap_session_get_proto.3
190c87c5fbaSopenharmony_ci	@echo ".so man3/coap_session.3" > coap_session_get_psk_hint.3
191c87c5fbaSopenharmony_ci	@echo ".so man3/coap_session.3" > coap_session_get_psk_key.3
192c87c5fbaSopenharmony_ci	@echo ".so man3/coap_session.3" > coap_session_get_state.3
193c87c5fbaSopenharmony_ci	@echo ".so man3/coap_session.3" > coap_session_get_tls.3
194c87c5fbaSopenharmony_ci	@echo ".so man3/coap_session.3" > coap_session_get_type.3
195c87c5fbaSopenharmony_ci	@echo ".so man3/coap_string.3" > coap_delete_bin_const.3
196c87c5fbaSopenharmony_ci	@echo ".so man3/coap_string.3" > coap_make_str_const.3
197c87c5fbaSopenharmony_ci	@echo ".so man3/coap_string.3" > coap_string_equal.3
198c87c5fbaSopenharmony_ci	@echo ".so man3/coap_string.3" > coap_binary_equal.3
199c87c5fbaSopenharmony_ci	@echo ".so man3/coap_tls_library.3" > coap_string_tls_support.3
200c87c5fbaSopenharmony_ci	@echo ".so man3/coap_tls_library.3" > coap_string_tls_version.3
201c87c5fbaSopenharmony_ci	@echo ".so man3/coap_tls_library.3" > coap_show_tls_version.3
202c87c5fbaSopenharmony_ci	$(INSTALL_DATA) $(A2X_EXTRA_PAGES_3) "$(DESTDIR)$(man3dir)"
203c87c5fbaSopenharmony_ci	$(INSTALL_DATA) $(A2X_EXTRA_PAGES_5) "$(DESTDIR)$(man5dir)"
204c87c5fbaSopenharmony_ci
205c87c5fbaSopenharmony_ci# As well as removing the base 'man' pages, remove other .3 files built by
206c87c5fbaSopenharmony_ci# a2x, as well as build by install-man specials.
207c87c5fbaSopenharmony_ciuninstall-man: uninstall-man3 uninstall-man5 uninstall-man7
208c87c5fbaSopenharmony_ci	-(cd $(DESTDIR)$(man3dir) ; rm -f $(A2X_EXTRA_PAGES_3) $(A2X_EXTRA_PAGES_5) )
209c87c5fbaSopenharmony_ci
210c87c5fbaSopenharmony_ciendif # BUILD_MANPAGES
211c87c5fbaSopenharmony_ci
212c87c5fbaSopenharmony_ciCLEANFILES = *.3 *.5 *.7 *.xml *.html docbook-xsl.css *.o examples-code-check
213c87c5fbaSopenharmony_ci
214c87c5fbaSopenharmony_ciclean-local:
215c87c5fbaSopenharmony_ci	-rm -rf tmp
216