Make sure sed uses the right locale.
[wine/dcerpc.git] / programs / make_progs
blob1c786c6b579fe762e0b18ffff9d89f806c84c87e
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 use strict;
25 my $makefiles = `find . -name Makefile.in -print`;
27 my %directories = ();
29 # Programs that we want to install in the bin directory too
30 my %bin_install =
32 "notepad" => 1,
33 "progman" => 1,
34 "regedit" => 1,
35 "regsvr32" => 1,
36 "uninstaller" => 1,
37 "wcmd" => 1,
38 "wineboot" => 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,
55 foreach my $i (split(/\s/,$makefiles))
57 my $module;
59 next if $i =~ /\/tests\/Makefile.in/;
61 open MAKE,$i;
63 $module = undef;
64 while (<MAKE>)
66 chop;
67 # hack to disable this program... the MKPROG_SKIP comment must appear
68 # at the very top of the Makefile.in
69 last if (/^\#\s*MKPROG_SKIP/);
71 if (/^MODULE\s*=\s*([a-zA-Z0-9_.]+)/)
73 $module = $1;
74 next if ($module eq "none");
75 ($directories{$module} = $i) =~ s/^\.\/(.*)\/[^\/]+$/$1/;
76 last;
78 if (/^PROGRAMS\s*=((\s*[a-zA-Z0-9_.]+)+)/)
80 my @programs = split / /, $1;
81 foreach my $prog (@programs)
83 next unless $prog =~ /\.exe$/;
84 ($directories{$prog} = $i) =~ s/^\.\/(.*)\/[^\/]+$/$1/;
86 last;
89 close MAKE;
92 open NEWMAKE,">Makefile.in.new" or die "cannot create Makefile.in.new";
94 ################################################################
95 # makefile header
97 print NEWMAKE <<EOF;
98 # Automatically generated by make_progs; DO NOT EDIT!!
100 TOPSRCDIR = \@top_srcdir\@
101 TOPOBJDIR = ..
102 SRCDIR = \@srcdir\@
103 VPATH = \@srcdir\@
107 ################################################################
108 # output the subdirs list
110 # get rid of duplicates
111 my %alldirs = ();
112 foreach my $dir (sort values %directories) { $alldirs{$dir} = 1; }
114 print NEWMAKE "SUBDIRS =";
115 foreach my $dir (sort keys %alldirs)
117 printf NEWMAKE " \\\n\t%s", $dir;
120 print NEWMAKE "\n\n# Sub-directories to run make install into\nINSTALLSUBDIRS =";
121 foreach my $dir (sort keys %alldirs)
123 next if $dont_install{$dir};
124 printf NEWMAKE " \\\n\t%s", $dir;
127 print NEWMAKE "\n\n# Programs to install in bin directory\nINSTALLPROGS =";
128 foreach my $dir (sort keys %alldirs)
130 printf NEWMAKE " \\\n\t%s", $dir if $bin_install{$dir};
133 print NEWMAKE "\n\n# Symlinks to apps that we want to run from inside the source tree\nSYMLINKS =";
134 foreach my $mod (sort keys %directories)
136 printf NEWMAKE " \\\n\t%s", $mod;
139 ################################################################
140 # output the build and install targets
142 print NEWMAKE <<EOF;
145 \@MAKE_RULES\@
147 all: wineapploader winelauncher \$(SUBDIRS) \$(SYMLINKS:%=%\$(DLLEXT))
149 wineapploader: wineapploader.in
150 sed -e 's,\@bindir\\\@,\$(bindir),g' \$(SRCDIR)/wineapploader.in >\$\@ || (\$(RM) \$\@ && false)
152 winelauncher: winelauncher.in
153 sed -e 's,\@bindir\\\@,\$(bindir),g' -e 's,\@libdir\\\@,\$(libdir),g' -e 's,\@dlldir\\\@,\$(dlldir),g' \$(SRCDIR)/winelauncher.in >\$\@ || (\$(RM) \$\@ && false)
155 # Rules for installation
157 .PHONY: install-apploader install-progs install-progs.so \$(INSTALLPROGS:%=%/__installprog__)
159 install-apploader: wineapploader dummy
160 \$(MKINSTALLDIRS) \$(bindir)
161 \$(INSTALL_SCRIPT) wineapploader \$(bindir)/wineapploader
163 \$(INSTALLPROGS:%=%/__installprog__): install-apploader
164 \$(RM) \$(bindir)/`dirname \$\@` && \$(LN) \$(bindir)/wineapploader \$(bindir)/`dirname \$\@`
166 install-progs.so: \$(INSTALLPROGS:%=%/__installprog__)
167 \$(RM) \$(bindir)/wineapploader
169 install-progs: # nothing to do here
171 install:: winelauncher install-progs\$(DLLEXT)
172 \$(MKINSTALLDIRS) \$(bindir)
173 \$(INSTALL_SCRIPT) winelauncher \$(bindir)/winelauncher
175 uninstall::
176 \$(RM) \$(bindir)/wineapploader \$(bindir)/winelauncher \$(INSTALLPROGS:%=\$(bindir)/%)
177 -rmdir \$(dlldir)
179 clean::
180 \$(RM) wineapploader winelauncher \$(SYMLINKS)
182 # Rules for testing
184 check test:: \$(SUBDIRS:%=%/__test__)
188 ################################################################
189 # output the symlinks rules
191 print NEWMAKE "# Rules for symlinks\n\n";
193 foreach my $mod (sort keys %directories)
195 printf NEWMAKE "%s\$(DLLEXT)", $mod;
196 printf NEWMAKE ": %s/%s\$(DLLEXT)\n", $directories{$mod}, $mod;
197 printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s/%s\$(DLLEXT) \$@\n\n", $directories{$mod}, $mod;
200 foreach my $mod (sort keys %directories)
202 printf NEWMAKE "%s/%s\$(DLLEXT): %s\n", $directories{$mod}, $mod, $directories{$mod};
205 ################################################################
206 # makefile trailer
208 print NEWMAKE "\n### Dependencies:\n";
210 close NEWMAKE;
211 rename "Makefile.in.new", "Makefile.in";
212 printf "Successfully updated Makefile.in\n";