From 48c14238b877df2fe04a4b54738e073a69266ae0 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Sun, 24 Sep 2006 12:11:39 +0200 Subject: [PATCH] make_makefiles: Merged the make_progs script into make_makefiles. --- programs/.gitignore | 2 +- programs/make_progs | 225 ------------------------------------------- tools/make_makefiles | 109 ++++++++++++++++++--- 3 files changed, 97 insertions(+), 239 deletions(-) delete mode 100755 programs/make_progs diff --git a/programs/.gitignore b/programs/.gitignore index 29f7ca303db..fbb5a64fd70 100644 --- a/programs/.gitignore +++ b/programs/.gitignore @@ -1,4 +1,4 @@ -# Automatically generated by make_dlls; DO NOT EDIT!! +# Automatically generated by make_makefiles; DO NOT EDIT!! /Makeprog.rules /wineapploader /winelauncher diff --git a/programs/make_progs b/programs/make_progs deleted file mode 100755 index 860c636f09c..00000000000 --- a/programs/make_progs +++ /dev/null @@ -1,225 +0,0 @@ -#!/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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA -# - -use strict; - -my %directories = (); - -# Programs that we want to install in the bin directory too -my %bin_install = -( - "msiexec" => 1, - "notepad" => 1, - "progman" => 1, - "regedit" => 1, - "regsvr32" => 1, - "uninstaller" => 1, - "wineboot" => 1, - "winebrowser" => 1, - "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, - "winetest" => 1, -); - -sub update_file($) -{ - my $file = shift; - if (!system "cmp $file $file.new >/dev/null") - { - unlink "$file.new"; - print "$file is unchanged\n"; - } - else - { - rename "$file.new", "$file"; - print "$file updated\n"; - } -} - -# if we are inside the programs dir, go up one level -if (! -f "configure.ac" && -f "../configure.ac") { chdir(".."); } - -my @args = @ARGV; -if (!@args) { @args = map { s/^(.*)\.in/$1/; $_; } split(/\s/,`find programs -name Makefile.in -print`); } - -foreach my $i (@args) -{ - my $module; - - open MAKE, "$i.in" or die "cannot open $i.in\n"; - - $module = undef; - while () - { - 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/^programs\/(.*)\/[^\/]+$/$1/; - die "invalid module $module in dir $directories{$module}\n" if "$directories{$module}.exe" ne $module; - 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,">programs/Makefile.in.new" or die "cannot create programs/Makefile.in.new"; - -################################################################ -# makefile header - -print NEWMAKE <\$\@ || (\$(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 \$(INSTALLDIRS) dummy - \$(INSTALL_SCRIPT) wineapploader \$(DESTDIR)\$(bindir)/wineapploader - -\$(INSTALLPROGS:%=%/__installprog__): install-apploader - \$(RM) \$(DESTDIR)\$(bindir)/`dirname \$\@` && \$(LN) \$(DESTDIR)\$(bindir)/wineapploader \$(DESTDIR)\$(bindir)/`dirname \$\@` - -install-progs.so: \$(INSTALLPROGS:%=%/__installprog__) - \$(RM) \$(DESTDIR)\$(bindir)/wineapploader - -install-progs: # nothing to do here - -install:: winelauncher install-progs\$(DLLEXT) \$(INSTALLDIRS) - \$(INSTALL_SCRIPT) winelauncher \$(DESTDIR)\$(bindir)/winelauncher - -uninstall:: - -cd \$(DESTDIR)\$(bindir) && \$(RM) wineapploader winelauncher \$(INSTALLPROGS) - -rmdir \$(DESTDIR)\$(dlldir) - -clean:: - \$(RM) wineapploader winelauncher - -# Rules for testing - -check test:: \$(SUBDIRS:%=%/__test__) -EOF - -close NEWMAKE; -update_file("programs/Makefile.in"); - -################################################################ -# .gitignore file - -open GITIGNORE, ">programs/.gitignore.new" or die "cannot create programs/.gitignore.new"; -print GITIGNORE "# Automatically generated by make_dlls; DO NOT EDIT!!\n"; - -my @ignores = -( - "/Makeprog.rules", - "/wineapploader", - "/winelauncher", -); - -foreach my $dir (sort keys %alldirs) -{ - push @ignores, "$dir/$dir"; -} - -print GITIGNORE join("\n", sort @ignores) . "\n"; - -close GITIGNORE; -update_file("programs/.gitignore"); diff --git a/tools/make_makefiles b/tools/make_makefiles index cc77d4026c7..5518808994a 100755 --- a/tools/make_makefiles +++ b/tools/make_makefiles @@ -19,6 +19,7 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA # +# Make rules files my %makerules = ( "MAKE_RULES" => "Make.rules", @@ -28,6 +29,34 @@ my %makerules = "MAKE_PROG_RULES" => "programs/Makeprog.rules", ); +# Programs that we want to install in the bin directory too +my %bin_install = +( + "msiexec" => 1, + "notepad" => 1, + "progman" => 1, + "regedit" => 1, + "regsvr32" => 1, + "uninstaller" => 1, + "wineboot" => 1, + "winebrowser" => 1, + "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, + "winetest" => 1, +); + my (@makefiles, %makefiles); # update a file if changed @@ -55,13 +84,16 @@ sub replace_in_file($$$@) my $start = shift; my $end = shift; - open OLD_FILE, "$file" or die "cannot open $file"; open NEW_FILE, ">$file.new" or die "cannot create $file.new"; - while () + if (defined($start)) { - last if /$start/; - print NEW_FILE $_; + open OLD_FILE, "$file" or die "cannot open $file"; + while () + { + last if /$start/; + print NEW_FILE $_; + } } print NEW_FILE @_; @@ -76,7 +108,7 @@ sub replace_in_file($$$@) } } - close OLD_FILE; + close OLD_FILE if defined($start); close NEW_FILE; return update_file($file); } @@ -85,6 +117,7 @@ sub replace_in_file($$$@) sub parse_makefile($) { my $file = shift; + my %make; open MAKE, "$file.in" or die "cannot open $file.in\n"; @@ -96,10 +129,21 @@ sub parse_makefile($) if (/^\@(MAKE.*RULES)\@/) { my $var = $1; - $makefiles{$file} = $makerules{$var}; - return; + $make{"=rules"} = $makerules{$var}; + next; + } + if (/^MODULE\s*=\s*([a-zA-Z0-9_.]+)/) + { + $make{"MODULE"} = $1; + next; + } + if (/^\#\s*MKDLL_SKIP/ || /^\#\s*MKPROG_SKIP/) + { + $make{"=skip"} = 1; + next; } } + return %make; } if (-d ".git") @@ -113,7 +157,8 @@ else foreach my $file (sort values %makerules, @makefiles) { - parse_makefile( $file ); + my %make = parse_makefile( $file ); + $makefiles{$file} = \%make; } ################################################################ @@ -179,14 +224,15 @@ my @depends; foreach my $file (sort values %makerules) { push @targets, $file; - if (!defined($makefiles{$file})) { push @depends, "$file: $file.in"; } + my %make = %{$makefiles{$file}}; + if (!defined($make{"=rules"})) { push @depends, "$file: $file.in"; } else { push @depends, "$file: $file.in Make.rules"; } } foreach my $file (sort @makefiles) { push @targets, $file unless $file eq "Makefile"; - my $dep = $makefiles{$file}; + my $dep = ${$makefiles{$file}}{"=rules"}; push @depends, "$file: $file.in $dep"; } @@ -211,7 +257,44 @@ system "dlls/make_dlls", @dll_makefiles; ################################################################ -# update programs/Makefile.in +# update programs/Makefile.in and programs/.gitignore -my @prog_makefiles = grep /^programs\//, @makefiles; -system "programs/make_progs", @prog_makefiles; +sub update_progs(@) +{ + my (@subdirs, @install_subdirs, @install_progs); + + my @ignores = + ( + "/Makeprog.rules", + "/wineapploader", + "/winelauncher", + ); + + foreach my $make (@_) + { + my %makefile = %{$makefiles{$make}}; + my $module = $makefile{"MODULE"}; + (my $dir = $make) =~ s/^programs\/(.*)\/Makefile$/$1/; + die "Invalid module $module in $make" unless "$dir.exe" eq $module; + next if defined $makefile{"=skip"}; + push @subdirs, $dir; + push @ignores, "$dir/$dir"; + push @install_subdirs, $dir unless $dont_install{$dir}; + push @install_progs, $dir if $bin_install{$dir}; + } + + replace_in_file( "programs/Makefile.in", '^SUBDIRS\s*=', '^INSTALLDIRS', + "SUBDIRS = \\\n\t", + join( " \\\n\t", @subdirs ), + "\n\n# Sub-directories to run make install into\nINSTALLSUBDIRS = \\\n\t", + join( " \\\n\t", @install_subdirs ), + "\n\n# Programs to install in bin directory\nINSTALLPROGS = \\\n\t", + join( " \\\n\t", @install_progs ), + "\n\nINSTALLDIRS = \$(DESTDIR)\$(bindir)\n" ); + + replace_in_file( "programs/.gitignore", undef, undef, + "# Automatically generated by make_makefiles; DO NOT EDIT!!\n", + join("\n", sort @ignores), "\n" ); +} + +update_progs( sort grep /^programs\/.*\/Makefile$/, @makefiles );