blob: 2dbca2b73bff8dd43474cc078b7cfd696aab891f [file] [log] [blame]
Ashwin Sridharanfd9cc7a2019-04-03 16:47:02 -04001
2#
3#==================================================================================
4# Copyright (c) 2019 Nokia
5# Copyright (c) 2018-2019 AT&T Intellectual Property.
6#
7# Licensed under the Apache License, Version 2.0 (the "License");
8# you may not use this file except in compliance with the License.
9# You may obtain a copy of the License at
10#
11# http://www.apache.org/licenses/LICENSE-2.0
12#
13# Unless required by applicable law or agreed to in writing, software
14# distributed under the License is distributed on an "AS IS" BASIS,
15# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16# See the License for the specific language governing permissions and
17# limitations under the License.
18#==================================================================================
19#
20
21
22# builds the man pages for the deb file (generates troff from {X}fm).
23# also builds postscript files, but leaves them in the current build dir.
24# but, ONLY if build_doc variable is true
25#
26
27# look for tfm to build the man pages with. if not found, then we pull
28# and build in the current build environment setting tfm/pfm commands to
29# point at the correct spot. If the user has {X}fm installed, we just
30# use their install.
31#
32if( BUILD_DOC )
33 find_program( tfm NAMES tfm )
34 find_program( pfm NAMES pfm )
35
36 if( "${tfm}" MATCHES "tfm-NOTFOUND" ) # user doesn't have installed; set where we expect them
37 set( tfm ${CMAKE_CURRENT_BINARY_DIR}/xfm/.build/src/tfm/tfm )
38 set( pfm "${CMAKE_CURRENT_BINARY_DIR}/xfm/.build/src/pfm/pfm" )
39
40 if( NOT EXISTS ${tfm} ) # not yet built here, pull and build
41 # pull and build {X}fm tools needed to generate manpages
42 execute_process(
43 COMMAND "bash" "-c" "git clone https://github.com/ScottDaniels/xfm.git && cd xfm && mkdir .build && cd .build && cmake .. && make"
44 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
45 )
46 message( "+++ xfm pulled and built" )
47 else()
48 message( "+++ found xfm in the build environment" )
49 endif()
50
51 endif()
52
53 # base filenames (with .xfm are input)
54 set( man_names
55 rmr.7
56 rmr_bytes2meid.3
57 rmr_bytes2xact.3
58 rmr_bytes2payload.3
59 rmr_free_msg.3
60 rmr_payload_size.3
61 rmr_rts_msg.3
62 rmr_wh_close.3
63 rmr_alloc_msg.3
64 rmr_get_rcvfd.3
65 rmr_rcv_msg.3
66 rmr_send_msg.3
67 rmr_wh_open.3
68 rmr_call.3
69 rmr_init.3
70 rmr_ready.3
71 rmr_str2meid.3
72 rmr_str2xact.3
73 rmr_support.3
74 rmr_torcv_msg.3
75 rmr_wh_send_msg.3
E. Scott Daniels08aee4a2019-04-19 19:51:41 +000076 rmr_get_trace.3
77 rmr_init_trace.3
78 rmr_set_trace.3
79 rmr_tralloc_msg.3
80 rmr_get_trlen.3
Ashwin Sridharanfd9cc7a2019-04-03 16:47:02 -040081 )
82
83 # empty list of roff/troff input files we generated
84 set( man3_files )
85 set( man7_files )
86
87 # mk is so much easier than this -- grumble
88 # for each source, build a specific command that runs tfm to generate the
89 # troff output. Sed is needed to remove the leading blank that tfm likes
90 # to insert even if indention is 0.
91 #
92 foreach( nm IN LISTS man_names )
93 set( out ${CMAKE_BINARY_DIR}/${nm} )
94 set( in ${CMAKE_SOURCE_DIR}/doc/src/man/${nm}.xfm )
95
96 add_custom_command(
97 OUTPUT ${out}
98 DEPENDS ${in}
99 COMMAND bash -c "export LIB=${CMAKE_SOURCE_DIR}/doc/src; ${tfm} ${in} stdout | sed 's/^ //' >${out}; ${pfm} ${in} ${out}.ps"
100 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
101 COMMENT "Building manpage ${out}"
102 VERBATIM
103 )
104 if( ${out} MATCHES ".*\.3" )
105 list( APPEND man3_files ${out} )
106 else()
107 list( APPEND man7_files ${out} )
108 endif()
109 endforeach()
110
111 # we must force these to install
112 # find all of the man pages in build and add them to the deb
113 #
114 install( FILES ${man3_files} DESTINATION ${install_man}/man3/ )
115 install( FILES ${man7_files} DESTINATION ${install_man}/man7/ )
116
117 add_custom_target( man_pages ALL DEPENDS ${man3_files};${man7_files} )
118
119else()
120 message( "+++ not building doc, set -DBULID_DOC on cmake commandline to enable" )
121endif()
122unset( BUILD_DOC CACHE ) # prevent it from being applied next build unless specifically set on comd line