mshtml: Don't crash in QueryInterface if uri is NULL.
[wine] / programs / make_progs
1 #!/usr/bin/perl -w
2 #
3 # Update the dependencies in the programs main Makefile.in.
4 # Must be run in the programs/ directory of the Wine tree.
5 #
6 # Copyright 2003 Alexandre Julliard
7 #
8 # This library is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU Lesser General Public
10 # License as published by the Free Software Foundation; either
11 # version 2.1 of the License, or (at your option) any later version.
12 #
13 # This library is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 # Lesser General Public License for more details.
17 #
18 # You should have received a copy of the GNU Lesser General Public
19 # License along with this library; if not, write to the Free Software
20 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #
22
23 use strict;
24
25 my $makefiles = `find . -name Makefile.in -print`;
26
27 my %directories = ();
28
29 # Programs that we want to install in the bin directory too
30 my %bin_install =
31 (
32   "msiexec" => 1,
33   "notepad" => 1,
34   "progman" => 1,
35   "regedit" => 1,
36   "regsvr32" => 1,
37   "uninstaller" => 1,
38   "wcmd" => 1,
39   "wineboot" => 1,
40   "winebrowser" => 1,
41   "winecfg" => 1,
42   "wineconsole" => 1,
43   "winedbg" => 1,
44   "winefile" => 1,
45   "winemine" => 1,
46   "winepath" => 1,
47   "winhelp" => 1,
48 );
49
50 # Programs that we don't want to install at all
51 my %dont_install =
52 (
53   "cmdlgtst" => 1,
54   "view" => 1,
55   "winetest" => 1,
56 );
57
58 foreach my $i (split(/\s/,$makefiles))
59 {
60     my $module;
61
62     next if $i =~ /\/tests\/Makefile.in/;
63
64     open MAKE,$i;
65
66     $module = undef;
67     while (<MAKE>)
68     {
69         chop;
70         # hack to disable this program... the MKPROG_SKIP comment must appear
71         # at the very top of the Makefile.in
72         last if (/^\#\s*MKPROG_SKIP/);
73
74         if (/^MODULE\s*=\s*([a-zA-Z0-9_.]+)/)
75         {
76             $module = $1;
77             next if ($module eq "none");
78             ($directories{$module} = $i) =~ s/^\.\/(.*)\/[^\/]+$/$1/;
79             die "invalid module $module in dir $directories{$module}\n" if "$directories{$module}.exe" ne $module;
80             last;
81         }
82         if (/^PROGRAMS\s*=((\s*[a-zA-Z0-9_.]+)+)/)
83         {
84             my @programs = split / /, $1;
85             foreach my $prog (@programs)
86             {
87                 next unless $prog =~ /\.exe$/;
88                 ($directories{$prog} = $i) =~ s/^\.\/(.*)\/[^\/]+$/$1/;
89             }
90             last;
91         }
92     }
93     close MAKE;
94 }
95
96 open NEWMAKE,">Makefile.in.new" or die "cannot create Makefile.in.new";
97
98 ################################################################
99 # makefile header
100
101 print NEWMAKE <<EOF;
102 # Automatically generated by make_progs; DO NOT EDIT!!
103
104 TOPSRCDIR = \@top_srcdir\@
105 TOPOBJDIR = ..
106 SRCDIR    = \@srcdir\@
107 VPATH     = \@srcdir\@
108
109 EOF
110
111 ################################################################
112 # output the subdirs list
113
114 # get rid of duplicates
115 my %alldirs = ();
116 foreach my $dir (sort values %directories) { $alldirs{$dir} = 1; }
117
118 print NEWMAKE "SUBDIRS =";
119 foreach my $dir (sort keys %alldirs)
120 {
121     printf NEWMAKE " \\\n\t%s", $dir;
122 }
123
124 print NEWMAKE "\n\n# Sub-directories to run make install into\nINSTALLSUBDIRS =";
125 foreach my $dir (sort keys %alldirs)
126 {
127     next if $dont_install{$dir};
128     printf NEWMAKE " \\\n\t%s", $dir;
129 }
130
131 print NEWMAKE "\n\n# Programs to install in bin directory\nINSTALLPROGS =";
132 foreach my $dir (sort keys %alldirs)
133 {
134     printf NEWMAKE " \\\n\t%s", $dir if $bin_install{$dir};
135 }
136
137 ################################################################
138 # output the build and install targets
139
140 print NEWMAKE <<EOF;
141
142
143 \@MAKE_RULES\@
144
145 all: wineapploader winelauncher \$(SUBDIRS)
146
147 wineapploader: wineapploader.in
148         sed -e 's,\@bindir\\\@,\$(bindir),g' \$(SRCDIR)/wineapploader.in >\$\@ || (\$(RM) \$\@ && false)
149
150 winelauncher: winelauncher.in
151         sed -e 's,\@bindir\\\@,\$(bindir),g' -e 's,\@libdir\\\@,\$(libdir),g' -e 's,\@dlldir\\\@,\$(dlldir),g' \$(SRCDIR)/winelauncher.in >\$\@ || (\$(RM) \$\@ && false)
152
153 # Rules for installation
154
155 .PHONY: install-apploader install-progs install-progs.so \$(INSTALLPROGS:%=%/__installprog__)
156
157 install-apploader: wineapploader dummy
158         \$(MKINSTALLDIRS) \$(DESTDIR)\$(bindir)
159         \$(INSTALL_SCRIPT) wineapploader \$(DESTDIR)\$(bindir)/wineapploader
160
161 \$(INSTALLPROGS:%=%/__installprog__): install-apploader
162         \$(RM) \$(DESTDIR)\$(bindir)/`dirname \$\@` && \$(LN) \$(DESTDIR)\$(bindir)/wineapploader \$(DESTDIR)\$(bindir)/`dirname \$\@`
163
164 install-progs.so: \$(INSTALLPROGS:%=%/__installprog__)
165         \$(RM) \$(DESTDIR)\$(bindir)/wineapploader
166
167 install-progs: # nothing to do here
168
169 install:: winelauncher install-progs\$(DLLEXT)
170         \$(MKINSTALLDIRS) \$(DESTDIR)\$(bindir)
171         \$(INSTALL_SCRIPT) winelauncher \$(DESTDIR)\$(bindir)/winelauncher
172
173 uninstall::
174         -cd \$(DESTDIR)\$(bindir) && \$(RM) wineapploader winelauncher \$(INSTALLPROGS)
175         -rmdir \$(DESTDIR)\$(dlldir)
176
177 clean::
178         \$(RM) wineapploader winelauncher
179
180 # Rules for testing
181
182 check test:: \$(SUBDIRS:%=%/__test__)
183
184 ### Dependencies:
185 EOF
186
187 close NEWMAKE;
188 rename "Makefile.in.new", "Makefile.in";
189 printf "Successfully updated Makefile.in\n";
190
191 ################################################################
192 # .gitignore file
193
194 open GITIGNORE, ">.gitignore.new" or die "cannot create .gitignore.new";
195 print GITIGNORE "# Automatically generated by make_dlls; DO NOT EDIT!!\n";
196
197 my @ignores =
198 (
199  "/Makeprog.rules",
200  "/wineapploader",
201  "/winelauncher",
202 );
203
204 foreach my $dir (sort keys %alldirs)
205 {
206     push @ignores, "$dir/$dir";
207 }
208
209 print GITIGNORE join("\n", sort @ignores) . "\n";
210
211 close GITIGNORE;
212 rename ".gitignore.new", ".gitignore";
213 printf "Successfully updated .gitignore\n";