| 3839 |
dpurdie |
1 |
########################################################################
|
|
|
2 |
# Copyright (C) 1998-2013 Vix Technology, All rights reserved
|
|
|
3 |
#
|
|
|
4 |
# Module name : MakePax.pl
|
|
|
5 |
# Module type : Makefile system
|
|
|
6 |
# Compiler(s) : Perl
|
|
|
7 |
# Environment(s): jats
|
|
|
8 |
#
|
|
|
9 |
# Description : Build Wrpper for the MakePax directive
|
|
|
10 |
# This script is invoked at 'make' time
|
|
|
11 |
# A perl script is used to provide a little bit of flexability
|
|
|
12 |
#
|
|
|
13 |
# Usage: : Invoked by JAT make system
|
|
|
14 |
#
|
|
|
15 |
#......................................................................#
|
|
|
16 |
|
|
|
17 |
require 5.008_002;
|
|
|
18 |
use strict;
|
|
|
19 |
use warnings;
|
|
|
20 |
|
|
|
21 |
use Pod::Usage;
|
|
|
22 |
use Getopt::Long;
|
|
|
23 |
|
|
|
24 |
use JatsError;
|
|
|
25 |
use JatsSystem;
|
|
|
26 |
use FileUtils;
|
|
|
27 |
|
|
|
28 |
#
|
|
|
29 |
# Globals
|
|
|
30 |
#
|
|
|
31 |
|
|
|
32 |
#
|
|
|
33 |
# Command line options
|
|
|
34 |
#
|
|
|
35 |
my $opt_debug = $ENV{'GBE_DEBUG'}; # Allow global debug
|
|
|
36 |
my $opt_verbose = $ENV{'GBE_VERBOSE'}; # Allow global verbose
|
|
|
37 |
my $opt_vargs; # Verbose arg
|
|
|
38 |
my $opt_help = 0;
|
|
|
39 |
my $opt_manual = 0;
|
|
|
40 |
my $opt_clean = 0;
|
|
|
41 |
my $opt_platform;
|
|
|
42 |
my $opt_buildname;
|
|
|
43 |
my $opt_buildversion;
|
|
|
44 |
my $opt_interfacedir;
|
|
|
45 |
my $opt_pkgdir;
|
|
|
46 |
my $opt_component;
|
|
|
47 |
my $opt_src;
|
|
|
48 |
|
|
|
49 |
#-------------------------------------------------------------------------------
|
|
|
50 |
# Function : Main Entry point
|
|
|
51 |
#
|
|
|
52 |
# Description : This function will be called when the package is initialised
|
|
|
53 |
# Extract arguments from the users environment
|
|
|
54 |
#
|
|
|
55 |
# Done here to greatly simplify the user script
|
|
|
56 |
# There should be no junk in the user script - keep it simple
|
|
|
57 |
#
|
|
|
58 |
# Inputs :
|
|
|
59 |
#
|
|
|
60 |
# Returns :
|
|
|
61 |
#
|
|
|
62 |
main();
|
|
|
63 |
|
|
|
64 |
sub main
|
|
|
65 |
{
|
|
|
66 |
my $dist_tree;
|
|
|
67 |
my @make_args;
|
|
|
68 |
|
|
|
69 |
my $result = GetOptions (
|
|
|
70 |
"verbose:s" => \$opt_vargs,
|
|
|
71 |
"clean" => \$opt_clean,
|
|
|
72 |
"BuildName=s" => \$opt_buildname,
|
|
|
73 |
"BuildVersion=s" => \$opt_buildversion,
|
|
|
74 |
"Platform=s" => \$opt_platform,
|
|
|
75 |
"InterfaceDir=s" => \$opt_interfacedir,
|
|
|
76 |
"PackageDir=s" => \$opt_pkgdir,
|
|
|
77 |
"Component=s" => \$opt_component,
|
|
|
78 |
"Src=s" => \$opt_src,
|
|
|
79 |
);
|
|
|
80 |
|
|
|
81 |
ErrorConfig( 'name' => 'MakePax',
|
|
|
82 |
'verbose' => $opt_verbose,
|
|
|
83 |
'debug' => $opt_debug );
|
|
|
84 |
|
|
|
85 |
#
|
|
|
86 |
# Init the FileSystem Uiltity interface
|
|
|
87 |
#
|
|
|
88 |
InitFileUtils();
|
|
|
89 |
|
|
|
90 |
#
|
|
|
91 |
# Ensure that we have all required options
|
|
|
92 |
#
|
|
|
93 |
Error ("BuildName not set") unless ( $opt_buildname );
|
|
|
94 |
Error ("BuildVersion not set") unless ( $opt_buildversion );
|
|
|
95 |
Error ("InterfaceDir not set") unless ( $opt_interfacedir );
|
|
|
96 |
Error ("Package Dir not set") unless ( $opt_pkgdir );
|
|
|
97 |
Error ("Component not set") unless ( $opt_component );
|
|
|
98 |
Error ("Source not set") unless ( $opt_src );
|
|
|
99 |
|
|
|
100 |
#
|
|
|
101 |
# A few sanity checks
|
|
|
102 |
#
|
|
|
103 |
Error ("Cannot find 'intellect.bat'. This file was generated by JATS")
|
|
|
104 |
unless ( -f 'intellect.bat' );
|
|
|
105 |
|
|
|
106 |
|
|
|
107 |
Error ("Source does not contain a 'makefile'", 'Src:' . $opt_src)
|
|
|
108 |
unless ( -f join('/', $opt_src, 'makefile') );
|
|
|
109 |
|
|
|
110 |
#
|
|
|
111 |
# Define some global values
|
|
|
112 |
#
|
|
|
113 |
push @make_args, '-c', $opt_src;
|
|
|
114 |
push @make_args, "-DDIST_PLATFORM=$opt_platform" if ( $opt_platform );
|
|
|
115 |
push @make_args, '-DMAKE_VERBOSE=1' if $opt_vargs;
|
|
|
116 |
|
|
|
117 |
$dist_tree = FullPath(join('/', $opt_pkgdir, 'pkg', $opt_component));
|
|
|
118 |
|
|
|
119 |
#
|
|
|
120 |
# Clean package
|
|
|
121 |
#
|
|
|
122 |
if ( $opt_clean )
|
|
|
123 |
{
|
|
|
124 |
Message ("Clean Pax Build");
|
|
|
125 |
runMake( @make_args, 'very_clean' );
|
|
|
126 |
exit 0;
|
|
|
127 |
}
|
|
|
128 |
|
|
|
129 |
|
|
|
130 |
#
|
|
|
131 |
# Build Package
|
|
|
132 |
# Remove packageing output
|
|
|
133 |
# Make install - in tree
|
|
|
134 |
# Make install - - for packaging
|
|
|
135 |
#
|
|
|
136 |
RmDirTree($dist_tree);
|
|
|
137 |
mkdir ( $dist_tree );
|
|
|
138 |
|
|
|
139 |
Message ("Build Software");
|
|
|
140 |
runMake( @make_args, 'install' );
|
|
|
141 |
|
|
|
142 |
Message ("Package Software");
|
|
|
143 |
runMake( @make_args, '-DDIST_TREE=' . $dist_tree, 'install' );
|
|
|
144 |
}
|
|
|
145 |
|
|
|
146 |
#-------------------------------------------------------------------------------
|
|
|
147 |
# Function : runMake
|
|
|
148 |
#
|
|
|
149 |
# Description : Run the PAX Builder Make command in the PAX Builder
|
|
|
150 |
# environment - as setup by intellect.bat
|
|
|
151 |
#
|
|
|
152 |
# Inputs : Array of make arguments
|
|
|
153 |
#
|
|
|
154 |
# Returns : Will not return on error
|
|
|
155 |
#
|
|
|
156 |
sub runMake
|
|
|
157 |
{
|
|
|
158 |
my (@args) = @_;
|
|
|
159 |
System ('--Exit','--NoShell','intellect.bat', 'make', @args );
|
|
|
160 |
}
|
|
|
161 |
|
|
|
162 |
|