Browse code

clamconf: print information about platform and build.

This should help diagnose bugs faster, since the user only needs to include
the output of 'clamconf -n' to get most of the needed info.

Török Edvin authored on 2010/04/19 23:12:34
Showing 5 changed files
... ...
@@ -1,3 +1,7 @@
1
+Mon Apr 19 17:12:06 EEST 2010 (edwin)
2
+-------------------------------------
3
+ * clamconf: print information about platform and build.
4
+
1 5
 Thu Apr 15 20:04:16 EEST 2010 (edwin)
2 6
 -------------------------------------
3 7
  * libclamav/c++/configure: disable gcc 3.4.6 by default, you can still use it with --enable-llvm (bb #1935).
... ...
@@ -28,6 +28,9 @@ clamconf_SOURCES = \
28 28
     clamconf.c
29 29
 
30 30
 DEFS = @DEFS@ -DCL_NOTHREADS
31
-AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav
31
+AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav\
32
+	      -DBUILD_CPPFLAGS="\"$(CPPFLAGS)\"" -DBUILD_CFLAGS="\"$(CFLAGS)\""\
33
+	      -DBUILD_CXXFLAGS="\"$(CXXFLAGS)\"" -DBUILD_LDFLAGS="\"$(LDFLAGS)\""\
34
+	      -DBUILD_CONFIGURE_FLAGS="\"$(BUILD_CONFIGURE_FLAGS)\""
32 35
 LIBS = $(top_builddir)/libclamav/libclamav.la @CLAMD_LIBS@ @THREAD_LIBS@
33 36
 CLEANFILES=*.gcda *.gcno
... ...
@@ -27,6 +27,10 @@
27 27
 #include <unistd.h>
28 28
 #endif
29 29
 #include <time.h>
30
+#ifdef HAVE_UNAME_SYSCALL
31
+#include <sys/utsname.h>
32
+#endif
33
+#include <zlib.h>
30 34
 
31 35
 #include "shared/optparser.h"
32 36
 #include "shared/misc.h"
... ...
@@ -35,6 +39,7 @@
35 35
 #include "libclamav/clamav.h"
36 36
 #include "libclamav/others.h"
37 37
 #include "libclamav/bytecode.h"
38
+#include "target.h"
38 39
 
39 40
 #ifndef _WIN32
40 41
 extern const struct clam_option *clam_options;
... ...
@@ -205,6 +210,65 @@ static void help(void)
205 205
     return;
206 206
 }
207 207
 
208
+static void print_platform(void)
209
+{
210
+    printf("\nPlatform information\n--------------------\n");
211
+#ifdef HAVE_UNAME_SYSCALL
212
+    struct utsname name;
213
+    uname(&name);
214
+    printf("uname: %s %s %s %s\n", name.sysname, name.release, name.version,
215
+	   name.machine);
216
+#endif
217
+    printf("OS: "TARGET_OS_TYPE", ARCH: "TARGET_ARCH_TYPE", CPU: "TARGET_CPU_TYPE"\n");
218
+
219
+#ifdef C_LINUX
220
+    if (!access("/usr/bin/lsb_release", X_OK)) {
221
+	fputs("Full OS version: ", stdout);
222
+	fflush(stdout);
223
+	system("/usr/bin/lsb_release -d -s");
224
+    }
225
+#else
226
+    /* e.g. Solaris */
227
+    if (!access("/etc/release", R_OK)) {
228
+	char buf[1024];
229
+	FILE *f = fopen("/etc/release", "r");
230
+	fgets(buf, sizeof(buf), f);
231
+	printf("Full OS version: %s", buf);
232
+    }
233
+#endif
234
+
235
+#ifdef ZLIB_VERNUM
236
+    printf("zlib version: %s (%s), compile flags: %02x\n",
237
+	   ZLIB_VERSION, zlibVersion(), zlibCompileFlags());
238
+#else
239
+    /* old zlib w/o zlibCompileFlags() */
240
+    printf("zlib version: %s (%s)\n",
241
+	   ZLIB_VERSION, zlibVersion());
242
+#endif
243
+}
244
+
245
+static void print_build(void)
246
+{
247
+    printf("\nBuild information\n-----------------\n");
248
+    /* Try to print information about some commonly used compilers */
249
+#ifdef __GNUC__
250
+    printf("GNU C: %s (%u.%u.%u)\n", __VERSION__, __GNUC__, __GNUC_MINOR__,
251
+	   __GNUC_PATCHLEVEL__);
252
+#endif
253
+#ifdef __INTEL_COMPILER
254
+    printf("Intel Compiler %u\n", __INTEL_COMPILER);
255
+#endif
256
+#ifdef _MSC_VER
257
+    printf("Microsoft Visual C++ %u\n", _MSC_VER);
258
+#endif
259
+#ifdef __SUNPRO_C
260
+    printf("Sun studio %u\n", __SUNPRO_C);
261
+#endif
262
+    printf("CPPFLAGS: %s\nCFLAGS: %s\nCXXFLAGS: %s\nLDFLAGS: %s\nConfigure: %s\n",
263
+	   BUILD_CPPFLAGS, BUILD_CFLAGS, BUILD_CXXFLAGS, BUILD_LDFLAGS,
264
+	   BUILD_CONFIGURE_FLAGS);
265
+}
266
+
208 267
 int main(int argc, char **argv)
