Cons_gcc.pm 858 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #
  2. # Some utilities to handle gcc compiler setup
  3. #
  4. package Cons_gcc;
  5. # pass the compiler name
  6. # returns an array, first element is 2 for 2.x 3 for 3.x, then full version, then machine info
  7. sub get_gcc_version
  8. {
  9. my @ret;
  10. my ($CC) = @_;
  11. my $version=`$CC --version | head -1`;
  12. chop($version);
  13. my $machine=`$CC -dumpmachine`;
  14. chop($machine);
  15. if($version =~ '2\.[0-9]*\.[0-9]*')
  16. {
  17. push @ret, '2';
  18. } else {
  19. push @ret, '3';
  20. }
  21. push @ret, $version;
  22. push @ret, $machine;
  23. return @ret;
  24. }
  25. # http://ccache.samba.org/
  26. # check ccache existence and path
  27. # returns an array, first element 0 / 1, then path
  28. sub get_ccache
  29. {
  30. my @ret;
  31. $ccache_path=`which ccache`;
  32. chop($ccache_path);
  33. if(-x $ccache_path)
  34. {
  35. push @ret, '1';
  36. push @ret, $ccache_path;
  37. return @ret;
  38. }
  39. push @ret, '0';
  40. return @ret;
  41. }
  42. # close package
  43. 1;