No-op; fix GPL address and use the explicit-program-name version.
[dcpomatic.git] / src / lib / environment_info.cc
1 /*
2     Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
6     DCP-o-matic is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     DCP-o-matic is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
18
19 */
20
21 #include "log.h"
22 #include "compose.hpp"
23 #include "version.h"
24 #include "cross.h"
25 #include <dcp/version.h>
26 #include <libssh/libssh.h>
27 #ifdef DCPOMATIC_IMAGE_MAGICK
28 #include <magick/MagickCore.h>
29 #else
30 #include <magick/common.h>
31 #include <magick/magick_config.h>
32 #endif
33 #include <magick/version.h>
34 extern "C" {
35 #include <libavcodec/avcodec.h>
36 #include <libavformat/avformat.h>
37 #include <libswscale/swscale.h>
38 #include <libavfilter/avfiltergraph.h>
39 #include <libavutil/pixfmt.h>
40 }
41 #include <boost/thread.hpp>
42
43 #include "i18n.h"
44
45 #define LOG_GENERAL(...) log->log (String::compose (__VA_ARGS__), LogEntry::TYPE_GENERAL);
46 #define LOG_GENERAL_NC(...) log->log (__VA_ARGS__, LogEntry::TYPE_GENERAL);
47
48 using std::string;
49 using std::list;
50 using std::pair;
51 using boost::shared_ptr;
52
53 /** @param v Version as used by FFmpeg.
54  *  @return A string representation of v.
55  */
56 static
57 string
58 ffmpeg_version_to_string (int v)
59 {
60         SafeStringStream s;
61         s << ((v & 0xff0000) >> 16) << N_(".") << ((v & 0xff00) >> 8) << N_(".") << (v & 0xff);
62         return s.str ();
63 }
64
65
66 /** Return a user-readable string summarising the versions of our dependencies */
67 static
68 string
69 dependency_version_summary ()
70 {
71         SafeStringStream s;
72         s << N_("libavcodec ") << ffmpeg_version_to_string (avcodec_version()) << N_(", ")
73           << N_("libavfilter ") << ffmpeg_version_to_string (avfilter_version()) << N_(", ")
74           << N_("libavformat ") << ffmpeg_version_to_string (avformat_version()) << N_(", ")
75           << N_("libavutil ") << ffmpeg_version_to_string (avutil_version()) << N_(", ")
76           << N_("libswscale ") << ffmpeg_version_to_string (swscale_version()) << N_(", ")
77           << MagickVersion << N_(", ")
78           << N_("libssh ") << ssh_version (0) << N_(", ")
79           << N_("libdcp ") << dcp::version << N_(" git ") << dcp::git_commit;
80
81         return s.str ();
82 }
83
84 list<string>
85 environment_info ()
86 {
87         list<string> info;
88
89         info.push_back (String::compose ("DCP-o-matic %1 git %2 using %3", dcpomatic_version, dcpomatic_git_commit, dependency_version_summary()));
90
91         {
92                 char buffer[128];
93                 gethostname (buffer, sizeof (buffer));
94                 info.push_back (String::compose ("Host name %1", buffer));
95         }
96
97 #ifdef DCPOMATIC_DEBUG
98         info.push_back ("DCP-o-matic built in debug mode.");
99 #else
100         info.push_back ("DCP-o-matic built in optimised mode.");
101 #endif
102 #ifdef LIBDCP_DEBUG
103         info.push_back ("libdcp built in debug mode.");
104 #else
105         info.push_back ("libdcp built in optimised mode.");
106 #endif
107
108 #ifdef DCPOMATIC_WINDOWS
109         OSVERSIONINFO os_info;
110         os_info.dwOSVersionInfoSize = sizeof (os_info);
111         GetVersionEx (&os_info);
112         info.push_back (
113                 String::compose (
114                         "Windows version %1.%2.%3 SP %4",
115                         os_info.dwMajorVersion, os_info.dwMinorVersion, os_info.dwBuildNumber, os_info.szCSDVersion
116                         )
117                 );
118 #endif
119
120 #if __GNUC__
121 #if __x86_64__
122         info.push_back ("Built for 64-bit");
123 #else
124         info.push_back ("Built for 32-bit");
125 #endif
126 #endif
127
128         info.push_back (String::compose ("CPU: %1, %2 processors", cpu_info(), boost::thread::hardware_concurrency ()));
129         list<pair<string, string> > const m = mount_info ();
130         for (list<pair<string, string> >::const_iterator i = m.begin(); i != m.end(); ++i) {
131                 info.push_back (String::compose ("Mount: %1 %2", i->first, i->second));
132         }
133
134         return info;
135 }