E. Scott Daniels | 2301eb8 | 2020-07-15 13:46:51 -0400 | [diff] [blame^] | 1 | # vim: ts=4 sw=4 noet: |
| 2 | #================================================================================== |
| 3 | # Copyright (c) 2020 AT&T Intellectual Property. |
| 4 | # Copyright (c) 2020 Nokia |
| 5 | # |
| 6 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | # you may not use this file except in compliance with the License. |
| 8 | # You may obtain a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, software |
| 13 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | # See the License for the specific language governing permissions and |
| 16 | # limitations under the License. |
| 17 | #================================================================================== |
| 18 | |
| 19 | # filename prefix to add when publishing docs to the scrapped directory. |
| 20 | # |
| 21 | doc_prefix = mgxapp_ |
| 22 | |
| 23 | # overrride from command line if {X}fm is not installed in the standard place |
| 24 | # the rules will _always_ add the current directory first, so this just needs |
| 25 | # to reference the location of the {X}fm imbed (.im) files installed with the |
| 26 | # {X}fm package |
| 27 | # |
| 28 | XPATH = /usr/local/share/xfm:.. |
| 29 | |
| 30 | %.txt: %.xfm |
| 31 | PASS=1 XFM_OUTPUT_TYPE=txt TFM_PATH=.:$(XPATH) tfm $< /dev/null |
| 32 | PASS=2 XFM_OUTPUT_TYPE=txt TFM_PATH=.:$(XPATH) tfm $< $@ |
| 33 | |
| 34 | # md and rst are space sensitive parsers and the leading blank that tfm inserts must |
| 35 | # be stripped. Trailing whitespace IS important for md, so do NOT strip that. |
| 36 | # |
| 37 | %.md: %.xfm |
| 38 | PASS=1 XFM_OUTPUT_TYPE=md TFM_PATH=.:$(XPATH) tfm $< /dev/null |
| 39 | PASS=2 XFM_OUTPUT_TYPE=md TFM_PATH=.:$(XPATH) tfm $< stdout | sed 's!^ !!' >$@ |
| 40 | |
| 41 | %.rst: %.xfm |
| 42 | PASS=1 XFM_OUTPUT_TYPE=rst TFM_PATH=.:$(XPATH) tfm $< /dev/null |
| 43 | PASS=2 XFM_OUTPUT_TYPE=rst TFM_PATH=.:$(XPATH) tfm $< stdout | sed 's!^ !!; s! *$$!!' >$@ |
| 44 | |
| 45 | %.ps: %.xfm |
| 46 | IN_FILE=$@ \ |
| 47 | && IN_FILE=$${IN_FILE%.*} XFM_OUTPUT_TYPE=ps PASS=1 XFM_PATH=.:$(XPATH) pfm $< /dev/null \ |
| 48 | && IN_FILE=$${IN_FILE%.*} XFM_OUTPUT_TYPE=ps PASS=2 XFM_PATH=.:$(XPATH) pfm $< $@ |
| 49 | |
| 50 | # requires ghostscript to be installed |
| 51 | %.pdf: %.ps |
| 52 | gs -dBATCH -dNOPROMPT -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=$@ $< |
| 53 | |
| 54 | |
| 55 | # ------------- generic all rule ---------------------------------------------------- |
| 56 | |
| 57 | # ALL_LIST names each doc; we'll generate all forms of supported output |
| 58 | all: $(ALL_LIST:%=%.ps) $(ALL_LIST:%=%.md) $(ALL_LIST:%=%.txt) $(ALL_LIST:%=%.rst) |
| 59 | |
| 60 | |
| 61 | # ----------- publishing generatd output -------------------------------------------- |
| 62 | |
| 63 | # copy the .rst versions to the top level docs directory for RTD scraping |
| 64 | # we must prefix documents because the scraper is dumb and doesn't support |
| 65 | # layers in the docs directory. We assume that this this directory is under |
| 66 | # repo/project/docs/src |
| 67 | # and thus the pulication directory is repo/docs with the relative path |
| 68 | # to copy files up from a subdirectory would be ../../../../docs/ |
| 69 | # |
| 70 | # |
| 71 | publish: $(ALL_LIST:%=%.rst) |
| 72 | for f in *.rst; \ |
| 73 | do \ |
| 74 | cp $$f ../../../../docs/$(doc_prefix)$$f; \ |
| 75 | done |
| 76 | |
| 77 | |
| 78 | # ----- housekeeping ------------------------------------------------------------------ |
| 79 | |
| 80 | # remove any intermediate file; leave final output files |
| 81 | clean: |
| 82 | rm -f *.bcnfile *.ca *.sp *.toc |
| 83 | |
| 84 | # trash anything that can be built |
| 85 | nuke: clean |
| 86 | rm -f *.pdf *.ps *.rst *.md *.txt |