[docs][TT# 1667] Get rid of wrong documentation
[parrot.git] / tools / dev / install_files.pl
blob8adc698f04b7a0d417df729f58af7bc82794d584
1 #! perl
2 ################################################################################
3 # Copyright (C) 2001-2009, Parrot Foundation.
4 # $Id$
5 ################################################################################
7 =head1 TITLE
9 tools/dev/install_files.pl - Copy files to their correct locations
11 =head1 SYNOPSIS
13 % perl tools/dev/install_files.pl [options]
15 =head1 DESCRIPTION
17 Use a detailed MANIFEST to install a set of files.
19 =head2 Options
21 =over 4
23 =item C<buildprefix>
25 The build prefix. Defaults to ''.
27 =item C<prefix>
29 The install prefix. Defaults to '/usr'.
31 =item C<exec_prefix>
33 The exec prefix. Defaults to '/usr'.
35 =item C<bindir>
37 The executables directory. Defaults to '/usr/bin'.
39 =item C<libdir>
41 The library directory. Defaults to '/usr/lib'.
43 =item C<includedir>
45 The header directory. Defaults to '/usr/include'.
47 =back
49 =head1 SEE ALSO
51 See F<lib/Parrot/Manifest.pm> for a detailed description of the MANIFEST
52 format.
54 F<tools/dev/mk_manifests.pl>
56 =cut
58 ################################################################################
60 use strict;
61 use warnings;
62 use File::Basename qw(basename);
63 use lib qw( lib );
64 use Parrot::Install qw(
65 install_files
66 create_directories
67 lines_to_files
70 # When run from the makefile, which is probably the only time this
71 # script will ever be used, all of these defaults will get overridden.
72 my %options = (
73 buildprefix => '',
74 prefix => '/usr',
75 destdir => '',
76 exec_prefix => '/usr',
77 bindir => '/usr/bin',
78 libdir => '/usr/lib', # parrot/ subdir added below
79 includedir => '/usr/include', # parrot/ subdir added below
80 docdir => '/usr/share/doc', # parrot/ subdir added below
81 versiondir => '',
82 'dry-run' => 0,
83 packages => 'main|library|pge',
86 my @manifests;
87 foreach (@ARGV) {
88 if (/^--([^=]+)=(.*)/) {
89 $options{$1} = $2;
91 else {
92 push @manifests, $_;
96 my $parrotdir = $options{versiondir};
98 # Set up transforms on filenames
99 my(@transformorder) = qw(lib bin include doc pkgconfig ^compilers);
100 my(%metatransforms) = (
101 lib => {
102 ismeta => 1,
103 optiondir => 'lib',
104 transform => sub {
105 my($filehash) = @_;
106 local($_) = $filehash->{Dest};
107 if ( /^install_config\.fpmc/ ) {
108 s/^install_//; # parrot with different config
109 $filehash->{DestDirs} = [$parrotdir, 'include'];
110 $filehash->{Dest} = $_;
112 elsif ( /install_config/ ) {
113 s/install_config/parrot_config/;
114 s/^src//; # strip off leading src/ dir
115 $filehash->{DestDirs} = [$parrotdir];
116 $filehash->{Dest} = $_;
118 else {
119 # don't allow libraries to be installed into subdirs of libdir
120 $filehash->{Dest} = basename($_);
122 return($filehash);
125 bin => {
126 ismeta => 1,
127 optiondir => 'bin',
128 transform => sub {
129 my($filehash) = @_;
130 # parrot with different config
131 $filehash->{Installable} = $filehash->{Dest} =~ s/^installable_//;
132 return($filehash);
134 isbin => 1,
136 include => {
137 ismeta => 1,
138 optiondir => 'include',
139 transform => sub {
140 my($filehash) = @_;
141 $filehash->{Dest} =~ s/^include//;
142 $filehash->{DestDirs} = [$parrotdir];
143 return($filehash);
146 doc => {
147 ismeta => 1,
148 optiondir => 'doc',
149 transform => sub {
150 my($filehash) = @_;
151 $filehash->{DestDirs} = [$parrotdir];
152 return($filehash);
155 pkgconfig => {
156 ismeta => 1,
157 optiondir => 'lib',
158 transform => sub {
159 my($filehash) = @_;
160 # For the time being this is hardcoded as being installed under
161 # libdir as it is typically done with automake installed packages.
162 # If the --pkgconfigdir option is used, then the default value will
163 # be overwritten with the specified subdirectory under libdir.
164 $filehash->{DestDirs} = ['pkgconfig', $parrotdir];
165 $filehash->{DestDirs} = [$options{pkgconfigdir}]
166 if $options{pkgconfigdir};
167 return($filehash);
170 '^compilers' => {
171 optiondir => 'lib',
172 transform => sub {
173 my($filehash) = @_;
174 $filehash->{Dest} =~ s/^compilers/languages/;
175 $filehash->{DestDirs} = [$parrotdir];
176 return($filehash);
181 my($filehashes, $directories) = lines_to_files(
182 \%metatransforms, \@transformorder, \@manifests, \%options, $parrotdir
185 unless ( $options{'dry-run'} ) {
186 create_directories($options{destdir}, $directories);
189 # TT #347
190 # 1. skip build_dir-only binaries for files marked Installable
191 my($filehash, @removes, $removes);
192 foreach $filehash (grep { $_->{Installable} } @$filehashes) {
193 my( $src, $dest ) = map { $filehash->{$_} } qw(Source Dest);
194 my ($file) = $src =~ /installable_(.+)$/;
195 next unless $file;
196 if((grep { $_->{Source} =~ /^$file$/ } @$filehashes) and -e $file) {
197 print "skipping $file, using installable_$file instead\n";
198 push @removes, $file;
201 $removes = join '|', @removes;
202 @$filehashes = grep { $_->{Source} !~ /^($removes)$/ } @$filehashes;
204 # 2. for every .exe check if there's an installable. Fail if not
205 my $i;
206 foreach $filehash (grep { ! $_->{Installable} } @$filehashes ) {
207 my( $src, $dest ) = map { $filehash->{$_} } qw(Source Dest);
208 next unless $src =~ /\.exe$/;
209 # This logic will fail on non-win32 if the generated files are really
210 # generated as with rt #40817. We don't have [main]bin here.
211 $i = "installable_$src";
212 unless (map {$_->{Source} =~ /^$i$/} grep { $_->{Installable} } @$filehashes) {
213 die "$i is missing in MANIFEST or MANIFEST.generated\n";
217 install_files($options{destdir}, $options{'dry-run'}, $filehashes);
219 print "Finished install_files.pl\n";
221 # Local Variables:
222 # mode: cperl
223 # cperl-indent-level: 4
224 # fill-column: 100
225 # End:
226 # vim: expandtab shiftwidth=4: