| 1 |
# Copyright (C) 2011-2014 Povilas Kanapickas <[email protected]> |
| 2 |
# |
| 3 |
# This file is part of cppreference-doc |
| 4 |
# |
| 5 |
# This program is free software: you can redistribute it and/or modify |
| 6 |
# it under the terms of the GNU General Public License as published by |
| 7 |
# the Free Software Foundation, either version 3 of the License, or |
| 8 |
# (at your option) any later version. |
| 9 |
# |
| 10 |
# This program is distributed in the hope that it will be useful, |
| 11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
# GNU General Public License for more details. |
| 14 |
# |
| 15 |
# You should have received a copy of the GNU General Public License |
| 16 |
# along with this program. If not, see http://www.gnu.org/licenses/. |
| 17 |
|
| 18 |
SHELL := /bin/bash |
| 19 |
|
| 20 |
#Common prefixes |
| 21 |
|
| 22 |
prefix = /usr |
| 23 |
datarootdir = $(prefix)/share |
| 24 |
docdir = $(datarootdir)/cppreference/doc |
| 25 |
bookdir = $(datarootdir)/devhelp/books |
| 26 |
|
| 27 |
qhelpgenerator = qhelpgenerator |
| 28 |
|
| 29 |
#Version |
| 30 |
|
| 31 |
VERSION=20170409 |
| 32 |
|
| 33 |
#STANDARD RULES |
| 34 |
|
| 35 |
all: doc_devhelp doc_qch doc_doxygen |
| 36 |
|
| 37 |
DISTFILES= \ |
| 38 |
gadgets/ \ |
| 39 |
headers/ \ |
| 40 |
images/ \ |
| 41 |
reference/ \ |
| 42 |
skins/ \ |
| 43 |
build_link_map.py \ |
| 44 |
ddg_parse_html.py \ |
| 45 |
devhelp2qch.xsl \ |
| 46 |
fix_devhelp-links.py \ |
| 47 |
index2autolinker.py \ |
| 48 |
index2browser.py \ |
| 49 |
index2ddg.py \ |
| 50 |
index2devhelp.py \ |
| 51 |
index2doxygen-tag.py \ |
| 52 |
index2highlight.py \ |
| 53 |
index2search.py \ |
| 54 |
index_transform.py \ |
| 55 |
index-chapters-c.xml \ |
| 56 |
index-chapters-cpp.xml \ |
| 57 |
index-cpp-search-app.txt \ |
| 58 |
index-functions.README \ |
| 59 |
index-functions-c.xml \ |
| 60 |
index-functions-cpp.xml \ |
| 61 |
link_map.py \ |
| 62 |
preprocess.py \ |
| 63 |
preprocess-css.css \ |
| 64 |
Makefile \ |
| 65 |
README.md \ |
| 66 |
xml_utils.py |
| 67 |
|
| 68 |
CLEANFILES= \ |
| 69 |
output |
| 70 |
|
| 71 |
clean: |
| 72 |
rm -rf $(CLEANFILES) |
| 73 |
|
| 74 |
check: |
| 75 |
|
| 76 |
dist: clean |
| 77 |
mkdir -p "cppreference-doc-$(VERSION)" |
| 78 |
cp -r $(DISTFILES) "cppreference-doc-$(VERSION)" |
| 79 |
tar czf "cppreference-doc-$(VERSION).tar.gz" "cppreference-doc-$(VERSION)" |
| 80 |
rm -rf "cppreference-doc-$(VERSION)" |
| 81 |
|
| 82 |
install: all |
| 83 |
# install the devhelp documentation |
| 84 |
pushd "output/reference" > /dev/null; \ |
| 85 |
find . -type f -not -iname "*.ttf" \ |
| 86 |
-exec install -DT -m 644 '{}' "$(DESTDIR)$(docdir)/html/{}" \; ; \ |
| 87 |
popd > /dev/null |
| 88 |
|
| 89 |
install -DT -m 644 "output/cppreference-doc-en-c.devhelp2" \ |
| 90 |
"$(DESTDIR)$(bookdir)/cppreference-doc-en-c/cppreference-doc-en-c.devhelp2" |
| 91 |
install -DT -m 644 "output/cppreference-doc-en-cpp.devhelp2" \ |
| 92 |
"$(DESTDIR)$(bookdir)/cppreference-doc-en-cpp/cppreference-doc-en-cpp.devhelp2" |
| 93 |
install -DT -m 644 "output/cppreference-doxygen-local.tag.xml" \ |
| 94 |
"$(DESTDIR)$(bookdir)/cppreference-doxygen-local.tag.xml" |
| 95 |
install -DT -m 644 "output/cppreference-doxygen-web.tag.xml" \ |
| 96 |
"$(DESTDIR)$(bookdir)/cppreference-doxygen-web.tag.xml" |
| 97 |
|
| 98 |
# install the .qch (Qt Help) documentation |
| 99 |
install -DT -m 644 "output/cppreference-doc-en-cpp.qch" \ |
| 100 |
"$(DESTDIR)$(docdir)/qch/cppreference-doc-en-cpp.qch" |
| 101 |
|
| 102 |
uninstall: |
| 103 |
rm -rf "$(DESTDIR)$(docdir)" |
| 104 |
rm -rf "$(DESTDIR)$(bookdir)" |
| 105 |
|
| 106 |
release: all |
| 107 |
rm -rf release |
| 108 |
mkdir -p release |
| 109 |
|
| 110 |
# zip the distributable |
| 111 |
mkdir -p "cppreference-doc-$(VERSION)" |
| 112 |
cp -r $(DISTFILES) "cppreference-doc-$(VERSION)" |
| 113 |
tar czf "release/cppreference-doc-$(VERSION).tar.gz" "cppreference-doc-$(VERSION)" |
| 114 |
zip -r "release/cppreference-doc-$(VERSION).zip" "cppreference-doc-$(VERSION)" |
| 115 |
rm -rf "cppreference-doc-$(VERSION)" |
| 116 |
|
| 117 |
# zip the html output |
| 118 |
pushd "output"; \ |
| 119 |
tar czf "../release/html-book-$(VERSION).tar.gz" "reference" \ |
| 120 |
"cppreference-doxygen-local.tag.xml" ; \ |
| 121 |
zip -r "../release/html-book-$(VERSION).zip" "reference" \ |
| 122 |
"cppreference-doxygen-local.tag.xml" ; \ |
| 123 |
popd |
| 124 |
|
| 125 |
# zip qch |
| 126 |
pushd "output"; \ |
| 127 |
tar czf "../release/qch-book-$(VERSION).tar.gz" "cppreference-doc-en-cpp.qch"; \ |
| 128 |
zip -r "../release/qch-book-$(VERSION).zip" "cppreference-doc-en-cpp.qch"; \ |
| 129 |
popd |
| 130 |
|
| 131 |
#WORKER RULES |
| 132 |
doc_html: output/reference |
| 133 |
|
| 134 |
doc_devhelp: output/cppreference-doc-en-c.devhelp2 output/cppreference-doc-en-cpp.devhelp2 |
| 135 |
|
| 136 |
doc_qch: output/cppreference-doc-en-cpp.qch |
| 137 |
|
| 138 |
doc_doxygen: output/cppreference-doxygen-web.tag.xml output/cppreference-doxygen-local.tag.xml |
| 139 |
|
| 140 |
#builds the title<->location map |
| 141 |
output/link-map.xml: output/reference |
| 142 |
./build_link_map.py |
| 143 |
|
| 144 |
#build the .devhelp2 index |
| 145 |
output/cppreference-doc-en-c.devhelp2: \ |
| 146 |
output/reference \ |
| 147 |
output/link-map.xml |
| 148 |
./index2devhelp.py $(docdir)/html index-chapters-c.xml \ |
| 149 |
"C Standard Library reference" "cppreference-doc-en-c" "c" \ |
| 150 |
index-functions-c.xml "output/devhelp-index-c.xml" |
| 151 |
./fix_devhelp-links.py "output/devhelp-index-c.xml" \ |
| 152 |
"output/cppreference-doc-en-c.devhelp2" |
| 153 |
|
| 154 |
output/cppreference-doc-en-cpp.devhelp2: \ |
| 155 |
output/reference \ |
| 156 |
output/link-map.xml |
| 157 |
./index2devhelp.py $(docdir)/html index-chapters-cpp.xml \ |
| 158 |
"C++ Standard Library reference" "cppreference-doc-en-cpp" "cpp" \ |
| 159 |
index-functions-cpp.xml "output/devhelp-index-cpp.xml" |
| 160 |
./fix_devhelp-links.py "output/devhelp-index-cpp.xml" \ |
| 161 |
"output/cppreference-doc-en-cpp.devhelp2" |
| 162 |
|
| 163 |
#build the .qch (QT help) file |
| 164 |
output/cppreference-doc-en-cpp.qch: output/qch-help-project-cpp.xml |
| 165 |
#qhelpgenerator only works if the project file is in the same directory as the documentation |
| 166 |
cp "output/qch-help-project-cpp.xml" "output/reference/qch.qhp" |
| 167 |
|
| 168 |
pushd "output/reference" > /dev/null; \ |
| 169 |
$(qhelpgenerator) "qch.qhp" -o "../cppreference-doc-en-cpp.qch"; \ |
| 170 |
popd > /dev/null |
| 171 |
|
| 172 |
rm -f "output/reference/qch.qhp" |
| 173 |
|
| 174 |
output/qch-help-project-cpp.xml: output/cppreference-doc-en-cpp.devhelp2 |
| 175 |
#build the file list |
| 176 |
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?><files>" > "output/qch-files.xml" |
| 177 |
|
| 178 |
pushd "output/reference" > /dev/null; \ |
| 179 |
find . -type f -not -iname "*.ttf" \ |
| 180 |
-exec echo "<file>"'{}'"</file>" \; | LC_ALL=C sort >> "../qch-files.xml" ; \ |
| 181 |
popd > /dev/null |
| 182 |
|
| 183 |
echo "</files>" >> "output/qch-files.xml" |
| 184 |
|
| 185 |
#create the project (copies the file list) |
| 186 |
xsltproc devhelp2qch.xsl "output/cppreference-doc-en-cpp.devhelp2" > \ |
| 187 |
"output/qch-help-project-cpp.xml" |
| 188 |
|
| 189 |
# build doxygen tag file |
| 190 |
output/cppreference-doxygen-local.tag.xml: \ |
| 191 |
output/reference \ |
| 192 |
output/link-map.xml |
| 193 |
./index2doxygen-tag.py "output/link-map.xml" \ |
| 194 |
"index-functions-cpp.xml" \ |
| 195 |
"index-chapters-cpp.xml" \ |
| 196 |
"output/cppreference-doxygen-local.tag.xml" |
| 197 |
|
| 198 |
output/cppreference-doxygen-web.tag.xml: \ |
| 199 |
output/reference \ |
| 200 |
output/link-map.xml |
| 201 |
./index2doxygen-tag.py web \ |
| 202 |
"index-functions-cpp.xml" \ |
| 203 |
"index-chapters-cpp.xml" \ |
| 204 |
"output/cppreference-doxygen-web.tag.xml" |
| 205 |
|
| 206 |
#create preprocessed archive |
| 207 |
output/reference: |
| 208 |
mkdir -p output |
| 209 |
./preprocess.py --src reference --dst output/reference |
| 210 |
|
| 211 |
# create indexes for the wiki |
| 212 |
indexes: |
| 213 |
mkdir -p output/indexes |
| 214 |
./index2highlight.py index-functions-cpp.xml output/indexes/highlight-cpp |
| 215 |
./index2highlight.py index-functions-c.xml output/indexes/highlight-c |
| 216 |
./index2search.py index-functions-cpp.xml output/indexes/search-cpp |
| 217 |
./index2search.py index-functions-c.xml output/indexes/search-c |
| 218 |
cat index-cpp-search-app.txt >> output/indexes/search-cpp |
| 219 |
./index2autolinker.py index-functions-c.xml output/indexes/autolink-c |
| 220 |
./index2autolinker.py index-functions-cpp.xml output/indexes/autolink-cpp |
| 221 |
|
| 222 |
#redownloads the source documentation directly from en.cppreference.com |
| 223 |
source: |
| 224 |
rm -rf "reference" |
| 225 |
mkdir "reference" |
| 226 |
|
| 227 |
pushd "reference" > /dev/null; \ |
| 228 |
regex=".*index\\.php.*|.*/Special:.*|.*/Talk:.*" \ |
| 229 |
regex+="|.*/Help:.*|.*/File:.*|.*/Cppreference:.*" \ |
| 230 |
regex+="|.*/WhatLinksHere:.*|.*/Template:.*|.*/Category:.*" \ |
| 231 |
regex+="|.*action=.*|.*printable=.*|.*en.cppreference.com/book.*" ; \ |
| 232 |
echo $$regex ; \ |
| 233 |
wget --adjust-extension --page-requisites --convert-links \ |
| 234 |
--force-directories --recursive --level=15 \ |
| 235 |
--span-hosts --domains=en.cppreference.com,upload.cppreference.com \ |
| 236 |
--reject-regex $$regex \ |
| 237 |
--timeout=5 --tries=50 --no-verbose \ |
| 238 |
--retry-connrefused --waitretry=10 --read-timeout=20 \ |
| 239 |
http://en.cppreference.com/w/ ; \ |
| 240 |
popd > /dev/null |
| 241 |
|
| 242 |
./export.py --url=http://en.cppreference.com/mwiki reference/cppreference-export-ns0,4,8,10.xml 0 4 8 10 |