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