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