make_progs 5.63 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
#!/usr/bin/perl -w
#
# Update the dependencies in the programs main Makefile.in.
# Must be run in the programs/ directory of the Wine tree.
#
# Copyright 2003 Alexandre Julliard
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#

use strict;

my $makefiles = `find . -name Makefile.in -print`;

my %directories = ();

# Programs that we want to install in the bin directory too
my %bin_install =
(
32
  "msiexec" => 1,
33 34 35 36 37 38 39
  "notepad" => 1,
  "progman" => 1,
  "regedit" => 1,
  "regsvr32" => 1,
  "uninstaller" => 1,
  "wcmd" => 1,
  "wineboot" => 1,
40
  "winebrowser" => 1,
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
  "winecfg" => 1,
  "wineconsole" => 1,
  "winedbg" => 1,
  "winefile" => 1,
  "winemine" => 1,
  "winepath" => 1,
  "winhelp" => 1,
);

# Programs that we don't want to install at all
my %dont_install =
(
  "cmdlgtst" => 1,
  "view" => 1,
);

foreach my $i (split(/\s/,$makefiles))
{
    my $module;

    next if $i =~ /\/tests\/Makefile.in/;

    open MAKE,$i;

    $module = undef;
    while (<MAKE>)
    {
        chop;
        # hack to disable this program... the MKPROG_SKIP comment must appear
        # at the very top of the Makefile.in
        last if (/^\#\s*MKPROG_SKIP/);

        if (/^MODULE\s*=\s*([a-zA-Z0-9_.]+)/)
        {
            $module = $1;
            next if ($module eq "none");
            ($directories{$module} = $i) =~ s/^\.\/(.*)\/[^\/]+$/$1/;
            last;
        }
        if (/^PROGRAMS\s*=((\s*[a-zA-Z0-9_.]+)+)/)
        {
            my @programs = split / /, $1;
            foreach my $prog (@programs)
            {
                next unless $prog =~ /\.exe$/;
                ($directories{$prog} = $i) =~ s/^\.\/(.*)\/[^\/]+$/$1/;
            }
            last;
        }
    }
    close MAKE;
}

open NEWMAKE,">Makefile.in.new" or die "cannot create Makefile.in.new";

################################################################
# makefile header

print NEWMAKE <<EOF;
# Automatically generated by make_progs; DO NOT EDIT!!

TOPSRCDIR = \@top_srcdir\@
TOPOBJDIR = ..
SRCDIR    = \@srcdir\@
VPATH     = \@srcdir\@

EOF

################################################################
# output the subdirs list

# get rid of duplicates
my %alldirs = ();
foreach my $dir (sort values %directories) { $alldirs{$dir} = 1; }

print NEWMAKE "SUBDIRS =";
foreach my $dir (sort keys %alldirs)
{
    printf NEWMAKE " \\\n\t%s", $dir;
}

print NEWMAKE "\n\n# Sub-directories to run make install into\nINSTALLSUBDIRS =";
foreach my $dir (sort keys %alldirs)
{
    next if $dont_install{$dir};
    printf NEWMAKE " \\\n\t%s", $dir;
}

print NEWMAKE "\n\n# Programs to install in bin directory\nINSTALLPROGS =";
foreach my $dir (sort keys %alldirs)
{
    printf NEWMAKE " \\\n\t%s", $dir if $bin_install{$dir};
}

print NEWMAKE "\n\n# Symlinks to apps that we want to run from inside the source tree\nSYMLINKS =";
foreach my $mod (sort keys %directories)
{
138
    printf NEWMAKE " \\\n\t%s\$(DLLEXT)", $mod;
139 140 141 142 143 144 145 146 147 148
}

################################################################
# output the build and install targets

print NEWMAKE <<EOF;


\@MAKE_RULES\@

149
all: wineapploader winelauncher \$(SUBDIRS) \$(SYMLINKS)
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177

wineapploader: wineapploader.in
	sed -e 's,\@bindir\\\@,\$(bindir),g' \$(SRCDIR)/wineapploader.in >\$\@ || (\$(RM) \$\@ && false)

winelauncher: winelauncher.in
	sed -e 's,\@bindir\\\@,\$(bindir),g' -e 's,\@libdir\\\@,\$(libdir),g' -e 's,\@dlldir\\\@,\$(dlldir),g' \$(SRCDIR)/winelauncher.in >\$\@ || (\$(RM) \$\@ && false)

# Rules for installation

.PHONY: install-apploader install-progs install-progs.so \$(INSTALLPROGS:%=%/__installprog__)

install-apploader: wineapploader dummy
	\$(MKINSTALLDIRS) \$(bindir)
	\$(INSTALL_SCRIPT) wineapploader \$(bindir)/wineapploader

\$(INSTALLPROGS:%=%/__installprog__): install-apploader
	\$(RM) \$(bindir)/`dirname \$\@` && \$(LN) \$(bindir)/wineapploader \$(bindir)/`dirname \$\@`

install-progs.so: \$(INSTALLPROGS:%=%/__installprog__)
	\$(RM) \$(bindir)/wineapploader

install-progs: # nothing to do here

install:: winelauncher install-progs\$(DLLEXT)
	\$(MKINSTALLDIRS) \$(bindir)
	\$(INSTALL_SCRIPT) winelauncher \$(bindir)/winelauncher

uninstall::
178
	-cd \$(bindir) && \$(RM) wineapploader winelauncher \$(INSTALLPROGS)
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214
	-rmdir \$(dlldir)

clean::
	\$(RM) wineapploader winelauncher \$(SYMLINKS)

# Rules for testing

check test:: \$(SUBDIRS:%=%/__test__)

EOF

################################################################
# output the symlinks rules

print NEWMAKE "# Rules for symlinks\n\n";

foreach my $mod (sort keys %directories)
{
    printf NEWMAKE "%s\$(DLLEXT)", $mod;
    printf NEWMAKE ": %s/%s\$(DLLEXT)\n", $directories{$mod}, $mod;
    printf NEWMAKE "\t\$(RM) \$@ && \$(LN_S) %s/%s\$(DLLEXT) \$@\n\n", $directories{$mod}, $mod;
}

foreach my $mod (sort keys %directories)
{
    printf NEWMAKE "%s/%s\$(DLLEXT): %s\n", $directories{$mod}, $mod, $directories{$mod};
}

################################################################
# makefile trailer

print NEWMAKE "\n### Dependencies:\n";

close NEWMAKE;
rename "Makefile.in.new", "Makefile.in";
printf "Successfully updated Makefile.in\n";