/[soft]/multiarch-utils/branches/1/check-multiarch-files
ViewVC logotype

Contents of /multiarch-utils/branches/1/check-multiarch-files

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1638 - (show annotations) (download)
Thu Jun 2 20:45:36 2011 UTC (12 years, 10 months ago) by dmorgan
File size: 2961 byte(s)
Branch for updates
1 #!/usr/bin/perl
2 #---------------------------------------------------------------
3 # Module : multiarch-utils
4 # File : check-multiarch
5 # Version : $Id: check-multiarch-files 156134 2005-08-07 14:29:26Z gbeauchesne $
6 # Author : Gwenole Beauchesne
7 # Created On : Mon Jan 24 18:02:21 CET 2005
8 #---------------------------------------------------------------
9
10 use strict;
11 use MDK::Common;
12
13 my $RPM_BUILD_ROOT = (shift);
14
15 if (! -d $RPM_BUILD_ROOT ) {
16 while (<STDIN>) { } # consume all inputs
17 exit 1
18 }
19
20 while (<STDIN>) {
21 chomp;
22
23 # File must be located in the usual development directories
24 -f $_ or next;
25 m,^\Q$RPM_BUILD_ROOT\E/usr(/X11R6)?/(bin|include)/, or next;
26 m,/multiarch-.+-\w+/, and next;
27 m,/include/asm, and next;
28
29 my $multiarch = 0;
30 my $multiarch_type;
31
32 # Heuristics for binary files
33 if (/bin/) {
34 my $file_magic = `file $_`;
35 $multiarch_type = "binary";
36
37 # check for *-config script files
38 if (/.+[-_]config/ && $file_magic =~ /shell script/) {
39 my $options;
40 foreach (cat_($_)) {
41 foreach my $opt (qw(cflags libs ldflags cppflags libdir libtool)) {
42 $options .= " --$opt" if /(\[--$opt\]|--$opt\s+([\#\[]|display|print))/;
43 }
44 }
45 # run the script to find out any libdir dependent flags
46 if ($options) {
47 my $output = `$_ $options`;
48 $multiarch = 1 if ($output =~ /(?<!\/include)\/lib(32|64)?/);
49 }
50 }
51 }
52
53 # Heuristics for include files
54 elsif (/include/) {
55 $multiarch_type = "header";
56 my %archdefs;
57 foreach (cat_($_)) {
58 if (/\#\s*define\s+(\w+)\s+(.+)/) {
59 my ($def, $val) = ($1, $2);
60
61 # check for typical arch-dependent macro definitions
62 my @keywords_with_int = qw(SIZEOF_VOID_P SIZEOF_CHAR_P SIZEOF_LONG BYTES_PER_LONG BITS_PER_LONG BITS_PER_WORD);
63 foreach my $pat (@keywords_with_int) {
64 if ($def =~ /$pat/ && int($val)) {
65 $archdefs{$def}++;
66 last;
67 }
68 }
69
70 # check for libdir references, typically plugins dir
71 # XXX check for /DIR/ in $def ?
72 if ($val =~ /"\/usr(\/X11R6)?\/lib(32|64)?\/(?!(X11|font)\/).*"/) {
73 $multiarch = 1;
74 }
75 }
76 }
77
78 # ignore multiple definitions of the same macro, assume
79 # arch-dependence is handled in that case
80 if (! $multiarch) {
81 foreach my $e (keys %archdefs) {
82 my $val = $archdefs{$e};
83 $multiarch = 1 if ($val == 1);
84 }
85 }
86 }
87
88 # Multiarch files detected?
89 print "$_\n" if $multiarch;
90 }
91
92 # Local variables:
93 # tab-width: 4
94 # indent-tabs-mode: nil
95 # End:

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.30