]> git.ipfire.org Git - thirdparty/pdns.git/blame - pdns/version.cc
Revert "Bail out when no Context library is available"
[thirdparty/pdns.git] / pdns / version.cc
CommitLineData
ba1a571d 1/*
6edbf68a
PL
2 * This file is part of PowerDNS or dnsdist.
3 * Copyright -- PowerDNS.COM B.V. and its contributors
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
8 *
9 * In addition, for the avoidance of any doubt, permission is granted to
10 * link this program with OpenSSL and to (re)distribute the binaries
11 * produced as the result of such linking.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 */
870a0fe4
AT
22#ifdef HAVE_CONFIG_H
23#include "config.h"
24#endif
ba1a571d
CH
25#include "logger.hh"
26#include "version.hh"
ba1a571d 27
3e135495 28static ProductType productType;
ba1a571d
CH
29
30string compilerVersion()
31{
32#if defined(__clang__)
e4a25816 33 return string("clang " __clang_version__ );
ba1a571d 34#elif defined(__GNUC__)
e4a25816 35 return string("gcc " __VERSION__ );
253cde09 36#else // add other compilers here
ba1a571d 37 return string("Unknown compiler");
253cde09 38#endif
ba1a571d
CH
39}
40
3e135495
CH
41// Human-readable product name
42string productName() {
43 switch (productType) {
44 case ProductAuthoritative:
45 return "PowerDNS Authoritative Server";
46 case ProductRecursor:
47 return "PowerDNS Recursor";
48 };
c4c9bcf6 49 return "Unknown";
3e135495
CH
50}
51
77b9f5ff 52string getPDNSVersion()
53{
ea1a7c39 54 return VERSION;
77b9f5ff 55}
56
3e135495
CH
57// REST API product type
58string productTypeApiType() {
59 switch (productType) {
60 case ProductAuthoritative:
61 return "authoritative";
62 case ProductRecursor:
63 return "recursor";
64 };
c4c9bcf6 65 return "unknown";
3e135495
CH
66}
67
ba1a571d
CH
68void showProductVersion()
69{
79fb4337 70 g_log<<Logger::Warning<<productName()<<" "<< VERSION << " (C) 2001-2019 "
ea1a7c39 71 "PowerDNS.COM BV" << endl;
e6a9dde5 72 g_log<<Logger::Warning<<"Using "<<(sizeof(unsigned long)*8)<<"-bits mode. "
5e6a3d93
PL
73 "Built using " << compilerVersion()
74#ifndef REPRODUCIBLE
75 <<" on " __DATE__ " " __TIME__ " by " BUILD_HOST
76#endif
77 <<"."<< endl;
e6a9dde5 78 g_log<<Logger::Warning<<"PowerDNS comes with ABSOLUTELY NO WARRANTY. "
ba1a571d
CH
79 "This is free software, and you are welcome to redistribute it "
80 "according to the terms of the GPL version 2." << endl;
81}
82
3613a51c
CH
83void showBuildConfiguration()
84{
e6a9dde5 85 g_log<<Logger::Warning<<"Features: "<<
21a8834a
KM
86#ifdef HAVE_LIBDECAF
87 "decaf " <<
fcc5d084 88#endif
9bdb77fa
CH
89#ifdef HAVE_BOOST_CONTEXT
90 "fcontext " <<
91#endif
92#ifdef HAVE_LIBCRYPTO_ECDSA
622644f7 93 "libcrypto-ecdsa " <<
9bdb77fa
CH
94#endif
95#ifdef HAVE_LIBCRYPTO_ED25519
622644f7 96 "libcrypto-ed25519 " <<
9bdb77fa
CH
97#endif
98#ifdef HAVE_LIBCRYPTO_ED448
622644f7 99 "libcrypto-ed448 " <<
9bdb77fa
CH
100#endif
101#ifdef HAVE_LIBCRYPTO_EDDSA
622644f7 102 "libcrypto-eddsa " <<
9bdb77fa 103#endif
3613a51c
CH
104#ifdef HAVE_LIBDL
105 "libdl " <<
106#endif
a8e771e5
PL
107#ifdef HAVE_GEOIP
108 "libgeoip " <<
109#endif
110#ifdef HAVE_MMDB
111 "libmaxminddb " <<
112#endif
3613a51c
CH
113#ifdef HAVE_LUA
114 "lua " <<
115#endif
9bdb77fa
CH
116#ifdef HAVE_LUA_RECORDS
117 "lua-records " <<
118#endif
119#ifdef NOD_ENABLED
120 "nod " <<
121#endif
122#ifdef HAVE_P11KIT1
123 "PKCS#11 " <<
124#endif
125#ifdef HAVE_PROTOBUF
fc7f729f
OM
126"protobuf " <<
127#endif
128#ifdef HAVE_FSTRM
129"dnstap-framestream " <<
9bdb77fa 130#endif
7404a2bd 131#ifdef REMOTEBACKEND_ZEROMQ
13f34f2e 132 "remotebackend-zeromq " <<
3613a51c 133#endif
9bdb77fa
CH
134#ifdef HAVE_NET_SNMP
135 "snmp " <<
136#endif
137#ifdef HAVE_LIBSODIUM
138 "sodium " <<
91bc549f 139#endif
3613a51c
CH
140#ifdef VERBOSELOG
141 "verboselog" <<
142#endif
143 endl;
144#ifdef PDNS_MODULES
145 // Auth only
e6a9dde5 146 g_log<<Logger::Warning<<"Built-in modules: "<<PDNS_MODULES<<endl;
3613a51c 147#endif
0060b613 148#ifdef PDNS_CONFIG_ARGS
4007a326
RK
149#define double_escape(s) #s
150#define escape_quotes(s) double_escape(s)
e6a9dde5 151 g_log<<Logger::Warning<<"Configured with: "<<escape_quotes(PDNS_CONFIG_ARGS)<<endl;
4007a326
RK
152#undef escape_quotes
153#undef double_escape
0060b613 154#endif
3613a51c
CH
155}
156
ba1a571d
CH
157string fullVersionString()
158{
05afd14a 159 ostringstream s;
ea1a7c39 160 s<<productName()<<" " VERSION;
5e6a3d93
PL
161#ifndef REPRODUCIBLE
162 s<<" (built " __DATE__ " " __TIME__ " by " BUILD_HOST ")";
163#endif
ba1a571d
CH
164 return s.str();
165}
166
3e135495
CH
167void versionSetProduct(ProductType pt)
168{
169 productType = pt;
170}
171
172ProductType versionGetProduct()
ba1a571d 173{
3e135495 174 return productType;
ba1a571d 175}