209 268
 {
210 269
 	const char *dir;
... ...
@@ -328,5 +392,7 @@ int main(int argc, char **argv)
328 328
 	    }
329 329
 	}
330 330
     }
331
+    print_platform();
332
+    print_build();
331 333
     return 0;
332 334
 }
... ...
@@ -430,6 +430,10 @@ if test "$enable_experimental" = "yes"; then
430 430
   VERSION_SUFFIX="$VERSION_SUFFIX-exp"
431 431
 fi
432 432
 
433
+build_configure_args=`echo "$ac_configure_args" | sed -e 's/[\"]//g'`
434
+AC_SUBST([BUILD_CONFIGURE_FLAGS], [$build_configure_args])
435
+
436
+AX_CHECK_UNAME_SYSCALL
433 437
 AC_CHECK_LIB([socket], [bind], [LIBS="$LIBS -lsocket"; CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -lsocket"; FRESHCLAM_LIBS="$FRESHCLAM_LIBS -lsocket"; CLAMD_LIBS="$CLAMD_LIBS -lsocket"])
434 438
 AC_SEARCH_LIBS([gethostent],[nsl], [(LIBS="$LIBS -lnsl"; CLAMAV_MILTER_LIBS="$CLAMAV_MILTER_LIBS -lnsl"; FRESHCLAM_LIBS="$FRESHCLAM_LIBS -lnsl"; CLAMD_LIBS="$CLAMD_LIBS -lnsl")])
435 439
 
436 440
new file mode 100644
... ...
@@ -0,0 +1,39 @@
0
+# ===========================================================================
1
+#  http://www.gnu.org/software/autoconf-archive/ax_check_uname_syscall.html
2
+# ===========================================================================
3
+#
4
+# SYNOPSIS
5
+#
6
+#   AX_CHECK_UNAME_SYSCALL
7
+#
8
+# DESCRIPTION
9
+#
10
+#   Check that the POSIX compliant uname(2) call works properly.
11
+#
12
+# LICENSE
13
+#
14
+#   Copyright (c) 2008 Bruce Korb <bkorb@gnu.org>
15
+#
16
+#   Copying and distribution of this file, with or without modification, are
17
+#   permitted in any medium without royalty provided the copyright notice
18
+#   and this notice are preserved. This file is offered as-is, without any
19
+#   warranty.
20
+
21
+#serial 5
22
+
23
+AU_ALIAS([AG_CHECK_UNAME_SYSCALL], [AX_CHECK_UNAME_SYSCALL])
24
+AC_DEFUN([AX_CHECK_UNAME_SYSCALL],[
25
+  AC_MSG_CHECKING([whether uname(2) is POSIX])
26
+  AC_CACHE_VAL([ax_cv_uname_syscall],[
27
+  AC_TRY_RUN([#include <sys/utsname.h>
28
+int main() { struct utsname unm;
29
+return uname( &unm ); }],[ax_cv_uname_syscall=yes],[ax_cv_uname_syscall=no],[ax_cv_uname_syscall=no]
30
+  ) # end of TRY_RUN]) # end of CACHE_VAL
31
+
32
+  AC_MSG_RESULT([$ax_cv_uname_syscall])
33
+  if test x$ax_cv_uname_syscall = xyes
34
+  then
35
+    AC_DEFINE(HAVE_UNAME_SYSCALL, 1,
36
+       [Define this if uname(2) is POSIX])
37
+  fi
38
+]) # end of AC_DEFUN of AX_CHECK_UNAME_SYSCALL