wmc: Get rid of xmalloc casts.
[wine.git] / programs / make_progs
blob01788d4e678f49d7824addbb4eba4ae9dc54a35c
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 $makefiles = `find programs -name Makefile.in -print`;
76 foreach my $i (split(/\s/,$makefiles))
78 my $module;
80 open MAKE,$i;
82 $module = undef;
83 while (<MAKE>)
85 chop;
86 # hack to disable this program... the MKPROG_SKIP comment must appear
87 # at the very top of the Makefile.in
88 last if (/^\#\s*MKPROG_SKIP/);
90 if (/^MODULE\s*=\s*([a-zA-Z0-9_.]+)/)
92 $module = $1;
93 next if ($module eq "none");
94 ($directories{$module} = $i) =~ s/^programs\/(.*)\/[^\/]+$/$1/;
95 die "invalid module $module in dir $directories{$module}\n" if "$directories{$module}.exe" ne $module;
96 last;
98 if (/^PROGRAMS\s*=((\s*[a-zA-Z0-9_.]+)+)/)
100 my @programs = split / /, $1;
101 foreach my $prog (@programs)
103 next unless $prog =~ /\.exe$/;
104 ($directories{$prog} = $i) =~ s/^\.\/(.*)\/[^\/]+$/$1/;
106 last;
109 close MAKE;
112 open NEWMAKE,">programs/Makefile.in.new" or die "cannot create programs/Makefile.in.new";
114 ################################################################
115 # makefile header
117 print NEWMAKE <<EOF;
118 # Automatically generated by make_progs; DO NOT EDIT!!
120 TOPSRCDIR = \@top_srcdir\@
121 TOPOBJDIR = ..
122 SRCDIR = \@srcdir\@
123 VPATH = \@srcdir\@
127 ################################################################
128 # output the subdirs list
130 # get rid of duplicates
131 my %alldirs = ();
132 foreach my $dir (sort values %directories) { $alldirs{$dir} = 1; }
134 print NEWMAKE "SUBDIRS =";
135 foreach my $dir (sort keys %alldirs)
137 printf NEWMAKE " \\\n\t%s", $dir;
140 print NEWMAKE "\n\n# Sub-directories to run make install into\nINSTALLSUBDIRS =";
141 foreach my $dir (sort keys %alldirs)
143 next if $dont_install{$dir};
144 printf NEWMAKE " \\\n\t%s", $dir;
147 print NEWMAKE "\n\n# Programs to install in bin directory\nINSTALLPROGS =";
148 foreach my $dir (sort keys %alldirs)
150 printf NEWMAKE " \\\n\t%s", $dir if $bin_install{$dir};
153 ################################################################
154 # output the build and install targets
156 print NEWMAKE <<EOF;
159 INSTALLDIRS = \$(DESTDIR)\$(bindir)
161 \@MAKE_RULES\@
163 all: wineapploader winelauncher \$(SUBDIRS)
165 wineapploader: wineapploader.in
166 sed -e 's,\@bindir\\\@,\$(bindir),g' \$(SRCDIR)/wineapploader.in >\$\@ || (\$(RM) \$\@ && false)
168 winelauncher: winelauncher.in
169 sed -e 's,\@bindir\\\@,\$(bindir),g' -e 's,\@libdir\\\@,\$(libdir),g' -e 's,\@dlldir\\\@,\$(dlldir),g' \$(SRCDIR)/winelauncher.in >\$\@ || (\$(RM) \$\@ && false)
171 # Rules for installation
173 .PHONY: install-apploader install-progs install-progs.so \$(INSTALLPROGS:%=%/__installprog__)
175 install-apploader: wineapploader \$(INSTALLDIRS) dummy
176 \$(INSTALL_SCRIPT) wineapploader \$(DESTDIR)\$(bindir)/wineapploader
178 \$(INSTALLPROGS:%=%/__installprog__): install-apploader
179 \$(RM) \$(DESTDIR)\$(bindir)/`dirname \$\@` && \$(LN) \$(DESTDIR)\$(bindir)/wineapploader \$(DESTDIR)\$(bindir)/`dirname \$\@`
181 install-progs.so: \$(INSTALLPROGS:%=%/__installprog__)
182 \$(RM) \$(DESTDIR)\$(bindir)/wineapploader
184 install-progs: # nothing to do here
186 install:: winelauncher install-progs\$(DLLEXT) \$(INSTALLDIRS)
187 \$(INSTALL_SCRIPT) winelauncher \$(DESTDIR)\$(bindir)/winelauncher
189 uninstall::
190 -cd \$(DESTDIR)\$(bindir) && \$(RM) wineapploader winelauncher \$(INSTALLPROGS)
191 -rmdir \$(DESTDIR)\$(dlldir)
193 clean::
194 \$(RM) wineapploader winelauncher
196 # Rules for testing
198 check test:: \$(SUBDIRS:%=%/__test__)
200 ### Dependencies:
203 close NEWMAKE;
204 update_file("programs/Makefile.in");
206 ################################################################
207 # .gitignore file
209 open GITIGNORE, ">programs/.gitignore.new" or die "cannot create programs/.gitignore.new";
210 print GITIGNORE "# Automatically generated by make_dlls; DO NOT EDIT!!\n";
212 my @ignores =
214 "/Makeprog.rules",
215 "/wineapploader",
216 "/winelauncher",
219 foreach my $dir (sort keys %alldirs)
221 push @ignores, "$dir/$dir";
224 print GITIGNORE join("\n", sort @ignores) . "\n";
226 close GITIGNORE;
227 update_file("programs/.gitignore");
229 ################################################################
230 # configure.ac file
232 open OLD_CONFIG, "configure.ac" or die "cannot open configure.ac";
233 open NEW_CONFIG, ">configure.ac.new" or die "cannot create configure.ac.new";
235 while (<OLD_CONFIG>)
237 print NEW_CONFIG $_;
238 last if /^programs\/Makefile/;
241 foreach my $dir (sort values %directories)
243 print NEW_CONFIG "programs/$dir/Makefile\n";
246 my $skip=1;
247 while (<OLD_CONFIG>)
249 $skip = 0 unless /^programs\//;
250 print NEW_CONFIG $_ unless $skip;
253 close OLD_CONFIG;
254 close NEW_CONFIG;
255 update_file("configure.ac");