updates.
[silc.git] / win32 / clean_dist.pl
1 #!/usr/bin/perl
2
3 $p = `pwd`;
4
5 if($p =~ /.*(\/win32)/)
6 {
7         @dirents = split('/', $p);
8         if(@dirents > 2)
9         {
10                 # check dependencies
11                 print "Checking dependencies\n";
12                 @statLibSilcDllDebug = stat("libsilc/Debug/libsilc.dll");
13                 @statLibSilcExpDebug = stat("libsilc/Debug/libsilc.exp");
14                 @statLibSilcLibDebug = stat("libsilc/Debug/libsilc.lib");
15                 if(! @statLibSilcDllDebug || ! @statLibSilcExpDebug || ! @statLibSilcLibDebug)
16                 {
17                         die "Please rebuild libsilc Debug before creating the distribution\n";
18                 }
19                 
20                 @statLibSilcDllRelease = stat("libsilc/Release/libsilc.dll");
21                 @statLibSilcExpRelease = stat("libsilc/Release/libsilc.exp");
22                 @statLibSilcLibRelease = stat("libsilc/Release/libsilc.lib");
23                 if(! @statLibSilcDllRelease || ! @statLibSilcExpRelease || ! @statLibSilcLibRelease)
24                 {
25                         die "Please rebuild libsilc Release before creating the distribution\n";
26                 }
27                 
28                 @statLibSilcClientDllDebug = stat("libsilcclient/Debug/libsilcclient.dll");
29                 @statLibSilcClientExpDebug = stat("libsilcclient/Debug/libsilcclient.exp");
30                 @statLibSilcClientLibDebug = stat("libsilcclient/Debug/libsilcclient.lib");
31                 if(! @statLibSilcClientDllDebug || 
32                         ! @statLibSilcClientExpDebug || 
33                         ! @statLibSilcClientLibDebug || 
34                         (@statLibSilcClientDllDebug[9] < @statLibSilcDllDebug[9]) ||
35                         (@statLibSilcClientExpDebug[9] < @statLibSilcExpDebug[9]) ||
36                         (@statLibSilcClientLibDebug[9] < @statLibSilcLibDebug[9])
37                         )
38                 {                       
39                         die "Please rebuild libsilcclient Debug before creating the distribution\n";
40                 }
41
42                 @statLibSilcClientDllRelease = stat("libsilcclient/Release/libsilcclient.dll");
43                 @statLibSilcClientExpRelease = stat("libsilcclient/Release/libsilcclient.exp");
44                 @statLibSilcClientLibRelease = stat("libsilcclient/Release/libsilcclient.lib");
45                 if(! @statLibSilcClientDllRelease || 
46                         ! @statLibSilcClientExpRelease || 
47                         ! @statLibSilcClientLibRelease ||
48                         (@statLibSilcClientDllRelease[9] < @statLibSilcDllRelease[9]) ||
49                         (@statLibSilcClientExpRelease[9] < @statLibSilcExpRelease[9]) ||
50                         (@statLibSilcClientLibRelease[9] < @statLibSilcLibRelease[9])
51                         )
52                 {
53                         die "Please rebuild libsilcclient Release before creating the distribution\n";
54                 }
55
56                 @statLibSilcStaticLibDebug = stat("libsilc_static/Debug/libsilc_static.lib");
57                 if(! @statLibSilcStaticLibDebug)
58                 {
59                         die "Please rebuild libsilc_static Debug before creating the distribution\n";
60                 }
61                 
62                 @statLibSilcStaticLibRelease = stat("libsilc_static/Release/libsilc_static.lib");
63                 if(! @statLibSilcStaticLibRelease)
64                 {
65                         die "Please rebuild libsilc_static Release before creating the distribution\n";
66                 }
67                 
68                 @statLibSilcClientStaticLibDebug = stat("libsilcclient_static/Debug/libsilcclient_static.lib");
69                 if(! @statLibSilcClientStaticLibDebug || (@statLibSilcClientStaticLibDebug[9] < @statLibSilcStaticLibDebug[9]))
70                 {                       
71                         die "Please rebuild libsilcclient_static Debug before creating the distribution\n";
72                 }
73
74                 @statLibSilcClientStaticLibRelease = stat("libsilcclient_static/Release/libsilcclient_static.lib");
75                 if(! @statLibSilcClientStaticLibRelease || (@statLibSilcClientStaticLibRelease[9] < @statLibSilcStaticLibRelease[9]))
76                 {                       
77                         die "Please rebuild libsilcclient_static Release before creating the distribution\n";
78                 }
79
80                 $index = @dirents - 2;
81                 $top = @dirents[$index];
82                 `find . -name \"*.obj\" -exec rm -f \\{} \\;`;
83                 `find . -name \"*.idb\" -exec rm -f \\{} \\;`;
84                 `find . -name \"*.pdb\" -exec rm -f \\{} \\;`;
85                 `find . -name \"*.pch\" -exec rm -f \\{} \\;`;
86                 `find ../ -name \"*.o\" -exec rm -f \\{} \\;`;
87                 `find ../ -name \"*.lo\" -exec rm -f \\{} \\;`;
88                 `find ../ -name \"*.a\" -exec rm -f \\{} \\;`;
89                 `find ../ -name \"*.la\" -exec rm -f \\{} \\;`;
90                 `find ../ -name \"*.lai\" -exec rm -f \\{} \\;`;
91
92                 push(@excludeList, "--exclude $top/win32/Debug");
93                 push(@excludeList, "--exclude $top/win32/libsilc/CVS");
94                 push(@excludeList, "--exclude $top/win32/libsilc/libsilc.plg");
95                 push(@excludeList, "--exclude $top/win32/libsilcclient/CVS");
96                 push(@excludeList, "--exclude $top/win32/libsilcclient/libsilcclient.plg");
97                 push(@excludeList, "--exclude $top/win32/libsilc_static/CVS");
98                 push(@excludeList, "--exclude $top/win32/libsilc_static/libsilc_static.plg");
99                 push(@excludeList, "--exclude $top/win32/libsilcclient_static/CVS");
100                 push(@excludeList, "--exclude $top/win32/libsilcclient_static/libsilcclient_static.plg");
101                 push(@excludeList, "--exclude $top/win32/silc.ncb");
102                 push(@excludeList, "--exclude $top/win32/all.plg");
103                 push(@excludeList, "--exclude $top/win32/buildDistAfterAllReleaseAndDebug.plg");
104                 push(@excludeList, "--exclude $top/win32/CVS");
105                 push(@excludeList, "--exclude $top/win32/tests/CVS");
106                 push(@excludeList, "--exclude $top/win32/libsilc/Debug/libsilc.ilk");
107                 push(@excludeList, "--exclude $top/win32/libsilc/Debug/libsilc.pdb");
108                 push(@excludeList, "--exclude $top/win32/libsilcclient/Debug/libsilcclient.ilk");
109                 push(@excludeList, "--exclude $top/win32/libsilcclient/Debug/libsilcclient.pdb");
110                 push(@excludeList, "--exclude $top/win32/libsilc/Release/libsilc.ilk");
111                 push(@excludeList, "--exclude $top/win32/libsilc/Release/libsilc.pdb");
112                 push(@excludeList, "--exclude $top/win32/libsilcclient/Release/libsilcclient.ilk");
113                 push(@excludeList, "--exclude $top/win32/silc.opt");
114                 push(@excludeList, "--exclude $top/win32/tests");
115                 push(@excludeList, "--exclude $top/apps");
116                 push(@excludeList, "--exclude $top/doc/CVS");
117                 push(@excludeList, "--exclude $top/doc/examples/CVS");
118                 push(@excludeList, "--exclude $top/includes/CVS");
119                 push(@excludeList, "--exclude $top/lib");
120                 push(@excludeList, "--exclude $top/tutorial/CVS");
121                 push(@excludeList, "--exclude $top/tutorial/mybot/CVS");
122
123                 $excludes = "";
124                 foreach $entry(@excludeList)
125                 {
126                         $excludes = sprintf("%s%s ", $excludes, $entry);
127                 }
128                 
129                 print "Copying headers\n";
130                 `rm -rf include`;
131                 `mkdir -p include`;
132                 `find ../includes -name \"*.h\" -exec cp \\{} include \\;`;
133                 `find ../lib -name \"*.h\" -exec cp \\{} include \\;`;
134                 print "Creating distribution archive.\n";
135                 `cd ../.. ; tar $excludes -zcvf $top-win32.tgz $top/*` || die "Failed to create distribution\n";        
136         }
137 }
138 else
139 {
140         die "Please run $0 from the win32 directory of the silc distribution\n";
141 }
142