This file is indexed.

/usr/share/doc/knot-resolver/build.html is in knot-resolver-doc 2.1.1-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Building project &#8212; Knot DNS Resolver 2.1.1 documentation</title>
    <link rel="stylesheet" href="_static/nature.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    './',
        VERSION:     '2.1.1',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true,
        SOURCELINK_SUFFIX: '.txt'
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="next" title="Knot DNS Resolver library" href="lib.html" />
    <link rel="prev" title="Knot DNS Resolver modules" href="modules.html" /> 
  </head>
  <body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="lib.html" title="Knot DNS Resolver library"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="modules.html" title="Knot DNS Resolver modules"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="index.html">Knot DNS Resolver 2.1.1 documentation</a> &#187;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="building-project">
<h1>Building project<a class="headerlink" href="#building-project" title="Permalink to this headline"></a></h1>
<div class="section" id="installing-from-packages">
<h2>Installing from packages<a class="headerlink" href="#installing-from-packages" title="Permalink to this headline"></a></h2>
<p>The resolver is packaged for Debian, Fedora+EPEL, Ubuntu, Docker, NixOS/NixPkgs, FreeBSD, HomeBrew, and Turris Omnia.
Some of these are maintained directly by the knot-resolver team.</p>
<p>Refer to <a class="reference external" href="https://www.knot-resolver.cz/download">project page</a> for information about
installing from packages. If packages are not available for your OS, see following sections
to see how you can build it from sources (or package it), or use official <a class="reference external" href="https://hub.docker.com/r/cznic/knot-resolver">Docker images</a>.</p>
</div>
<div class="section" id="platform-considerations">
<h2>Platform considerations<a class="headerlink" href="#platform-considerations" title="Permalink to this headline"></a></h2>
<table border="1" class="docutils">
<colgroup>
<col width="33%" />
<col width="33%" />
<col width="33%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Project</th>
<th class="head">Platforms</th>
<th class="head">Compatibility notes</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><code class="docutils literal"><span class="pre">daemon</span></code></td>
<td>UNIX-like <a class="footnote-reference" href="#id3" id="id1">[1]</a></td>
<td>C99, <a class="reference external" href="https://github.com/libuv/libuv">libuv</a> provides portable I/O</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">library</span></code></td>
<td>UNIX-like</td>
<td><a class="reference external" href="https://msdn.microsoft.com/en-us/vstudio/hh386302.aspx">MSVC</a> not supported, needs <a class="reference external" href="http://www.mingw.org/">MinGW</a></td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">modules</span></code></td>
<td><em>varies</em></td>
<td>&#160;</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">tests/unit</span></code></td>
<td><em>equivalent to library</em></td>
<td>&#160;</td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">tests/integration</span></code></td>
<td>UNIX-like</td>
<td>Depends on library injection (see <a class="footnote-reference" href="#id7" id="id2">[2]</a>)</td>
</tr>
</tbody>
</table>
<table class="docutils footnote" frame="void" id="id3" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" href="#id1">[1]</a></td><td>Known to be running (not exclusively) on FreeBSD, Linux and OS X.</td></tr>
</tbody>
</table>
</div>
<div class="section" id="requirements">
<h2>Requirements<a class="headerlink" href="#requirements" title="Permalink to this headline"></a></h2>
<p>The following is a list of software required to build Knot DNS Resolver from sources.</p>
<table border="1" class="docutils">
<colgroup>
<col width="33%" />
<col width="33%" />
<col width="33%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Requirement</th>
<th class="head">Required by</th>
<th class="head">Notes</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><a class="reference external" href="https://www.gnu.org/software/make/">GNU Make</a> 3.80+</td>
<td><em>all</em></td>
<td><em>(build only)</em></td>
</tr>
<tr class="row-odd"><td>C compiler</td>
<td><em>all</em></td>
<td><em>(build only)</em> <a class="footnote-reference" href="#id7" id="id4">[2]</a></td>
</tr>
<tr class="row-even"><td><a class="reference external" href="https://www.freedesktop.org/wiki/Software/pkg-config/">pkg-config</a></td>
<td><em>all</em></td>
<td><em>(build only)</em> <a class="footnote-reference" href="#id8" id="id5">[3]</a></td>
</tr>
<tr class="row-odd"><td>hexdump or xxd</td>
<td><code class="docutils literal"><span class="pre">daemon</span></code></td>
<td><em>(build only)</em></td>
</tr>
<tr class="row-even"><td><a class="reference external" href="https://gitlab.labs.nic.cz/knot/knot-dns">libknot</a> 2.4.0+</td>
<td><em>all</em></td>
<td>Knot DNS library (requires autotools, GnuTLS and Jansson).</td>
</tr>
<tr class="row-odd"><td><a class="reference external" href="http://luajit.org/luajit.html">LuaJIT</a> 2.0+</td>
<td><code class="docutils literal"><span class="pre">daemon</span></code></td>
<td>Embedded scripting language.</td>
</tr>
<tr class="row-even"><td><a class="reference external" href="https://github.com/libuv/libuv">libuv</a> 1.7+</td>
<td><code class="docutils literal"><span class="pre">daemon</span></code></td>
<td>Multiplatform I/O and services (<a class="reference external" href="https://github.com/libuv/libuv">libuv</a> 1.0 with limitations <a class="footnote-reference" href="#id9" id="id6">[4]</a>).</td>
</tr>
</tbody>
</table>
<p>There are also <em>optional</em> packages that enable specific functionality in Knot DNS Resolver, they are useful mainly for developers to build documentation and tests.</p>
<table border="1" class="docutils">
<colgroup>
<col width="33%" />
<col width="33%" />
<col width="33%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Optional</th>
<th class="head">Needed for</th>
<th class="head">Notes</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><a class="reference external" href="https://luarocks.org/modules/daurnimator/http">lua-http</a></td>
<td><code class="docutils literal"><span class="pre">modules/http</span></code></td>
<td>HTTP/2 client/server for Lua.</td>
</tr>
<tr class="row-odd"><td><a class="reference external" href="https://luarocks.org/modules/luarocks/luasocket">luasocket</a></td>
<td><code class="docutils literal"><span class="pre">trust</span> <span class="pre">anchors,</span> <span class="pre">modules/stats</span></code></td>
<td>Sockets for Lua.</td>
</tr>
<tr class="row-even"><td><a class="reference external" href="https://luarocks.org/modules/brunoos/luasec">luasec</a></td>
<td><code class="docutils literal"><span class="pre">trust</span> <span class="pre">anchors</span></code></td>
<td>TLS for Lua.</td>
</tr>
<tr class="row-odd"><td><a class="reference external" href="http://libmemcached.org/libMemcached.html">libmemcached</a></td>
<td><code class="docutils literal"><span class="pre">modules/memcached</span></code></td>
<td>To build memcached backend module.</td>
</tr>
<tr class="row-even"><td><a class="reference external" href="https://github.com/redis/hiredis">hiredis</a></td>
<td><code class="docutils literal"><span class="pre">modules/redis</span></code></td>
<td>To build redis backend module.</td>
</tr>
<tr class="row-odd"><td><a class="reference external" href="https://golang.org">Go</a> 1.5+</td>
<td><code class="docutils literal"><span class="pre">modules</span></code></td>
<td>Build modules written in Go.</td>
</tr>
<tr class="row-even"><td><a class="reference external" href="https://cmocka.org/">cmocka</a></td>
<td><code class="docutils literal"><span class="pre">unit</span> <span class="pre">tests</span></code></td>
<td>Unit testing framework.</td>
</tr>
<tr class="row-odd"><td><a class="reference external" href="https://www.stack.nl/~dimitri/doxygen/manual/index.html">Doxygen</a></td>
<td><code class="docutils literal"><span class="pre">documentation</span></code></td>
<td>Generating API documentation.</td>
</tr>
<tr class="row-even"><td><a class="reference external" href="http://sphinx-doc.org/">Sphinx</a> and <a class="reference external" href="https://pypi.python.org/pypi/sphinx_rtd_theme">sphinx_rtd_theme</a></td>
<td><code class="docutils literal"><span class="pre">documentation</span></code></td>
<td>Building this HTML/PDF documentation.</td>
</tr>
<tr class="row-odd"><td><a class="reference external" href="https://github.com/michaeljones/breathe">breathe</a></td>
<td><code class="docutils literal"><span class="pre">documentation</span></code></td>
<td>Exposing Doxygen API doc to Sphinx.</td>
</tr>
<tr class="row-even"><td><a class="reference external" href="https://www.freedesktop.org/wiki/Software/systemd/">libsystemd</a></td>
<td><code class="docutils literal"><span class="pre">daemon</span></code></td>
<td>Systemd socket activation support.</td>
</tr>
<tr class="row-odd"><td><a class="reference external" href="https://developers.google.com/protocol-buffers/">libprotobuf</a> 3.0+</td>
<td><code class="docutils literal"><span class="pre">modules/dnstap</span></code></td>
<td>Protocol Buffers support for <a class="reference external" href="http://dnstap.info/">dnstap</a>.</td>
</tr>
<tr class="row-even"><td><a class="reference external" href="https://github.com/protobuf-c/protobuf-c/wiki">libprotobuf-c</a> 1.0+</td>
<td><code class="docutils literal"><span class="pre">modules/dnstap</span></code></td>
<td>C bindings for Protobuf.</td>
</tr>
<tr class="row-odd"><td><a class="reference external" href="https://github.com/farsightsec/fstrm">libfstrm</a> 0.2+</td>
<td><code class="docutils literal"><span class="pre">modules/dnstap</span></code></td>
<td>Frame Streams data transport protocol.</td>
</tr>
<tr class="row-even"><td><a class="reference external" href="http://luacheck.readthedocs.io">luacheck</a></td>
<td><code class="docutils literal"><span class="pre">lint-lua</span></code></td>
<td>Syntax and static analysis checker for Lua.</td>
</tr>
<tr class="row-odd"><td><a class="reference external" href="http://clang.llvm.org/extra/clang-tidy/index.html">clang-tidy</a></td>
<td><code class="docutils literal"><span class="pre">lint-c</span></code></td>
<td>Syntax and static analysis checker for C.</td>
</tr>
<tr class="row-even"><td><a class="reference external" href="https://keplerproject.github.io/luacov/">luacov</a></td>
<td><code class="docutils literal"><span class="pre">check-config</span></code></td>
<td>Code coverage analysis for Lua modules.</td>
</tr>
</tbody>
</table>
<table class="docutils footnote" frame="void" id="id7" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" href="#id4">[2]</a></td><td>Requires C99, <code class="docutils literal"><span class="pre">__attribute__((cleanup))</span></code> and <code class="docutils literal"><span class="pre">-MMD</span> <span class="pre">-MP</span></code> for dependency file generation. GCC, Clang and ICC are supported.</td></tr>
</tbody>
</table>
<table class="docutils footnote" frame="void" id="id8" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" href="#id5">[3]</a></td><td>You can use variables <code class="docutils literal"><span class="pre">&lt;dependency&gt;_CFLAGS</span></code> and <code class="docutils literal"><span class="pre">&lt;dependency&gt;_LIBS</span></code> to configure dependencies manually (i.e. <code class="docutils literal"><span class="pre">libknot_CFLAGS</span></code> and <code class="docutils literal"><span class="pre">libknot_LIBS</span></code>).</td></tr>
</tbody>
</table>
<table class="docutils footnote" frame="void" id="id9" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" href="#id6">[4]</a></td><td>libuv 1.7 brings SO_REUSEPORT support that is needed for multiple forks. libuv &lt; 1.7 can be still used, but only in single-process mode. Use <a class="reference internal" href="daemon.html#daemon-reuseport"><span class="std std-ref">different method</span></a> for load balancing.</td></tr>
</tbody>
</table>
<div class="section" id="packaged-dependencies">
<h3>Packaged dependencies<a class="headerlink" href="#packaged-dependencies" title="Permalink to this headline"></a></h3>
<p>Most of the dependencies can be resolved from packages, here’s an overview for several platforms.</p>
<ul class="simple">
<li><strong>Debian</strong> (since <em>sid</em>) - current stable doesn’t have libknot and libuv, which must be installed from sources.</li>
</ul>
<div class="highlight-bash"><div class="highlight"><pre><span></span>sudo apt-get install pkg-config libknot-dev libuv1-dev libcmocka-dev libluajit-5.1-dev
</pre></div>
</div>
<ul class="simple">
<li><strong>Ubuntu</strong> - unknown.</li>
<li><strong>Fedora</strong></li>
</ul>
<div class="highlight-bash"><div class="highlight"><pre><span></span><span class="c1"># minimal build</span>
sudo dnf install @buildsys-build knot-devel libuv-devel luajit-devel
<span class="c1"># unit tests</span>
sudo dnf install libcmocka-devel
<span class="c1"># integration tests</span>
sudo dnf install cmake git python-dns python-jinja2
<span class="c1"># optional features</span>
sudo dnf install golang hiredis-devel libmemcached-devel lua-sec-compat lua-socket-compat systemd-devel
<span class="c1"># docs</span>
sudo dnf install doxygen python-breathe python-sphinx
</pre></div>
</div>
<ul class="simple">
<li><strong>RHEL/CentOS</strong> - unknown.</li>
<li><strong>openSUSE</strong> - there is an <a class="reference external" href="https://build.opensuse.org/package/show/server:dns/knot-resolver">experimental package</a>.</li>
<li><strong>FreeBSD</strong> - when installing from ports, all dependencies will install automatically, corresponding to the selected options.</li>
<li><strong>NetBSD</strong> - unknown.</li>
<li><strong>OpenBSD</strong> - unknown.</li>
<li><strong>Mac OS X</strong> - the dependencies can be found through <a class="reference external" href="http://brew.sh/">Homebrew</a>.</li>
</ul>
<div class="highlight-bash"><div class="highlight"><pre><span></span>brew install pkg-config libuv luajit cmocka
</pre></div>
</div>
</div>
</div>
<div class="section" id="building-from-sources">
<h2>Building from sources<a class="headerlink" href="#building-from-sources" title="Permalink to this headline"></a></h2>
<p>Initialize git submodules first.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ git submodule update --init --recursive
</pre></div>
</div>
<p>The Knot DNS Resolver depends on the the Knot DNS library, recent version of <a class="reference external" href="https://github.com/libuv/libuv">libuv</a>, and <a class="reference external" href="http://luajit.org/luajit.html">LuaJIT</a>.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ make info <span class="c1"># See what&#39;s missing</span>
</pre></div>
</div>
<p>When you have all the dependencies ready, you can build and install.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ make <span class="nv">PREFIX</span><span class="o">=</span><span class="s2">&quot;/usr/local&quot;</span>
$ make install <span class="nv">PREFIX</span><span class="o">=</span><span class="s2">&quot;/usr/local&quot;</span>
</pre></div>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Always build with <code class="docutils literal"><span class="pre">PREFIX</span></code> if you want to install, as it is hardcoded in the executable for module search path.
Production code should be compiled with <code class="docutils literal"><span class="pre">-DNDEBUG</span></code>.
If you build the binary with <code class="docutils literal"><span class="pre">-DNOVERBOSELOG</span></code>, it won’t be possible to turn on verbose logging; we advise packagers against using that flag.</p>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">If you build with <code class="docutils literal"><span class="pre">PREFIX</span></code>, you may need to also set the <code class="docutils literal"><span class="pre">LDFLAGS</span></code> for the libraries:</p>
</div>
<div class="highlight-bash"><div class="highlight"><pre><span></span>make <span class="nv">LDFLAGS</span><span class="o">=</span><span class="s2">&quot;-Wl,-rpath=/usr/local/lib&quot;</span> <span class="nv">PREFIX</span><span class="o">=</span><span class="s2">&quot;/usr/local&quot;</span>
</pre></div>
</div>
<p>Alternatively you can build only specific parts of the project, i.e. <code class="docutils literal"><span class="pre">library</span></code>.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ make lib
$ make lib-install
</pre></div>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Documentation is not built by default, run <code class="docutils literal"><span class="pre">make</span> <span class="pre">doc</span></code> to build it.</p>
</div>
<div class="section" id="building-with-security-compiler-flags">
<h3>Building with security compiler flags<a class="headerlink" href="#building-with-security-compiler-flags" title="Permalink to this headline"></a></h3>
<p>Knot DNS Resolver enables certain <a class="reference external" href="https://wiki.debian.org/Hardening#Notes_on_Memory_Corruption_Mitigation_Methods">security compile-time flags</a> that do not affect performance.
You can add more flags to the build by appending them to <cite>CFLAGS</cite> variable, e.g. <code class="docutils literal"><span class="pre">make</span> <span class="pre">CFLAGS=&quot;-fstack-protector&quot;</span></code>.</p>
<blockquote>
<div><table border="1" class="docutils">
<colgroup>
<col width="33%" />
<col width="33%" />
<col width="33%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Method</th>
<th class="head">Status</th>
<th class="head">Notes</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>-fstack-protector</td>
<td><em>disabled</em></td>
<td>(must be specifically enabled in CFLAGS)</td>
</tr>
<tr class="row-odd"><td>-D_FORTIFY_SOURCE=2</td>
<td><strong>enabled</strong></td>
<td>&#160;</td>
</tr>
<tr class="row-even"><td>-pie</td>
<td><strong>enabled</strong></td>
<td>enables ASLR for kresd (disable with <code class="docutils literal"><span class="pre">make</span> <span class="pre">HARDENING=no</span></code>)</td>
</tr>
<tr class="row-odd"><td>RELRO</td>
<td><strong>enabled</strong></td>
<td>full <a class="footnote-reference" href="#id11" id="id10">[5]</a></td>
</tr>
</tbody>
</table>
</div></blockquote>
<p>You can also disable linker hardening when it’s unsupported with <code class="docutils literal"><span class="pre">make</span> <span class="pre">HARDENING=no</span></code>.</p>
<table class="docutils footnote" frame="void" id="id11" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" href="#id10">[5]</a></td><td>See <a class="reference external" href="http://www.trapkit.de/tools/checksec.html">checksec.sh</a></td></tr>
</tbody>
</table>
</div>
<div class="section" id="building-for-packages">
<h3>Building for packages<a class="headerlink" href="#building-for-packages" title="Permalink to this headline"></a></h3>
<p>The build system supports <a class="reference external" href="https://www.gnu.org/prep/standards/html_node/DESTDIR.html">DESTDIR</a></p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ make install <span class="nv">DESTDIR</span><span class="o">=</span>/tmp/stage
</pre></div>
</div>
<div class="admonition tip">
<p class="first admonition-title">Tip</p>
<p class="last">There is a template for service file and AppArmor profile to help you kickstart the package.</p>
</div>
</div>
<div class="section" id="default-paths">
<h3>Default paths<a class="headerlink" href="#default-paths" title="Permalink to this headline"></a></h3>
<p>The default installation follows FHS with several custom paths for configuration and modules.
All paths are prefixed with <code class="docutils literal"><span class="pre">PREFIX</span></code> variable by default if not specified otherwise.</p>
<blockquote>
<div><table border="1" class="docutils">
<colgroup>
<col width="25%" />
<col width="25%" />
<col width="25%" />
<col width="25%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Component</th>
<th class="head">Variable</th>
<th class="head">Default</th>
<th class="head">Notes</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>library</td>
<td><code class="docutils literal"><span class="pre">LIBDIR</span></code></td>
<td><code class="docutils literal"><span class="pre">$(PREFIX)/lib</span></code></td>
<td>pkg-config is auto-generated <a class="footnote-reference" href="#id15" id="id12">[6]</a></td>
</tr>
<tr class="row-odd"><td>daemon</td>
<td><code class="docutils literal"><span class="pre">SBINDIR</span></code></td>
<td><code class="docutils literal"><span class="pre">$(PREFIX)/sbin</span></code></td>
<td>&#160;</td>
</tr>
<tr class="row-even"><td>configuration</td>
<td><code class="docutils literal"><span class="pre">ETCDIR</span></code></td>
<td><code class="docutils literal"><span class="pre">$(PREFIX)/etc/knot-resolver</span></code></td>
<td>Configuration file, templates.</td>
</tr>
<tr class="row-odd"><td>modules</td>
<td><code class="docutils literal"><span class="pre">MODULEDIR</span></code></td>
<td><code class="docutils literal"><span class="pre">$(LIBDIR)/kdns_modules</span></code></td>
<td>Runtime directory for loading dynamic modules <a class="footnote-reference" href="#id16" id="id13">[7]</a>.</td>
</tr>
<tr class="row-even"><td>trust anchor file</td>
<td><code class="docutils literal"><span class="pre">KEYFILE_DEFAULT</span></code></td>
<td><em>(none)</em></td>
<td>Path to read-only trust anchor file, which is used as fallback when no other file is specified. <a class="footnote-reference" href="#id17" id="id14">[8]</a></td>
</tr>
<tr class="row-odd"><td>work directory</td>
<td>&#160;</td>
<td>the current directory</td>
<td>Run directory for daemon. (Only relevant during run time, not e.g. during installation.)</td>
</tr>
</tbody>
</table>
</div></blockquote>
<table class="docutils footnote" frame="void" id="id15" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" href="#id12">[6]</a></td><td>The <code class="docutils literal"><span class="pre">libkres.pc</span></code> is installed in <code class="docutils literal"><span class="pre">$(LIBDIR)/pkgconfig</span></code>.</td></tr>
</tbody>
</table>
<table class="docutils footnote" frame="void" id="id16" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" href="#id13">[7]</a></td><td>The default moduledir can be changed with <cite>-m</cite> option to <cite>kresd</cite> daemon or by calling <cite>moduledir()</cite> function from lua.</td></tr>
</tbody>
</table>
<table class="docutils footnote" frame="void" id="id17" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" href="#id14">[8]</a></td><td>If no other trust anchor is specified by user, the compiled-in path <code class="docutils literal"><span class="pre">KEYFILE_DEFAULT</span></code> must contain a valid trust anchor. This is typically used by distributions which provide DNSSEC root trust anchors as part of distribution package. Users can disable the built-in trust anchor by adding <code class="docutils literal"><span class="pre">trust_anchors.keyfile_default</span> <span class="pre">=</span> <span class="pre">nil</span></code> to their configuration.</td></tr>
</tbody>
</table>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Each module is self-contained and may install additional bundled files within <code class="docutils literal"><span class="pre">$(MODULEDIR)/$(modulename)</span></code>. These files should be read-only, non-executable.</p>
</div>
</div>
<div class="section" id="static-or-dynamic">
<h3>Static or dynamic?<a class="headerlink" href="#static-or-dynamic" title="Permalink to this headline"></a></h3>
<p>By default the resolver library is built as a dynamic library with versioned ABI. You can revert to static build with <code class="docutils literal"><span class="pre">BUILDMODE</span></code> variable.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ make <span class="nv">BUILDMODE</span><span class="o">=</span>dynamic <span class="c1"># Default, create dynamic library</span>
$ make <span class="nv">BUILDMODE</span><span class="o">=</span>static  <span class="c1"># Create static library</span>
</pre></div>
</div>
<p>When the library is linked statically, it usually produces a smaller binary. However linking it to various C modules might violate ODR and increase the size.</p>
</div>
<div class="section" id="resolving-dependencies">
<h3>Resolving dependencies<a class="headerlink" href="#resolving-dependencies" title="Permalink to this headline"></a></h3>
<p>The build system relies on <a class="reference external" href="https://www.freedesktop.org/wiki/Software/pkg-config/">pkg-config</a> to find dependencies.
You can override it to force custom versions of the software by environment variables.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ make <span class="nv">libknot_CFLAGS</span><span class="o">=</span><span class="s2">&quot;-I/opt/include&quot;</span> <span class="nv">libknot_LIBS</span><span class="o">=</span><span class="s2">&quot;-L/opt/lib -lknot -ldnssec&quot;</span>
</pre></div>
</div>
<p>Optional dependencies may be disabled as well using <code class="docutils literal"><span class="pre">HAS_x=yes|no</span></code> variable.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ make <span class="nv">HAS_go</span><span class="o">=</span>no <span class="nv">HAS_cmocka</span><span class="o">=</span>no
</pre></div>
</div>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">If the dependencies lie outside of library search path, you need to add them somehow.
Try <code class="docutils literal"><span class="pre">LD_LIBRARY_PATH</span></code> on Linux/BSD, and <code class="docutils literal"><span class="pre">DYLD_FALLBACK_LIBRARY_PATH</span></code> on OS X.
Otherwise you need to add the locations to linker search path.</p>
</div>
<p>Several dependencies may not be in the packages yet, the script pulls and installs all dependencies in a chroot.
You can avoid rebuilding dependencies by specifying <cite>BUILD_IGNORE</cite> variable, see the <a class="reference external" href="https://registry.hub.docker.com/u/cznic/knot-resolver/dockerfile/">Dockerfile</a> for example.
Usually you only really need to rebuild <a class="reference external" href="https://gitlab.labs.nic.cz/knot/knot-dns">libknot</a>.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ <span class="nb">export</span> <span class="nv">FAKEROOT</span><span class="o">=</span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">HOME</span><span class="si">}</span><span class="s2">/.local&quot;</span>
$ <span class="nb">export</span> <span class="nv">PKG_CONFIG_PATH</span><span class="o">=</span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">FAKEROOT</span><span class="si">}</span><span class="s2">/lib/pkgconfig&quot;</span>
$ <span class="nb">export</span> <span class="nv">BUILD_IGNORE</span><span class="o">=</span><span class="s2">&quot;...&quot;</span> <span class="c1"># Ignore installed dependencies</span>
$ ./scripts/bootstrap-depends.sh <span class="si">${</span><span class="nv">FAKEROOT</span><span class="si">}</span>
</pre></div>
</div>
</div>
<div class="section" id="building-extras">
<h3>Building extras<a class="headerlink" href="#building-extras" title="Permalink to this headline"></a></h3>
<p>The project can be built with code coverage tracking using the <code class="docutils literal"><span class="pre">COVERAGE=1</span></code> variable.</p>
<p>The <cite>make coverage</cite> target gathers both gcov code coverage for C files, and <a class="reference external" href="https://keplerproject.github.io/luacov/">luacov</a> code coverage for Lua files and merges it for analysis. It requires <a class="reference external" href="http://ltp.sourceforge.net/coverage/lcov.php">lcov</a> to be installed.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ make coverage
</pre></div>
</div>
</div>
<div class="section" id="running-unit-and-integration-tests">
<h3>Running unit and integration tests<a class="headerlink" href="#running-unit-and-integration-tests" title="Permalink to this headline"></a></h3>
<p>The linter requires <a class="reference external" href="http://luacheck.readthedocs.io">luacheck</a> and <a class="reference external" href="http://clang.llvm.org/extra/clang-tidy/index.html">clang-tidy</a> and is executed by <code class="docutils literal"><span class="pre">make</span> <span class="pre">lint</span></code>.
The unit tests require <a class="reference external" href="https://cmocka.org/">cmocka</a> and are executed by <code class="docutils literal"><span class="pre">make</span> <span class="pre">check</span></code>.
Tests for the dnstap module need go and are executed by <code class="docutils literal"><span class="pre">make</span> <span class="pre">ckeck-dnstap</span></code>.</p>
<p>The integration tests use Deckard, the <a class="reference external" href="deckard">DNS test harness</a>.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$  make check-integration
</pre></div>
</div>
<p>Note that the daemon and modules must be installed first before running integration tests, the reason is that the daemon
is otherwise unable to find and load modules.</p>
<p>Read the <a class="reference external" href="deckard_doc">documentation</a> for more information about requirements, how to run it and extend it.</p>
</div>
</div>
<div class="section" id="getting-docker-image">
<h2>Getting Docker image<a class="headerlink" href="#getting-docker-image" title="Permalink to this headline"></a></h2>
<p>Docker images require only either Linux or a Linux VM (see <a class="reference external" href="http://boot2docker.io/">boot2docker</a> on OS X).</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ docker run cznic/knot-resolver
</pre></div>
</div>
<p>See the <a class="reference external" href="https://hub.docker.com/r/cznic/knot-resolver">Docker images</a> page for more information and options.
You can hack on the container by changing the container entrypoint to shell like:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ docker run -it --entrypoint<span class="o">=</span>/bin/bash cznic/knot-resolver
</pre></div>
</div>
<div class="admonition tip">
<p class="first admonition-title">Tip</p>
<p class="last">You can build the Docker image yourself with <code class="docutils literal"><span class="pre">docker</span> <span class="pre">build</span> <span class="pre">-t</span> <span class="pre">knot-resolver</span> <span class="pre">scripts</span></code>.</p>
</div>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h3><a href="index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Building project</a><ul>
<li><a class="reference internal" href="#installing-from-packages">Installing from packages</a></li>
<li><a class="reference internal" href="#platform-considerations">Platform considerations</a></li>
<li><a class="reference internal" href="#requirements">Requirements</a><ul>
<li><a class="reference internal" href="#packaged-dependencies">Packaged dependencies</a></li>
</ul>
</li>
<li><a class="reference internal" href="#building-from-sources">Building from sources</a><ul>
<li><a class="reference internal" href="#building-with-security-compiler-flags">Building with security compiler flags</a></li>
<li><a class="reference internal" href="#building-for-packages">Building for packages</a></li>
<li><a class="reference internal" href="#default-paths">Default paths</a></li>
<li><a class="reference internal" href="#static-or-dynamic">Static or dynamic?</a></li>
<li><a class="reference internal" href="#resolving-dependencies">Resolving dependencies</a></li>
<li><a class="reference internal" href="#building-extras">Building extras</a></li>
<li><a class="reference internal" href="#running-unit-and-integration-tests">Running unit and integration tests</a></li>
</ul>
</li>
<li><a class="reference internal" href="#getting-docker-image">Getting Docker image</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="modules.html"
                        title="previous chapter">Knot DNS Resolver modules</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="lib.html"
                        title="next chapter">Knot DNS Resolver library</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="_sources/build.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3>Quick search</h3>
    <form class="search" action="search.html" method="get">
      <div><input type="text" name="q" /></div>
      <div><input type="submit" value="Go" /></div>
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="lib.html" title="Knot DNS Resolver library"
             >next</a> |</li>
        <li class="right" >
          <a href="modules.html" title="Knot DNS Resolver modules"
             >previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="index.html">Knot DNS Resolver 2.1.1 documentation</a> &#187;</li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2014-2018 CZ.NIC labs.
      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.6.7.
    </div>
  </body>
</html>