Browse code

win32 build stuff

aCaB authored on 2010/01/26 11:29:48
Showing 2 changed files
... ...
@@ -179,8 +179,6 @@ return 0;
179 179
 ], [ ac_cv_have_control_in_msghdr="yes" ], [ ac_cv_have_control_in_msghdr="no" ])
180 180
 ])
181 181
 if test "x$ac_cv_have_control_in_msghdr" = "xyes" ; then
182
-    AC_DEFINE([HAVE_CONTROL_IN_MSGHDR],1,[ancillary data style fd pass])
183
-
184 182
     dnl Check whether FD passing works <edwin@clamav.net>
185 183
     AC_MSG_CHECKING([BSD 4.4 / RFC2292 style fd passing])
186 184
     AC_ARG_ENABLE([fdpassing],[  --disable-fdpassing        don't build file descriptor passing support],
187 185
new file mode 100644
... ...
@@ -0,0 +1,394 @@
0
+#!/usr/bin/perl
1
+
2
+use strict;
3
+use warnings;
4
+use XML::Twig;
5
+
6
+
7
+
8
+#########################################################
9
+# HACK HERE  HACK HERE  HACK HERE  HACK HERE  HACK HERE # 
10
+#########################################################
11
+
12
+use constant DEBUG => 0;
13
+
14
+# CLAMAV-CONFIG.H MACROES
15
+# - Set to the proper win32 value or -1 to undef - #
16
+my %CONF = (
17
+    'AC_APPLE_UNIVERSAL_BUILD' => -1,
18
+    'ANONYMOUS_MAP' => -1,
19
+    'BIND_8_COMPAT' => -1,
20
+    'BUILD_CLAMD' => '1',
21
+    'CLAMAVGROUP' => '"clamav"',
22
+    'CLAMAVUSER' => '"clamav"',
23
+    'CLAMUKO' => -1,
24
+    'CL_DEBUG' => -1,
25
+    'CL_EXPERIMENTAL' => -1,
26
+    'CL_THREAD_SAFE' => '1',
27
+    'CONFDIR' => '"C:\\\\ClamAV"',
28
+    'CURSES_INCLUDE' => -1,
29
+    'C_AIX' => -1,
30
+    'C_BEOS' => -1,
31
+    'C_BIGSTACK' => -1,
32
+    'C_BSD' => -1,
33
+    'C_DARWIN' => -1,
34
+    'C_GNU_HURD' => -1,
35
+    'C_HPUX' => -1,
36
+    'C_INTERIX' => -1,
37
+    'C_IRIX' => -1,
38
+    'C_KFREEBSD_GNU' => -1,
39
+    'C_LINUX' => -1,
40
+    'C_OS2' => -1,
41
+    'C_OSF' => -1,
42
+    'C_QNX6' => -1,
43
+    'C_SOLARIS' => -1,
44
+    'DATADIR' => '"C:\\\\ClamAV\\\\db"',
45
+    'DEFAULT_FD_SETSIZE' => '1024',
46
+    'FDPASS_NEED_XOPEN' => -1,
47
+    'FILEBUFF' => '8192',
48
+    'FPU_WORDS_BIGENDIAN' => '0',
49
+    'FRESHCLAM_DNS_FIX' => -1,
50
+    'FRESHCLAM_NO_CACHE' => -1,
51
+    'HAVE_ARGZ_ADD' => -1,
52
+    'HAVE_ARGZ_APPEND' => -1,
53
+    'HAVE_ARGZ_COUNT' => -1,
54
+    'HAVE_ARGZ_CREATE_SEP' => -1,
55
+    'HAVE_ARGZ_H' => -1,
56
+    'HAVE_ARGZ_INSERT' => -1,
57
+    'HAVE_ARGZ_NEXT' => -1,
58
+    'HAVE_ARGZ_STRINGIFY' => -1,
59
+    'HAVE_ATTRIB_ALIGNED' => -1,
60
+    'HAVE_ATTRIB_PACKED' => -1,
61
+    'HAVE_BZLIB_H' => '1',
62
+    'HAVE_CLOSEDIR' => '1',
63
+    'HAVE_CTIME_R' => '1',
64
+    'HAVE_CTIME_R_2' => '1',
65
+    'HAVE_CTIME_R_3' => -1,
66
+    'HAVE_DECL_CYGWIN_CONV_PATH' => -1,
67
+    'HAVE_DIRENT_H' => '1',
68
+    'HAVE_DLD' => -1,
69
+    'HAVE_DLD_H' => -1,
70
+    'HAVE_DLERROR' => -1,
71
+    'HAVE_DLFCN_H' => '1',
72
+    'HAVE_DL_H' => -1,
73
+    'HAVE_DYLD' => -1,
74
+    'HAVE_ERROR_T' => -1,
75
+    'HAVE_FD_PASSING' => -1,
76
+    'HAVE_FSEEKO' => '1',
77
+    'HAVE_GETADDRINFO' => '1',
78
+    'HAVE_GETPAGESIZE' => '1',
79
+    'HAVE_GRP_H' => -1,
80
+    'HAVE_ICONV' => -1,
81
+    'HAVE_INET_NTOP' => '1',
82
+    'HAVE_INITGROUPS' => -1,
83
+    'HAVE_INTTYPES_H' => -1,
84
+    'HAVE_IN_ADDR_T' => -1,
85
+    'HAVE_IN_PORT_T' => '1',
86
+    'HAVE_LIBCHECK' => -1,
87
+    'HAVE_LIBDL' => '1',
88
+    'HAVE_LIBDLLOADER' => '1',
89
+    'HAVE_LIBMILTER_MFAPI_H' => -1,
90
+    'HAVE_LIBNCURSES' => -1,
91
+    'HAVE_LIBPDCURSES' => -1,
92
+    'HAVE_LIBZ' => '1',
93
+    'HAVE_LIMITS_H' => '1',
94
+    'HAVE_LTDL' => '1',
95
+    'HAVE_MACH_O_DYLD_H' => -1,
96
+    'HAVE_MADVISE' => -1,
97
+    'HAVE_MALLINFO' => -1,
98
+    'HAVE_MALLOC_H' => '1',
99
+    'HAVE_MEMCPY' => '1',
100
+    'HAVE_MEMORY_H' => '1',
101
+    'HAVE_MKSTEMP' => '1',
102
+    'HAVE_MMAP' => -1,
103
+    'HAVE_NDIR_H' => -1,
104
+    'HAVE_OPENDIR' => '1',
105
+    'HAVE_POLL' => '1',
106
+    'HAVE_POLL_H' => '1',
107
+    'HAVE_PRAGMA_PACK' => '1',
108
+    'HAVE_PRAGMA_PACK_HPPA' => -1,
109
+    'HAVE_PRELOADED_SYMBOLS' => -1,
110
+    'HAVE_PTHREAD_YIELD' => '1',
111
+    'HAVE_PWD_H' => -1,
112
+    'HAVE_READDIR' => '1',
113
+    'HAVE_READDIR_R_2' => -1,
114
+    'HAVE_READDIR_R_3' => -1,
115
+    'HAVE_RECVMSG' => '1',
116
+    'HAVE_RESOLV_H' => '1',
117
+    'HAVE_SAR' => '1',
118
+    'HAVE_SCHED_YIELD' => -1,
119
+    'HAVE_SENDMSG' => '1',
120
+    'HAVE_SETGROUPS' => -1,
121
+    'HAVE_SETSID' => '1',
122
+    'HAVE_SHL_LOAD' => -1,
123
+    'HAVE_SNPRINTF' => '1',
124
+    'HAVE_STDBOOL_H' => -1,
125
+    'HAVE_STDINT_H' => -1,
126
+    'HAVE_STDLIB_H' => '1',
127
+    'HAVE_STRCASESTR' => -1,
128
+    'HAVE_STRERROR_R' => '1',
129
+    'HAVE_STRINGS_H' => -1,
130
+    'HAVE_STRING_H' => '1',
131
+    'HAVE_STRLCAT' => -1,
132
+    'HAVE_STRLCPY' => -1,
133
+    'HAVE_SYSCONF_SC_PAGESIZE' => -1,
134
+    'HAVE_SYSTEM_TOMMATH' => -1,
135
+    'HAVE_SYS_DL_H' => -1,
136
+    'HAVE_SYS_FILIO_H' => -1,
137
+    'HAVE_SYS_INTTYPES_H' => -1,
138
+    'HAVE_SYS_INT_TYPES_H' => -1,
139
+    'HAVE_SYS_MMAN_H' => -1,
140
+    'HAVE_SYS_PARAM_H' => -1,
141
+    'HAVE_SYS_SELECT_H' => -1,
142
+    'HAVE_SYS_STAT_H' => '1',
143
+    'HAVE_SYS_TYPES_H' => '1',
144
+    'HAVE_SYS_UIO_H' => -1,
145
+    'HAVE_TERMIOS_H' => -1,
146
+    'HAVE_UNISTD_H' => -1,
147
+    'HAVE_VSNPRINTF' => '1',
148
+    'HAVE_WORKING_ARGZ' => -1,
149
+    'LIBCLAMAV_FULLVER' => '"6.0.4"',
150
+    'LIBCLAMAV_MAJORVER' => '6',
151
+    'LTDL_DLOPEN_DEPLIBS' => -1,
152
+    'LT_DLSEARCH_PATH' => '""',
153
+    'LT_LIBEXT' => '"dll"',
154
+    'LT_MODULE_EXT' => '".dll"',
155
+    'LT_MODULE_PATH_VAR' => '"LD_LIBRARY_PATH"',
156
+    'LT_OBJDIR' => '""',
157
+    'NDEBUG' => '1',
158
+    'NEED_USCORE' => -1,
159
+    'NOBZ2PREFIX' => -1,
160
+    'NO_FD_SET' => -1,
161
+    'PACKAGE' => 'PACKAGE_NAME',
162
+    'PACKAGE_BUGREPORT' => '"http://bugs.clamav.net/"',
163
+    'PACKAGE_NAME' => '"ClamAV"',
164
+    'PACKAGE_STRING' => '"ClamAV devel"',
165
+    'PACKAGE_TARNAME' => '"clamav"',
166
+    'PACKAGE_URL' => '"http://www.clamav.net/"',
167
+    'PACKAGE_VERSION' => '"devel"',
168
+    'SCANBUFF' => '131072',
169
+    'SETPGRP_VOID' => '1',
170
+    'SIZEOF_INT' => '4',
171
+    'SIZEOF_LONG' => '4',
172
+    'SIZEOF_LONG_LONG' => '8',
173
+    'SIZEOF_SHORT' => '2',
174
+    'SIZEOF_VOID_P' => '4',
175
+    'STDC_HEADERS' => '1',
176
+    'SUPPORT_IPv6' => -1,
177
+    'USE_MPOOL' => -1,
178
+    'USE_SYSLOG' => -1,
179
+    'VERSION_SUFFIX' => '""',
180
+    'WORDS_BIGENDIAN' => '0',
181
+    '_LARGEFILE_SOURCE' => -1,
182
+    '_POSIX_PII_SOCKET' => -1,
183
+    '_REENTRANT' => '1',
184
+    '_THREAD_SAFE' => -1,
185
+    '__error_t_defined' => -1,
186
+    'const' => -1,
187
+    'error_t' => -1,
188
+    'inline' => '_inline',
189
+    'off_t' => -1,
190
+    'restrict' => -1,
191
+    'socklen_t' => -1,
192
+    );
193
+
194
+
195
+# PROJECT FILES #
196
+# - makefile: path to Makefile.am from the root of the repo
197
+# - sections: section of Makefile.am to parse (without _SOURCES or _la_SOURCES)
198
+# - output: path to the output vcproj file
199
+# - makefile_only: *optional* regex to allow exclusion of certain files from the vcproj (use double escapes)
200
+# - vcproj_only: *optional* regex to allow inclusion of certain files into the vcproj (use double escapes)
201
+
202
+my @PROJECTS = (
203
+    # LIBCLAMAV #
204
+    {makefile => 'libclamav', sections => ['libclamav', 'libclamav_internal_utils'], output => 'win32/libclamav.vcproj', makefile_only => 'BraIA64\\.c$', vcproj_only => '(3rdparty\\\\|compat\\\\|getopt\\.c|misc\\.c)'},
205
+
206
+    # LIBCLAMUNRAR_IFACE #
207
+    {makefile => 'libclamav', sections => ['libclamunrar_iface'], output => 'win32/libclamunrar_iface.vcproj', vcproj_only => 'compat\\\\'},
208
+
209
+    # LIBCLAMUNRAR #
210
+    {makefile => 'libclamav', sections => ['libclamunrar'], output => 'win32/libclamunrar.vcproj'},
211
+
212
+    # CLAMSCAN #
213
+    {makefile => 'clamscan', sections => ['clamscan'], output => 'win32/clamscan.vcproj', makefile_only => 'optparser\\.c$', vcproj_only => 'compat\\\\'},
214
+
215
+    # FRESHCLAM #
216
+    {makefile => 'freshclam', sections => ['freshclam'], output => 'win32/freshclam.vcproj', makefile_only => 'optparser\\.c$', vcproj_only => 'compat\\\\'},
217
+
218
+    # CLAMCONF #
219
+    {makefile => 'clamconf', sections => ['clamconf'], output => 'win32/clamconf.vcproj', makefile_only => 'optparser\\.c$'},
220
+
221
+    # CLAMBC #
222
+    {makefile => 'clambc', sections => ['clambc'], output => 'win32/clambc.vcproj', makefile_only => 'optparser\\.c$'},
223
+
224
+    # LLVMsystem #
225
+    {makefile => 'libclamav/c++', sections => ['libllvmsystem'], output => 'win32/LLVMsystem.vcproj'},
226
+
227
+    # LLVMsupport #
228
+    {makefile => 'libclamav/c++', sections => ['libllvmsupport'], output => 'win32/LLVMsupport.vcproj'},
229
+
230
+    # LLVMcodgen #
231
+    {makefile => 'libclamav/c++', sections => ['libllvmcodegen'], output => 'win32/LLVMcodegen.vcproj'},
232
+
233
+    # LLVMcodgen #
234
+    {makefile => 'libclamav/c++', sections => ['libllvmx86codegen'], output => 'win32/LLVMx86codegen.vcproj'},
235
+
236
+    # LLVMjit #
237
+    {makefile => 'libclamav/c++', sections => ['libllvmjit'], output => 'win32/LLVMjit.vcproj', makefile_only => '\\\\llvm\\\\lib\\\\Support\\\\'},
238
+
239
+
240
+    );
241
+
242
+###########################################################
243
+# STOP HACKING HERE  STOP HACKING HERE  STOP HACKING HERE # 
244
+###########################################################
245
+
246
+
247
+
248
+
249
+my %ref_files;
250
+my %files;
251
+my $exclude;
252
+
253
+sub ugly_print {
254
+    no warnings 'recursion';
255
+    my $t = shift;
256
+    return unless $t;
257
+    my $haveatt = 0;
258
+
259
+    for(my $i=0; $i<$t->level; $i++) {
260
+	print "\t";
261
+    }
262
+    print "<".$t->gi;
263
+    if(scalar keys %{$t->atts}) {
264
+	print "\n";
265
+	foreach (sort keys %{$t->atts}) {
266
+	    for(my $i=0; $i<=$t->level; $i++) {
267
+		print "\t";
268
+	    }
269
+	    print $_.'="'.$t->atts->{$_}."\"\n";
270
+	}
271
+	$haveatt = 1;
272
+    }
273
+
274
+    if($haveatt) {
275
+        for(my $i=0; $i<$t->level; $i++) {
276
+	    print "\t";
277
+	}
278
+	print "\t" if($t->children);
279
+    }
280
+    print "/" unless $t->children;
281
+    print ">\n";
282
+    ugly_print($t->first_child);
283
+    if($t->children) {
284
+	for(my $i=0; $i<$t->level; $i++) {
285
+	    print "\t";
286
+	}
287
+	print "</".$t->gi.">\n";
288
+    }
289
+    ugly_print($t->next_sibling);
290
+}
291
+
292
+sub file {
293
+    my ($twig, $file) = @_;
294
+    my $fname = $file->{'att'}->{'RelativePath'};
295
+    return unless $fname =~ /^.*\.c(pp)?$/;
296
+    return if defined($exclude) && $fname =~ /$exclude/;
297
+    warn "Warning: File $fname not in Makefile.am\n" unless defined($ref_files{$fname});
298
+    $files{$fname} = 1;
299
+}
300
+
301
+
302
+my $BASE_DIR = `git rev-parse --git-dir`;
303
+chomp($BASE_DIR);
304
+die "This script only works in a GIT repository\n" unless $BASE_DIR;
305
+$BASE_DIR = "$BASE_DIR/..";
306
+my $VER = `git describe --always`;
307
+chomp($VER);
308
+die "Cannot determine git version via git-describe\n" unless $VER && !$?;
309
+$VER = "devel-$VER";
310
+my $w = 0;
311
+
312
+print "Generating clamav-config.h...\n";
313
+
314
+open IN, "< $BASE_DIR/clamav-config.h.in" || die "Cannot find clamav-config.h.in: $!\n";
315
+open OUT, "> $BASE_DIR/win32/clamav-config.h" || die "Cannot open clamav-config.h: $!\n";
316
+
317
+print OUT "/* clamav-config.h.  Generated from clamav-config.h.in by update-win32.  */\n\n";
318
+while(<IN>) {
319
+    if(!/^#\s*undef (.*)/) {
320
+	print OUT $_;
321
+	next;
322
+    }
323
+    if($1 eq 'VERSION') {
324
+	print OUT "#define VERSION \"$VER\"\n";
325
+	next;
326
+    }
327
+    if(!exists($CONF{$1})) {
328
+	warn "Warning: clamav-config.h option '$1' is unknown. Please take a second to update this script.\n";
329
+	print OUT "/* #undef $1 */\n";
330
+	$w++;
331
+	next;
332
+    }
333
+    if($CONF{$1} eq -1) {
334
+	print OUT "/* #undef $1 */\n";
335
+    } else {
336
+	print OUT "#define $1 $CONF{$1}\n";
337
+    }
338
+}
339
+close OUT;
340
+close IN;
341
+print "clamav-config.h generated ($w warnings)\n";
342
+
343
+if(-e "$BASE_DIR/libclamav/version.h.static") {
344
+    print "Skipping regeneration of libclamav/version.h (static version found)\n";
345
+} else {
346
+    print "Generating libclamav/version.h...\n";
347
+    open OUT, "> $BASE_DIR/libclamav/version.h" || die "Cannot open clamav-config.h: $!\n";
348
+    print OUT "/* Automatically generated by update-win32 */\n\n#define REPO_VERSION \"$VER\"\n";
349
+    close OUT;
350
+    print "libclamav/version.h generated\n";
351
+}
352
+
353
+
354
+foreach (@PROJECTS) {
355
+    my %proj = %$_;
356
+    %files = ();
357
+    %ref_files = ();
358
+    my $got = 0;
359
+    $exclude = $proj{'vcproj_only'};
360
+    print "Generating $proj{'output'}...\n";
361
+    open IN, "$proj{'makefile'}/Makefile.am" or die "Cannot open $proj{'makefile'}/Makefile.am\n";
362
+    while(<IN>) {
363
+	my ($trail, $fname);
364
+	if($got == 0) {
365
+	    next unless /^(.*?)(?:_la)?_SOURCES\s*\+?=\s*(.*?)\s*(\\)?\s*$/;
366
+	    next unless grep {$_ eq $1} (@{$proj{'sections'}});
367
+	    $got = 1;
368
+	    $trail = $3;
369
+	    $fname = $2;
370
+	} else {
371
+	    /^\s*(.*?)(\s*\\)?$/;
372
+	    $trail = $2;
373
+	    $fname = $1;
374
+	}
375
+	if($fname =~ /\.c(pp)?$/) {
376
+	    if($fname =~ s/^(\$\(top_srcdir\)|\.\.)\///) {
377
+		$fname = "../$fname";
378
+	    } else {
379
+		$fname = "../$proj{'makefile'}/$fname";
380
+	    }
381
+            $fname =~ y/\//\\/;
382
+	    $ref_files{$fname} = 1 unless defined($proj{'makefile_only'}) && $fname =~ /$proj{'makefile_only'}/;
383
+	}
384
+	$got = 0 unless $trail;
385
+    }
386
+    
387
+    my $xml = XML::Twig->new( keep_encoding => 1, twig_handlers => { File => \&file } );
388
+    $xml->parsefile("$BASE_DIR/$proj{output}");
389
+
390
+    my @missing = grep ! exists $files{$_}, keys %ref_files;
391
+    warn "Warning: File $_ not in $proj{output}\n" foreach @missing;
392
+#    ugly_print($xml->root);
393
+}