summaryrefslogtreecommitdiffstats
path: root/check-multiarch-files
diff options
context:
space:
mode:
authorGwenolé Beauchesne <gbeauchesne@mandriva.org>2005-01-24 21:34:57 +0000
committerGwenolé Beauchesne <gbeauchesne@mandriva.org>2005-01-24 21:34:57 +0000
commitc5f78f7f736824438fb2d4e39ec58898ebb91754 (patch)
tree0591139c773c3c2aa63536dbefbc4d868e0ddd7d /check-multiarch-files
parent3e6ab0fa27f53985c2c6f41b2ba552a320b0ba16 (diff)
downloadmultiarch-utils-c5f78f7f736824438fb2d4e39ec58898ebb91754.tar
multiarch-utils-c5f78f7f736824438fb2d4e39ec58898ebb91754.tar.gz
multiarch-utils-c5f78f7f736824438fb2d4e39ec58898ebb91754.tar.bz2
multiarch-utils-c5f78f7f736824438fb2d4e39ec58898ebb91754.tar.xz
multiarch-utils-c5f78f7f736824438fb2d4e39ec58898ebb91754.zip
add check-multiarch-files
Diffstat (limited to 'check-multiarch-files')
-rwxr-xr-xcheck-multiarch-files90
1 files changed, 90 insertions, 0 deletions
diff --git a/check-multiarch-files b/check-multiarch-files
new file mode 100755
index 0000000..5b556fb
--- /dev/null
+++ b/check-multiarch-files
@@ -0,0 +1,90 @@
+#!/usr/bin/perl
+#---------------------------------------------------------------
+# Project : Mandrakelinux
+# Module : multiarch-utils
+# File : check-multiarch
+# Version : $Id$
+# Author : Gwenole Beauchesne
+# Created On : Mon Jan 24 18:02:21 CET 2005
+#---------------------------------------------------------------
+
+use strict;
+use MDK::Common;
+
+while (<STDIN>) {
+ chomp;
+
+ # File must be located in the usual development directories
+ -f $_ or next;
+ /\/usr(\/X11R6)?\/(bin|include)\// or next;
+ /\/multiarch-.*-linux\// and next;
+ /\/include\/asm/ and next;
+
+ my $multiarch = 0;
+ my $multiarch_type;
+
+ # Heuristics for binary files
+ if (/bin/) {
+ my $file_magic = `file $_`;
+ $multiarch_type = "binary";
+
+ # check for *-config script files
+ if (/.+-config/ && $file_magic =~ /shell script/) {
+ my $options;
+ foreach (cat_($_)) {
+ $options .= " --cflags" if /\[--cflags\]/;
+ $options .= " --libs" if /\[--libs\]/;
+ $options .= " --ldflags" if /\[--ldflags\]/;
+ $options .= " --cppflags" if /\[--cppflags\]/;
+ }
+ # run the script to find out any libdir dependent flags
+ if ($options) {
+ my $output = `$_ $options`;
+ $multiarch = 1 if ($output =~ /(?<!\/include)\/lib(32|64)?/);
+ }
+ }
+ }
+
+ # Heuristics for include files
+ elsif (/include/) {
+ $multiarch_type = "header";
+ my %archdefs;
+ foreach (cat_($_)) {
+ if (/\#\s*define\s+(\w+)\s+(.+)/) {
+ my ($def, $val) = ($1, $2);
+
+ # check for typical arch-dependent macro definitions
+ my @keywords_with_int = qw(SIZEOF_VOID_P SIZEOF_CHAR_P SIZEOF_LONG BYTES_PER_LONG BITS_PER_LONG);
+ foreach my $pat (@keywords_with_int) {
+ if ($def =~ /$pat/ && int($val)) {
+ $archdefs{$def}++;
+ last;
+ }
+ }
+
+ # check for libdir references, typically plugins dir
+ # XXX check for /DIR/ in $def ?
+ if ($val =~ /"\/usr(\/X11R6)?\/lib(32|64)?\/.*"/) {
+ $multiarch = 1;
+ }
+ }
+ }
+
+ # ignore multiple definitions of the same macro, assume
+ # arch-dependence is handled in that case
+ if (! $multiarch) {
+ foreach my $e (keys %archdefs) {
+ my $val = $archdefs{$e};
+ $multiarch = 1 if ($val == 1);
+ }
+ }
+ }
+
+ # Multiarch files detected?
+ print "$_\n" if $multiarch;
+}
+
+# Local variables:
+# tab-width: 4
+# indent-tabs-mode: nil
+# End: