| 
									
										
										
										
											2010-01-26 03:29:48 +01:00
										 |  |  | #!/usr/bin/perl | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | use strict; | 
					
						
							|  |  |  | use warnings; | 
					
						
							|  |  |  | use XML::Twig; | 
					
						
							| 
									
										
										
										
											2010-01-26 17:08:35 +01:00
										 |  |  | use File::Copy; | 
					
						
							|  |  |  | use File::Temp 'tempfile'; | 
					
						
							| 
									
										
										
										
											2010-01-26 03:29:48 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ######################################################### | 
					
						
							|  |  |  | # HACK HERE  HACK HERE  HACK HERE  HACK HERE  HACK HERE #  | 
					
						
							|  |  |  | ######################################################### | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | use constant DEBUG => 0; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-26 19:42:52 +01:00
										 |  |  | ### CLAMAV-CONFIG.H MACROES ### | 
					
						
							| 
									
										
										
										
											2010-01-26 03:29:48 +01:00
										 |  |  | # - 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, | 
					
						
							| 
									
										
										
										
											2010-03-22 17:28:38 +02:00
										 |  |  |     'CL_BCUNSIGNED' => -1, | 
					
						
							| 
									
										
										
										
											2010-01-26 03:29:48 +01:00
										 |  |  |     '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', | 
					
						
							| 
									
										
										
										
											2010-01-29 14:44:55 +01:00
										 |  |  |     'HAVE_POLL' => '1', | 
					
						
							| 
									
										
										
										
											2010-01-28 23:36:37 +01:00
										 |  |  |     'HAVE_POLL_H' => -1, | 
					
						
							| 
									
										
										
										
											2010-01-26 03:29:48 +01:00
										 |  |  |     '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', | 
					
						
							| 
									
										
										
										
											2010-05-15 22:46:08 +02:00
										 |  |  |     'SIZEOF_VOID_P' => -1, | 
					
						
							| 
									
										
										
										
											2010-01-26 03:29:48 +01:00
										 |  |  |     'STDC_HEADERS' => '1', | 
					
						
							|  |  |  |     'SUPPORT_IPv6' => -1, | 
					
						
							| 
									
										
										
										
											2010-05-10 03:46:46 +02:00
										 |  |  |     'USE_MPOOL' => 1, | 
					
						
							| 
									
										
										
										
											2010-01-26 03:29:48 +01:00
										 |  |  |     '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, | 
					
						
							| 
									
										
										
										
											2010-05-10 03:46:46 +02:00
										 |  |  |     'HAVE_UNAME_SYSCALL' => -1, | 
					
						
							|  |  |  |     'HAVE__INTERNAL__SHA_COLLECT' => -1 | 
					
						
							| 
									
										
										
										
											2010-01-26 03:29:48 +01:00
										 |  |  |     ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-26 19:42:52 +01:00
										 |  |  | ### PROJECT FILES ### | 
					
						
							| 
									
										
										
										
											2010-01-26 03:29:48 +01:00
										 |  |  | # - makefile: path to Makefile.am from the root of the repo | 
					
						
							|  |  |  | # - sections: section of Makefile.am to parse (without _SOURCES or _la_SOURCES) | 
					
						
							| 
									
										
										
										
											2010-07-24 04:14:56 +02:00
										 |  |  | # - output: path to the output vcxproj file | 
					
						
							|  |  |  | # - makefile_only: *optional* regex to allow exclusion of certain files from the vcxproj (use double escapes) | 
					
						
							|  |  |  | # - vcxproj_only: *optional* regex to allow inclusion of certain files into the vcxproj (use double escapes) | 
					
						
							| 
									
										
										
										
											2010-01-26 03:29:48 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | my @PROJECTS = ( | 
					
						
							|  |  |  |     # LIBCLAMAV # | 
					
						
							| 
									
										
										
										
											2010-07-24 04:14:56 +02:00
										 |  |  |     {makefile => 'libclamav', sections => ['libclamav', 'libclamav_internal_utils'], output => 'win32/libclamav.vcxproj', vcxproj_only => '(3rdparty\\\\|compat\\\\|getopt\\.c|misc\\.c)'}, | 
					
						
							| 
									
										
										
										
											2010-01-26 03:29:48 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # LIBCLAMUNRAR_IFACE # | 
					
						
							| 
									
										
										
										
											2010-07-24 04:14:56 +02:00
										 |  |  |     {makefile => 'libclamav', sections => ['libclamunrar_iface'], output => 'win32/libclamunrar_iface.vcxproj', vcxproj_only => 'compat\\\\'}, | 
					
						
							| 
									
										
										
										
											2010-01-26 03:29:48 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # LIBCLAMUNRAR # | 
					
						
							| 
									
										
										
										
											2010-07-24 04:14:56 +02:00
										 |  |  |     {makefile => 'libclamav', sections => ['libclamunrar'], output => 'win32/libclamunrar.vcxproj'}, | 
					
						
							| 
									
										
										
										
											2010-01-26 03:29:48 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-26 19:00:24 +01:00
										 |  |  |     # LIBCLAMAVCXX # | 
					
						
							| 
									
										
										
										
											2010-07-24 04:14:56 +02:00
										 |  |  |     {makefile => 'libclamav/c++', sections => ['libclamavcxx'], output => 'win32/libclamavcxx.vcxproj'}, | 
					
						
							| 
									
										
										
										
											2010-01-26 19:00:24 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-26 03:29:48 +01:00
										 |  |  |     # CLAMSCAN # | 
					
						
							| 
									
										
										
										
											2010-07-24 04:14:56 +02:00
										 |  |  |     {makefile => 'clamscan', sections => ['clamscan'], output => 'win32/clamscan.vcxproj', makefile_only => '(optparser\\.c|getopt\\.c)$'}, | 
					
						
							| 
									
										
										
										
											2010-01-28 23:36:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-31 17:12:34 +01:00
										 |  |  |     # CLAMDSCAN # | 
					
						
							| 
									
										
										
										
											2010-07-24 04:14:56 +02:00
										 |  |  |     {makefile => 'clamdscan', sections => ['clamdscan'], output => 'win32/clamdscan.vcxproj', makefile_only => '(optparser\\.c|getopt\\.c)$'}, | 
					
						
							| 
									
										
										
										
											2010-01-31 17:12:34 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-28 23:36:37 +01:00
										 |  |  |     # CLAMD # | 
					
						
							| 
									
										
										
										
											2010-07-24 04:14:56 +02:00
										 |  |  |     {makefile => 'clamd', sections => ['clamd'], output => 'win32/clamd.vcxproj', makefile_only => '(optparser\\.c|getopt\\.c|(daz|clam)uko.*)$'}, | 
					
						
							| 
									
										
										
										
											2010-01-26 03:29:48 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # FRESHCLAM # | 
					
						
							| 
									
										
										
										
											2010-07-24 04:14:56 +02:00
										 |  |  |     {makefile => 'freshclam', sections => ['freshclam'], output => 'win32/freshclam.vcxproj', makefile_only => '(optparser\\.c|getopt\\.c)$', vcxproj_only => 'compat\\\\'}, | 
					
						
							| 
									
										
										
										
											2010-01-26 03:29:48 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # CLAMCONF # | 
					
						
							| 
									
										
										
										
											2010-07-24 04:14:56 +02:00
										 |  |  |     {makefile => 'clamconf', sections => ['clamconf'], output => 'win32/clamconf.vcxproj', makefile_only => '(optparser\\.c$|getopt\\.c)$'}, | 
					
						
							| 
									
										
										
										
											2010-01-26 03:29:48 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # CLAMBC # | 
					
						
							| 
									
										
										
										
											2010-07-24 04:14:56 +02:00
										 |  |  |     {makefile => 'clambc', sections => ['clambc'], output => 'win32/clambc.vcxproj', makefile_only => '(optparser\\.c|getopt\\.c)$'}, | 
					
						
							| 
									
										
										
										
											2010-01-26 03:29:48 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # LLVMsystem # | 
					
						
							| 
									
										
										
										
											2010-07-24 04:14:56 +02:00
										 |  |  |     {makefile => 'libclamav/c++', sections => ['libllvmsystem'], output => 'win32/LLVMsystem.vcxproj'}, | 
					
						
							| 
									
										
										
										
											2010-01-26 03:29:48 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # LLVMcodgen # | 
					
						
							| 
									
										
										
										
											2010-07-24 04:14:56 +02:00
										 |  |  |     {makefile => 'libclamav/c++', sections => ['libllvmcodegen'], output => 'win32/LLVMcodegen.vcxproj'}, | 
					
						
							| 
									
										
										
										
											2010-01-26 03:29:48 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-28 23:36:37 +01:00
										 |  |  |     # LLVMx86codgen # | 
					
						
							| 
									
										
										
										
											2010-07-24 04:14:56 +02:00
										 |  |  |     {makefile => 'libclamav/c++', sections => ['libllvmx86codegen'], output => 'win32/LLVMx86codegen.vcxproj'}, | 
					
						
							| 
									
										
										
										
											2010-01-26 03:29:48 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # LLVMjit # | 
					
						
							| 
									
										
										
										
											2010-07-24 04:14:56 +02:00
										 |  |  |     {makefile => 'libclamav/c++', sections => ['libllvmjit'], output => 'win32/LLVMjit.vcxproj'}, | 
					
						
							| 
									
										
										
										
											2010-01-26 03:29:48 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-16 04:17:10 +01:00
										 |  |  |     # sigtool # | 
					
						
							| 
									
										
										
										
											2010-07-24 04:14:56 +02:00
										 |  |  |     {makefile => 'sigtool', sections => ['sigtool'], output => 'win32/sigtool.vcxproj', makefile_only => '(optparser\\.c|getopt\\.c)$'}, | 
					
						
							| 
									
										
										
										
											2010-01-26 03:29:48 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ########################################################### | 
					
						
							|  |  |  | # STOP HACKING HERE  STOP HACKING HERE  STOP HACKING HERE #  | 
					
						
							|  |  |  | ########################################################### | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | my %ref_files; | 
					
						
							|  |  |  | my %files; | 
					
						
							|  |  |  | my $exclude; | 
					
						
							| 
									
										
										
										
											2010-01-26 17:08:35 +01:00
										 |  |  | my $do_patch = 0; | 
					
						
							| 
									
										
										
										
											2010-01-26 03:29:48 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | sub file { | 
					
						
							|  |  |  |     my ($twig, $file) = @_; | 
					
						
							| 
									
										
										
										
											2010-07-24 04:14:56 +02:00
										 |  |  |     my $fname = $file->{'att'}->{'Include'}; | 
					
						
							| 
									
										
										
										
											2010-01-26 03:29:48 +01:00
										 |  |  |     return unless $fname =~ /^.*\.c(pp)?$/; | 
					
						
							|  |  |  |     return if defined($exclude) && $fname =~ /$exclude/; | 
					
						
							| 
									
										
										
										
											2010-01-26 17:08:35 +01:00
										 |  |  |     $file->delete unless !$do_patch || exists $ref_files{$fname}; | 
					
						
							| 
									
										
										
										
											2010-01-26 03:29:48 +01:00
										 |  |  |     $files{$fname} = 1; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-26 17:08:35 +01:00
										 |  |  | $do_patch = $#ARGV == 0 && $ARGV[0] eq '--regen'; | 
					
						
							|  |  |  | die("Usage:\nupdate-win32.pl [--regen]\n\nChecks the win32 build system and regenerates it if --regen is given\n\n") if $#ARGV == 0 && $ARGV[0] eq '--help'; | 
					
						
							| 
									
										
										
										
											2010-01-26 03:29:48 +01:00
										 |  |  | 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; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-26 18:41:47 +01:00
										 |  |  | print "Processing clamav-config.h...\n"; | 
					
						
							| 
									
										
										
										
											2010-01-26 03:29:48 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | open IN, "< $BASE_DIR/clamav-config.h.in" || die "Cannot find clamav-config.h.in: $!\n"; | 
					
						
							| 
									
										
										
										
											2010-01-26 18:41:47 +01:00
										 |  |  | $do_patch and open OUT, "> $BASE_DIR/win32/clamav-config.h" || die "Cannot open clamav-config.h: $!\n"; | 
					
						
							|  |  |  | $do_patch and  print OUT "/* clamav-config.h.  Generated from clamav-config.h.in by update-win32.  */\n\n"; | 
					
						
							| 
									
										
										
										
											2010-01-26 03:29:48 +01:00
										 |  |  | while(<IN>) { | 
					
						
							|  |  |  |     if(!/^#\s*undef (.*)/) { | 
					
						
							| 
									
										
										
										
											2010-01-26 18:41:47 +01:00
										 |  |  | 	$do_patch and print OUT $_; | 
					
						
							| 
									
										
										
										
											2010-01-26 03:29:48 +01:00
										 |  |  | 	next; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if($1 eq 'VERSION') { | 
					
						
							| 
									
										
										
										
											2010-01-26 18:41:47 +01:00
										 |  |  | 	$do_patch and print OUT "#define VERSION \"$VER\"\n"; | 
					
						
							| 
									
										
										
										
											2010-01-26 03:29:48 +01:00
										 |  |  | 	next; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if(!exists($CONF{$1})) { | 
					
						
							|  |  |  | 	warn "Warning: clamav-config.h option '$1' is unknown. Please take a second to update this script.\n"; | 
					
						
							| 
									
										
										
										
											2010-01-26 18:41:47 +01:00
										 |  |  | 	$do_patch and print OUT "/* #undef $1 */\n"; | 
					
						
							| 
									
										
										
										
											2010-01-26 03:29:48 +01:00
										 |  |  | 	$w++; | 
					
						
							|  |  |  | 	next; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if($CONF{$1} eq -1) { | 
					
						
							| 
									
										
										
										
											2010-01-26 18:41:47 +01:00
										 |  |  | 	$do_patch and print OUT "/* #undef $1 */\n"; | 
					
						
							| 
									
										
										
										
											2010-01-26 03:29:48 +01:00
										 |  |  |     } else { | 
					
						
							| 
									
										
										
										
											2010-01-26 18:41:47 +01:00
										 |  |  | 	$do_patch and print OUT "#define $1 $CONF{$1}\n"; | 
					
						
							| 
									
										
										
										
											2010-01-26 03:29:48 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | close IN; | 
					
						
							| 
									
										
										
										
											2010-01-26 18:41:47 +01:00
										 |  |  | if($do_patch) { | 
					
						
							|  |  |  |     close OUT; | 
					
						
							|  |  |  |     print "clamav-config.h generated ($w warnings)\n"; | 
					
						
							|  |  |  | } else { | 
					
						
							|  |  |  |     print "clamav-config.h.in parsed ($w warnings)\n"; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2010-01-26 03:29:48 +01:00
										 |  |  | foreach (@PROJECTS) { | 
					
						
							|  |  |  |     my %proj = %$_; | 
					
						
							|  |  |  |     %files = (); | 
					
						
							|  |  |  |     %ref_files = (); | 
					
						
							|  |  |  |     my $got = 0; | 
					
						
							| 
									
										
										
										
											2010-07-24 04:14:56 +02:00
										 |  |  |     $exclude = $proj{'vcxproj_only'}; | 
					
						
							| 
									
										
										
										
											2010-01-26 18:41:47 +01:00
										 |  |  |     print "Parsing $proj{'output'}...\n"; | 
					
						
							| 
									
										
										
										
											2010-01-26 03:29:48 +01:00
										 |  |  |     open IN, "$proj{'makefile'}/Makefile.am" or die "Cannot open $proj{'makefile'}/Makefile.am\n"; | 
					
						
							|  |  |  |     while(<IN>) { | 
					
						
							|  |  |  | 	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; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2010-01-26 17:08:35 +01:00
										 |  |  |     close IN; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-24 04:14:56 +02:00
										 |  |  |     my $xml = XML::Twig->new( keep_encoding => 1, twig_handlers => { 'ItemGroup/ClCompile' => \&file }, pretty_print => 'record' ); | 
					
						
							| 
									
										
										
										
											2010-01-26 17:08:35 +01:00
										 |  |  |     $xml->parsefile("$BASE_DIR/$proj{'output'}"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-24 04:14:56 +02:00
										 |  |  |     my @missing_in_vcxproj = grep ! exists $files{$_}, keys %ref_files; | 
					
						
							| 
									
										
										
										
											2010-01-26 17:08:35 +01:00
										 |  |  |     my @missing_in_makefile = grep ! exists $ref_files{$_}, keys %files; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if($do_patch) { | 
					
						
							| 
									
										
										
										
											2010-07-24 04:14:56 +02:00
										 |  |  | 	if($#missing_in_vcxproj >=0) { | 
					
						
							|  |  |  | 	    my $group = $xml->root; | 
					
						
							|  |  |  | 	    while($group = $group->next_elt('ItemGroup')) { | 
					
						
							|  |  |  | 		last if $group->has_child('ClCompile'); | 
					
						
							|  |  |  | 	    } | 
					
						
							|  |  |  | 	    if(!defined($group)) { | 
					
						
							|  |  |  | 		$group = $xml->root('ItemGroup'); | 
					
						
							|  |  |  | 		$group->paste($xml->root); | 
					
						
							| 
									
										
										
										
											2010-01-26 17:08:35 +01:00
										 |  |  | 	    } | 
					
						
							| 
									
										
										
										
											2010-07-24 04:14:56 +02:00
										 |  |  | 	    foreach (@missing_in_vcxproj) { | 
					
						
							|  |  |  | 		my $addfile = $xml->root->new('ClCompile'); | 
					
						
							|  |  |  | 		$addfile->set_att('Include' => $_); | 
					
						
							|  |  |  | 		$addfile->paste($group); | 
					
						
							|  |  |  | 		warn "Warning: File $_ not in $proj{'output'}: added!\n" foreach @missing_in_vcxproj; | 
					
						
							| 
									
										
										
										
											2010-01-26 17:08:35 +01:00
										 |  |  | 	    } | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	warn "Warning: File $_ not in $proj{'makefile'}/Makefile.am: deleted!\n" foreach @missing_in_makefile; | 
					
						
							| 
									
										
										
										
											2010-01-26 18:41:47 +01:00
										 |  |  | 	my ($fh, $filename) = tempfile(); | 
					
						
							| 
									
										
										
										
											2010-07-24 04:14:56 +02:00
										 |  |  | 	$xml->print($fh); | 
					
						
							| 
									
										
										
										
											2010-07-29 14:02:25 +02:00
										 |  |  | 	close $fh; | 
					
						
							| 
									
										
										
										
											2010-01-26 18:41:47 +01:00
										 |  |  | 	move($filename, "$proj{'output'}"); | 
					
						
							| 
									
										
										
										
											2010-07-24 04:14:56 +02:00
										 |  |  | 	print "Regenerated $proj{'output'} (".($#missing_in_vcxproj + $#missing_in_makefile + 2)." changes)\n"; | 
					
						
							| 
									
										
										
										
											2010-01-26 17:08:35 +01:00
										 |  |  |     } else { | 
					
						
							| 
									
										
										
										
											2010-07-24 04:14:56 +02:00
										 |  |  | 	warn "Warning: File $_ not in $proj{'output'}\n" foreach @missing_in_vcxproj; | 
					
						
							| 
									
										
										
										
											2010-01-26 17:08:35 +01:00
										 |  |  | 	warn "Warning: File $_ not in $proj{'makefile'}/Makefile.am\n" foreach @missing_in_makefile; | 
					
						
							| 
									
										
										
										
											2010-07-24 04:14:56 +02:00
										 |  |  | 	print "Parsed $proj{'output'} (".($#missing_in_vcxproj + $#missing_in_makefile + 2)." warnings)\n"; | 
					
						
							| 
									
										
										
										
											2010-01-26 17:08:35 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2010-01-26 03:29:48 +01:00
										 |  |  | } |