Message box to suggest the user not run wine as root.
[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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  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   "notepad" => 1,
33   "progman" => 1,
34   "regedit" => 1,
35   "regsvr32" => 1,
36   "uninstaller" => 1,
37   "wcmd" => 1,
38   "wineboot" => 1,
39   "winebrowser" => 1,
40   "winecfg" => 1,
41   "wineconsole" => 1,
42   "winedbg" => 1,
43   "winefile" => 1,
44   "winemine" => 1,
45   "winepath" => 1,
46   "winhelp" => 1,
47 );
48
49 # Programs that we don't want to install at all
50 my %dont_install =
51 (
52   "cmdlgtst" => 1,
53   "view" => 1,
54 );
55
56 foreach my $i (split(/\s/,$makefiles))
57 {
58     my $module;
59
60     next if $i =~ /\/tests\/Makefile.in/;
61
62     open MAKE,$i;
63
64     $module = undef;
65     while (<MAKE>)
66     {
67         chop;
68         # hack to disable this program... the MKPROG_SKIP comment must appear
69         # at the very top of the Makefile.in
70         last if (/^\#\s*MKPROG_SKIP/);
71
72         if (/^MODULE\s*=\s*([a-zA-Z0-9_.]+)/)
73         {
74             $module = $1;
75             next if ($module eq "none");
76             ($directories{$module} = $i) =~ s/^\.\/(.*)\/[^\/]+$/$1/;
77             last;
78         }
79         if (/^PROGRAMS\s*=((\s*[a-zA-Z0-9_.]+)+)/)
80         {
81             my @programs = split / /, $1;
82             foreach my $prog (@programs)
83             {
84                 next unless $prog =~ /\.exe$/;
85                 ($directories{$prog} = $i) =~ s/^\.\/(.*)\/[^\/]+$/$1/;
86             }
87             last;
88         }
89     }
90     close MAKE;
91 }
92
93 open NEWMAKE,">Makefile.in.new" or die "cannot create Makefile.in.new";
94
95 ################################################################
96 # makefile header
97
98 print NEWMAKE <<EOF;
99 # Automatically generated by make_progs; DO NOT EDIT!!
100
101 TOPSRCDIR = \@top_srcdir\@
102 TOPOBJDIR = ..
103 SRCDIR    = \@srcdir\@
104 VPATH     = \@srcdir\@
105
106 EOF
107
108 ################################################################
109 # output the subdirs list
110
111 # get rid of duplicates
112 my %alldirs = ();
113 foreach my $dir (sort values %directories) { $alldirs{$dir} = 1; }
114
115 print NEWMAKE "SUBDIRS =";
116 foreach my $dir (sort keys %alldirs)
117 {
118     printf NEWMAKE " \\\n\t%s", $dir;
119 }
120
121 print NEWMAKE "\n\n# Sub-directories to run make install into\nINSTALLSUBDIRS =";
122 foreach my $dir (sort keys %alldirs)
123 {
124     next if $dont_install{$dir};
125     printf NEWMAKE " \\\n\t%s", $dir;
126 }
127
128 print NEWMAKE "\n\n# Programs to install in bin directory\nINSTALLPROGS =";
129 foreach my $dir (sort keys %alldirs)
130 {
131     printf NEWMAKE " \\\n\t%s", $dir if $bin_install{$dir};
132 }
133
134 print NEWMAKE "\n\n# Symlinks to apps that we want to run from inside the source tree\nSYMLINKS =";
135 foreach my $mod (sort keys %directories)
136 {
137     printf NEWMAKE " \\\n\t%s", $mod;
138 }
139
140 ################################################################
141 # output the build and install targets
142
143 print NEWMAKE <<EOF;
144
145
146 \@MAKE_RULES\@
147
148 all: wineapploader winelauncher \$(SUBDIRS) \$(SYMLINKS:%=%\$(DLLEXT))
149
150 wineapploader: wineapploader.in
151         sed -e 's,\@bindir\\\@,\$(bindir),g' \$(SRCDIR)/wineapploader.in >\$\@ || (\$(RM) \$\@ && false)
152
153 winelauncher: winelauncher.in
154         sed -e 's,\@bindir\\\@,\$(bindir),g' -e 's,\@libdir\\\@,\$(libdir),g' -e 's,\@dlldir\\\@,\$(dlldir),g' \$(SRCDIR)/winelauncher.in >\$\@ || (\$(RM) \$\@ && false)
155
156 # Rules for installation
157
158 .PHONY: install-apploader install-progs install-progs.so \$(INSTALLPROGS:%=%/__installprog__)
159
160 install-apploader: wineapploader dummy
161         \$(MKINSTALLDIRS) \$(bindir)
162         \$(INSTALL_SCRIPT) wineapploader \$(bindir)/wineapploader
163
164 \$(INSTALLPROGS:%=%/__installprog__): install-apploader
165         \$(RM) \$(bindir)/`dirname \$\@` && \$(LN) \$(bindir)/wineapploader \$(bindir)/`dirname \$\@`
166
167 install-progs.so: \$(INSTALLPROGS:%=%/__installprog__)
168         \$(RM) \$(bindir)/wineapploader
169
170 install-progs: # nothing to do here
171
172 install:: winelauncher install-progs\$(DLLEXT)
173         \$(MKINSTALLDIRS) \$(bindir)
174         \$(INSTALL_SCRIPT) winelauncher \$(bindir)/winelauncher
175
176 uninstall::
177         \$(RM) \$(bindir)/wineapploader \$(bindir)/winelauncher \$(INSTALLPROGS:%=\$(bindir)/%)
178         -rmdir \$(dlldir)
179
180 clean::
181         \$(RM) wineapploader winelauncher \$(SYMLINKS)
182
183 # Rules for testing
184
185 check test:: \$(SUBDIRS:%=%/__test__)
186
187 EOF
188
189 ################################################################
190 # output the symlinks rules
191
192 print NEWMAKE "# Rules for symlinks\n\n";
193
194 foreach my $mod (sort keys %directories)
195 {
196     printf NEWMAKE "%s\$(DLLEXT)", $mod;
197     printf NEWMAKE ": %s/%s\$(DLLEXT)\n", $directories{$mod}, $mod;
198     printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s/%s\$(DLLEXT) \$@\n\n", $directories{$mod}, $mod;
199 }
200
201 foreach my $mod (sort keys %directories)
202 {
203     printf NEWMAKE "%s/%s\$(DLLEXT): %s\n", $directories{$mod}, $mod, $directories{$mod};
204 }
205
206 ################################################################
207 # makefile trailer
208
209 print NEWMAKE "\n### Dependencies:\n";
210
211 close NEWMAKE;
212 rename "Makefile.in.new", "Makefile.in";
213 printf "Successfully updated Makefile.in\n";