diff --git a/clamav-config.h.in b/clamav-config.h.in index ffe2ad788..5b9339d3d 100644 --- a/clamav-config.h.in +++ b/clamav-config.h.in @@ -138,9 +138,6 @@ /* Define to 1 if you have the `closedir' function. */ #undef HAVE_CLOSEDIR -/* ancillary data style fd pass */ -#undef HAVE_CONTROL_IN_MSGHDR - /* Define to 1 if you have the `ctime_r' function. */ #undef HAVE_CTIME_R diff --git a/configure b/configure index 22a3c9b6f..8a9306064 100755 --- a/configure +++ b/configure @@ -17800,10 +17800,6 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_have_control_in_msghdr" >&5 $as_echo "$ac_cv_have_control_in_msghdr" >&6; } if test "x$ac_cv_have_control_in_msghdr" = "xyes" ; then - -$as_echo "#define HAVE_CONTROL_IN_MSGHDR 1" >>confdefs.h - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking BSD 4.4 / RFC2292 style fd passing" >&5 $as_echo_n "checking BSD 4.4 / RFC2292 style fd passing... " >&6; } # Check whether --enable-fdpassing was given. diff --git a/m4/fdpassing.m4 b/m4/fdpassing.m4 index 09ce48d26..8a3ad1afe 100644 --- a/m4/fdpassing.m4 +++ b/m4/fdpassing.m4 @@ -179,8 +179,6 @@ return 0; ], [ ac_cv_have_control_in_msghdr="yes" ], [ ac_cv_have_control_in_msghdr="no" ]) ]) if test "x$ac_cv_have_control_in_msghdr" = "xyes" ; then - AC_DEFINE([HAVE_CONTROL_IN_MSGHDR],1,[ancillary data style fd pass]) - dnl Check whether FD passing works AC_MSG_CHECKING([BSD 4.4 / RFC2292 style fd passing]) AC_ARG_ENABLE([fdpassing],[ --disable-fdpassing don't build file descriptor passing support], diff --git a/win32/update-win32.pl b/win32/update-win32.pl new file mode 100644 index 000000000..2afa95282 --- /dev/null +++ b/win32/update-win32.pl @@ -0,0 +1,394 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use XML::Twig; + + + +######################################################### +# HACK HERE HACK HERE HACK HERE HACK HERE HACK HERE # +######################################################### + +use constant DEBUG => 0; + +# CLAMAV-CONFIG.H MACROES +# - Set to the proper win32 value or -1 to undef - # +my %CONF = ( + 'AC_APPLE_UNIVERSAL_BUILD' => -1, + 'ANONYMOUS_MAP' => -1, + 'BIND_8_COMPAT' => -1, + 'BUILD_CLAMD' => '1', + 'CLAMAVGROUP' => '"clamav"', + 'CLAMAVUSER' => '"clamav"', + 'CLAMUKO' => -1, + 'CL_DEBUG' => -1, + 'CL_EXPERIMENTAL' => -1, + 'CL_THREAD_SAFE' => '1', + 'CONFDIR' => '"C:\\\\ClamAV"', + 'CURSES_INCLUDE' => -1, + 'C_AIX' => -1, + 'C_BEOS' => -1, + 'C_BIGSTACK' => -1, + 'C_BSD' => -1, + 'C_DARWIN' => -1, + 'C_GNU_HURD' => -1, + 'C_HPUX' => -1, + 'C_INTERIX' => -1, + 'C_IRIX' => -1, + 'C_KFREEBSD_GNU' => -1, + 'C_LINUX' => -1, + 'C_OS2' => -1, + 'C_OSF' => -1, + 'C_QNX6' => -1, + 'C_SOLARIS' => -1, + 'DATADIR' => '"C:\\\\ClamAV\\\\db"', + 'DEFAULT_FD_SETSIZE' => '1024', + 'FDPASS_NEED_XOPEN' => -1, + 'FILEBUFF' => '8192', + 'FPU_WORDS_BIGENDIAN' => '0', + 'FRESHCLAM_DNS_FIX' => -1, + 'FRESHCLAM_NO_CACHE' => -1, + 'HAVE_ARGZ_ADD' => -1, + 'HAVE_ARGZ_APPEND' => -1, + 'HAVE_ARGZ_COUNT' => -1, + 'HAVE_ARGZ_CREATE_SEP' => -1, + 'HAVE_ARGZ_H' => -1, + 'HAVE_ARGZ_INSERT' => -1, + 'HAVE_ARGZ_NEXT' => -1, + 'HAVE_ARGZ_STRINGIFY' => -1, + 'HAVE_ATTRIB_ALIGNED' => -1, + 'HAVE_ATTRIB_PACKED' => -1, + 'HAVE_BZLIB_H' => '1', + 'HAVE_CLOSEDIR' => '1', + 'HAVE_CTIME_R' => '1', + 'HAVE_CTIME_R_2' => '1', + 'HAVE_CTIME_R_3' => -1, + 'HAVE_DECL_CYGWIN_CONV_PATH' => -1, + 'HAVE_DIRENT_H' => '1', + 'HAVE_DLD' => -1, + 'HAVE_DLD_H' => -1, + 'HAVE_DLERROR' => -1, + 'HAVE_DLFCN_H' => '1', + 'HAVE_DL_H' => -1, + 'HAVE_DYLD' => -1, + 'HAVE_ERROR_T' => -1, + 'HAVE_FD_PASSING' => -1, + 'HAVE_FSEEKO' => '1', + 'HAVE_GETADDRINFO' => '1', + 'HAVE_GETPAGESIZE' => '1', + 'HAVE_GRP_H' => -1, + 'HAVE_ICONV' => -1, + 'HAVE_INET_NTOP' => '1', + 'HAVE_INITGROUPS' => -1, + 'HAVE_INTTYPES_H' => -1, + 'HAVE_IN_ADDR_T' => -1, + 'HAVE_IN_PORT_T' => '1', + 'HAVE_LIBCHECK' => -1, + 'HAVE_LIBDL' => '1', + 'HAVE_LIBDLLOADER' => '1', + 'HAVE_LIBMILTER_MFAPI_H' => -1, + 'HAVE_LIBNCURSES' => -1, + 'HAVE_LIBPDCURSES' => -1, + 'HAVE_LIBZ' => '1', + 'HAVE_LIMITS_H' => '1', + 'HAVE_LTDL' => '1', + 'HAVE_MACH_O_DYLD_H' => -1, + 'HAVE_MADVISE' => -1, + 'HAVE_MALLINFO' => -1, + 'HAVE_MALLOC_H' => '1', + 'HAVE_MEMCPY' => '1', + 'HAVE_MEMORY_H' => '1', + 'HAVE_MKSTEMP' => '1', + 'HAVE_MMAP' => -1, + 'HAVE_NDIR_H' => -1, + 'HAVE_OPENDIR' => '1', + 'HAVE_POLL' => '1', + 'HAVE_POLL_H' => '1', + 'HAVE_PRAGMA_PACK' => '1', + 'HAVE_PRAGMA_PACK_HPPA' => -1, + 'HAVE_PRELOADED_SYMBOLS' => -1, + 'HAVE_PTHREAD_YIELD' => '1', + 'HAVE_PWD_H' => -1, + 'HAVE_READDIR' => '1', + 'HAVE_READDIR_R_2' => -1, + 'HAVE_READDIR_R_3' => -1, + 'HAVE_RECVMSG' => '1', + 'HAVE_RESOLV_H' => '1', + 'HAVE_SAR' => '1', + 'HAVE_SCHED_YIELD' => -1, + 'HAVE_SENDMSG' => '1', + 'HAVE_SETGROUPS' => -1, + 'HAVE_SETSID' => '1', + 'HAVE_SHL_LOAD' => -1, + 'HAVE_SNPRINTF' => '1', + 'HAVE_STDBOOL_H' => -1, + 'HAVE_STDINT_H' => -1, + 'HAVE_STDLIB_H' => '1', + 'HAVE_STRCASESTR' => -1, + 'HAVE_STRERROR_R' => '1', + 'HAVE_STRINGS_H' => -1, + 'HAVE_STRING_H' => '1', + 'HAVE_STRLCAT' => -1, + 'HAVE_STRLCPY' => -1, + 'HAVE_SYSCONF_SC_PAGESIZE' => -1, + 'HAVE_SYSTEM_TOMMATH' => -1, + 'HAVE_SYS_DL_H' => -1, + 'HAVE_SYS_FILIO_H' => -1, + 'HAVE_SYS_INTTYPES_H' => -1, + 'HAVE_SYS_INT_TYPES_H' => -1, + 'HAVE_SYS_MMAN_H' => -1, + 'HAVE_SYS_PARAM_H' => -1, + 'HAVE_SYS_SELECT_H' => -1, + 'HAVE_SYS_STAT_H' => '1', + 'HAVE_SYS_TYPES_H' => '1', + 'HAVE_SYS_UIO_H' => -1, + 'HAVE_TERMIOS_H' => -1, + 'HAVE_UNISTD_H' => -1, + 'HAVE_VSNPRINTF' => '1', + 'HAVE_WORKING_ARGZ' => -1, + 'LIBCLAMAV_FULLVER' => '"6.0.4"', + 'LIBCLAMAV_MAJORVER' => '6', + 'LTDL_DLOPEN_DEPLIBS' => -1, + 'LT_DLSEARCH_PATH' => '""', + 'LT_LIBEXT' => '"dll"', + 'LT_MODULE_EXT' => '".dll"', + 'LT_MODULE_PATH_VAR' => '"LD_LIBRARY_PATH"', + 'LT_OBJDIR' => '""', + 'NDEBUG' => '1', + 'NEED_USCORE' => -1, + 'NOBZ2PREFIX' => -1, + 'NO_FD_SET' => -1, + 'PACKAGE' => 'PACKAGE_NAME', + 'PACKAGE_BUGREPORT' => '"http://bugs.clamav.net/"', + 'PACKAGE_NAME' => '"ClamAV"', + 'PACKAGE_STRING' => '"ClamAV devel"', + 'PACKAGE_TARNAME' => '"clamav"', + 'PACKAGE_URL' => '"http://www.clamav.net/"', + 'PACKAGE_VERSION' => '"devel"', + 'SCANBUFF' => '131072', + 'SETPGRP_VOID' => '1', + 'SIZEOF_INT' => '4', + 'SIZEOF_LONG' => '4', + 'SIZEOF_LONG_LONG' => '8', + 'SIZEOF_SHORT' => '2', + 'SIZEOF_VOID_P' => '4', + 'STDC_HEADERS' => '1', + 'SUPPORT_IPv6' => -1, + 'USE_MPOOL' => -1, + 'USE_SYSLOG' => -1, + 'VERSION_SUFFIX' => '""', + 'WORDS_BIGENDIAN' => '0', + '_LARGEFILE_SOURCE' => -1, + '_POSIX_PII_SOCKET' => -1, + '_REENTRANT' => '1', + '_THREAD_SAFE' => -1, + '__error_t_defined' => -1, + 'const' => -1, + 'error_t' => -1, + 'inline' => '_inline', + 'off_t' => -1, + 'restrict' => -1, + 'socklen_t' => -1, + ); + + +# PROJECT FILES # +# - makefile: path to Makefile.am from the root of the repo +# - sections: section of Makefile.am to parse (without _SOURCES or _la_SOURCES) +# - output: path to the output vcproj file +# - makefile_only: *optional* regex to allow exclusion of certain files from the vcproj (use double escapes) +# - vcproj_only: *optional* regex to allow inclusion of certain files into the vcproj (use double escapes) + +my @PROJECTS = ( + # LIBCLAMAV # + {makefile => 'libclamav', sections => ['libclamav', 'libclamav_internal_utils'], output => 'win32/libclamav.vcproj', makefile_only => 'BraIA64\\.c$', vcproj_only => '(3rdparty\\\\|compat\\\\|getopt\\.c|misc\\.c)'}, + + # LIBCLAMUNRAR_IFACE # + {makefile => 'libclamav', sections => ['libclamunrar_iface'], output => 'win32/libclamunrar_iface.vcproj', vcproj_only => 'compat\\\\'}, + + # LIBCLAMUNRAR # + {makefile => 'libclamav', sections => ['libclamunrar'], output => 'win32/libclamunrar.vcproj'}, + + # CLAMSCAN # + {makefile => 'clamscan', sections => ['clamscan'], output => 'win32/clamscan.vcproj', makefile_only => 'optparser\\.c$', vcproj_only => 'compat\\\\'}, + + # FRESHCLAM # + {makefile => 'freshclam', sections => ['freshclam'], output => 'win32/freshclam.vcproj', makefile_only => 'optparser\\.c$', vcproj_only => 'compat\\\\'}, + + # CLAMCONF # + {makefile => 'clamconf', sections => ['clamconf'], output => 'win32/clamconf.vcproj', makefile_only => 'optparser\\.c$'}, + + # CLAMBC # + {makefile => 'clambc', sections => ['clambc'], output => 'win32/clambc.vcproj', makefile_only => 'optparser\\.c$'}, + + # LLVMsystem # + {makefile => 'libclamav/c++', sections => ['libllvmsystem'], output => 'win32/LLVMsystem.vcproj'}, + + # LLVMsupport # + {makefile => 'libclamav/c++', sections => ['libllvmsupport'], output => 'win32/LLVMsupport.vcproj'}, + + # LLVMcodgen # + {makefile => 'libclamav/c++', sections => ['libllvmcodegen'], output => 'win32/LLVMcodegen.vcproj'}, + + # LLVMcodgen # + {makefile => 'libclamav/c++', sections => ['libllvmx86codegen'], output => 'win32/LLVMx86codegen.vcproj'}, + + # LLVMjit # + {makefile => 'libclamav/c++', sections => ['libllvmjit'], output => 'win32/LLVMjit.vcproj', makefile_only => '\\\\llvm\\\\lib\\\\Support\\\\'}, + + + ); + +########################################################### +# STOP HACKING HERE STOP HACKING HERE STOP HACKING HERE # +########################################################### + + + + +my %ref_files; +my %files; +my $exclude; + +sub ugly_print { + no warnings 'recursion'; + my $t = shift; + return unless $t; + my $haveatt = 0; + + for(my $i=0; $i<$t->level; $i++) { + print "\t"; + } + print "<".$t->gi; + if(scalar keys %{$t->atts}) { + print "\n"; + foreach (sort keys %{$t->atts}) { + for(my $i=0; $i<=$t->level; $i++) { + print "\t"; + } + print $_.'="'.$t->atts->{$_}."\"\n"; + } + $haveatt = 1; + } + + if($haveatt) { + for(my $i=0; $i<$t->level; $i++) { + print "\t"; + } + print "\t" if($t->children); + } + print "/" unless $t->children; + print ">\n"; + ugly_print($t->first_child); + if($t->children) { + for(my $i=0; $i<$t->level; $i++) { + print "\t"; + } + print "gi.">\n"; + } + ugly_print($t->next_sibling); +} + +sub file { + my ($twig, $file) = @_; + my $fname = $file->{'att'}->{'RelativePath'}; + return unless $fname =~ /^.*\.c(pp)?$/; + return if defined($exclude) && $fname =~ /$exclude/; + warn "Warning: File $fname not in Makefile.am\n" unless defined($ref_files{$fname}); + $files{$fname} = 1; +} + + +my $BASE_DIR = `git rev-parse --git-dir`; +chomp($BASE_DIR); +die "This script only works in a GIT repository\n" unless $BASE_DIR; +$BASE_DIR = "$BASE_DIR/.."; +my $VER = `git describe --always`; +chomp($VER); +die "Cannot determine git version via git-describe\n" unless $VER && !$?; +$VER = "devel-$VER"; +my $w = 0; + +print "Generating clamav-config.h...\n"; + +open IN, "< $BASE_DIR/clamav-config.h.in" || die "Cannot find clamav-config.h.in: $!\n"; +open OUT, "> $BASE_DIR/win32/clamav-config.h" || die "Cannot open clamav-config.h: $!\n"; + +print OUT "/* clamav-config.h. Generated from clamav-config.h.in by update-win32. */\n\n"; +while() { + if(!/^#\s*undef (.*)/) { + print OUT $_; + next; + } + if($1 eq 'VERSION') { + print OUT "#define VERSION \"$VER\"\n"; + next; + } + if(!exists($CONF{$1})) { + warn "Warning: clamav-config.h option '$1' is unknown. Please take a second to update this script.\n"; + print OUT "/* #undef $1 */\n"; + $w++; + next; + } + if($CONF{$1} eq -1) { + print OUT "/* #undef $1 */\n"; + } else { + print OUT "#define $1 $CONF{$1}\n"; + } +} +close OUT; +close IN; +print "clamav-config.h generated ($w warnings)\n"; + +if(-e "$BASE_DIR/libclamav/version.h.static") { + print "Skipping regeneration of libclamav/version.h (static version found)\n"; +} else { + print "Generating libclamav/version.h...\n"; + open OUT, "> $BASE_DIR/libclamav/version.h" || die "Cannot open clamav-config.h: $!\n"; + print OUT "/* Automatically generated by update-win32 */\n\n#define REPO_VERSION \"$VER\"\n"; + close OUT; + print "libclamav/version.h generated\n"; +} + + +foreach (@PROJECTS) { + my %proj = %$_; + %files = (); + %ref_files = (); + my $got = 0; + $exclude = $proj{'vcproj_only'}; + print "Generating $proj{'output'}...\n"; + open IN, "$proj{'makefile'}/Makefile.am" or die "Cannot open $proj{'makefile'}/Makefile.am\n"; + while() { + my ($trail, $fname); + if($got == 0) { + next unless /^(.*?)(?:_la)?_SOURCES\s*\+?=\s*(.*?)\s*(\\)?\s*$/; + next unless grep {$_ eq $1} (@{$proj{'sections'}}); + $got = 1; + $trail = $3; + $fname = $2; + } else { + /^\s*(.*?)(\s*\\)?$/; + $trail = $2; + $fname = $1; + } + if($fname =~ /\.c(pp)?$/) { + if($fname =~ s/^(\$\(top_srcdir\)|\.\.)\///) { + $fname = "../$fname"; + } else { + $fname = "../$proj{'makefile'}/$fname"; + } + $fname =~ y/\//\\/; + $ref_files{$fname} = 1 unless defined($proj{'makefile_only'}) && $fname =~ /$proj{'makefile_only'}/; + } + $got = 0 unless $trail; + } + + my $xml = XML::Twig->new( keep_encoding => 1, twig_handlers => { File => \&file } ); + $xml->parsefile("$BASE_DIR/$proj{output}"); + + my @missing = grep ! exists $files{$_}, keys %ref_files; + warn "Warning: File $_ not in $proj{output}\n" foreach @missing; +# ugly_print($xml->root); +}