Try to fix build failure with ImageMagick 7 on arch.
[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 /* ImageMagick */
29 #ifdef DCPOMATIC_MAGICKCORE_MAGICK
30 #include <magick/MagickCore.h>
31 #else
32 #include <MagickCore/MagickCore.h>
33 #endif
34 #else
35 /* GraphicsMagick */
36 #include <magick/common.h>
37 #include <magick/magick_config.h>
38 #endif
39 #include <magick/version.h>
40 extern "C" {
41 #include <libavcodec/avcodec.h>
42 #include <libavformat/avformat.h>
43 #include <libswscale/swscale.h>
44 #include <libavfilter/avfiltergraph.h>
45 #include <libavutil/pixfmt.h>
46 }
47 #include <boost/thread.hpp>
48
49 #include "i18n.h"
50
51 #define LOG_GENERAL(...) log->log (String::compose (__VA_ARGS__), LogEntry::TYPE_GENERAL);
52 #define LOG_GENERAL_NC(...) log->log (__VA_ARGS__, LogEntry::TYPE_GENERAL);
53
54 using std::string;
55 using std::list;
56 using std::pair;
57 using boost::shared_ptr;
58
59 /** @param v Version as used by FFmpeg.
60  *  @return A string representation of v.
61  */
62 static
63 string
64 ffmpeg_version_to_string (int v)
65 {
66         char buffer[64];
67         snprintf (buffer, sizeof(buffer), "%d.%d.%d", ((v & 0xff0000) >> 16), ((v & 0xff00) >> 8), (v & 0xff));
68         return buffer;
69 }
70
71 /** Return a user-readable string summarising the versions of our dependencies */
72 static
73 string
74 dependency_version_summary ()
75 {
76         char buffer[512];
77         snprintf (
78                 buffer, sizeof(buffer), "libavcodec %s, libavfilter %s, libavformat %s, libavutil %s, libswscale %s, %s, libssh %s, libdcp %s git %s",
79                 ffmpeg_version_to_string(avcodec_version()).c_str(),
80                 ffmpeg_version_to_string(avfilter_version()).c_str(),
81                 ffmpeg_version_to_string(avformat_version()).c_str(),
82                 ffmpeg_version_to_string(avutil_version()).c_str(),
83                 ffmpeg_version_to_string(swscale_version()).c_str(),
84                 MagickVersion,
85                 ssh_version(0),
86                 dcp::version, dcp::git_commit
87                 );
88
89         return buffer;
90 }
91
92 list<string>
93 environment_info ()
94 {
95         list<string> info;
96
97         info.push_back (String::compose ("DCP-o-matic %1 git %2 using %3", dcpomatic_version, dcpomatic_git_commit, dependency_version_summary()));
98
99         {
100                 char buffer[128];
101                 gethostname (buffer, sizeof (buffer));
102                 info.push_back (String::compose ("Host name %1", &buffer[0]));
103         }
104
105 #ifdef DCPOMATIC_DEBUG
106         info.push_back ("DCP-o-matic built in debug mode.");
107 #else
108         info.push_back ("DCP-o-matic built in optimised mode.");
109 #endif
110 #ifdef LIBDCP_DEBUG
111         info.push_back ("libdcp built in debug mode.");
112 #else
113         info.push_back ("libdcp built in optimised mode.");
114 #endif
115
116 #ifdef DCPOMATIC_WINDOWS
117         OSVERSIONINFO os_info;
118         os_info.dwOSVersionInfoSize = sizeof (os_info);
119         GetVersionEx (&os_info);
120         info.push_back (
121                 String::compose (
122                         "Windows version %1.%2.%3",
123                         (int) os_info.dwMajorVersion, (int) os_info.dwMinorVersion, (int) os_info.dwBuildNumber
124                         )
125                 );
126         if (os_info.dwMajorVersion == 5 && os_info.dwMinorVersion == 0) {
127                 info.push_back ("Windows 2000");
128         } else if (os_info.dwMajorVersion == 5 && os_info.dwMinorVersion == 1) {
129                 info.push_back ("Windows XP");
130         } else if (os_info.dwMajorVersion == 5 && os_info.dwMinorVersion == 2) {
131                 info.push_back ("Windows XP 64-bit or Windows Server 2003");
132         } else if (os_info.dwMajorVersion == 6 && os_info.dwMinorVersion == 0) {
133                 info.push_back ("Windows Vista or Windows Server 2008");
134         } else if (os_info.dwMajorVersion == 6 && os_info.dwMinorVersion == 1) {
135                 info.push_back ("Windows 7 or Windows Server 2008");
136         } else if (os_info.dwMajorVersion == 6 && (os_info.dwMinorVersion == 2 || os_info.dwMinorVersion == 3)) {
137                 info.push_back ("Windows 8 or Windows Server 2012");
138         } else if (os_info.dwMajorVersion == 10 && os_info.dwMinorVersion == 0) {
139                 info.push_back ("Windows 10 or Windows Server 2016");
140         }
141 #endif
142
143 #if __GNUC__
144 #if __x86_64__
145         info.push_back ("Built for 64-bit");
146 #else
147         info.push_back ("Built for 32-bit");
148 #endif
149 #endif
150
151         info.push_back (String::compose ("CPU: %1, %2 processors", cpu_info(), boost::thread::hardware_concurrency ()));
152         list<pair<string, string> > const m = mount_info ();
153         for (list<pair<string, string> >::const_iterator i = m.begin(); i != m.end(); ++i) {
154                 info.push_back (String::compose ("Mount: %1 %2", i->first, i->second));
155         }
156
157         return info;
158 }