File: replace-install-prefix.pl

package info (click to toggle)
trilinos 16.1.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 994,012 kB
  • sloc: cpp: 3,764,859; ansic: 425,011; fortran: 160,684; python: 101,476; xml: 74,329; sh: 37,044; makefile: 22,641; perl: 7,525; f90: 6,424; csh: 5,285; objc: 2,620; lex: 1,646; lisp: 810; yacc: 603; javascript: 552; awk: 364; ml: 281; php: 145
file content (89 lines) | stat: -rwxr-xr-x 2,855 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/perl -w
use strict;
use Getopt::Long;
#
# This script is called to do a set of text replacements for installing
# a Mafile.export.package file so that external clients can use it.
#
# Read in commandline arguments
#
my $exec_prefix = "";           # [required] Abs path to base installation directory (i.e. --prefix=??? option passed to configure)
my $my_export_makefile = "";    # [required] Name only of installed Makefile.export.package file
my $my_top_srcdir = "";         # [required] Abs path to this package's top source directory
my $my_incl_dirs = "";          # [required] Abs path to this package's include directories
my $my_lib_dirs = "";           # [optional] Abs path to this package's library directories (if any exist)
my $dep_package_builddirs = ""; # [optional] Abs paths to other directly dependent framework package build directories (if any exist)
GetOptions(
  "exec-prefix=s"                   => \$exec_prefix,
  "my-export-makefile=s"            => \$my_export_makefile,
  "my-abs-top-srcdir=s"             => \$my_top_srcdir,
  "my-abs-incl-dirs=s"              => \$my_incl_dirs,
  "my-abs-lib-dirs=s"               => \$my_lib_dirs,
  "dep-package-abs-builddirs=s"     => \$dep_package_builddirs
  );
#
# Validate commandline arguments
#
scalar(@ARGV) == 0 || die;
$exec_prefix ne "" || die;
$my_export_makefile ne "" || die;
$my_top_srcdir ne "" || die;
$my_incl_dirs ne "" || die;
#
# Interpret commandline arguments
#
$exec_prefix = remove_rel_paths($exec_prefix);
my @my_incl_dirs = split(":",$my_incl_dirs);
my @my_lib_dirs = split(":",$my_lib_dirs);
my @dep_export_package_builddirs = split(":",$dep_package_builddirs);
#
# Do the replacements
#
my $my_abs_export_makefile = "${exec_prefix}/include/${my_export_makefile}";

my $cmnd_base = "${my_top_srcdir}/config/token-replace.pl ";
#
foreach(@dep_export_package_builddirs) {
  if($_ ne "") {
    run_cmnd($cmnd_base . "${_} ${exec_prefix}/include ${my_abs_export_makefile} ${my_abs_export_makefile}");
  }
}
#
foreach(@my_incl_dirs) {
  if($_ ne "") {
    run_cmnd($cmnd_base . "-I${_} -I${exec_prefix}/include ${my_abs_export_makefile} ${my_abs_export_makefile}");
  }
}
#
foreach(@my_lib_dirs) {
  if($_ ne "") {
    run_cmnd($cmnd_base . "-L${_} -L${exec_prefix}/lib ${my_abs_export_makefile} ${my_abs_export_makefile}");
  }
}
#
run_cmnd($cmnd_base . "${my_top_srcdir}/config ${exec_prefix}/include ${my_abs_export_makefile} ${my_abs_export_makefile}");
#
# Subroutines
#
sub remove_rel_paths {
	my $entry_in = shift;
	if ($entry_in=~/-L\.\./) {
		return $entry_in;
	}
	my @paths = split("/",$entry_in);
	my @new_paths;
	foreach( @paths ) {
		if( !($_=~/\.\./) ) {
			push @new_paths, $_;
		}
		else {
			pop @new_paths
		}
	}
	return join("/",@new_paths);
}
sub run_cmnd {
  my $cmnd = shift;
  #print "\n", $cmnd, "\n";
  system($cmnd)==0 || die;
}