add SetPrinterDataExW.exe.
[gd/win32-spoolss/.git] / gen_makefile_win32.pl
1 #!/usr/bin/perl -w
2 #
3 use strict;
4 use File::Glob ':globally';
5 my @list = <*.{c}>;
6 my @exes;
7 my @files;
8 my @objs;
9 my @helpers = qw(printlib.c);
10 my @helpers_objs;
11
12 sub file_is_helper($@)
13 {
14         my ($file, @helpers) = @_;
15
16         foreach my $helper (@helpers) {
17                 if ($file eq $helper) {
18                         return 1;
19                 }
20         }
21         return 0;
22 }
23
24 foreach my $file (@list) {
25         chomp($file);
26 #       printf("file: $file\n");
27         if (file_is_helper($file, @helpers)) {
28                 next;
29         }
30         push(@files, $file);
31         my $exe = $file;
32         $exe =~ s/.c$/.exe/g;
33         push(@exes, $exe);
34 }
35
36 print("CFLAGS = /nologo /Zi /MT /Gm- /W4 /FR\n");
37 print("LIBS = kernel32.lib gdi32.lib user32.lib shell32.lib \\\n");
38 print("\tadvapi32.lib ole32.lib ws2_32.lib rpcrt4.lib\n");
39 print("WINSPOOL_LIBS = winspool.lib\n\n");
40
41 print("all: @exes\n");
42 print("\n");
43
44 print(".cpp.obj:\n");
45 print("\tcl /c \$(CFLAGS) \$*.cpp\n\n");
46
47 print(".c.obj:\n");
48 print("\tcl /c \$(CFLAGS) \$*.c\n\n");
49
50 print("clean: cleantmp\n");
51 print("\t-del *.dll 2>nul\n\n");
52 print("cleantmp:\n");
53 print("\t-del *~ *.o *.obj *.sbr *.bsc *.pdb *.lib *.ilk *.exp 2>nul\n");
54 print("\t-del test_s.c test_c.c test.h 2>nul\n\n");
55
56 #print("ctags:\n");
57 #print("\tctags `find . -name \"*.[ch]\" | grep -v include/proto\.h`\n");
58 #print("\tctags --c-kinds=-p -a `find /usr/i686-pc-mingw32/sys-root/mingw/include -name \"*.[ch]\" | grep -v /CVS/`\n");
59 #print("\n");
60
61 #print("proto:\n");
62 #print("\tmkproto.pl printlib.c --private=printlib.h --public=proto_pub.h --srcdir=. --builddir=.\n");
63 #print("\n");
64
65 print("###############################\n");
66 print("# helpers\n");
67 print("###############################\n\n");
68
69 foreach my $helper (@helpers) {
70         my $obj = $helper;
71         $obj =~ s/.c$/.obj/g;
72         printf("%s: %s\n\n", $obj, $helper);
73         push(@helpers_objs, $obj);
74 }
75
76 print("###############################\n");
77 print("# binaries\n");
78 print("###############################\n\n");
79
80 foreach my $file (@files) {
81         my $exe = $file;
82         my $obj = $file;
83         my $pdb = $file;
84         $exe =~ s/.c$/.exe/g;
85         $obj =~ s/.c$/.obj/g;
86         $pdb =~ s/.c$/.pdb/g;
87 #       print "exe: $exe\n";
88         printf("%s: %s\n\n", $obj, $file);
89         printf("%s: %s %s\n", $exe, $obj, @helpers_objs);
90         printf("\tcl \$(CFLAGS) /Fe\$@ %s %s \\\n", $obj, @helpers_objs);
91         printf("\t/link /incremental:no /subsystem:console \$(LIBS) \$(WINSPOOL_LIBS)\n\n");
92 }