msi: Callers of alloc_msihandle should handle failure.
[wine/wine64.git] / programs / make_progs
blob10edb18468bb4270e8dd213ec8717bef63d69e0a
1 #!/usr/bin/perl -w
3 # Update the dependencies in the programs main Makefile.in.
4 # Must be run in the programs/ directory of the Wine tree.
6 # Copyright 2003 Alexandre Julliard
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.
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.
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
23 use strict;
25 my %directories = ();
27 # Programs that we want to install in the bin directory too
28 my %bin_install =
30 "msiexec" => 1,
31 "notepad" => 1,
32 "progman" => 1,
33 "regedit" => 1,
34 "regsvr32" => 1,
35 "uninstaller" => 1,
36 "wcmd" => 1,
37 "wineboot" => 1,
38 "winebrowser" => 1,
39 "winecfg" => 1,
40 "wineconsole" => 1,
41 "winedbg" => 1,
42 "winefile" => 1,
43 "winemine" => 1,
44 "winepath" => 1,
45 "winhelp" => 1,
48 # Programs that we don't want to install at all
49 my %dont_install =
51 "cmdlgtst" => 1,
52 "view" => 1,
53 "winetest" => 1,
56 sub update_file($)
58 my $file = shift;
59 if (!system "cmp $file $file.new >/dev/null")
61 unlink "$file.new";
62 print "$file is unchanged\n";
64 else
66 rename "$file.new", "$file";
67 print "$file updated\n";
71 # if we are inside the programs dir, go up one level
72 if (! -f "configure.ac" && -f "../configure.ac") { chdir(".."); }
74 my @args = @ARGV;
75 if (!@args) { @args = split /\s/, `find programs -name Makefile.in -print`; }
77 foreach my $i (@args)
79 my $module;
81 open MAKE,$i;
83 $module = undef;
84 while (<MAKE>)
86 chop;
87 # hack to disable this program... the MKPROG_SKIP comment must appear
88 # at the very top of the Makefile.in
89 last if (/^\#\s*MKPROG_SKIP/);
91 if (/^MODULE\s*=\s*([a-zA-Z0-9_.]+)/)
93 $module = $1;
94 next if ($module eq "none");
95 ($directories{$module} = $i) =~ s/^programs\/(.*)\/[^\/]+$/$1/;
96 die "invalid module $module in dir $directories{$module}\n" if "$directories{$module}.exe" ne $module;
97 last;
99 if (/^PROGRAMS\s*=((\s*[a-zA-Z0-9_.]+)+)/)
101 my @programs = split / /, $1;
102 foreach my $prog (@programs)
104 next unless $prog =~ /\.exe$/;
105 ($directories{$prog} = $i) =~ s/^\.\/(.*)\/[^\/]+$/$1/;
107 last;
110 close MAKE;
113 open NEWMAKE,">programs/Makefile.in.new" or die "cannot create programs/Makefile.in.new";
115 ################################################################
116 # makefile header
118 print NEWMAKE <<EOF;
119 # Automatically generated by make_progs; DO NOT EDIT!!
121 TOPSRCDIR = \@top_srcdir\@
122 TOPOBJDIR = ..
123 SRCDIR = \@srcdir\@
124 VPATH = \@srcdir\@
128 ################################################################
129 # output the subdirs list
131 # get rid of duplicates
132 my %alldirs = ();
133 foreach my $dir (sort values %directories) { $alldirs{$dir} = 1; }
135 print NEWMAKE "SUBDIRS =";
136 foreach my $dir (sort keys %alldirs)
138 printf NEWMAKE " \\\n\t%s", $dir;
141 print NEWMAKE "\n\n# Sub-directories to run make install into\nINSTALLSUBDIRS =";
142 foreach my $dir (sort keys %alldirs)
144 next if $dont_install{$dir};
145 printf NEWMAKE " \\\n\t%s", $dir;
148 print NEWMAKE "\n\n# Programs to install in bin directory\nINSTALLPROGS =";
149 foreach my $dir (sort keys %alldirs)
151 printf NEWMAKE " \\\n\t%s", $dir if $bin_install{$dir};
154 ################################################################
155 # output the build and install targets
157 print NEWMAKE <<EOF;
160 INSTALLDIRS = \$(DESTDIR)\$(bindir)
162 \@MAKE_RULES\@
164 all: wineapploader winelauncher \$(SUBDIRS)
166 wineapploader: wineapploader.in
167 sed -e 's,\@bindir\\\@,\$(bindir),g' \$(SRCDIR)/wineapploader.in >\$\@ || (\$(RM) \$\@ && false)
169 winelauncher: winelauncher.in
170 sed -e 's,\@bindir\\\@,\$(bindir),g' -e 's,\@libdir\\\@,\$(libdir),g' -e 's,\@dlldir\\\@,\$(dlldir),g' \$(SRCDIR)/winelauncher.in >\$\@ || (\$(RM) \$\@ && false)
172 # Rules for installation
174 .PHONY: install-apploader install-progs install-progs.so \$(INSTALLPROGS:%=%/__installprog__)
176 install-apploader: wineapploader \$(INSTALLDIRS) dummy
177 \$(INSTALL_SCRIPT) wineapploader \$(DESTDIR)\$(bindir)/wineapploader
179 \$(INSTALLPROGS:%=%/__installprog__): install-apploader
180 \$(RM) \$(DESTDIR)\$(bindir)/`dirname \$\@` && \$(LN) \$(DESTDIR)\$(bindir)/wineapploader \$(DESTDIR)\$(bindir)/`dirname \$\@`
182 install-progs.so: \$(INSTALLPROGS:%=%/__installprog__)
183 \$(RM) \$(DESTDIR)\$(bindir)/wineapploader
185 install-progs: # nothing to do here
187 install:: winelauncher install-progs\$(DLLEXT) \$(INSTALLDIRS)
188 \$(INSTALL_SCRIPT) winelauncher \$(DESTDIR)\$(bindir)/winelauncher
190 uninstall::
191 -cd \$(DESTDIR)\$(bindir) && \$(RM) wineapploader winelauncher \$(INSTALLPROGS)
192 -rmdir \$(DESTDIR)\$(dlldir)
194 clean::
195 \$(RM) wineapploader winelauncher
197 # Rules for testing
199 check test:: \$(SUBDIRS:%=%/__test__)
201 ### Dependencies:
204 close NEWMAKE;
205 update_file("programs/Makefile.in");
207 ################################################################
208 # .gitignore file
210 open GITIGNORE, ">programs/.gitignore.new" or die "cannot create programs/.gitignore.new";
211 print GITIGNORE "# Automatically generated by make_dlls; DO NOT EDIT!!\n";
213 my @ignores =
215 "/Makeprog.rules",
216 "/wineapploader",
217 "/winelauncher",
220 foreach my $dir (sort keys %alldirs)
222 push @ignores, "$dir/$dir";
225 print GITIGNORE join("\n", sort @ignores) . "\n";
227 close GITIGNORE;
228 update_file("programs/.gitignore");