Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 1 | |
| 2 | # |
| 3 | #================================================================================== |
E. Scott Daniels | d4f18ba | 2019-06-17 15:08:17 -0400 | [diff] [blame] | 4 | # Copyright (c) 2019 Nokia |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 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 | # |
| 32 | if( 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 |
E. Scott Daniels | d4f18ba | 2019-06-17 15:08:17 -0400 | [diff] [blame] | 42 | execute_process( |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 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() |
E. Scott Daniels | d4f18ba | 2019-06-17 15:08:17 -0400 | [diff] [blame] | 50 | |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 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 |
E. Scott Daniels | 15390d7 | 2019-05-06 20:19:59 +0000 | [diff] [blame] | 65 | rmr_get_meid.3 |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 66 | rmr_rcv_msg.3 |
| 67 | rmr_send_msg.3 |
| 68 | rmr_wh_open.3 |
| 69 | rmr_call.3 |
| 70 | rmr_init.3 |
| 71 | rmr_ready.3 |
| 72 | rmr_str2meid.3 |
| 73 | rmr_str2xact.3 |
| 74 | rmr_support.3 |
| 75 | rmr_torcv_msg.3 |
| 76 | rmr_wh_send_msg.3 |
E. Scott Daniels | 08aee4a | 2019-04-19 19:51:41 +0000 | [diff] [blame] | 77 | rmr_get_trace.3 |
| 78 | rmr_init_trace.3 |
| 79 | rmr_set_trace.3 |
| 80 | rmr_tralloc_msg.3 |
| 81 | rmr_get_trlen.3 |
E. Scott Daniels | c1aee2b | 2019-04-19 21:12:25 +0000 | [diff] [blame] | 82 | rmr_get_src.3 |
E. Scott Daniels | 412d53d | 2019-05-20 20:00:52 +0000 | [diff] [blame] | 83 | rmr_mt_call.3 |
| 84 | rmr_mt_rcv.3 |
E. Scott Daniels | 68d09fa | 2019-06-03 19:45:12 +0000 | [diff] [blame] | 85 | rmr_get_srcip.3 |
E. Scott Daniels | d9de79a | 2019-10-31 09:20:33 -0400 | [diff] [blame^] | 86 | rmr_realloc_payload.3 |
E. Scott Daniels | a7610c6 | 2019-07-11 10:24:01 -0400 | [diff] [blame] | 87 | rmr_trace_ref.3 |
E. Scott Daniels | e30fc3a | 2019-07-16 12:03:45 -0400 | [diff] [blame] | 88 | rmr_set_stimeout.3 |
E. Scott Daniels | 4ac73e3 | 2019-08-13 11:35:04 -0400 | [diff] [blame] | 89 | rmr_get_xact.3 |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 90 | ) |
| 91 | |
E. Scott Daniels | d4f18ba | 2019-06-17 15:08:17 -0400 | [diff] [blame] | 92 | # initialise lists of files we generated |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 93 | set( man3_files ) |
| 94 | set( man7_files ) |
| 95 | |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 96 | # for each source, build a specific command that runs tfm to generate the |
E. Scott Daniels | d4f18ba | 2019-06-17 15:08:17 -0400 | [diff] [blame] | 97 | # troff output as a gzipped file. Sed is needed to remove the leading blank |
E. Scott Daniels | e30fc3a | 2019-07-16 12:03:45 -0400 | [diff] [blame] | 98 | # that tfm likes to insert even if indention is 0. We also generate postscript |
E. Scott Daniels | ffba61c | 2019-07-29 14:28:00 -0400 | [diff] [blame] | 99 | # markdown, plain ascii and rts output which are left in the build directory |
| 100 | # for the developer to use as needed. |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 101 | # |
| 102 | foreach( nm IN LISTS man_names ) |
| 103 | set( out ${CMAKE_BINARY_DIR}/${nm} ) |
| 104 | set( in ${CMAKE_SOURCE_DIR}/doc/src/man/${nm}.xfm ) |
| 105 | |
E. Scott Daniels | d4f18ba | 2019-06-17 15:08:17 -0400 | [diff] [blame] | 106 | add_custom_command( |
| 107 | OUTPUT ${out}.gz |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 108 | DEPENDS ${in} |
E. Scott Daniels | ffba61c | 2019-07-29 14:28:00 -0400 | [diff] [blame] | 109 | COMMAND bash -c "export LIB=${CMAKE_SOURCE_DIR}/doc/src; \ |
| 110 | export OUTPUT_TYPE=troff; \ |
| 111 | ${tfm} ${in} stdout | sed 's/^ //' | gzip >${out}.gz; \ |
| 112 | export OUTPUT_TYPE=rst; \ |
| 113 | ${tfm} ${in} ${out}.rst; \ |
| 114 | export OUTPUT_TYPE=txt; \ |
| 115 | ${tfm} ${in} ${out}.txt; \ |
| 116 | export OUTPUT_TYPE=markdown; \ |
| 117 | ${tfm} ${in} stdout | sed 's/^ //' >${out}.md; \ |
| 118 | export OUTPUT_TYPE=postscript; \ |
| 119 | ${pfm} ${in} ${out}.ps" |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 120 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR} |
| 121 | COMMENT "Building manpage ${out}" |
| 122 | VERBATIM |
| 123 | ) |
| 124 | if( ${out} MATCHES ".*\.3" ) |
E. Scott Daniels | d4f18ba | 2019-06-17 15:08:17 -0400 | [diff] [blame] | 125 | list( APPEND man3_files ${out}.gz ) |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 126 | else() |
E. Scott Daniels | d4f18ba | 2019-06-17 15:08:17 -0400 | [diff] [blame] | 127 | list( APPEND man7_files ${out}.gz ) |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 128 | endif() |
| 129 | endforeach() |
| 130 | |
| 131 | # we must force these to install |
E. Scott Daniels | d4f18ba | 2019-06-17 15:08:17 -0400 | [diff] [blame] | 132 | # find all of the man pages in build and add them to the package |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 133 | # |
| 134 | install( FILES ${man3_files} DESTINATION ${install_man}/man3/ ) |
| 135 | install( FILES ${man7_files} DESTINATION ${install_man}/man7/ ) |
| 136 | |
| 137 | add_custom_target( man_pages ALL DEPENDS ${man3_files};${man7_files} ) |
| 138 | |
| 139 | else() |
E. Scott Daniels | a943533 | 2019-05-09 14:39:19 +0000 | [diff] [blame] | 140 | message( "+++ not building doc, set -DBULID_DOC=1 on cmake command line to enable" ) |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 141 | endif() |
| 142 | unset( BUILD_DOC CACHE ) # prevent it from being applied next build unless specifically set on comd line |