| 227 |
dpurdie |
1 |
# -*- mode: perl; tabs: 8; indent-width: 4; show-tabs: yes; -*-
|
| 261 |
dpurdie |
2 |
# Copyright (C) 1998-2008 ERG Transit Systems, All rights reserved
|
| 227 |
dpurdie |
3 |
#
|
|
|
4 |
# Module name : makelib.pl2
|
|
|
5 |
# Module type : Makefile system
|
|
|
6 |
#
|
|
|
7 |
# Description:
|
|
|
8 |
# This modules builds the platform definition makefiles(s)
|
|
|
9 |
#
|
|
|
10 |
# Notes: *** DO NOT DETAB ***
|
|
|
11 |
# Beware the use of space v's tab characters within the
|
|
|
12 |
# makefile generation sessions.
|
|
|
13 |
#
|
|
|
14 |
##############################################################################
|
|
|
15 |
# Globals:
|
|
|
16 |
# $ScmVersion Makelib.pl2 version
|
|
|
17 |
# $ScmRoot Command line parameter that gives the root directory
|
|
|
18 |
# location for this directory tree.
|
|
|
19 |
# $ScmMakelib Command line parameter that points to the location
|
|
|
20 |
# of THIS script. ie. location of makelib.pl.
|
|
|
21 |
# $ScmPlatform Current platform
|
|
|
22 |
# $ScmProduct Current product (if any)
|
|
|
23 |
# $ScmTarget Resulting target (derived from Platform)
|
|
|
24 |
# @ScmPlatformArgs Platform arguments
|
|
|
25 |
# $ScmToolset Toolset
|
|
|
26 |
# @ScmToolsetArgs Toolset arguments
|
|
|
27 |
# $ScmDebug Debug level
|
|
|
28 |
# $ScmVerbose Verbose setting
|
|
|
29 |
# $ScmSourceTypes Source types, aliasing for C, C++ and assembler
|
|
|
30 |
# source.
|
|
|
31 |
# @CFLAGS List containing all of the defined C flags
|
|
|
32 |
# @CXXFLAGS List containing all of the defined C++ flags
|
|
|
33 |
# @ASFLAGS List containing all of the defined assembler flags
|
|
|
34 |
# @CLINTFLAGS List containing all of the defined C lint flags
|
|
|
35 |
# @CXXLINTFLAGS List containing all of the defined C++ lint flags
|
|
|
36 |
# @{G|L}_INCDIRS List containing all of include paths
|
|
|
37 |
# @{G|L}_SRCDIRS List containing all of source search paths
|
|
|
38 |
# @{G|L}_LIBDIRS List containing all of library search paths
|
|
|
39 |
# @LDFLAGS List containing all of the defined linker flags
|
|
|
40 |
# @SRCS List of ALL source files. ie. C/C++ and other (eg .x)
|
|
|
41 |
# Key is source file, value is source path
|
|
|
42 |
# @OBJS List of ALL (non-shared) object files.
|
| 289 |
dpurdie |
43 |
# %SHOBJ_LIB List of ALL shared library object files and associated library.
|
| 227 |
dpurdie |
44 |
# %OBJSOURCE List of ALL object files
|
|
|
45 |
# from that should result from later makes.
|
|
|
46 |
# Key is objectfile, value is source file
|
|
|
47 |
# %OBJREFS List of ALL object files, built options.
|
|
|
48 |
# @PROGOBJS List of ALL application object files.
|
|
|
49 |
# %SRC_ARGS List of arguments that are to be used when making the
|
|
|
50 |
# nominated source. Key is the source name, the
|
|
|
51 |
# value is a string of arguments to apply. The
|
|
|
52 |
# arguments are '$;' separated.
|
|
|
53 |
# %SRC_TYPE Source file type (user override).
|
|
|
54 |
# @CHDRS List of C header files.
|
|
|
55 |
# @CSRCS List of C files
|
|
|
56 |
# Key is objectfile, value is source file
|
|
|
57 |
# @CXXSRCS List of C++ files
|
|
|
58 |
# @ASHDRS List of assembler include files (.inc)
|
|
|
59 |
# @ASSRCS List of assembler source files
|
|
|
60 |
# @GENERATED List of files that should result from a 'generate'
|
|
|
61 |
# make rule. The programmer is expected to provide
|
|
|
62 |
# the necessary rule(s).
|
|
|
63 |
# @RULES List of additional make rules the programmer
|
|
|
64 |
# has specified to be included in the make.
|
|
|
65 |
# %INSTALL_HDRS List of headers that are to be installed for later
|
|
|
66 |
# "public" consumption.
|
|
|
67 |
# %INSTALL_CLSS List of Java classes or JAR files that are to be installed
|
|
|
68 |
# for later "public" consumption.
|
|
|
69 |
# @LIBS List of libraries that are to be built.
|
| 289 |
dpurdie |
70 |
# $LIBS Ref to a collection of static library descriptors
|
|
|
71 |
# Indexed by lib name
|
| 227 |
dpurdie |
72 |
# %INSTALL_LIBS List of libraries that are to be installed for later
|
|
|
73 |
# public consumption.
|
|
|
74 |
# @MLIBS List of libraries that are to be built via merging
|
| 289 |
dpurdie |
75 |
# $MLIBS Ref to a collection of merged lib descriptors
|
| 227 |
dpurdie |
76 |
# @SHLIBS List of shared libraries that are to be built.
|
| 289 |
dpurdie |
77 |
# $SHLIBS Ref to collection of shared library information
|
| 227 |
dpurdie |
78 |
# %INSTALL_SHLIBS List of libraries that are to be installed for later
|
|
|
79 |
# public consumption.
|
|
|
80 |
# @PROGS List of programs (binary executables) that are
|
|
|
81 |
# to be built
|
| 289 |
dpurdie |
82 |
# $PROGS Ref to collection of program information
|
| 227 |
dpurdie |
83 |
# %SCRIPTS List of scripts to 'create' (key) and whether they
|
|
|
84 |
# should be made executable or not (value). Script
|
|
|
85 |
# set to executable is denoted by the value being
|
|
|
86 |
# defined AND true.
|
|
|
87 |
# %INSTALL_PROGS List of programs for "public" cosumption to install
|
|
|
88 |
# where (key) is the file and where to install it
|
|
|
89 |
# to vs. (value) which is composed of the original
|
|
|
90 |
# location of the file, the destination directory
|
|
|
91 |
# and a list of service providers this file applies to.
|
|
|
92 |
# $ProjectBase Base of the user's project. This variable is designed to
|
|
|
93 |
# be used by the user.
|
|
|
94 |
#....
|
|
|
95 |
|
| 255 |
dpurdie |
96 |
require 5.006_001;
|
| 227 |
dpurdie |
97 |
use strict;
|
|
|
98 |
use warnings;
|
| 261 |
dpurdie |
99 |
use Getopt::Long;
|
| 227 |
dpurdie |
100 |
use Data::Dumper;
|
| 271 |
dpurdie |
101 |
use JatsError;
|
| 227 |
dpurdie |
102 |
use JatsEnv;
|
|
|
103 |
use MakeEntry;
|
|
|
104 |
use JatsLocateFiles;
|
|
|
105 |
use JatsDPackage;
|
| 271 |
dpurdie |
106 |
use MakeIf;
|
| 289 |
dpurdie |
107 |
use ToolsetPrinter;
|
|
|
108 |
use MakeObject;
|
| 339 |
dpurdie |
109 |
use JatsVersionUtils;
|
| 227 |
dpurdie |
110 |
|
|
|
111 |
|
|
|
112 |
our $ScmVersion = "2.34";
|
|
|
113 |
our $ScmGlobal = 0;
|
|
|
114 |
our $ScmExpert = 0;
|
|
|
115 |
our $ScmInterface = "interface"; # default 'interface'
|
|
|
116 |
our $ScmPackage = 1; # package active by default.
|
|
|
117 |
our $ScmProcessingRootMake = 0; # Processing root makefile.pl
|
|
|
118 |
our $ScmPlatformSeen = 0; # Platform directive has been seen
|
|
|
119 |
|
|
|
120 |
our $ScmToolsetVersion = ""; # version of toolset
|
|
|
121 |
our $ScmToolsetGenerate = 1; # generate active by default.
|
|
|
122 |
our $ScmToolsetProgDependancies = 1; # 1: Write program dependancies
|
|
|
123 |
# 0: Don't write progdeps. Prog is Phony
|
| 289 |
dpurdie |
124 |
our $ScmToolsetSingleType = 0; # Toolset does not support Debug and Production
|
| 227 |
dpurdie |
125 |
our $ScmToolsetProgSource = (); # Toolset Program Source
|
| 339 |
dpurdie |
126 |
our $ScmToolsetSoName = 0; # 1: Shared library supports SoName
|
| 363 |
dpurdie |
127 |
our $ScmToolsetNillLibSrc = 0; # 1: Librarys created without source specified
|
|
|
128 |
|
| 227 |
dpurdie |
129 |
our $ScmRoot = "";
|
|
|
130 |
our $ScmMakelib = "";
|
|
|
131 |
our $ScmPlatform = "";
|
|
|
132 |
our $ScmMachType = "";
|
|
|
133 |
our $ScmSrcDir = "";
|
|
|
134 |
our @ScmPlatformDirs = ();
|
|
|
135 |
our @ScmPlatformArgs = ();
|
| 289 |
dpurdie |
136 |
our $ScmBuildType = 0; # 0, P, D. 0 == P and D
|
| 227 |
dpurdie |
137 |
our $ScmProduct = "";
|
|
|
138 |
our $ScmTarget = "";
|
|
|
139 |
our $ScmTargetHost = "";
|
|
|
140 |
our $ScmToolset = "";
|
|
|
141 |
our @ScmToolsetArgs = ();
|
|
|
142 |
our @ScmDepends = ();
|
|
|
143 |
our %ScmSourceTypes = ();
|
|
|
144 |
our $ScmDeploymentPatch = "";
|
|
|
145 |
our $ProjectBase = ""; # Base of the user's project
|
|
|
146 |
our $ScmNoToolsTest = ""; # Supress compiler tests
|
|
|
147 |
our $ScmDependTags = 0; # Create dependancy scanning tag
|
|
|
148 |
|
|
|
149 |
our @CFLAGS = ();
|
|
|
150 |
our @CFLAGS_DEBUG = ();
|
|
|
151 |
our @CFLAGS_PROD = ();
|
|
|
152 |
our @CLINTFLAGS = ();
|
|
|
153 |
our @CLINTFLAGS_DEBUG = ();
|
|
|
154 |
our @CLINTFLAGS_PROD = ();
|
|
|
155 |
our @CXXFLAGS = ();
|
|
|
156 |
our @CXXFLAGS_DEBUG = ();
|
|
|
157 |
our @CXXFLAGS_PROD = ();
|
|
|
158 |
our @CXXLINTFLAGS = ();
|
|
|
159 |
our @CXXLINTFLAGS_DEBUG = ();
|
|
|
160 |
our @CXXLINTFLAGS_PROD = ();
|
|
|
161 |
our @ASFLAGS = ();
|
| 267 |
dpurdie |
162 |
our @ASFLAGS_DEBUG = ();
|
|
|
163 |
our @ASFLAGS_PROD = ();
|
| 227 |
dpurdie |
164 |
our @LDFLAGS = ();
|
| 267 |
dpurdie |
165 |
our @LDFLAGS_DEBUG = ();
|
|
|
166 |
our @LDFLAGS_PROD = ();
|
| 227 |
dpurdie |
167 |
|
|
|
168 |
our @INCDIRS = ();
|
|
|
169 |
our @NODEPDIRS = ();
|
|
|
170 |
our @S_INCDIRS = ();
|
|
|
171 |
our @G_INCDIRS = ();
|
|
|
172 |
our @L_INCDIRS = ();
|
|
|
173 |
our @SRCDIRS = ();
|
|
|
174 |
our @S_SRCDIRS = ();
|
|
|
175 |
our @G_SRCDIRS = ();
|
|
|
176 |
our @L_SRCDIRS = ();
|
|
|
177 |
our @LIBDIRS = ();
|
|
|
178 |
our @S_LIBDIRS = ();
|
|
|
179 |
our @G_LIBDIRS = ();
|
|
|
180 |
our @L_LIBDIRS = ();
|
|
|
181 |
|
|
|
182 |
our %SRCS = ();
|
|
|
183 |
our %SRC_ARGS = ();
|
|
|
184 |
our %SRC_TYPE = ();
|
|
|
185 |
our %SRC_DEPEND = ();
|
|
|
186 |
our %SCRIPTS = ();
|
|
|
187 |
our @COPYIN = ();
|
|
|
188 |
our @INITS = ();
|
|
|
189 |
our @DEFINES = ();
|
|
|
190 |
our @OBJS = ();
|
|
|
191 |
our %SHOBJ_LIB = ();
|
|
|
192 |
our @PROGOBJS = ();
|
| 289 |
dpurdie |
193 |
our @TESTPROGOBJS = ();
|
| 227 |
dpurdie |
194 |
our %OBJSOURCE = ();
|
|
|
195 |
our @CHDRS = ();
|
|
|
196 |
our @CSRCS = ();
|
|
|
197 |
our @CXXSRCS = ();
|
|
|
198 |
our @ASHDRS = ();
|
|
|
199 |
our @ASSRCS = ();
|
|
|
200 |
our @GENERATED = ();
|
|
|
201 |
our @GENERATED_NOTSRC = ();
|
|
|
202 |
our @RULES = ();
|
|
|
203 |
our @TOOLSETRULES = ();
|
|
|
204 |
our @TOOLSETDIRS = ();
|
|
|
205 |
our @TOOLSETDIRTREES = ();
|
|
|
206 |
our @TOOLSETGENERATED = ();
|
|
|
207 |
our @USERGENERATED = ();
|
|
|
208 |
our @TOOLSETOBJS = ();
|
|
|
209 |
our @TOOLSETLIBS = ();
|
|
|
210 |
our @TOOLSETPROGS = ();
|
|
|
211 |
our %INSTALL_HDRS = ();
|
|
|
212 |
our %INSTALL_CLSS = ();
|
|
|
213 |
|
|
|
214 |
our @LIBS = ();
|
| 289 |
dpurdie |
215 |
our $LIBS = ();
|
| 227 |
dpurdie |
216 |
our %LIB_PKG = ();
|
|
|
217 |
our %LIB_INS = ();
|
|
|
218 |
our %INSTALL_LIBS = ();
|
|
|
219 |
|
|
|
220 |
our @MLIBS = ();
|
| 289 |
dpurdie |
221 |
our $MLIBS = ();
|
| 227 |
dpurdie |
222 |
|
|
|
223 |
our @SHLIBS = ();
|
| 289 |
dpurdie |
224 |
our $SHLIBS = ();
|
| 227 |
dpurdie |
225 |
our @SHLIB_TARGETS = ();
|
|
|
226 |
our %SHLIB_PKG = ();
|
|
|
227 |
our %SHLIB_INS = ();
|
|
|
228 |
our %INSTALL_SHLIBS = ();
|
|
|
229 |
|
| 289 |
dpurdie |
230 |
our $TESTPROGS = ();
|
|
|
231 |
our @TESTPROGS = ();
|
| 227 |
dpurdie |
232 |
|
| 289 |
dpurdie |
233 |
our $PROGS = (); # Simplify tracking of progs
|
| 227 |
dpurdie |
234 |
our @PROGS = ();
|
| 289 |
dpurdie |
235 |
our @PROGS_EXTRA = (); # Look at doing better !!
|
| 227 |
dpurdie |
236 |
our %PROG_PKG = ();
|
|
|
237 |
our %PROG_INS = ();
|
|
|
238 |
our %INSTALL_PROGS = ();
|
|
|
239 |
|
|
|
240 |
our %PACKAGE_DIST = ();
|
|
|
241 |
our %PACKAGE_SETS = ();
|
|
|
242 |
our %PACKAGE_HDRS = ();
|
|
|
243 |
our %PACKAGE_LIBS = ();
|
|
|
244 |
our %PACKAGE_CLSS = ();
|
|
|
245 |
our %PACKAGE_SHLIBS = ();
|
|
|
246 |
our %PACKAGE_PROGS = ();
|
|
|
247 |
our %PACKAGE_FILES = ();
|
|
|
248 |
|
|
|
249 |
our @PACKAGE_VARS = ( '%PACKAGE_CLSS', '%PACKAGE_FILES', '%PACKAGE_HDRS',
|
|
|
250 |
'%PACKAGE_LIBS', '%PACKAGE_PROGS', '%PACKAGE_SHLIBS' );
|
|
|
251 |
our @INSTALL_VARS = ( '%INSTALL_CLSS', '%INSTALL_HDRS', '%INSTALL_LIBS',
|
|
|
252 |
'%INSTALL_PROGS', '%INSTALL_SHLIBS');
|
|
|
253 |
|
|
|
254 |
our @LINTLIBS = ();
|
|
|
255 |
our @LINTSHLIBS = ();
|
|
|
256 |
|
|
|
257 |
our @TESTS_TO_RUN = ();
|
|
|
258 |
our @TESTPROJECT_TO_URUN = ();
|
|
|
259 |
our @TESTPROJECT_TO_ARUN = ();
|
|
|
260 |
my $TESTS_TO_AUTORUN = undef;
|
| 263 |
dpurdie |
261 |
my $TESTS_TO_RUN = undef;
|
| 227 |
dpurdie |
262 |
|
|
|
263 |
#our $CurrentTime = "";
|
|
|
264 |
#our $CurrentDate = "";
|
|
|
265 |
#our $Cwd = "";
|
|
|
266 |
|
|
|
267 |
our @GENERATE_FILES = ();
|
|
|
268 |
our %DEPLOYPACKAGE = ();
|
| 267 |
dpurdie |
269 |
our $DEPLOYPACKAGE = 0;
|
| 261 |
dpurdie |
270 |
our %MakeTags;
|
| 227 |
dpurdie |
271 |
|
|
|
272 |
#
|
|
|
273 |
# Some toolset options that affect the generation of the makefile
|
|
|
274 |
#
|
|
|
275 |
our $UseAbsObjects = 0; # Default is relative paths to objects
|
|
|
276 |
our $UseRelativeRoot = 0; # Default is absolute paths to build root
|
| 299 |
dpurdie |
277 |
our $DPackageDirective = 0;
|
| 227 |
dpurdie |
278 |
|
| 271 |
dpurdie |
279 |
#
|
|
|
280 |
# Arrays of hook functions
|
|
|
281 |
#
|
|
|
282 |
our %MF_RegisterSrcHooks; # Hook source file discovery
|
|
|
283 |
|
|
|
284 |
|
| 227 |
dpurdie |
285 |
###############################################################################
|
|
|
286 |
#
|
|
|
287 |
# Packaging and Installation Information
|
|
|
288 |
# Held in a structure as its used in a few places
|
|
|
289 |
# Items
|
|
|
290 |
# PBase - Package Base directory. Used for user overrides
|
|
|
291 |
# IBase - Local Install Base directory
|
|
|
292 |
# Dir - Default directory suffix for components. Added to Pbase and IBase
|
|
|
293 |
#
|
|
|
294 |
#
|
|
|
295 |
our %PackageInfo = (
|
|
|
296 |
'File' => { 'PBase' => '$(PKGDIR)' ,'IBase' => '$(LOCALDIR)' , 'Dir' => '' },
|
|
|
297 |
'Hdr' => { 'PBase' => '$(INCDIR_PKG)' ,'IBase' => '$(INCDIR_LOCAL)' , 'Dir' => ''},
|
|
|
298 |
'Lib' => { 'PBase' => '$(LIBDIR_PKG)' ,'IBase' => '$(LIBDIR_LOCAL)' , 'Dir' => '/$(GBE_PLATFORM)'},
|
|
|
299 |
'Prog' => { 'PBase' => '$(BINDIR_PKG)' ,'IBase' => '$(BINDIR_LOCAL)' , 'Dir' => '/$(GBE_PLATFORM)$(GBE_TYPE)'},
|
|
|
300 |
'Jar' => { 'PBase' => '$(CLSDIR_PKG)' ,'IBase' => '$(CLSDIR_LOCAL)' , 'Dir' => ''},
|
| 241 |
dpurdie |
301 |
'Tool' => { 'PBase' => '$(PKGDIR)' ,'IBase' => '$(LOCALDIR)' , 'Dir' => '/tools/bin/$(GBE_HOSTMACH)'},
|
| 227 |
dpurdie |
302 |
);
|
|
|
303 |
|
|
|
304 |
MakeLib2Init(); # Runtime initialisation
|
|
|
305 |
|
|
|
306 |
sub MakeLib2Init
|
|
|
307 |
{
|
|
|
308 |
#.. Test environment
|
|
|
309 |
#
|
|
|
310 |
EnvImport( "GBE_CORE" );
|
|
|
311 |
EnvImport( "GBE_BIN" );
|
|
|
312 |
EnvImport( "GBE_PERL" );
|
|
|
313 |
EnvImport( "GBE_TOOLS" );
|
|
|
314 |
EnvImport( "GBE_CONFIG" );
|
|
|
315 |
EnvImport( "GBE_MACHTYPE" );
|
|
|
316 |
|
|
|
317 |
#.. Common stuff
|
|
|
318 |
#
|
|
|
319 |
require "$::GBE_TOOLS/common.pl"; # Common stuff
|
|
|
320 |
push( @ScmDepends, "$::GBE_TOOLS/common.pl" );
|
|
|
321 |
|
|
|
322 |
CommonInit( "makelib2" );
|
|
|
323 |
Debug( "version: $ScmVersion" );
|
|
|
324 |
|
|
|
325 |
#.. Cache arguments
|
|
|
326 |
#
|
|
|
327 |
CommandLine();
|
|
|
328 |
|
|
|
329 |
#.. Build defaults
|
|
|
330 |
#
|
|
|
331 |
$ScmSourceTypes{ ".h" } = ".h";
|
|
|
332 |
$ScmSourceTypes{ ".hpp" } = ".h";
|
|
|
333 |
$ScmSourceTypes{ ".c" } = ".c";
|
|
|
334 |
$ScmSourceTypes{ ".C" } = ".c";
|
|
|
335 |
$ScmSourceTypes{ ".cpp" } = ".cc";
|
|
|
336 |
$ScmSourceTypes{ ".cc" } = ".cc";
|
|
|
337 |
$ScmSourceTypes{ ".asm" } = ".asm";
|
|
|
338 |
$ScmSourceTypes{ ".x" } = "--Ignore";
|
|
|
339 |
$ScmSourceTypes{ ".ini" } = "--Ignore";
|
|
|
340 |
$ScmSourceTypes{ ".sh" } = "--Ignore";
|
|
|
341 |
$ScmSourceTypes{ ".pl" } = "--Ignore";
|
|
|
342 |
$ScmSourceTypes{ ".awk" } = "--Ignore";
|
|
|
343 |
|
|
|
344 |
#.. Get the stuff from the build configuration file
|
|
|
345 |
#
|
|
|
346 |
ConfigLoad();
|
|
|
347 |
|
| 369 |
dpurdie |
348 |
if ( (%::ScmBuildPlatforms) ) # Interface/build.cfg
|
| 227 |
dpurdie |
349 |
{
|
|
|
350 |
AddPlatformArg( split( /$;/, $::ScmBuildPlatforms{ $ScmPlatform } ));
|
|
|
351 |
}
|
|
|
352 |
|
| 369 |
dpurdie |
353 |
if ( (%::ScmBuildIncludes) ) # Interface/build.cfg
|
| 227 |
dpurdie |
354 |
{
|
|
|
355 |
my( @includes ) = split( ',', $::ScmBuildIncludes{ $ScmPlatform } );
|
|
|
356 |
my( $global ) = $ScmGlobal;
|
|
|
357 |
|
|
|
358 |
$ScmGlobal = 1; # Follow defs are "global's" ...
|
|
|
359 |
foreach my $elem ( @includes )
|
|
|
360 |
{
|
|
|
361 |
AddIncDir( "*", $elem ) if ($elem);
|
|
|
362 |
}
|
|
|
363 |
$ScmGlobal = $global; # Restore global status ...
|
|
|
364 |
}
|
|
|
365 |
|
| 369 |
dpurdie |
366 |
if ( (%::ScmBuildLibraries) ) # Interface/build.cfg
|
| 227 |
dpurdie |
367 |
{
|
|
|
368 |
my( @libraries ) = split( ',', $::ScmBuildLibraries{ $ScmPlatform } );
|
|
|
369 |
my( $global ) = $ScmGlobal;
|
|
|
370 |
|
|
|
371 |
$ScmGlobal = 1; # Follow defs are "global's" ...
|
|
|
372 |
foreach my $elem ( @libraries )
|
|
|
373 |
{
|
|
|
374 |
AddLibDir( "*", $elem ) if ($elem);
|
|
|
375 |
}
|
|
|
376 |
$ScmGlobal = $global; # Restore global status ...
|
|
|
377 |
}
|
|
|
378 |
|
|
|
379 |
#.. Determine the value of $ScmMachType
|
|
|
380 |
# In the makefile GBE_MACHTYPE will be set to $ScmMachType.
|
|
|
381 |
#
|
|
|
382 |
# There is an compatibility issue here.
|
|
|
383 |
# A lot of (legacy) package.pl files use GBE_MACHTYPE to specify platform
|
|
|
384 |
# specfic directories and names. This is not to be encouraged.
|
|
|
385 |
#
|
|
|
386 |
# Allow for a platformm specific override
|
|
|
387 |
#
|
|
|
388 |
if ( exists( $::BUILDINFO{$ScmPlatform}{'SCMMACHTYPE'} ))
|
|
|
389 |
{
|
|
|
390 |
$ScmMachType = $::BUILDINFO{$ScmPlatform}{'SCMMACHTYPE'};
|
|
|
391 |
Verbose("Override ScmMachType: $ScmMachType");
|
|
|
392 |
}
|
|
|
393 |
else
|
|
|
394 |
{
|
|
|
395 |
$ScmMachType = $ScmPlatform;
|
|
|
396 |
}
|
|
|
397 |
|
|
|
398 |
|
|
|
399 |
#.. Get the stuff from the Package definition file
|
|
|
400 |
# A convention is that package.pl provide a package name via $Pbase
|
|
|
401 |
# This may be different to the BUILDNAME. Generate a default $Pbase
|
|
|
402 |
# to allow the package.pl to use the package name part of the buildname
|
|
|
403 |
#
|
|
|
404 |
$::Pbase = $::ScmBuildPackage;
|
|
|
405 |
if ( -f "$ScmRoot/package.pl" )
|
|
|
406 |
{
|
|
|
407 |
Warning ("package.pl file used. Use is being deprecated");
|
|
|
408 |
|
|
|
409 |
my( $global ) = $ScmGlobal; # Follow defs are "global's" ...
|
|
|
410 |
$ScmGlobal = 1;
|
|
|
411 |
require "$ScmRoot/package.pl";
|
|
|
412 |
$ScmGlobal = $global; # Restore global status ...
|
|
|
413 |
|
|
|
414 |
if ( defined ($::ScmBuildPackage) && defined ($::Pbase) )
|
|
|
415 |
{
|
|
|
416 |
# Special case.
|
|
|
417 |
# $Pbase is set to ".". Set $Pbase to the Build Name to force
|
|
|
418 |
# construction of a well formatted package.
|
|
|
419 |
#
|
|
|
420 |
$::Pbase = $::ScmBuildPackage
|
|
|
421 |
if ( $::Pbase eq "." );
|
|
|
422 |
|
|
|
423 |
#
|
|
|
424 |
# Error if Pbase has changed
|
|
|
425 |
#
|
|
|
426 |
Error ("Pbase is not the same as the BuildName (Check package.pl)",
|
|
|
427 |
"Pbase : $::Pbase",
|
|
|
428 |
"BuildName: $::ScmBuildPackage")
|
|
|
429 |
if ( $::Pbase ne $::ScmBuildPackage );
|
|
|
430 |
}
|
|
|
431 |
}
|
| 289 |
dpurdie |
432 |
|
|
|
433 |
#
|
|
|
434 |
# Create objects to keep track of Libraies and Programs
|
|
|
435 |
#
|
|
|
436 |
$LIBS = MakeObject::NewType( 'Library', \@LIBS, '$(LIBDIR)/', \&GenLibName);
|
|
|
437 |
$MLIBS = MakeObject::NewType( 'MergedLibrary', \@MLIBS, '$(LIBDIR)/', \&GenLibName);
|
|
|
438 |
$SHLIBS = MakeObject::NewType( 'SharedLibrary', \@SHLIBS, '$(LIBDIR)/', \&GenLibName);
|
|
|
439 |
$PROGS = MakeObject::NewType( 'Program', \@PROGS, '$(BINDIR)/', \&GenProgName);
|
|
|
440 |
$TESTPROGS = MakeObject::NewType( 'TestProgram', \@TESTPROGS,'$(BINDIR)/', \&GenProgName);
|
| 227 |
dpurdie |
441 |
}
|
|
|
442 |
|
| 261 |
dpurdie |
443 |
#-------------------------------------------------------------------------------
|
| 289 |
dpurdie |
444 |
# Function : GenLibName
|
|
|
445 |
#
|
|
|
446 |
# Description : Helper function to generate a (static) library name
|
|
|
447 |
# Used by MakeObject::NewType
|
|
|
448 |
#
|
|
|
449 |
# If the toolset doesn't support Debug and Prod, then
|
|
|
450 |
# The library name will not have the suffix
|
|
|
451 |
#
|
|
|
452 |
# Inputs : arg0 - Base name of the library
|
| 343 |
dpurdie |
453 |
# arg1 - Mode: 1 == Plain. No P or D
|
| 289 |
dpurdie |
454 |
#
|
|
|
455 |
# Returns : Name of the library as used in the makefiles
|
|
|
456 |
# Does not include base directory
|
|
|
457 |
#
|
|
|
458 |
sub GenLibName
|
|
|
459 |
{
|
| 343 |
dpurdie |
460 |
if ( $ScmToolsetSingleType || $_[1] ) {
|
| 289 |
dpurdie |
461 |
return "$_[0].$::a"
|
|
|
462 |
} else {
|
|
|
463 |
return "$_[0]\$(GBE_TYPE).$::a"
|
|
|
464 |
}
|
|
|
465 |
}
|
|
|
466 |
|
|
|
467 |
#-------------------------------------------------------------------------------
|
|
|
468 |
# Function : GenProgName
|
|
|
469 |
#
|
|
|
470 |
# Description : Helper function to generate a program name
|
|
|
471 |
# Used by MakeObject::NewType
|
|
|
472 |
#
|
|
|
473 |
# Inputs : arg0 - Base name of the library
|
|
|
474 |
#
|
|
|
475 |
# Returns : Name of the program as used in the makefiles
|
|
|
476 |
# Does not include base directory
|
|
|
477 |
#
|
|
|
478 |
sub GenProgName
|
|
|
479 |
{
|
|
|
480 |
return "$_[0]$::exe"
|
|
|
481 |
}
|
|
|
482 |
|
|
|
483 |
|
|
|
484 |
#-------------------------------------------------------------------------------
|
| 261 |
dpurdie |
485 |
# Function : CommandLine
|
|
|
486 |
#
|
|
|
487 |
# Description : Process the command line.
|
|
|
488 |
# Arguments describes below
|
|
|
489 |
#
|
|
|
490 |
# Arguments : ARG0 - Root of the project
|
|
|
491 |
# ARG1 - Path to this script
|
|
|
492 |
# ARG2 - Target Platform
|
|
|
493 |
#
|
|
|
494 |
# Options follow
|
|
|
495 |
# --interface=name - Name of interface dir
|
|
|
496 |
# --arg=xxx - Platform argument
|
|
|
497 |
#
|
|
|
498 |
# Otherwise display a usage message
|
|
|
499 |
#
|
|
|
500 |
# Returns : Nothing
|
|
|
501 |
#
|
| 227 |
dpurdie |
502 |
sub CommandLine
|
|
|
503 |
{
|
| 261 |
dpurdie |
504 |
Verbose ("Command Line: @ARGV");
|
| 227 |
dpurdie |
505 |
|
| 261 |
dpurdie |
506 |
#
|
|
|
507 |
# Extract options first
|
|
|
508 |
#
|
|
|
509 |
my $opt_help = 0;
|
|
|
510 |
my $result = GetOptions (
|
|
|
511 |
"help+" => \$opt_help,
|
|
|
512 |
"interface=s" => \$::ScmInterface,
|
|
|
513 |
"arg=s" => sub{ AddPlatformArg( "--$_[1]") }
|
|
|
514 |
);
|
|
|
515 |
Usage() if ( $opt_help || !$result );
|
|
|
516 |
|
|
|
517 |
#
|
|
|
518 |
# Need 3 Arguments
|
|
|
519 |
#
|
| 227 |
dpurdie |
520 |
$ScmRoot = ${ARGV[0]};
|
| 261 |
dpurdie |
521 |
$ScmRoot = RelPath( $ScmRoot );
|
| 227 |
dpurdie |
522 |
$ProjectBase = $ScmRoot;
|
|
|
523 |
|
|
|
524 |
$ScmMakelib = ${ARGV[1]};
|
|
|
525 |
$ScmPlatform = ${ARGV[2]};
|
|
|
526 |
$ScmTarget = $ScmPlatform;
|
|
|
527 |
|
|
|
528 |
Message ("[$ScmPlatform] Generate Makefile");
|
|
|
529 |
Debug( "root\t=$ScmRoot" );
|
|
|
530 |
Debug( "makelib\t=$ScmMakelib" );
|
|
|
531 |
Debug( "platform\t=$ScmPlatform" );
|
|
|
532 |
}
|
|
|
533 |
|
|
|
534 |
# Usage ---
|
|
|
535 |
# Command line usage help.
|
|
|
536 |
#..
|
|
|
537 |
|
|
|
538 |
sub Usage
|
|
|
539 |
{
|
| 261 |
dpurdie |
540 |
Error ( "Usage: perl makefile.pl2 <ROOTDIR> <makelib.pl2> <PLATFORM> [options ...]",
|
|
|
541 |
"Valid options:",
|
|
|
542 |
" --interface=name Set interface directory",
|
|
|
543 |
" --arg=text Specify platform argument",
|
|
|
544 |
);
|
| 227 |
dpurdie |
545 |
}
|
|
|
546 |
|
|
|
547 |
|
|
|
548 |
#-------------------------------------------------------------------------------
|
|
|
549 |
# Function : SubDir
|
|
|
550 |
#
|
|
|
551 |
# Description : Include a sub-makefile
|
|
|
552 |
# When called when processing by this script this directive
|
|
|
553 |
# does nothing. The processing will be done by makelib.pl
|
|
|
554 |
#
|
|
|
555 |
# This directive MUST occur before the Platform directive
|
|
|
556 |
#
|
|
|
557 |
# Inputs : None that are used
|
|
|
558 |
#
|
|
|
559 |
# Returns : Nothing
|
|
|
560 |
#
|
|
|
561 |
|
|
|
562 |
sub SubDir
|
|
|
563 |
{
|
|
|
564 |
Error ("SubDir directive not allowed after the Platform directive")
|
|
|
565 |
if ( $ScmPlatformSeen );
|
|
|
566 |
}
|
|
|
567 |
|
|
|
568 |
|
|
|
569 |
###############################################################################
|
|
|
570 |
# Platform support
|
|
|
571 |
###############################################################################
|
|
|
572 |
|
|
|
573 |
sub Platform
|
|
|
574 |
{
|
|
|
575 |
my( $global, $file );
|
|
|
576 |
|
|
|
577 |
Debug( "Platform( $ScmPlatform, @ScmPlatformArgs )" );
|
|
|
578 |
|
|
|
579 |
#.. Sanity test
|
|
|
580 |
#
|
|
|
581 |
Error ("Platform directive is not allowed in common makefile.pl")
|
|
|
582 |
if ( $ScmProcessingRootMake );
|
|
|
583 |
|
|
|
584 |
Error ("Only one Platform directive is allowed")
|
|
|
585 |
if ( $ScmPlatformSeen );
|
|
|
586 |
$ScmPlatformSeen = 1;
|
|
|
587 |
|
|
|
588 |
#.. Arguments
|
|
|
589 |
#
|
|
|
590 |
$ScmTargetHost = $::ScmHost; # default
|
|
|
591 |
|
|
|
592 |
#.. Common configuration
|
|
|
593 |
#
|
|
|
594 |
$global = $ScmGlobal; # Follow defs are "global's" ...
|
|
|
595 |
$ScmGlobal = 1;
|
|
|
596 |
|
|
|
597 |
#.. Common rules (ScmHost specific)
|
|
|
598 |
#
|
|
|
599 |
push( @ScmDepends, "$ScmMakelib" ); # parent
|
|
|
600 |
|
|
|
601 |
$file = Require( "$::GBE_CONFIG", "Rules", "Common rules " );
|
|
|
602 |
push( @ScmDepends, "$file" );
|
|
|
603 |
|
|
|
604 |
#.. Platform (defines ScmToolset)
|
|
|
605 |
#
|
| 369 |
dpurdie |
606 |
if ( ( %::ScmBuildProducts ) && # interface/build.cfg
|
| 227 |
dpurdie |
607 |
$::ScmBuildProducts{ $ScmPlatform } )
|
|
|
608 |
{
|
|
|
609 |
my( @args ) = split( ',', $::ScmBuildProducts{ $ScmPlatform } );
|
|
|
610 |
|
|
|
611 |
$ScmProduct = $args[0];
|
|
|
612 |
$ScmTarget = $args[1];
|
|
|
613 |
|
|
|
614 |
Debug( " mapping to product $ScmProduct" );
|
|
|
615 |
|
|
|
616 |
# Platform/target specific
|
|
|
617 |
MakeIf::PackageDirs( \@ScmPlatformDirs, $ScmPlatform, $ScmTarget );
|
|
|
618 |
push @ScmPlatformDirs, "$::GBE_CONFIG"; # .. plus default
|
|
|
619 |
|
|
|
620 |
@ScmPlatformArgs = ( "--product=$ScmProduct", @ScmPlatformArgs );
|
|
|
621 |
$file = Require( "PLATFORM", $ScmTarget,
|
|
|
622 |
"Platform definition ", @ScmPlatformDirs );
|
|
|
623 |
}
|
|
|
624 |
else # standard
|
|
|
625 |
{
|
|
|
626 |
Debug( " native platform" );
|
|
|
627 |
|
|
|
628 |
# Platform specific
|
|
|
629 |
MakeIf::PackageDirs( \@ScmPlatformDirs, $ScmPlatform );
|
|
|
630 |
push @ScmPlatformDirs, "$::GBE_CONFIG"; # .. plus default
|
|
|
631 |
|
|
|
632 |
$file = Require( "PLATFORM", $ScmPlatform,
|
|
|
633 |
"Platform definition ", @ScmPlatformDirs );
|
|
|
634 |
}
|
|
|
635 |
push( @ScmDepends, "$file" );
|
|
|
636 |
|
|
|
637 |
Error( "Toolset undefined for platform $ScmPlatform ...")
|
|
|
638 |
unless( $ScmToolset );
|
|
|
639 |
|
|
|
640 |
#.. Toolset
|
|
|
641 |
#
|
|
|
642 |
$file = Require( "$::GBE_CONFIG/TOOLSET", $ScmToolset, "Toolset definition " );
|
|
|
643 |
push( @ScmDepends, "$file" );
|
|
|
644 |
|
|
|
645 |
#.. Package definitions
|
|
|
646 |
#
|
| 367 |
dpurdie |
647 |
# Global DPACKAGE definitions, which may pull in $ScmTarget specific definitions.
|
| 227 |
dpurdie |
648 |
#
|
|
|
649 |
|
|
|
650 |
MakeIf::PackageLoad( $ScmPlatform ); # DPACKAGE's (if any)
|
|
|
651 |
|
|
|
652 |
|
|
|
653 |
#.. Package extensions
|
|
|
654 |
# Import, into the current package, files of the form gbe/DIRECTIVES
|
|
|
655 |
# These allow the JATS directives to be extended by the contents of a package
|
|
|
656 |
# without the need to update the core JATS release.
|
|
|
657 |
#
|
|
|
658 |
# Intended use: Associate a directive with a tool script, such that the
|
|
|
659 |
# new directive simplifies the use of the tool script.
|
|
|
660 |
#
|
|
|
661 |
#
|
|
|
662 |
# First: Extend the Perl Search Space to include the toolset extensions
|
|
|
663 |
# Although the directives are in gbe/DIRECTIVES/*.pm, they may need
|
|
|
664 |
# to reference other packages that are not.
|
|
|
665 |
#
|
| 311 |
dpurdie |
666 |
# Look in the 'interface' and 'link' packages
|
|
|
667 |
# The 'build' packages are duplicated into the 'interface'
|
|
|
668 |
#
|
| 227 |
dpurdie |
669 |
for my $path ( ToolExtensionPaths() )
|
|
|
670 |
{
|
|
|
671 |
UniquePush (\@INC, $path)
|
|
|
672 |
if (glob( "$path/*.pm") || glob( "$path/*/*.pm"));
|
|
|
673 |
}
|
|
|
674 |
|
|
|
675 |
for my $entry (@{$::ScmBuildPkgRules{$ScmPlatform} })
|
|
|
676 |
{
|
| 311 |
dpurdie |
677 |
next if ( $entry->{'TYPE'} eq 'build' );
|
| 227 |
dpurdie |
678 |
my $cfgdir = $entry->{'CFGDIR'};
|
|
|
679 |
next unless ( $cfgdir );
|
|
|
680 |
my $base_dir = $entry->{'ROOT'} . $cfgdir . '/DIRECTIVES';
|
|
|
681 |
next unless ( -d $base_dir );
|
|
|
682 |
foreach my $file ( glob ("$base_dir/*.pm") )
|
|
|
683 |
{
|
|
|
684 |
push( @ScmDepends, "$file" );
|
|
|
685 |
require $file;
|
|
|
686 |
}
|
|
|
687 |
}
|
|
|
688 |
|
|
|
689 |
#
|
| 271 |
dpurdie |
690 |
# Include local toolset extensions
|
|
|
691 |
# These are rooted in the build directory and are not to be confused with
|
|
|
692 |
# extensions that may be packaged
|
|
|
693 |
#
|
|
|
694 |
my $local_base_dir = "$ScmRoot/gbe/DIRECTIVES";
|
|
|
695 |
if ( -d $local_base_dir )
|
|
|
696 |
{
|
|
|
697 |
foreach my $file ( glob ("$local_base_dir/*.pm") )
|
|
|
698 |
{
|
|
|
699 |
push( @ScmDepends, "$file" );
|
|
|
700 |
require $file;
|
|
|
701 |
}
|
|
|
702 |
}
|
|
|
703 |
|
|
|
704 |
#
|
| 227 |
dpurdie |
705 |
# All makefile.pl's will include a makefile.pl found in the build
|
|
|
706 |
# root directory ( The same directory as build.pl ). This makefile.pl
|
|
|
707 |
# is a little bit different - It should not "require "$ARGV[1]", nor
|
|
|
708 |
# should it use a Platform directive.
|
|
|
709 |
#
|
|
|
710 |
# Note: This makefile is processed AFTER the toolset has been initialised
|
|
|
711 |
# so that toolset extensions are available to the directives
|
|
|
712 |
#
|
|
|
713 |
$file = "$ScmRoot/makefile.pl";
|
|
|
714 |
if ( -e $file ) {
|
|
|
715 |
$ScmProcessingRootMake = 1;
|
|
|
716 |
require "$file";
|
|
|
717 |
$ScmProcessingRootMake = 0;
|
|
|
718 |
push( @ScmDepends, "$file" );
|
|
|
719 |
}
|
|
|
720 |
|
|
|
721 |
#
|
| 289 |
dpurdie |
722 |
# Sanity Test for platforms that do not support both debug and production
|
|
|
723 |
# builds at the same time. This information is flagged by the toolset
|
|
|
724 |
# which we have now loaded.
|
|
|
725 |
#
|
|
|
726 |
if ( $ScmToolsetSingleType )
|
|
|
727 |
{
|
|
|
728 |
unless ( $ScmBuildType )
|
|
|
729 |
{
|
|
|
730 |
Error ("The toolset used by the \"$ScmPlatform\" platform does not support",
|
|
|
731 |
"both Production and Debug Builds" );
|
|
|
732 |
}
|
|
|
733 |
}
|
|
|
734 |
|
|
|
735 |
#
|
| 227 |
dpurdie |
736 |
# Restore global status ...
|
|
|
737 |
#
|
|
|
738 |
$ScmGlobal = $global;
|
|
|
739 |
}
|
|
|
740 |
|
|
|
741 |
|
|
|
742 |
sub PlatformRequire
|
|
|
743 |
{
|
|
|
744 |
my( $script, @arguments ) = @_;
|
|
|
745 |
my( $file );
|
|
|
746 |
|
|
|
747 |
Debug( "PlatformRequire($script, @arguments)" );
|
|
|
748 |
|
|
|
749 |
push( @ScmPlatformArgs, @arguments ); # additional arguments
|
|
|
750 |
|
|
|
751 |
$file = Require( "PLATFORM", $script,
|
|
|
752 |
"PlatformRequire ", @ScmPlatformDirs );
|
|
|
753 |
|
|
|
754 |
push( @ScmDepends, "$file" );
|
|
|
755 |
}
|
|
|
756 |
|
|
|
757 |
|
|
|
758 |
sub PlatformInclude
|
|
|
759 |
{
|
|
|
760 |
my( $script, @arguments ) = @_;
|
|
|
761 |
my( $file );
|
|
|
762 |
|
|
|
763 |
Debug( "PlatformInclude( @_ )" );
|
|
|
764 |
|
|
|
765 |
$file = Require2( \@arguments, "PLATFORM", $script,
|
|
|
766 |
"PlatformInclude ", @ScmPlatformDirs );
|
|
|
767 |
|
|
|
768 |
push( @ScmDepends, "$file" );
|
|
|
769 |
}
|
|
|
770 |
|
|
|
771 |
|
|
|
772 |
sub PlatformDefine
|
|
|
773 |
{
|
|
|
774 |
Debug2( "PlatformDefine(@_)" );
|
|
|
775 |
|
|
|
776 |
Define( @_ );
|
|
|
777 |
}
|
|
|
778 |
|
|
|
779 |
|
|
|
780 |
sub PlatformDefines
|
|
|
781 |
{
|
|
|
782 |
my( $script ) = @_;
|
|
|
783 |
my( $line );
|
|
|
784 |
|
|
|
785 |
Debug2( "PlatformDefine(@_)" );
|
|
|
786 |
|
|
|
787 |
$script = Exists( "PLATFORM", $script, # locate image
|
|
|
788 |
"PlatformDefines", @ScmPlatformDirs );
|
|
|
789 |
|
| 271 |
dpurdie |
790 |
push( @DEFINES, "# PlatformDefines from: $script" );
|
| 285 |
dpurdie |
791 |
open( my $fh, '<', $script ) || Error( "Opening $script" );
|
|
|
792 |
while (<$fh>) {
|
| 227 |
dpurdie |
793 |
$_ =~ s/\s*(\n|$)//; # kill trailing whitespace & nl
|
|
|
794 |
push( @DEFINES, $_ );
|
|
|
795 |
}
|
|
|
796 |
push( @ScmDepends, "$script" ); # makefile dependencies
|
| 285 |
dpurdie |
797 |
close( $fh );
|
| 227 |
dpurdie |
798 |
}
|
|
|
799 |
|
|
|
800 |
|
|
|
801 |
sub PlatformEntry
|
|
|
802 |
{
|
|
|
803 |
my( $prelim, $postlim, $prefix, $postfix, @elements ) = @_;
|
|
|
804 |
|
| 285 |
dpurdie |
805 |
my $str = "$prelim";
|
|
|
806 |
foreach my $element ( @elements )
|
| 227 |
dpurdie |
807 |
{
|
|
|
808 |
$str .= "${prefix}${element}${postfix}";
|
|
|
809 |
}
|
|
|
810 |
$str .= "$postlim";
|
|
|
811 |
PlatformDefine( $str );
|
|
|
812 |
}
|
|
|
813 |
|
|
|
814 |
|
|
|
815 |
#
|
|
|
816 |
# Add arguments to the ScmPlatformArgs, but remove "Global" arguments
|
|
|
817 |
# --OnlyDebug
|
|
|
818 |
# --OnlyProduction
|
| 343 |
dpurdie |
819 |
# --NoToolSet
|
| 227 |
dpurdie |
820 |
#
|
| 289 |
dpurdie |
821 |
# Capture OnlyDebug and OnlyProd information
|
|
|
822 |
# Will be sanitized by caller.
|
|
|
823 |
#
|
| 227 |
dpurdie |
824 |
sub AddPlatformArg
|
|
|
825 |
{
|
|
|
826 |
Debug("AddPlatformArg: @_" );
|
| 289 |
dpurdie |
827 |
foreach ( @_ )
|
|
|
828 |
{
|
|
|
829 |
if ( m~^--OnlyDebug~ ) {
|
|
|
830 |
$ScmBuildType = 'D';
|
|
|
831 |
} elsif ( m~--OnlyProd~ ) {
|
|
|
832 |
$ScmBuildType = 'P';
|
| 343 |
dpurdie |
833 |
} elsif ( m~--NoToolSet~ ) {
|
|
|
834 |
$ScmNoToolsTest = 1;
|
| 289 |
dpurdie |
835 |
} else {
|
| 343 |
dpurdie |
836 |
UniquePush( \@::ScmPlatformArgs, $_ );
|
| 289 |
dpurdie |
837 |
}
|
|
|
838 |
}
|
| 227 |
dpurdie |
839 |
|
|
|
840 |
Debug("AddPlatformArg: Result: @::ScmPlatformArgs" );
|
|
|
841 |
1;
|
|
|
842 |
}
|
|
|
843 |
|
|
|
844 |
###############################################################################
|
|
|
845 |
# Toolset support
|
|
|
846 |
#
|
|
|
847 |
# Toolset( 'platform [, ... ]', name, [arg, ... ] )
|
|
|
848 |
# Specify the toolset for a platform
|
|
|
849 |
#
|
|
|
850 |
# ToolDefine( )
|
|
|
851 |
# ToolDefines( )
|
|
|
852 |
# Specifies toolset defines for insertion into the target makefile.
|
|
|
853 |
#
|
|
|
854 |
# ToolsetDir
|
|
|
855 |
# Define toolset created directory(s) for removal during
|
|
|
856 |
# 'clean' operations.
|
|
|
857 |
#
|
|
|
858 |
# ToolsetGenerate
|
|
|
859 |
# Define toolset created file(s) for removal during
|
|
|
860 |
# 'clean' operations.
|
|
|
861 |
#
|
|
|
862 |
# ToolsetObj
|
|
|
863 |
# Define toolset created object(s) for removal during
|
|
|
864 |
# 'clean' operations.
|
|
|
865 |
#
|
|
|
866 |
# ToolsetLib
|
|
|
867 |
# Define toolset created library(s) for removal during
|
|
|
868 |
# 'clean' operations.
|
|
|
869 |
#
|
|
|
870 |
# ToolsetProg
|
|
|
871 |
# Define toolset created prog(s) for removal during
|
|
|
872 |
# 'clean' operations.
|
|
|
873 |
#
|
|
|
874 |
# ToolsetRule( )
|
|
|
875 |
# ToolsetRules( )
|
|
|
876 |
# Specifies toolset rules for insertion into the target makefile.
|
|
|
877 |
#
|
|
|
878 |
##############################################################################
|
|
|
879 |
|
|
|
880 |
sub Toolset
|
|
|
881 |
{
|
|
|
882 |
my( $platforms, $toolset, @arguments ) = @_;
|
|
|
883 |
|
|
|
884 |
Debug2( "Toolset(@_)" );
|
|
|
885 |
|
|
|
886 |
return if ( ! ActivePlatform($platforms) );
|
|
|
887 |
|
|
|
888 |
$ScmToolset = $toolset;
|
|
|
889 |
@ScmToolsetArgs = @arguments;
|
|
|
890 |
}
|
|
|
891 |
|
|
|
892 |
|
|
|
893 |
sub ToolsetRequire
|
|
|
894 |
{
|
|
|
895 |
my( $script, @arguments ) = @_;
|
|
|
896 |
my( $file );
|
|
|
897 |
|
|
|
898 |
Debug2( "ToolsetRequire(@_)" );
|
|
|
899 |
|
|
|
900 |
@ScmToolsetArgs = @arguments;
|
|
|
901 |
$file = Require( "",
|
|
|
902 |
$script,
|
|
|
903 |
"ToolsetRequire",
|
|
|
904 |
"$::GBE_CONFIG/TOOLSET", @::BUILDTOOLSPATH );
|
|
|
905 |
push( @ScmDepends, "$file" );
|
|
|
906 |
}
|
|
|
907 |
|
|
|
908 |
|
|
|
909 |
sub ToolsetDefine
|
|
|
910 |
{
|
|
|
911 |
Debug2( "ToolsetDefine(@_)" );
|
|
|
912 |
|
|
|
913 |
Define( @_ );
|
|
|
914 |
}
|
|
|
915 |
|
|
|
916 |
|
|
|
917 |
sub ToolsetDefines
|
|
|
918 |
{
|
|
|
919 |
Debug2( "ToolsetDefines(@_)" );
|
|
|
920 |
|
| 261 |
dpurdie |
921 |
Defines( "$::GBE_CONFIG/TOOLSET", @_ );
|
| 227 |
dpurdie |
922 |
}
|
|
|
923 |
|
|
|
924 |
|
|
|
925 |
sub ToolsetDir
|
|
|
926 |
{
|
|
|
927 |
Debug2( "ToolsetDir(@_)" );
|
|
|
928 |
|
| 261 |
dpurdie |
929 |
UniquePush ( \@TOOLSETDIRS, @_ );
|
| 227 |
dpurdie |
930 |
}
|
|
|
931 |
|
|
|
932 |
|
|
|
933 |
sub ToolsetDirTree
|
|
|
934 |
{
|
|
|
935 |
Debug2( "ToolsetDirTree(@_)" );
|
|
|
936 |
|
| 261 |
dpurdie |
937 |
UniquePush ( \@TOOLSETDIRTREES, @_);
|
| 227 |
dpurdie |
938 |
}
|
|
|
939 |
|
|
|
940 |
|
|
|
941 |
sub ToolsetGenerate
|
|
|
942 |
{
|
|
|
943 |
Debug2( "ToolsetGenerate(@_)" );
|
|
|
944 |
|
|
|
945 |
UniquePush( \@TOOLSETGENERATED, @_ );
|
|
|
946 |
}
|
|
|
947 |
|
|
|
948 |
|
|
|
949 |
sub ToolsetObj
|
|
|
950 |
{
|
|
|
951 |
Debug2( "ToolsetObj(@_)" );
|
|
|
952 |
|
| 261 |
dpurdie |
953 |
foreach my $obj ( @_ )
|
| 227 |
dpurdie |
954 |
{
|
| 261 |
dpurdie |
955 |
UniquePush( \@TOOLSETOBJS, "$obj.$::o" );
|
| 227 |
dpurdie |
956 |
}
|
|
|
957 |
}
|
|
|
958 |
|
|
|
959 |
|
|
|
960 |
sub ToolsetLib
|
|
|
961 |
{
|
|
|
962 |
Debug2( "ToolsetLib(@_)" );
|
|
|
963 |
|
| 261 |
dpurdie |
964 |
foreach my $lib ( @_ )
|
| 227 |
dpurdie |
965 |
{
|
| 289 |
dpurdie |
966 |
UniquePush( \@TOOLSETLIBS, GenLibName( $lib ) );
|
| 227 |
dpurdie |
967 |
}
|
|
|
968 |
}
|
|
|
969 |
|
|
|
970 |
|
|
|
971 |
sub ToolsetProg
|
|
|
972 |
{
|
|
|
973 |
Debug2( "ToolsetProg(@_)" );
|
|
|
974 |
|
| 261 |
dpurdie |
975 |
foreach my $prog ( @_ )
|
| 227 |
dpurdie |
976 |
{
|
| 289 |
dpurdie |
977 |
UniquePush( \@TOOLSETPROGS, GenProgName( $prog ) );
|
| 227 |
dpurdie |
978 |
}
|
|
|
979 |
}
|
|
|
980 |
|
|
|
981 |
|
|
|
982 |
sub ToolsetRule
|
|
|
983 |
{
|
|
|
984 |
Debug2( "ToolsetRule(@_)" );
|
|
|
985 |
|
|
|
986 |
push( @TOOLSETRULES, @_ );
|
|
|
987 |
}
|
|
|
988 |
|
|
|
989 |
|
|
|
990 |
sub ToolsetRules
|
|
|
991 |
{
|
|
|
992 |
my( $script ) = @_;
|
|
|
993 |
my( $line );
|
|
|
994 |
|
|
|
995 |
Debug2( "ToolsetRules(@_)" );
|
|
|
996 |
|
|
|
997 |
$script = Exists( "$::GBE_CONFIG/TOOLSET", $script, "ToolsetRules" );
|
| 271 |
dpurdie |
998 |
push( @TOOLSETRULES, "# ToolsetRules from: $script" );
|
| 285 |
dpurdie |
999 |
open( my $fh, '<', $script ) || Error( "Opening $script" );
|
|
|
1000 |
while (<$fh>) {
|
| 227 |
dpurdie |
1001 |
$_ =~ s/\s*(\n|$)//; # kill trailing whitespace & newline
|
|
|
1002 |
push( @TOOLSETRULES, $_ );
|
|
|
1003 |
}
|
|
|
1004 |
push( @ScmDepends, "$script" ); # makefile dependencies
|
| 285 |
dpurdie |
1005 |
close( $fh );
|
| 227 |
dpurdie |
1006 |
}
|
|
|
1007 |
|
|
|
1008 |
|
|
|
1009 |
###############################################################################
|
|
|
1010 |
# User interface:
|
|
|
1011 |
#
|
|
|
1012 |
# AddFlags( 'platform [, ... ]', 'flags' [, 'flag' ... ] )
|
|
|
1013 |
# This subroutine takes the C and C++ compiler flags
|
|
|
1014 |
# specified adding them to a global list for later
|
|
|
1015 |
# inclusion in the built makefile.
|
|
|
1016 |
#
|
|
|
1017 |
# AddCFlags( 'platform [, ... ]', 'flags' [, 'flag' ... ] )
|
|
|
1018 |
# This subroutine takes the C compiler flags
|
|
|
1019 |
# specified adding them to a global list for later
|
|
|
1020 |
# inclusion in the built makefile.
|
|
|
1021 |
#
|
|
|
1022 |
# AddCXXFlags( 'platform [, ... ]', 'flags' [, 'flag' ... ] )
|
|
|
1023 |
# This subroutine takes the C++ compiler flags
|
|
|
1024 |
# specified adding them to a global list for later
|
|
|
1025 |
# inclusion in the built makefile.
|
|
|
1026 |
#
|
|
|
1027 |
# AddLintFlags( 'platform [, ... ]', 'flags' [, ... ] )
|
|
|
1028 |
# This subroutine takes the Lint flags specified
|
|
|
1029 |
# adding them to a global list for later inclusion
|
|
|
1030 |
# in the built makefile.
|
|
|
1031 |
#
|
|
|
1032 |
# AddASFlags( 'platform [, ... ]', 'flags' [, ... ] )
|
|
|
1033 |
# This subroutine takes the Assemler flags specified
|
|
|
1034 |
# adding them to a global list for later inclusion
|
|
|
1035 |
# in the built makefile.
|
|
|
1036 |
#
|
|
|
1037 |
# AddLDFlags( 'platform [, ... ]', 'flags' [, ... ] )
|
|
|
1038 |
# This subroutine takes the Linker flags specified
|
|
|
1039 |
# adding them to a global list for later inclusion
|
|
|
1040 |
# in the built makefile.
|
|
|
1041 |
#
|
|
|
1042 |
# AddDir
|
|
|
1043 |
# This subroutine takes the directories specified adding
|
|
|
1044 |
# them to a global include and source directory list for
|
|
|
1045 |
# later inclusion in the built makefile.
|
|
|
1046 |
#
|
|
|
1047 |
# AddIncDir( 'platform [, ... ]', 'dir' [, ... ] )
|
|
|
1048 |
# This subroutine takes the include file directories
|
|
|
1049 |
# specified adding them to a global list for later
|
|
|
1050 |
# inclusion in the built makefile.
|
|
|
1051 |
#
|
|
|
1052 |
# AddSrcDir( 'platform [, ... ]', 'dir' [, ... ] )
|
|
|
1053 |
# This subroutine takes the source file directories
|
|
|
1054 |
# specified adding them to a global list used to resolve
|
|
|
1055 |
# Src() definitions.
|
|
|
1056 |
#
|
|
|
1057 |
# AddLibDir( 'platform [, ... ]', 'dir' [, ... ] )
|
|
|
1058 |
# This subroutine takes the library directories
|
|
|
1059 |
# specified adding them to a global list for later
|
|
|
1060 |
# inclusion in the built makefile.
|
|
|
1061 |
#
|
|
|
1062 |
# AddSourceType( 'ext', '.c|.cc|.asm' )
|
|
|
1063 |
# This subroutine takes the extension(s) specified by the
|
|
|
1064 |
# programmer and adds them to a global list for later
|
|
|
1065 |
# inclusion in the built makefile. This list contains
|
|
|
1066 |
# the extensions to be recognised as 'C', 'C++' or
|
|
|
1067 |
# assembler file types.
|
|
|
1068 |
#
|
|
|
1069 |
# AddSourceFile( 'platform [, ... ]', 'file' [, ... ] )
|
|
|
1070 |
# This subroutine takes the non-standard source file(s)
|
|
|
1071 |
# and adds them add it to either C, C++ or assembler
|
|
|
1072 |
# sources and the object list.
|
|
|
1073 |
#
|
|
|
1074 |
# Init( 'platform [, ... ]', 'rule' )
|
|
|
1075 |
# Initialisation rule
|
|
|
1076 |
#
|
|
|
1077 |
# Generate( 'platform [, ... ]', 'file' [, ... ] )
|
|
|
1078 |
# This subroutine is used to add the list of given
|
|
|
1079 |
# source files to the generate sources list, and if
|
|
|
1080 |
# the generated source is of type C, C++ or assember
|
|
|
1081 |
# also adds it to either C, C++ or assembler sources and
|
|
|
1082 |
# the object lists.
|
|
|
1083 |
#
|
|
|
1084 |
# --c Treat as a C source file.
|
|
|
1085 |
# --cpp Treat as a C++ source file.
|
|
|
1086 |
# --asm Treat as a assembler source file.
|
|
|
1087 |
#
|
|
|
1088 |
# Rule( 'platform [, ... ]', definition )
|
|
|
1089 |
# This subroutine is used to add the non-standard make
|
|
|
1090 |
# rules required to build the system. eg. any rules
|
|
|
1091 |
# necessary to produce a .cc & .h file from a .x file.
|
|
|
1092 |
#
|
|
|
1093 |
# Src( 'platform [, ... ]', 'file' [, ... ], [ 'arg' [, ...]] )
|
|
|
1094 |
# This subroutine is used to add the list of given source
|
|
|
1095 |
# files to the sources list, and if the source is of type
|
|
|
1096 |
# C, C++ or assember also adds it to either C, C++ or
|
|
|
1097 |
# assembler sources and the object lists. The optional
|
|
|
1098 |
# list of arguments is assigned to all source files.
|
|
|
1099 |
#
|
|
|
1100 |
# --c Treat as a C source file.
|
|
|
1101 |
# --cpp Treat as a C++ source file.
|
|
|
1102 |
# --asm Treat as a assembler source file.
|
|
|
1103 |
# --Shared Shared, produces position-independent
|
|
|
1104 |
# code (on targets where required).
|
|
|
1105 |
#
|
|
|
1106 |
# Lib( 'platform [, ... ]', 'name', 'obj' [, ... ] [, '-arg' [, ... ]] )
|
|
|
1107 |
# This subroutine takes a library definition list and adds
|
|
|
1108 |
# the entries to the 3 libraries definition lists. 'name'
|
|
|
1109 |
# of the library to be created. List of the object files
|
|
|
1110 |
# 'obj' that make up this library. List of special
|
|
|
1111 |
# arguments 'arg' to pass to the librarian.
|
|
|
1112 |
#
|
|
|
1113 |
# MergeLibrary( 'platform [, ... ]', 'name', 'lib' [, ... ] )
|
|
|
1114 |
# This subroutine takes a library merge list and adds
|
|
|
1115 |
# the entries to the 2 merge libraries definition lists. 'name'
|
|
|
1116 |
# of the library to be created. List of the libraries to be merged
|
|
|
1117 |
#
|
|
|
1118 |
# LocalScript( 'platform [, ... ]', name, ['1'] )
|
|
|
1119 |
# Script( 'platform [, ... ]', name, ['1'] )
|
|
|
1120 |
# This subroutine takes a list that defines the name of
|
|
|
1121 |
# the script to be placed in the platform 'bin' directory,
|
|
|
1122 |
# and an optional second element that defines whether the
|
|
|
1123 |
# script should be made executable or not.
|
|
|
1124 |
#
|
|
|
1125 |
# Prog( 'platform [, ... ]', 'name', ['obj', ... ],
|
|
|
1126 |
# ['-llib', ... ], ['options'] )
|
|
|
1127 |
# This subroutine takes a list that defines which program
|
|
|
1128 |
# (binary) is to be made, what libraries and object it is
|
|
|
1129 |
# made from, and any special commands required to perform
|
|
|
1130 |
# the program creation.
|
|
|
1131 |
#
|
|
|
1132 |
# @PROGS Updated list of programs to create
|
|
|
1133 |
#
|
|
|
1134 |
# TestProg( 'platform [, ... ]', 'name', ['obj', ... ],
|
|
|
1135 |
# ['-llib', ... ], ['options'] )
|
|
|
1136 |
# This subroutine takes a list that defines which test program
|
|
|
1137 |
# (binary) is to be made, what libraries and object it is
|
|
|
1138 |
# made from, and any special commands required to perform
|
|
|
1139 |
# the program creation.
|
|
|
1140 |
#
|
|
|
1141 |
# @TESTPROGS Updated list of programs to create
|
|
|
1142 |
#
|
|
|
1143 |
# InstallHdr( 'platform [, ... ]', 'file' [, ...], ['-arg'] )
|
|
|
1144 |
# This subroutine takes the given list of files and adds them
|
|
|
1145 |
# to the install header files list. Files in this list will be
|
|
|
1146 |
# installed into the 'local header directory' area for public
|
|
|
1147 |
# consumption. This is generally API files for other modules
|
|
|
1148 |
# to use.
|
|
|
1149 |
#
|
|
|
1150 |
# --Strip Strip directory from source
|
|
|
1151 |
# --Full Install using full path
|
|
|
1152 |
# --Subdir=subdir Install within the specified sub-directory
|
|
|
1153 |
# --Prefix=subdir " " " " " "
|
|
|
1154 |
#
|
|
|
1155 |
# InstallLib( 'platform [, ... ]', 'file', ['subdir'] )
|
|
|
1156 |
# This subroutine takes the given list of files and adds them
|
|
|
1157 |
# to the install libraries files list. Files in this list will
|
|
|
1158 |
# be installed into the 'local library directory' area for
|
|
|
1159 |
# public consumption.
|
|
|
1160 |
#
|
|
|
1161 |
# InstallProg( 'platform [, ... ]', 'file', ['subdir'] ) )
|
|
|
1162 |
# This subroutine takes a list that defines the executable file
|
|
|
1163 |
# that is to be installed. The file in this list will be
|
|
|
1164 |
# installed into the 'local executable directory' specified for
|
|
|
1165 |
# public consumption.
|
|
|
1166 |
#
|
|
|
1167 |
###############################################################################
|
|
|
1168 |
|
|
|
1169 |
|
|
|
1170 |
sub Include # User include
|
|
|
1171 |
{
|
|
|
1172 |
my( $path, $name ) = @_;
|
|
|
1173 |
my( $file );
|
|
|
1174 |
|
|
|
1175 |
$file = Require( $path, $name, "Include" );
|
|
|
1176 |
push( @ScmDepends, "$file" );
|
|
|
1177 |
}
|
|
|
1178 |
|
|
|
1179 |
sub ForceCCompile
|
|
|
1180 |
{
|
|
|
1181 |
CompileOptions( $_[0], 'compile_as_c' ); # Backward compatability
|
|
|
1182 |
}
|
|
|
1183 |
|
|
|
1184 |
#-------------------------------------------------------------------------------
|
|
|
1185 |
# Create a data structure to define the global compiler options
|
|
|
1186 |
# The hash is keyed by compiler option
|
|
|
1187 |
# The value contains another hash.
|
|
|
1188 |
# The key is a makefile variable to set ( or remove )
|
|
|
1189 |
# The value is the value to assign to the makefile variable
|
|
|
1190 |
# If the value is 'undef' then the variable will be deleted
|
|
|
1191 |
#
|
|
|
1192 |
# Keys of the form key=value are also supported
|
|
|
1193 |
#
|
|
|
1194 |
# If the value is a CODE reference, then routine will be called with the key
|
|
|
1195 |
# and value as arguments. The return value will be utilised.
|
|
|
1196 |
#
|
|
|
1197 |
our %ScmCompilerOptions =
|
|
|
1198 |
(
|
|
|
1199 |
'strict_ansi' => { 'USE_STRICT_ANSI' => '1' },
|
|
|
1200 |
'no_strict_ansi' => { 'USE_STRICT_ANSI' => '' }, # Default
|
|
|
1201 |
|
|
|
1202 |
'profile' => { 'USE_PROFILE' => '1' },
|
|
|
1203 |
'no_profile' => { 'USE_PROFILE' => '' }, # Default
|
|
|
1204 |
|
|
|
1205 |
|
|
|
1206 |
'prod_no_optimise' => { 'PROD_USE_OPTIMISE' => '' },
|
|
|
1207 |
'prod_no_debuginfo' => { 'PROD_USE_DEBUGINFO' => '' }, # Default
|
|
|
1208 |
'prod_optimise' => { 'PROD_USE_OPTIMISE' => '1' }, # Default
|
|
|
1209 |
'prod_debuginfo' => { 'PROD_USE_DEBUGINFO' => '1' },
|
|
|
1210 |
|
|
|
1211 |
'debug_no_optimise' => { 'DEBUG_USE_OPTIMISE' => '' }, # Default
|
|
|
1212 |
'debug_no_debuginfo' => { 'DEBUG_USE_DEBUGINFO' => '' },
|
|
|
1213 |
'debug_optimise' => { 'DEBUG_USE_OPTIMISE' => '1' },
|
|
|
1214 |
'debug_debuginfo' => { 'DEBUG_USE_DEBUGINFO' => '1' }, # Default
|
|
|
1215 |
|
|
|
1216 |
'compile_as_cpp' => { 'FORCE_CC_COMPILE' => '1',
|
|
|
1217 |
'FORCE_C_COMPILE' => undef },
|
|
|
1218 |
'compile_as_c' => { 'FORCE_C_COMPILE' => '1',
|
|
|
1219 |
'FORCE_CC_COMPILE' => undef },
|
| 267 |
dpurdie |
1220 |
|
|
|
1221 |
'no_define_source_file' => { 'DISABLE__SOURCE__' => '1' },
|
|
|
1222 |
'define_source_file' => { 'DISABLE__SOURCE__' => undef }, # Default
|
|
|
1223 |
|
| 227 |
dpurdie |
1224 |
);
|
|
|
1225 |
|
|
|
1226 |
#
|
|
|
1227 |
# The toolset can extend the options by setting the following hash
|
|
|
1228 |
#
|
|
|
1229 |
our %ScmToolsetCompilerOptions = ();
|
|
|
1230 |
|
|
|
1231 |
#
|
|
|
1232 |
# Define default compiler options
|
|
|
1233 |
# These are makefile variables that will be assigned
|
|
|
1234 |
#
|
|
|
1235 |
our %ScmCompilerOpts =
|
|
|
1236 |
(
|
|
|
1237 |
'USE_STRICT_ANSI' => '',
|
|
|
1238 |
'USE_PROFILE' => '',
|
|
|
1239 |
'PROD_USE_DEBUGINFO' => '',
|
|
|
1240 |
'PROD_USE_OPTIMISE' => '1',
|
|
|
1241 |
'DEBUG_USE_OPTIMISE' => '',
|
|
|
1242 |
'DEBUG_USE_DEBUGINFO' => '1',
|
|
|
1243 |
);
|
|
|
1244 |
|
|
|
1245 |
|
|
|
1246 |
sub CompileOptions
|
|
|
1247 |
{
|
|
|
1248 |
my( $platforms, @elements ) = @_;
|
|
|
1249 |
return if ( ! ActivePlatform($platforms) );
|
|
|
1250 |
|
|
|
1251 |
for (@elements)
|
|
|
1252 |
{
|
|
|
1253 |
my $oref;
|
|
|
1254 |
|
|
|
1255 |
#
|
|
|
1256 |
# The toolset option may be a text string or a definition
|
|
|
1257 |
# Name - A text string
|
|
|
1258 |
# Name=Value - A value
|
|
|
1259 |
#
|
|
|
1260 |
my $value;
|
|
|
1261 |
my $key = $_;
|
|
|
1262 |
if ( $key =~ m~(.*=)(.*)~ )
|
|
|
1263 |
{
|
|
|
1264 |
$key = $1;
|
|
|
1265 |
$value = $2 || '';
|
|
|
1266 |
}
|
| 247 |
dpurdie |
1267 |
$key = lc( $key );
|
| 227 |
dpurdie |
1268 |
|
|
|
1269 |
#
|
|
|
1270 |
# Examine the global flags
|
|
|
1271 |
# Then the toolset extensions
|
|
|
1272 |
# Then just drop it
|
|
|
1273 |
#
|
|
|
1274 |
unless ( $oref = ($ScmCompilerOptions{$key} || $ScmToolsetCompilerOptions{$key}) )
|
|
|
1275 |
{
|
|
|
1276 |
Warning ("Compile Option ignored: $_");
|
|
|
1277 |
next;
|
|
|
1278 |
}
|
|
|
1279 |
|
|
|
1280 |
#
|
|
|
1281 |
# Parse the definition and adjust makefile variables as required
|
|
|
1282 |
# Set the value of a make variable or remove the definition
|
|
|
1283 |
#
|
|
|
1284 |
# If the user value is a code reference, then call the code
|
|
|
1285 |
# and use the returned value as the value.
|
|
|
1286 |
#
|
|
|
1287 |
while ( (my($ukey, $uvalue)) = each %{$oref} )
|
|
|
1288 |
{
|
|
|
1289 |
if ( defined( $uvalue) )
|
|
|
1290 |
{
|
|
|
1291 |
if ( ref($uvalue) eq "CODE" )
|
|
|
1292 |
{
|
| 255 |
dpurdie |
1293 |
$uvalue = &$uvalue( $key, $value, $ukey);
|
| 227 |
dpurdie |
1294 |
unless ( defined $uvalue )
|
|
|
1295 |
{
|
|
|
1296 |
Warning ("Compile Option ignored: $_");
|
|
|
1297 |
next;
|
|
|
1298 |
}
|
|
|
1299 |
}
|
| 247 |
dpurdie |
1300 |
elsif ( defined $value )
|
|
|
1301 |
{
|
|
|
1302 |
$uvalue = $value;
|
|
|
1303 |
}
|
| 227 |
dpurdie |
1304 |
|
|
|
1305 |
$ScmCompilerOpts{$ukey} = $uvalue;
|
|
|
1306 |
}
|
|
|
1307 |
else
|
|
|
1308 |
{
|
|
|
1309 |
delete $ScmCompilerOpts{$ukey};
|
|
|
1310 |
}
|
|
|
1311 |
}
|
|
|
1312 |
}
|
|
|
1313 |
}
|
|
|
1314 |
|
|
|
1315 |
#-------------------------------------------------------------------------------
|
|
|
1316 |
# Function : AddFlags
|
|
|
1317 |
# AddCFlags
|
|
|
1318 |
# AddCXXFlags
|
|
|
1319 |
# AddASFlags
|
|
|
1320 |
# AddLDFlags
|
|
|
1321 |
# AddLintFlags
|
|
|
1322 |
#
|
|
|
1323 |
# Description : Add target specfic flags to the C compiler
|
|
|
1324 |
# This SHOULD only be used to add Defines to the compiler
|
|
|
1325 |
# but it can be absued.
|
|
|
1326 |
#
|
|
|
1327 |
# Inputs : $platform - Platforms for which the directive is active
|
|
|
1328 |
# ... - list of flags to add
|
|
|
1329 |
#
|
|
|
1330 |
# Embedded options include:
|
|
|
1331 |
# --Debug - Following options are added to the debug build
|
|
|
1332 |
# --Prod - Following options are added to the production build
|
|
|
1333 |
#
|
|
|
1334 |
# Returns : Nothing
|
|
|
1335 |
#
|
|
|
1336 |
|
|
|
1337 |
sub AddFlags
|
|
|
1338 |
{
|
|
|
1339 |
my( $platforms, @elements ) = @_;
|
|
|
1340 |
|
|
|
1341 |
AddCFlags( $platforms, @elements );
|
|
|
1342 |
AddCXXFlags( $platforms, @elements );
|
|
|
1343 |
}
|
|
|
1344 |
|
|
|
1345 |
sub AddCFlags
|
|
|
1346 |
{
|
|
|
1347 |
my( $platforms, @elements ) = @_;
|
|
|
1348 |
|
|
|
1349 |
Debug2( "AddCFlags($platforms, @elements)" );
|
|
|
1350 |
return if ( ! ActivePlatform($platforms) );
|
|
|
1351 |
|
|
|
1352 |
WarnIfNastyFlag( @elements );
|
|
|
1353 |
__AddFlags( "CFLAGS", \@elements,
|
|
|
1354 |
\@CFLAGS, \@CLINTFLAGS,
|
|
|
1355 |
\@CFLAGS_DEBUG, \@CLINTFLAGS_DEBUG,
|
|
|
1356 |
\@CFLAGS_PROD, \@CLINTFLAGS_PROD );
|
|
|
1357 |
}
|
|
|
1358 |
|
|
|
1359 |
sub AddCXXFlags
|
|
|
1360 |
{
|
|
|
1361 |
my( $platforms, @elements ) = @_;
|
|
|
1362 |
|
|
|
1363 |
Debug2( "AddCXXFlags($platforms, @elements)" );
|
|
|
1364 |
return if ( ! ActivePlatform($platforms) );
|
|
|
1365 |
|
|
|
1366 |
WarnIfNastyFlag( @elements );
|
|
|
1367 |
__AddFlags( "CXXFLAGS", \@elements,
|
|
|
1368 |
\@CXXFLAGS, \@CXXLINTFLAGS,
|
|
|
1369 |
\@CXXFLAGS_DEBUG, \@CXXLINTFLAGS_DEBUG,
|
|
|
1370 |
\@CXXFLAGS_PROD, \@CXXLINTFLAGS_PROD );
|
|
|
1371 |
}
|
|
|
1372 |
|
|
|
1373 |
sub AddASFlags
|
|
|
1374 |
{
|
|
|
1375 |
my( $platforms, @elements ) = @_;
|
|
|
1376 |
|
|
|
1377 |
Debug2( "AddASFlags($platforms, @elements)" );
|
|
|
1378 |
|
|
|
1379 |
return if ( ! ActivePlatform($platforms) );
|
|
|
1380 |
|
| 267 |
dpurdie |
1381 |
__AddFlags( "ASFLAGS", \@elements,
|
|
|
1382 |
\@ASFLAGS, undef,
|
|
|
1383 |
\@ASFLAGS_DEBUG, undef,
|
|
|
1384 |
\@ASFLAGS_PROD, undef );
|
| 227 |
dpurdie |
1385 |
}
|
|
|
1386 |
|
|
|
1387 |
sub AddLDFlags
|
|
|
1388 |
{
|
|
|
1389 |
my( $platforms, @elements ) = @_;
|
|
|
1390 |
|
|
|
1391 |
Debug2( "AddLDFlags($platforms, @elements)" );
|
|
|
1392 |
|
|
|
1393 |
return if ( ! ActivePlatform($platforms) );
|
|
|
1394 |
|
|
|
1395 |
foreach ( @elements )
|
|
|
1396 |
{
|
| 267 |
dpurdie |
1397 |
next if ( m~^--(Debug|Prod)~ );
|
| 227 |
dpurdie |
1398 |
Warning("Use of linker flag discouraged (will be used): $_");
|
|
|
1399 |
}
|
| 267 |
dpurdie |
1400 |
__AddFlags( "LDFLAGS", \@elements,
|
|
|
1401 |
\@LDFLAGS, undef,
|
|
|
1402 |
\@LDFLAGS_DEBUG, undef,
|
|
|
1403 |
\@LDFLAGS_PROD, undef );
|
| 227 |
dpurdie |
1404 |
|
|
|
1405 |
}
|
|
|
1406 |
|
|
|
1407 |
sub AddLintFlags
|
|
|
1408 |
{
|
|
|
1409 |
my( $platforms, @elements ) = @_;
|
|
|
1410 |
|
|
|
1411 |
return if ( ! ActivePlatform($platforms) );
|
|
|
1412 |
|
|
|
1413 |
Debug2( "AddLintFlags($platforms, @elements)" );
|
|
|
1414 |
|
|
|
1415 |
__AddFlags( "LINTFLAG", \@elements,
|
|
|
1416 |
\@CLINTFLAGS, \@CXXLINTFLAGS,
|
|
|
1417 |
\@CLINTFLAGS_DEBUG, \@CXXLINTFLAGS_DEBUG,
|
|
|
1418 |
\@CLINTFLAGS_PROD, \@CXXLINTFLAGS_PROD );
|
|
|
1419 |
}
|
|
|
1420 |
|
|
|
1421 |
|
|
|
1422 |
#-------------------------------------------------------------------------------
|
|
|
1423 |
# Function : __AddFlags
|
|
|
1424 |
#
|
|
|
1425 |
# Description : Generic flag adding to lists routine
|
|
|
1426 |
# Internal use only
|
|
|
1427 |
#
|
|
|
1428 |
# Supports --Debug and --Prod options
|
|
|
1429 |
# if the appropriate list is present.
|
|
|
1430 |
#
|
|
|
1431 |
# Inputs : Lots
|
|
|
1432 |
# References to compiler and lint flags for
|
|
|
1433 |
# common, debug and product builds.
|
|
|
1434 |
#
|
|
|
1435 |
# Not all the lists are needed.
|
|
|
1436 |
#
|
|
|
1437 |
# Returns : Nothing
|
|
|
1438 |
#
|
|
|
1439 |
sub __AddFlags
|
|
|
1440 |
{
|
|
|
1441 |
my ($textname, $eref,
|
|
|
1442 |
$f_all, $flint_all,
|
|
|
1443 |
$f_debug, $flint_debug,
|
|
|
1444 |
$f_prod, $flint_prod ) = @_;
|
|
|
1445 |
|
|
|
1446 |
#
|
|
|
1447 |
# Start added flags to the ALL lists
|
|
|
1448 |
#
|
|
|
1449 |
my $list = $f_all;
|
|
|
1450 |
my $lintlist = $flint_all;
|
|
|
1451 |
my $nowarn = 0;
|
|
|
1452 |
|
|
|
1453 |
#
|
|
|
1454 |
# Process flags up front
|
|
|
1455 |
#
|
|
|
1456 |
$nowarn = 1 if ( grep (/^--NoWarn$/, @$eref) );
|
|
|
1457 |
|
|
|
1458 |
#
|
|
|
1459 |
# Process all the user arguments
|
|
|
1460 |
#
|
|
|
1461 |
ADD:
|
|
|
1462 |
foreach my $element ( @$eref )
|
|
|
1463 |
{
|
|
|
1464 |
#
|
|
|
1465 |
# Skip flags
|
|
|
1466 |
#
|
|
|
1467 |
if ( $element eq '--NoWarn' )
|
|
|
1468 |
{
|
|
|
1469 |
next;
|
|
|
1470 |
}
|
|
|
1471 |
|
|
|
1472 |
#
|
|
|
1473 |
# Detect --Debug and --Prod options and swap
|
|
|
1474 |
# lists accordingly.
|
|
|
1475 |
#
|
|
|
1476 |
if ( $element eq '--Debug' )
|
|
|
1477 |
{
|
|
|
1478 |
Error ("--Debug not supported for $textname") unless ( $f_debug );
|
|
|
1479 |
$list = $f_debug;
|
|
|
1480 |
$lintlist = $flint_debug;
|
|
|
1481 |
next;
|
|
|
1482 |
}
|
|
|
1483 |
|
|
|
1484 |
if ( $element eq '--Prod' )
|
|
|
1485 |
{
|
|
|
1486 |
Error ("--Prod not supported for $textname") unless ( $f_prod );
|
|
|
1487 |
$list = $f_prod;
|
|
|
1488 |
$lintlist = $flint_prod;
|
|
|
1489 |
next;
|
|
|
1490 |
}
|
|
|
1491 |
|
|
|
1492 |
#
|
|
|
1493 |
# Scan all the lists for a possible duplicates
|
|
|
1494 |
#
|
|
|
1495 |
foreach my $temp ( @$f_all, @$f_debug, @$f_prod ) {
|
|
|
1496 |
if ($temp eq $element) {
|
|
|
1497 |
Warning( "Duplicate $textname ignored '$element'") unless $nowarn;
|
|
|
1498 |
next ADD;
|
|
|
1499 |
}
|
|
|
1500 |
}
|
|
|
1501 |
|
|
|
1502 |
#
|
|
|
1503 |
# Add the flag to the compiler and lint lists
|
|
|
1504 |
#
|
|
|
1505 |
push( @$list, $element ) if $list;
|
|
|
1506 |
push( @$lintlist, $element ) if $lintlist;
|
|
|
1507 |
}
|
|
|
1508 |
}
|
|
|
1509 |
|
|
|
1510 |
sub WarnIfNastyFlag
|
|
|
1511 |
{
|
|
|
1512 |
foreach ( @_ )
|
|
|
1513 |
{
|
|
|
1514 |
Warning("Use of compiler flags discouraged (will be used): $_")
|
|
|
1515 |
unless ( m/^-[DU]/ || m/^--Debug/ || m/^--Prod/ || /^--NoWarn/ );
|
|
|
1516 |
}
|
|
|
1517 |
}
|
|
|
1518 |
|
|
|
1519 |
|
|
|
1520 |
sub AddDir
|
|
|
1521 |
{
|
|
|
1522 |
AddIncDir( @_);
|
|
|
1523 |
AddSrcDir( @_ );
|
|
|
1524 |
}
|
|
|
1525 |
|
|
|
1526 |
|
|
|
1527 |
sub AddIncDir
|
|
|
1528 |
{
|
|
|
1529 |
_AddDir( 'AddIncDir', 'INCDIR', \@INCDIRS, \@S_INCDIRS, \@G_INCDIRS, \@L_INCDIRS, @_ );
|
|
|
1530 |
}
|
|
|
1531 |
|
|
|
1532 |
sub AddSrcDir
|
|
|
1533 |
{
|
|
|
1534 |
_AddDir( 'AddSrcDir', 'SRCDIR', \@SRCDIRS, \@S_SRCDIRS, \@G_SRCDIRS, \@L_SRCDIRS, @_ );
|
|
|
1535 |
}
|
|
|
1536 |
|
|
|
1537 |
sub AddLibDir
|
|
|
1538 |
{
|
|
|
1539 |
_AddDir( 'AddLibDir', 'LIBDIR', \@LIBDIRS, \@S_LIBDIRS, \@G_LIBDIRS, \@L_LIBDIRS, @_ );
|
|
|
1540 |
}
|
|
|
1541 |
|
|
|
1542 |
#-------------------------------------------------------------------------------
|
|
|
1543 |
# Function : _AddDir
|
|
|
1544 |
#
|
|
|
1545 |
# Description : Internal routine to add a directory to list of directories
|
|
|
1546 |
# Common code to simplify implementation of other directives
|
|
|
1547 |
#
|
|
|
1548 |
# Inputs : $name - Name of function
|
|
|
1549 |
# $udir - User name of dir list
|
|
|
1550 |
# $dirref - Reference to directory array
|
|
|
1551 |
# $s_dirref - Reference to system directory array
|
|
|
1552 |
# $g_dirref - Reference to global directory array
|
|
|
1553 |
# $l_dirref - Reference to local directory array
|
|
|
1554 |
# @args - User arguments
|
|
|
1555 |
# - platforms
|
|
|
1556 |
# - Directories and --Options
|
|
|
1557 |
#
|
|
|
1558 |
sub _AddDir
|
|
|
1559 |
{
|
|
|
1560 |
my( $name, $udir, $dirref, $s_dirref, $g_dirref, $l_dirref, $platforms, @elements ) = @_;
|
|
|
1561 |
|
|
|
1562 |
Debug ( "$name($platforms, @elements)" );
|
|
|
1563 |
Error ( "$name: Insufficient arguments") unless ( @elements );
|
|
|
1564 |
return if ( ! ActivePlatform($platforms) );
|
|
|
1565 |
|
|
|
1566 |
#
|
|
|
1567 |
# Cleanup user parameters
|
|
|
1568 |
#
|
|
|
1569 |
foreach ( @elements )
|
|
|
1570 |
{
|
|
|
1571 |
s/^\s+//; # Remove leading space
|
|
|
1572 |
s/\s+$//; # Remove trailing spaces
|
|
|
1573 |
s~/$~~; # Remove trailing /
|
|
|
1574 |
s~//~/~g; # Remove multiple /
|
|
|
1575 |
}
|
|
|
1576 |
|
|
|
1577 |
#.. Collect arguments
|
|
|
1578 |
my $tlist_ref = $ScmGlobal ? $g_dirref : $l_dirref; # "current" scope ....
|
|
|
1579 |
my $nowarn = 0;
|
|
|
1580 |
my $nodepend = 0;
|
|
|
1581 |
my @dirs;
|
|
|
1582 |
|
|
|
1583 |
foreach ( @elements )
|
|
|
1584 |
{
|
|
|
1585 |
if ( ! /^--/ ) { # Collect directories
|
|
|
1586 |
push @dirs, $_;
|
|
|
1587 |
|
|
|
1588 |
} elsif (/^--Local$/) { # "local" scope ....
|
|
|
1589 |
$tlist_ref = $l_dirref;
|
|
|
1590 |
|
|
|
1591 |
} elsif (/^--Global$/) { # "global" scope ...
|
|
|
1592 |
$tlist_ref = $g_dirref;
|
|
|
1593 |
|
|
|
1594 |
} elsif (/^--System$/) { # "system" scope ...
|
|
|
1595 |
$tlist_ref = $s_dirref;
|
|
|
1596 |
|
|
|
1597 |
} elsif (/^--NoDepend$/) { # Split from dependency list
|
|
|
1598 |
if ( $udir eq 'INCDIR' ) { # AddIncDir only
|
|
|
1599 |
$nodepend = 1;
|
|
|
1600 |
}
|
|
|
1601 |
|
|
|
1602 |
} elsif (/^--NoWarn$/) { # Disable warnings
|
|
|
1603 |
$nowarn = 1;
|
|
|
1604 |
|
|
|
1605 |
} elsif (/^--(.*)/) {
|
|
|
1606 |
Message( "$name: unknown option $_ -- ignored\n" );
|
|
|
1607 |
|
|
|
1608 |
}
|
|
|
1609 |
}
|
|
|
1610 |
|
|
|
1611 |
Error ( "$name: No directory specified: ($platforms, @elements)" )
|
|
|
1612 |
unless ( @dirs );
|
|
|
1613 |
|
|
|
1614 |
|
|
|
1615 |
#.. Push source path(s)
|
|
|
1616 |
foreach ( @dirs )
|
|
|
1617 |
{
|
|
|
1618 |
#
|
|
|
1619 |
# Add to complete list of directories
|
|
|
1620 |
# Warn on duplicates
|
|
|
1621 |
#
|
|
|
1622 |
unless ( UniquePush( $dirref, $_) )
|
|
|
1623 |
{
|
|
|
1624 |
Warning( "Duplicate $udir ignored '$_'" )
|
|
|
1625 |
unless ( $nowarn );
|
|
|
1626 |
next;
|
|
|
1627 |
}
|
|
|
1628 |
|
|
|
1629 |
#
|
|
|
1630 |
# Check that the directory actually exists
|
|
|
1631 |
# If the path contains a $(XXXXX) then it can't be checked
|
|
|
1632 |
#
|
|
|
1633 |
if ( index( $_, '$' ) == -1 )
|
|
|
1634 |
{
|
|
|
1635 |
Warning( "$name. Directory not found: $_",
|
|
|
1636 |
"Current directory : $::Cwd",
|
|
|
1637 |
"Cannot resolved Directory : " . AbsPath($_),
|
|
|
1638 |
)
|
|
|
1639 |
unless ( $nowarn || -d $_ );
|
|
|
1640 |
}
|
|
|
1641 |
|
|
|
1642 |
#
|
|
|
1643 |
# Add to suitable list
|
|
|
1644 |
#
|
|
|
1645 |
push @{$tlist_ref}, $_;
|
|
|
1646 |
|
|
|
1647 |
#
|
|
|
1648 |
# Add to the no dependancy list (ie generated depend file)
|
|
|
1649 |
# Only used by AddIncDir, accepted by AddSrcDir
|
|
|
1650 |
#
|
|
|
1651 |
push( @NODEPDIRS, $_ )
|
|
|
1652 |
if ($nodepend);
|
|
|
1653 |
}
|
|
|
1654 |
}
|
|
|
1655 |
|
|
|
1656 |
|
|
|
1657 |
sub AddProg
|
|
|
1658 |
{
|
|
|
1659 |
my( $platforms, @progs ) = @_;
|
|
|
1660 |
|
|
|
1661 |
Debug2( "AddProg($platforms, @progs)" );
|
|
|
1662 |
|
|
|
1663 |
return if ( ! ActivePlatform($platforms) );
|
|
|
1664 |
|
| 285 |
dpurdie |
1665 |
foreach my $prog (@progs)
|
| 227 |
dpurdie |
1666 |
{
|
| 289 |
dpurdie |
1667 |
my $pProg = $PROGS->Get($prog);
|
| 227 |
dpurdie |
1668 |
Warning( "Duplicate prog ignored '$prog'" )
|
| 289 |
dpurdie |
1669 |
if ( $pProg );
|
|
|
1670 |
$pProg = $PROGS->NewAdd($prog)
|
| 227 |
dpurdie |
1671 |
}
|
|
|
1672 |
}
|
|
|
1673 |
|
|
|
1674 |
|
|
|
1675 |
sub AddSourceType
|
|
|
1676 |
{
|
|
|
1677 |
my( $ext, $type ) = @_;
|
|
|
1678 |
|
|
|
1679 |
Debug2( "AddSourceType(@_)" );
|
|
|
1680 |
|
|
|
1681 |
#
|
|
|
1682 |
# Default Source Type (C)
|
|
|
1683 |
#
|
|
|
1684 |
$type = ".c" unless ( $type );
|
|
|
1685 |
|
|
|
1686 |
Error ("Source type '$ext' not allowed")
|
|
|
1687 |
if ( $ext !~ /^\.\w+$/ );
|
|
|
1688 |
|
|
|
1689 |
$type = lc($type)
|
|
|
1690 |
if ( $::ScmHost ne "Unix" );
|
|
|
1691 |
$ScmSourceTypes{ $ext } = $type;
|
|
|
1692 |
}
|
|
|
1693 |
|
|
|
1694 |
|
|
|
1695 |
sub AddSourceFile
|
|
|
1696 |
{
|
|
|
1697 |
my( $platforms, @elements ) = @_;
|
|
|
1698 |
|
|
|
1699 |
Debug2( "AddSourceFile($platforms, @elements)" );
|
|
|
1700 |
return if ( ! ActivePlatform($platforms) );
|
|
|
1701 |
|
| 285 |
dpurdie |
1702 |
foreach my $path ( @elements )
|
| 227 |
dpurdie |
1703 |
{
|
|
|
1704 |
__AddSourceFile( 1, $path );
|
|
|
1705 |
}
|
|
|
1706 |
}
|
|
|
1707 |
|
|
|
1708 |
|
|
|
1709 |
#-------------------------------------------------------------------------------
|
|
|
1710 |
# Function : __AddSourceFile
|
|
|
1711 |
#
|
|
|
1712 |
# Description : Internal function
|
|
|
1713 |
# Add a source file to internal lists
|
|
|
1714 |
#
|
|
|
1715 |
# Assumes that the current platform is ACTIVE
|
|
|
1716 |
#
|
|
|
1717 |
# Inputs : push 0: Don't push onto OBJS (non-shared objfiles)
|
|
|
1718 |
# path Filename.extension
|
|
|
1719 |
# obj object file name (optional)
|
|
|
1720 |
# type Type of file. "" -> auto detect
|
|
|
1721 |
#
|
|
|
1722 |
# Returns : True - File is a 'known' source file
|
|
|
1723 |
# False - File is not a 'known' source file
|
|
|
1724 |
#
|
|
|
1725 |
sub __AddSourceFile
|
|
|
1726 |
{
|
|
|
1727 |
my( $push, $path, $obj, $type ) = @_;
|
| 271 |
dpurdie |
1728 |
my( $filename, $ext, $srcfile, $is_obj, $ext_type, $result );
|
| 227 |
dpurdie |
1729 |
|
| 271 |
dpurdie |
1730 |
$filename = StripDir($path); # file name
|
| 227 |
dpurdie |
1731 |
|
|
|
1732 |
$ext = StripFile($path); # extension
|
|
|
1733 |
$ext = lc($ext)
|
|
|
1734 |
if ( $::ScmHost ne "Unix" );
|
|
|
1735 |
|
| 271 |
dpurdie |
1736 |
if (! ($srcfile = $SRCS{$filename})) {
|
| 227 |
dpurdie |
1737 |
$srcfile = $path; # generated
|
|
|
1738 |
}
|
|
|
1739 |
|
| 271 |
dpurdie |
1740 |
$obj = StripExt( $filename ) # Base name of object file
|
| 227 |
dpurdie |
1741 |
if ( ! defined($obj) || $obj eq "" );
|
|
|
1742 |
|
|
|
1743 |
$type = "" # optional type
|
|
|
1744 |
if ( ! defined( $type ) );
|
|
|
1745 |
|
|
|
1746 |
#
|
|
|
1747 |
# Push file onto a suitable source file list
|
|
|
1748 |
#
|
|
|
1749 |
$result = 0;
|
|
|
1750 |
$ext_type = ""; # map extension
|
|
|
1751 |
$ext_type = $ScmSourceTypes{ $ext }
|
|
|
1752 |
if ( exists( $ScmSourceTypes{ $ext } ) );
|
|
|
1753 |
$result = 1 if ( $ext_type );
|
|
|
1754 |
|
|
|
1755 |
if ( $type eq "" && defined $::ScmToolsetProgSource{$ext} )
|
|
|
1756 |
{
|
|
|
1757 |
Debug( "SourceFile: $path is ToolsetProgSource -> $srcfile" );
|
|
|
1758 |
push( @CSRCS, $srcfile );
|
|
|
1759 |
$result = 1;
|
|
|
1760 |
}
|
|
|
1761 |
elsif ( ($type eq "" && $ext_type eq ".h") || ($type eq ".h") )
|
|
|
1762 |
{
|
|
|
1763 |
Debug( "SourceFile: $path is .h -> $srcfile" );
|
|
|
1764 |
push( @CHDRS, $srcfile );
|
|
|
1765 |
}
|
|
|
1766 |
elsif ( ($type eq "" && $ext_type eq ".inc") || ($type eq ".inc") )
|
|
|
1767 |
{
|
|
|
1768 |
Debug( "SourceFile: $path is .inc -> $srcfile" );
|
|
|
1769 |
push( @ASHDRS, $srcfile );
|
|
|
1770 |
}
|
|
|
1771 |
elsif ( ($type eq "" && $ext_type eq ".c") || ($type eq ".c") )
|
|
|
1772 |
{
|
|
|
1773 |
Debug( "SourceFile: $path is .c -> $srcfile=$obj" );
|
|
|
1774 |
push( @CSRCS, $srcfile );
|
|
|
1775 |
$is_obj = 1;
|
|
|
1776 |
}
|
|
|
1777 |
elsif ( ($type eq "" && $ext_type eq ".cc") || ($type eq ".cc") )
|
|
|
1778 |
{
|
|
|
1779 |
Debug( "SourceFile: $path is .cc -> $srcfile=$obj" );
|
|
|
1780 |
push( @CXXSRCS, $srcfile );
|
|
|
1781 |
$is_obj = 1;
|
|
|
1782 |
}
|
|
|
1783 |
elsif ( ($type eq "" && $ext_type eq ".asm") || ($type eq ".asm") )
|
|
|
1784 |
{
|
|
|
1785 |
Debug( "SourceFile: $path is .asm -> $srcfile=$obj" );
|
|
|
1786 |
push( @ASSRCS, $srcfile );
|
|
|
1787 |
$is_obj = 1;
|
|
|
1788 |
}
|
|
|
1789 |
elsif ( $ext_type eq "--Ignore" )
|
|
|
1790 |
{ # ignored ...
|
|
|
1791 |
# .x "rpcgen" source files
|
|
|
1792 |
# .ini Configuration
|
|
|
1793 |
# .sh Shell script
|
|
|
1794 |
}
|
|
|
1795 |
else
|
|
|
1796 |
{
|
|
|
1797 |
Debug( "SourceFile: $path is unknown file type" );
|
|
|
1798 |
|
|
|
1799 |
#
|
|
|
1800 |
# Insert source files with unknown extensions onto lists
|
|
|
1801 |
# of there own type
|
|
|
1802 |
#
|
|
|
1803 |
if ( $ext )
|
|
|
1804 |
{
|
|
|
1805 |
(my $varname = uc ( $ext . 'SRCS')) =~ s~\.~~g;
|
|
|
1806 |
no strict 'refs';
|
|
|
1807 |
push @$varname, $srcfile;
|
|
|
1808 |
use strict 'refs';
|
|
|
1809 |
}
|
|
|
1810 |
}
|
|
|
1811 |
|
|
|
1812 |
#
|
| 271 |
dpurdie |
1813 |
# See if there is a hook function for this type of source file
|
|
|
1814 |
# Invoke user function to perform additional processing on the file
|
|
|
1815 |
#
|
|
|
1816 |
if ( %MF_RegisterSrcHooks )
|
|
|
1817 |
{
|
|
|
1818 |
my @listeners;
|
|
|
1819 |
push @listeners, @{$MF_RegisterSrcHooks{$ext}} if ( exists $MF_RegisterSrcHooks{$ext} );
|
|
|
1820 |
push @listeners, @{$MF_RegisterSrcHooks{'*'}} if ( exists $MF_RegisterSrcHooks{'*'} );
|
|
|
1821 |
while ( @listeners )
|
|
|
1822 |
{
|
|
|
1823 |
Debug( "RegisterSrcHook: Invoke SrcHook function" );
|
|
|
1824 |
my ($fname, @args) = @{shift @listeners};
|
|
|
1825 |
&$fname ( $srcfile ,$filename, $obj, $ext ,@args );
|
|
|
1826 |
}
|
|
|
1827 |
}
|
|
|
1828 |
|
|
|
1829 |
#
|
| 227 |
dpurdie |
1830 |
# Object files are saved in
|
|
|
1831 |
# OBJSOURCE - Generate a recipe to create the object
|
|
|
1832 |
# OBJS - A list of ALL non-shared object files
|
|
|
1833 |
#
|
|
|
1834 |
if ( $is_obj && $::o )
|
|
|
1835 |
{
|
|
|
1836 |
$OBJSOURCE{ "$obj" } = $srcfile;
|
|
|
1837 |
push( @OBJS, $obj )
|
|
|
1838 |
if ($push);
|
|
|
1839 |
}
|
|
|
1840 |
|
|
|
1841 |
#
|
|
|
1842 |
# Indicate to the user that the file is a 'known' source file
|
|
|
1843 |
# This implies that the file is required early in the build process
|
|
|
1844 |
# and may need to be generated early.
|
|
|
1845 |
#
|
|
|
1846 |
return $result;
|
|
|
1847 |
}
|
|
|
1848 |
|
|
|
1849 |
#-------------------------------------------------------------------------------
|
|
|
1850 |
# Function : SetValue
|
|
|
1851 |
#
|
|
|
1852 |
# Description : Defines a variable that can be used within the makefile.pl
|
|
|
1853 |
# Use sparingly
|
|
|
1854 |
# An attempt to formalise a mechanism that is used anyway, but
|
|
|
1855 |
# with correct platform detection
|
|
|
1856 |
#
|
|
|
1857 |
# Inputs : $platform - Platform selector
|
|
|
1858 |
# $name - Name to set
|
|
|
1859 |
# $value - Value to set
|
|
|
1860 |
# options - Options
|
|
|
1861 |
# --NoWarn
|
|
|
1862 |
# --Project=xxxx[,xxxx]+
|
|
|
1863 |
# --
|
|
|
1864 |
#
|
|
|
1865 |
sub SetValue
|
|
|
1866 |
{
|
|
|
1867 |
my( $platforms, @elements ) = @_;
|
|
|
1868 |
my $name;
|
|
|
1869 |
my $value;
|
|
|
1870 |
my $nowarn;
|
|
|
1871 |
my $nomoreswicthes = 0;
|
|
|
1872 |
|
|
|
1873 |
Debug2( "SetValue($platforms, @elements)" );
|
|
|
1874 |
|
|
|
1875 |
return if ( ! ActivePlatform($platforms) );
|
|
|
1876 |
|
|
|
1877 |
#
|
|
|
1878 |
# Process elements extracting values and options
|
|
|
1879 |
#
|
|
|
1880 |
foreach ( @elements )
|
|
|
1881 |
{
|
|
|
1882 |
if ( m/^--$/ ) {
|
|
|
1883 |
$nomoreswicthes = ! $nomoreswicthes;
|
|
|
1884 |
next;
|
|
|
1885 |
}
|
|
|
1886 |
|
|
|
1887 |
if ( m/^--/ && ! $nomoreswicthes )
|
|
|
1888 |
{
|
|
|
1889 |
|
|
|
1890 |
if ( m/^--NoWarn/ ) {
|
|
|
1891 |
$nowarn = 1;
|
|
|
1892 |
|
|
|
1893 |
} elsif ( m/^--Project=(.*)/ ) {
|
|
|
1894 |
return unless ( ActiveProject( $1) );
|
|
|
1895 |
|
|
|
1896 |
} else {
|
|
|
1897 |
Error ("SetValue: Unknown option: $_");
|
|
|
1898 |
|
|
|
1899 |
}
|
|
|
1900 |
|
|
|
1901 |
} elsif ( ! defined $name ) {
|
|
|
1902 |
$name = $_;
|
|
|
1903 |
|
|
|
1904 |
} elsif ( ! defined $value ) {
|
|
|
1905 |
$value = $_;
|
|
|
1906 |
|
|
|
1907 |
} else {
|
|
|
1908 |
Error ("SetValue: $name. Too many parameters" );
|
|
|
1909 |
|
|
|
1910 |
}
|
|
|
1911 |
}
|
|
|
1912 |
|
|
|
1913 |
#
|
|
|
1914 |
# Warn if the named variable already exists
|
|
|
1915 |
# It may be a JATS internal or it may be a user.
|
|
|
1916 |
#
|
|
|
1917 |
unless ( $nowarn )
|
|
|
1918 |
{
|
|
|
1919 |
no strict 'refs';
|
|
|
1920 |
Warning("SetValue: $name. Redefined") if defined ( $$name );
|
|
|
1921 |
use strict 'refs';
|
|
|
1922 |
}
|
|
|
1923 |
|
|
|
1924 |
#
|
|
|
1925 |
# Set the value
|
|
|
1926 |
#
|
|
|
1927 |
no strict 'refs';
|
|
|
1928 |
$$name = $value;
|
|
|
1929 |
use strict 'refs';
|
|
|
1930 |
}
|
|
|
1931 |
|
|
|
1932 |
#-------------------------------------------------------------------------------
|
|
|
1933 |
# Function : SetList
|
|
|
1934 |
#
|
|
|
1935 |
# Description : Defines a list variable that can be used within the makefile.pl
|
|
|
1936 |
# Use sparingly
|
|
|
1937 |
# An attempt to formalise a mechanism that is used anyway, but
|
|
|
1938 |
# with correct platform detection
|
|
|
1939 |
#
|
|
|
1940 |
# Inputs : $platform - Platform selector
|
|
|
1941 |
# $name - Name to set
|
|
|
1942 |
# $value,... - Values to set
|
|
|
1943 |
# options - Options
|
|
|
1944 |
# --NoWarn
|
|
|
1945 |
# --Project=xxxx[,xxxx]+
|
|
|
1946 |
# --Unique
|
|
|
1947 |
# --Clear
|
|
|
1948 |
# --Append
|
|
|
1949 |
# --
|
|
|
1950 |
#
|
|
|
1951 |
my %SetList_names;
|
|
|
1952 |
sub SetList
|
|
|
1953 |
{
|
|
|
1954 |
my( $platforms, @elements ) = @_;
|
|
|
1955 |
my $name;
|
|
|
1956 |
my @value;
|
|
|
1957 |
my $nowarn;
|
|
|
1958 |
my $unique;
|
|
|
1959 |
my $clear;
|
|
|
1960 |
my $nomoreswicthes = 0;
|
|
|
1961 |
|
|
|
1962 |
Debug2( "SetList($platforms, @elements)" );
|
|
|
1963 |
|
|
|
1964 |
return if ( ! ActivePlatform($platforms) );
|
|
|
1965 |
|
|
|
1966 |
#
|
|
|
1967 |
# Process elements extracting values and options
|
|
|
1968 |
#
|
|
|
1969 |
foreach ( @elements )
|
|
|
1970 |
{
|
|
|
1971 |
if ( m/^--$/ ) {
|
|
|
1972 |
$nomoreswicthes = ! $nomoreswicthes;
|
|
|
1973 |
next;
|
|
|
1974 |
}
|
|
|
1975 |
|
|
|
1976 |
if ( m/^--/ && ! $nomoreswicthes )
|
|
|
1977 |
{
|
|
|
1978 |
if ( m/^--NoWarn/ ) {
|
|
|
1979 |
$nowarn = 1;
|
|
|
1980 |
|
|
|
1981 |
} elsif ( m/^--Project=(.*)/ ) {
|
|
|
1982 |
return unless ( ActiveProject( $1) );
|
|
|
1983 |
|
|
|
1984 |
} elsif ( m/^--Unique/ ) {
|
|
|
1985 |
$unique = 1;
|
|
|
1986 |
|
|
|
1987 |
} elsif ( m/^--Clear/ ) {
|
|
|
1988 |
$clear = 1;
|
|
|
1989 |
|
|
|
1990 |
} elsif ( m/^--Append/ ) {
|
|
|
1991 |
$clear = 0;
|
|
|
1992 |
|
|
|
1993 |
} else {
|
|
|
1994 |
Error ("SetList: Unknown option: $_");
|
|
|
1995 |
}
|
|
|
1996 |
} elsif ( ! defined $name ) {
|
|
|
1997 |
$name = $_;
|
|
|
1998 |
|
|
|
1999 |
} else {
|
|
|
2000 |
push @value, $_;
|
|
|
2001 |
|
|
|
2002 |
}
|
|
|
2003 |
}
|
|
|
2004 |
|
|
|
2005 |
Error ("SetList: No name specified") unless ( $name );
|
|
|
2006 |
|
|
|
2007 |
#
|
|
|
2008 |
# Warn if the named variable already exists
|
|
|
2009 |
# It may be a JATS internal or it may be a user.
|
|
|
2010 |
#
|
|
|
2011 |
# Only do this iff the name is not known to this function
|
|
|
2012 |
# Keep a list a names that have been set.
|
|
|
2013 |
#
|
|
|
2014 |
if ( ! $SetList_names{$name} && ! $nowarn )
|
|
|
2015 |
{
|
|
|
2016 |
no strict 'refs';
|
|
|
2017 |
Warning("SetList: $name. Defined outside the ScanList/SetList directive","May clash with Jats internals") if defined ( @$name );
|
|
|
2018 |
use strict 'refs';
|
|
|
2019 |
}
|
|
|
2020 |
$SetList_names{$name} = 1;
|
|
|
2021 |
|
|
|
2022 |
#
|
|
|
2023 |
# Clear list
|
|
|
2024 |
#
|
|
|
2025 |
if ( $clear )
|
|
|
2026 |
{
|
|
|
2027 |
no strict 'refs';
|
|
|
2028 |
@$name = ();
|
|
|
2029 |
use strict 'refs';
|
|
|
2030 |
}
|
|
|
2031 |
|
|
|
2032 |
#
|
|
|
2033 |
# Set the value
|
|
|
2034 |
#
|
|
|
2035 |
no strict 'refs';
|
|
|
2036 |
if ( $unique ) {
|
|
|
2037 |
UniquePush( \@$name, @value);
|
|
|
2038 |
} else {
|
|
|
2039 |
push @$name, @value;
|
|
|
2040 |
}
|
|
|
2041 |
use strict 'refs';
|
|
|
2042 |
}
|
|
|
2043 |
|
|
|
2044 |
#-------------------------------------------------------------------------------
|
|
|
2045 |
# Function : ScanList
|
|
|
2046 |
#
|
|
|
2047 |
# Description : Create a list by scanning for files in a directory
|
|
|
2048 |
# The files may be in a local directory or within a package
|
|
|
2049 |
# Care must be taken when using a package as the results
|
|
|
2050 |
# may differ bewteen BuildPkgArchive and LinkPkgArchive
|
|
|
2051 |
#
|
|
|
2052 |
# Interworks with SetList
|
|
|
2053 |
#
|
|
|
2054 |
# Inputs : $platform - Platform selector
|
|
|
2055 |
# $name - Name to set
|
|
|
2056 |
# $value,... - Values to set
|
|
|
2057 |
# options - Options
|
|
|
2058 |
# --NoWarn
|
|
|
2059 |
# --Project=xxxx[,xxxx]+
|
|
|
2060 |
# --Unique
|
|
|
2061 |
# --Clear
|
|
|
2062 |
# --Append
|
|
|
2063 |
#
|
|
|
2064 |
# --Package=xxxx[,ext]
|
|
|
2065 |
# --Dir=xxx
|
|
|
2066 |
#
|
|
|
2067 |
# --Subdir=yyy
|
|
|
2068 |
# --DirListOnly
|
|
|
2069 |
# --FileListOnly
|
| 335 |
dpurdie |
2070 |
# --Recurse (default)
|
| 227 |
dpurdie |
2071 |
# --NoRecurse
|
| 335 |
dpurdie |
2072 |
# --FullPath (default)
|
|
|
2073 |
# --NoFullPath
|
| 227 |
dpurdie |
2074 |
#
|
|
|
2075 |
# --FilterIn=xxx
|
|
|
2076 |
# --FilterInRe=xxx
|
|
|
2077 |
# --FilterOut=xxx
|
|
|
2078 |
# --FilterOutRe=xxx
|
|
|
2079 |
#
|
|
|
2080 |
# Returns :
|
|
|
2081 |
#
|
|
|
2082 |
sub ScanList
|
|
|
2083 |
{
|
|
|
2084 |
my( $platforms, @elements ) = @_;
|
|
|
2085 |
my $name;
|
|
|
2086 |
my $package;
|
|
|
2087 |
my $dir;
|
|
|
2088 |
my $subdir;
|
|
|
2089 |
my @set_args;
|
|
|
2090 |
my $search = JatsLocateFiles->new('Recurse','FullPath' );
|
|
|
2091 |
|
|
|
2092 |
Debug2( "ScanList($platforms, @elements)" );
|
|
|
2093 |
|
|
|
2094 |
return if ( ! ActivePlatform($platforms) );
|
|
|
2095 |
|
|
|
2096 |
#
|
|
|
2097 |
# Process elements extracting values and options
|
|
|
2098 |
#
|
|
|
2099 |
foreach ( @elements )
|
|
|
2100 |
{
|
|
|
2101 |
if ( m/^--Unique|--Clear|--Append|--NoWarn/ ) {
|
|
|
2102 |
push @set_args, $_;
|
|
|
2103 |
|
|
|
2104 |
} elsif ( m/^--Project=(.*)/ ) {
|
|
|
2105 |
return unless ( ActiveProject( $1) );
|
|
|
2106 |
|
|
|
2107 |
} elsif ( m/^--Package=(.*)/ ) {
|
|
|
2108 |
$package = $1;
|
|
|
2109 |
|
|
|
2110 |
} elsif ( m/^--Dir=(.*)/ ) {
|
|
|
2111 |
$dir = $1;
|
|
|
2112 |
|
|
|
2113 |
} elsif ( m/^--Subdir=(.*)/ ) {
|
|
|
2114 |
$subdir = $1;
|
|
|
2115 |
|
|
|
2116 |
} elsif ( $search->option( $_ ) ) {
|
|
|
2117 |
Verbose ("Search Option: $_" );
|
|
|
2118 |
|
|
|
2119 |
} elsif ( m/^--/ ) {
|
|
|
2120 |
Error ("ScanList: Unknown option: $_");
|
|
|
2121 |
|
|
|
2122 |
} elsif ( ! defined $name ) {
|
|
|
2123 |
$name = $_;
|
|
|
2124 |
|
|
|
2125 |
} else {
|
|
|
2126 |
Error ("ScanList $name: Unknown option: $_");
|
|
|
2127 |
|
|
|
2128 |
}
|
|
|
2129 |
}
|
|
|
2130 |
|
|
|
2131 |
Error ("ScanList: No variable name specified") unless ( $name );
|
|
|
2132 |
Error ("ScanList: Must Specify --Dir or --Package") unless ( $dir || $package );
|
|
|
2133 |
Error ("ScanList: --Dir and --Package are mutually exclusive") if ( $dir && $package );
|
|
|
2134 |
|
|
|
2135 |
#
|
|
|
2136 |
# Locate the base of the scan
|
|
|
2137 |
# This may be either a package name or a local directory
|
|
|
2138 |
#
|
|
|
2139 |
# Its no use allowing the user to use OBJ/LIB/BIN directories as the
|
|
|
2140 |
# directories MUST exist at build time. Don't really want the user doing
|
|
|
2141 |
# that level of poking out of a package
|
|
|
2142 |
#
|
|
|
2143 |
if ( $package )
|
|
|
2144 |
{
|
|
|
2145 |
$dir = GetPackageBase( "ScanList", $package );
|
|
|
2146 |
Error ("ScanList: Package not found: $package") unless ( $dir );
|
|
|
2147 |
}
|
|
|
2148 |
else
|
|
|
2149 |
{
|
|
|
2150 |
Error ("ScanList: Root directory not found: $dir") unless ( -d $dir );
|
|
|
2151 |
}
|
|
|
2152 |
if ( $subdir )
|
|
|
2153 |
{
|
|
|
2154 |
$dir .= "/" . $subdir;
|
|
|
2155 |
Error ("ScanList: Sub directory not found: $subdir") unless ( -d $dir );
|
|
|
2156 |
}
|
|
|
2157 |
|
|
|
2158 |
#
|
|
|
2159 |
# Use SetList to do the rest of the work
|
|
|
2160 |
#
|
|
|
2161 |
SetList( $platforms, $name, @set_args, '--', $search->search($dir) );
|
|
|
2162 |
}
|
|
|
2163 |
|
|
|
2164 |
|
|
|
2165 |
sub Init
|
|
|
2166 |
{
|
|
|
2167 |
push( @INITS, @_ );
|
|
|
2168 |
}
|
|
|
2169 |
|
|
|
2170 |
#-------------------------------------------------------------------------------
|
|
|
2171 |
# Function : Generate
|
|
|
2172 |
#
|
|
|
2173 |
# Description : Legacy Function - don't use unless you have too.
|
|
|
2174 |
# Flags files that are to be generated during the
|
|
|
2175 |
# early 'generate' make phase. Will also add named files
|
|
|
2176 |
# to various internal lists
|
|
|
2177 |
#
|
|
|
2178 |
# Intended to be used in conjunction with the 'Rule' directive
|
|
|
2179 |
# to flag header and source files that need to be created early
|
|
|
2180 |
# in the build process.
|
|
|
2181 |
#
|
|
|
2182 |
# Inputs : See GenerateSrcFile
|
|
|
2183 |
#
|
|
|
2184 |
# Returns :
|
|
|
2185 |
#
|
|
|
2186 |
sub Generate
|
|
|
2187 |
{
|
|
|
2188 |
my( $platforms, @elements ) = @_;
|
|
|
2189 |
|
|
|
2190 |
Debug2( "Generate($platforms, @elements)" );
|
|
|
2191 |
|
|
|
2192 |
return if ( ! ActivePlatform($platforms) );
|
|
|
2193 |
Message("Generate directive used. Consider replacing with GenerateFiles");
|
|
|
2194 |
|
|
|
2195 |
#
|
|
|
2196 |
# Use Non-warning version to do the hard work
|
|
|
2197 |
#
|
|
|
2198 |
GenerateSrcFile( 1, @elements );
|
|
|
2199 |
}
|
|
|
2200 |
|
|
|
2201 |
#-------------------------------------------------------------------------------
|
|
|
2202 |
# Function : Generated
|
|
|
2203 |
#
|
|
|
2204 |
# Description : Legacy Function - don't use unless you have too.
|
|
|
2205 |
# Flags files that are generated by misc Rules
|
|
|
2206 |
#
|
|
|
2207 |
# Intended to be used in conjunction with the 'Rule' directive
|
|
|
2208 |
# to mark files that have been generated, so that they can be
|
|
|
2209 |
# cleaned up.
|
|
|
2210 |
#
|
|
|
2211 |
# Note the difference to the 'Generate' directive which will
|
|
|
2212 |
# ensure that the Rule will be run in the 'generate' phase,
|
|
|
2213 |
# this directive doesn't.
|
|
|
2214 |
#
|
|
|
2215 |
# Inputs : Files with internal Makefile Paths and codes
|
|
|
2216 |
# Eg: Generated( '*', "\$(LIBDIR)/libcsf\$(GBE_TYPE).\${a}" );
|
|
|
2217 |
# See why its YUK!
|
|
|
2218 |
#
|
|
|
2219 |
# Returns :
|
|
|
2220 |
#
|
|
|
2221 |
sub Generated
|
|
|
2222 |
{
|
|
|
2223 |
my( $platforms, @elements ) = @_;
|
|
|
2224 |
my( @args );
|
|
|
2225 |
|
|
|
2226 |
return if ( ! ActivePlatform($platforms) );
|
|
|
2227 |
Debug2( "Generated($platforms, @elements)" );
|
|
|
2228 |
|
|
|
2229 |
#.. Collect arguments
|
|
|
2230 |
#
|
|
|
2231 |
foreach ( @elements )
|
|
|
2232 |
{
|
|
|
2233 |
if ( /^-(.*)/ )
|
|
|
2234 |
{
|
|
|
2235 |
Debug( "Gen: arg $_" );
|
|
|
2236 |
push ( @args, $_);
|
|
|
2237 |
}
|
|
|
2238 |
}
|
|
|
2239 |
|
|
|
2240 |
#.. Push source file(s)
|
|
|
2241 |
#
|
|
|
2242 |
foreach ( @elements )
|
|
|
2243 |
{
|
|
|
2244 |
if ( ! /^-(.*)/ )
|
|
|
2245 |
{
|
|
|
2246 |
Debug( "Generated: $_ (@args)" );
|
|
|
2247 |
push (@USERGENERATED, $_);
|
|
|
2248 |
|
|
|
2249 |
#
|
|
|
2250 |
# Add the file to the list of known source files
|
|
|
2251 |
# This will allow them to be packaged
|
|
|
2252 |
#
|
|
|
2253 |
GenerateSrcFile (0, $_ );
|
|
|
2254 |
}
|
|
|
2255 |
}
|
|
|
2256 |
}
|
|
|
2257 |
|
|
|
2258 |
|
|
|
2259 |
#-------------------------------------------------------------------------------
|
|
|
2260 |
# Function : GenerateSrcFile
|
|
|
2261 |
#
|
|
|
2262 |
# Description : Internal Function (No $platform)
|
|
|
2263 |
# Determine how to handle a 'Generated' file
|
|
|
2264 |
#
|
|
|
2265 |
#
|
|
|
2266 |
# Inputs : $generated - 0: Don't add to GENERATED List
|
|
|
2267 |
# 1: Add to GENERATED List
|
|
|
2268 |
# 2: Add to GENERATED List, if a source file
|
|
|
2269 |
# FileName(s) - Name of one or more files to process
|
|
|
2270 |
# All files are processed in the same way
|
|
|
2271 |
# These file may contain Makefile prefixes
|
|
|
2272 |
# ie: $(OBJDIR)/file.obj
|
|
|
2273 |
# Options:
|
|
|
2274 |
# --c - Hint: Its a "C" file
|
|
|
2275 |
# --cpp - Hint: Its a C++ file
|
|
|
2276 |
# --asm - Hint: Its an ASM file
|
|
|
2277 |
# -* - Save as argument attached to the file
|
|
|
2278 |
#
|
| 303 |
dpurdie |
2279 |
# Returns : Number of 'source' file
|
| 227 |
dpurdie |
2280 |
#
|
|
|
2281 |
sub GenerateSrcFile # Internal Function - no $platform
|
|
|
2282 |
{
|
|
|
2283 |
my( $generated, @elements ) = @_;
|
|
|
2284 |
my( $type, @args );
|
| 303 |
dpurdie |
2285 |
my $result = 0;
|
| 227 |
dpurdie |
2286 |
|
|
|
2287 |
Debug2( "GenerateSrcFile($generated,@elements)" );
|
|
|
2288 |
|
|
|
2289 |
#.. Collect arguments
|
|
|
2290 |
#
|
|
|
2291 |
$type = "";
|
|
|
2292 |
foreach ( @elements )
|
|
|
2293 |
{
|
|
|
2294 |
if ( /^--c$/ ) {
|
|
|
2295 |
Debug( "Gen: --c" );
|
|
|
2296 |
$type = ".c";
|
|
|
2297 |
|
|
|
2298 |
} elsif ( /^--cpp$/ ) {
|
|
|
2299 |
Debug( "Gen: --cpp" );
|
|
|
2300 |
$type = ".cc";
|
|
|
2301 |
|
|
|
2302 |
} elsif ( /^--asm$/ ) {
|
|
|
2303 |
Debug( "Gen: --asm" );
|
|
|
2304 |
$type = ".asm";
|
|
|
2305 |
|
|
|
2306 |
} elsif ( /^-(.*)/ ) {
|
|
|
2307 |
Debug( "Src: arg $_" );
|
|
|
2308 |
push @args, $_;
|
|
|
2309 |
}
|
|
|
2310 |
}
|
|
|
2311 |
|
|
|
2312 |
#.. Process source file(s)
|
|
|
2313 |
#
|
|
|
2314 |
# Determine if file is already a known SRCS file - skip if already known
|
|
|
2315 |
# Update SRCS data
|
|
|
2316 |
# Update SRC_TYPE data
|
|
|
2317 |
# Update SRC_ARGS data
|
|
|
2318 |
# Add the file to a suitable source file list ie: @CHDRS,...
|
|
|
2319 |
# Flag as a GENERATED file - These will be processed during the 'generate' phase
|
|
|
2320 |
#
|
|
|
2321 |
foreach my $source ( @elements )
|
|
|
2322 |
{
|
|
|
2323 |
next if ( $source =~ /^-(.*)/ ); # Not a source file
|
|
|
2324 |
|
|
|
2325 |
my $basename = StripDir( $source );
|
|
|
2326 |
Debug( "Generate: $source=$basename (@args)" );
|
|
|
2327 |
|
|
|
2328 |
if ($SRCS{ $basename }) {
|
|
|
2329 |
Warning( "Duplicate src ignored '$source'" );
|
|
|
2330 |
next;
|
|
|
2331 |
}
|
|
|
2332 |
$SRCS{ $basename } = $source;
|
|
|
2333 |
|
|
|
2334 |
HashJoin( \%SRC_ARGS, $;, $basename, @args )
|
|
|
2335 |
if (@args);
|
|
|
2336 |
|
|
|
2337 |
$SRC_TYPE{ $basename } = $type
|
|
|
2338 |
if ($type);
|
|
|
2339 |
|
|
|
2340 |
#
|
|
|
2341 |
# Add the file to any source file lists that it may like to know
|
|
|
2342 |
# about this file.
|
|
|
2343 |
#
|
|
|
2344 |
# If the file was a known source file, then it may need to be generated
|
|
|
2345 |
# very early in the build process.
|
|
|
2346 |
#
|
|
|
2347 |
my $src_file_type = __AddSourceFile( 1, $basename );
|
| 285 |
dpurdie |
2348 |
if ($generated == 1 || ($src_file_type && $generated > 1) )
|
| 227 |
dpurdie |
2349 |
{
|
|
|
2350 |
push(@GENERATED, $source);
|
| 303 |
dpurdie |
2351 |
$result++;
|
| 227 |
dpurdie |
2352 |
}
|
|
|
2353 |
else
|
|
|
2354 |
{
|
|
|
2355 |
push(@GENERATED_NOTSRC, $source);
|
|
|
2356 |
}
|
|
|
2357 |
}
|
| 303 |
dpurdie |
2358 |
|
|
|
2359 |
return $result;
|
| 227 |
dpurdie |
2360 |
}
|
|
|
2361 |
|
|
|
2362 |
#-------------------------------------------------------------------------------
|
|
|
2363 |
# Function : GenerateFiles
|
|
|
2364 |
#
|
|
|
2365 |
# Description : Generate files in a controlled manner using a specified
|
|
|
2366 |
# tool to perform the task
|
|
|
2367 |
#
|
|
|
2368 |
# Inputs : $1 - platform specifier '*' (comma delemitered)
|
|
|
2369 |
# $2 - Tool Name
|
|
|
2370 |
# $3... - Command line argument to generate files with embedded information
|
|
|
2371 |
# - or options. Multiple command line arguments will be joind with
|
|
|
2372 |
# a single space
|
|
|
2373 |
#
|
|
|
2374 |
# The generated files will be placed in the OBJ directory for
|
|
|
2375 |
# the current target platform. This allows different files to
|
|
|
2376 |
# be generated for each platform, without collision.
|
|
|
2377 |
#
|
|
|
2378 |
# The full name of the generated files will be added to the list of
|
|
|
2379 |
# source files. Thus the user does not need to know the
|
|
|
2380 |
# full name of the file - it will be tracked by JATS.
|
|
|
2381 |
#
|
|
|
2382 |
# If a generated file is a header file, then the OBJ directory
|
|
|
2383 |
# will be added as AddIncDir() so that the header files can be
|
|
|
2384 |
# extracted
|
|
|
2385 |
#
|
|
|
2386 |
# If a generated file is a "C"/"C++" source file, then it will
|
|
|
2387 |
# compiled and the object file made available
|
|
|
2388 |
#
|
|
|
2389 |
# The tool name may be:
|
|
|
2390 |
# --Tool=name or "name"
|
|
|
2391 |
# Look in the tool paths in Packages
|
|
|
2392 |
# Look in the JATS tool directory for named script
|
|
|
2393 |
# Look in the JATS bin directory for the named exe
|
|
|
2394 |
# Look in the users path ( and generate a warning )
|
|
|
2395 |
# Give up and hope magic happens later
|
|
|
2396 |
# --Script=name
|
|
|
2397 |
# Resolve the name using known Src paths
|
|
|
2398 |
# The script may be generated and need not exist
|
|
|
2399 |
# at the time the makefile is created.
|
|
|
2400 |
# --Shell
|
|
|
2401 |
# The command line argument is a shell script that
|
|
|
2402 |
# will be passed to a simple shell.
|
| 263 |
dpurdie |
2403 |
# --Prog=name
|
|
|
2404 |
# Resolve to a program generated within this makefile
|
| 227 |
dpurdie |
2405 |
#
|
|
|
2406 |
#
|
|
|
2407 |
# The command line argument contains keywords to allow
|
|
|
2408 |
# information to be extracted from the line. Keywords are:
|
|
|
2409 |
#
|
|
|
2410 |
# --Generated(xxx) - xxx is a generated file
|
|
|
2411 |
# It will be placed in the OBJDIR
|
|
|
2412 |
# --GeneratedCommon(xxx) - xxx is a generated file
|
|
|
2413 |
# File will be placed in the local directory
|
|
|
2414 |
# and will be shared by by all platforms
|
|
|
2415 |
# --GeneratedObject(xxx) - xxx is a generated object file
|
|
|
2416 |
# It will be placed in the OBJDIR and will
|
|
|
2417 |
# have a suitable object suffix appended
|
|
|
2418 |
# --GeneratedProg(xxx) - xxx is a generated program file
|
|
|
2419 |
# It will be placed in the BINDIR
|
|
|
2420 |
# --Prerequisite(xxx) - xxx is a prerequisite file
|
|
|
2421 |
# The full name of the file will be located
|
|
|
2422 |
# and used within the command. The file will
|
|
|
2423 |
# be added to the list of recipe prerequisites
|
|
|
2424 |
# --GeneratedDirectory(xxx)
|
|
|
2425 |
# --GeneratedCommonDirectory(xxx)
|
|
|
2426 |
# --GeneratedObjectDirectory(xxx)
|
|
|
2427 |
# --GeneratedProgDirectory(xxx)
|
|
|
2428 |
# - xxx is a generated file, but is not placed
|
|
|
2429 |
# on the command line. It is flagged as
|
|
|
2430 |
# a generated files
|
|
|
2431 |
# --PackageBase(xxx) - xxx is a package. The keyword will be replaced
|
|
|
2432 |
# with the pathname to the package. If the package
|
|
|
2433 |
# has been copied in the the interface directory
|
|
|
2434 |
# then the interface directory will be used.
|
|
|
2435 |
# --PackageInfo(xxx,--opt)- xxx is a package. The keyword will be replaced
|
|
|
2436 |
# with the information requested.
|
|
|
2437 |
# Options are:
|
|
|
2438 |
# --path
|
|
|
2439 |
# --version
|
|
|
2440 |
# --fullversion
|
|
|
2441 |
# --project
|
|
|
2442 |
#
|
|
|
2443 |
# Where "xxx" may be of the form:
|
|
|
2444 |
# name,option[,option]
|
|
|
2445 |
#
|
|
|
2446 |
# Flag options are:
|
|
|
2447 |
# --file - The file part of the full name
|
|
|
2448 |
# --dir - The directory part of the full name
|
|
|
2449 |
# --abspath - Abs path
|
|
|
2450 |
# --absdrive - Abs path with drive letter
|
|
|
2451 |
#
|
|
|
2452 |
# --Var(Name,opt) - Name is the name of a recognised varable
|
|
|
2453 |
# Refer to ExpandGenVar function for details
|
|
|
2454 |
# of Name and available options
|
|
|
2455 |
# The expanded text will be replaced with an
|
|
|
2456 |
# suitable makefile variables that will be
|
|
|
2457 |
# replaced at run-time.
|
|
|
2458 |
#
|
|
|
2459 |
# The keyword will be replaced with the resolved name. This may be a file,
|
|
|
2460 |
# a directory or other text.
|
|
|
2461 |
#
|
|
|
2462 |
# Options do not alter command line text. They do affect the way the command is
|
|
|
2463 |
# processed.
|
|
|
2464 |
# Options include:
|
|
|
2465 |
# --Prereq=name - The name of a file to add as a prerequisite
|
|
|
2466 |
# The file does not form part of the command line
|
|
|
2467 |
# --Created=name - The name of a file to treat as a generated file
|
|
|
2468 |
# --CreatedCommon=name The file does not form part of the command line
|
|
|
2469 |
# --CreatedObject=name
|
|
|
2470 |
# --CreatedProg=name
|
|
|
2471 |
#
|
|
|
2472 |
# --NoVarTag - Modifes --Var operation to suppress tags
|
|
|
2473 |
# --NoWarn - Don't warn if no prerequistes found
|
|
|
2474 |
# --NoGenerate - Don't warn if no generated files are found
|
|
|
2475 |
# Will create a dummy rule name and the recipe will
|
|
|
2476 |
# always be executed during the 'GenerateFiles' phase
|
|
|
2477 |
# --UnknownPreq - Prerequisites are not fully known.
|
|
|
2478 |
# Rebuild the target whenever it is required.
|
|
|
2479 |
# --AutoGenerate - Examine the generated file to determine when the
|
|
|
2480 |
# tools is to be run.
|
| 261 |
dpurdie |
2481 |
# Must be before any options that declare
|
|
|
2482 |
# creation of files.
|
| 227 |
dpurdie |
2483 |
# --Text=<text> - Display text for command
|
|
|
2484 |
#
|
| 263 |
dpurdie |
2485 |
# --Clean[=arg] - Call script with arg[-clean] for cleaning.
|
|
|
2486 |
# --PreDelete - Delete generated files before running the command
|
| 227 |
dpurdie |
2487 |
#
|
|
|
2488 |
# Eg: GenerateFiles ( '*', "--Tool=mod_if.pl",
|
|
|
2489 |
# "-src --Prerequisite(udh_module.cfg)",
|
|
|
2490 |
# "-direct -hdr --Generated(udp.h) -quiet" );
|
|
|
2491 |
#
|
|
|
2492 |
my $NoGenIndex = 0;
|
|
|
2493 |
sub GenerateFiles
|
|
|
2494 |
{
|
|
|
2495 |
my ( $platforms, $tool, @args) = @_;
|
|
|
2496 |
|
|
|
2497 |
return if ( ! ActivePlatform($platforms) );
|
|
|
2498 |
|
|
|
2499 |
Debug2( "GenerateFiles:($platforms, $tool, @args)" );
|
|
|
2500 |
|
|
|
2501 |
my @preq_files;
|
|
|
2502 |
my $preq_unknown;
|
|
|
2503 |
my @gen_files;
|
|
|
2504 |
my $shell_script;
|
|
|
2505 |
my $shell_cmds;
|
|
|
2506 |
my @tool_args;
|
|
|
2507 |
my $no_warn;
|
|
|
2508 |
my $clean_tag;
|
|
|
2509 |
my $text;
|
|
|
2510 |
my $gtype = 1;
|
| 303 |
dpurdie |
2511 |
my @has_source;
|
| 227 |
dpurdie |
2512 |
my @var_opts;
|
| 261 |
dpurdie |
2513 |
my @genreq_seen;
|
| 263 |
dpurdie |
2514 |
my $predelete;
|
| 227 |
dpurdie |
2515 |
|
|
|
2516 |
#
|
|
|
2517 |
# Process the first argument - this describes the program that will be used
|
|
|
2518 |
# to generate the files. It may be:
|
|
|
2519 |
# --Tool - A Jats Tool or Plugin
|
|
|
2520 |
# --Script - A shell script file
|
|
|
2521 |
# --Shell - Raw shell commands
|
|
|
2522 |
# --Prog - A program created within the Makefile
|
|
|
2523 |
#
|
|
|
2524 |
#
|
|
|
2525 |
if ( $tool =~ /^--Tool=(.*)/ || $tool =~ /^([^-].*)/)
|
|
|
2526 |
{
|
|
|
2527 |
$tool = $1;
|
|
|
2528 |
my $tool_no_prereq = 0;
|
|
|
2529 |
|
|
|
2530 |
#
|
|
|
2531 |
# Process the Tool name and determine the location of the tool
|
|
|
2532 |
# Support --Tool=name and "name"
|
|
|
2533 |
# Locate the tool one of the many well known locations
|
|
|
2534 |
# 1) Tool paths from Package Archives
|
|
|
2535 |
# 2) JATS tool and binaries
|
|
|
2536 |
# 3) User PATH (!YUK)
|
|
|
2537 |
#
|
|
|
2538 |
|
|
|
2539 |
#
|
|
|
2540 |
# Create a list of known extensions to scan
|
|
|
2541 |
# Basically present so that we can use .exe files without the .exe name
|
|
|
2542 |
#
|
|
|
2543 |
my @extension_list;
|
|
|
2544 |
push @extension_list, '.exe' if ( $::ScmHost ne "Unix" );
|
|
|
2545 |
push @extension_list, '.pl', '.sh', '.ksh', '';
|
|
|
2546 |
|
|
|
2547 |
TOOL_SEARCH:
|
|
|
2548 |
{
|
|
|
2549 |
#
|
|
|
2550 |
# Locate tool with package
|
|
|
2551 |
#
|
|
|
2552 |
if ( my $fname = ToolExtensionProgram( $tool, @extension_list ))
|
|
|
2553 |
{
|
|
|
2554 |
$tool = $fname;
|
|
|
2555 |
last TOOL_SEARCH;
|
|
|
2556 |
}
|
|
|
2557 |
|
|
|
2558 |
#
|
|
|
2559 |
# Search the JATS tools and Bin directory
|
|
|
2560 |
# Retain the symbolic name of the JATS directory
|
|
|
2561 |
#
|
|
|
2562 |
for my $ext ( @extension_list )
|
|
|
2563 |
{
|
|
|
2564 |
foreach my $jdir ( qw( / /DEPLOY/ /LOCAL/ ) )
|
|
|
2565 |
{
|
|
|
2566 |
if ( -f "$::GBE_TOOLS$jdir$tool$ext" )
|
|
|
2567 |
{
|
|
|
2568 |
$tool = "\$(GBE_TOOLS)$jdir$tool$ext";
|
|
|
2569 |
last TOOL_SEARCH;
|
|
|
2570 |
}
|
|
|
2571 |
}
|
|
|
2572 |
|
|
|
2573 |
if ( -f "$::GBE_BIN/$tool$ext" )
|
|
|
2574 |
{
|
|
|
2575 |
$tool = "\$(GBE_BIN)/$tool$ext";
|
|
|
2576 |
last TOOL_SEARCH;
|
|
|
2577 |
}
|
|
|
2578 |
}
|
|
|
2579 |
|
|
|
2580 |
#
|
|
|
2581 |
# Has the user provided an absolute PATH
|
|
|
2582 |
# This is not good, but for testing we can use it
|
|
|
2583 |
#
|
|
|
2584 |
if ( $tool =~ m~^/~ || $tool =~ m~^.:~ )
|
|
|
2585 |
{
|
|
|
2586 |
Warning("Absolute path program specified. Uncontrolled tool: $tool");
|
|
|
2587 |
for my $ext ( @extension_list )
|
|
|
2588 |
{
|
|
|
2589 |
if ( -f "$tool$ext" )
|
|
|
2590 |
{
|
|
|
2591 |
$tool = "$tool$ext";
|
|
|
2592 |
last TOOL_SEARCH;
|
|
|
2593 |
}
|
|
|
2594 |
}
|
|
|
2595 |
}
|
|
|
2596 |
|
|
|
2597 |
#
|
|
|
2598 |
# May have a relative path to a local tool
|
|
|
2599 |
#
|
|
|
2600 |
if ( -f $tool )
|
|
|
2601 |
{
|
|
|
2602 |
UniquePush (\@preq_files, $tool);
|
|
|
2603 |
last TOOL_SEARCH;
|
|
|
2604 |
}
|
|
|
2605 |
|
|
|
2606 |
#
|
|
|
2607 |
# Search the users PATH
|
|
|
2608 |
# Generate a warning if the program is found. These programs are
|
|
|
2609 |
# not nice as they are not really controlled.
|
|
|
2610 |
#
|
|
|
2611 |
for my $dir (split( $::ScmPathSep, $ENV{'PATH'} ) )
|
|
|
2612 |
{
|
|
|
2613 |
for my $ext ( @extension_list )
|
|
|
2614 |
{
|
|
|
2615 |
if ( -f "$dir/$tool$ext" )
|
|
|
2616 |
{
|
|
|
2617 |
Warning("External program found in the user's PATH. Uncontrolled tool: $tool");
|
|
|
2618 |
$tool = "$dir/$tool$ext";
|
|
|
2619 |
|
|
|
2620 |
#
|
|
|
2621 |
# Do not make the program a pre-requisite if we are running
|
|
|
2622 |
# under Windows. This avoids two problems:
|
|
|
2623 |
# 1) May have spaces in pathname
|
|
|
2624 |
# 2) May have driver letter in pathname
|
|
|
2625 |
#
|
|
|
2626 |
$tool_no_prereq = 1 if ( $::ScmHost eq "WIN" );
|
|
|
2627 |
last TOOL_SEARCH;
|
|
|
2628 |
}
|
|
|
2629 |
}
|
|
|
2630 |
}
|
|
|
2631 |
|
|
|
2632 |
#
|
|
|
2633 |
# Specified progrom not found
|
|
|
2634 |
# Generate a warning and use the raw name
|
|
|
2635 |
#
|
|
|
2636 |
Warning("Tool not found: $tool");
|
|
|
2637 |
$tool_no_prereq = 1;
|
|
|
2638 |
}
|
|
|
2639 |
UniquePush (\@preq_files, $tool) unless ($tool_no_prereq);
|
|
|
2640 |
|
|
|
2641 |
} elsif ( $tool =~ /^--Script=(.*)/ ) {
|
|
|
2642 |
|
|
|
2643 |
#
|
|
|
2644 |
# Locate the script in a known source directory and make
|
|
|
2645 |
# the script a prerequisite of the target files, since the
|
|
|
2646 |
# script may be generated.
|
|
|
2647 |
#
|
|
|
2648 |
$tool = MakeSrcResolve ( $1 );
|
|
|
2649 |
UniquePush (\@preq_files, $tool);
|
|
|
2650 |
|
|
|
2651 |
} elsif ( $tool =~ /^--Shell$/ ) {
|
|
|
2652 |
#
|
|
|
2653 |
# The user has provided a shell script within the command body
|
|
|
2654 |
# This will be executed directly by a shell
|
|
|
2655 |
# directores will need to use a "/" separator
|
|
|
2656 |
#
|
|
|
2657 |
$tool = "InternalShell";
|
|
|
2658 |
$shell_script = 1;
|
|
|
2659 |
$shell_cmds = 1;
|
|
|
2660 |
|
|
|
2661 |
|
|
|
2662 |
} elsif ( $tool =~ /^--Prog=(.*)$/ ) {
|
|
|
2663 |
#
|
|
|
2664 |
# Using a program that has been created within this script
|
|
|
2665 |
#
|
|
|
2666 |
my $prog = $1;
|
| 289 |
dpurdie |
2667 |
if ( my $pProg = $PROGS->Get($prog) )
|
| 227 |
dpurdie |
2668 |
{
|
| 289 |
dpurdie |
2669 |
$tool = $pProg->getPath()
|
| 227 |
dpurdie |
2670 |
unless ( $tool = $SRCS{$prog} );
|
|
|
2671 |
UniquePush (\@preq_files, $tool);
|
|
|
2672 |
}
|
|
|
2673 |
else
|
|
|
2674 |
{
|
|
|
2675 |
Error ("Unknown program: $prog");
|
|
|
2676 |
}
|
|
|
2677 |
|
|
|
2678 |
} else {
|
|
|
2679 |
|
|
|
2680 |
#
|
|
|
2681 |
# Currently generate a warning and then use the raw tool name
|
|
|
2682 |
#
|
|
|
2683 |
Error ("Unknown TOOL syntax: $tool");
|
|
|
2684 |
}
|
|
|
2685 |
|
|
|
2686 |
#
|
|
|
2687 |
# May need to quote the path
|
|
|
2688 |
# If the toolpath contains spaces then ugliness can occur - so quote the program
|
|
|
2689 |
#
|
|
|
2690 |
$tool = '"' . $tool . '"'
|
|
|
2691 |
if ( (! $shell_script ) && $tool =~ m~\s~ );
|
|
|
2692 |
|
|
|
2693 |
#
|
|
|
2694 |
# Determine special startup for various programs
|
|
|
2695 |
# Perl - use known implemenatation
|
|
|
2696 |
# Shell - use known implemenatation
|
|
|
2697 |
# Otherwise - simply run it
|
|
|
2698 |
#
|
|
|
2699 |
# Windows: Shell and Perl don't need '\' in paths
|
|
|
2700 |
#
|
|
|
2701 |
if ( $tool =~ /\.pl$/ )
|
|
|
2702 |
{
|
|
|
2703 |
$tool = "\$(GBE_PERL) $tool";
|
|
|
2704 |
$shell_script = 1;
|
|
|
2705 |
}
|
|
|
2706 |
elsif ( $tool =~ /\.k?sh$/ )
|
|
|
2707 |
{
|
|
|
2708 |
$tool = "\$(GBE_BIN)/sh $tool";
|
|
|
2709 |
$shell_script = 1;
|
|
|
2710 |
}
|
|
|
2711 |
Debug( "GenerateFiles: Tool: $tool" );
|
|
|
2712 |
|
|
|
2713 |
|
|
|
2714 |
#
|
|
|
2715 |
# Process the remaining arguments
|
|
|
2716 |
# These will be command line arguments or options/flags
|
|
|
2717 |
# Command line arguments are concatenated together
|
|
|
2718 |
#
|
|
|
2719 |
for my $arg (@args)
|
|
|
2720 |
{
|
| 263 |
dpurdie |
2721 |
if ( $arg =~ /^--PreDelete$/ )
|
|
|
2722 |
{
|
|
|
2723 |
#
|
|
|
2724 |
# Delete generated files before running the generation process
|
|
|
2725 |
# Some programs refuse to overwrite existing files
|
|
|
2726 |
#
|
|
|
2727 |
$predelete = 1;
|
|
|
2728 |
next;
|
|
|
2729 |
}
|
|
|
2730 |
|
| 227 |
dpurdie |
2731 |
if ( $arg =~ /^--NoVarTag$/ )
|
|
|
2732 |
{
|
|
|
2733 |
#
|
|
|
2734 |
# Modify the operation of --Var to supress the tags
|
|
|
2735 |
# Should be usd early as will only affect following --Var usage
|
|
|
2736 |
#
|
|
|
2737 |
push @var_opts, "--notag";
|
|
|
2738 |
next;
|
|
|
2739 |
}
|
|
|
2740 |
|
|
|
2741 |
if ( $arg =~ /^--NoWarn$/ )
|
|
|
2742 |
{
|
|
|
2743 |
#
|
|
|
2744 |
# Supress warnings - No prequisites found
|
|
|
2745 |
# This is acceptable, but normally a tool should take an input
|
|
|
2746 |
# and create some output from it.
|
|
|
2747 |
#
|
|
|
2748 |
$no_warn = 1;
|
|
|
2749 |
next;
|
|
|
2750 |
}
|
|
|
2751 |
|
|
|
2752 |
if ( $arg =~ /^--NoGenerate$/ )
|
|
|
2753 |
{
|
|
|
2754 |
#
|
|
|
2755 |
# Tool does generate a definable output
|
|
|
2756 |
# Should only be used internally
|
|
|
2757 |
#
|
|
|
2758 |
# Need to create a dummy name for the rule
|
|
|
2759 |
# Use a base name and a number
|
|
|
2760 |
#
|
|
|
2761 |
my $dummy_target = 'generate_files_' . $NoGenIndex;
|
|
|
2762 |
UniquePush (\@gen_files, $dummy_target );
|
|
|
2763 |
UniquePush (\@GENERATED, $dummy_target);
|
|
|
2764 |
next;
|
|
|
2765 |
}
|
|
|
2766 |
|
|
|
2767 |
if ( $arg =~ /^--UnknownPreq/ )
|
|
|
2768 |
{
|
|
|
2769 |
#
|
|
|
2770 |
# Indicate that the prequisites are not known, or too complex to
|
|
|
2771 |
# describe. ie: All files in a directory. May be used by packaging
|
|
|
2772 |
# tools.
|
|
|
2773 |
# The recipe will be run EVERY time we want to use the target.
|
|
|
2774 |
#
|
|
|
2775 |
$preq_unknown = 1;
|
|
|
2776 |
$no_warn = 1;
|
|
|
2777 |
next;
|
|
|
2778 |
}
|
|
|
2779 |
|
|
|
2780 |
if ( $arg =~ /^--AutoGenerate/ )
|
|
|
2781 |
{
|
|
|
2782 |
#
|
|
|
2783 |
# Determine when to run the tool based on the types of files that
|
|
|
2784 |
# are generated. Existance of a source file will force the tool
|
|
|
2785 |
# to be run during the 'generate' phase, othewise the tool will be run
|
|
|
2786 |
# when the generated components are required.
|
|
|
2787 |
#
|
|
|
2788 |
$gtype = 2;
|
| 261 |
dpurdie |
2789 |
Warning ("AutoGenerate MUST occur before options that declare generation of files",
|
|
|
2790 |
"Have seen:", @genreq_seen)
|
|
|
2791 |
if (@genreq_seen);
|
| 227 |
dpurdie |
2792 |
next;
|
|
|
2793 |
}
|
|
|
2794 |
|
|
|
2795 |
if ( $arg =~ /^--Prereq=(.*)/ )
|
|
|
2796 |
{
|
|
|
2797 |
#
|
|
|
2798 |
# Specify a prerequisite file, that is not a part of the command line
|
|
|
2799 |
# Simply add the files to the list of preq files
|
|
|
2800 |
#
|
|
|
2801 |
my $fn = LocatePreReq ($1);
|
|
|
2802 |
UniquePush ( \@preq_files, $fn );
|
|
|
2803 |
Debug( "GenerateFiles: ExtraPrereq: $fn" );
|
|
|
2804 |
next;
|
|
|
2805 |
}
|
|
|
2806 |
|
|
|
2807 |
if ( $arg =~ /^--Created(.*)=(.*)/ )
|
|
|
2808 |
{
|
|
|
2809 |
#
|
|
|
2810 |
# Specify a generated file, that is not a part of the command line
|
|
|
2811 |
# Add the files to the list of generated files
|
|
|
2812 |
#
|
|
|
2813 |
my $type = $1;
|
|
|
2814 |
my $fn = $2;
|
|
|
2815 |
|
| 343 |
dpurdie |
2816 |
#
|
|
|
2817 |
# Append object suffix to CreatedObject
|
|
|
2818 |
#
|
| 227 |
dpurdie |
2819 |
$fn .= '.' . $::o
|
|
|
2820 |
if ( $type =~ m/Object/ );
|
|
|
2821 |
|
| 343 |
dpurdie |
2822 |
#
|
|
|
2823 |
# If the files is 'created' in a subdir, then add the dir
|
|
|
2824 |
# as a prerequisite.
|
|
|
2825 |
#
|
|
|
2826 |
if ( $type =~ m/Prog/ ) {
|
|
|
2827 |
$fn = "\$(BINDIR)/$fn";
|
|
|
2828 |
UniquePush (\@preq_files, '$(GBE_BINDIR)');
|
|
|
2829 |
|
|
|
2830 |
} elsif ( $type !~ m/Common/ ) {
|
|
|
2831 |
$fn = "\$(OBJDIR)/$fn";
|
|
|
2832 |
UniquePush (\@preq_files, '$(GBE_OBJDIR)');
|
|
|
2833 |
}
|
| 227 |
dpurdie |
2834 |
|
|
|
2835 |
#
|
|
|
2836 |
# Examine the file and see if it needs to be compiled
|
|
|
2837 |
# Add to the list of source files
|
|
|
2838 |
#
|
| 261 |
dpurdie |
2839 |
push @genreq_seen, $arg;
|
| 303 |
dpurdie |
2840 |
if ( UniquePush (\@gen_files, $fn) )
|
|
|
2841 |
{
|
|
|
2842 |
if ( GenerateSrcFile ( $gtype, $fn ) && $gtype == 2 )
|
|
|
2843 |
{
|
|
|
2844 |
push @has_source, $fn;
|
|
|
2845 |
}
|
|
|
2846 |
}
|
| 227 |
dpurdie |
2847 |
Debug( "GenerateFiles: ExtraCreated: $fn" );
|
|
|
2848 |
next;
|
|
|
2849 |
}
|
|
|
2850 |
|
|
|
2851 |
if ( $arg =~ /^--Clean($|=(.*))/ )
|
|
|
2852 |
{
|
|
|
2853 |
#
|
|
|
2854 |
# Detect Clean option
|
|
|
2855 |
#
|
|
|
2856 |
$clean_tag = $2 ? $2 : '-clean';
|
|
|
2857 |
|
|
|
2858 |
#
|
|
|
2859 |
# Shell command with a --Clean will only
|
|
|
2860 |
# be run during a clean phase. They should not have any prereq
|
|
|
2861 |
# and should not generate any files, so simplify the interface.
|
|
|
2862 |
#
|
|
|
2863 |
push @args, '--NoWarn', '--NoGenerate'
|
|
|
2864 |
if ( $shell_cmds );
|
|
|
2865 |
|
|
|
2866 |
next;
|
|
|
2867 |
}
|
|
|
2868 |
|
|
|
2869 |
if ( $arg =~ /^--Text=(.*)/ )
|
|
|
2870 |
{
|
|
|
2871 |
#
|
|
|
2872 |
# Display this text when executing commands
|
|
|
2873 |
#
|
|
|
2874 |
$text = $1;
|
|
|
2875 |
next;
|
|
|
2876 |
}
|
|
|
2877 |
|
|
|
2878 |
|
|
|
2879 |
# Not an option. Must be an argument to the tool/program
|
|
|
2880 |
# Process the tool arguments and extract file information
|
|
|
2881 |
# Extract all fields of the form:
|
|
|
2882 |
# --xxxxx(yyyyyy[,zzzzz])
|
|
|
2883 |
# --xxxxx{yyyyyyy}
|
|
|
2884 |
# --xxxxx[yyyyyyy] to allow embedded brackets
|
|
|
2885 |
#
|
|
|
2886 |
while ( $arg =~ m/--(\w+) # --CommandWord $1
|
|
|
2887 |
( # Just for grouping
|
|
|
2888 |
\((.*?)\) | # Stuff like (yyyyy) $3
|
|
|
2889 |
{(.*?)} | # or like {yyyyy} $4
|
|
|
2890 |
\[(.*?)\] # or like [yyyyy] $5
|
|
|
2891 |
)/x ) # Allow comments and whitespace
|
|
|
2892 |
{
|
|
|
2893 |
my $cmd = $1; # The command
|
|
|
2894 |
my $ufn = $3 || $4 || $5; # User filename + options
|
|
|
2895 |
my $mb = $-[0]; # Match begin offset
|
|
|
2896 |
my $me = $+[0]; # Match end
|
|
|
2897 |
my $flags = ''; # Optional flags ( --dir or --file )
|
|
|
2898 |
my $raw_arg = $ufn; # Raw arguments
|
| 285 |
dpurdie |
2899 |
my $all = substr( $arg, $mb, $me ); # All of match. Avoid use of $&
|
| 343 |
dpurdie |
2900 |
my $is_path = 1;
|
| 285 |
dpurdie |
2901 |
|
| 227 |
dpurdie |
2902 |
|
|
|
2903 |
Error ("GenerateFiles. Empty element not allowed: $all")
|
|
|
2904 |
unless ( defined($ufn) );
|
|
|
2905 |
|
|
|
2906 |
$ufn =~ s/\s+$//;
|
|
|
2907 |
$ufn =~ s/^\s+//;
|
|
|
2908 |
$ufn =~ s~//~/~g; # Remove multiple /
|
|
|
2909 |
if ( $ufn =~ m/(.*?),(.*)/ ) # Extract out any flags
|
|
|
2910 |
{
|
|
|
2911 |
$ufn = $1;
|
|
|
2912 |
$flags = $2;
|
|
|
2913 |
}
|
|
|
2914 |
|
|
|
2915 |
my $fn = $ufn ; # Replacement filename
|
| 343 |
dpurdie |
2916 |
my $fnp = ''; # Prefix to $fn
|
| 227 |
dpurdie |
2917 |
Error ("GenerateFiles. Empty element not allowed: $all" )
|
|
|
2918 |
if ( length ($ufn) <= 0 );
|
|
|
2919 |
|
|
|
2920 |
#
|
|
|
2921 |
# Process found user command
|
|
|
2922 |
#
|
|
|
2923 |
if ( $cmd =~ /^Generated/ )
|
|
|
2924 |
{
|
|
|
2925 |
my $use_dir = "";
|
| 343 |
dpurdie |
2926 |
|
| 227 |
dpurdie |
2927 |
#
|
|
|
2928 |
# Generated filename
|
|
|
2929 |
# Determine the target directory
|
|
|
2930 |
# Determine the full name of the file.
|
|
|
2931 |
# Flag the file as generated
|
|
|
2932 |
#
|
|
|
2933 |
if ( $cmd =~ /Prog/ )
|
|
|
2934 |
{
|
|
|
2935 |
#
|
|
|
2936 |
# Generated Prog are generated in the BIN directory
|
|
|
2937 |
# Ensure the directory exists by using its symbolic name
|
|
|
2938 |
# as a prerequisite.
|
|
|
2939 |
#
|
| 343 |
dpurdie |
2940 |
$use_dir = '$(BINDIR)';
|
|
|
2941 |
UniquePush (\@preq_files, '$(GBE_BINDIR)');
|
| 227 |
dpurdie |
2942 |
}
|
|
|
2943 |
elsif ( $cmd !~ /Common/ )
|
|
|
2944 |
{
|
|
|
2945 |
#
|
|
|
2946 |
# Files that are not Common are generated in the
|
|
|
2947 |
# object directory. This directory must exist, so it
|
|
|
2948 |
# symbolic name GBE_OBJDIR is made a prerequisite too.
|
|
|
2949 |
#
|
|
|
2950 |
# If the file is a header file, then add the directory
|
|
|
2951 |
# to the include search path too.
|
|
|
2952 |
#
|
| 343 |
dpurdie |
2953 |
$use_dir = '$(OBJDIR)';
|
|
|
2954 |
UniquePush (\@preq_files, '$(GBE_OBJDIR)');
|
|
|
2955 |
AddIncDir( $platforms , '$(OBJDIR)', '--NoWarn' )
|
| 227 |
dpurdie |
2956 |
if ( $ScmSourceTypes{ StripFile($fn) } && $ScmSourceTypes{ StripFile($fn) } eq ".h" );
|
|
|
2957 |
}
|
|
|
2958 |
|
|
|
2959 |
|
|
|
2960 |
#
|
|
|
2961 |
# Append a toolset specfic object file name suffix
|
|
|
2962 |
# for Object files only
|
|
|
2963 |
#
|
|
|
2964 |
$fn .= ".$::o"
|
|
|
2965 |
if ( $cmd =~ /Object/ );
|
|
|
2966 |
|
|
|
2967 |
#
|
|
|
2968 |
# Merge directory and filename parts
|
|
|
2969 |
#
|
|
|
2970 |
$fn = $use_dir . ( $use_dir ? "/" : "" ) . $fn;
|
|
|
2971 |
|
|
|
2972 |
#
|
|
|
2973 |
# Save for later user
|
|
|
2974 |
# Flag the file as a generated file
|
|
|
2975 |
#
|
| 261 |
dpurdie |
2976 |
push @genreq_seen, $cmd;
|
| 303 |
dpurdie |
2977 |
if ( UniquePush (\@gen_files, $fn) )
|
|
|
2978 |
{
|
|
|
2979 |
if ( GenerateSrcFile ( $gtype, $fn ) && $gtype == 2 )
|
|
|
2980 |
{
|
|
|
2981 |
push @has_source, $fn;
|
|
|
2982 |
}
|
|
|
2983 |
}
|
| 227 |
dpurdie |
2984 |
|
|
|
2985 |
#
|
|
|
2986 |
# Use the directory or the full name
|
|
|
2987 |
# If using the directory then ensure that we have a name
|
|
|
2988 |
# even if its "."
|
|
|
2989 |
#
|
|
|
2990 |
$fn = ($use_dir) ? "$use_dir" : "."
|
|
|
2991 |
if ( $cmd =~ /Directory/ );
|
|
|
2992 |
|
|
|
2993 |
Debug( "GenerateFiles: Generate: $fn" );
|
|
|
2994 |
|
|
|
2995 |
}
|
|
|
2996 |
elsif ( $cmd =~ /^Prereq/ )
|
|
|
2997 |
{
|
|
|
2998 |
#
|
|
|
2999 |
# Prerequisite filename
|
|
|
3000 |
# Resolve the full name of the file. It may be known
|
|
|
3001 |
# as a source file (possibly generated) or it may be
|
|
|
3002 |
# located in a known source directory
|
|
|
3003 |
#
|
|
|
3004 |
$fn = LocatePreReq ($ufn);
|
|
|
3005 |
UniquePush (\@preq_files, $fn);
|
|
|
3006 |
|
|
|
3007 |
Debug( "GenerateFiles: Prereq: $fn" );
|
|
|
3008 |
|
|
|
3009 |
}
|
|
|
3010 |
elsif ( $cmd =~ /^PackageBase/ )
|
|
|
3011 |
{
|
|
|
3012 |
$fn = GetPackageBase( "GenerateFiles", $raw_arg );
|
|
|
3013 |
UniquePush (\@preq_files, $fn);
|
|
|
3014 |
}
|
|
|
3015 |
elsif ( $cmd =~ /^PackageInfo/ )
|
|
|
3016 |
{
|
|
|
3017 |
$fn = GetPackageInfo( "GenerateFiles", $raw_arg );
|
|
|
3018 |
}
|
|
|
3019 |
elsif ( $cmd =~ /^Var/ )
|
|
|
3020 |
{
|
| 343 |
dpurdie |
3021 |
($fnp, $fn, $is_path) = ExpandGenVar( "GenerateFiles", $raw_arg, @var_opts );
|
| 227 |
dpurdie |
3022 |
$flags = '';
|
| 343 |
dpurdie |
3023 |
if ( $raw_arg eq 'ObjDir' ) {
|
|
|
3024 |
UniquePush (\@preq_files, '$(GBE_OBJDIR)');
|
|
|
3025 |
} elsif ( $raw_arg eq 'BinDir' ) {
|
|
|
3026 |
UniquePush (\@preq_files, '$(GBE_BINDIR)');
|
|
|
3027 |
} elsif ( $raw_arg eq 'LibDir' ) {
|
|
|
3028 |
UniquePush (\@preq_files, '$(GBE_LIBDIR)');
|
|
|
3029 |
}
|
| 227 |
dpurdie |
3030 |
}
|
|
|
3031 |
else
|
|
|
3032 |
{
|
|
|
3033 |
Warning ("GenerateFiles: Unknown replacement command: $cmd");
|
|
|
3034 |
$fn = $ufn;
|
|
|
3035 |
}
|
|
|
3036 |
|
|
|
3037 |
#
|
|
|
3038 |
# Process path modification flags
|
|
|
3039 |
#
|
|
|
3040 |
$fn = ProcessPathName( $fn, $flags );
|
|
|
3041 |
|
|
|
3042 |
#
|
|
|
3043 |
# Minor kludge under windows. Ensure directores have a "\" sep
|
|
|
3044 |
# Unless the user has specified a straight shell command
|
|
|
3045 |
#
|
| 303 |
dpurdie |
3046 |
$fn = "\$(subst /,\\,$fn)"
|
| 343 |
dpurdie |
3047 |
if ( $is_path && $::ScmHost eq "WIN" && ! defined($shell_script) );
|
| 227 |
dpurdie |
3048 |
|
|
|
3049 |
#
|
| 343 |
dpurdie |
3050 |
# Prepend any $fn Prefix
|
|
|
3051 |
# This will be a tag and is not subject to path processing
|
|
|
3052 |
#
|
|
|
3053 |
$fn = $fnp . $fn;
|
|
|
3054 |
|
|
|
3055 |
#
|
| 227 |
dpurdie |
3056 |
# Replace the found string with the real name of the file
|
|
|
3057 |
# Note: 4 argument version of substr is not always available
|
|
|
3058 |
# so we must do it the hard way
|
|
|
3059 |
# substr( $arg, $mb, $me - $mb, $fn);
|
|
|
3060 |
#
|
|
|
3061 |
$arg = substr( $arg, 0, $mb ) . $fn . substr( $arg, $me );
|
|
|
3062 |
|
|
|
3063 |
Debug2( "GenerateFiles: subs: $all -> $fn" );
|
|
|
3064 |
}
|
|
|
3065 |
|
|
|
3066 |
#
|
|
|
3067 |
# Save the tool arguments in an array
|
|
|
3068 |
#
|
|
|
3069 |
push @tool_args, $arg;
|
|
|
3070 |
}
|
|
|
3071 |
|
|
|
3072 |
|
|
|
3073 |
#
|
|
|
3074 |
# Sanity test. Ensure that some file have been marged as generated
|
|
|
3075 |
# Warn if no prerequisites found
|
|
|
3076 |
#
|
| 303 |
dpurdie |
3077 |
Warning( "GenerateFiles. --AutoGenerate option has no effect",
|
|
|
3078 |
"The following files are 'source' files", @has_source ) if ( @has_source );
|
| 227 |
dpurdie |
3079 |
Warning( "No Prerequisite files found in $tool",@tool_args) unless ( $no_warn || $#preq_files >= 0 );
|
|
|
3080 |
Error ( "No generated files found in $tool",@tool_args) unless ($#gen_files >= 0);
|
|
|
3081 |
|
|
|
3082 |
|
|
|
3083 |
#
|
|
|
3084 |
# Save information
|
|
|
3085 |
# Will be used to create makefile statements later
|
|
|
3086 |
#
|
|
|
3087 |
my %gen_data;
|
|
|
3088 |
|
|
|
3089 |
$gen_data{'index'} = $NoGenIndex++;
|
|
|
3090 |
$gen_data{'shell'} = $shell_cmds;
|
|
|
3091 |
$gen_data{'gen'} = \@gen_files;
|
|
|
3092 |
$gen_data{'preq'} = \@preq_files;
|
|
|
3093 |
$gen_data{'tool'} = $tool;
|
|
|
3094 |
$gen_data{'toolargs'} = \@tool_args;
|
|
|
3095 |
$gen_data{'clean'} = $clean_tag;
|
|
|
3096 |
$gen_data{'text'} = $text || $gen_files[0];
|
|
|
3097 |
$gen_data{'preq_sus'} = 1 if ( $preq_unknown );
|
| 263 |
dpurdie |
3098 |
$gen_data{'predelete'} = 1 if ( $predelete );
|
| 227 |
dpurdie |
3099 |
|
|
|
3100 |
push(@GENERATE_FILES, \%gen_data);
|
|
|
3101 |
|
|
|
3102 |
Debug2( "GenerateFiles: cmd: $tool @tool_args" );
|
|
|
3103 |
}
|
|
|
3104 |
|
|
|
3105 |
#-------------------------------------------------------------------------------
|
|
|
3106 |
# Function : MakePerlModule
|
|
|
3107 |
#
|
|
|
3108 |
# Description : Build Perl Module(s) using the Perl Build System
|
|
|
3109 |
# This is a thin wrapper around a specialised script
|
|
|
3110 |
#
|
|
|
3111 |
# The user can do the same job with correct use of
|
|
|
3112 |
# a GenerateFiles, but this is a lot tidier.
|
|
|
3113 |
#
|
|
|
3114 |
# Inputs : $1 - platform specifier '*' (comma delemitered)
|
|
|
3115 |
# $* - Paths to Perl Modules[,command options]
|
|
|
3116 |
# Options to the BuildPerl script
|
|
|
3117 |
#
|
|
|
3118 |
# Returns :
|
|
|
3119 |
#
|
|
|
3120 |
sub MakePerlModule
|
|
|
3121 |
{
|
|
|
3122 |
my ( $platforms, @args) = @_;
|
|
|
3123 |
|
|
|
3124 |
return if ( ! ActivePlatform($platforms) );
|
|
|
3125 |
|
|
|
3126 |
Debug2( "MakePerlModule:($platforms, @args)" );
|
|
|
3127 |
my @opts;
|
|
|
3128 |
|
|
|
3129 |
#
|
|
|
3130 |
# Extract options from paths to Perl Packages
|
|
|
3131 |
# Package names do not start with a '-'
|
|
|
3132 |
#
|
|
|
3133 |
foreach my $arg ( @args )
|
|
|
3134 |
{
|
|
|
3135 |
if ( $arg =~ /^-/ ) {
|
|
|
3136 |
push @opts, $arg;
|
|
|
3137 |
|
|
|
3138 |
} else {
|
|
|
3139 |
#
|
|
|
3140 |
# Perl Package Directory Name
|
|
|
3141 |
# This may also contain embedded command to the Make command
|
|
|
3142 |
# These will be seperated with a comma
|
|
|
3143 |
# ie: module,-options=fred
|
|
|
3144 |
#
|
|
|
3145 |
my ($name,$options) = split( ',', $arg );
|
|
|
3146 |
push @opts, "-PerlPackage=$arg";
|
|
|
3147 |
push @opts, "--Prereq=$name/Makefile.PL";
|
|
|
3148 |
}
|
|
|
3149 |
}
|
|
|
3150 |
|
|
|
3151 |
#
|
|
|
3152 |
# Invoke GenerateFiles with a bunch of additional arguments
|
|
|
3153 |
#
|
|
|
3154 |
GenerateFiles ($platforms, "--Tool=jats_buildperl.pl",
|
|
|
3155 |
'--Var(MachType)', # Build Machine type
|
|
|
3156 |
'--Var(PackageDir)', # Package dir
|
|
|
3157 |
'--NoGenerate', # Don't know the output
|
|
|
3158 |
'--Text=Make Perl Module', # Pretty print
|
|
|
3159 |
'--NoWarn',
|
|
|
3160 |
'--Clean=-clean_build', # Jats clean support
|
|
|
3161 |
'--NoVarTag', # No more Tags
|
|
|
3162 |
@opts,
|
|
|
3163 |
);
|
|
|
3164 |
}
|
|
|
3165 |
|
|
|
3166 |
#-------------------------------------------------------------------------------
|
|
|
3167 |
# Function : MakeLinuxDriver
|
|
|
3168 |
#
|
|
|
3169 |
# Description : Build a Linux Device Driver using the Linux Device Driver
|
|
|
3170 |
# Build System
|
|
|
3171 |
# This is a thin wrapper around a specialised script
|
|
|
3172 |
#
|
|
|
3173 |
# The user can do the same job with correct use of
|
|
|
3174 |
# a GenerateFiles, but this is a lot tidier.
|
|
|
3175 |
#
|
|
|
3176 |
# Inputs : $1 - platform specifier '*' (comma delemitered)
|
|
|
3177 |
# $2 - name of the driver. No extension
|
|
|
3178 |
# $* - Driver sources
|
|
|
3179 |
# Options to the script
|
|
|
3180 |
#
|
|
|
3181 |
# Returns :
|
|
|
3182 |
#
|
|
|
3183 |
sub MakeLinuxDriver
|
|
|
3184 |
{
|
|
|
3185 |
my ( $platforms, $driver_name, @args) = @_;
|
|
|
3186 |
|
|
|
3187 |
return if ( ! ActivePlatform($platforms) );
|
|
|
3188 |
|
| 285 |
dpurdie |
3189 |
Error ("No driver name specified") unless ( $driver_name );
|
| 227 |
dpurdie |
3190 |
Debug2( "MakeLinuxDriver:($platforms, $driver_name ,@args)" );
|
|
|
3191 |
my @srcs;
|
|
|
3192 |
my @opts;
|
|
|
3193 |
|
|
|
3194 |
#
|
|
|
3195 |
# Extract options from source files
|
|
|
3196 |
# Package names do not start with a '-'
|
|
|
3197 |
#
|
|
|
3198 |
foreach my $arg ( @args )
|
|
|
3199 |
{
|
|
|
3200 |
if ( $arg =~ /^--Define=(.)/ ) {
|
|
|
3201 |
push @opts, $arg;
|
|
|
3202 |
|
|
|
3203 |
} elsif ( $arg =~ /^-/ ) {
|
|
|
3204 |
push @opts, $arg;
|
|
|
3205 |
Warning ("MakeLinuxDriver: Unknown option: $arg. Passed to script");
|
|
|
3206 |
|
|
|
3207 |
} else {
|
|
|
3208 |
push @srcs, $arg;
|
|
|
3209 |
push @opts, "--Prereq=$arg";
|
|
|
3210 |
}
|
|
|
3211 |
}
|
|
|
3212 |
|
|
|
3213 |
#
|
|
|
3214 |
# Cleanup the drive name
|
|
|
3215 |
#
|
|
|
3216 |
$driver_name =~ s~\.ko$~~;
|
|
|
3217 |
|
|
|
3218 |
#
|
|
|
3219 |
# Remove the specified sources from the list of object files
|
|
|
3220 |
# that will be build. This will ensure that some internal rules are
|
|
|
3221 |
# not generated.
|
|
|
3222 |
#
|
|
|
3223 |
foreach ( @srcs )
|
|
|
3224 |
{
|
|
|
3225 |
my $file = StripExt(StripDir( $_ ));
|
|
|
3226 |
delete $OBJSOURCE{ $file };
|
|
|
3227 |
@OBJS = grep(!/^$file$/, @OBJS);
|
|
|
3228 |
}
|
|
|
3229 |
|
|
|
3230 |
#
|
|
|
3231 |
# Invoke GenerateFiles with a bunch of additional arguments
|
|
|
3232 |
# At runtime the include directories will be added as
|
|
|
3233 |
# absolute paths
|
|
|
3234 |
#
|
|
|
3235 |
GenerateFiles ($platforms, "--Tool=jats_buildlinux.pl",
|
|
|
3236 |
"-Output=--GeneratedProg($driver_name.ko)",
|
|
|
3237 |
"-Driver=$driver_name",
|
|
|
3238 |
"-GccPath=\$(GCC_CC)",
|
|
|
3239 |
"-Arch=\$(HOST_CPU)",
|
|
|
3240 |
"-LeaveTmp=\$(LEAVETMP)",
|
|
|
3241 |
"-Verbose=\$(CC_PRE)",
|
|
|
3242 |
"-Type=\$(GBE_TYPE)",
|
|
|
3243 |
"-Platform=\$(GBE_PLATFORM)",
|
|
|
3244 |
'$(patsubst %,-Incdir=%,$(INCDIRS))',
|
|
|
3245 |
@opts,
|
|
|
3246 |
@srcs
|
|
|
3247 |
);
|
|
|
3248 |
}
|
|
|
3249 |
|
|
|
3250 |
#-------------------------------------------------------------------------------
|
|
|
3251 |
# Function : GetPackageBase
|
|
|
3252 |
#
|
|
|
3253 |
# Description : Helper routine
|
|
|
3254 |
# Given a package name, determine the base address of the
|
|
|
3255 |
# package
|
|
|
3256 |
#
|
|
|
3257 |
# Inputs : $dname - Directive name (Reporting)
|
|
|
3258 |
# $name - Required package
|
|
|
3259 |
# Allows two forms:
|
|
|
3260 |
# package_name
|
|
|
3261 |
# package_name,ext
|
|
|
3262 |
#
|
|
|
3263 |
# Returns : Path to the directory in which the files are installed
|
|
|
3264 |
# This may be the interface directory
|
|
|
3265 |
#
|
|
|
3266 |
sub GetPackageBase
|
|
|
3267 |
{
|
|
|
3268 |
my ($dname, $fname) = @_;
|
|
|
3269 |
my $pkg;
|
|
|
3270 |
my ($name, $ext) = split(',', $fname);
|
|
|
3271 |
|
|
|
3272 |
$pkg = GetPackageEntry( $name, $ext );
|
|
|
3273 |
Error ("$dname: Package not found: $fname") unless ( $pkg );
|
|
|
3274 |
|
|
|
3275 |
#
|
|
|
3276 |
# If a BuildPkgArchive then use the interface directory
|
|
|
3277 |
#
|
|
|
3278 |
return ( $pkg->{'TYPE'} eq 'link' ) ? $pkg->{'ROOT'} : '$(INTERFACEDIR)';
|
|
|
3279 |
}
|
|
|
3280 |
|
|
|
3281 |
#-------------------------------------------------------------------------------
|
|
|
3282 |
# Function : GetPackageInfo
|
|
|
3283 |
#
|
|
|
3284 |
# Description : Helper routine
|
|
|
3285 |
# Given a package name, return some information about the package
|
|
|
3286 |
# Only one information item is allowed with each call
|
|
|
3287 |
#
|
|
|
3288 |
# Inputs : $dname - Directive name (Reporting)
|
|
|
3289 |
# $name - Required package
|
|
|
3290 |
# Allows two forms:
|
|
|
3291 |
# package_name
|
|
|
3292 |
# package_name,ext
|
|
|
3293 |
# Selector
|
|
|
3294 |
# --path
|
|
|
3295 |
# --version
|
|
|
3296 |
# --fullversion
|
|
|
3297 |
# --project
|
|
|
3298 |
#
|
|
|
3299 |
# Returns : Package information
|
|
|
3300 |
my %GetPackageInfo = qw(path ROOT
|
|
|
3301 |
version DVERSION
|
|
|
3302 |
fullversion VERSION
|
|
|
3303 |
project DPROJ);
|
|
|
3304 |
sub GetPackageInfo
|
|
|
3305 |
{
|
|
|
3306 |
my ($dname, $args) = @_;
|
|
|
3307 |
my $pkg;
|
|
|
3308 |
my $name;
|
|
|
3309 |
my $ext;
|
|
|
3310 |
my $info;
|
|
|
3311 |
|
| 363 |
dpurdie |
3312 |
#
|
|
|
3313 |
# Split up the arguments
|
|
|
3314 |
# Options start with '--'
|
|
|
3315 |
# First non-option is the package name
|
|
|
3316 |
# 2nd non-option is the packag extension
|
|
|
3317 |
#
|
|
|
3318 |
# Only one option allowed
|
|
|
3319 |
# Convert it into a known package info item
|
|
|
3320 |
#
|
|
|
3321 |
#
|
| 227 |
dpurdie |
3322 |
foreach ( split(',', $args) )
|
|
|
3323 |
{
|
|
|
3324 |
if ( m/^--(.*)/ ) {
|
|
|
3325 |
Error( "$dname: Too many info requests: $args") if ( $info );
|
|
|
3326 |
$info = $GetPackageInfo{$1};
|
|
|
3327 |
Error( "$dname: Unknown info type: $_") unless ($info);
|
| 363 |
dpurdie |
3328 |
|
| 227 |
dpurdie |
3329 |
} elsif ( $ext ) {
|
|
|
3330 |
Error("$dname: Too many names: $args");
|
| 363 |
dpurdie |
3331 |
|
| 227 |
dpurdie |
3332 |
} elsif ( $name ) {
|
|
|
3333 |
$ext = $_;
|
| 363 |
dpurdie |
3334 |
|
| 227 |
dpurdie |
3335 |
} else {
|
|
|
3336 |
$name = $_;
|
|
|
3337 |
}
|
|
|
3338 |
}
|
|
|
3339 |
|
|
|
3340 |
$pkg = GetPackageEntry( $name, $ext );
|
|
|
3341 |
Error ("$dname: Package not found: $args") unless ( $pkg );
|
|
|
3342 |
|
|
|
3343 |
#
|
|
|
3344 |
# If a BuildPkgArchive then use the interface directory
|
| 363 |
dpurdie |
3345 |
# Default data item - path to the package
|
| 227 |
dpurdie |
3346 |
#
|
| 363 |
dpurdie |
3347 |
$info = 'ROOT' unless ( $info );
|
|
|
3348 |
if ( $info eq 'ROOT' && $pkg->{'TYPE'} ne 'link' )
|
| 227 |
dpurdie |
3349 |
{
|
|
|
3350 |
return ( '$(INTERFACEDIR)');
|
|
|
3351 |
}
|
| 363 |
dpurdie |
3352 |
|
| 227 |
dpurdie |
3353 |
return ( $pkg->{$info} );
|
|
|
3354 |
}
|
|
|
3355 |
|
|
|
3356 |
#-------------------------------------------------------------------------------
|
|
|
3357 |
# Function : GetPackageEntry
|
|
|
3358 |
#
|
|
|
3359 |
# Description : Return the package class pointer given a package name
|
|
|
3360 |
#
|
|
|
3361 |
# Inputs : $name - Required package
|
|
|
3362 |
# $ext - Option package extension
|
|
|
3363 |
#
|
|
|
3364 |
# Returns : Class pointer
|
|
|
3365 |
#
|
|
|
3366 |
sub GetPackageEntry
|
|
|
3367 |
{
|
|
|
3368 |
my ($name, $ext) = @_;
|
|
|
3369 |
$ext = '' unless ( $ext );
|
|
|
3370 |
|
|
|
3371 |
for my $entry (@{$::ScmBuildPkgRules{$ScmPlatform} })
|
|
|
3372 |
{
|
|
|
3373 |
next unless ( $entry->{'NAME'} eq $name );
|
|
|
3374 |
next if ( $ext && $entry->{'DPROJ'} ne $ext );
|
|
|
3375 |
return $entry;
|
|
|
3376 |
}
|
| 285 |
dpurdie |
3377 |
return;
|
| 227 |
dpurdie |
3378 |
}
|
|
|
3379 |
|
|
|
3380 |
#-------------------------------------------------------------------------------
|
|
|
3381 |
# Function : ExpandGenVar
|
|
|
3382 |
#
|
|
|
3383 |
# Description : Expand a known variable for the Generate Files option
|
|
|
3384 |
#
|
|
|
3385 |
# Inputs : $dname - Directive name (Reporting)
|
|
|
3386 |
# $arg - Raw argument
|
|
|
3387 |
# This of the form of
|
|
|
3388 |
# Tag[,--option]+
|
|
|
3389 |
# Tags are specified in %ExpandGenVarConvert
|
|
|
3390 |
#
|
|
|
3391 |
# Options are:
|
|
|
3392 |
# --tag
|
|
|
3393 |
# --notag
|
|
|
3394 |
# --tag=<SomeTag>
|
|
|
3395 |
# --absdrive
|
|
|
3396 |
# --abspath
|
| 285 |
dpurdie |
3397 |
# --default=text
|
| 343 |
dpurdie |
3398 |
# --allownone
|
| 227 |
dpurdie |
3399 |
# Not all options are avalaible on all variables
|
|
|
3400 |
# @opts - Options
|
|
|
3401 |
# --notag - Default is --notag
|
|
|
3402 |
#
|
| 343 |
dpurdie |
3403 |
# Returns : Tag - Any tag component of the expansion
|
|
|
3404 |
# Path/Value - Path/Value of the component
|
|
|
3405 |
# is_path - Above is a path
|
|
|
3406 |
# is_abs - Path is absolute
|
| 227 |
dpurdie |
3407 |
#
|
|
|
3408 |
|
|
|
3409 |
#
|
|
|
3410 |
# Create a Hash to simplify the process of converting Var names
|
| 343 |
dpurdie |
3411 |
# into makefile variables. There are two data items, separated by a comma.
|
|
|
3412 |
# The first is the runtime expansion value
|
|
|
3413 |
# The second describes the first:
|
|
|
3414 |
# NotPresent - Expansion is not a path
|
|
|
3415 |
# '-' - Expansion is a path and is relative to CWD
|
|
|
3416 |
# '+' - Expansion is a path and is absolute
|
| 227 |
dpurdie |
3417 |
#
|
|
|
3418 |
my %ExpandGenVarConvert = (
|
|
|
3419 |
'BuildName' => '$(GBE_PBASE)',
|
|
|
3420 |
'BuildVersion' => '$(BUILDVER)',
|
|
|
3421 |
'BuildVersionNum' => '$(BUILDVERNUM)',
|
|
|
3422 |
|
|
|
3423 |
'PackageDir' => '$(PKGDIR),+',
|
|
|
3424 |
'PackagePkgDir' => '$(PKGDIR)/pkg/pkg.$(GBE_PLATFORM),+',
|
|
|
3425 |
'PackageIncDir' => '$(INCDIR_PKG),+',
|
|
|
3426 |
'PackageLibDir' => '$(LIBDIR_PKG)/$(GBE_PLATFORM),+',
|
|
|
3427 |
'PackageBinDir' => '$(BINDIR_PKG)/$(GBE_PLATFORM)$(GBE_TYPE),+',
|
|
|
3428 |
|
|
|
3429 |
'PackageToolDir' => '$(PKGDIR)/tools,+',
|
|
|
3430 |
'PackageToolBin' => '$(PKGDIR)/tools/bin/$(GBE_HOSTMACH),+',
|
|
|
3431 |
'PackageToolScript' => '$(PKGDIR)/tools/scripts,+',
|
|
|
3432 |
|
|
|
3433 |
'LibDir' => '$(LIBDIR),+',
|
|
|
3434 |
'BinDir' => '$(BINDIR),+',
|
|
|
3435 |
'ObjDir' => '$(OBJDIR),+',
|
|
|
3436 |
|
|
|
3437 |
'InterfaceDir' => '$(INTERFACEDIR),+',
|
|
|
3438 |
'InterfaceIncDir' => '$(INCDIR_INTERFACE),+',
|
|
|
3439 |
'InterfaceLibDir' => '$(LIBDIR_INTERFACE)/$(GBE_PLATFORM),+',
|
|
|
3440 |
'InterfaceBinDir' => '$(BINDIR_INTERFACE)/$(GBE_PLATFORM)$(GBE_TYPE),+',
|
|
|
3441 |
|
|
|
3442 |
'LocalDir' => '$(LOCALDIR),+',
|
|
|
3443 |
'LocalIncDir' => '$(INCDIR_LOCAL),+',
|
|
|
3444 |
'LocalLibDir' => '$(LIBDIR_LOCAL)/$(GBE_PLATFORM),+',
|
|
|
3445 |
'LocalBinDir' => '$(BINDIR_LOCAL)/$(GBE_PLATFORM)$(GBE_TYPE),+',
|
|
|
3446 |
|
|
|
3447 |
'Platform' => '$(GBE_PLATFORM)',
|
|
|
3448 |
'Product' => '$(GBE_PRODUCT)',
|
|
|
3449 |
'Target' => '$(GBE_TARGET)',
|
|
|
3450 |
|
|
|
3451 |
'Type' => '$(GBE_TYPE)',
|
|
|
3452 |
'Arch' => '$(HOST_CPU)',
|
|
|
3453 |
'Architecture' => '$(HOST_CPU)',
|
|
|
3454 |
'MachType' => '$(GBE_HOSTMACH)',
|
|
|
3455 |
'BuildRoot' => '$(GBE_ROOT),+',
|
|
|
3456 |
|
|
|
3457 |
|
|
|
3458 |
'Verbose' => '$(CC_PRE)',
|
|
|
3459 |
'LeaveTmp' => '$(LEAVETMP)',
|
| 329 |
dpurdie |
3460 |
'Cwd' => '$(CURDIR),-',
|
| 227 |
dpurdie |
3461 |
|
|
|
3462 |
'CompilerPath' => '$(SCM_COMPILERPATH)',
|
|
|
3463 |
);
|
|
|
3464 |
|
|
|
3465 |
sub ExpandGenVar
|
|
|
3466 |
{
|
|
|
3467 |
my ($dname, $args, @uopts) = @_;
|
|
|
3468 |
my $expansion;
|
|
|
3469 |
my $prefix='';
|
|
|
3470 |
my ($tag, @opts) = split('\s*,\s*', $args);
|
|
|
3471 |
my $no_prefix;
|
| 285 |
dpurdie |
3472 |
my $default_value;
|
|
|
3473 |
my $allow_none;
|
| 329 |
dpurdie |
3474 |
my $is_abs = 0;
|
| 227 |
dpurdie |
3475 |
|
| 285 |
dpurdie |
3476 |
#
|
|
|
3477 |
# Parse options lists
|
|
|
3478 |
# Options provided by the caller
|
|
|
3479 |
# Options embedded in the argument
|
| 227 |
dpurdie |
3480 |
foreach ( @uopts )
|
|
|
3481 |
{
|
|
|
3482 |
if ( m/^--notag$/ ) {
|
|
|
3483 |
$no_prefix = 1;
|
|
|
3484 |
} else{
|
|
|
3485 |
Error ("$dname: Unknown option: $_")
|
|
|
3486 |
}
|
|
|
3487 |
}
|
|
|
3488 |
|
| 285 |
dpurdie |
3489 |
foreach ( @opts )
|
|
|
3490 |
{
|
|
|
3491 |
if ( m/^--default=(.+)/i ) {
|
|
|
3492 |
$default_value = $1;
|
|
|
3493 |
} elsif ( m/^--allownone$/i ) {
|
|
|
3494 |
$allow_none = 1;
|
|
|
3495 |
}
|
|
|
3496 |
}
|
|
|
3497 |
|
| 227 |
dpurdie |
3498 |
#
|
|
|
3499 |
# Perform run-time update on the %ExpandGenVarConvert
|
|
|
3500 |
# Most of it can be initialised at startup - but not all of it.
|
|
|
3501 |
#
|
|
|
3502 |
$ExpandGenVarConvert{CompilerPath} = undef unless $::ScmToolsetCompilerPath;
|
|
|
3503 |
$ExpandGenVarConvert{Product} = '$(GBE_PLATFORM)' unless $ScmProduct;
|
|
|
3504 |
|
|
|
3505 |
#
|
|
|
3506 |
# Look up a hash of conversions
|
|
|
3507 |
# Could allow for a code ref, but not needed yet
|
|
|
3508 |
#
|
|
|
3509 |
Error ("$dname: Unknown expansion --Var($tag)")
|
|
|
3510 |
unless ( exists $ExpandGenVarConvert{$tag} );
|
|
|
3511 |
|
| 285 |
dpurdie |
3512 |
#
|
|
|
3513 |
# Handle undefined expansions
|
|
|
3514 |
# Only 'CompilerPath', but it can be a pain in user land
|
|
|
3515 |
#
|
|
|
3516 |
$expansion = $ExpandGenVarConvert{$tag};
|
|
|
3517 |
unless ( defined $expansion )
|
|
|
3518 |
{
|
|
|
3519 |
return '' if ( $allow_none );
|
|
|
3520 |
$expansion = $default_value;
|
|
|
3521 |
Error ("$dname: Expansion --Var($tag) not be supported by toolset: $ScmToolset")
|
|
|
3522 |
unless ( $expansion );
|
|
|
3523 |
}
|
| 227 |
dpurdie |
3524 |
|
| 285 |
dpurdie |
3525 |
|
| 227 |
dpurdie |
3526 |
($expansion,my $is_path) = split (',', $expansion );
|
| 329 |
dpurdie |
3527 |
$is_abs = 1
|
|
|
3528 |
if ($is_path && $is_path eq '-' );
|
| 227 |
dpurdie |
3529 |
|
|
|
3530 |
#
|
|
|
3531 |
# Process options
|
|
|
3532 |
# Assume that a tag will be provided
|
|
|
3533 |
#
|
|
|
3534 |
$prefix = $no_prefix ? '' : "-$tag=";
|
|
|
3535 |
foreach my $opt ( @opts )
|
|
|
3536 |
{
|
|
|
3537 |
if ( $opt =~ /^--tag=(.*)/i ) {
|
|
|
3538 |
$prefix = "$1=";
|
|
|
3539 |
|
|
|
3540 |
} elsif ( $opt =~ m/^--tag$/i ) {
|
|
|
3541 |
$prefix = "-$tag=";
|
|
|
3542 |
|
|
|
3543 |
} elsif ( $opt =~ m/^--notag/i ) {
|
|
|
3544 |
$prefix = '';
|
|
|
3545 |
|
| 329 |
dpurdie |
3546 |
} elsif ( $is_path && !$is_abs && $opt =~ /--abspath|--absdrive/i ) {
|
| 227 |
dpurdie |
3547 |
$expansion = '$(CURDIR)/' . $expansion;
|
| 329 |
dpurdie |
3548 |
$is_abs = 1;
|
| 227 |
dpurdie |
3549 |
|
| 285 |
dpurdie |
3550 |
} elsif ( $opt =~ m/^--default=(.+)/i ) {
|
|
|
3551 |
# Already processed
|
|
|
3552 |
} elsif ( $opt =~ m/^--allownone$/i ) {
|
|
|
3553 |
# Already processed
|
| 227 |
dpurdie |
3554 |
} else {
|
|
|
3555 |
Error ("$dname: Unsupported option($opt) for --Var(@_)");
|
|
|
3556 |
}
|
|
|
3557 |
}
|
|
|
3558 |
|
|
|
3559 |
Debug ("ExpandGenVar: args $args --> $prefix$expansion");
|
| 343 |
dpurdie |
3560 |
return $prefix , $expansion, $is_path ? 1 : 0, $is_abs;
|
| 227 |
dpurdie |
3561 |
|
|
|
3562 |
}
|
|
|
3563 |
|
|
|
3564 |
#-------------------------------------------------------------------------------
|
|
|
3565 |
# Function : ProcessPathName
|
|
|
3566 |
#
|
|
|
3567 |
# Description : Massage a pathname according to a set of flags
|
|
|
3568 |
#
|
|
|
3569 |
# Inputs : $fn - Patchname to massage
|
|
|
3570 |
# $flags - Flags in a string
|
|
|
3571 |
# --dir - only the directory part ( or a "." )
|
|
|
3572 |
# --file - only the file part
|
|
|
3573 |
# --abspath - Absolute path
|
|
|
3574 |
# --absdrive - Absolute path with drive letter(WIN)
|
|
|
3575 |
#
|
|
|
3576 |
# Returns : Massaged pathname
|
|
|
3577 |
#
|
|
|
3578 |
sub ProcessPathName
|
|
|
3579 |
{
|
|
|
3580 |
my ( $fn, $flags ) = @_;
|
|
|
3581 |
#
|
|
|
3582 |
# Process flags
|
|
|
3583 |
# --dir - only the directory part ( or a "." )
|
|
|
3584 |
# --file - only the file part
|
|
|
3585 |
# --abspath - Absolute path
|
|
|
3586 |
# --absdrive - Absolute path with drive letter(WIN)
|
|
|
3587 |
#
|
|
|
3588 |
if ( $flags =~ /--dir/ )
|
|
|
3589 |
{
|
|
|
3590 |
$fn = '.'
|
|
|
3591 |
unless ( $fn =~ s~/[^/]*$~~);
|
|
|
3592 |
}
|
|
|
3593 |
|
|
|
3594 |
if ( $flags =~ /--file/ )
|
|
|
3595 |
{
|
|
|
3596 |
$fn =~ s~.*/~~;
|
|
|
3597 |
}
|
|
|
3598 |
|
|
|
3599 |
if ( $flags =~ /--abspath/ )
|
|
|
3600 |
{
|
|
|
3601 |
$fn = AbsPath( $fn );
|
|
|
3602 |
}
|
|
|
3603 |
elsif ( $flags =~ /--absdrive/ )
|
|
|
3604 |
{
|
|
|
3605 |
$fn = AbsPath( $fn );
|
|
|
3606 |
if ( $::ScmHost eq "WIN" )
|
|
|
3607 |
{
|
|
|
3608 |
$fn = $::CwdDrive . '/' . $fn
|
|
|
3609 |
unless ( $fn =~ m~^\w:/~ );
|
|
|
3610 |
$fn =~ s~//~/~g;
|
|
|
3611 |
}
|
|
|
3612 |
}
|
|
|
3613 |
|
|
|
3614 |
return $fn;
|
|
|
3615 |
}
|
|
|
3616 |
|
|
|
3617 |
#-------------------------------------------------------------------------------
|
|
|
3618 |
# Function : LocatePreReq
|
|
|
3619 |
#
|
|
|
3620 |
# Description : Locate a file known to JATS
|
|
|
3621 |
# There are many places to search
|
|
|
3622 |
# 1) Src files - specified with a Src directive
|
|
|
3623 |
# 2) Scripts - specified with a script directive
|
|
|
3624 |
# 3) Search - Files in the specified search path
|
|
|
3625 |
# 4) Programs specified with a 'Prog' directive
|
|
|
3626 |
#
|
|
|
3627 |
# Should also look in other locations (Libs, SharedLibs)
|
|
|
3628 |
# Not done yet. May be issues of a name clash if a program
|
|
|
3629 |
# and a library have the same name.
|
|
|
3630 |
#
|
|
|
3631 |
# Inputs : Name to locate
|
|
|
3632 |
#
|
|
|
3633 |
# Returns : Full pathname of file
|
|
|
3634 |
#
|
|
|
3635 |
sub LocatePreReq
|
|
|
3636 |
{
|
|
|
3637 |
my ( $name ) = @_;
|
|
|
3638 |
Debug ("LocatePreReq:Looking for $name");
|
|
|
3639 |
#
|
|
|
3640 |
# Try a Src file first
|
|
|
3641 |
#
|
|
|
3642 |
if ( exists $SRCS{ $name } )
|
|
|
3643 |
{
|
|
|
3644 |
return $SRCS{ $name };
|
|
|
3645 |
}
|
|
|
3646 |
|
|
|
3647 |
#
|
|
|
3648 |
# Try a script
|
|
|
3649 |
#
|
|
|
3650 |
if ( exists $SCRIPTS{ $name } )
|
|
|
3651 |
{
|
|
|
3652 |
return $SCRIPTS{ $name };
|
|
|
3653 |
}
|
|
|
3654 |
|
|
|
3655 |
#
|
|
|
3656 |
# Try a PROG
|
|
|
3657 |
#
|
| 289 |
dpurdie |
3658 |
if ( my $pProg = $PROGS->Get($name) )
|
| 227 |
dpurdie |
3659 |
{
|
| 289 |
dpurdie |
3660 |
return $pProg->getPath();
|
| 227 |
dpurdie |
3661 |
}
|
|
|
3662 |
|
|
|
3663 |
#
|
|
|
3664 |
# Try searching for the file
|
|
|
3665 |
# Uses Data from AddSrcDir
|
|
|
3666 |
#
|
|
|
3667 |
# Done: last because it generates warning messages
|
|
|
3668 |
#
|
|
|
3669 |
return MakeSrcResolve( $name );
|
|
|
3670 |
}
|
|
|
3671 |
|
|
|
3672 |
#-------------------------------------------------------------------------------
|
|
|
3673 |
# Function : ToolExtensionPaths
|
|
|
3674 |
#
|
|
|
3675 |
# Description : Return a list of toolset extension directories
|
|
|
3676 |
# The data will have been discovered by the build process
|
|
|
3677 |
# and will have been saved for the makefile creation phase
|
|
|
3678 |
#
|
|
|
3679 |
# Inputs : None
|
|
|
3680 |
#
|
|
|
3681 |
# Returns : Return an ordered unique list
|
|
|
3682 |
#
|
|
|
3683 |
sub ToolExtensionPaths
|
|
|
3684 |
{
|
|
|
3685 |
Debug( "ToolExtensionPaths:", @::BUILDTOOLSPATH );
|
|
|
3686 |
return @::BUILDTOOLSPATH;
|
|
|
3687 |
}
|
|
|
3688 |
|
|
|
3689 |
#-------------------------------------------------------------------------------
|
|
|
3690 |
# Function : ToolExtensionProgram
|
|
|
3691 |
#
|
|
|
3692 |
# Description : Determine if the named program exists within the PATH
|
|
|
3693 |
# that also includes the toolset extension
|
|
|
3694 |
#
|
|
|
3695 |
# Inputs : program - Name of program
|
|
|
3696 |
# elist - An array of possible program extensions
|
|
|
3697 |
#
|
|
|
3698 |
# Returns : Full path the to program or undef
|
|
|
3699 |
#
|
|
|
3700 |
sub ToolExtensionProgram
|
|
|
3701 |
{
|
|
|
3702 |
my ($program, @elist ) = @_;
|
|
|
3703 |
|
|
|
3704 |
#
|
|
|
3705 |
# If elist is empty then insert a defined entry
|
|
|
3706 |
#
|
|
|
3707 |
push @elist, '' unless ( @elist );
|
|
|
3708 |
|
|
|
3709 |
#
|
|
|
3710 |
# Scan all toolset directories
|
|
|
3711 |
# for the program
|
|
|
3712 |
#
|
|
|
3713 |
for my $dir ( ToolExtensionPaths() )
|
|
|
3714 |
{
|
|
|
3715 |
for my $ext ( @elist )
|
|
|
3716 |
{
|
|
|
3717 |
my $tool = "$dir/$program$ext";
|
|
|
3718 |
Debug2( "ToolsetExtensionProgram: Look for: $tool" );
|
|
|
3719 |
|
|
|
3720 |
return $tool if ( -f $tool );
|
|
|
3721 |
}
|
|
|
3722 |
}
|
|
|
3723 |
}
|
|
|
3724 |
|
|
|
3725 |
sub Define
|
|
|
3726 |
{
|
|
|
3727 |
Debug2( "Define(@_)" );
|
|
|
3728 |
|
|
|
3729 |
push( @DEFINES, @_ );
|
|
|
3730 |
}
|
|
|
3731 |
|
|
|
3732 |
|
|
|
3733 |
sub Defines
|
|
|
3734 |
{
|
|
|
3735 |
my( $path, $script ) = @_;
|
|
|
3736 |
my( $line );
|
|
|
3737 |
|
|
|
3738 |
Debug2( "Defines($path, $script)" );
|
|
|
3739 |
|
|
|
3740 |
$script = Exists( $path, $script, "Defines" );
|
| 271 |
dpurdie |
3741 |
push( @DEFINES, "# Defines from: $script" );
|
| 285 |
dpurdie |
3742 |
open( my $fh, '<', $script ) || Error( "Opening $script" );
|
|
|
3743 |
while (<$fh>) {
|
| 227 |
dpurdie |
3744 |
$_ =~ s/\s*(\n|$)//; # kill trailing whitespace & nl
|
|
|
3745 |
push( @DEFINES, $_ );
|
|
|
3746 |
}
|
|
|
3747 |
push( @ScmDepends, "$script" ); # makefile dependencies
|
| 285 |
dpurdie |
3748 |
close( $fh );
|
| 227 |
dpurdie |
3749 |
}
|
| 271 |
dpurdie |
3750 |
#-------------------------------------------------------------------------------
|
|
|
3751 |
# Function : Rule
|
|
|
3752 |
#
|
|
|
3753 |
# Description : Add a Rule and Recipe to the generated makefile
|
|
|
3754 |
# This is not encouraged as it has been misused to create
|
|
|
3755 |
# unreadable and unmaintainable makefiles.
|
|
|
3756 |
#
|
|
|
3757 |
# Rules will be added to the makefile after the rules and
|
|
|
3758 |
# recipes created by JATS directives
|
|
|
3759 |
#
|
|
|
3760 |
# Inputs : $platform - Platform predicate
|
|
|
3761 |
# @rule - Array of rules to add
|
|
|
3762 |
#
|
|
|
3763 |
# Returns :
|
|
|
3764 |
#
|
| 227 |
dpurdie |
3765 |
sub Rule
|
|
|
3766 |
{
|
|
|
3767 |
my( $platforms, @rule ) = @_;
|
|
|
3768 |
|
|
|
3769 |
return if ( ! ActivePlatform($platforms) );
|
|
|
3770 |
|
|
|
3771 |
push( @RULES, @rule );
|
|
|
3772 |
Message("Rule directive used. Consider replacing with GenerateFiles");
|
|
|
3773 |
}
|
|
|
3774 |
|
| 271 |
dpurdie |
3775 |
#-------------------------------------------------------------------------------
|
|
|
3776 |
# Function : Rules
|
|
|
3777 |
#
|
|
|
3778 |
# Description : Add a file of Rules and Recipes to the generated makefile
|
|
|
3779 |
# Used internally ONLY as there is no platform predicate
|
|
|
3780 |
# Similar to 'Rule()'
|
|
|
3781 |
#
|
|
|
3782 |
# Inputs : $path - path to script
|
|
|
3783 |
# $script - File fo Rules
|
|
|
3784 |
#
|
|
|
3785 |
# Returns :
|
|
|
3786 |
#
|
| 227 |
dpurdie |
3787 |
sub Rules
|
|
|
3788 |
{
|
|
|
3789 |
my( $path, $script ) = @_;
|
|
|
3790 |
my( $line );
|
|
|
3791 |
|
|
|
3792 |
$script = Exists( $path, $script, "Rules" );
|
| 271 |
dpurdie |
3793 |
push( @RULES, "# Rules from: $script" );
|
| 285 |
dpurdie |
3794 |
open( my $fh, '<', $script ) || Error( "Opening $script" );
|
|
|
3795 |
while (<$fh>) {
|
| 227 |
dpurdie |
3796 |
$_ =~ s/\s*(\n|$)//; # kill trailing whitespace & nl
|
|
|
3797 |
push( @RULES, $_ );
|
|
|
3798 |
}
|
|
|
3799 |
push( @ScmDepends, "$script" ); # makefile dependencies
|
| 285 |
dpurdie |
3800 |
close( $fh );
|
| 227 |
dpurdie |
3801 |
}
|
|
|
3802 |
|
| 271 |
dpurdie |
3803 |
#-------------------------------------------------------------------------------
|
|
|
3804 |
# Function : AddRule
|
|
|
3805 |
#
|
|
|
3806 |
# Description : Inernal function
|
|
|
3807 |
# Add a line to the Rules area
|
|
|
3808 |
#
|
|
|
3809 |
# Inputs : @elements - Array of lines to add
|
|
|
3810 |
#
|
|
|
3811 |
# Returns : Nothing
|
|
|
3812 |
#
|
|
|
3813 |
sub AddRule
|
|
|
3814 |
{
|
|
|
3815 |
push( @RULES, @_ );
|
|
|
3816 |
}
|
| 227 |
dpurdie |
3817 |
|
| 271 |
dpurdie |
3818 |
#-------------------------------------------------------------------------------
|
|
|
3819 |
# Function : Src
|
|
|
3820 |
#
|
|
|
3821 |
# Description : This directive is used to identify files to JATS
|
|
|
3822 |
# Once a file has been identified as a 'Source' file, then it
|
|
|
3823 |
# can be used by name, without the need to locate the file again.
|
|
|
3824 |
# This implies that filenames must be unique.
|
|
|
3825 |
# The directories cannot be used to make files of the same name
|
|
|
3826 |
# unqiue - this is not the JATS way
|
|
|
3827 |
#
|
|
|
3828 |
# Source files will be classified as one of:
|
|
|
3829 |
# c, c++, header, assembler or other
|
|
|
3830 |
#
|
|
|
3831 |
#
|
|
|
3832 |
# Inputs : $platform - Active Platform Predicate
|
|
|
3833 |
# @elements - A list of files and options
|
|
|
3834 |
#
|
|
|
3835 |
# Valid options are:
|
|
|
3836 |
# --c - Specifies the type of file
|
|
|
3837 |
# --cpp
|
|
|
3838 |
# --h, --headers
|
|
|
3839 |
# --asm
|
|
|
3840 |
# --FromPackage - Search packages for the file
|
|
|
3841 |
# --List=xxx - Append file to a named list
|
|
|
3842 |
# --Depends=xxx - Manually name a dependency
|
|
|
3843 |
#
|
|
|
3844 |
# Options are processed before file elements
|
|
|
3845 |
# Thus options apply to all files in the list
|
|
|
3846 |
#
|
|
|
3847 |
# Returns : Nothing
|
|
|
3848 |
#
|
| 227 |
dpurdie |
3849 |
sub Src
|
|
|
3850 |
{
|
|
|
3851 |
my( $platforms, @elements ) = @_;
|
|
|
3852 |
my( $type, @args, $source, $basename, $from_package, @lists );
|
|
|
3853 |
my( @depends, @srcs );
|
|
|
3854 |
|
|
|
3855 |
$platforms = '' unless ( $platforms );
|
|
|
3856 |
Debug2( "Src($platforms, @elements)" );
|
|
|
3857 |
|
|
|
3858 |
#
|
|
|
3859 |
# Ensure that there is a file within the list
|
|
|
3860 |
#
|
|
|
3861 |
Warning( "Src directive does not specify any files: Src($platforms, @elements)" )
|
|
|
3862 |
unless (grep( /^[^-]/, @elements ) );
|
|
|
3863 |
|
|
|
3864 |
return if ( ! ActivePlatform($platforms) );
|
|
|
3865 |
|
|
|
3866 |
#
|
|
|
3867 |
# Remove spaces from both ends of the arguments.
|
|
|
3868 |
# It is easier to remove spaces now than to detect them later
|
|
|
3869 |
#
|
|
|
3870 |
foreach ( @elements )
|
|
|
3871 |
{
|
|
|
3872 |
s/^\s+//;
|
|
|
3873 |
s/\s+$//;
|
|
|
3874 |
s~//~/~g; # Remove multiple /
|
|
|
3875 |
}
|
|
|
3876 |
|
|
|
3877 |
#.. Collect arguments
|
|
|
3878 |
#
|
|
|
3879 |
$type = "";
|
|
|
3880 |
foreach ( @elements )
|
|
|
3881 |
{
|
|
|
3882 |
if ( /^--c$/ )
|
|
|
3883 |
{
|
|
|
3884 |
Debug( "Src: --c" );
|
|
|
3885 |
$type = ".c";
|
|
|
3886 |
}
|
|
|
3887 |
elsif ( /^--cpp$/ )
|
|
|
3888 |
{
|
|
|
3889 |
Debug( "Src: --cpp" );
|
|
|
3890 |
$type = ".cc";
|
|
|
3891 |
}
|
|
|
3892 |
elsif ( /^--h$/ || /^--header$/ )
|
|
|
3893 |
{
|
|
|
3894 |
Debug( "Src: --h" );
|
|
|
3895 |
$type = ".h";
|
|
|
3896 |
}
|
|
|
3897 |
elsif ( /^--asm$/ )
|
|
|
3898 |
{
|
|
|
3899 |
Debug( "Src: --asm" );
|
|
|
3900 |
$type = ".asm";
|
|
|
3901 |
}
|
|
|
3902 |
elsif ( /^--FromPackage$/ )
|
|
|
3903 |
{
|
|
|
3904 |
$from_package = 1;
|
|
|
3905 |
}
|
|
|
3906 |
elsif ( /^--List=(.*)/ )
|
|
|
3907 |
{
|
|
|
3908 |
my $list_name = $1;
|
|
|
3909 |
Error( "Bad list name: $list_name" )
|
|
|
3910 |
unless ( $list_name =~ m/^[A-Za-z]\w+/ );
|
|
|
3911 |
push @lists, $list_name;
|
|
|
3912 |
}
|
|
|
3913 |
elsif ( /^--Depends=(.*)/ )
|
|
|
3914 |
{
|
|
|
3915 |
foreach ( split( ',', $1) )
|
|
|
3916 |
{
|
|
|
3917 |
my $full = MakeSrcResolveExtended( $from_package, $_ );
|
|
|
3918 |
push @depends, $full;
|
|
|
3919 |
}
|
|
|
3920 |
}
|
|
|
3921 |
elsif ( /^-(.*)/ )
|
|
|
3922 |
{
|
|
|
3923 |
Debug( "Src: arg $_" );
|
|
|
3924 |
push @args, $_;
|
|
|
3925 |
}
|
|
|
3926 |
else
|
|
|
3927 |
{
|
|
|
3928 |
push @srcs, $_;
|
|
|
3929 |
Warning ("Src files contains a '\\' character: $_" ) if (m~\\~);
|
|
|
3930 |
}
|
|
|
3931 |
}
|
|
|
3932 |
|
|
|
3933 |
#.. Push source file(s)
|
|
|
3934 |
foreach ( @srcs )
|
|
|
3935 |
{
|
|
|
3936 |
if ( ! /^-(.*)/ )
|
|
|
3937 |
{
|
|
|
3938 |
$source = MakeSrcResolveExtended( $from_package, $_ );
|
|
|
3939 |
$basename = StripDir( $source );
|
|
|
3940 |
Debug( "Src: $_ -> $source=$basename (@args),(@depends)" );
|
|
|
3941 |
|
|
|
3942 |
if ( $SRCS{ $basename } ) {
|
|
|
3943 |
Warning( "Duplicate src ignored '$source'");
|
|
|
3944 |
next;
|
|
|
3945 |
}
|
|
|
3946 |
$SRCS{ $basename } = $source;
|
|
|
3947 |
|
|
|
3948 |
HashJoin( \%SRC_ARGS, $;, $basename, @args )
|
|
|
3949 |
if (@args);
|
|
|
3950 |
|
|
|
3951 |
HashJoin( \%SRC_DEPEND, $;, $basename, @depends )
|
|
|
3952 |
if ( @depends );
|
|
|
3953 |
|
|
|
3954 |
$SRC_TYPE{ $basename } = $type
|
|
|
3955 |
if ($type);
|
|
|
3956 |
|
|
|
3957 |
|
|
|
3958 |
foreach (@lists) {
|
|
|
3959 |
my $lname_short = "LIST_$_";
|
|
|
3960 |
my $lname_full = "LIST_FULL_$_";
|
|
|
3961 |
|
|
|
3962 |
no strict 'refs';
|
|
|
3963 |
|
|
|
3964 |
push @$lname_short,$basename;
|
|
|
3965 |
push @$lname_full ,$source;
|
|
|
3966 |
|
|
|
3967 |
use strict 'refs';
|
|
|
3968 |
}
|
|
|
3969 |
|
|
|
3970 |
__AddSourceFile( 1, $source, "", $type );
|
|
|
3971 |
}
|
|
|
3972 |
}
|
|
|
3973 |
}
|
|
|
3974 |
|
|
|
3975 |
|
|
|
3976 |
###############################################################################
|
|
|
3977 |
# sub LibNameSplit
|
|
|
3978 |
# Just a little help to deal with major/minor stuff for shared libs -
|
|
|
3979 |
# given the name of the library as the argument, split out major and minor
|
|
|
3980 |
# parts and return the basename, i.e name without major and minor and
|
|
|
3981 |
# the pair of major and minor.
|
|
|
3982 |
###############################################################################
|
|
|
3983 |
|
|
|
3984 |
sub LibNameSplit
|
|
|
3985 |
{
|
|
|
3986 |
my ( @bits ) = split('\.', $_[0]);
|
|
|
3987 |
my ( $major, $minor );
|
|
|
3988 |
|
|
|
3989 |
if ($#bits >= 1) {
|
|
|
3990 |
$major = $bits[0]; $minor = $bits[1];
|
|
|
3991 |
} elsif ($#bits >= 0) {
|
|
|
3992 |
$major = $bits[0]; $minor = 0;
|
|
|
3993 |
} else {
|
|
|
3994 |
$major = 1; $minor = 0;
|
|
|
3995 |
}
|
|
|
3996 |
Debug( "LibName: $@_[0] ($major.$minor)" );
|
|
|
3997 |
return ($major, $minor);
|
|
|
3998 |
}
|
|
|
3999 |
|
|
|
4000 |
#-------------------------------------------------------------------------------
|
|
|
4001 |
# Function : Lib
|
|
|
4002 |
#
|
|
|
4003 |
# Description : Generate a static library
|
|
|
4004 |
#
|
|
|
4005 |
# Inputs : Platform specifier
|
|
|
4006 |
# Name of the library
|
|
|
4007 |
# Arguemnts ...
|
|
|
4008 |
#
|
|
|
4009 |
# Returns :
|
|
|
4010 |
#
|
|
|
4011 |
sub Lib
|
|
|
4012 |
{
|
|
|
4013 |
my( $platforms, $lib, @args ) = @_;
|
|
|
4014 |
return if ( ! ActivePlatform($platforms) );
|
|
|
4015 |
|
|
|
4016 |
Error ("Lib: Library name not defined") unless ( $lib );
|
|
|
4017 |
|
|
|
4018 |
#
|
|
|
4019 |
# May be a shared library or a static library - for historic reasons
|
|
|
4020 |
# If the user has specified a --Shared then its a shared library
|
|
|
4021 |
#
|
|
|
4022 |
return SharedLib( @_ )
|
|
|
4023 |
if ( grep (/^--Shared/, @args) );
|
|
|
4024 |
|
|
|
4025 |
#
|
|
|
4026 |
# Does this toolset support libraries
|
|
|
4027 |
#
|
|
|
4028 |
Error ("Libraries are not supported") unless ( defined $::a );
|
|
|
4029 |
|
|
|
4030 |
#.. Fully qualify library path for addition to library list.
|
|
|
4031 |
$lib = "lib$lib"
|
|
|
4032 |
if ( $ScmTargetHost eq "Unix" && $lib !~ m/^lib/);
|
|
|
4033 |
Debug( "Lib: $lib" );
|
|
|
4034 |
|
|
|
4035 |
#
|
| 289 |
dpurdie |
4036 |
# Create a new object to describe the library
|
| 227 |
dpurdie |
4037 |
# Ensure that only one such lib exists
|
| 289 |
dpurdie |
4038 |
# Add the library to the list of static libraries
|
| 227 |
dpurdie |
4039 |
#
|
|
|
4040 |
Error( "Library of the same name already defined: $lib" )
|
| 289 |
dpurdie |
4041 |
if ( $LIBS->Get($lib) );
|
|
|
4042 |
$LIBS->NewAdd($lib);
|
| 227 |
dpurdie |
4043 |
|
|
|
4044 |
#
|
|
|
4045 |
# Process arguments
|
|
|
4046 |
#
|
|
|
4047 |
push( @LINTLIBS, $lib );
|
|
|
4048 |
_LibArgs( $lib, @args );
|
|
|
4049 |
}
|
|
|
4050 |
|
|
|
4051 |
|
|
|
4052 |
#-------------------------------------------------------------------------------
|
|
|
4053 |
# Function : SharedLib
|
|
|
4054 |
#
|
|
|
4055 |
# Description : Generate a shared library
|
|
|
4056 |
#
|
|
|
4057 |
# Inputs : Platform specifier
|
|
|
4058 |
# Name of the library
|
|
|
4059 |
# Arguemnts ...
|
|
|
4060 |
#
|
|
|
4061 |
# Returns :
|
|
|
4062 |
#
|
|
|
4063 |
sub SharedLib
|
|
|
4064 |
{
|
|
|
4065 |
my( $platforms, $lib, @args ) = @_;
|
|
|
4066 |
|
|
|
4067 |
return if ( ! ActivePlatform($platforms) );
|
|
|
4068 |
|
|
|
4069 |
Error ("SharedLib: Library name not defined") unless ( $lib );
|
|
|
4070 |
Error ("Shared Libraries are not supported") unless ( defined $::so );
|
|
|
4071 |
|
|
|
4072 |
#.. Fully qualify library path for addition to library list.
|
|
|
4073 |
$lib = "lib$lib"
|
|
|
4074 |
if ( $ScmTargetHost eq "Unix" && $lib !~ m/^lib/);
|
|
|
4075 |
Debug( "ShLib: $lib" );
|
|
|
4076 |
|
|
|
4077 |
#
|
|
|
4078 |
# Ensure that only one such lib exists
|
|
|
4079 |
#
|
| 289 |
dpurdie |
4080 |
Error( "Library of the same name already defined: $lib" )
|
|
|
4081 |
if ( $SHLIBS->Get($lib) );
|
|
|
4082 |
$SHLIBS->NewAdd($lib);
|
| 293 |
dpurdie |
4083 |
|
| 227 |
dpurdie |
4084 |
#
|
|
|
4085 |
# If the user has not specified a --Shared parameter then provide one
|
|
|
4086 |
#
|
|
|
4087 |
push @args, "--Shared=Current"
|
|
|
4088 |
unless ( grep (/^--Shared/, @args) );
|
|
|
4089 |
|
|
|
4090 |
#
|
|
|
4091 |
# Process arguments
|
|
|
4092 |
#
|
|
|
4093 |
push( @LINTSHLIBS, $lib );
|
|
|
4094 |
_SharedLibArgs( $lib, @args );
|
|
|
4095 |
}
|
|
|
4096 |
|
|
|
4097 |
|
|
|
4098 |
#-------------------------------------------------------------------------------
|
|
|
4099 |
# Function : LibArgs
|
|
|
4100 |
#
|
|
|
4101 |
# Description : Add arguments to an existing library directive
|
|
|
4102 |
#
|
|
|
4103 |
# Inputs : Platform specifier
|
|
|
4104 |
# Name of the library
|
|
|
4105 |
# Arguemnts ...
|
|
|
4106 |
#
|
|
|
4107 |
# Returns :
|
|
|
4108 |
#
|
|
|
4109 |
sub LibArgs
|
|
|
4110 |
{
|
|
|
4111 |
my( $platforms, $lib, @args ) = @_;
|
|
|
4112 |
return if ( ! ActivePlatform($platforms) );
|
|
|
4113 |
|
|
|
4114 |
#.. Fully qualify library path for addition to library list.
|
|
|
4115 |
$lib = "lib$lib"
|
|
|
4116 |
if ( $ScmTargetHost eq "Unix" && $lib !~ m/^lib/);
|
|
|
4117 |
Debug( "LibArgs: $lib" );
|
|
|
4118 |
|
|
|
4119 |
#
|
|
|
4120 |
# Process the arguments
|
|
|
4121 |
#
|
|
|
4122 |
_LibArgs( $lib, @args );
|
|
|
4123 |
}
|
|
|
4124 |
|
|
|
4125 |
|
|
|
4126 |
#-------------------------------------------------------------------------------
|
|
|
4127 |
# Function : _LibArgs
|
|
|
4128 |
#
|
|
|
4129 |
# Description : Process static library arguments
|
|
|
4130 |
# Internal use only
|
|
|
4131 |
#
|
|
|
4132 |
# Inputs : Name of the library
|
|
|
4133 |
# Arguments to process
|
|
|
4134 |
#
|
|
|
4135 |
sub _LibArgs
|
|
|
4136 |
{
|
|
|
4137 |
my( $lib, @elements) = @_;
|
|
|
4138 |
my $obj;
|
|
|
4139 |
|
|
|
4140 |
#
|
| 289 |
dpurdie |
4141 |
# Ensure that only one such lib exists
|
|
|
4142 |
#
|
|
|
4143 |
my $libp = $LIBS->Get($lib);
|
|
|
4144 |
Error("Library name not defined: $lib")
|
|
|
4145 |
unless ( $libp );
|
|
|
4146 |
|
|
|
4147 |
#
|
| 227 |
dpurdie |
4148 |
# Process each element
|
|
|
4149 |
#
|
|
|
4150 |
foreach (@elements)
|
|
|
4151 |
{
|
| 371 |
dpurdie |
4152 |
if ( /^\s+/ )
|
|
|
4153 |
{
|
|
|
4154 |
Error ("Argument cannot start with a space: '$_'");
|
|
|
4155 |
}
|
| 227 |
dpurdie |
4156 |
if ( /^--Shared/ )
|
|
|
4157 |
{
|
|
|
4158 |
Error( "--Shared not valid for a static library" );
|
|
|
4159 |
}
|
|
|
4160 |
|
|
|
4161 |
if ( /^-l(.*)/ || /^--l(.*)/ || /^-L(.*)/ || /^--L(.*)/ )
|
|
|
4162 |
{
|
|
|
4163 |
#.. Target library specified - add to library list.
|
|
|
4164 |
#
|
|
|
4165 |
Warning( "$_ within non shared library specification" );
|
|
|
4166 |
next;
|
|
|
4167 |
}
|
|
|
4168 |
|
|
|
4169 |
if ( /^--if(.*)/ )
|
|
|
4170 |
{
|
|
|
4171 |
Warning( "$_ within non shared library specification" );
|
|
|
4172 |
next;
|
|
|
4173 |
}
|
|
|
4174 |
|
|
|
4175 |
if ( /^--(.*)/ )
|
|
|
4176 |
{
|
|
|
4177 |
Debug( "LibArgs: arg $_" );
|
|
|
4178 |
|
|
|
4179 |
#.. Argument specified - add to argument list
|
|
|
4180 |
#
|
| 289 |
dpurdie |
4181 |
$libp->addItem('ARGS', $_);
|
|
|
4182 |
|
| 227 |
dpurdie |
4183 |
next;
|
|
|
4184 |
}
|
|
|
4185 |
|
| 369 |
dpurdie |
4186 |
if ( %::ScmToolsetProgSource )
|
| 227 |
dpurdie |
4187 |
{
|
|
|
4188 |
#
|
|
|
4189 |
# Toolset provides support for some file types
|
|
|
4190 |
# to be passed directly to the librarian builder
|
|
|
4191 |
#
|
|
|
4192 |
my $ext = StripFile($_);
|
|
|
4193 |
if ( exists ($::ScmToolsetProgSource{$ext}) )
|
|
|
4194 |
{
|
|
|
4195 |
my $full_path = MakeSrcResolve ( $_ );
|
|
|
4196 |
my $flag = $::ScmToolsetProgSource{$ext};
|
|
|
4197 |
Debug( "LibArgs: src $_" );
|
| 289 |
dpurdie |
4198 |
$libp->addItem('ARGS', "$flag$full_path" );
|
| 227 |
dpurdie |
4199 |
next;
|
|
|
4200 |
}
|
|
|
4201 |
}
|
|
|
4202 |
|
|
|
4203 |
if ( $::o )
|
|
|
4204 |
{
|
|
|
4205 |
#.. Object specified - add to object list.
|
|
|
4206 |
#
|
|
|
4207 |
$obj = _LibObject( "", $_ );
|
|
|
4208 |
|
|
|
4209 |
#.. Add to object list.
|
|
|
4210 |
# Note: Object path must be explicit as several
|
|
|
4211 |
# toolsets add additional objects.
|
|
|
4212 |
#
|
| 289 |
dpurdie |
4213 |
$libp->addItem('OBJS', "\$(OBJDIR)/$obj" );
|
| 227 |
dpurdie |
4214 |
next;
|
|
|
4215 |
}
|
|
|
4216 |
|
|
|
4217 |
#
|
|
|
4218 |
# Don't know how to handle this type of argument
|
|
|
4219 |
#
|
|
|
4220 |
Error ("LibArgs: Don't know how to handle: $_" );
|
|
|
4221 |
}
|
|
|
4222 |
}
|
|
|
4223 |
|
|
|
4224 |
|
|
|
4225 |
#-------------------------------------------------------------------------------
|
|
|
4226 |
# Function : SharedLibArgs
|
|
|
4227 |
#
|
|
|
4228 |
# Description : Add arguments to an existing shared library directive
|
|
|
4229 |
#
|
|
|
4230 |
# Inputs : Platform specifier
|
|
|
4231 |
# Name of the library
|
|
|
4232 |
# Arguemnts ...
|
|
|
4233 |
#
|
|
|
4234 |
# Returns :
|
|
|
4235 |
#
|
|
|
4236 |
sub SharedLibArgs
|
|
|
4237 |
{
|
|
|
4238 |
my( $platforms, $lib, @args ) = @_;
|
|
|
4239 |
return if ( ! ActivePlatform($platforms) );
|
|
|
4240 |
|
|
|
4241 |
#.. Fully qualify library path for addition to library list.
|
|
|
4242 |
$lib = "lib$lib"
|
|
|
4243 |
if ( $ScmTargetHost eq "Unix" && $lib !~ m/^lib/);
|
|
|
4244 |
Debug( "ShLibArgs: $lib" );
|
|
|
4245 |
|
|
|
4246 |
_SharedLibArgs( $lib, @args );
|
|
|
4247 |
}
|
|
|
4248 |
|
|
|
4249 |
|
|
|
4250 |
#-------------------------------------------------------------------------------
|
|
|
4251 |
# Function : _SharedLibArgs
|
|
|
4252 |
#
|
|
|
4253 |
# Description : Process shared library arguments
|
|
|
4254 |
# Internal use only
|
|
|
4255 |
#
|
|
|
4256 |
# Inputs : Name of the library
|
|
|
4257 |
# Arguments to process
|
|
|
4258 |
#
|
|
|
4259 |
sub _SharedLibArgs
|
|
|
4260 |
{
|
|
|
4261 |
my ( $lib, @elements) = @_;
|
|
|
4262 |
|
| 289 |
dpurdie |
4263 |
my $libp = $SHLIBS->Get($lib);
|
|
|
4264 |
Error("Library name not defined: $lib")
|
|
|
4265 |
unless ( $libp );
|
|
|
4266 |
|
| 227 |
dpurdie |
4267 |
#
|
| 289 |
dpurdie |
4268 |
#.. Collect --Shared arguments
|
| 339 |
dpurdie |
4269 |
# Need to process this one first so that we have a version number
|
| 227 |
dpurdie |
4270 |
#
|
|
|
4271 |
foreach (@elements)
|
|
|
4272 |
{
|
| 371 |
dpurdie |
4273 |
if ( /^\s+/ )
|
|
|
4274 |
{
|
|
|
4275 |
Error ("Argument cannot start with a space: '$_'");
|
|
|
4276 |
}
|
| 289 |
dpurdie |
4277 |
next unless ( /^--Shared/ );
|
|
|
4278 |
|
|
|
4279 |
my $shared;
|
| 227 |
dpurdie |
4280 |
if ( /^--Shared$/ )
|
|
|
4281 |
{
|
|
|
4282 |
#.. Shared library, default library version 1.0
|
|
|
4283 |
#
|
|
|
4284 |
$shared = "1.0";
|
|
|
4285 |
}
|
|
|
4286 |
elsif ( /^--Shared=Current$/ )
|
|
|
4287 |
{
|
|
|
4288 |
#.. Shared library, using 'current' build version
|
|
|
4289 |
#
|
|
|
4290 |
$shared = $::ScmBuildVersion;
|
| 289 |
dpurdie |
4291 |
$shared = "1.0" if ($shared eq "");
|
| 227 |
dpurdie |
4292 |
}
|
|
|
4293 |
elsif ( /^--Shared=(.*)/ )
|
|
|
4294 |
{
|
|
|
4295 |
#.. Shared library, specific version
|
|
|
4296 |
#
|
|
|
4297 |
my($M, $m) = LibNameSplit($1);
|
| 289 |
dpurdie |
4298 |
$shared = "$M.$m";
|
|
|
4299 |
}
|
| 227 |
dpurdie |
4300 |
|
| 289 |
dpurdie |
4301 |
#
|
|
|
4302 |
# Update the shared Names
|
|
|
4303 |
#
|
|
|
4304 |
if ( defined $shared )
|
|
|
4305 |
{
|
| 227 |
dpurdie |
4306 |
Warning( "multiple --Shared arguments" )
|
| 339 |
dpurdie |
4307 |
if (exists $libp->{ VERSION });
|
| 227 |
dpurdie |
4308 |
Debug( "ShLibArgs: shared $_ ($shared)" );
|
| 289 |
dpurdie |
4309 |
$libp->{ VERSION } = $shared;
|
| 227 |
dpurdie |
4310 |
}
|
| 289 |
dpurdie |
4311 |
else
|
|
|
4312 |
{
|
|
|
4313 |
Error ("ShLibArgs: --Shared argument not understood");
|
|
|
4314 |
}
|
| 227 |
dpurdie |
4315 |
}
|
|
|
4316 |
|
|
|
4317 |
|
|
|
4318 |
#.. Parse all of the object and argument entries.
|
|
|
4319 |
#
|
|
|
4320 |
foreach (@elements)
|
|
|
4321 |
{
|
| 289 |
dpurdie |
4322 |
next if ( /^--Shared(.*)/ );
|
| 227 |
dpurdie |
4323 |
|
|
|
4324 |
if ( /^[-]{1,2}([lL])(.*)/ )
|
|
|
4325 |
{
|
|
|
4326 |
#.. Target library specified - add to library list.
|
| 339 |
dpurdie |
4327 |
# Support --L and -L and --l and -l
|
| 227 |
dpurdie |
4328 |
#
|
|
|
4329 |
Debug( "ShLibArgs: lib -$1$2" );
|
| 289 |
dpurdie |
4330 |
$libp->addItem('LIBS', "-$1$2" );
|
| 227 |
dpurdie |
4331 |
next;
|
|
|
4332 |
}
|
|
|
4333 |
|
|
|
4334 |
if ( /^--if(.*)/ )
|
|
|
4335 |
{
|
|
|
4336 |
#.. Library conditional - add to library list.
|
|
|
4337 |
#
|
|
|
4338 |
Debug( "ShLibArgs: cond $_" );
|
| 289 |
dpurdie |
4339 |
$libp->addItem('LIBS', $_);
|
| 227 |
dpurdie |
4340 |
next;
|
|
|
4341 |
}
|
|
|
4342 |
|
| 339 |
dpurdie |
4343 |
if ( /^--SoName=(.*)/i )
|
|
|
4344 |
{
|
|
|
4345 |
#.. Specify the SoName of the library
|
|
|
4346 |
# Not supported by all toolsets
|
|
|
4347 |
#
|
|
|
4348 |
my $soMode = $1;
|
|
|
4349 |
if ( !$ScmToolsetSoName )
|
|
|
4350 |
{
|
|
|
4351 |
Warning ("Toolset does not support --SoName. Option ignored");
|
|
|
4352 |
next;
|
|
|
4353 |
}
|
|
|
4354 |
|
|
|
4355 |
Error ("SharedLib: $lib. Multiple --SoName arguments not allowed")
|
|
|
4356 |
if ( $libp->{ SONAME } );
|
|
|
4357 |
|
|
|
4358 |
my ($major, $minor, $patch, $build, $raw_patch) = SplitVersion($::ScmBuildVersionFull);
|
|
|
4359 |
my $soname = '.';
|
|
|
4360 |
if ( $soMode =~ m/Major/i ) {
|
|
|
4361 |
$soname .= $major;
|
|
|
4362 |
} elsif ( $soMode =~ m/^Minor/i ) {
|
|
|
4363 |
$soname .= "$major.$minor";
|
|
|
4364 |
} elsif ( $soMode =~ m/^Patch/i ) {
|
|
|
4365 |
$soname .= "$major.$minor.$patch";
|
|
|
4366 |
} elsif ( $soMode =~ m/^Build/i ) {
|
|
|
4367 |
$soname .= "$major.$minor.$patch.$build";
|
|
|
4368 |
} elsif ( $soMode =~ m/^Full/i ) {
|
|
|
4369 |
$soname .= $libp->{ VERSION };
|
|
|
4370 |
} elsif ( $soMode =~ m/^None/i ) {
|
|
|
4371 |
$soname = '';
|
|
|
4372 |
} elsif ( $soMode =~ m/^[0-9.]+$/ ) {
|
|
|
4373 |
$soname .= $soMode;
|
|
|
4374 |
} else {
|
|
|
4375 |
Error ("Unknown --SoName mode: $soMode");
|
|
|
4376 |
}
|
|
|
4377 |
$libp->addItem('ARGS', '--SoNameSuffix=' . $soname);
|
|
|
4378 |
$libp->{ SONAME } = 1;
|
|
|
4379 |
next;
|
|
|
4380 |
}
|
|
|
4381 |
|
| 227 |
dpurdie |
4382 |
if ( /^-(.*)/ )
|
|
|
4383 |
{
|
|
|
4384 |
#.. Argument specified - add to argument list
|
|
|
4385 |
#
|
|
|
4386 |
Debug( "ShLibArgs: arg $_" );
|
| 289 |
dpurdie |
4387 |
$libp->addItem('ARGS', $_);
|
| 227 |
dpurdie |
4388 |
next;
|
|
|
4389 |
}
|
|
|
4390 |
|
| 369 |
dpurdie |
4391 |
if ( %::ScmToolsetProgSource )
|
| 227 |
dpurdie |
4392 |
{
|
|
|
4393 |
#
|
|
|
4394 |
# Toolset provides support for some file types
|
|
|
4395 |
# to be passed directly to the program builder
|
|
|
4396 |
#
|
|
|
4397 |
my $ext = StripFile($_);
|
|
|
4398 |
if ( exists ($::ScmToolsetProgSource{$ext}) )
|
|
|
4399 |
{
|
|
|
4400 |
my $full_path = MakeSrcResolve ( $_ );
|
|
|
4401 |
my $flag = $::ScmToolsetProgSource{$ext};
|
|
|
4402 |
Debug( "ShLibArgs: src $_" );
|
| 289 |
dpurdie |
4403 |
$libp->addItem('ARGS', "$flag$full_path");
|
| 227 |
dpurdie |
4404 |
next;
|
|
|
4405 |
}
|
|
|
4406 |
}
|
|
|
4407 |
|
|
|
4408 |
if ( $::o )
|
|
|
4409 |
{
|
|
|
4410 |
#.. Object specified - add to object list.
|
|
|
4411 |
#
|
|
|
4412 |
my ($obj) = _LibObject( $lib, $_ );
|
|
|
4413 |
|
|
|
4414 |
#.. Add to object list.
|
|
|
4415 |
# Note: Object path must be explicit as several
|
|
|
4416 |
# toolsets add additional objects.
|
|
|
4417 |
#
|
|
|
4418 |
$SHOBJ_LIB{ $obj } = $lib;
|
| 289 |
dpurdie |
4419 |
$libp->addItem('OBJS', "\$(OBJDIR)/$obj");
|
| 227 |
dpurdie |
4420 |
next;
|
|
|
4421 |
}
|
|
|
4422 |
|
|
|
4423 |
#
|
|
|
4424 |
# Don't know how to handle this type of argument
|
|
|
4425 |
#
|
|
|
4426 |
Error ("SharedLib: Don't know how to handle: $_" );
|
|
|
4427 |
}
|
|
|
4428 |
}
|
|
|
4429 |
|
|
|
4430 |
|
|
|
4431 |
#-------------------------------------------------------------------------------
|
|
|
4432 |
# Function : _LibObject
|
|
|
4433 |
#
|
|
|
4434 |
# Description : Process library object file
|
|
|
4435 |
# Common processing routine for static and shared library
|
|
|
4436 |
# Internal use only
|
|
|
4437 |
#
|
|
|
4438 |
# Inputs : shared - Name of the shared library is shared, if defined
|
|
|
4439 |
# fname - Name of file
|
|
|
4440 |
#
|
|
|
4441 |
# Returns : Name of the object file
|
|
|
4442 |
#
|
|
|
4443 |
sub _LibObject
|
|
|
4444 |
{
|
|
|
4445 |
my ($shared, $fname) = @_;
|
|
|
4446 |
my ($file, $ext, $obj, $srcfile, $delete_obj);
|
|
|
4447 |
|
|
|
4448 |
#.. Object specified - add to object list.
|
|
|
4449 |
#
|
| 381 |
dpurdie |
4450 |
$file = StripDirExt($fname); # file name, without extension or Dir
|
| 227 |
dpurdie |
4451 |
$ext = StripFile($fname); # extension
|
|
|
4452 |
|
|
|
4453 |
if ($shared) {
|
|
|
4454 |
$obj = "$shared/$file"; # library specific subdir
|
|
|
4455 |
} else {
|
|
|
4456 |
$obj = "$file";
|
|
|
4457 |
}
|
|
|
4458 |
|
|
|
4459 |
Debug( "LibObjs: obj [$shared]$fname ($file$ext)" );
|
|
|
4460 |
|
|
|
4461 |
#.. Unqualified object name
|
|
|
4462 |
#
|
|
|
4463 |
if ( $ext eq "" )
|
|
|
4464 |
{
|
|
|
4465 |
#
|
|
|
4466 |
# Object file not covered by a "Src" statement
|
|
|
4467 |
# Assume that it will be created
|
|
|
4468 |
#
|
|
|
4469 |
unless ( $srcfile = $OBJSOURCE{ "$file" } )
|
|
|
4470 |
{
|
|
|
4471 |
#
|
|
|
4472 |
# If the object is "generated" then it will be is the
|
|
|
4473 |
# SRCS list
|
|
|
4474 |
#
|
|
|
4475 |
unless ( $srcfile = $SRCS{"$file.$::o"} )
|
|
|
4476 |
{
|
|
|
4477 |
Warning( "No source for object '$fname' ($file)" );
|
|
|
4478 |
}
|
|
|
4479 |
}
|
|
|
4480 |
$delete_obj = 1;
|
|
|
4481 |
}
|
|
|
4482 |
|
|
|
4483 |
#.. Qualified object name (ie has extension)
|
|
|
4484 |
# Strip extension and resolve ...
|
|
|
4485 |
# Assume that the named file can be built into an object file
|
|
|
4486 |
#
|
|
|
4487 |
else
|
|
|
4488 |
{
|
|
|
4489 |
#.. Resolve
|
|
|
4490 |
#
|
|
|
4491 |
if ( !($srcfile = $OBJSOURCE{ "$file" }) )
|
|
|
4492 |
{
|
|
|
4493 |
$srcfile = MakeSrcResolve( $fname );
|
|
|
4494 |
$SRCS{ $fname } = $srcfile;
|
|
|
4495 |
__AddSourceFile( 0, $fname, $obj );
|
|
|
4496 |
$delete_obj = 1;
|
|
|
4497 |
}
|
|
|
4498 |
}
|
|
|
4499 |
|
|
|
4500 |
#.. Delete generated object file
|
|
|
4501 |
# Ensure that the object file is added to the delete list
|
|
|
4502 |
# Add it to the ToolsetObj deletion list as the main OBJ deleltion
|
|
|
4503 |
# list will aready have been processed
|
|
|
4504 |
#
|
|
|
4505 |
ToolsetObj( "\$(OBJDIR)/$obj" )
|
|
|
4506 |
if ( $delete_obj );
|
|
|
4507 |
|
|
|
4508 |
|
|
|
4509 |
#.. Shared library objects,
|
|
|
4510 |
# Must explicitly relate source and object, as shared libraries
|
|
|
4511 |
# objects are built within a library specific subdirs.
|
|
|
4512 |
#
|
|
|
4513 |
$OBJSOURCE{ $obj } = $srcfile
|
| 371 |
dpurdie |
4514 |
if ( $shared && defined $srcfile );
|
| 227 |
dpurdie |
4515 |
|
|
|
4516 |
return $obj;
|
|
|
4517 |
}
|
|
|
4518 |
|
|
|
4519 |
|
|
|
4520 |
# MergeLibrary
|
|
|
4521 |
# Merge a list of libraries into one library
|
|
|
4522 |
#
|
|
|
4523 |
sub MergeLibrary
|
|
|
4524 |
{
|
|
|
4525 |
my( $platforms, $lib, @elements ) = @_;
|
|
|
4526 |
|
|
|
4527 |
return if ( ! ActivePlatform($platforms) );
|
|
|
4528 |
|
|
|
4529 |
|
|
|
4530 |
#.. Fully qualify library path for addition to library list.
|
|
|
4531 |
$lib = "lib$lib"
|
|
|
4532 |
if ( $ScmTargetHost eq "Unix" && $lib !~ m/^lib/);
|
|
|
4533 |
Debug( "MergeLibrary: $lib" );
|
|
|
4534 |
|
| 289 |
dpurdie |
4535 |
#
|
|
|
4536 |
# Create a new object to describe the library
|
|
|
4537 |
# Ensure that only one such lib exists
|
|
|
4538 |
# Add the library to the list of static libraries
|
|
|
4539 |
#
|
|
|
4540 |
Error( "Merged Library of the same name already defined: $lib" )
|
|
|
4541 |
if ( $MLIBS->Get($lib) );
|
|
|
4542 |
my $libp = $MLIBS->NewAdd($lib);
|
|
|
4543 |
|
| 227 |
dpurdie |
4544 |
#.. Parse all of the object and argument entries.
|
|
|
4545 |
#
|
|
|
4546 |
foreach (@elements)
|
|
|
4547 |
{
|
|
|
4548 |
if ( /^--(.*)/ )
|
|
|
4549 |
{
|
| 289 |
dpurdie |
4550 |
$libp->addItem('ARGS', $_);
|
| 227 |
dpurdie |
4551 |
}
|
|
|
4552 |
else
|
|
|
4553 |
{
|
|
|
4554 |
my ($llib);
|
|
|
4555 |
|
|
|
4556 |
#
|
|
|
4557 |
# Collect the source libraries
|
|
|
4558 |
# These must have been installed and will be in a known area
|
|
|
4559 |
# Create full names for the libaries
|
|
|
4560 |
#
|
|
|
4561 |
if ( $ScmTargetHost eq "Unix" ) {
|
|
|
4562 |
$llib = "lib$_"; # Prefix "lib" ....
|
|
|
4563 |
$lib =~ s/^liblib/lib/; # @LIBS already has lib added
|
|
|
4564 |
} else {
|
|
|
4565 |
$llib = $_;
|
|
|
4566 |
}
|
|
|
4567 |
|
|
|
4568 |
Debug( "MergeLibrary: merge $llib" );
|
| 289 |
dpurdie |
4569 |
$libp->addItem('LIBS', $llib);
|
| 227 |
dpurdie |
4570 |
}
|
|
|
4571 |
}
|
|
|
4572 |
}
|
|
|
4573 |
|
|
|
4574 |
#-------------------------------------------------------------------------------
|
|
|
4575 |
# Function : Script
|
|
|
4576 |
#
|
|
|
4577 |
# Description : Locate a script for test purposes
|
|
|
4578 |
#
|
|
|
4579 |
# Inputs : $platforms - Platform selector
|
|
|
4580 |
# $script - A single script name
|
|
|
4581 |
# $execute - Flag to indicate that the script is to
|
|
|
4582 |
# marked as executable when used in a TestProg
|
|
|
4583 |
# This flag is NOT used as the script will
|
|
|
4584 |
# be forced executable
|
|
|
4585 |
#
|
|
|
4586 |
# Returns : Nothing
|
|
|
4587 |
#
|
|
|
4588 |
sub Script
|
|
|
4589 |
{
|
|
|
4590 |
my( $platforms, $script, $execute ) = @_;
|
|
|
4591 |
|
|
|
4592 |
Debug2( "Script(@_)" );
|
|
|
4593 |
|
|
|
4594 |
return if ( ! ActivePlatform($platforms) );
|
|
|
4595 |
|
|
|
4596 |
#
|
|
|
4597 |
# Locate the script as a source file
|
|
|
4598 |
#
|
|
|
4599 |
my $file = MakeSrcResolve ( $script );
|
|
|
4600 |
$script = StripDir( $file );
|
|
|
4601 |
$SCRIPTS{ $script } = $file;
|
|
|
4602 |
}
|
|
|
4603 |
|
|
|
4604 |
#-------------------------------------------------------------------------------
|
|
|
4605 |
# Function : RunTest
|
|
|
4606 |
#
|
|
|
4607 |
# Description : Define a test to be run with the 'run_tests' and 'run_unit_tests'
|
|
|
4608 |
#
|
|
|
4609 |
# Inputs : $platform - Enabled for these platforms
|
|
|
4610 |
# $prog - Program to run
|
|
|
4611 |
# This SHOULD return a non-zero exit status
|
|
|
4612 |
# on error. The program may be a 'TestProg'
|
|
|
4613 |
# or a 'Script'.
|
|
|
4614 |
# @elements - Options and test arguments
|
|
|
4615 |
# Options are:
|
|
|
4616 |
# --Auto - Non interactive unit test
|
|
|
4617 |
# --Unit - Same and --Auto
|
|
|
4618 |
# --CopyIn=file - A file to be copied into
|
|
|
4619 |
# The test directory.
|
|
|
4620 |
#
|
|
|
4621 |
# Non Options are passed to the test program.
|
|
|
4622 |
# --PackageBase(xxx) - Base of package
|
|
|
4623 |
# --PackageInfo(xxx) - Package information
|
|
|
4624 |
# --File(xxx) - Resolved name of file
|
|
|
4625 |
# --Var(xxx) - Expanded variable
|
|
|
4626 |
# --Local(xxx) - File within the local directory
|
|
|
4627 |
#
|
|
|
4628 |
# Returns : Nothing
|
|
|
4629 |
#
|
|
|
4630 |
|
|
|
4631 |
sub RunTest
|
|
|
4632 |
{
|
|
|
4633 |
my( $platforms, $prog, @elements ) = @_;
|
|
|
4634 |
my $command = './'; # program prefix / command
|
|
|
4635 |
my $winprog = 1; # 1: Convert / -> \ (WIN32 only)
|
|
|
4636 |
my $framework;
|
|
|
4637 |
my @framework_opts;
|
|
|
4638 |
my @copy = ();
|
|
|
4639 |
my $auto;
|
|
|
4640 |
|
|
|
4641 |
return if ( ! ActivePlatform($platforms) );
|
|
|
4642 |
|
|
|
4643 |
#
|
|
|
4644 |
# Scan @elements and extract useful information
|
|
|
4645 |
# Need to process twice as some args will modify the
|
|
|
4646 |
# processing done later
|
|
|
4647 |
#
|
|
|
4648 |
my @args;
|
|
|
4649 |
foreach ( @elements )
|
|
|
4650 |
{
|
|
|
4651 |
if ( m/^--FrameWork=(.+)/ ) {
|
|
|
4652 |
$framework = $1;
|
|
|
4653 |
|
|
|
4654 |
} elsif ( m/^--Auto/ || m/^--Unit/) {
|
|
|
4655 |
$auto = 1;
|
|
|
4656 |
|
|
|
4657 |
} elsif ( m/^--CopyIn=(.*)/ ) {
|
|
|
4658 |
push @copy, MakeSrcResolve ( $1 );
|
|
|
4659 |
|
|
|
4660 |
|
|
|
4661 |
} elsif ( $framework && m/^--\w+=(.+)/ ) {
|
|
|
4662 |
push @framework_opts, $_;
|
|
|
4663 |
|
|
|
4664 |
} else {
|
|
|
4665 |
push @args, $_;
|
|
|
4666 |
}
|
|
|
4667 |
}
|
|
|
4668 |
@elements = @args;
|
|
|
4669 |
@args = ();
|
|
|
4670 |
|
|
|
4671 |
#
|
|
|
4672 |
# Determine the source of the test prog
|
|
|
4673 |
# If using a plug-in framework, then we don;'t know
|
|
|
4674 |
# If not, then may be a script or a TESTPROGS
|
|
|
4675 |
#
|
|
|
4676 |
|
|
|
4677 |
unless ( $framework )
|
|
|
4678 |
{
|
| 289 |
dpurdie |
4679 |
if ( $TESTPROGS->Get($prog) || $PROGS->Get($prog) ) {
|
| 227 |
dpurdie |
4680 |
#
|
|
|
4681 |
# Append a suitable EXE suffix
|
|
|
4682 |
#
|
| 289 |
dpurdie |
4683 |
$prog = GenProgName( $prog );
|
| 227 |
dpurdie |
4684 |
|
|
|
4685 |
} elsif ( exists $SCRIPTS{$prog} ) {
|
|
|
4686 |
#
|
|
|
4687 |
# Script names are raw
|
|
|
4688 |
# Perl script are invoked directly
|
|
|
4689 |
#
|
|
|
4690 |
$command = "\$(GBE_PERL) -w "
|
|
|
4691 |
if ( $prog =~ /\.pl$/ );
|
|
|
4692 |
|
|
|
4693 |
#
|
|
|
4694 |
# Pass / to shells
|
|
|
4695 |
#
|
|
|
4696 |
$winprog = 0
|
|
|
4697 |
unless ( $prog =~ m~\.bat$~ )
|
|
|
4698 |
|
|
|
4699 |
} else {
|
|
|
4700 |
Warning("RunTest program not known: $prog",
|
| 261 |
dpurdie |
4701 |
"It is not a TestProg, Prog or a Script",
|
|
|
4702 |
"The test may fail" );
|
| 227 |
dpurdie |
4703 |
}
|
|
|
4704 |
}
|
|
|
4705 |
|
|
|
4706 |
#
|
|
|
4707 |
# Extract and process options
|
|
|
4708 |
#
|
|
|
4709 |
my @uargs = ();
|
|
|
4710 |
my @preq_files;
|
|
|
4711 |
|
|
|
4712 |
foreach my $arg (@elements) {
|
|
|
4713 |
#
|
|
|
4714 |
# Process the tool arguments and extract file information
|
|
|
4715 |
# Extract all fields of the form:
|
|
|
4716 |
# --xxxxx(yyyyyy[,zzzzz])
|
|
|
4717 |
# --xxxxx{yyyyyyy}
|
|
|
4718 |
# --xxxxx[yyyyyyy] to allow embedded brackets
|
|
|
4719 |
#
|
|
|
4720 |
while ( $arg =~ m/--(\w+) # --CommandWord $1
|
|
|
4721 |
( # Just for grouping
|
|
|
4722 |
\((.*?)\) | # Stuff like (yyyyy) $3
|
|
|
4723 |
{(.*?)} | # or like {yyyyy} $4
|
|
|
4724 |
\[(.*?)\] # or like [yyyyy] $5
|
|
|
4725 |
)/x ) # Allow comments and whitespace
|
|
|
4726 |
{
|
|
|
4727 |
my $cmd = $1; # The command
|
|
|
4728 |
my $ufn = $3 || $4 || $5; # User filename + options
|
|
|
4729 |
my $mb = $-[0]; # Match begin offset
|
|
|
4730 |
my $me = $+[0]; # Match end
|
|
|
4731 |
my $flags = ''; # Optional flags ( --dir or --file )
|
|
|
4732 |
my $raw_arg = $ufn; # Raw arguments
|
| 285 |
dpurdie |
4733 |
my $all = substr( $arg, $mb, $me ); # All of match. Avoid use of $&
|
| 329 |
dpurdie |
4734 |
my $is_abs;
|
|
|
4735 |
my $is_path = 1;
|
| 227 |
dpurdie |
4736 |
|
|
|
4737 |
Error ("RunTest. Empty element not allowed: $all")
|
|
|
4738 |
unless ( defined($ufn) );
|
|
|
4739 |
|
|
|
4740 |
$ufn =~ s/\s+$//;
|
|
|
4741 |
$ufn =~ s~//~/~g; # Remove multiple /
|
|
|
4742 |
if ( $ufn =~ m/(.*?),(.*)/ ) # Extract out any flags
|
|
|
4743 |
{
|
|
|
4744 |
$ufn = $1;
|
|
|
4745 |
$flags = $2;
|
|
|
4746 |
}
|
|
|
4747 |
|
|
|
4748 |
my $fn = $ufn ; # Replacement filename
|
| 343 |
dpurdie |
4749 |
my $fnp = ''; # Prefix to $fn
|
| 227 |
dpurdie |
4750 |
Error ("RunTest. Empty element not allowed: $all" )
|
|
|
4751 |
if ( length ($ufn) <= 0 );
|
|
|
4752 |
|
|
|
4753 |
#
|
|
|
4754 |
# Process found user command
|
|
|
4755 |
#
|
|
|
4756 |
if ( $cmd =~ /^File/ )
|
|
|
4757 |
{
|
|
|
4758 |
#
|
|
|
4759 |
# Prerequisite filename
|
|
|
4760 |
# Resolve the full name of the file. It may be known
|
|
|
4761 |
# as a source file (possibly generated) or it may be
|
|
|
4762 |
# located in a known source directory
|
|
|
4763 |
#
|
|
|
4764 |
$fn = MakeSrcResolve ( $ufn );
|
|
|
4765 |
UniquePush (\@preq_files, $fn);
|
|
|
4766 |
|
|
|
4767 |
Debug( "RunTest: Prereq: $fn" );
|
|
|
4768 |
|
|
|
4769 |
}
|
|
|
4770 |
elsif ( $cmd =~ /^PackageBase/ )
|
|
|
4771 |
{
|
|
|
4772 |
$fn = GetPackageBase( "RunTest", $raw_arg );
|
|
|
4773 |
UniquePush (\@preq_files, $fn);
|
|
|
4774 |
}
|
|
|
4775 |
elsif ( $cmd =~ /^PackageInfo/ )
|
|
|
4776 |
{
|
|
|
4777 |
$fn = GetPackageInfo( "RunTest", $raw_arg );
|
|
|
4778 |
}
|
|
|
4779 |
elsif ( $cmd =~ /^Var/ )
|
|
|
4780 |
{
|
| 343 |
dpurdie |
4781 |
($fnp, $fn, $is_path, $is_abs) = ExpandGenVar( "RunTest", $raw_arg );
|
| 227 |
dpurdie |
4782 |
$flags = '';
|
|
|
4783 |
}
|
|
|
4784 |
elsif ( $cmd =~ /^Local/ )
|
|
|
4785 |
{
|
|
|
4786 |
$fn = '$(LOCALDIR)/' . $ufn ;
|
|
|
4787 |
UniquePush (\@preq_files, $fn);
|
|
|
4788 |
}
|
|
|
4789 |
else
|
|
|
4790 |
{
|
|
|
4791 |
Warning ("RunTest: Unknown replacement command: $cmd");
|
|
|
4792 |
$fn = $ufn;
|
|
|
4793 |
}
|
|
|
4794 |
|
|
|
4795 |
#
|
|
|
4796 |
# Process path modification flags
|
|
|
4797 |
# --dir - only the directory part ( or a "." )
|
|
|
4798 |
# --file - only the file part
|
|
|
4799 |
# --abspath - Absolute path
|
|
|
4800 |
# --absdrive - Absolute path with drive letter(WIN)
|
|
|
4801 |
#
|
|
|
4802 |
$fn = ProcessPathName( $fn, $flags );
|
|
|
4803 |
|
|
|
4804 |
#
|
|
|
4805 |
# The program is going to be executed within a subdirectory
|
|
|
4806 |
# so add one more level of indirection to the path, but only if
|
|
|
4807 |
# the path is relative
|
|
|
4808 |
#
|
| 329 |
dpurdie |
4809 |
if ( $is_path && ! $is_abs )
|
| 227 |
dpurdie |
4810 |
{
|
| 329 |
dpurdie |
4811 |
unless ( $fn =~ m~^/|^\w:/~ )
|
|
|
4812 |
{
|
|
|
4813 |
$fn = '../' . $fn
|
|
|
4814 |
unless( $fn =~ s~=~=../~ );
|
|
|
4815 |
$fn =~ s~/.$~~;
|
|
|
4816 |
}
|
| 227 |
dpurdie |
4817 |
}
|
|
|
4818 |
|
|
|
4819 |
#
|
|
|
4820 |
# Minor kludge under windows. Ensure directores have a "\" sep
|
|
|
4821 |
# Unless the user has specified a straight shell command
|
|
|
4822 |
#
|
| 303 |
dpurdie |
4823 |
$fn = "\$(subst /,\\,$fn)"
|
| 227 |
dpurdie |
4824 |
if ( $::ScmHost eq "WIN" && $winprog );
|
|
|
4825 |
|
|
|
4826 |
#
|
| 343 |
dpurdie |
4827 |
# Prepend any $fn Prefix
|
|
|
4828 |
# This will be a tag and is not subject to path processing
|
|
|
4829 |
#
|
|
|
4830 |
$fn = $fnp . $fn;
|
|
|
4831 |
|
|
|
4832 |
#
|
| 227 |
dpurdie |
4833 |
# Replace the found string with the real name of the file
|
|
|
4834 |
# Note: 4 argument version of substr is not always available
|
|
|
4835 |
# so we must do it the hard way
|
|
|
4836 |
# substr( $arg, $mb, $me - $mb, $fn);
|
|
|
4837 |
#
|
|
|
4838 |
$arg = substr( $arg, 0, $mb ) . $fn . substr( $arg, $me );
|
|
|
4839 |
|
|
|
4840 |
Debug2( "RunTest: subs: $all -> $fn" );
|
|
|
4841 |
}
|
|
|
4842 |
push(@uargs, "'$arg'");
|
|
|
4843 |
}
|
|
|
4844 |
|
|
|
4845 |
#
|
|
|
4846 |
# Create the test entry
|
|
|
4847 |
# This is a structure that will be placed in an array
|
|
|
4848 |
# The array preserves order and uniqness
|
|
|
4849 |
#
|
|
|
4850 |
my %test_entry;
|
|
|
4851 |
$test_entry{'framework'}= $framework if ( $framework );
|
|
|
4852 |
$test_entry{'framework_opts'}= \@framework_opts if ( $framework );
|
|
|
4853 |
$test_entry{'command'} = $command . $prog unless ( $framework);
|
|
|
4854 |
|
|
|
4855 |
$test_entry{'prog'} = $prog;
|
|
|
4856 |
$test_entry{'copyprog'} = 1;
|
|
|
4857 |
$test_entry{'args'} = \@uargs;
|
|
|
4858 |
$test_entry{'auto'} = $auto if ( $auto );
|
|
|
4859 |
$test_entry{'copyin'} = \@copy;
|
|
|
4860 |
$test_entry{'copyonce'} = ();
|
|
|
4861 |
$test_entry{'preq'} = \@preq_files;
|
|
|
4862 |
$test_entry{'testdir'} = 'BINDIR';
|
|
|
4863 |
|
|
|
4864 |
push ( @TESTS_TO_RUN, \%test_entry );
|
|
|
4865 |
|
|
|
4866 |
#
|
|
|
4867 |
# Flag Auto Run processing required
|
|
|
4868 |
#
|
|
|
4869 |
$TESTS_TO_AUTORUN = 1 if ( $auto );
|
|
|
4870 |
}
|
|
|
4871 |
|
|
|
4872 |
|
|
|
4873 |
sub TestProg
|
|
|
4874 |
{
|
|
|
4875 |
my( $platforms, $prog, @elements ) = @_;
|
|
|
4876 |
|
|
|
4877 |
Debug2( "TestProg($platforms, $prog, @elements)" );
|
|
|
4878 |
|
|
|
4879 |
return if ( ! ActivePlatform($platforms) );
|
|
|
4880 |
|
|
|
4881 |
Error ("TestProg: Program name not defined") unless ( $prog );
|
|
|
4882 |
Error ("Programs are not supported") unless ( defined $::exe );
|
|
|
4883 |
|
| 289 |
dpurdie |
4884 |
#
|
|
|
4885 |
# Create a new Prog object, or retrieve any existing one
|
|
|
4886 |
#
|
|
|
4887 |
my $pProg = $TESTPROGS->Get($prog);
|
|
|
4888 |
$pProg = $TESTPROGS->NewAdd($prog)
|
|
|
4889 |
unless ( $pProg );
|
| 227 |
dpurdie |
4890 |
|
|
|
4891 |
#.. Parse all of the object, library and argument entries
|
|
|
4892 |
Debug( "TestProg: $prog" );
|
|
|
4893 |
foreach (@elements)
|
|
|
4894 |
{
|
|
|
4895 |
if ( /^[-]{1,2}([lL])(.*)/ )
|
|
|
4896 |
{
|
|
|
4897 |
#.. Target Library specified - add to library list.
|
|
|
4898 |
#
|
|
|
4899 |
Debug( "TestProg: lib -$1$2" );
|
| 289 |
dpurdie |
4900 |
$pProg->addItem('LIBS', "-$1$2");
|
| 227 |
dpurdie |
4901 |
next;
|
|
|
4902 |
}
|
|
|
4903 |
|
|
|
4904 |
if ( /^--if(.*)/ )
|
|
|
4905 |
{
|
|
|
4906 |
#.. Library conditional - add to library list.
|
|
|
4907 |
#
|
|
|
4908 |
Debug( "TestProg: cond $_" );
|
| 289 |
dpurdie |
4909 |
$pProg->addItem('LIBS', $_);
|
| 227 |
dpurdie |
4910 |
next;
|
|
|
4911 |
}
|
|
|
4912 |
|
|
|
4913 |
if ( /^-(.*)/ )
|
|
|
4914 |
{
|
|
|
4915 |
#.. Argument specified - add to argument list
|
|
|
4916 |
#
|
|
|
4917 |
Debug( "TestProg: arg $_" );
|
| 289 |
dpurdie |
4918 |
$pProg->addItem('ARGS', $_);
|
| 227 |
dpurdie |
4919 |
next;
|
|
|
4920 |
}
|
|
|
4921 |
|
| 369 |
dpurdie |
4922 |
if ( %::ScmToolsetProgSource )
|
| 227 |
dpurdie |
4923 |
{
|
|
|
4924 |
#
|
|
|
4925 |
# Toolset provides support for some file types
|
|
|
4926 |
# to be passed directly to the program builder
|
|
|
4927 |
#
|
|
|
4928 |
my $ext = StripFile($_);
|
|
|
4929 |
if ( exists ($::ScmToolsetProgSource{$ext}) )
|
|
|
4930 |
{
|
|
|
4931 |
my $full_path = MakeSrcResolve ( $_ );
|
|
|
4932 |
my $flag = $::ScmToolsetProgSource{$ext};
|
|
|
4933 |
Debug( "TestProg: src $_" );
|
| 289 |
dpurdie |
4934 |
$pProg->addItem('ARGS', "$flag$full_path");
|
| 227 |
dpurdie |
4935 |
next;
|
|
|
4936 |
}
|
|
|
4937 |
}
|
|
|
4938 |
|
|
|
4939 |
if ( $::o )
|
|
|
4940 |
{
|
|
|
4941 |
#.. Object specified - add to object list.
|
|
|
4942 |
#
|
|
|
4943 |
my $obj = _LibObject( "", $_ );
|
|
|
4944 |
|
|
|
4945 |
#.. Add to program object list.
|
| 289 |
dpurdie |
4946 |
$pProg->addItem('OBJS', "\$(OBJDIR)/$obj");
|
| 227 |
dpurdie |
4947 |
next;
|
|
|
4948 |
}
|
|
|
4949 |
|
|
|
4950 |
#
|
|
|
4951 |
# Don't know how to handle this type of argument
|
|
|
4952 |
#
|
|
|
4953 |
Error ("TestProg: Don't know how to handle: $_" );
|
|
|
4954 |
}
|
|
|
4955 |
}
|
|
|
4956 |
|
|
|
4957 |
|
|
|
4958 |
sub Prog
|
|
|
4959 |
{
|
|
|
4960 |
my( $platforms, $prog, @elements ) = @_;
|
|
|
4961 |
|
|
|
4962 |
Debug2( "Prog($platforms, $prog, @elements)" );
|
|
|
4963 |
|
|
|
4964 |
return if ( ! ActivePlatform($platforms) );
|
|
|
4965 |
|
|
|
4966 |
Error ("Prog: Program name not defined") unless ( $prog );
|
|
|
4967 |
Error ("Programs are not supported") unless ( defined $::exe );
|
|
|
4968 |
|
| 289 |
dpurdie |
4969 |
#
|
|
|
4970 |
# Create a new Prog object, or retrieve any existing one
|
|
|
4971 |
#
|
|
|
4972 |
my $pProg = $PROGS->Get($prog);
|
|
|
4973 |
$pProg = $PROGS->NewAdd($prog)
|
|
|
4974 |
unless ( $pProg );
|
| 227 |
dpurdie |
4975 |
|
|
|
4976 |
#.. Parse all of the object, library and argument entries
|
|
|
4977 |
Debug( "Prog: $prog" );
|
|
|
4978 |
foreach (@elements)
|
|
|
4979 |
{
|
|
|
4980 |
if ( /^[-]{1,2}([lL])(.*)/ )
|
|
|
4981 |
{
|
|
|
4982 |
#.. Target Library specified - add to library list.
|
|
|
4983 |
#
|
|
|
4984 |
Debug( "Prog: lib -$1$2" );
|
| 289 |
dpurdie |
4985 |
$pProg->addItem('LIBS', "-$1$2");
|
| 227 |
dpurdie |
4986 |
next;
|
|
|
4987 |
}
|
|
|
4988 |
|
|
|
4989 |
if ( /^--if(.*)/ )
|
|
|
4990 |
{
|
|
|
4991 |
#.. Library conditional - add to library list.
|
|
|
4992 |
#
|
|
|
4993 |
Debug( "Prog: cond $_" );
|
| 289 |
dpurdie |
4994 |
$pProg->addItem('LIBS', $_);
|
| 227 |
dpurdie |
4995 |
next;
|
|
|
4996 |
}
|
|
|
4997 |
|
|
|
4998 |
if ( /^-(.*)/ )
|
|
|
4999 |
{
|
|
|
5000 |
#.. Argument specified - add to argument list
|
|
|
5001 |
#
|
|
|
5002 |
Debug( "Prog: arg $_" );
|
| 289 |
dpurdie |
5003 |
$pProg->addItem('ARGS', $_);
|
| 227 |
dpurdie |
5004 |
next;
|
|
|
5005 |
}
|
|
|
5006 |
|
| 369 |
dpurdie |
5007 |
if ( %::ScmToolsetProgSource )
|
| 227 |
dpurdie |
5008 |
{
|
|
|
5009 |
#
|
|
|
5010 |
# Toolset provides support for some file types
|
|
|
5011 |
# to be passed directly to the program builder
|
|
|
5012 |
#
|
|
|
5013 |
my $ext = StripFile($_);
|
|
|
5014 |
if ( exists ($::ScmToolsetProgSource{$ext}) )
|
|
|
5015 |
{
|
|
|
5016 |
my $full_path = MakeSrcResolve ( $_ );
|
|
|
5017 |
my $flag = $::ScmToolsetProgSource{$ext};
|
|
|
5018 |
Debug( "Prog: src $_" );
|
| 289 |
dpurdie |
5019 |
$pProg->addItem('ARGS', "$flag$full_path");
|
| 227 |
dpurdie |
5020 |
next;
|
|
|
5021 |
}
|
|
|
5022 |
}
|
|
|
5023 |
|
|
|
5024 |
if ( $::o )
|
|
|
5025 |
{
|
|
|
5026 |
#.. Object specified - add to object list.
|
|
|
5027 |
#
|
|
|
5028 |
my $obj = _LibObject( "", $_ );
|
|
|
5029 |
|
|
|
5030 |
#.. Add to program object list.
|
| 289 |
dpurdie |
5031 |
$pProg->addItem('OBJS', "\$(OBJDIR)/$obj");
|
| 227 |
dpurdie |
5032 |
next;
|
|
|
5033 |
}
|
|
|
5034 |
|
|
|
5035 |
#
|
|
|
5036 |
# Don't know how to handle this type of argument
|
|
|
5037 |
#
|
|
|
5038 |
Error ("Prog: Don't know how to handle: $_" );
|
|
|
5039 |
}
|
|
|
5040 |
}
|
|
|
5041 |
|
|
|
5042 |
#-------------------------------------------------------------------------------
|
|
|
5043 |
# Function : ProgAddExtra
|
|
|
5044 |
#
|
|
|
5045 |
# Description : This (internal) function allows a toolset to list additional
|
|
|
5046 |
# binaries as a part of a program. This will ensure that the
|
|
|
5047 |
# binaries are generated in the 'make_prog' phase with the main
|
|
|
5048 |
# program.
|
|
|
5049 |
#
|
|
|
5050 |
# The files are not listed for packaging, by this function
|
|
|
5051 |
#
|
|
|
5052 |
# The function does not ensure that the files are not already
|
|
|
5053 |
# listed as a @PROG ( as @PROGS is not fully resolved at this point )
|
|
|
5054 |
#
|
|
|
5055 |
# Inputs : $name - Tag name of program being built
|
|
|
5056 |
# Not used (yet)
|
|
|
5057 |
# $prog - Fully resolved path to a file
|
|
|
5058 |
#
|
|
|
5059 |
# Returns : Nothing
|
|
|
5060 |
#
|
|
|
5061 |
sub ProgAddExtra
|
|
|
5062 |
{
|
|
|
5063 |
my ($name, $prog) = @_;
|
|
|
5064 |
Debug2( "ProgAddExtra($name: $prog)" );
|
|
|
5065 |
|
|
|
5066 |
UniquePush(\@PROGS_EXTRA, $prog);
|
|
|
5067 |
}
|
|
|
5068 |
|
|
|
5069 |
#-------------------------------------------------------------------------------
|
|
|
5070 |
# Function : MakeProject
|
|
|
5071 |
#
|
|
|
5072 |
# Description : A nasty directive that is intended to build a Microsoft
|
|
|
5073 |
# project for WINCE, WIN32 and .NET builds.
|
|
|
5074 |
#
|
|
|
5075 |
# There are many constraints:
|
|
|
5076 |
# Cannot be mixed with multi-platform builds
|
|
|
5077 |
# Some parameters are tool specific
|
|
|
5078 |
#
|
| 267 |
dpurdie |
5079 |
# Allow programs to be Installed as well as Packaged
|
|
|
5080 |
# The 'Progect' is treated' as a program and it doesn't work
|
|
|
5081 |
# to well if we Install libraries.
|
| 227 |
dpurdie |
5082 |
#
|
| 267 |
dpurdie |
5083 |
# Only Reason to Install Programs is to allow the Cab Maker
|
|
|
5084 |
# to locate them.
|
|
|
5085 |
#
|
| 227 |
dpurdie |
5086 |
# Inputs : Platform - Active platform
|
|
|
5087 |
# Project - Project Name with extension
|
|
|
5088 |
# Options - Many options
|
|
|
5089 |
#
|
|
|
5090 |
# Returns :
|
|
|
5091 |
#
|
|
|
5092 |
our %PROJECTS; # Project information
|
|
|
5093 |
my @PROJECTS_ORDER;
|
|
|
5094 |
sub MakeProject
|
|
|
5095 |
{
|
|
|
5096 |
my( $platforms, $proj, @elements ) = @_;
|
|
|
5097 |
|
|
|
5098 |
Debug2( "MakeProject($platforms, $proj, @elements)" );
|
|
|
5099 |
|
|
|
5100 |
return if ( ! ActivePlatform($platforms) );
|
|
|
5101 |
|
|
|
5102 |
#
|
|
|
5103 |
# Sanity test
|
|
|
5104 |
#
|
|
|
5105 |
Error ("MakeProject: Project name not defined") unless ( $proj );
|
|
|
5106 |
|
|
|
5107 |
#
|
|
|
5108 |
# Take the project name and convert it into a full path
|
|
|
5109 |
#
|
|
|
5110 |
my $project = MakeSrcResolve ( $proj );
|
|
|
5111 |
$proj = StripDir( $project );
|
| 237 |
dpurdie |
5112 |
Error ("Project File Not found: $project") unless ( -f $project );
|
| 227 |
dpurdie |
5113 |
|
|
|
5114 |
my $basedir = StripFileExt( $project );
|
|
|
5115 |
|
|
|
5116 |
#
|
|
|
5117 |
# Collect user arguments
|
|
|
5118 |
# They are all processed within the toolset
|
|
|
5119 |
#
|
|
|
5120 |
my @tool_options;
|
|
|
5121 |
foreach ( @elements )
|
|
|
5122 |
{
|
|
|
5123 |
if ( m/^--Debug/ ) {
|
|
|
5124 |
$PROJECTS{$proj}{'Debug'} = 1;
|
|
|
5125 |
|
|
|
5126 |
} elsif ( m/^--Prod/ ) {
|
|
|
5127 |
$PROJECTS{$proj}{'Prod'} = 1;
|
|
|
5128 |
|
| 267 |
dpurdie |
5129 |
} elsif ( m/^--(Package|Install)ProgDebug=(.*)/ ) {
|
|
|
5130 |
_PackageFromProject( $1, $proj, $basedir,'Prog', 'D', $2 );
|
| 227 |
dpurdie |
5131 |
|
| 267 |
dpurdie |
5132 |
} elsif ( m/^--(Package|Install)Prog(Prod)*=(.*)/ ) {
|
|
|
5133 |
_PackageFromProject( $1, $proj, $basedir, 'Prog', 'P', $3 );
|
| 227 |
dpurdie |
5134 |
|
| 267 |
dpurdie |
5135 |
} elsif ( m/^--(Package)LibDebug=(.*)/ ) {
|
|
|
5136 |
_PackageFromProject( $1, $proj, $basedir, 'Lib', 'D', $2 );
|
| 227 |
dpurdie |
5137 |
|
| 267 |
dpurdie |
5138 |
} elsif ( m/^--(Package)Lib(Prod)*=(.*)/ ) {
|
|
|
5139 |
_PackageFromProject( $1, $proj, $basedir, 'Lib', 'P', $3 );
|
| 227 |
dpurdie |
5140 |
|
| 267 |
dpurdie |
5141 |
} elsif ( m/^--(Package)SharedLibDebug=(.*)/ ) {
|
|
|
5142 |
_PackageFromProject( $1, $proj, $basedir, 'Lib', 'D', $2 );
|
| 227 |
dpurdie |
5143 |
|
| 267 |
dpurdie |
5144 |
} elsif ( m/^--(Package)SharedLib(Prod)*=(.*)/ ) {
|
|
|
5145 |
_PackageFromProject( $1, $proj, $basedir, 'Lib', 'P', $3 );
|
| 227 |
dpurdie |
5146 |
|
| 267 |
dpurdie |
5147 |
} elsif ( m/^--(Package)Hdr=(.*)/ ) {
|
|
|
5148 |
_PackageFromProject( $1, $proj, $basedir, 'Hdr', undef, $2 );
|
| 227 |
dpurdie |
5149 |
|
| 267 |
dpurdie |
5150 |
} elsif ( m/^--(Package)File=(.*)/ ) {
|
|
|
5151 |
_PackageFromProject( $1, $proj, $basedir, 'File', undef, $2 );
|
| 227 |
dpurdie |
5152 |
|
| 267 |
dpurdie |
5153 |
} elsif ( m/^--(Package)Tool(Prod)*=(.*)/ ) {
|
|
|
5154 |
_PackageFromProject( $1, $proj, $basedir, 'Tool', 'P', $3 );
|
| 241 |
dpurdie |
5155 |
|
| 267 |
dpurdie |
5156 |
} elsif ( m/^--(Package)ToolDebug=(.*)/ ) {
|
|
|
5157 |
_PackageFromProject( $1, $proj, $basedir, 'Tool', 'D', $2 );
|
| 241 |
dpurdie |
5158 |
|
| 267 |
dpurdie |
5159 |
} elsif ( m/^--(Package|Install)/ ) {
|
|
|
5160 |
Error("MakeProject. Unknown $1 option: $_");
|
| 227 |
dpurdie |
5161 |
|
|
|
5162 |
} else {
|
|
|
5163 |
push @tool_options, $_;
|
|
|
5164 |
}
|
|
|
5165 |
}
|
|
|
5166 |
|
|
|
5167 |
#
|
|
|
5168 |
# Save the information
|
|
|
5169 |
#
|
|
|
5170 |
$PROJECTS{$proj}{'options'} = \@tool_options;
|
|
|
5171 |
$PROJECTS{$proj}{'name'} = $proj;
|
|
|
5172 |
$PROJECTS{$proj}{'project'} = $project;
|
|
|
5173 |
$PROJECTS{$proj}{'basedir'} = $basedir;
|
|
|
5174 |
UniquePush (\@PROJECTS_ORDER, $proj);
|
|
|
5175 |
|
|
|
5176 |
#
|
|
|
5177 |
# Validate some of the arguments
|
|
|
5178 |
#
|
|
|
5179 |
Error ("Makeproject. Conflicting options --Debug and --Prod" )
|
|
|
5180 |
if ( $PROJECTS{$proj}{'Debug'} && $PROJECTS{$proj}{'Prod'} );
|
|
|
5181 |
}
|
|
|
5182 |
|
|
|
5183 |
#-------------------------------------------------------------------------------
|
|
|
5184 |
# Function : _PackageFromProject
|
|
|
5185 |
#
|
|
|
5186 |
# Description : Save Packaged data from the project
|
|
|
5187 |
#
|
| 267 |
dpurdie |
5188 |
# Inputs : $tgt - Install or Package
|
|
|
5189 |
# $proj - Name of the project
|
| 227 |
dpurdie |
5190 |
# $base - Base directory of files
|
|
|
5191 |
# $etype - Type of Package (Progs, Libs, ... )
|
|
|
5192 |
# $type - Debug or Production or both
|
|
|
5193 |
# $items - Item to add. It may be comma seperated
|
|
|
5194 |
#
|
| 267 |
dpurdie |
5195 |
my %PackageToData = ( 'Package' =>
|
|
|
5196 |
{ 'Hdr' => \%PACKAGE_HDRS,
|
|
|
5197 |
'Lib' => \%PACKAGE_LIBS,
|
|
|
5198 |
'Prog' => \%PACKAGE_PROGS,
|
|
|
5199 |
'File' => \%PACKAGE_FILES,
|
|
|
5200 |
'Tool' => \%PACKAGE_FILES,
|
|
|
5201 |
'_BASE' => 'PBase',
|
|
|
5202 |
},
|
|
|
5203 |
'Install' =>
|
|
|
5204 |
{ 'Hdr' => \%INSTALL_HDRS,
|
|
|
5205 |
'Lib' => \%INSTALL_LIBS,
|
|
|
5206 |
'Prog' => \%INSTALL_PROGS,
|
|
|
5207 |
'File' => undef,
|
|
|
5208 |
'Tool' => undef,
|
|
|
5209 |
'_BASE' => 'IBase',
|
|
|
5210 |
},
|
| 227 |
dpurdie |
5211 |
);
|
|
|
5212 |
|
|
|
5213 |
sub _PackageFromProject
|
|
|
5214 |
{
|
| 267 |
dpurdie |
5215 |
my( $tgt, $proj, $base, $etype, $type, $items ) = @_;
|
| 227 |
dpurdie |
5216 |
my $subdir = '';
|
|
|
5217 |
|
|
|
5218 |
#
|
| 267 |
dpurdie |
5219 |
# Sanity test
|
|
|
5220 |
#
|
|
|
5221 |
$type = '' unless ( $type );
|
|
|
5222 |
Error ("INTERNAL. Bad packaging option: $tgt") unless ( exists $PackageToData{$tgt} );
|
|
|
5223 |
Error ("INTERNAL. Bad packaging option: $etype") unless ( exists $PackageToData{$tgt}{$etype} );
|
|
|
5224 |
Error ("Unsupported packaging combination: $tgt$etype$type=$items") unless ( defined $PackageToData{$tgt}{$etype} );
|
|
|
5225 |
|
|
|
5226 |
#
|
|
|
5227 |
# Determine the index into the 'PackageInfo' structure
|
|
|
5228 |
# This provides the symbolic name for the target package path
|
|
|
5229 |
# for Package or Install
|
|
|
5230 |
#
|
|
|
5231 |
# The key '_BASE' is internal. Used only to provide this information
|
|
|
5232 |
#
|
|
|
5233 |
my $tbase = $PackageToData{$tgt}{'_BASE'};
|
|
|
5234 |
|
|
|
5235 |
#
|
| 227 |
dpurdie |
5236 |
# Process options
|
|
|
5237 |
#
|
|
|
5238 |
foreach my $item ( split (/,/, $items ) )
|
|
|
5239 |
{
|
|
|
5240 |
next unless ( $item =~ m/^--/ );
|
|
|
5241 |
if ( $item =~ m/^--Subdir=(.*)/ )
|
|
|
5242 |
{
|
|
|
5243 |
$subdir = '/' . $1;
|
|
|
5244 |
$subdir =~ s~//~/~g;
|
|
|
5245 |
$subdir =~ s~/$~~g;
|
|
|
5246 |
}
|
|
|
5247 |
else
|
|
|
5248 |
{
|
|
|
5249 |
Warning( "MakeProject: Unknown packaging option ignored: $_" );
|
|
|
5250 |
}
|
|
|
5251 |
}
|
|
|
5252 |
|
|
|
5253 |
#
|
|
|
5254 |
# Process files
|
|
|
5255 |
#
|
|
|
5256 |
foreach my $item ( split (/,/, $items ) )
|
|
|
5257 |
{
|
|
|
5258 |
next if ( $item =~ m/^--/ );
|
|
|
5259 |
|
| 267 |
dpurdie |
5260 |
my $tdir = $PackageInfo{$etype}{$tbase} . $PackageInfo{$etype}{'Dir'} . $subdir ;
|
| 227 |
dpurdie |
5261 |
my $fname = StripDir( $item );
|
|
|
5262 |
my $target = $tdir . '/' . $fname;
|
|
|
5263 |
|
|
|
5264 |
$item = "$base/$item" if ( $base );
|
|
|
5265 |
|
|
|
5266 |
#
|
|
|
5267 |
# Do not use $(GBE_TYPE) in the target name
|
|
|
5268 |
# The existing package mechanism does not handle different
|
|
|
5269 |
# production and debug file naming mechanism, whereas the project
|
|
|
5270 |
# must. Convert $(GBE_TYPE) into P or D to ensure uniquness
|
|
|
5271 |
#
|
| 387 |
dpurdie |
5272 |
$item = QuoteForMake($item);
|
|
|
5273 |
$target = QuoteForMake($target);
|
| 227 |
dpurdie |
5274 |
$target =~ s~\$\(GBE_TYPE\)~$type~ if ($type);
|
|
|
5275 |
|
|
|
5276 |
#
|
|
|
5277 |
# Create a PACKAGE entry suitable for processing by the normal packaging
|
|
|
5278 |
# routines. This is complicated because the Projects do not adhere to
|
| 267 |
dpurdie |
5279 |
# the JATS file name conventions
|
| 227 |
dpurdie |
5280 |
#
|
|
|
5281 |
my %package_entry;
|
|
|
5282 |
$package_entry{'src'} = $item;
|
|
|
5283 |
$package_entry{'dir'} = $tdir;
|
| 267 |
dpurdie |
5284 |
$package_entry{'set'} = 'ALL' if ($tgt eq 'Package');
|
| 227 |
dpurdie |
5285 |
$package_entry{'type'} = $type if ($type);
|
|
|
5286 |
|
| 267 |
dpurdie |
5287 |
$PackageToData{$tgt}{$etype}->{$target} = {%package_entry};
|
| 227 |
dpurdie |
5288 |
}
|
|
|
5289 |
}
|
|
|
5290 |
|
|
|
5291 |
#-------------------------------------------------------------------------------
|
|
|
5292 |
# Function : MakeAnt
|
|
|
5293 |
#
|
|
|
5294 |
# Description : A nasty directive to create JAR files via ANT
|
|
|
5295 |
# There are several limitations
|
|
|
5296 |
# This is closely related to the MakeProject directive
|
|
|
5297 |
#
|
|
|
5298 |
#
|
|
|
5299 |
# Inputs : Platform - Active platform
|
|
|
5300 |
# buildfile - Name of the build.xml file
|
|
|
5301 |
# Options - A few options
|
|
|
5302 |
# --Jar=file
|
|
|
5303 |
# Generated JAR file(s)
|
|
|
5304 |
# --GeneratedFile=file
|
|
|
5305 |
# Other generated files
|
|
|
5306 |
# Used to flag JNI that must
|
|
|
5307 |
# Occur early
|
|
|
5308 |
# --AutoTest=<name>
|
|
|
5309 |
# Supports unitAutomated unit test
|
|
|
5310 |
# by calling build target <name>
|
|
|
5311 |
# --UnitTest=<name>
|
|
|
5312 |
# Supports unit test
|
|
|
5313 |
# by calling build target <name>
|
|
|
5314 |
# --PackageBase
|
|
|
5315 |
# Provides path to base of all packages
|
|
|
5316 |
#
|
|
|
5317 |
# Returns :
|
|
|
5318 |
#
|
|
|
5319 |
our %JAR_FILES;
|
|
|
5320 |
sub MakeAnt
|
|
|
5321 |
{
|
|
|
5322 |
my( $platforms, $proj, @elements ) = @_;
|
|
|
5323 |
|
|
|
5324 |
Debug2( "MakeAnt($platforms, $proj, @elements)" );
|
|
|
5325 |
|
|
|
5326 |
return if ( ! ActivePlatform($platforms) );
|
|
|
5327 |
|
|
|
5328 |
#
|
|
|
5329 |
# Sanity test
|
|
|
5330 |
#
|
|
|
5331 |
Error ("MakeAnt: build.xml name not defined") unless ( $proj );
|
|
|
5332 |
|
|
|
5333 |
#
|
|
|
5334 |
# Take the project name and convert it into a full path
|
|
|
5335 |
#
|
|
|
5336 |
my $project;
|
|
|
5337 |
$project = MakeSrcResolve ( $proj );
|
|
|
5338 |
$proj = StripDir( $project );
|
| 237 |
dpurdie |
5339 |
Error ("Build File Not found: $project") unless ( -f $project );
|
| 227 |
dpurdie |
5340 |
|
|
|
5341 |
my $basedir = StripFileExt( $project );
|
|
|
5342 |
|
|
|
5343 |
#
|
|
|
5344 |
# Collect user arguments
|
|
|
5345 |
# They are all processed within the toolset
|
|
|
5346 |
#
|
|
|
5347 |
my @tool_options;
|
|
|
5348 |
my @generated;
|
|
|
5349 |
my $unit_tests;
|
|
|
5350 |
my $auto_tests;
|
|
|
5351 |
my $package_base;
|
|
|
5352 |
|
|
|
5353 |
foreach ( @elements )
|
|
|
5354 |
{
|
|
|
5355 |
if ( m/^--Debug/ ) {
|
|
|
5356 |
$PROJECTS{$proj}{'Debug'} = 1;
|
|
|
5357 |
|
|
|
5358 |
} elsif ( m/^--Prod/ ) {
|
|
|
5359 |
$PROJECTS{$proj}{'Prod'} = 1;
|
|
|
5360 |
|
|
|
5361 |
} elsif ( m/^--Jar=(.*)/ ) {
|
|
|
5362 |
my $tgt = $1;
|
|
|
5363 |
$tgt = "$basedir/$tgt" if ( $basedir );
|
|
|
5364 |
my $fn = StripDir( $1 );
|
|
|
5365 |
$JAR_FILES{$fn} = $tgt;
|
|
|
5366 |
GenerateSrcFile( 0, $tgt );
|
|
|
5367 |
|
|
|
5368 |
} elsif ( m/^--GeneratedFile=(.*)/ ) {
|
|
|
5369 |
my $tgt = $1;
|
|
|
5370 |
$tgt = "$basedir/$tgt" if ( $basedir );
|
|
|
5371 |
push @generated, $tgt;
|
|
|
5372 |
GenerateSrcFile( 2, $tgt );
|
|
|
5373 |
|
|
|
5374 |
} elsif ( m/^--UnitTest=(.*)/ ) {
|
|
|
5375 |
$unit_tests = $1
|
|
|
5376 |
|
|
|
5377 |
} elsif ( m/^--AutoTest=(.*)/ ) {
|
|
|
5378 |
$auto_tests = $1
|
|
|
5379 |
|
|
|
5380 |
} elsif ( m/^--PackageBase/ ) {
|
|
|
5381 |
$package_base = 1;
|
|
|
5382 |
|
|
|
5383 |
|
|
|
5384 |
} elsif ( m/^--/ ) {
|
|
|
5385 |
Error("MakeAnt. Unknown option ignored: $_");
|
|
|
5386 |
|
|
|
5387 |
} else {
|
|
|
5388 |
push @tool_options, $_;
|
|
|
5389 |
}
|
|
|
5390 |
}
|
|
|
5391 |
|
|
|
5392 |
#
|
|
|
5393 |
# Extend option arguments to include the base dir of packages
|
|
|
5394 |
# Create definitions of the form PACKAGE_<name>
|
|
|
5395 |
#
|
|
|
5396 |
for my $entry (@{$::ScmBuildPkgRules{$ScmPlatform} })
|
|
|
5397 |
{
|
|
|
5398 |
next unless ( $entry->{'TYPE'} eq 'link' );
|
|
|
5399 |
my $dir = $entry->{'ROOT'};
|
|
|
5400 |
my $name = $entry->{'NAME'};
|
|
|
5401 |
unless ( $package_base )
|
|
|
5402 |
{
|
|
|
5403 |
$dir .= '/jar';
|
|
|
5404 |
next unless ( -d $dir );
|
|
|
5405 |
}
|
|
|
5406 |
push @tool_options, "-DPACKAGE_$name=$dir";
|
|
|
5407 |
}
|
|
|
5408 |
#
|
|
|
5409 |
# Extend options to include the base dir of the created package
|
|
|
5410 |
# Allows careful use for direct packaging of artifacts
|
|
|
5411 |
#
|
|
|
5412 |
push @tool_options, '-DPACKAGEDIR=$(PWD)/$(PKGDIR)';
|
|
|
5413 |
|
|
|
5414 |
#
|
|
|
5415 |
# Save the information
|
|
|
5416 |
#
|
|
|
5417 |
$PROJECTS{$proj}{'options'} = \@tool_options;
|
|
|
5418 |
$PROJECTS{$proj}{'generated'} = \@generated if ( @generated );
|
|
|
5419 |
$PROJECTS{$proj}{'name'} = $proj;
|
|
|
5420 |
$PROJECTS{$proj}{'project'} = $project;
|
|
|
5421 |
$PROJECTS{$proj}{'basedir'} = $basedir;
|
|
|
5422 |
$PROJECTS{$proj}{'type'} = 'ant';
|
|
|
5423 |
$PROJECTS{$proj}{'unittest'} = $unit_tests if ( $unit_tests );
|
|
|
5424 |
$PROJECTS{$proj}{'autotest'} = $auto_tests if ( $auto_tests );
|
|
|
5425 |
UniquePush (\@PROJECTS_ORDER, $proj);
|
|
|
5426 |
|
|
|
5427 |
$TESTS_TO_AUTORUN = 1 if ( $auto_tests );
|
| 263 |
dpurdie |
5428 |
$TESTS_TO_RUN = 1 if ( $unit_tests || $auto_tests );
|
| 227 |
dpurdie |
5429 |
|
|
|
5430 |
#
|
|
|
5431 |
# Validate some of the arguments
|
|
|
5432 |
#
|
|
|
5433 |
Error ("MakeAnt. Conflicting options --Debug and --Prod" )
|
|
|
5434 |
if ( $PROJECTS{$proj}{'Debug'} && $PROJECTS{$proj}{'Prod'} );
|
|
|
5435 |
}
|
|
|
5436 |
|
|
|
5437 |
###############################################################################
|
|
|
5438 |
#
|
|
|
5439 |
# Installation/Packaging util functions
|
|
|
5440 |
#
|
|
|
5441 |
#-------------------------------------------------------------------------------
|
|
|
5442 |
# Function : __TargetDir
|
|
|
5443 |
#
|
|
|
5444 |
# Description : Internal function to process common arguments for
|
|
|
5445 |
# the PackageXxx directives
|
|
|
5446 |
#
|
|
|
5447 |
# Inputs : flags - Indicate how to handle this argument
|
|
|
5448 |
# base - Base directory for this type of package
|
|
|
5449 |
# argument - Argument to process
|
|
|
5450 |
# pdir - Reference to resultant directory
|
|
|
5451 |
# ptype - Reference to resultant type (P or D)(optional)
|
|
|
5452 |
#
|
|
|
5453 |
# Returns : 0 - Agument not consumed
|
|
|
5454 |
# 1 - Argument consumed
|
|
|
5455 |
# 2 - Skip this directive
|
|
|
5456 |
#
|
|
|
5457 |
my $T_TYPE = 0x0001; # Postfix GBE_TYPE
|
|
|
5458 |
my $T_PKG = 0x0002; # Special --Dir handling
|
|
|
5459 |
my $T_MACH = 0x0004; # Allow --Machine too
|
|
|
5460 |
my $T_GBE = 0x0008; # Allow --Gbe too
|
|
|
5461 |
my $T_FILE = 0x0010; # Suffix or prefix subdir
|
|
|
5462 |
|
|
|
5463 |
sub __TargetDir
|
|
|
5464 |
{
|
|
|
5465 |
my( $flags, $base, $argument, $pdir, $ptype ) = @_;
|
|
|
5466 |
my $dir = "";
|
|
|
5467 |
my $consumed = 0;
|
|
|
5468 |
|
|
|
5469 |
#
|
|
|
5470 |
# Generate basic parts
|
|
|
5471 |
# Note Product will default to Platform
|
|
|
5472 |
#
|
|
|
5473 |
my $str_platform = '$(GBE_PLATFORM)';
|
|
|
5474 |
my $str_product = $ScmProduct ? '$(GBE_PRODUCT)' : '$(GBE_PLATFORM)';
|
|
|
5475 |
my $str_target = '$(GBE_TARGET)';
|
|
|
5476 |
my $str_common = '$(GBE_OS_COMMON)';
|
|
|
5477 |
|
|
|
5478 |
my $str_common_avail = 0;
|
|
|
5479 |
$str_common_avail = 1 if ( exists( $::BUILDINFO{$ScmPlatform}{OS_COMMON} ));
|
|
|
5480 |
|
|
|
5481 |
|
|
|
5482 |
#
|
|
|
5483 |
# Add requested suffix
|
|
|
5484 |
#
|
|
|
5485 |
if ($flags & $T_TYPE)
|
|
|
5486 |
{
|
|
|
5487 |
$str_platform .= '$(GBE_TYPE)';
|
|
|
5488 |
$str_product .= '$(GBE_TYPE)';
|
|
|
5489 |
$str_target .= '$(GBE_TYPE)';
|
|
|
5490 |
$str_common .= '$(GBE_TYPE)';
|
|
|
5491 |
}
|
|
|
5492 |
|
|
|
5493 |
#
|
|
|
5494 |
# Process the argument
|
|
|
5495 |
#
|
|
|
5496 |
$_ = $argument;
|
|
|
5497 |
if ( /^--Debug/ ) { # In the Debug build only
|
|
|
5498 |
if ( $ptype ) {
|
|
|
5499 |
$$ptype = "D";
|
|
|
5500 |
$consumed = 1;
|
|
|
5501 |
}
|
|
|
5502 |
|
|
|
5503 |
} elsif ( /^--Prod$/ || /^--Production$/ ) { # In the Production build only
|
|
|
5504 |
if ( $ptype ) {
|
|
|
5505 |
$$ptype = "P";
|
|
|
5506 |
$consumed = 1;
|
|
|
5507 |
}
|
|
|
5508 |
|
|
|
5509 |
} elsif (/^--Prefix=(.*)/) { # Prefix with subdir
|
|
|
5510 |
$dir = "$base/$1";
|
|
|
5511 |
|
|
|
5512 |
} elsif (/^--Subdir=(.*)/) { # same as 'prefix'
|
|
|
5513 |
$dir = "$base/$1";
|
|
|
5514 |
|
|
|
5515 |
} elsif (/^--Platform$/) { # Platform installation
|
|
|
5516 |
$dir = "$base/$str_platform";
|
|
|
5517 |
|
|
|
5518 |
} elsif (/^--Platform=(.*?),(.*)/) { # prefix and suffix with platform specific subdir
|
|
|
5519 |
$dir = "$base/$1/$str_platform/$2";
|
|
|
5520 |
|
|
|
5521 |
} elsif (/^--Platform=(.*)/) { # prefix with platform specific subdir
|
|
|
5522 |
if ($flags & $T_FILE) {
|
|
|
5523 |
$dir = "$base/$1/$str_platform";
|
|
|
5524 |
} else {
|
|
|
5525 |
$dir = "$base/$str_platform/$1";
|
|
|
5526 |
}
|
|
|
5527 |
|
|
|
5528 |
} elsif (/^--Product$/) { # Product installation
|
|
|
5529 |
$dir = "$base/$str_product";
|
|
|
5530 |
|
|
|
5531 |
} elsif (/^--Product=(.*?),(.*)/) { # prefix and suffix with product specific subdir
|
|
|
5532 |
$dir = "$base/$1/$str_product/$2";
|
|
|
5533 |
|
|
|
5534 |
} elsif (/^--Product=(.*)/) { # prefix with product specific subdir
|
|
|
5535 |
if ($flags & $T_FILE) {
|
|
|
5536 |
$dir = "$base/$1/$str_product";
|
|
|
5537 |
} else {
|
|
|
5538 |
$dir = "$base/$str_product/$1";
|
|
|
5539 |
}
|
|
|
5540 |
|
|
|
5541 |
} elsif (/^--Target$/) { # Target installation
|
|
|
5542 |
$dir = "$base/$str_target";
|
|
|
5543 |
|
|
|
5544 |
} elsif (/^--Target=(.*?),(.*)/) { # prefix and suffix with target specific subdir
|
|
|
5545 |
$dir = "$base/$1/$str_target/$2";
|
|
|
5546 |
|
|
|
5547 |
} elsif (/^--Target=(.*)/) { # prefix with target specific subdir
|
|
|
5548 |
if ($flags & $T_FILE) {
|
|
|
5549 |
$dir = "$base/$1/$str_target";
|
|
|
5550 |
} else {
|
|
|
5551 |
$dir = "$base/$str_target/$1";
|
|
|
5552 |
}
|
|
|
5553 |
|
|
|
5554 |
} elsif (/^--OsCommon/) {
|
|
|
5555 |
|
|
|
5556 |
unless ( $str_common_avail ) {
|
|
|
5557 |
Warning("Packaging option --OsCommon not supported on this platform($ScmPlatform). Directive skipped");
|
|
|
5558 |
$consumed = 2;
|
|
|
5559 |
|
|
|
5560 |
} elsif (/^--OsCommon$/) { # OS installation
|
|
|
5561 |
$dir = "$base/$str_common";
|
|
|
5562 |
|
|
|
5563 |
} elsif (/^--OsCommon=(.*?),(.*)/) { # prefix and suffix with target specific subdir
|
|
|
5564 |
$dir = "$base/$1/$str_common/$2";
|
|
|
5565 |
|
|
|
5566 |
} elsif (/^--OsCommon=(.*)/) { # prefix with target specific subdir
|
|
|
5567 |
if ($flags & $T_FILE) {
|
|
|
5568 |
$dir = "$base/$1/$str_common";
|
|
|
5569 |
} else {
|
|
|
5570 |
$dir = "$base/$str_common/$1";
|
|
|
5571 |
}
|
|
|
5572 |
}
|
|
|
5573 |
|
|
|
5574 |
} elsif (/^--Derived=(.*?),(.*?),(.*)/) { # Derived target + prefix + subdir
|
|
|
5575 |
$dir = "$base/$2/$1_$str_platform/$3";
|
|
|
5576 |
|
|
|
5577 |
} elsif (/^--Derived=(.*?),(.*)/) { # Derived target + subdir
|
|
|
5578 |
if ($flags & $T_FILE) {
|
|
|
5579 |
$dir = "$base/$2/$1_$str_platform";
|
|
|
5580 |
} else {
|
|
|
5581 |
$dir = "$base/$1_$str_platform/$2";
|
|
|
5582 |
}
|
|
|
5583 |
|
|
|
5584 |
} elsif (/^--Derived=(.*)/) { # Derived target
|
|
|
5585 |
$dir = "$base/$1_$str_platform";
|
|
|
5586 |
|
|
|
5587 |
} elsif ($flags & $T_MACH && /^--Machine(([=])(.*))?$/) { # Allow Machine and Machine=xxx specfic target
|
|
|
5588 |
#
|
|
|
5589 |
# Special: Append machine type to user dir
|
|
|
5590 |
# Intended to create tools/bin/win32 and tools/bin/sparc directories
|
|
|
5591 |
my $path = ( defined( $3) ) ? "/$3" : "";
|
|
|
5592 |
$dir = "$base$path/\$(GBE_HOSTMACH)";
|
|
|
5593 |
|
|
|
5594 |
} elsif ($flags & $T_GBE && /^--Gbe(([=])(.*))?$/) { # Allow Gbe and Gbe=xxx specfic target
|
|
|
5595 |
my $path = ( defined( $3) ) ? "/$3" : "";
|
|
|
5596 |
$dir = "$base/gbe$path";
|
|
|
5597 |
|
|
|
5598 |
} elsif (/^--Dir=(.*)/) { # prefix with target specific subdir
|
|
|
5599 |
Error ('Packaging directive with --Dir option does not specify a directory.',
|
|
|
5600 |
'Possible bad use of option of the form:--Dir=$xxx',
|
|
|
5601 |
'Note: Use of package.pl and this construct is deprecated') unless ( $1 );
|
| 241 |
dpurdie |
5602 |
my $udir = $1;
|
|
|
5603 |
|
|
|
5604 |
#
|
|
|
5605 |
# Remove leading ./
|
|
|
5606 |
# Check for leading ../
|
|
|
5607 |
while ( $udir =~ s{^\./}{} ){};
|
|
|
5608 |
|
|
|
5609 |
if ( $udir =~ m~^\.\./~ )
|
|
|
5610 |
{
|
|
|
5611 |
Warning("Packaging directive with --Dir option contains relative path (removed)", "Option: $_");
|
|
|
5612 |
while ( $udir =~ s{^\.\./}{} ){};
|
|
|
5613 |
}
|
| 227 |
dpurdie |
5614 |
if ($flags & $T_PKG) {
|
| 241 |
dpurdie |
5615 |
$dir = __PkgDir( $udir );
|
| 227 |
dpurdie |
5616 |
} else {
|
| 241 |
dpurdie |
5617 |
$dir = "\$(LOCALDIR)/$udir";
|
| 227 |
dpurdie |
5618 |
}
|
|
|
5619 |
}
|
|
|
5620 |
|
|
|
5621 |
return ($consumed) if ($dir eq "");
|
|
|
5622 |
$dir =~ s~//~/~g;
|
|
|
5623 |
$dir =~ s~/$~~;
|
|
|
5624 |
$$pdir = $dir;
|
|
|
5625 |
return (1);
|
|
|
5626 |
}
|
|
|
5627 |
|
|
|
5628 |
|
|
|
5629 |
# __PkgDir ---
|
|
|
5630 |
# Convert --Dir Package directives, removing leading subdir if
|
|
|
5631 |
# matching the global $Pbase value.
|
|
|
5632 |
#
|
|
|
5633 |
# Required as PKGDIR has the value 'GBE_ROOT/pkg/$Pbase'.
|
|
|
5634 |
# Required to maintain compatability with older (package.pl) constructs
|
|
|
5635 |
#..
|
|
|
5636 |
|
|
|
5637 |
sub __PkgDir
|
|
|
5638 |
{
|
|
|
5639 |
my( $dir ) = @_;
|
|
|
5640 |
my $org = $dir;
|
|
|
5641 |
|
| 245 |
dpurdie |
5642 |
$dir =~ s~^\Q$::Pbase\E[/]?~~;
|
| 227 |
dpurdie |
5643 |
Debug2( " PkgDir: converted \"$org\" to \"$dir\"" );
|
|
|
5644 |
|
|
|
5645 |
$dir = "\$(PKGDIR)/$dir";
|
|
|
5646 |
return $dir;
|
|
|
5647 |
}
|
|
|
5648 |
|
|
|
5649 |
|
|
|
5650 |
# getMajorMinor ---
|
|
|
5651 |
# Just a little help to deal with major/minor stuff for shared libs -
|
|
|
5652 |
# given the name of the library as the argument, split out major and
|
|
|
5653 |
# minor parts and return the basename, i.e name without major and minor
|
|
|
5654 |
# and the pair of major and minor.
|
|
|
5655 |
#..
|
|
|
5656 |
|
| 285 |
dpurdie |
5657 |
sub getMajorMinor
|
| 227 |
dpurdie |
5658 |
{
|
|
|
5659 |
my @bits = split ('\.', $_[0]);
|
|
|
5660 |
my $stop;
|
|
|
5661 |
my $major;
|
|
|
5662 |
my $minor;
|
|
|
5663 |
|
|
|
5664 |
if ( $#bits > 2 )
|
|
|
5665 |
{
|
|
|
5666 |
$stop = $#bits - 2;
|
|
|
5667 |
$major = $bits[$#bits-1];
|
|
|
5668 |
$minor = $bits[$#bits];
|
|
|
5669 |
}
|
|
|
5670 |
elsif ($#bits > 1)
|
|
|
5671 |
{
|
|
|
5672 |
$stop = $#bits-1;
|
|
|
5673 |
$major = $bits[$#bits];
|
|
|
5674 |
$minor=0;
|
|
|
5675 |
}
|
|
|
5676 |
else
|
|
|
5677 |
{
|
|
|
5678 |
$stop = $#bits; $major = 1; $minor = 0;
|
|
|
5679 |
}
|
|
|
5680 |
|
|
|
5681 |
my $base = $bits[0];
|
|
|
5682 |
for ( my $i=1; $i <= $stop; $i++ ) {
|
|
|
5683 |
$base = join ('.', $base, $bits[$i]);
|
|
|
5684 |
}
|
|
|
5685 |
|
|
|
5686 |
return ($base, $major, $minor);
|
|
|
5687 |
}
|
|
|
5688 |
|
|
|
5689 |
###############################################################################
|
|
|
5690 |
#
|
|
|
5691 |
# Installation
|
|
|
5692 |
#
|
|
|
5693 |
|
|
|
5694 |
sub InstallHdr
|
|
|
5695 |
{
|
|
|
5696 |
my( $platforms, @elements ) = @_;
|
| 335 |
dpurdie |
5697 |
my( $base, $dir, $srcfile, $full, $strip, $package );
|
| 227 |
dpurdie |
5698 |
my( $len, $name, $basename );
|
|
|
5699 |
|
|
|
5700 |
Debug2( "InstallHdr($platforms, @elements)" );
|
|
|
5701 |
|
|
|
5702 |
return if ( ! ActivePlatform($platforms) );
|
|
|
5703 |
Warning ("InstallHdr: Needs local directory specified in build.pl") unless ( $::ScmLocal );
|
|
|
5704 |
|
|
|
5705 |
#.. Arguments
|
|
|
5706 |
#
|
|
|
5707 |
$base = $PackageInfo{'Hdr'}{'IBase'}; # Base of target
|
|
|
5708 |
$dir = $base . $PackageInfo{'Hdr'}{'Dir'}; # Installation path (default)
|
| 335 |
dpurdie |
5709 |
$full = $strip = 0;
|
| 227 |
dpurdie |
5710 |
|
| 285 |
dpurdie |
5711 |
foreach ( @elements )
|
| 227 |
dpurdie |
5712 |
{
|
|
|
5713 |
# Standard targets
|
|
|
5714 |
my $rv = __TargetDir(0, $base, $_, \$dir);
|
|
|
5715 |
next if ( $rv == 1 );
|
|
|
5716 |
return if ( $rv == 2 );
|
|
|
5717 |
|
|
|
5718 |
if (/^--Full/) { # using full (resolved) path
|
|
|
5719 |
$full = 1;
|
|
|
5720 |
|
|
|
5721 |
} elsif (/^--Strip$/) { # Strip path from source files
|
|
|
5722 |
$strip = 1;
|
|
|
5723 |
|
|
|
5724 |
# Package
|
|
|
5725 |
} elsif (/^--Package$/ || /^--Package=(.*)/) {
|
|
|
5726 |
$package = 1;
|
|
|
5727 |
|
|
|
5728 |
} elsif (/^--(.*)/) {
|
|
|
5729 |
Message( "InstallHdr: unknown option $_ -- ignored\n" );
|
|
|
5730 |
}
|
|
|
5731 |
}
|
|
|
5732 |
|
|
|
5733 |
#.. Files
|
|
|
5734 |
#
|
| 285 |
dpurdie |
5735 |
foreach ( @elements )
|
| 227 |
dpurdie |
5736 |
{
|
|
|
5737 |
my %package_entry;
|
|
|
5738 |
if ( ! /^--(.*)/ )
|
|
|
5739 |
{
|
|
|
5740 |
$name = $_;
|
|
|
5741 |
$basename = StripDir( $name );
|
| 335 |
dpurdie |
5742 |
if ( !($srcfile = $SRCS{ $basename }) ) {
|
|
|
5743 |
$srcfile = $name;
|
|
|
5744 |
}
|
|
|
5745 |
|
| 227 |
dpurdie |
5746 |
if ( $full )
|
|
|
5747 |
{
|
| 335 |
dpurdie |
5748 |
my $subdir = StripFileExt($srcfile);
|
|
|
5749 |
$subdir = $1
|
|
|
5750 |
if ( $subdir =~ m~^$ProjectBase/(.*)~ );
|
|
|
5751 |
$dir .= '/' . $subdir;
|
|
|
5752 |
$dir =~ s~//~/~g;
|
|
|
5753 |
$dir =~ s~/./~/~g;
|
|
|
5754 |
$dir =~ s~/$~~g;
|
|
|
5755 |
$name = $basename;
|
| 227 |
dpurdie |
5756 |
}
|
|
|
5757 |
|
|
|
5758 |
$name = $basename
|
|
|
5759 |
if ( $strip );
|
|
|
5760 |
|
|
|
5761 |
Debug( "InstallHdr( $dir/$name, src: $srcfile, dest: $dir)" );
|
|
|
5762 |
|
|
|
5763 |
$package_entry{'src'} = $srcfile;
|
|
|
5764 |
$package_entry{'dir'} = StripFileExt( "$dir/$name" );
|
|
|
5765 |
$INSTALL_HDRS{ "$dir/$name" } = {%package_entry};
|
|
|
5766 |
}
|
|
|
5767 |
}
|
|
|
5768 |
|
|
|
5769 |
#.. Package
|
|
|
5770 |
#
|
|
|
5771 |
PackageHdr( @_ ) # auto package
|
|
|
5772 |
if ( $package );
|
|
|
5773 |
}
|
|
|
5774 |
|
|
|
5775 |
|
|
|
5776 |
sub InstallLib
|
|
|
5777 |
{
|
|
|
5778 |
my( $platforms, @elements ) = @_;
|
|
|
5779 |
my( $base, $dir, $package );
|
|
|
5780 |
my( $lib, $strip );
|
| 289 |
dpurdie |
5781 |
my $org_lib;
|
| 227 |
dpurdie |
5782 |
|
|
|
5783 |
Debug2( "InstallLib($platforms, @elements)" );
|
|
|
5784 |
|
|
|
5785 |
return if ( ! ActivePlatform($platforms) );
|
|
|
5786 |
Warning ("InstallLib: Needs local directory specified in build.pl") unless ( $::ScmLocal );
|
|
|
5787 |
|
|
|
5788 |
#.. Arguments
|
|
|
5789 |
#
|
|
|
5790 |
$base = $PackageInfo{'Lib'}{'IBase'}; # Base of target
|
|
|
5791 |
$dir = $base . $PackageInfo{'Lib'}{'Dir'}; # Installation path (default)
|
|
|
5792 |
|
| 285 |
dpurdie |
5793 |
foreach ( @elements )
|
| 227 |
dpurdie |
5794 |
{
|
|
|
5795 |
# Standard targets
|
|
|
5796 |
my $rv = __TargetDir(0, $base, $_, \$dir);
|
|
|
5797 |
next if ( $rv == 1 );
|
|
|
5798 |
return if ( $rv == 2 );
|
|
|
5799 |
|
|
|
5800 |
if (/^--Package$/ || /^--Package=(.*)/) {
|
|
|
5801 |
$package = 1;
|
|
|
5802 |
|
|
|
5803 |
} elsif (/^--Strip$/) { # Strip path from source files
|
|
|
5804 |
$strip = 1;
|
|
|
5805 |
|
|
|
5806 |
} elsif (/^--(.*)/) {
|
|
|
5807 |
Message( "InstallLib: unknown option $_ -- ignored\n" );
|
|
|
5808 |
}
|
|
|
5809 |
}
|
|
|
5810 |
|
|
|
5811 |
#.. Files
|
|
|
5812 |
#
|
| 285 |
dpurdie |
5813 |
foreach ( @elements )
|
| 227 |
dpurdie |
5814 |
{
|
|
|
5815 |
my %package_entry;
|
|
|
5816 |
if ( ! /^--(.*)/ )
|
|
|
5817 |
{
|
|
|
5818 |
$_ = basename ($_)
|
|
|
5819 |
if ( $strip );
|
| 289 |
dpurdie |
5820 |
$org_lib = $_; # Original name
|
| 227 |
dpurdie |
5821 |
|
|
|
5822 |
if ( $ScmTargetHost eq "Unix" ) {
|
|
|
5823 |
$lib = "lib$_"; # Prefix "lib" ....
|
|
|
5824 |
$lib =~ s/^liblib/lib/; # @LIBS already has lib added
|
|
|
5825 |
} else {
|
|
|
5826 |
$lib = $_;
|
|
|
5827 |
}
|
|
|
5828 |
|
| 289 |
dpurdie |
5829 |
if ( my $libp = $SHLIBS->Get($lib) )
|
| 227 |
dpurdie |
5830 |
{
|
|
|
5831 |
Debug( "InstallLib( $dir/$lib\$(GBE_TYPE).$::so, " .
|
|
|
5832 |
"src: \$(LIBDIR)/$lib\$(GBE_TYPE).$::so, dest: $dir)" );
|
|
|
5833 |
|
|
|
5834 |
#
|
|
|
5835 |
# Create a "placekeeper" entry within $INSTALL_SHLIBS
|
|
|
5836 |
# The exact format of the name of the shared library is
|
|
|
5837 |
# toolset specific. Create an entry to allow the toolset
|
|
|
5838 |
# to extend the packaging information when the shared library
|
|
|
5839 |
# recipe is constructed.
|
|
|
5840 |
#
|
| 289 |
dpurdie |
5841 |
my $ver = $libp->{ VERSION };
|
| 227 |
dpurdie |
5842 |
my $name = "$dir/$lib.$ver.PlaceKeeper";
|
|
|
5843 |
|
|
|
5844 |
$package_entry{'placekeeper'} = 1;
|
|
|
5845 |
$package_entry{'version'} = $ver;
|
|
|
5846 |
$package_entry{'lib'} = $lib;
|
|
|
5847 |
$package_entry{'dir'} = $dir;
|
| 289 |
dpurdie |
5848 |
|
|
|
5849 |
push @{$SHLIB_INS{$lib}}, $name;
|
| 227 |
dpurdie |
5850 |
$INSTALL_SHLIBS{$name} = {%package_entry};
|
|
|
5851 |
}
|
|
|
5852 |
|
| 289 |
dpurdie |
5853 |
#
|
|
|
5854 |
# Clean up the package_entry
|
|
|
5855 |
# Insert common items
|
|
|
5856 |
#
|
|
|
5857 |
%package_entry = ();
|
|
|
5858 |
$package_entry{'lib'} = $lib;
|
|
|
5859 |
$package_entry{'dir'} = $dir;
|
|
|
5860 |
|
| 321 |
dpurdie |
5861 |
if ( my $libfile = $SRCS{$org_lib} )
|
| 227 |
dpurdie |
5862 |
{
|
|
|
5863 |
#
|
|
|
5864 |
# Allow the user to package a sourced file as a library
|
| 289 |
dpurdie |
5865 |
# But must be the un-massaged name of the file.
|
| 227 |
dpurdie |
5866 |
#
|
| 289 |
dpurdie |
5867 |
$package_entry{'dst'} = "$dir/$org_lib";
|
|
|
5868 |
$package_entry{'src'} = $libfile;
|
|
|
5869 |
}
|
|
|
5870 |
elsif ( $LIBS->Get($lib) )
|
|
|
5871 |
{
|
|
|
5872 |
#
|
|
|
5873 |
# Install a library known to the makefile
|
|
|
5874 |
#
|
|
|
5875 |
my $libp = $LIBS->Get($lib);
|
| 227 |
dpurdie |
5876 |
|
| 289 |
dpurdie |
5877 |
$package_entry{'dst'} = $dir . '/' . $libp->getFullName();
|
|
|
5878 |
$package_entry{'src'} = $libp->getPath();
|
| 227 |
dpurdie |
5879 |
}
|
| 289 |
dpurdie |
5880 |
elsif ( ! $SHLIBS->Get($lib) )
|
| 227 |
dpurdie |
5881 |
{
|
| 289 |
dpurdie |
5882 |
#
|
|
|
5883 |
# Not a known shared lib
|
|
|
5884 |
# Not a known static lib
|
|
|
5885 |
# Not a 'sourced' file
|
|
|
5886 |
# Assume the a static library has magically appeared
|
|
|
5887 |
# in the standard LIB directory. May have been placed there
|
|
|
5888 |
# by a 'rule'
|
|
|
5889 |
#
|
|
|
5890 |
my $libp = $LIBS->New($lib);
|
| 227 |
dpurdie |
5891 |
|
| 289 |
dpurdie |
5892 |
$package_entry{'dst'} = $dir . '/' . $libp->getFullName();
|
|
|
5893 |
$package_entry{'src'} = $libp->getPath();
|
|
|
5894 |
}
|
| 227 |
dpurdie |
5895 |
|
| 289 |
dpurdie |
5896 |
#
|
|
|
5897 |
# Add entry to various lists if required
|
|
|
5898 |
#
|
|
|
5899 |
PackageLib_AddEntry ('InstallLib', \%LIB_INS, \%INSTALL_LIBS, \%package_entry )
|
|
|
5900 |
if ( exists $package_entry{'dst'} );
|
| 227 |
dpurdie |
5901 |
}
|
|
|
5902 |
}
|
|
|
5903 |
|
|
|
5904 |
#.. Package
|
|
|
5905 |
#
|
|
|
5906 |
PackageLib( @_ ) # auto package
|
|
|
5907 |
if ( $package );
|
|
|
5908 |
}
|
|
|
5909 |
|
|
|
5910 |
|
|
|
5911 |
sub InstallJar
|
|
|
5912 |
{
|
|
|
5913 |
my( $platforms, @elements ) = @_;
|
|
|
5914 |
my( $base, $dir, $package );
|
|
|
5915 |
my( $jar );
|
|
|
5916 |
|
|
|
5917 |
Debug2( "InstallJar($platforms, @elements)" );
|
|
|
5918 |
|
|
|
5919 |
return if ( ! ActivePlatform($platforms) );
|
|
|
5920 |
Warning ("InstallJar: Needs local directory specified in build.pl") unless ( $::ScmLocal );
|
|
|
5921 |
|
|
|
5922 |
#.. Arguments
|
|
|
5923 |
#
|
|
|
5924 |
$base = $PackageInfo{'Jar'}{'IBase'}; # Base of target
|
|
|
5925 |
$dir = $base . $PackageInfo{'Jar'}{'Dir'}; # Installation path (default)
|
|
|
5926 |
|
| 285 |
dpurdie |
5927 |
foreach ( @elements )
|
| 227 |
dpurdie |
5928 |
{
|
|
|
5929 |
# Standard targets
|
|
|
5930 |
my $rv = __TargetDir(0, $base, $_, \$dir);
|
|
|
5931 |
next if ( $rv == 1 );
|
|
|
5932 |
return if ( $rv == 2 );
|
|
|
5933 |
|
|
|
5934 |
if (/^--Package$/ || /^--Package=(.*)/) {
|
|
|
5935 |
$package = 1;
|
|
|
5936 |
|
|
|
5937 |
} elsif (/^--(.*)/) {
|
|
|
5938 |
Message( "InstallJar: unknown option $_ -- ignored\n" );
|
|
|
5939 |
}
|
|
|
5940 |
}
|
|
|
5941 |
|
|
|
5942 |
|
|
|
5943 |
#.. Files
|
|
|
5944 |
#
|
| 285 |
dpurdie |
5945 |
foreach ( @elements )
|
| 227 |
dpurdie |
5946 |
{
|
|
|
5947 |
my %package_entry;
|
|
|
5948 |
if ( ! /^--(.*)/ )
|
|
|
5949 |
{
|
|
|
5950 |
$jar = $_;
|
|
|
5951 |
my $src;
|
|
|
5952 |
my $dest;
|
|
|
5953 |
|
|
|
5954 |
if ( $JAR_FILES{$jar} )
|
|
|
5955 |
{
|
|
|
5956 |
$src = $JAR_FILES{$jar};
|
|
|
5957 |
$dest = $jar;
|
|
|
5958 |
}
|
|
|
5959 |
else
|
|
|
5960 |
{
|
|
|
5961 |
$src = "\$(CLSDIR)/$jar\$(GBE_TYPE).jar";
|
|
|
5962 |
$dest = "$jar\$(GBE_TYPE).jar";
|
|
|
5963 |
}
|
|
|
5964 |
|
|
|
5965 |
|
|
|
5966 |
Debug( "InstallJar( $dir/$dest, " .
|
|
|
5967 |
"src: $src, dest: $dir)" );
|
|
|
5968 |
|
|
|
5969 |
$package_entry{'src'} = $src;
|
|
|
5970 |
$package_entry{'dir'} = $dir;
|
|
|
5971 |
$INSTALL_CLSS{ "$dir/$dest" } = {%package_entry};
|
|
|
5972 |
|
|
|
5973 |
}
|
|
|
5974 |
}
|
|
|
5975 |
|
|
|
5976 |
#.. Package
|
|
|
5977 |
#
|
|
|
5978 |
PackageJar( @_ ) # auto package
|
|
|
5979 |
if ( $package );
|
|
|
5980 |
}
|
|
|
5981 |
|
|
|
5982 |
|
|
|
5983 |
sub InstallProg
|
|
|
5984 |
{
|
|
|
5985 |
my( $platforms, @elements ) = @_;
|
|
|
5986 |
my( $base, $dir, $package );
|
|
|
5987 |
my( $prog );
|
|
|
5988 |
|
|
|
5989 |
Debug2( "InstallProg($platforms, @elements)" );
|
|
|
5990 |
|
|
|
5991 |
return if ( ! ActivePlatform($platforms) );
|
|
|
5992 |
Warning ("InstallProg: Needs local directory specified in build.pl") unless ( $::ScmLocal );
|
|
|
5993 |
|
|
|
5994 |
#.. Arguments
|
|
|
5995 |
#
|
|
|
5996 |
$base = $PackageInfo{'Prog'}{'IBase'}; # Base of target
|
|
|
5997 |
$dir = $base . $PackageInfo{'Prog'}{'Dir'}; # Installation path (default)
|
|
|
5998 |
|
| 285 |
dpurdie |
5999 |
foreach ( @elements )
|
| 227 |
dpurdie |
6000 |
{
|
|
|
6001 |
# Standard targets
|
|
|
6002 |
my $rv = __TargetDir($T_TYPE, $base, $_, \$dir);
|
|
|
6003 |
next if ( $rv == 1 );
|
|
|
6004 |
return if ( $rv == 2 );
|
|
|
6005 |
|
|
|
6006 |
if (/^--Package$/ || /^--Package=(.*)/) {
|
|
|
6007 |
$package = 1;
|
|
|
6008 |
|
|
|
6009 |
} elsif (/^--(.*)/) {
|
|
|
6010 |
Message( "InstallProg: unknown option $_ -- ignored\n" );
|
|
|
6011 |
}
|
|
|
6012 |
}
|
|
|
6013 |
|
|
|
6014 |
#.. Files
|
|
|
6015 |
#
|
| 285 |
dpurdie |
6016 |
foreach ( @elements )
|
| 227 |
dpurdie |
6017 |
{
|
|
|
6018 |
my %package_entry;
|
|
|
6019 |
if ( ! /^--(.*)/ )
|
|
|
6020 |
{
|
|
|
6021 |
my $ext = "";
|
|
|
6022 |
$prog = $_;
|
|
|
6023 |
|
|
|
6024 |
#
|
|
|
6025 |
# If the named target is a program then append the correct
|
|
|
6026 |
# extension. Otherwise assume that the target is either a script
|
|
|
6027 |
# or a some other file - and don't append an extension
|
|
|
6028 |
#
|
|
|
6029 |
$ext = $::exe
|
| 289 |
dpurdie |
6030 |
if ( $PROGS->Get($prog) );
|
| 227 |
dpurdie |
6031 |
|
|
|
6032 |
#
|
|
|
6033 |
# A "file" that is specified with a "Src" directive may be
|
|
|
6034 |
# installed as though it were a program
|
|
|
6035 |
#
|
|
|
6036 |
my $progfile;
|
|
|
6037 |
$progfile = "\$(BINDIR)/$prog$ext"
|
|
|
6038 |
unless ( $progfile = $SRCS{$prog} );
|
|
|
6039 |
|
|
|
6040 |
Debug( "InstallProg( $dir/$prog$ext, " .
|
|
|
6041 |
"src: $progfile, dest: $dir)" );
|
|
|
6042 |
|
|
|
6043 |
push @{$PROG_INS{$prog}}, "$dir/$prog$ext";
|
|
|
6044 |
|
|
|
6045 |
$package_entry{'src'} = $progfile;
|
|
|
6046 |
$package_entry{'dir'} = $dir;
|
|
|
6047 |
$INSTALL_PROGS{ "$dir/$prog$ext" } = {%package_entry};
|
|
|
6048 |
}
|
|
|
6049 |
}
|
|
|
6050 |
|
|
|
6051 |
#.. Package
|
|
|
6052 |
#
|
|
|
6053 |
PackageProg( @_ ) # auto package
|
|
|
6054 |
if ( $package );
|
|
|
6055 |
}
|
|
|
6056 |
|
|
|
6057 |
|
|
|
6058 |
###############################################################################
|
|
|
6059 |
#
|
|
|
6060 |
# Packaging
|
|
|
6061 |
#
|
|
|
6062 |
sub PackageDist
|
|
|
6063 |
{
|
|
|
6064 |
my( $name, @elements ) = @_;
|
|
|
6065 |
|
|
|
6066 |
Debug2( "PackageDist($name, @elements)" );
|
|
|
6067 |
|
|
|
6068 |
foreach ( @elements )
|
|
|
6069 |
{
|
|
|
6070 |
#.. Distribution sets
|
|
|
6071 |
#
|
|
|
6072 |
HashJoin( \%PACKAGE_DIST, $;, $name, "$_" );
|
|
|
6073 |
|
|
|
6074 |
#.. Summary of distribution sets
|
|
|
6075 |
#
|
| 267 |
dpurdie |
6076 |
$PACKAGE_SETS{ $_ }{'TAG'} = 1
|
|
|
6077 |
if ( ! exists $PACKAGE_SETS{ $_ }{'TAG'} );
|
| 227 |
dpurdie |
6078 |
}
|
|
|
6079 |
}
|
|
|
6080 |
|
| 311 |
dpurdie |
6081 |
#-------------------------------------------------------------------------------
|
|
|
6082 |
# Function : PackageFile
|
|
|
6083 |
#
|
|
|
6084 |
# Description : Directive to package files
|
|
|
6085 |
# Not to be used to package libraries, executables, headers
|
|
|
6086 |
# as this should be done by specialised directives
|
|
|
6087 |
#
|
|
|
6088 |
# Use to package other files
|
|
|
6089 |
# Can package an entire tree (ugly)
|
|
|
6090 |
#
|
|
|
6091 |
# Inputs :
|
|
|
6092 |
#
|
|
|
6093 |
#
|
| 227 |
dpurdie |
6094 |
sub PackageFile
|
|
|
6095 |
{
|
|
|
6096 |
my( $platforms, @elements ) = @_;
|
| 335 |
dpurdie |
6097 |
my( $base, $dir, $full, $path, $dist, $strip, $exefile, $type );
|
| 227 |
dpurdie |
6098 |
my( $name, $basename, $len, $srcfile );
|
| 341 |
dpurdie |
6099 |
my( $dir_tree, @dir_tree_exclude, @dir_tree_include, $strip_base );
|
| 335 |
dpurdie |
6100 |
my $recurse = 1;
|
| 227 |
dpurdie |
6101 |
|
|
|
6102 |
Debug2( "PackageFile($platforms, @elements)" );
|
|
|
6103 |
|
|
|
6104 |
return if ( !$ScmPackage ); # Packaging enabled ?
|
|
|
6105 |
return if ( ! ActivePlatform($platforms) );
|
|
|
6106 |
|
|
|
6107 |
#.. Arguments
|
|
|
6108 |
#
|
|
|
6109 |
$dist = "ALL"; # Default set (ALL)
|
|
|
6110 |
$base = $PackageInfo{'File'}{'PBase'}; # Base of target
|
|
|
6111 |
$dir = $base . $PackageInfo{'File'}{'Dir'}; # Installation path (default)
|
| 335 |
dpurdie |
6112 |
$full = 0;
|
| 227 |
dpurdie |
6113 |
$strip = 0;
|
| 341 |
dpurdie |
6114 |
$strip_base = 0;
|
| 227 |
dpurdie |
6115 |
$exefile = 0;
|
|
|
6116 |
|
| 285 |
dpurdie |
6117 |
foreach ( @elements )
|
| 227 |
dpurdie |
6118 |
{
|
|
|
6119 |
my $rv = __TargetDir($T_PKG|$T_MACH|$T_GBE|$T_FILE, $base, $_, \$dir, \$type);
|
|
|
6120 |
next if ( $rv == 1 );
|
|
|
6121 |
return if ( $rv == 2 );
|
|
|
6122 |
|
|
|
6123 |
if (/^--Full/) { # Using full (resolved) path
|
|
|
6124 |
$full = 1;
|
|
|
6125 |
|
|
|
6126 |
} elsif (/^--Set=(.*)/) { # Distribution set
|
|
|
6127 |
$dist = "$1";
|
|
|
6128 |
|
|
|
6129 |
} elsif (/^--Package$/) { # Package .. call by InstallFile
|
|
|
6130 |
} elsif (/^--Package=(.*)/) {
|
|
|
6131 |
$dist = "$1";
|
|
|
6132 |
|
|
|
6133 |
} elsif (/^--Strip$/) { # Strip path from source files
|
|
|
6134 |
$strip = 1;
|
|
|
6135 |
|
|
|
6136 |
} elsif (/^--Executable$/) { # Mark the file as executable
|
|
|
6137 |
$exefile = "X";
|
|
|
6138 |
|
|
|
6139 |
} elsif ( /^--DirTree=(.*)/ ) {
|
|
|
6140 |
Error("DirTree. Multiple directories not allowed.") if ( $dir_tree );
|
|
|
6141 |
$dir_tree = $1;
|
|
|
6142 |
|
|
|
6143 |
Error("DirTree cannot extend outside current subtree. '..' not allowed.",
|
|
|
6144 |
"Directory: $dir_tree") if ( $dir_tree =~ m~\.\.~ );
|
|
|
6145 |
Error("DirTree. Absolute paths are not allowed",
|
|
|
6146 |
"Directory: $dir_tree") if ( $dir_tree =~ m~^/~ || $dir_tree =~ m~^.\:~ );
|
|
|
6147 |
Error("DirTree. Directory not found",
|
|
|
6148 |
"Directory: $dir_tree") unless ( -d $dir_tree );
|
|
|
6149 |
|
|
|
6150 |
} elsif ( /^--FilterOut=(.*)/ ) {
|
|
|
6151 |
push @dir_tree_exclude, $1;
|
|
|
6152 |
|
|
|
6153 |
} elsif ( /^--FilterIn=(.*)/ ) {
|
|
|
6154 |
push @dir_tree_include, $1;
|
|
|
6155 |
|
|
|
6156 |
} elsif ( /^--StripDir/ ) {
|
| 341 |
dpurdie |
6157 |
$strip_base = 1;
|
| 227 |
dpurdie |
6158 |
|
| 335 |
dpurdie |
6159 |
} elsif ( m/^--Recurse/ ) {
|
|
|
6160 |
$recurse = 1;
|
|
|
6161 |
|
|
|
6162 |
} elsif ( m/^--NoRecurse/ ) {
|
|
|
6163 |
$recurse = 0;
|
|
|
6164 |
|
| 227 |
dpurdie |
6165 |
} elsif (/^--(.*)/) {
|
|
|
6166 |
Message( "PackageFile: unknown option $_ -- ignored\n" );
|
|
|
6167 |
}
|
|
|
6168 |
}
|
|
|
6169 |
|
|
|
6170 |
|
|
|
6171 |
#.. DirTree expansion
|
|
|
6172 |
# Note: Uses REs, not simple globs
|
|
|
6173 |
# Use JatsLocateFiles to do the hard work
|
|
|
6174 |
if ( $dir_tree )
|
|
|
6175 |
{
|
| 335 |
dpurdie |
6176 |
my $search = JatsLocateFiles->new('FullPath' );
|
|
|
6177 |
$search->recurse($recurse);
|
| 227 |
dpurdie |
6178 |
$search->filter_in_re ( $_ ) foreach ( @dir_tree_include );
|
|
|
6179 |
$search->filter_out_re( $_ ) foreach ( @dir_tree_exclude );
|
| 1429 |
dpurdie |
6180 |
$search->filter_out_re( '/\.svn/' );
|
| 227 |
dpurdie |
6181 |
@elements = $search->search ( $dir_tree );
|
| 341 |
dpurdie |
6182 |
$strip_base = length( $dir_tree ) if ( $strip_base );
|
| 227 |
dpurdie |
6183 |
}
|
|
|
6184 |
|
|
|
6185 |
#.. Files
|
|
|
6186 |
#
|
| 285 |
dpurdie |
6187 |
foreach ( @elements )
|
| 227 |
dpurdie |
6188 |
{
|
|
|
6189 |
my %package_entry;
|
| 299 |
dpurdie |
6190 |
$name = $_;
|
|
|
6191 |
|
| 227 |
dpurdie |
6192 |
#
|
| 299 |
dpurdie |
6193 |
# Trap special files
|
|
|
6194 |
# DPACKAGE - but only if we have a DPackageLibrary directive
|
|
|
6195 |
# in the same makefile.
|
|
|
6196 |
#
|
|
|
6197 |
if ( m~^DPACKAGE$~ && $DPackageDirective ) {
|
|
|
6198 |
$name = 'DPACKAGE.' . $::GBE_MACHTYPE;
|
|
|
6199 |
}
|
|
|
6200 |
|
|
|
6201 |
#
|
| 387 |
dpurdie |
6202 |
# Allow for named files that must be quoted
|
|
|
6203 |
$name = QuoteForMake( $name );
|
| 227 |
dpurdie |
6204 |
|
|
|
6205 |
if ( ! /^--(.*)/ )
|
|
|
6206 |
{
|
|
|
6207 |
$basename = StripDir( $name );
|
| 335 |
dpurdie |
6208 |
if ( !($srcfile = $SRCS{ $basename }) ) {
|
|
|
6209 |
$srcfile = $name;
|
|
|
6210 |
}
|
|
|
6211 |
|
| 227 |
dpurdie |
6212 |
if ( $full )
|
|
|
6213 |
{
|
| 335 |
dpurdie |
6214 |
my $subdir = StripFileExt($srcfile);
|
|
|
6215 |
$subdir = $1
|
|
|
6216 |
if ( $subdir =~ m~^$ProjectBase/(.*)~ );
|
|
|
6217 |
$dir .= '/' . $subdir;
|
|
|
6218 |
$dir =~ s~//~/~g;
|
|
|
6219 |
$dir =~ s~/./~/~g;
|
|
|
6220 |
$dir =~ s~/$~~g;
|
|
|
6221 |
$name = $basename;
|
| 227 |
dpurdie |
6222 |
}
|
|
|
6223 |
|
|
|
6224 |
$name = $basename
|
|
|
6225 |
if ( $strip );
|
|
|
6226 |
|
| 341 |
dpurdie |
6227 |
if ( $strip_base )
|
|
|
6228 |
{
|
|
|
6229 |
$name = substr $name, $strip_base;
|
|
|
6230 |
$name =~ s~^/~~;
|
|
|
6231 |
}
|
|
|
6232 |
|
| 227 |
dpurdie |
6233 |
$dir =~ s~//~/~g;
|
|
|
6234 |
$dir =~ s~/$~~;
|
|
|
6235 |
|
|
|
6236 |
#
|
|
|
6237 |
# Sanity test the source filename
|
|
|
6238 |
# User may have misused an option
|
|
|
6239 |
#
|
|
|
6240 |
if ( ( $srcfile =~ m/=/ ) || ( $srcfile =~ m/^-/ ) || ( $srcfile =~ m~/-~ ) )
|
|
|
6241 |
{
|
|
|
6242 |
Warning ("PackageFile: Suspect source filename: $srcfile");
|
|
|
6243 |
}
|
|
|
6244 |
|
|
|
6245 |
Debug( "PackageFile( $dir/$name, " .
|
|
|
6246 |
"src: $srcfile, dest: $dir, dist: $dist, exe: $exefile )" );
|
|
|
6247 |
|
|
|
6248 |
$package_entry{'src'} = $srcfile;
|
|
|
6249 |
$package_entry{'dir'} = StripFileExt( "$dir/$name" );
|
|
|
6250 |
$package_entry{'set'} = $dist;
|
|
|
6251 |
$package_entry{'exe'} = $exefile if $exefile;
|
|
|
6252 |
$package_entry{'type'} = $type if ( $type );
|
|
|
6253 |
|
|
|
6254 |
$PACKAGE_FILES{ "$dir/$name" } = {%package_entry};
|
|
|
6255 |
}
|
|
|
6256 |
}
|
|
|
6257 |
}
|
|
|
6258 |
|
|
|
6259 |
sub PackageHdr
|
|
|
6260 |
{
|
|
|
6261 |
my( $platforms, @elements ) = @_;
|
| 335 |
dpurdie |
6262 |
my( $base, $dir, $full, $path, $dist, $strip );
|
| 227 |
dpurdie |
6263 |
my( $name, $basename, $len, $srcfile );
|
|
|
6264 |
|
|
|
6265 |
Debug2( "PackageHdr($platforms, @elements)" );
|
|
|
6266 |
|
|
|
6267 |
return if ( !$ScmPackage ); # Packaging enabled ?
|
|
|
6268 |
return if ( ! ActivePlatform($platforms) );
|
|
|
6269 |
|
|
|
6270 |
#.. Arguments
|
|
|
6271 |
#
|
|
|
6272 |
$dist = "ALL"; # Default set (ALL)
|
|
|
6273 |
$base = $PackageInfo{'Hdr'}{'PBase'}; # Base of target
|
|
|
6274 |
$dir = $base . $PackageInfo{'Hdr'}{'Dir'}; # Installation path (default)
|
| 335 |
dpurdie |
6275 |
$full = 0;
|
| 227 |
dpurdie |
6276 |
$strip = 0;
|
|
|
6277 |
|
| 285 |
dpurdie |
6278 |
foreach ( @elements )
|
| 227 |
dpurdie |
6279 |
{
|
|
|
6280 |
my $rv = __TargetDir($T_PKG, $base, $_, \$dir);
|
|
|
6281 |
next if ( $rv == 1 );
|
|
|
6282 |
return if ( $rv == 2 );
|
|
|
6283 |
|
|
|
6284 |
if (/^--Full/) { # Using full (resolved) path
|
|
|
6285 |
$full = 1;
|
|
|
6286 |
|
|
|
6287 |
} elsif (/^--Set=(.*)/) { # Distribution set
|
|
|
6288 |
$dist = "$1";
|
|
|
6289 |
|
|
|
6290 |
} elsif (/^--Package$/) { # Package .. call by InstallHdr
|
|
|
6291 |
} elsif (/^--Package=(.*)/) {
|
|
|
6292 |
$dist = "$1";
|
|
|
6293 |
|
|
|
6294 |
} elsif (/^--Strip$/) { # Strip path from source files
|
|
|
6295 |
$strip = 1;
|
|
|
6296 |
|
|
|
6297 |
} elsif (/^--(.*)/) {
|
|
|
6298 |
Message( "PackageHdr: unknown option $_ -- ignored\n" );
|
|
|
6299 |
}
|
|
|
6300 |
}
|
|
|
6301 |
|
|
|
6302 |
#.. Files
|
|
|
6303 |
#
|
| 285 |
dpurdie |
6304 |
foreach ( @elements )
|
| 227 |
dpurdie |
6305 |
{
|
|
|
6306 |
my %package_entry;
|
|
|
6307 |
if ( ! /^--(.*)/ )
|
|
|
6308 |
{
|
| 387 |
dpurdie |
6309 |
$name = QuoteForMake($_);
|
| 227 |
dpurdie |
6310 |
$basename = StripDir( $name );
|
| 335 |
dpurdie |
6311 |
if ( !($srcfile = $SRCS{ $basename }) ) {
|
|
|
6312 |
$srcfile = $name;
|
|
|
6313 |
}
|
|
|
6314 |
|
| 227 |
dpurdie |
6315 |
if ( $full )
|
|
|
6316 |
{
|
| 335 |
dpurdie |
6317 |
my $subdir = StripFileExt($srcfile);
|
|
|
6318 |
$subdir = $1
|
|
|
6319 |
if ( $subdir =~ m~^$ProjectBase/(.*)~ );
|
|
|
6320 |
$dir .= '/' . $subdir;
|
|
|
6321 |
$dir =~ s~//~/~g;
|
|
|
6322 |
$dir =~ s~/./~/~g;
|
|
|
6323 |
$dir =~ s~/$~~g;
|
|
|
6324 |
$name = $basename;
|
| 227 |
dpurdie |
6325 |
}
|
|
|
6326 |
|
|
|
6327 |
$name = $basename
|
|
|
6328 |
if ( $strip );
|
|
|
6329 |
|
|
|
6330 |
Debug( "PackageHdr( $dir/$name, " .
|
|
|
6331 |
"src: $srcfile, dest: $dir, dist: $dist )" );
|
|
|
6332 |
|
|
|
6333 |
$package_entry{'src'} = $srcfile;
|
|
|
6334 |
$package_entry{'dir'} = StripFileExt( "$dir/$name" );
|
|
|
6335 |
$package_entry{'set'} = $dist;
|
|
|
6336 |
|
|
|
6337 |
$PACKAGE_HDRS{ "$dir/$name" } = {%package_entry};
|
|
|
6338 |
}
|
|
|
6339 |
}
|
|
|
6340 |
}
|
|
|
6341 |
|
|
|
6342 |
|
|
|
6343 |
sub PackageLib
|
|
|
6344 |
{
|
|
|
6345 |
my( $platforms, @elements ) = @_;
|
|
|
6346 |
my( $base, $dir, $dist, $type );
|
|
|
6347 |
my( $lib, $org_lib, %extras, $strip );
|
|
|
6348 |
|
|
|
6349 |
Debug2( "PackageLib($platforms, @elements)" );
|
|
|
6350 |
|
|
|
6351 |
return if ( !$ScmPackage ); # Packaging enabled ?
|
|
|
6352 |
return if ( ! ActivePlatform($platforms) );
|
|
|
6353 |
|
|
|
6354 |
#.. Arguments
|
|
|
6355 |
#
|
|
|
6356 |
$dist = "ALL"; # Default set (ALL)
|
|
|
6357 |
$base = $PackageInfo{'Lib'}{'PBase'}; # Base of target
|
|
|
6358 |
$dir = $base . $PackageInfo{'Lib'}{'Dir'}; # Installation path (default)
|
|
|
6359 |
$type = "";
|
|
|
6360 |
|
| 285 |
dpurdie |
6361 |
foreach ( @elements )
|
| 227 |
dpurdie |
6362 |
{
|
|
|
6363 |
# Standard targets
|
|
|
6364 |
my $rv = __TargetDir($T_PKG, $base, $_, \$dir, \$type);
|
|
|
6365 |
next if ( $rv == 1 );
|
|
|
6366 |
return if ( $rv == 2 );
|
|
|
6367 |
|
|
|
6368 |
if (/^--Set=(.*)/) { # Distribution set(s)
|
|
|
6369 |
$dist = "$1";
|
|
|
6370 |
|
|
|
6371 |
} elsif (/^--Package$/) { # Package .. call by PackageLib
|
|
|
6372 |
} elsif (/^--Package=(.*)/) {
|
|
|
6373 |
$dist = "$1";
|
|
|
6374 |
|
|
|
6375 |
} elsif (/^--Extras=(.*)/) { # Extras=[none, .. ,all]
|
|
|
6376 |
foreach my $elem ( split( ',', $1 ) )
|
|
|
6377 |
{
|
|
|
6378 |
Error ("PackageLib: Unknown Extras mode: $elem")
|
|
|
6379 |
unless ( grep m/$elem/, qw(none stub map lint debug all) );
|
|
|
6380 |
$extras{$elem} = 1;
|
|
|
6381 |
}
|
|
|
6382 |
%extras = () if ( $extras{'all'} );
|
|
|
6383 |
|
|
|
6384 |
} elsif (/^--Strip$/) { # Strip path from source files
|
|
|
6385 |
$strip = 1;
|
|
|
6386 |
|
|
|
6387 |
} elsif (/^--(.*)/) {
|
|
|
6388 |
Message( "PackageLib: unknown option $_ -- ignored\n" );
|
|
|
6389 |
}
|
|
|
6390 |
}
|
|
|
6391 |
|
|
|
6392 |
#.. Files
|
|
|
6393 |
#
|
| 285 |
dpurdie |
6394 |
foreach ( @elements )
|
| 227 |
dpurdie |
6395 |
{
|
|
|
6396 |
my %package_entry;
|
|
|
6397 |
if ( ! /^--(.*)/ )
|
|
|
6398 |
{
|
|
|
6399 |
$_ = StripDir( $_ )
|
|
|
6400 |
if ( $strip );
|
|
|
6401 |
|
|
|
6402 |
$org_lib = $_; # Original name
|
|
|
6403 |
if ( $ScmTargetHost eq "Unix" ) {
|
|
|
6404 |
$lib = "lib$_"; # Prefix "lib" ....
|
|
|
6405 |
$lib =~ s/^liblib/lib/; # @LIBS already has lib added
|
|
|
6406 |
} else {
|
|
|
6407 |
$lib = $_;
|
|
|
6408 |
}
|
|
|
6409 |
|
| 289 |
dpurdie |
6410 |
if ( my $libp = $SHLIBS->Get($lib) )
|
| 227 |
dpurdie |
6411 |
{
|
|
|
6412 |
Debug( "PackageLib( $dir/$lib\$(GBE_TYPE).$::so, " .
|
|
|
6413 |
"src: \$(LIBDIR)/$lib\$(GBE_TYPE).$::so, dest: $dir, dist: $dist, type: $type )" );
|
|
|
6414 |
|
|
|
6415 |
#
|
|
|
6416 |
# Create a "placekeeper" entry within $PACKAGE_SHLIBS
|
|
|
6417 |
# The exact format of the name of the shared library is
|
|
|
6418 |
# toolset specific. Create an entry to allow the toolset
|
|
|
6419 |
# to extend the packaging information when the shared library
|
|
|
6420 |
# recipe is constructed.
|
|
|
6421 |
#
|
|
|
6422 |
#
|
| 289 |
dpurdie |
6423 |
my $ver = $libp->{ VERSION };
|
| 227 |
dpurdie |
6424 |
my $name = "$dir/$lib.$ver.PlaceKeeper";
|
|
|
6425 |
|
|
|
6426 |
$package_entry{'placekeeper'} = 1;
|
|
|
6427 |
$package_entry{'version'} = $ver;
|
|
|
6428 |
$package_entry{'lib'} = $lib;
|
|
|
6429 |
$package_entry{'dir'} = $dir;
|
|
|
6430 |
$package_entry{'set'} = $dist;
|
|
|
6431 |
$package_entry{'type'} = $type if ( $type );
|
|
|
6432 |
$package_entry{'extras'} = {%extras} if ( scalar %extras );
|
| 289 |
dpurdie |
6433 |
|
|
|
6434 |
push @{$SHLIB_PKG{$lib}}, $name;
|
| 227 |
dpurdie |
6435 |
$PACKAGE_SHLIBS{$name} = {%package_entry};
|
|
|
6436 |
}
|
|
|
6437 |
|
| 289 |
dpurdie |
6438 |
#
|
|
|
6439 |
# Clean up the package_entry
|
|
|
6440 |
# Insert common items
|
|
|
6441 |
#
|
|
|
6442 |
%package_entry = ();
|
|
|
6443 |
$package_entry{'lib'} = $lib;
|
|
|
6444 |
$package_entry{'dir'} = $dir;
|
|
|
6445 |
$package_entry{'set'} = $dist;
|
|
|
6446 |
$package_entry{'extras'} = {%extras} if ( scalar %extras );
|
|
|
6447 |
$package_entry{'type'} = $type if ( $type );
|
|
|
6448 |
|
| 227 |
dpurdie |
6449 |
if ( my $libfile = $SRCS{$org_lib} )
|
|
|
6450 |
{
|
|
|
6451 |
#
|
|
|
6452 |
# Allow the user to package a sourced file as a library
|
|
|
6453 |
# But must be the un-massaged name of the file.
|
|
|
6454 |
#
|
| 387 |
dpurdie |
6455 |
$package_entry{'dst'} = QuoteForMake("$dir/$org_lib");
|
|
|
6456 |
$package_entry{'src'} = QuoteForMake($libfile);
|
| 289 |
dpurdie |
6457 |
}
|
|
|
6458 |
elsif ( $LIBS->Get($lib) )
|
|
|
6459 |
{
|
|
|
6460 |
#
|
|
|
6461 |
# Package up a library known to the makefile
|
|
|
6462 |
#
|
|
|
6463 |
my $libp = $LIBS->Get($lib);
|
| 227 |
dpurdie |
6464 |
|
| 289 |
dpurdie |
6465 |
$package_entry{'dst'} = $dir . '/' . $libp->getFullName();
|
|
|
6466 |
$package_entry{'src'} = $libp->getPath();
|
| 227 |
dpurdie |
6467 |
}
|
| 289 |
dpurdie |
6468 |
elsif ( ! $SHLIBS->Get($lib) )
|
| 227 |
dpurdie |
6469 |
{
|
| 289 |
dpurdie |
6470 |
#
|
|
|
6471 |
# Not a known shared lib
|
|
|
6472 |
# Not a known static lib
|
|
|
6473 |
# Not a 'sourced' file
|
|
|
6474 |
# Assume the a static library has magically appeared
|
|
|
6475 |
# in the standard LIB directory. May have been placed there
|
|
|
6476 |
# by a 'rule'
|
|
|
6477 |
#
|
|
|
6478 |
my $libp = $LIBS->New($lib);
|
| 227 |
dpurdie |
6479 |
|
| 289 |
dpurdie |
6480 |
$package_entry{'dst'} = $dir . '/' . $libp->getFullName();
|
|
|
6481 |
$package_entry{'src'} = $libp->getPath();
|
|
|
6482 |
}
|
| 227 |
dpurdie |
6483 |
|
| 289 |
dpurdie |
6484 |
#
|
|
|
6485 |
# Add entry to various lists if required
|
|
|
6486 |
#
|
|
|
6487 |
PackageLib_AddEntry ('PackageLib', \%LIB_PKG, \%PACKAGE_LIBS, \%package_entry )
|
|
|
6488 |
if ( exists $package_entry{'dst'} );
|
| 227 |
dpurdie |
6489 |
}
|
|
|
6490 |
}
|
|
|
6491 |
}
|
|
|
6492 |
|
| 289 |
dpurdie |
6493 |
#-------------------------------------------------------------------------------
|
|
|
6494 |
# Function : PackageLib_AddEntry
|
|
|
6495 |
#
|
|
|
6496 |
# Description : Helper function to add a package entry
|
|
|
6497 |
# to the lists
|
|
|
6498 |
#
|
|
|
6499 |
# Inputs : $directive - Directive name
|
|
|
6500 |
# $pList - Ref to array list to maintain
|
|
|
6501 |
# $pHash - Ref to hash to maintain
|
|
|
6502 |
# $pData - Packaging Data
|
|
|
6503 |
# Must Take a copy.
|
|
|
6504 |
#
|
|
|
6505 |
# Returns :
|
|
|
6506 |
#
|
| 227 |
dpurdie |
6507 |
|
| 289 |
dpurdie |
6508 |
sub PackageLib_AddEntry
|
|
|
6509 |
{
|
|
|
6510 |
my ($directive, $pList, $pHash, $pData) = @_;
|
|
|
6511 |
|
|
|
6512 |
my $lib = delete $pData->{'lib'};
|
|
|
6513 |
my $dst = delete $pData->{'dst'};
|
|
|
6514 |
|
|
|
6515 |
Error ("INTERNAL PackageLib_AddEntry: lib or dst not defined")
|
|
|
6516 |
unless ( $lib && $dst );
|
|
|
6517 |
|
|
|
6518 |
Debug( "$directive( ",$dst,
|
|
|
6519 |
", src: " ,$pData->{'src'},
|
|
|
6520 |
", dest: ",$pData->{'dir'},
|
|
|
6521 |
", dist: ",$pData->{'set'},
|
|
|
6522 |
", type: ",$pData->{'type'} || '',
|
|
|
6523 |
" )" );
|
|
|
6524 |
|
|
|
6525 |
push @{$pList->{$lib }}, $dst;
|
|
|
6526 |
$pHash->{$dst } = {%$pData};
|
|
|
6527 |
}
|
|
|
6528 |
|
|
|
6529 |
|
| 227 |
dpurdie |
6530 |
sub PackageProg
|
|
|
6531 |
{
|
|
|
6532 |
my( $platforms, @elements ) = @_;
|
|
|
6533 |
my( $base, $dir, $dist, $type );
|
|
|
6534 |
my( $prog, %extras, $strip );
|
|
|
6535 |
|
|
|
6536 |
Debug2( "PackageProg($platforms, @elements)" );
|
|
|
6537 |
|
|
|
6538 |
return if ( !$ScmPackage ); # Packaging enabled ?
|
|
|
6539 |
return if ( ! ActivePlatform($platforms) );
|
|
|
6540 |
|
|
|
6541 |
#.. Arguments
|
|
|
6542 |
#
|
|
|
6543 |
$dist = "ALL"; # Default set (ALL)
|
|
|
6544 |
$base = $PackageInfo{'Prog'}{'PBase'}; # Base of target
|
|
|
6545 |
$dir = $base . $PackageInfo{'Prog'}{'Dir'}; # Installation path (default)
|
|
|
6546 |
$type = "";
|
|
|
6547 |
|
| 285 |
dpurdie |
6548 |
foreach ( @elements )
|
| 227 |
dpurdie |
6549 |
{
|
|
|
6550 |
# Standard targets
|
|
|
6551 |
my $rv = __TargetDir($T_PKG|$T_TYPE, $base, $_, \$dir, \$type);
|
|
|
6552 |
next if ( $rv == 1 );
|
|
|
6553 |
return if ( $rv == 2 );
|
|
|
6554 |
|
|
|
6555 |
if (/^--Set=(.*)/) { # Distribution set(s)
|
|
|
6556 |
$dist = "$1";
|
|
|
6557 |
|
|
|
6558 |
} elsif (/^--Package$/) { # Package .. call by PackageLib
|
|
|
6559 |
} elsif (/^--Package=(.*)/) {
|
|
|
6560 |
$dist = "$1";
|
|
|
6561 |
|
|
|
6562 |
} elsif (/^--Tool(([=])(.*))?$/) { # Allow Tool and Tool=xxx specfic target
|
|
|
6563 |
my $path = ( defined( $3) ) ? "/$3" : "";
|
| 261 |
dpurdie |
6564 |
$dir = "\$(PKGDIR)$path/\$(GBE_HOSTMACH)";
|
| 227 |
dpurdie |
6565 |
|
|
|
6566 |
} elsif (/^--Extras=(.*)/) { # Extras=[none, .. ,all]
|
|
|
6567 |
foreach my $elem ( split( ',', $1 ) )
|
|
|
6568 |
{
|
|
|
6569 |
Error ("PackageLib: Unknown Extras mode: $elem")
|
|
|
6570 |
unless ( grep m/$elem/, qw(none stub map lint debug all) );
|
|
|
6571 |
$extras{$elem} = 1;
|
|
|
6572 |
}
|
|
|
6573 |
%extras = () if ( $extras{'all'} );
|
|
|
6574 |
|
|
|
6575 |
} elsif (/^--Strip$/) { # Strip path from source files
|
|
|
6576 |
$strip = 1;
|
|
|
6577 |
|
|
|
6578 |
} elsif (/^--(.*)/) {
|
|
|
6579 |
Message( "PackageProg: unknown option $_ -- ignored\n" );
|
|
|
6580 |
}
|
|
|
6581 |
}
|
|
|
6582 |
|
|
|
6583 |
#.. Files
|
|
|
6584 |
#
|
| 285 |
dpurdie |
6585 |
foreach ( @elements )
|
| 227 |
dpurdie |
6586 |
{
|
|
|
6587 |
my %package_entry;
|
|
|
6588 |
if ( m~descpkg~ ) {
|
|
|
6589 |
PackageFile($platforms, @elements);
|
|
|
6590 |
|
|
|
6591 |
} elsif ( ! /^--(.*)/ ) {
|
|
|
6592 |
$_ = StripDir( $_ )
|
|
|
6593 |
if ( $strip );
|
|
|
6594 |
|
|
|
6595 |
my $ext = "";
|
|
|
6596 |
$prog = $_;
|
|
|
6597 |
|
|
|
6598 |
#
|
|
|
6599 |
# If the named target is a program then append the correct
|
|
|
6600 |
# extension. Otherwise assume that the target is either a script
|
|
|
6601 |
# or a some other file - and don't append an extension
|
|
|
6602 |
#
|
|
|
6603 |
# A program may not have any object files, only libraries
|
|
|
6604 |
#
|
|
|
6605 |
$ext = $::exe
|
| 289 |
dpurdie |
6606 |
if ( $PROGS->Get($prog) );
|
| 227 |
dpurdie |
6607 |
|
|
|
6608 |
#
|
|
|
6609 |
# A "file" that is specified with a "Src" directive may be
|
|
|
6610 |
# installed as though it were a program
|
|
|
6611 |
#
|
|
|
6612 |
my $progfile;
|
| 387 |
dpurdie |
6613 |
if ( $progfile = $SRCS{$prog} )
|
|
|
6614 |
{
|
|
|
6615 |
$progfile = QuoteForMake($progfile);
|
|
|
6616 |
$prog = QuoteForMake($prog);
|
|
|
6617 |
}
|
|
|
6618 |
else
|
|
|
6619 |
{
|
|
|
6620 |
$progfile = "\$(BINDIR)/$prog$ext";
|
|
|
6621 |
}
|
| 227 |
dpurdie |
6622 |
|
|
|
6623 |
Debug( "PackageProg( $dir/$prog$ext, " .
|
|
|
6624 |
"src: $progfile, dest: $dir, dist: $dist, type: $type )" );
|
|
|
6625 |
|
|
|
6626 |
my $target = "$dir/$prog$ext";
|
|
|
6627 |
push @{$PROG_PKG{$prog}}, $target;
|
|
|
6628 |
|
|
|
6629 |
$package_entry{'src'} = $progfile;
|
|
|
6630 |
$package_entry{'dir'} = $dir;
|
|
|
6631 |
$package_entry{'set'} = $dist;
|
|
|
6632 |
$package_entry{'extras'}= {%extras} if ( scalar %extras );
|
|
|
6633 |
$package_entry{'type'} = $type if ( $type );
|
|
|
6634 |
|
|
|
6635 |
$PACKAGE_PROGS{$target} = {%package_entry};
|
|
|
6636 |
}
|
|
|
6637 |
}
|
|
|
6638 |
}
|
|
|
6639 |
|
|
|
6640 |
|
|
|
6641 |
sub PackageJar
|
|
|
6642 |
{
|
|
|
6643 |
my( $platforms, @elements ) = @_;
|
|
|
6644 |
my( $base, $dir, $dist, $type );
|
|
|
6645 |
my( $jar );
|
|
|
6646 |
|
|
|
6647 |
Debug2( "PackageJar($platforms, @elements)" );
|
|
|
6648 |
|
|
|
6649 |
return if ( !$ScmPackage ); # Packaging enabled ?
|
|
|
6650 |
return if ( ! ActivePlatform($platforms) );
|
|
|
6651 |
|
|
|
6652 |
#.. Arguments
|
|
|
6653 |
#
|
|
|
6654 |
$dist = "ALL"; # Default set (ALL)
|
|
|
6655 |
$base = $PackageInfo{'Jar'}{'PBase'}; # Base of target
|
|
|
6656 |
$dir = $base . $PackageInfo{'Jar'}{'Dir'}; # Installation path (default)
|
|
|
6657 |
$type = "";
|
|
|
6658 |
|
| 285 |
dpurdie |
6659 |
foreach ( @elements )
|
| 227 |
dpurdie |
6660 |
{
|
|
|
6661 |
# Standard targets
|
|
|
6662 |
my $rv = __TargetDir($T_PKG, $base, $_, \$dir, \$type);
|
|
|
6663 |
next if ( $rv == 1 );
|
|
|
6664 |
return if ( $rv == 2 );
|
|
|
6665 |
|
|
|
6666 |
if (/^--Set=(.*)/) { # Distribution set(s)
|
|
|
6667 |
$dist = "$1";
|
|
|
6668 |
|
|
|
6669 |
} elsif (/^--Package$/) { # Package .. call by InstallJar
|
|
|
6670 |
} elsif (/^--Package=(.*)/) {
|
|
|
6671 |
$dist = "$1";
|
|
|
6672 |
|
|
|
6673 |
} elsif (/^--(.*)/) {
|
|
|
6674 |
Message( "PackageJar: unknown option $_ -- ignored\n" );
|
|
|
6675 |
}
|
|
|
6676 |
}
|
|
|
6677 |
|
|
|
6678 |
#.. Files
|
|
|
6679 |
#
|
| 285 |
dpurdie |
6680 |
foreach ( @elements )
|
| 227 |
dpurdie |
6681 |
{
|
|
|
6682 |
my %package_entry;
|
|
|
6683 |
if ( ! /^--(.*)/ )
|
|
|
6684 |
{
|
|
|
6685 |
$jar = $_;
|
|
|
6686 |
my $src;
|
|
|
6687 |
my $dest;
|
|
|
6688 |
|
|
|
6689 |
if ( $JAR_FILES{$jar} )
|
|
|
6690 |
{
|
|
|
6691 |
$src = $JAR_FILES{$jar};
|
|
|
6692 |
$dest = $jar;
|
|
|
6693 |
}
|
|
|
6694 |
else
|
|
|
6695 |
{
|
|
|
6696 |
$src = "\$(CLSDIR)/$jar\$(GBE_TYPE).jar";
|
|
|
6697 |
$dest = "$jar\$(GBE_TYPE).jar";
|
|
|
6698 |
}
|
|
|
6699 |
|
|
|
6700 |
|
|
|
6701 |
Debug( "PackageJar( $dir/$dest, " .
|
|
|
6702 |
"src: $src, dest: $dir, dist: $dist, type: $type )" );
|
|
|
6703 |
|
|
|
6704 |
$package_entry{'src'} = $src;;
|
|
|
6705 |
$package_entry{'dir'} = $dir;
|
|
|
6706 |
$package_entry{'set'} = $dist;
|
|
|
6707 |
$package_entry{'type'} = $type if ( $type );
|
|
|
6708 |
|
|
|
6709 |
$PACKAGE_CLSS{ "$dir/$dest" } = {%package_entry};
|
|
|
6710 |
|
|
|
6711 |
}
|
|
|
6712 |
}
|
|
|
6713 |
}
|
|
|
6714 |
|
|
|
6715 |
#-------------------------------------------------------------------------------
|
|
|
6716 |
# Function : PackageProgAddFiles - Add files to a PackageProg
|
|
|
6717 |
# PackageLibAddFiles - Add files to a PackageLib
|
|
|
6718 |
# PackageShlibAddFiles - Add files to a PackageLib (shared lib)
|
|
|
6719 |
# PackageShlibAddLibFiles - Add files to a PackageLib (shared lib)
|
|
|
6720 |
# Add static library files
|
|
|
6721 |
#
|
|
|
6722 |
# Description : Add files to a Program package or installation
|
|
|
6723 |
# For use by Tool sets to allow additional files to be
|
|
|
6724 |
# packaged with a program.
|
|
|
6725 |
#
|
|
|
6726 |
# The files are only added if the named program is being
|
|
|
6727 |
# packaged and/or installed.
|
|
|
6728 |
#
|
|
|
6729 |
#
|
|
|
6730 |
# Inputs : prog - program identifier
|
|
|
6731 |
# file - A file to be add
|
|
|
6732 |
# args - Additional packageing arguments
|
|
|
6733 |
#
|
|
|
6734 |
# Returns : Nothing
|
|
|
6735 |
#
|
|
|
6736 |
|
|
|
6737 |
sub PackageProgAddFiles
|
|
|
6738 |
{
|
|
|
6739 |
Debug("PackageProgAddFiles");
|
|
|
6740 |
|
|
|
6741 |
PackageAddFiles ( \%PACKAGE_PROGS, \%PACKAGE_PROGS, \%PROG_PKG, @_);
|
|
|
6742 |
PackageAddFiles ( \%INSTALL_PROGS, \%INSTALL_PROGS, \%PROG_INS, @_);
|
|
|
6743 |
}
|
|
|
6744 |
|
|
|
6745 |
sub PackageLibAddFiles
|
|
|
6746 |
{
|
|
|
6747 |
Debug("PackageLibAddFiles");
|
|
|
6748 |
|
|
|
6749 |
PackageAddFiles ( \%PACKAGE_LIBS, \%PACKAGE_LIBS, \%LIB_PKG, @_ );
|
|
|
6750 |
PackageAddFiles ( \%INSTALL_LIBS, \%INSTALL_LIBS, \%LIB_INS, @_ );
|
|
|
6751 |
}
|
|
|
6752 |
|
|
|
6753 |
sub PackageShlibAddFiles
|
|
|
6754 |
{
|
|
|
6755 |
my ($prog, $file, @args) = @_;
|
|
|
6756 |
Debug("PackageShlibAddFiles");
|
|
|
6757 |
|
|
|
6758 |
PackageAddFiles ( \%INSTALL_SHLIBS, \%INSTALL_SHLIBS, \%SHLIB_INS, @_ );
|
|
|
6759 |
PackageAddFiles ( \%PACKAGE_SHLIBS, \%PACKAGE_SHLIBS, \%SHLIB_PKG, @_ );
|
|
|
6760 |
|
|
|
6761 |
#
|
|
|
6762 |
# These files become the target of the "make_install_shlib" operation unless:
|
|
|
6763 |
# Conditionally packaged files are not always created
|
|
|
6764 |
# RemoveOnly files are not always generated
|
|
|
6765 |
#
|
|
|
6766 |
my $no_add;
|
|
|
6767 |
foreach ( @args )
|
|
|
6768 |
{
|
|
|
6769 |
if ( m/^defined=/ or m/^RemoveOnly=/ )
|
|
|
6770 |
{
|
|
|
6771 |
$no_add = 1;
|
|
|
6772 |
last;
|
|
|
6773 |
}
|
|
|
6774 |
}
|
|
|
6775 |
|
|
|
6776 |
push (@SHLIB_TARGETS, $file ) unless $no_add;
|
|
|
6777 |
}
|
|
|
6778 |
|
|
|
6779 |
sub PackageShlibAddLibFiles
|
|
|
6780 |
{
|
|
|
6781 |
Debug("PackageShlibAddLibFiles");
|
|
|
6782 |
|
|
|
6783 |
PackageAddFiles ( \%PACKAGE_SHLIBS, \%PACKAGE_LIBS, \%SHLIB_PKG, @_ , 'Class=lib');
|
|
|
6784 |
PackageAddFiles ( \%INSTALL_SHLIBS, \%INSTALL_LIBS, \%SHLIB_INS, @_ , 'Class=lib');
|
|
|
6785 |
}
|
|
|
6786 |
|
|
|
6787 |
#-------------------------------------------------------------------------------
|
|
|
6788 |
# Function : PackageAddFiles
|
|
|
6789 |
#
|
|
|
6790 |
# Description : Internal function to add files to the data structures that
|
|
|
6791 |
# describe a package or installation
|
|
|
6792 |
#
|
|
|
6793 |
# Use this function to package or install additional files with
|
|
|
6794 |
# the Progs and Libs
|
|
|
6795 |
#
|
|
|
6796 |
# ie: Add a LIB file to be packaged with a Shared Library
|
|
|
6797 |
# ie: Add a MAP file to be packaged with a program
|
|
|
6798 |
#
|
|
|
6799 |
# Inputs : ref_spkg - Reference to the hash that contains the package data
|
|
|
6800 |
# ref_dpkg - Reference to the target package/install hash
|
|
|
6801 |
# Normally the same as ref_dpkg, but does allow
|
| 289 |
dpurdie |
6802 |
# a static library to be added to a dynamic library
|
| 227 |
dpurdie |
6803 |
# package.
|
|
|
6804 |
# ref_list - Reference to a hash that may contain package keys to process
|
|
|
6805 |
# prog - Key for index to above
|
|
|
6806 |
# file - A file to be added
|
|
|
6807 |
# args - Additional packaging arguments
|
|
|
6808 |
#
|
|
|
6809 |
# Returns :
|
|
|
6810 |
#
|
|
|
6811 |
sub PackageAddFiles
|
|
|
6812 |
{
|
|
|
6813 |
my ($ref_spkg, $ref_dpkg, $ref_list, $prog, $file, @args ) = @_;
|
|
|
6814 |
|
|
|
6815 |
#
|
|
|
6816 |
# Process entry
|
|
|
6817 |
# The files may need to be added to multiple packages
|
|
|
6818 |
#
|
|
|
6819 |
Debug("PackageAddFiles: $file");
|
|
|
6820 |
|
|
|
6821 |
return unless ( $ref_list->{$prog} );
|
|
|
6822 |
|
|
|
6823 |
#
|
|
|
6824 |
# Parse arguments and extract the "Class=xxx" argument. This may be used
|
|
|
6825 |
# to limit the extra files piggybacked with the base file
|
|
|
6826 |
# All files without a class will be treated as base files
|
|
|
6827 |
#
|
|
|
6828 |
my $class;
|
|
|
6829 |
foreach ( @args )
|
|
|
6830 |
{
|
|
|
6831 |
next unless ( m~^Class=(.*)$~ );
|
|
|
6832 |
$class = $1 unless ( $1 eq 'none' );
|
|
|
6833 |
}
|
|
|
6834 |
Debug("PackageAddFiles: Class: ", $class || 'Default=None');
|
|
|
6835 |
|
|
|
6836 |
foreach my $entry_key ( @{$ref_list->{$prog}} )
|
|
|
6837 |
{
|
|
|
6838 |
Debug("PackageAddFiles: Entry found: $entry_key");
|
|
|
6839 |
|
|
|
6840 |
#
|
|
|
6841 |
# Copy of the template entry
|
|
|
6842 |
#
|
|
|
6843 |
my %package_entry = %{$ref_spkg->{$entry_key}};
|
|
|
6844 |
Error ("INTERNAL: Expected entry in PACKAGE_ hash not found: $entry_key" )
|
|
|
6845 |
unless ( %package_entry );
|
|
|
6846 |
|
|
|
6847 |
#
|
|
|
6848 |
# Do not add the file if the user has limited the extra files added
|
|
|
6849 |
# to the packaging list and the current file is not in the class list
|
|
|
6850 |
#
|
|
|
6851 |
if ( $class && $package_entry{'extras'} )
|
|
|
6852 |
{
|
|
|
6853 |
next unless ( $package_entry{'extras'}{$class} );
|
|
|
6854 |
}
|
|
|
6855 |
|
|
|
6856 |
#
|
|
|
6857 |
# Create new entries for the file
|
|
|
6858 |
#
|
|
|
6859 |
$package_entry{'src'} = $file;
|
|
|
6860 |
foreach ( @args )
|
|
|
6861 |
{
|
|
|
6862 |
m~^(.*)=(.*)$~;
|
|
|
6863 |
$package_entry{$1} = $2;
|
|
|
6864 |
}
|
|
|
6865 |
|
|
|
6866 |
#
|
|
|
6867 |
# Clean out useless fields
|
|
|
6868 |
# Must remove the placekeeper marker to allow the entry to be visible
|
|
|
6869 |
#
|
|
|
6870 |
delete $package_entry{'placekeeper'};
|
|
|
6871 |
delete $package_entry{'version'};
|
|
|
6872 |
delete $package_entry{'lib'};
|
| 261 |
dpurdie |
6873 |
# delete $package_entry{'extras'}; # Keep these
|
| 227 |
dpurdie |
6874 |
delete $package_entry{'Class'};
|
|
|
6875 |
|
|
|
6876 |
#
|
|
|
6877 |
# Add the entry
|
|
|
6878 |
#
|
|
|
6879 |
# Under some conditions is it possible to attempt to add the same named
|
|
|
6880 |
# file. This will result in a circular dependancy in the makefile
|
|
|
6881 |
#
|
|
|
6882 |
# The condition is when merged libaries with PDBs (WINCE+WIN32) are merged
|
| 261 |
dpurdie |
6883 |
# and the source for the merge is the "local directory.
|
| 227 |
dpurdie |
6884 |
#
|
|
|
6885 |
#
|
|
|
6886 |
my $dst = $package_entry{'dir'} ;
|
|
|
6887 |
( my $dfile = $file) =~ s~.*/~~;
|
|
|
6888 |
Debug( " added $dst/$dfile = $file" );
|
|
|
6889 |
|
|
|
6890 |
$ref_dpkg->{"$dst/$dfile"} = {%package_entry}
|
|
|
6891 |
unless ( "$dst/$dfile" eq "$file" );
|
|
|
6892 |
}
|
|
|
6893 |
}
|
|
|
6894 |
|
|
|
6895 |
#-------------------------------------------------------------------------------
|
|
|
6896 |
# Function : PackageProgRemoveFiles
|
|
|
6897 |
#
|
|
|
6898 |
# Description : Flag a Packaged program to be not packaged
|
|
|
6899 |
# This mechanism is used to remove a program from packageing
|
|
|
6900 |
# under conditions where the toolset has generated a different
|
|
|
6901 |
# program.
|
|
|
6902 |
#
|
|
|
6903 |
# The entry is flagged as a placeholder
|
|
|
6904 |
#
|
|
|
6905 |
# Inputs : prog - Program to process
|
|
|
6906 |
#
|
|
|
6907 |
# Returns : Nothing
|
|
|
6908 |
#
|
|
|
6909 |
sub PackageProgRemoveFiles
|
|
|
6910 |
{
|
|
|
6911 |
my ($prog) = @_;
|
|
|
6912 |
Verbose ("PackageProgRemoveFiles: $prog" );
|
|
|
6913 |
return unless (exists($PROG_PKG{$prog}));
|
|
|
6914 |
|
|
|
6915 |
#
|
|
|
6916 |
# Must lookup the TAG to locate the required entry
|
|
|
6917 |
#
|
|
|
6918 |
my $tag = $PROG_PKG{$prog};
|
|
|
6919 |
foreach my $entry ( @$tag )
|
|
|
6920 |
{
|
|
|
6921 |
Verbose("Do not package: $entry");
|
|
|
6922 |
if ( exists $PACKAGE_PROGS{$entry} )
|
|
|
6923 |
{
|
|
|
6924 |
$PACKAGE_PROGS{$entry}{placekeeper} = 'ProgRemoved';
|
|
|
6925 |
}
|
|
|
6926 |
}
|
|
|
6927 |
}
|
|
|
6928 |
|
|
|
6929 |
#-------------------------------------------------------------------------------
|
|
|
6930 |
# Function : DPackageLibrary
|
|
|
6931 |
#
|
|
|
6932 |
# Description : Collect information to allow the generation of a DPACKAGE
|
| 299 |
dpurdie |
6933 |
# file. This directive allows the generation of "Library"
|
| 227 |
dpurdie |
6934 |
# directives within the final DPACKAGE
|
|
|
6935 |
#
|
|
|
6936 |
# This directive does generate the DPACKAGE file.
|
|
|
6937 |
#
|
|
|
6938 |
# Inputs : platform - This does not need to be an active platform
|
|
|
6939 |
# it is simply passed to the DPACKAGE builder
|
|
|
6940 |
#
|
|
|
6941 |
# using - The "using" target
|
|
|
6942 |
#
|
|
|
6943 |
# ... - Arguments for the Library directive
|
|
|
6944 |
#
|
|
|
6945 |
# Returns :
|
|
|
6946 |
#
|
|
|
6947 |
sub DPackageLibrary
|
|
|
6948 |
{
|
|
|
6949 |
JatsDPackage::DPackageAdd ( @_ );
|
| 299 |
dpurdie |
6950 |
$DPackageDirective = 1;
|
| 227 |
dpurdie |
6951 |
}
|
|
|
6952 |
|
|
|
6953 |
#-------------------------------------------------------------------------------
|
|
|
6954 |
# Function : SetProjectBase
|
|
|
6955 |
#
|
|
|
6956 |
# Description : Allows the user to modify the build's concept of the Base
|
|
|
6957 |
# of the build. By default the base is the same directory as
|
|
|
6958 |
# the build.pl file, but in some contorted environments it
|
|
|
6959 |
# is a great deal simpler to specify a differnt base.
|
|
|
6960 |
#
|
|
|
6961 |
# The use may use the variable $ProjectBase as a path
|
|
|
6962 |
# specifier to locate files and directories
|
|
|
6963 |
#
|
|
|
6964 |
# Both absolute and relative paths are supported
|
|
|
6965 |
# If the initial value of $ProjectBase is relative then
|
|
|
6966 |
# it will be maintained as a relative path.
|
|
|
6967 |
#
|
|
|
6968 |
# Inputs : elements path to base
|
|
|
6969 |
# These may be:
|
|
|
6970 |
# --Up=xx
|
|
|
6971 |
# name
|
|
|
6972 |
#
|
|
|
6973 |
# Returns : Nothing
|
|
|
6974 |
#
|
|
|
6975 |
|
|
|
6976 |
#
|
|
|
6977 |
# Allow the user to modify the project base variable
|
|
|
6978 |
#
|
|
|
6979 |
sub SetProjectBase
|
|
|
6980 |
{
|
|
|
6981 |
my $rip = 0;
|
|
|
6982 |
my $path = "";
|
|
|
6983 |
my $is_relative;
|
|
|
6984 |
|
|
|
6985 |
Debug("ProjectBase Initial: $ProjectBase, @_");
|
|
|
6986 |
|
|
|
6987 |
#
|
|
|
6988 |
# Ensure that the ProjectBase is in a "nice" form
|
|
|
6989 |
# 1) No /./ bits
|
|
|
6990 |
# 2) No trailing /
|
|
|
6991 |
# 3) Not equal to .
|
|
|
6992 |
# 4) No training /.
|
|
|
6993 |
# 5) No //
|
|
|
6994 |
#
|
|
|
6995 |
$ProjectBase =~ s~/\./~/~g;
|
|
|
6996 |
$ProjectBase =~ s~/$~~g;
|
|
|
6997 |
$ProjectBase =~ s~^\.$~~g;
|
|
|
6998 |
$ProjectBase =~ s~/\.$~~g;
|
|
|
6999 |
$ProjectBase =~ s~//$~/~g;
|
|
|
7000 |
|
|
|
7001 |
#
|
|
|
7002 |
# ProjectBase may be absolute or relative
|
|
|
7003 |
# Determine this before we mess with it
|
|
|
7004 |
#
|
|
|
7005 |
$is_relative = ($ProjectBase !~ m~^/~);
|
|
|
7006 |
|
|
|
7007 |
#
|
|
|
7008 |
# Process each argument
|
|
|
7009 |
#
|
|
|
7010 |
foreach ( @_ )
|
|
|
7011 |
{
|
|
|
7012 |
if ( /^--Up=([0-9]*)/ ) {
|
|
|
7013 |
$rip = $1;
|
|
|
7014 |
} elsif ( /^--/ ) {
|
|
|
7015 |
Warning( "SetProjectBase - unknown option \"$_\" - ignored" );
|
|
|
7016 |
} else {
|
|
|
7017 |
$path = $_;
|
|
|
7018 |
}
|
|
|
7019 |
}
|
|
|
7020 |
|
|
|
7021 |
#
|
|
|
7022 |
# Process the UP requests
|
|
|
7023 |
# If the tail directory is a ".." then up is done by adding another ".."
|
|
|
7024 |
# If the tail directory is not a "..", then up is done by removing it
|
|
|
7025 |
#
|
|
|
7026 |
# If we go past the start of the path then simply add ".."
|
|
|
7027 |
#
|
|
|
7028 |
while ( $rip-- > 0 )
|
|
|
7029 |
{
|
|
|
7030 |
Debug2("ProjectBase: $ProjectBase, Up: $rip, IsRel: $is_relative");
|
|
|
7031 |
|
|
|
7032 |
#
|
|
|
7033 |
# If ending in a /.. or is exactly equal to ..
|
|
|
7034 |
# Then its a dot-dot and the way to go UP is to append another ..
|
|
|
7035 |
#
|
|
|
7036 |
if ( $ProjectBase =~ m~(/\.\.$)|(^\.\.$)~ )
|
|
|
7037 |
{
|
|
|
7038 |
$ProjectBase .= '/..';
|
|
|
7039 |
}
|
|
|
7040 |
else
|
|
|
7041 |
{
|
|
|
7042 |
#
|
|
|
7043 |
# Not a dot-dot ending
|
|
|
7044 |
# Attempt to remove the last directory of the form
|
|
|
7045 |
# /xxxxx
|
|
|
7046 |
# Where the leading / is optional
|
|
|
7047 |
# Note: Must have at least one character in the dirname
|
|
|
7048 |
# This prevents leading / from matching - which is needed
|
|
|
7049 |
#
|
|
|
7050 |
unless ($ProjectBase =~ s~/?[^/]+$~~)
|
|
|
7051 |
{
|
|
|
7052 |
#
|
|
|
7053 |
# Removal failed
|
|
|
7054 |
# If a relative path then we can keep on going up,
|
|
|
7055 |
# otherwise we are dead.
|
|
|
7056 |
#
|
|
|
7057 |
Error ("ProjectBase outside project") unless ($is_relative);
|
|
|
7058 |
$ProjectBase = '..';
|
|
|
7059 |
}
|
|
|
7060 |
|
|
|
7061 |
#
|
|
|
7062 |
# Ensure that the leading / in an absolute path is not deleted
|
|
|
7063 |
#
|
|
|
7064 |
$ProjectBase = '/'
|
|
|
7065 |
unless ( $is_relative || $ProjectBase );
|
|
|
7066 |
}
|
|
|
7067 |
}
|
|
|
7068 |
|
|
|
7069 |
#
|
|
|
7070 |
# Append the user path
|
|
|
7071 |
#
|
|
|
7072 |
$ProjectBase .= '/' . $path if ( $path );
|
|
|
7073 |
$ProjectBase = '.' unless ( $ProjectBase );
|
|
|
7074 |
Debug("ProjectBase set to : $ProjectBase");
|
|
|
7075 |
|
|
|
7076 |
#
|
|
|
7077 |
# Once upon a time I tried to convert paths that contained spaces into
|
|
|
7078 |
# short (mangled) names. This was not sucessful because:
|
|
|
7079 |
# 1) Clearcase dynamic views do not support name mangling
|
|
|
7080 |
# 2) Samba file system does not appear to support name mangling
|
|
|
7081 |
#
|
|
|
7082 |
# Spaces in paths are not good for MAKE
|
|
|
7083 |
# Now I simple generate a message
|
|
|
7084 |
#
|
|
|
7085 |
Warning( "ProjectBase contains a space: $ProjectBase")
|
|
|
7086 |
if ( $ProjectBase =~ m/ / );
|
|
|
7087 |
|
|
|
7088 |
#
|
|
|
7089 |
# Sanity check
|
|
|
7090 |
# Absolute paths can be checked easily
|
|
|
7091 |
# Checking of relative paths does not appear to work
|
|
|
7092 |
# When I tested it chdir, opendir and stat would limit themselves
|
|
|
7093 |
# and drop into the root directory ( under windows )
|
|
|
7094 |
#
|
|
|
7095 |
# Solution: Check the path does not extend beyond the file tree
|
|
|
7096 |
#
|
|
|
7097 |
my $distance = 1;
|
|
|
7098 |
my $tpath = $ProjectBase;
|
|
|
7099 |
|
|
|
7100 |
if ( $is_relative && $tpath ne '.' )
|
|
|
7101 |
{
|
|
|
7102 |
#
|
|
|
7103 |
# Build up the complete pathname by merging it with the
|
|
|
7104 |
# current directory. Then clean it up.
|
|
|
7105 |
#
|
|
|
7106 |
$tpath = $::Cwd . '/' . $ProjectBase;
|
|
|
7107 |
|
|
|
7108 |
#
|
|
|
7109 |
# Scan the list of diretories and count the distance from the root
|
|
|
7110 |
# This should not be greater than zero for sanity
|
|
|
7111 |
# Note: Get an empty elemement from the split due to
|
|
|
7112 |
# the leading / of the ABS path
|
|
|
7113 |
#
|
|
|
7114 |
$distance = 0;
|
|
|
7115 |
foreach ( split ('/', $tpath) )
|
|
|
7116 |
{
|
|
|
7117 |
if ( m~\.\.~ )
|
|
|
7118 |
{
|
|
|
7119 |
$distance--;
|
|
|
7120 |
}
|
|
|
7121 |
else
|
|
|
7122 |
{
|
|
|
7123 |
$distance++;
|
|
|
7124 |
}
|
|
|
7125 |
}
|
|
|
7126 |
}
|
|
|
7127 |
|
|
|
7128 |
#
|
|
|
7129 |
# Warn if not a valid directory
|
|
|
7130 |
#
|
|
|
7131 |
Warning( "ProjectBase is not a directory: $ProjectBase")
|
|
|
7132 |
if ( $distance <= 0 || ! -d $tpath );
|
|
|
7133 |
|
|
|
7134 |
#
|
|
|
7135 |
# $ProjectBase will always be a valid directory, but if its the top
|
|
|
7136 |
# directory (/) and it is added to a path we will get //path
|
|
|
7137 |
# This is not good, so // will be removed later in the AddIncDir and
|
|
|
7138 |
# AddSrcDir commands where $ProjectBase is really used.
|
|
|
7139 |
#
|
|
|
7140 |
# Alternatively we could set $ProjectBase to an empty string, but then
|
|
|
7141 |
# this may be confused with an empty relative directory
|
|
|
7142 |
#
|
|
|
7143 |
Debug("ProjectBase Final : $ProjectBase");
|
|
|
7144 |
}
|
|
|
7145 |
|
|
|
7146 |
#-------------------------------------------------------------------------------
|
|
|
7147 |
# Function : DeployPackage
|
|
|
7148 |
#
|
|
|
7149 |
# Description : Generate a deployed package
|
|
|
7150 |
# This is a gateway to a different packaging system
|
|
|
7151 |
#
|
|
|
7152 |
# DeployPackage and PackageXxxxx directives are mutually
|
|
|
7153 |
# exclusive. Only one person can play in the package area.
|
|
|
7154 |
#
|
|
|
7155 |
# Inputs : Platform Specifier
|
|
|
7156 |
# Package Name (Optional)
|
|
|
7157 |
# Options
|
|
|
7158 |
# --Name : Base name of the package. The default is taken
|
|
|
7159 |
# from the build.pl file
|
|
|
7160 |
# --Dir : Package directory
|
|
|
7161 |
# The default is based on the package name
|
|
|
7162 |
#
|
|
|
7163 |
# Returns :
|
|
|
7164 |
#
|
|
|
7165 |
sub DeployPackage
|
|
|
7166 |
{
|
|
|
7167 |
my( $platforms, @elements ) = @_;
|
|
|
7168 |
my $dir;
|
|
|
7169 |
my $name;
|
|
|
7170 |
|
| 267 |
dpurdie |
7171 |
#
|
|
|
7172 |
# Flag that this build creates a deployable package, even if its not
|
|
|
7173 |
# active on this platform.
|
|
|
7174 |
#
|
|
|
7175 |
$DEPLOYPACKAGE = 1;
|
|
|
7176 |
|
|
|
7177 |
|
| 227 |
dpurdie |
7178 |
Debug2( "DeployPackage($platforms, @elements)" );
|
|
|
7179 |
return if ( ! ActivePlatform($platforms) );
|
|
|
7180 |
|
|
|
7181 |
#
|
|
|
7182 |
# Only allow one use of this directive
|
|
|
7183 |
#
|
|
|
7184 |
Error("DeployPackage can only be used once" ) if ( %DEPLOYPACKAGE );
|
| 267 |
dpurdie |
7185 |
$DEPLOYPACKAGE = 2;
|
| 227 |
dpurdie |
7186 |
|
|
|
7187 |
#
|
|
|
7188 |
# Ensure that the deployment file is available
|
|
|
7189 |
#
|
|
|
7190 |
my $command_file = $ScmDeploymentPatch ? "deploypatch.pl" : "deployfile.pl";
|
|
|
7191 |
Error("DeployPackage: $command_file not found") unless (-f "./$command_file");
|
|
|
7192 |
#
|
|
|
7193 |
# Collect arguments
|
|
|
7194 |
#
|
|
|
7195 |
foreach (@elements )
|
|
|
7196 |
{
|
|
|
7197 |
if ( m/^--Dir=(.*)/ ) {
|
|
|
7198 |
Error ("DeployPackage: Package directory defined multiple times") if $dir;
|
|
|
7199 |
$dir = $1;
|
|
|
7200 |
|
|
|
7201 |
} elsif ( m/^--Name=(.*)/ ) {
|
|
|
7202 |
Error ("DeployPackage: Package name defined multiple times") if $name;
|
|
|
7203 |
$name = $1;
|
|
|
7204 |
|
|
|
7205 |
} elsif ( m/^--/ ) {
|
|
|
7206 |
Warning( "DeployPackage: Unknown option ignored: $_");
|
|
|
7207 |
|
|
|
7208 |
} else {
|
|
|
7209 |
Error ("DeployPackage: Package name defined multiple times") if $name;
|
|
|
7210 |
$name = $_;
|
|
|
7211 |
|
|
|
7212 |
}
|
|
|
7213 |
}
|
|
|
7214 |
|
|
|
7215 |
$name = $::ScmBuildPackage unless ( $name );
|
|
|
7216 |
|
|
|
7217 |
#
|
|
|
7218 |
# Save the deployment data
|
|
|
7219 |
#
|
|
|
7220 |
$dir = lc($name) unless ( $dir );
|
|
|
7221 |
$DEPLOYPACKAGE{'name'} = $name;
|
|
|
7222 |
$DEPLOYPACKAGE{'dir'} = $dir;
|
|
|
7223 |
$DEPLOYPACKAGE{'cmdfile'} = $command_file;
|
|
|
7224 |
|
|
|
7225 |
#
|
|
|
7226 |
# Flag that toolset tests should be supressed
|
|
|
7227 |
# The Deploy world does not really use the full makefiles and if the
|
|
|
7228 |
# compilers are not installed will not be able to create deployment
|
|
|
7229 |
# packages
|
|
|
7230 |
#
|
|
|
7231 |
$ScmNoToolsTest = 1;
|
|
|
7232 |
}
|
|
|
7233 |
|
|
|
7234 |
|
|
|
7235 |
###############################################################################
|
|
|
7236 |
###############################################################################
|
|
|
7237 |
# Private function section.
|
|
|
7238 |
# The following functions are used INTERNALLY by makelib.pl2.
|
|
|
7239 |
###############################################################################
|
|
|
7240 |
|
|
|
7241 |
###############################################################################
|
|
|
7242 |
# A collection of functions to write to the MAKEFILE handle
|
|
|
7243 |
#
|
|
|
7244 |
# MakeHeader - Write a nice section header
|
|
|
7245 |
# MakeNewLine - Print a new line
|
|
|
7246 |
# MakePrint - Print a line ( without trailing \n)
|
|
|
7247 |
# MakeQuote - Escape \ and " character, then print a line
|
|
|
7248 |
# MakePrintList - Print an array
|
|
|
7249 |
# MakeEntry - Complex line printer
|
|
|
7250 |
# MakePadded - Padded line printer (internal)
|
|
|
7251 |
# PadToPosn - Calc space+tabs to tabstop (internal)
|
|
|
7252 |
# MakeEntry3 - Complex Line Printer
|
|
|
7253 |
# MakeDefEntry - Print a definition line (Production + Debug support)
|
|
|
7254 |
# MakeIfDefEntry - Print ifdef entry
|
| 261 |
dpurdie |
7255 |
# MakeIfnDefEntry - Print ifndef entry
|
|
|
7256 |
# MakeIfZeroEntry - Print ifeq entry
|
| 227 |
dpurdie |
7257 |
#
|
|
|
7258 |
###############################################################################
|
|
|
7259 |
|
|
|
7260 |
sub MakeHeader
|
|
|
7261 |
{
|
|
|
7262 |
my ($text, @rest) = @_;
|
|
|
7263 |
my $length = length ($text);
|
|
|
7264 |
|
|
|
7265 |
print MAKEFILE "\n";
|
|
|
7266 |
print MAKEFILE "#--------- $text ", '-' x (80 - 12 - $length) ,"\n";
|
|
|
7267 |
print MAKEFILE "# $_\n" foreach ( @rest ) ;
|
|
|
7268 |
print MAKEFILE "#\n";
|
|
|
7269 |
}
|
|
|
7270 |
|
|
|
7271 |
sub MakeNewLine # Print a newline to the current 'Makefile'
|
|
|
7272 |
{
|
|
|
7273 |
print MAKEFILE "\n";
|
|
|
7274 |
}
|
|
|
7275 |
|
|
|
7276 |
sub MakePrint # Print to the current 'Makefile'
|
|
|
7277 |
{
|
|
|
7278 |
print MAKEFILE @_
|
|
|
7279 |
if ( defined $_[0] );
|
|
|
7280 |
}
|
|
|
7281 |
|
|
|
7282 |
sub MakeQuote # Quote a makefile text line
|
|
|
7283 |
{
|
|
|
7284 |
my( $line ) = @_;
|
|
|
7285 |
$line =~ s/\\/\\\\/g; # quote all '\' characters
|
|
|
7286 |
$line =~ s/"/\\"/g; # Then quote '"' characters
|
| 255 |
dpurdie |
7287 |
$line =~ s/=#/=\\#/g; # Then quote '=#' sequence
|
| 227 |
dpurdie |
7288 |
print MAKEFILE $line;
|
|
|
7289 |
}
|
|
|
7290 |
|
|
|
7291 |
sub MakePrintList
|
|
|
7292 |
{
|
|
|
7293 |
print MAKEFILE $_ . "\n" foreach (@{$_[0]});
|
|
|
7294 |
}
|
|
|
7295 |
|
|
|
7296 |
|
|
|
7297 |
#-------------------------------------------------------------------------------
|
|
|
7298 |
# Function : MakeEntry
|
|
|
7299 |
#
|
|
|
7300 |
# Description : Build a entry based on the element list
|
|
|
7301 |
# Creates text of the form
|
|
|
7302 |
# $(BINDIR)/prog.exe: object1.obj \
|
|
|
7303 |
# object2.obj
|
|
|
7304 |
#
|
|
|
7305 |
#
|
|
|
7306 |
# Inputs : $prelim - Preamble (one-off)
|
|
|
7307 |
# $postlim - Postamble (one-off)
|
|
|
7308 |
# $prefix - Pefix (to each element of array)
|
|
|
7309 |
# $postfix - Postfix (to each element of array )
|
|
|
7310 |
# @elements - Array of element to wrap
|
|
|
7311 |
#
|
|
|
7312 |
# Returns : 1 Always
|
|
|
7313 |
#
|
|
|
7314 |
# Notes:
|
|
|
7315 |
# The above description means that the following entry format is
|
|
|
7316 |
# produced:
|
|
|
7317 |
#
|
|
|
7318 |
# <preliminary><prefix><variant1><prefix><variant2>...<final>
|
|
|
7319 |
#
|
|
|
7320 |
# With judicious use of newline and tab characters, a target
|
|
|
7321 |
# and dependency list along with the command(s) to build the
|
|
|
7322 |
# target can be constructed.
|
|
|
7323 |
#
|
|
|
7324 |
sub MakeEntry
|
|
|
7325 |
{
|
|
|
7326 |
my( $prelim, $postlim, $prefix, $postfix, @elements ) = @_;
|
|
|
7327 |
|
|
|
7328 |
MakePrint $prelim;
|
|
|
7329 |
MakePrint "${prefix}${_}${postfix}" foreach ( @elements );
|
|
|
7330 |
MakePrint $postlim if ($postlim);
|
|
|
7331 |
return 1;
|
|
|
7332 |
}
|
|
|
7333 |
|
|
|
7334 |
#-------------------------------------------------------------------------------
|
|
|
7335 |
# Function : MakePadded
|
|
|
7336 |
#
|
|
|
7337 |
# Description : Generate aligned output of the form
|
|
|
7338 |
# Prefix_text Aligned_text
|
|
|
7339 |
# where the aligned text is at a specified TAB boundary
|
|
|
7340 |
#
|
|
|
7341 |
# Inputs : $align - Tab stop (One tab = 8 chars)
|
|
|
7342 |
# $prefix - Text to print before alignment occurs
|
|
|
7343 |
# @line - Remainder of the line
|
|
|
7344 |
#
|
|
|
7345 |
sub MakePadded # Print to the current 'Makefile', tab aligning
|
|
|
7346 |
{
|
|
|
7347 |
my( $align, $prefix, @line ) = @_;
|
|
|
7348 |
|
|
|
7349 |
my $strlen = length( $prefix );
|
|
|
7350 |
my $pad = PadToPosn( $strlen, $align * 8 );
|
|
|
7351 |
|
|
|
7352 |
print MAKEFILE $prefix . $pad;
|
|
|
7353 |
print MAKEFILE @line;
|
|
|
7354 |
}
|
|
|
7355 |
|
|
|
7356 |
#-------------------------------------------------------------------------------
|
|
|
7357 |
# Function : PadToPosn
|
|
|
7358 |
#
|
|
|
7359 |
# Description : Given that we are at $startposn return a tab and space
|
|
|
7360 |
# string to place us at $endposn
|
|
|
7361 |
#
|
|
|
7362 |
sub PadToPosn
|
|
|
7363 |
{
|
|
|
7364 |
my ($startposn, $endposn ) = @_;
|
|
|
7365 |
|
|
|
7366 |
|
|
|
7367 |
#
|
|
|
7368 |
# Case where we are already too far into the line
|
|
|
7369 |
#
|
|
|
7370 |
return ( ' ' )if ( $endposn <= $startposn );
|
|
|
7371 |
|
|
|
7372 |
my $tcount = 0;
|
|
|
7373 |
my $scount = 0;
|
|
|
7374 |
|
|
|
7375 |
while ( $startposn < $endposn )
|
|
|
7376 |
{
|
|
|
7377 |
$tcount ++;
|
|
|
7378 |
$startposn = ($startposn >> 3) * 8 + 8;
|
|
|
7379 |
|
|
|
7380 |
my $delta = $endposn - $startposn;
|
|
|
7381 |
if ( $delta < 8 )
|
|
|
7382 |
{
|
|
|
7383 |
$scount = $delta;
|
|
|
7384 |
last;
|
|
|
7385 |
}
|
|
|
7386 |
|
|
|
7387 |
}
|
|
|
7388 |
return ( "\t" x $tcount . ' ' x $scount );
|
|
|
7389 |
}
|
|
|
7390 |
|
|
|
7391 |
#-------------------------------------------------------------------------------
|
|
|
7392 |
# Function : MakeEntry3
|
|
|
7393 |
#
|
|
|
7394 |
# Description : Build a makefile entry based on the element list, tab aligned
|
|
|
7395 |
# Can creat text of the form:
|
|
|
7396 |
# TAG = NAME0 \ TAG : NAME0 \
|
|
|
7397 |
# NAME1 NAME1
|
|
|
7398 |
#
|
|
|
7399 |
#
|
|
|
7400 |
# Inputs : $prelim - Preliminary text
|
|
|
7401 |
# $presep - Preliminary seperator
|
|
|
7402 |
# $elem_ref - Either a single name or a reference to
|
|
|
7403 |
# and array of names, or a hash.
|
|
|
7404 |
#
|
|
|
7405 |
# Returns : Writes directly to the Makefile
|
|
|
7406 |
#
|
|
|
7407 |
sub MakeEntry3
|
|
|
7408 |
{
|
|
|
7409 |
my( $prelim, $presep, $elem_ref ) = @_;
|
|
|
7410 |
|
|
|
7411 |
#
|
|
|
7412 |
# The prelim may have some "\n" characters at the start
|
|
|
7413 |
# These simplify formatting, but mess up the nice formatting
|
|
|
7414 |
#
|
|
|
7415 |
if ($prelim =~ m~(^\n+)(.*)~ )
|
|
|
7416 |
{
|
|
|
7417 |
MakePrint $1;
|
|
|
7418 |
$prelim = $2;
|
|
|
7419 |
}
|
|
|
7420 |
|
|
|
7421 |
#
|
|
|
7422 |
# Print the definition and the sep with nice padding
|
|
|
7423 |
#
|
|
|
7424 |
MakePadded ( 3, $prelim, $presep );
|
|
|
7425 |
my $leadin = ' ';
|
|
|
7426 |
|
|
|
7427 |
#
|
|
|
7428 |
# If a HASH reference then use a sorted list of keys from the hash.
|
|
|
7429 |
#
|
|
|
7430 |
if ( ref ($elem_ref) eq "HASH" )
|
|
|
7431 |
{
|
|
|
7432 |
my @hash_list;
|
|
|
7433 |
@hash_list = sort keys ( %{$elem_ref} );
|
|
|
7434 |
$elem_ref = \@hash_list;
|
|
|
7435 |
}
|
|
|
7436 |
|
|
|
7437 |
#
|
|
|
7438 |
# If the list is only one element long, then create a simple form
|
|
|
7439 |
# If the list is not an array ref, then treat it as a single element
|
|
|
7440 |
#
|
|
|
7441 |
if ( ref ($elem_ref) eq "ARRAY" )
|
|
|
7442 |
{
|
|
|
7443 |
my $line = 0;
|
|
|
7444 |
foreach my $element ( @$elem_ref )
|
|
|
7445 |
{
|
|
|
7446 |
print MAKEFILE $leadin . $element;
|
|
|
7447 |
$leadin = " \\\n" . PadToPosn(0,24 + length( $presep ) + 1 ) unless ($line++);
|
|
|
7448 |
}
|
|
|
7449 |
}
|
|
|
7450 |
elsif ( defined $elem_ref )
|
|
|
7451 |
{
|
|
|
7452 |
print MAKEFILE $leadin . $elem_ref;
|
|
|
7453 |
}
|
|
|
7454 |
MakeNewLine();
|
|
|
7455 |
return 1;
|
|
|
7456 |
}
|
|
|
7457 |
|
|
|
7458 |
#-------------------------------------------------------------------------------
|
|
|
7459 |
# Function : MakeDefEntry
|
|
|
7460 |
#
|
|
|
7461 |
# Description : Make a definition entry of the form
|
|
|
7462 |
#
|
|
|
7463 |
# TAG = NAME0 \
|
|
|
7464 |
# NAME1
|
|
|
7465 |
#
|
|
|
7466 |
# Support a list of definitions that will always be created
|
|
|
7467 |
# as well as a production and a debug list.
|
|
|
7468 |
#
|
|
|
7469 |
# Will always generate the "TAG = " string, even if the list
|
|
|
7470 |
# is empty.
|
|
|
7471 |
#
|
|
|
7472 |
# Will supress the TAG if there is no data if the FIRST opr starts with a '+'
|
|
|
7473 |
#
|
|
|
7474 |
# Inputs : TAG - Text tag to create
|
|
|
7475 |
# FIRST - First assignement opr. = or +=
|
|
|
7476 |
# ALL_LIST - A reference to a list of names to assign
|
|
|
7477 |
# or a single name.
|
|
|
7478 |
# PROD_LIST - Optional list to extend the definition with for a production build
|
|
|
7479 |
# DEBUG_LIST - Optional list to extend the definition with for a debug build
|
|
|
7480 |
#
|
|
|
7481 |
# Returns : Nothing
|
|
|
7482 |
#
|
|
|
7483 |
|
|
|
7484 |
sub MakeDefEntry
|
|
|
7485 |
{
|
|
|
7486 |
my( $tag, $assign, $all, $prod, $debug ) = @_;
|
|
|
7487 |
|
|
|
7488 |
#
|
|
|
7489 |
# Do not generate anything if the $opr is "+=" and there is no data
|
|
|
7490 |
# to output. ie: Supress empty TAG += statements
|
|
|
7491 |
#
|
|
|
7492 |
return if ( $assign =~ m/\+/ && ( ref($all) && ! defined $all->[0] ) );
|
|
|
7493 |
|
|
|
7494 |
#
|
|
|
7495 |
# TAG for all entries
|
|
|
7496 |
#
|
|
|
7497 |
MakeEntry3( $tag, $assign, $all );
|
|
|
7498 |
|
|
|
7499 |
|
|
|
7500 |
#
|
|
|
7501 |
# TAGs for PROD build
|
|
|
7502 |
# TAGs for DEBUG build
|
|
|
7503 |
#
|
|
|
7504 |
if ( defined $prod && defined $prod->[0] )
|
|
|
7505 |
{
|
|
|
7506 |
print MAKEFILE 'ifeq "$(DEBUG)" "0"' . "\n";
|
|
|
7507 |
MakeEntry3( $tag, "+=", $prod );
|
| 267 |
dpurdie |
7508 |
print MAKEFILE 'endif' . "\n";
|
| 227 |
dpurdie |
7509 |
}
|
|
|
7510 |
|
|
|
7511 |
if ( defined $debug && defined $debug->[0] )
|
|
|
7512 |
{
|
|
|
7513 |
print MAKEFILE 'ifeq "$(DEBUG)" "1"' . "\n";
|
|
|
7514 |
MakeEntry3( $tag, "+=", $debug );
|
| 267 |
dpurdie |
7515 |
print MAKEFILE 'endif' . "\n";
|
| 227 |
dpurdie |
7516 |
}
|
|
|
7517 |
|
|
|
7518 |
}
|
|
|
7519 |
|
|
|
7520 |
sub MakeIfDefEntry
|
|
|
7521 |
{
|
|
|
7522 |
my( $iftag, @rest ) = @_;
|
|
|
7523 |
|
|
|
7524 |
print MAKEFILE "ifdef $iftag\n";
|
|
|
7525 |
MakeDefEntry (@rest);
|
|
|
7526 |
print MAKEFILE "endif\n\n";
|
|
|
7527 |
}
|
|
|
7528 |
|
|
|
7529 |
sub MakeIfnDefEntry
|
|
|
7530 |
{
|
|
|
7531 |
my( $iftag, @rest ) = @_;
|
|
|
7532 |
|
|
|
7533 |
print MAKEFILE "ifndef $iftag\n";
|
|
|
7534 |
MakeDefEntry (@rest);
|
|
|
7535 |
print MAKEFILE "endif\n\n";
|
|
|
7536 |
}
|
|
|
7537 |
|
| 261 |
dpurdie |
7538 |
sub MakeIfZeroEntry
|
|
|
7539 |
{
|
|
|
7540 |
my( $iftag, @rest ) = @_;
|
|
|
7541 |
|
|
|
7542 |
print MAKEFILE "ifeq (\$($iftag),0)\n";
|
|
|
7543 |
MakeDefEntry (@rest);
|
|
|
7544 |
print MAKEFILE "endif\n\n";
|
|
|
7545 |
}
|
|
|
7546 |
|
| 227 |
dpurdie |
7547 |
#-------------------------------------------------------------------------------
|
|
|
7548 |
# Function : CreateNameList
|
|
|
7549 |
#
|
|
|
7550 |
# Description : Create a list of names by adding a prefix and suffix to a
|
|
|
7551 |
# list of items. This is used to add a directory prefix and a
|
|
|
7552 |
# file suffix to a list of files.
|
|
|
7553 |
#
|
|
|
7554 |
# Inputs : $prefix ie: '$(OBJDIR)/'
|
|
|
7555 |
# $suffix ie: '.obj'
|
|
|
7556 |
# $elem_ref ie: A list of files ( passed be ref )
|
|
|
7557 |
# If a Hash then its sorted keys is used
|
|
|
7558 |
#
|
|
|
7559 |
# Returns : A ref to the resulting list
|
|
|
7560 |
#
|
|
|
7561 |
sub CreateNameList
|
|
|
7562 |
{
|
|
|
7563 |
my( $prefix, $suffix, $elem_ref ) = @_;
|
|
|
7564 |
my @result;
|
|
|
7565 |
|
|
|
7566 |
if ( ref ($elem_ref) eq "HASH" )
|
|
|
7567 |
{
|
|
|
7568 |
my @hash_list;
|
|
|
7569 |
@hash_list = sort keys ( %{$elem_ref} );
|
|
|
7570 |
$elem_ref = \@hash_list;
|
|
|
7571 |
}
|
|
|
7572 |
|
|
|
7573 |
foreach ( @$elem_ref )
|
|
|
7574 |
{
|
|
|
7575 |
push @result, $prefix . $_ . $suffix;
|
|
|
7576 |
}
|
|
|
7577 |
return \@result;
|
|
|
7578 |
}
|
|
|
7579 |
|
|
|
7580 |
#-------------------------------------------------------------------------------
|
|
|
7581 |
# Function : ListGeneratedProjects
|
|
|
7582 |
#
|
|
|
7583 |
# Description : Return a list of generated/nongenerated projects
|
|
|
7584 |
# Used in conjunction with CreateNameList
|
|
|
7585 |
#
|
|
|
7586 |
# Inputs : $type - TRUE : Generated
|
|
|
7587 |
# FALSE: Not Generated
|
|
|
7588 |
#
|
|
|
7589 |
# Returns : A reference to a list of projects
|
|
|
7590 |
# undef will be retuend if there are no projects
|
|
|
7591 |
#
|
|
|
7592 |
sub ListGeneratedProjects
|
|
|
7593 |
{
|
|
|
7594 |
my ($type) = @_;
|
|
|
7595 |
my @list;
|
|
|
7596 |
foreach my $project ( @PROJECTS_ORDER )
|
|
|
7597 |
{
|
|
|
7598 |
if ( exists($PROJECTS{$project}->{'generated'}) xor $type )
|
|
|
7599 |
{
|
|
|
7600 |
push @list, $project;
|
|
|
7601 |
}
|
|
|
7602 |
}
|
|
|
7603 |
return @list ? \@list : undef;
|
|
|
7604 |
}
|
|
|
7605 |
|
|
|
7606 |
#-------------------------------------------------------------------------------
|
|
|
7607 |
# Function : ListCleanGenerated
|
|
|
7608 |
#
|
|
|
7609 |
# Description : return a list of generated targets that have 'clean'
|
|
|
7610 |
# operations. This is used in conjunction with CreateNameList
|
|
|
7611 |
#
|
|
|
7612 |
# Inputs : None
|
|
|
7613 |
#
|
|
|
7614 |
# Returns : A list of project indexes, that can be cleaned
|
|
|
7615 |
#
|
|
|
7616 |
sub ListCleanGenerated
|
|
|
7617 |
{
|
|
|
7618 |
my @list;
|
|
|
7619 |
foreach my $i ( @GENERATE_FILES )
|
|
|
7620 |
{
|
|
|
7621 |
push @list, $i->{'index'}
|
|
|
7622 |
if ( $i->{'clean'} );
|
|
|
7623 |
}
|
|
|
7624 |
return \@list;
|
|
|
7625 |
}
|
|
|
7626 |
|
| 251 |
dpurdie |
7627 |
#-------------------------------------------------------------------------------
|
|
|
7628 |
# Function : MakeResolve
|
|
|
7629 |
#
|
|
|
7630 |
# Description : Internal Function
|
|
|
7631 |
# Locate a source file by examining a list of directories
|
|
|
7632 |
#
|
|
|
7633 |
# Don't use directly
|
|
|
7634 |
# Use MakeSrcResolve or MakeSrcResolveExtended
|
|
|
7635 |
#
|
|
|
7636 |
# Inputs : $dirs - Ref to an array of directories to scan
|
|
|
7637 |
# $source - File to locate
|
|
|
7638 |
#
|
|
|
7639 |
# Returns : Resolved path to the file
|
|
|
7640 |
# Will warn if multiple instances of the file are found
|
|
|
7641 |
#
|
| 227 |
dpurdie |
7642 |
sub MakeResolve
|
|
|
7643 |
{
|
|
|
7644 |
my( $dirs, $source ) = @_;
|
| 285 |
dpurdie |
7645 |
my( $first, $count );
|
| 227 |
dpurdie |
7646 |
|
| 237 |
dpurdie |
7647 |
#
|
|
|
7648 |
# If the path contains a '$' then its assumed to be
|
|
|
7649 |
# a variable name in the path. Just assume that it exists
|
|
|
7650 |
#
|
|
|
7651 |
return $source if ( $source =~ m#\$# );
|
|
|
7652 |
|
|
|
7653 |
#
|
|
|
7654 |
# If the path is absolute or contains a leading ., then don't search
|
|
|
7655 |
# Warn if it can't be found
|
|
|
7656 |
#
|
|
|
7657 |
if ( $source =~ m#^(/|\.)# )
|
|
|
7658 |
{
|
|
|
7659 |
Warning( "Unable to resolve '$source' path" ) unless -f $source;
|
|
|
7660 |
return $source;
|
| 227 |
dpurdie |
7661 |
}
|
|
|
7662 |
|
| 237 |
dpurdie |
7663 |
|
| 227 |
dpurdie |
7664 |
#.. search local path first
|
|
|
7665 |
#
|
|
|
7666 |
$count = 0;
|
|
|
7667 |
$first = "";
|
| 331 |
dpurdie |
7668 |
$first = "$source" # was ./$source
|
| 227 |
dpurdie |
7669 |
if (-r "$source");
|
|
|
7670 |
|
|
|
7671 |
#.. search directory paths
|
|
|
7672 |
#
|
| 285 |
dpurdie |
7673 |
foreach my $dir (@$dirs)
|
| 227 |
dpurdie |
7674 |
{
|
| 331 |
dpurdie |
7675 |
next if ( $dir eq '.' );
|
|
|
7676 |
my $temp = "$dir/$source"; # was ./$dir/$source
|
| 227 |
dpurdie |
7677 |
Debug2( "MakeResolve: Looking in: $temp" );
|
|
|
7678 |
if (-r "$temp")
|
|
|
7679 |
{
|
|
|
7680 |
if ($first eq "") {
|
|
|
7681 |
$first = $temp;
|
|
|
7682 |
} else {
|
|
|
7683 |
Warning( "Duplicate '$source' image - '$temp'" );
|
|
|
7684 |
$count++;
|
|
|
7685 |
}
|
|
|
7686 |
}
|
|
|
7687 |
Debug3( "MakeResolve: $count, $temp" );
|
|
|
7688 |
}
|
|
|
7689 |
|
|
|
7690 |
if ($first eq "") {
|
|
|
7691 |
$first = $source;
|
|
|
7692 |
Warning( "Unable to resolve '$source' path" );
|
|
|
7693 |
} else {
|
|
|
7694 |
Warning( " using '$first'" )
|
|
|
7695 |
if ($count);
|
|
|
7696 |
}
|
|
|
7697 |
return $first;
|
|
|
7698 |
}
|
|
|
7699 |
|
| 251 |
dpurdie |
7700 |
#-------------------------------------------------------------------------------
|
|
|
7701 |
# Function : MakeSrcResolve
|
|
|
7702 |
#
|
|
|
7703 |
# Description : Locate a source file by examining the list of source
|
|
|
7704 |
# directories. There are a few frills
|
|
|
7705 |
#
|
|
|
7706 |
# Look for a source file in
|
|
|
7707 |
# 1) %::BUILD_KNOWNFILES
|
|
|
7708 |
# 2) %SRCS
|
|
|
7709 |
# 3) Dirs specified by the array @SRCSDIRS
|
|
|
7710 |
#
|
|
|
7711 |
# Inputs : Name of a file to resolve
|
|
|
7712 |
#
|
|
|
7713 |
# Returns : Resolved path.
|
| 283 |
dpurdie |
7714 |
# Input file - if not found at all
|
| 251 |
dpurdie |
7715 |
#
|
| 227 |
dpurdie |
7716 |
sub MakeSrcResolve
|
|
|
7717 |
{
|
|
|
7718 |
my ($name) = @_;
|
|
|
7719 |
my $file;
|
|
|
7720 |
|
| 251 |
dpurdie |
7721 |
if ( exists ( $::BUILD_KNOWNFILES{$name} ) ) {
|
|
|
7722 |
#
|
|
|
7723 |
# The Known Files list is relative to ScmRoot
|
|
|
7724 |
# This must be included in the full path
|
|
|
7725 |
#
|
|
|
7726 |
$file = $ScmRoot . '/' . $::BUILD_KNOWNFILES{$name};
|
|
|
7727 |
|
|
|
7728 |
} elsif ( exists $SRCS{$name} ) {
|
|
|
7729 |
$file = $SRCS{$name};
|
|
|
7730 |
|
|
|
7731 |
} else {
|
|
|
7732 |
$file = MakeResolve( \@SRCDIRS, @_ )
|
|
|
7733 |
}
|
| 227 |
dpurdie |
7734 |
return $file;
|
|
|
7735 |
}
|
|
|
7736 |
|
|
|
7737 |
|
|
|
7738 |
# MakeSrcResolveExtended
|
|
|
7739 |
# from_global = 0 : Search user specified directories
|
|
|
7740 |
# = 1 : Search LinkPkgArchive list
|
|
|
7741 |
#
|
|
|
7742 |
our @PkgSrcDirList;
|
|
|
7743 |
sub MakeSrcResolveExtended
|
|
|
7744 |
{
|
|
|
7745 |
my ( $from_global, $file ) = @_;
|
|
|
7746 |
|
|
|
7747 |
#
|
|
|
7748 |
# Simple Case. Resolve source from known source directories
|
|
|
7749 |
#
|
|
|
7750 |
#
|
|
|
7751 |
return MakeSrcResolve( $file )
|
|
|
7752 |
unless ( $from_global );
|
|
|
7753 |
|
|
|
7754 |
#
|
|
|
7755 |
# Not so simple Case
|
|
|
7756 |
# Resolve the source from the imported packages
|
|
|
7757 |
#
|
|
|
7758 |
# Create a list of directores to search, but only the first time
|
| 311 |
dpurdie |
7759 |
# - Interface directories - from BuildPkgArchive
|
| 227 |
dpurdie |
7760 |
# - LnkPkgArchive directories
|
|
|
7761 |
# Using target,product,platform include directories
|
|
|
7762 |
#
|
|
|
7763 |
unless ( @PkgSrcDirList )
|
|
|
7764 |
{
|
|
|
7765 |
for my $entry (@{$::ScmBuildPkgRules{$ScmPlatform} })
|
|
|
7766 |
{
|
| 311 |
dpurdie |
7767 |
next if ( $entry->{'TYPE'} eq 'build' ); # Ignore BuildPkgArchives
|
|
|
7768 |
|
| 227 |
dpurdie |
7769 |
for (@{$entry->{'PINCDIRS'}}, @{$entry->{'THXDIRS'}}, '' )
|
|
|
7770 |
{
|
|
|
7771 |
my $dir = $entry->{'ROOT'} . "/" . $_ ;
|
|
|
7772 |
$dir =~ s~//~/~g;
|
|
|
7773 |
$dir =~ s~/$~~;
|
| 311 |
dpurdie |
7774 |
push ( @PkgSrcDirList, $dir );
|
| 227 |
dpurdie |
7775 |
}
|
|
|
7776 |
}
|
| 311 |
dpurdie |
7777 |
}
|
| 227 |
dpurdie |
7778 |
|
|
|
7779 |
return MakeResolve( \@PkgSrcDirList, $file );
|
|
|
7780 |
}
|
|
|
7781 |
|
|
|
7782 |
#-------------------------------------------------------------------------------
|
|
|
7783 |
# Function : GetPackageRoot
|
|
|
7784 |
#
|
|
|
7785 |
# Description : Determine the root directory for a given package
|
|
|
7786 |
# This routine is intended for non-standard JATS scripts that
|
|
|
7787 |
# access package contents directly
|
|
|
7788 |
#
|
|
|
7789 |
# Note: This routine does not attempt to handle multiple
|
|
|
7790 |
# instances of a package ( sysbasetypes ).
|
|
|
7791 |
#
|
|
|
7792 |
# Inputs : $pname - Name of the package
|
|
|
7793 |
#
|
|
|
7794 |
# Returns :
|
|
|
7795 |
#
|
|
|
7796 |
sub GetPackageRoot
|
|
|
7797 |
{
|
|
|
7798 |
my( $pname ) = @_;
|
|
|
7799 |
Debug( "GetPackageRoot(@_)" );
|
|
|
7800 |
|
|
|
7801 |
my $result = undef;
|
|
|
7802 |
my $pkg = GetPackageEntry( $pname );
|
|
|
7803 |
if ( $pkg )
|
|
|
7804 |
{
|
|
|
7805 |
$result = $pkg->{'ROOT'};
|
|
|
7806 |
Debug( "GetPackageRoot: $result" );
|
|
|
7807 |
}
|
|
|
7808 |
|
|
|
7809 |
return $result;
|
|
|
7810 |
}
|
|
|
7811 |
|
|
|
7812 |
#-------------------------------------------------------------------------------
|
|
|
7813 |
# Function : ActiveProject
|
|
|
7814 |
#
|
|
|
7815 |
# Description : Determine if the specified project is currenly 'active'
|
|
|
7816 |
#
|
| 345 |
dpurdie |
7817 |
# Inputs : $project - one or more project names separated
|
|
|
7818 |
# by either a comma or a colon
|
| 227 |
dpurdie |
7819 |
#
|
|
|
7820 |
# Returns : TRUE if the project is active
|
|
|
7821 |
#
|
|
|
7822 |
sub ActiveProject
|
|
|
7823 |
{
|
|
|
7824 |
my ($project) = @_;
|
| 345 |
dpurdie |
7825 |
foreach ( split( '\s*[:,]\s*', $project ) )
|
| 227 |
dpurdie |
7826 |
{
|
|
|
7827 |
return 1
|
|
|
7828 |
if ( $_ eq $::ScmBuildProject );
|
|
|
7829 |
}
|
|
|
7830 |
return 0;
|
|
|
7831 |
}
|
|
|
7832 |
|
| 345 |
dpurdie |
7833 |
#-------------------------------------------------------------------------------
|
|
|
7834 |
# Function : ActiveDefine
|
|
|
7835 |
#
|
|
|
7836 |
# Description : Determine if the specified definition is currenly 'active'
|
|
|
7837 |
#
|
|
|
7838 |
# Inputs : $defs - one or more variable names separated
|
|
|
7839 |
# by either a comma or a colon
|
|
|
7840 |
#
|
|
|
7841 |
# Returns : TRUE if any of the definitions are known
|
|
|
7842 |
#
|
|
|
7843 |
sub ActiveDefine
|
|
|
7844 |
{
|
|
|
7845 |
my ($defs) = @_;
|
|
|
7846 |
no strict 'refs';
|
|
|
7847 |
foreach ( split( '\s*[:,]\s*', $defs ) )
|
|
|
7848 |
{
|
|
|
7849 |
return 1
|
|
|
7850 |
if ( defined( $$_ ) || defined( @$_ ) );
|
|
|
7851 |
}
|
|
|
7852 |
use strict 'refs';
|
|
|
7853 |
return 0;
|
|
|
7854 |
}
|
| 227 |
dpurdie |
7855 |
|
|
|
7856 |
#-------------------------------------------------------------------------------
|
| 345 |
dpurdie |
7857 |
# Function : ActiveMachType
|
|
|
7858 |
#
|
|
|
7859 |
# Description : Determine if the specified MachType is currenly 'active'
|
|
|
7860 |
#
|
|
|
7861 |
# Inputs : $mtype - one or more machine names separated
|
|
|
7862 |
# by either a comma or a colon
|
|
|
7863 |
#
|
|
|
7864 |
# Returns : TRUE if any of the current MachType is in the list
|
|
|
7865 |
#
|
|
|
7866 |
sub ActiveMachType
|
|
|
7867 |
{
|
|
|
7868 |
my ($mtype) = @_;
|
|
|
7869 |
foreach ( split( '\s*[:,]\s*', $mtype ) )
|
|
|
7870 |
{
|
|
|
7871 |
return 1
|
|
|
7872 |
if ( uc($_) eq uc($::GBE_MACHTYPE) );
|
|
|
7873 |
}
|
|
|
7874 |
return 0;
|
|
|
7875 |
}
|
|
|
7876 |
|
|
|
7877 |
#-------------------------------------------------------------------------------
|
| 227 |
dpurdie |
7878 |
# Function : ActivePlatform
|
|
|
7879 |
#
|
|
|
7880 |
# Description : Determine if the specified platform is currently 'active'
|
|
|
7881 |
# This is used by all user directives in order to determine
|
|
|
7882 |
# if the directive should be ignored for the current platform
|
|
|
7883 |
#
|
|
|
7884 |
# Inputs : $platform_spec - A platform specifier
|
|
|
7885 |
# This is a bit complex.
|
|
|
7886 |
#
|
| 241 |
dpurdie |
7887 |
# Format of platform_spec. One or more of
|
|
|
7888 |
# PlatformName
|
|
|
7889 |
# AliasName
|
|
|
7890 |
# TargetName,--Target
|
| 345 |
dpurdie |
7891 |
# Special Options (Must all be True)
|
|
|
7892 |
# --Project=ProjectName[:ProjectName]+
|
|
|
7893 |
# --Defined=SomeValue[:SomeValue]+
|
|
|
7894 |
# --MachType=SomeValue[:SomeValue]+
|
|
|
7895 |
|
|
|
7896 |
# Each can be prefixed with a '!' to negate the test
|
| 227 |
dpurdie |
7897 |
#
|
| 241 |
dpurdie |
7898 |
# Valid options are:
|
| 271 |
dpurdie |
7899 |
# --Target - indicates that the platform is a 'target'
|
| 241 |
dpurdie |
7900 |
#
|
|
|
7901 |
# Returns : TRUE if the platform spec is satisfied
|
|
|
7902 |
#
|
| 227 |
dpurdie |
7903 |
sub ActivePlatform
|
|
|
7904 |
{
|
|
|
7905 |
my( $platform_spec ) = @_;
|
|
|
7906 |
my( @platforms, $scmplatform, $platform );
|
|
|
7907 |
my( %arguments, @args, $filter );
|
| 241 |
dpurdie |
7908 |
my @plist;
|
|
|
7909 |
my ($match_count, $count_invert, $count_vert) = (0,0,0);
|
| 227 |
dpurdie |
7910 |
|
| 241 |
dpurdie |
7911 |
#
|
|
|
7912 |
# Short circuit check
|
|
|
7913 |
# '*' is used so often that it pays to check it first
|
|
|
7914 |
#
|
|
|
7915 |
if ( $platform_spec eq '*' )
|
|
|
7916 |
{
|
|
|
7917 |
Debug3( " ActivePlatform(@_) = TRUE" );
|
|
|
7918 |
return 1;
|
|
|
7919 |
}
|
| 227 |
dpurdie |
7920 |
|
| 241 |
dpurdie |
7921 |
#
|
|
|
7922 |
# Platform specifier may be a comma seperated list
|
|
|
7923 |
# ie: WIN32,MOS,XXX
|
|
|
7924 |
# Extract non-platform arguments
|
| 279 |
dpurdie |
7925 |
# Process to yield a dummy platform of '0' or '1' - these will be seen later
|
| 241 |
dpurdie |
7926 |
#
|
|
|
7927 |
foreach ( split( '\s*,\s*', $platform_spec ) )
|
|
|
7928 |
{
|
| 345 |
dpurdie |
7929 |
my ($result, $not);
|
|
|
7930 |
if ( m~^(!?)--Project=(.+)~ ) {
|
| 325 |
dpurdie |
7931 |
$not = $1;
|
| 345 |
dpurdie |
7932 |
$result = ActiveProject($2);
|
| 277 |
dpurdie |
7933 |
|
| 345 |
dpurdie |
7934 |
} elsif ( m~^(!?)--Defined=(.+)~ ) {
|
| 325 |
dpurdie |
7935 |
$not = $1;
|
| 345 |
dpurdie |
7936 |
$result = ActiveDefine($2);
|
| 241 |
dpurdie |
7937 |
|
| 345 |
dpurdie |
7938 |
} elsif ( m~^(!?)--MachType=(.+)~ ) {
|
| 325 |
dpurdie |
7939 |
$not = $1;
|
| 345 |
dpurdie |
7940 |
$result = ActiveMachType($2);
|
|
|
7941 |
|
| 325 |
dpurdie |
7942 |
} else {
|
|
|
7943 |
#
|
|
|
7944 |
# Must be a platform argument
|
|
|
7945 |
# Add to a list
|
|
|
7946 |
#
|
|
|
7947 |
push @platforms, $_;
|
| 241 |
dpurdie |
7948 |
next;
|
|
|
7949 |
}
|
|
|
7950 |
|
|
|
7951 |
#
|
| 325 |
dpurdie |
7952 |
# Continue processing non-platform arguments
|
| 345 |
dpurdie |
7953 |
# Each one must be TRUE, allowing for negation.
|
| 241 |
dpurdie |
7954 |
#
|
| 325 |
dpurdie |
7955 |
$result = $result ? 1 : 0;
|
| 345 |
dpurdie |
7956 |
$result = ! $result if ( $not );
|
|
|
7957 |
return 0 unless ( $result );
|
| 241 |
dpurdie |
7958 |
}
|
|
|
7959 |
|
|
|
7960 |
# Platform specified may be an Alias
|
|
|
7961 |
# Perform alias expansion
|
|
|
7962 |
#
|
|
|
7963 |
@platforms = ExpandPlatforms( @platforms ); # aliasing
|
| 227 |
dpurdie |
7964 |
Debug3( " ActivePlatform(@_)" );
|
| 325 |
dpurdie |
7965 |
# Debug0( " Platforms(@platforms)", "PLIST(@plist)" );
|
| 227 |
dpurdie |
7966 |
|
|
|
7967 |
#.. Arguments
|
| 241 |
dpurdie |
7968 |
# At this point we have a list of platforms and arguments
|
|
|
7969 |
# Build up a hash of arguments for each platform being parsed
|
| 227 |
dpurdie |
7970 |
# Multiple arguments can follow a platform name
|
| 241 |
dpurdie |
7971 |
# Arguments apply to the preceeding platform name
|
| 227 |
dpurdie |
7972 |
#
|
| 241 |
dpurdie |
7973 |
$platform = undef;
|
| 227 |
dpurdie |
7974 |
foreach ( @platforms )
|
|
|
7975 |
{
|
| 241 |
dpurdie |
7976 |
if ( /^--Target/ ) { # Arguments
|
|
|
7977 |
if ( $platform ) {
|
|
|
7978 |
$arguments{$platform}{'Target'} = 1;
|
|
|
7979 |
} else {
|
| 317 |
dpurdie |
7980 |
Warning ("No Platform preceding platform option: $_");
|
| 241 |
dpurdie |
7981 |
}
|
|
|
7982 |
|
| 305 |
dpurdie |
7983 |
} elsif ( /^--Only(Prod)|(Debug)/ || /--board=/ ) {
|
| 273 |
dpurdie |
7984 |
# Known arguments
|
| 305 |
dpurdie |
7985 |
# Bit of a kludge. Must be a better way
|
| 273 |
dpurdie |
7986 |
|
| 241 |
dpurdie |
7987 |
} elsif ( /^--/ ) {
|
|
|
7988 |
Warning ("Unknown platform option: $_");
|
|
|
7989 |
|
| 227 |
dpurdie |
7990 |
} else { # Target
|
|
|
7991 |
$platform = $_;
|
| 241 |
dpurdie |
7992 |
push @plist, $platform;
|
| 227 |
dpurdie |
7993 |
}
|
|
|
7994 |
}
|
|
|
7995 |
|
| 241 |
dpurdie |
7996 |
#.. Scan the expression
|
| 227 |
dpurdie |
7997 |
#
|
|
|
7998 |
$scmplatform = uc( $ScmPlatform ); # current platform
|
| 325 |
dpurdie |
7999 |
|
| 241 |
dpurdie |
8000 |
foreach ( @plist )
|
| 227 |
dpurdie |
8001 |
{
|
|
|
8002 |
$platform = uc( Trim( $_ ) ); # trim white and convert case
|
|
|
8003 |
|
|
|
8004 |
#
|
| 241 |
dpurdie |
8005 |
# Determine filter comparison
|
|
|
8006 |
# Either a Platform or a Target
|
|
|
8007 |
#
|
|
|
8008 |
if ( $arguments{$platform}{'Target'} )
|
| 227 |
dpurdie |
8009 |
{
|
| 241 |
dpurdie |
8010 |
$filter = uc( $ScmTarget );
|
| 227 |
dpurdie |
8011 |
}
|
| 241 |
dpurdie |
8012 |
else
|
|
|
8013 |
{
|
|
|
8014 |
$filter = $scmplatform; # filter specification
|
|
|
8015 |
}
|
|
|
8016 |
|
| 227 |
dpurdie |
8017 |
Debug3( " Platform=$platform, Filter=$filter" );
|
|
|
8018 |
|
|
|
8019 |
#
|
|
|
8020 |
# Examine platform names
|
|
|
8021 |
# Allow negation of name (!), but all the names must be negated
|
|
|
8022 |
# as a mix does not make sense.
|
|
|
8023 |
# ie: !P1,!P2,!P3 - All except P1,P2 or P3
|
|
|
8024 |
# P1,P2,P2 - Only P1,P2,P3
|
|
|
8025 |
#
|
| 241 |
dpurdie |
8026 |
my $invert = 0;
|
|
|
8027 |
if ( substr($platform, 0, 1) eq '!' )
|
|
|
8028 |
{
|
|
|
8029 |
$count_invert++;
|
|
|
8030 |
$platform = substr($platform, 1);
|
| 227 |
dpurdie |
8031 |
}
|
|
|
8032 |
else
|
| 241 |
dpurdie |
8033 |
{
|
|
|
8034 |
$count_vert++;
|
|
|
8035 |
}
|
| 227 |
dpurdie |
8036 |
|
| 241 |
dpurdie |
8037 |
$match_count++ if ( $platform eq '' ||
|
|
|
8038 |
$platform eq '*' ||
|
|
|
8039 |
$platform eq '1' ||
|
|
|
8040 |
$platform eq $filter );
|
| 227 |
dpurdie |
8041 |
}
|
|
|
8042 |
|
| 241 |
dpurdie |
8043 |
#
|
|
|
8044 |
# Sanity test
|
|
|
8045 |
# Force failure on bad sanity
|
|
|
8046 |
#
|
|
|
8047 |
if ( $count_vert && $count_invert )
|
|
|
8048 |
{
|
|
|
8049 |
Warning( "Platform expression makes no sense. Mixed use of '!' operator",
|
|
|
8050 |
"Expression: @_" );
|
|
|
8051 |
return 0;
|
|
|
8052 |
}
|
|
|
8053 |
|
|
|
8054 |
#
|
|
|
8055 |
# Test for pass
|
|
|
8056 |
# If not using '!', then any match passes : P1 or P2 or P3
|
|
|
8057 |
# If are using '!', then any match is bad : !P1 and !P2 and !P3 == !(P1 or P2 or P3)
|
|
|
8058 |
#
|
|
|
8059 |
if ( ( $count_vert && $match_count ) || ( $count_invert && ( not $match_count) ) )
|
|
|
8060 |
{
|
| 227 |
dpurdie |
8061 |
Debug3( " ActivePlatform(@_ == $ScmPlatform) = TRUE" );
|
|
|
8062 |
return 1;
|
|
|
8063 |
}
|
| 241 |
dpurdie |
8064 |
|
| 227 |
dpurdie |
8065 |
Debug3( " ActivePlatform(@_ == $ScmPlatform) = FALSE" );
|
|
|
8066 |
return 0;
|
|
|
8067 |
}
|
|
|
8068 |
|
|
|
8069 |
#-------------------------------------------------------------------------------
|
| 321 |
dpurdie |
8070 |
# Function : If
|
|
|
8071 |
#
|
|
|
8072 |
# Description : Function for embedding arguments in directives
|
|
|
8073 |
# To be used within another directive
|
|
|
8074 |
# ie:
|
|
|
8075 |
# AnyDirective ('*', arg1, arg2, ...
|
|
|
8076 |
# If (SomePlatform, arg1, .. ,argn))
|
|
|
8077 |
#
|
|
|
8078 |
# Inputs : $platform - Active Platform speciifier
|
|
|
8079 |
# @args - Args
|
|
|
8080 |
#
|
|
|
8081 |
# Returns : @args or nothing
|
|
|
8082 |
#
|
|
|
8083 |
sub If
|
|
|
8084 |
{
|
|
|
8085 |
my $platform = shift;
|
|
|
8086 |
return @_
|
|
|
8087 |
if ( ActivePlatform( $platform ));
|
|
|
8088 |
return;
|
|
|
8089 |
}
|
|
|
8090 |
|
|
|
8091 |
#-------------------------------------------------------------------------------
|
| 227 |
dpurdie |
8092 |
# Function : RegisterMakefileGenerate
|
|
|
8093 |
#
|
|
|
8094 |
# Description : Register a function to be called at the start of the
|
|
|
8095 |
# makefile generation process
|
|
|
8096 |
#
|
|
|
8097 |
# Inputs : $fname - Name of the function
|
|
|
8098 |
# $args - Function Arguments
|
|
|
8099 |
#
|
|
|
8100 |
# Returns : Nothing
|
|
|
8101 |
#
|
|
|
8102 |
our @MF_Generators;
|
|
|
8103 |
sub RegisterMakefileGenerate
|
|
|
8104 |
{
|
|
|
8105 |
my ($fref) = @_;
|
|
|
8106 |
my $rtype = ref($fref) || 'not a reference';
|
|
|
8107 |
|
|
|
8108 |
Error ("RegisterMakefileGenerate called incorrectly",
|
|
|
8109 |
"First argument MUST be a code reference",
|
|
|
8110 |
"It is a $rtype"
|
|
|
8111 |
) unless ( $rtype eq 'CODE' );
|
|
|
8112 |
|
|
|
8113 |
#
|
|
|
8114 |
# Save the arguments by reference in an array
|
|
|
8115 |
# The array will be processed later
|
|
|
8116 |
#
|
|
|
8117 |
push @MF_Generators, \@_;
|
|
|
8118 |
}
|
|
|
8119 |
|
|
|
8120 |
#-------------------------------------------------------------------------------
|
| 271 |
dpurdie |
8121 |
# Function : RegisterSrcHook
|
|
|
8122 |
#
|
|
|
8123 |
# Description : Register a function to be called when a source file is
|
|
|
8124 |
# declared
|
|
|
8125 |
#
|
|
|
8126 |
# Inputs : $ext - Extension of interest
|
|
|
8127 |
# '*' will be used by all
|
|
|
8128 |
# $fname - Name of the function
|
|
|
8129 |
# $args - Function Arguments
|
|
|
8130 |
#
|
|
|
8131 |
# Returns : Nothing
|
|
|
8132 |
#
|
|
|
8133 |
sub RegisterSrcHook
|
|
|
8134 |
{
|
|
|
8135 |
my $ext = shift;
|
|
|
8136 |
my ($fref) = @_;
|
|
|
8137 |
my $rtype = ref($fref) || 'not a reference';
|
|
|
8138 |
|
|
|
8139 |
Error ("RegisterSrcHook called incorrectly",
|
|
|
8140 |
"Second argument MUST be a code reference",
|
|
|
8141 |
"It is a $rtype"
|
|
|
8142 |
) unless ( $rtype eq 'CODE' );
|
|
|
8143 |
|
|
|
8144 |
#
|
|
|
8145 |
# Save the arguments by reference in an array
|
|
|
8146 |
# The array will be processed later
|
|
|
8147 |
#
|
|
|
8148 |
push @{$MF_RegisterSrcHooks{$ext}}, \@_;
|
|
|
8149 |
}
|
|
|
8150 |
|
|
|
8151 |
|
|
|
8152 |
#-------------------------------------------------------------------------------
|
| 227 |
dpurdie |
8153 |
# Function : MakefileHeader
|
|
|
8154 |
#
|
|
|
8155 |
# Description: : Generate a "standard" makefile header.
|
|
|
8156 |
#
|
|
|
8157 |
#..
|
|
|
8158 |
|
|
|
8159 |
sub MakefileHeader
|
|
|
8160 |
{
|
|
|
8161 |
my ($file, $desc, $by, @trailing) = @_;
|
|
|
8162 |
my ($diff);
|
|
|
8163 |
|
|
|
8164 |
$diff = 0 if (($diff = ((80-5) - length($desc))) < 0);
|
|
|
8165 |
$desc .= ' ' . ('-' x $diff);
|
|
|
8166 |
|
|
|
8167 |
print $file <<EOF;
|
|
|
8168 |
# -*- mode: mak; -*-
|
|
|
8169 |
#-- $desc
|
|
|
8170 |
#
|
|
|
8171 |
# -- Please do not edit this file. --
|
|
|
8172 |
#
|
|
|
8173 |
# To do so may result in a system failure, in additional to any
|
|
|
8174 |
# changes made shall be overwritten.
|
|
|
8175 |
#
|
|
|
8176 |
# Created by $by
|
|
|
8177 |
# on $::CurrentTime
|
|
|
8178 |
#
|
|
|
8179 |
EOF
|
|
|
8180 |
#
|
|
|
8181 |
# Print out the trailer
|
|
|
8182 |
# This is an array. Place each entry on a new line
|
|
|
8183 |
#
|
|
|
8184 |
print $file $_ . "\n" for ( @trailing );
|
|
|
8185 |
}
|
|
|
8186 |
|
|
|
8187 |
###############################################################################
|
|
|
8188 |
# MakeFileGenerate:
|
|
|
8189 |
# This subroutine does all of the actual make file generation based
|
|
|
8190 |
# on information provided in the calls to the various public
|
|
|
8191 |
# interface routines.
|
|
|
8192 |
#
|
|
|
8193 |
# Inputs:
|
|
|
8194 |
#
|
|
|
8195 |
# Returns:
|
|
|
8196 |
###############################################################################
|
|
|
8197 |
|
|
|
8198 |
my $MakefileGenerate_once = 0;
|
|
|
8199 |
sub MakefileGenerate
|
|
|
8200 |
{
|
|
|
8201 |
my $Makefile = "$ScmPlatform.mk";
|
|
|
8202 |
Debug( "MakefileGenerate: $Makefile" );
|
|
|
8203 |
|
|
|
8204 |
#
|
|
|
8205 |
# Nasty things happen when we generate a makefile twice
|
|
|
8206 |
# Just warn the user and do nothing
|
|
|
8207 |
# If its in the common makefile.pl then just ignore it
|
|
|
8208 |
#
|
|
|
8209 |
if ( $ScmProcessingRootMake )
|
|
|
8210 |
{
|
|
|
8211 |
Warning ("MakefileGenerate directive is not allowed in common makefile.pl");
|
|
|
8212 |
return;
|
|
|
8213 |
}
|
|
|
8214 |
|
|
|
8215 |
if ( $MakefileGenerate_once )
|
|
|
8216 |
{
|
|
|
8217 |
Warning ("MakefileGenerate should only be called once.",
|
|
|
8218 |
"Dir: $::Cwd");
|
|
|
8219 |
return;
|
|
|
8220 |
}
|
|
|
8221 |
$MakefileGenerate_once = 1;
|
|
|
8222 |
|
|
|
8223 |
#
|
|
|
8224 |
# Invoke all registered Makefile Generator functions
|
|
|
8225 |
# These allow clever directives to collect information to be
|
|
|
8226 |
# processed before the makefiles are created
|
|
|
8227 |
#
|
|
|
8228 |
while ( @MF_Generators )
|
|
|
8229 |
{
|
|
|
8230 |
Debug( "MakefileGenerate: Invoke RegisterMakefileGenerate function" );
|
|
|
8231 |
my ($fname, @args) = @{shift @MF_Generators};
|
|
|
8232 |
&$fname ( @args );
|
|
|
8233 |
}
|
|
|
8234 |
|
|
|
8235 |
#
|
|
|
8236 |
# Allow the toolset the opportunity to process all the collected data
|
|
|
8237 |
# before the makefile is created. This is optional
|
|
|
8238 |
#
|
|
|
8239 |
my( $if ) = MakeIf::Factory(); # build interface
|
|
|
8240 |
$if->Preprocess();
|
|
|
8241 |
|
|
|
8242 |
#
|
| 343 |
dpurdie |
8243 |
# If we have supressed the Toolset use, then we need to sanity test
|
|
|
8244 |
# the use of the toolset
|
|
|
8245 |
#
|
|
|
8246 |
if ( $ScmNoToolsTest )
|
|
|
8247 |
{
|
|
|
8248 |
ReportError ("Building programs not supported with --NoToolset") if ( @PROGS || @TESTPROGS );
|
|
|
8249 |
ReportError ("Building libraries not supported with --NoToolset") if ( @LIBS || @MLIBS || @SHLIBS );
|
|
|
8250 |
ReportError ("Building projects not supported with --NoToolset") if ( %PROJECTS );
|
|
|
8251 |
ErrorDoExit();
|
|
|
8252 |
}
|
|
|
8253 |
|
|
|
8254 |
#
|
| 227 |
dpurdie |
8255 |
# Auto package the 'descpkg' file
|
|
|
8256 |
# If this makefile packages any files, then it can also package the descpkg file
|
|
|
8257 |
# The descpkg will be piggybacked into all makefiles that do a package
|
|
|
8258 |
#
|
|
|
8259 |
if ( %PACKAGE_FILES || %PACKAGE_HDRS || %PACKAGE_CLSS || %PACKAGE_LIBS
|
|
|
8260 |
|| %PACKAGE_SHLIBS || %PACKAGE_PROGS )
|
|
|
8261 |
{
|
| 251 |
dpurdie |
8262 |
Src ('*', 'descpkg') unless ($SRCS{ descpkg });
|
|
|
8263 |
PackageFile ('*', 'descpkg');
|
| 227 |
dpurdie |
8264 |
}
|
|
|
8265 |
|
|
|
8266 |
#
|
|
|
8267 |
# Some toolsets NEED a relative root
|
| 261 |
dpurdie |
8268 |
# Note: At the moment ScmRoot is relative anyway, thus this code
|
|
|
8269 |
# does nothing
|
| 227 |
dpurdie |
8270 |
#
|
|
|
8271 |
my $gbe_root = $::ScmRoot;
|
|
|
8272 |
if ( $::UseRelativeRoot )
|
|
|
8273 |
{
|
|
|
8274 |
$gbe_root = RelPath( $::ScmRoot );
|
|
|
8275 |
}
|
|
|
8276 |
|
|
|
8277 |
#
|
|
|
8278 |
# Now start to create the makefile
|
|
|
8279 |
#
|
| 285 |
dpurdie |
8280 |
open( MAKEFILE, '>', $Makefile ) || Error( "Cannot create $Makefile" );
|
| 227 |
dpurdie |
8281 |
::MakefileHeader( *MAKEFILE,
|
|
|
8282 |
'Auto-generated Platform Dependent Makefile',
|
|
|
8283 |
"$ScmMakelib (version $ScmVersion)",
|
| 343 |
dpurdie |
8284 |
"# Copyright (C) 1995-$::CurrentYear Vix-ERG, All rights reserved",
|
| 227 |
dpurdie |
8285 |
'#',
|
|
|
8286 |
"# Located in $::Cwd",
|
|
|
8287 |
"# Platform $::ScmPlatform",
|
|
|
8288 |
'#' . ('-' x 79),
|
|
|
8289 |
);
|
|
|
8290 |
|
|
|
8291 |
#
|
|
|
8292 |
# Ensure that some essential variables are set
|
|
|
8293 |
#
|
|
|
8294 |
print MAKEFILE <<EOF;
|
|
|
8295 |
#
|
|
|
8296 |
# Validate essential environment variables
|
|
|
8297 |
#
|
|
|
8298 |
ifndef GBE_BIN
|
|
|
8299 |
\$(error ERROR: GBE_BIN is not available)
|
|
|
8300 |
endif
|
|
|
8301 |
ifndef GBE_PERL
|
|
|
8302 |
\$(error ERROR: GBE_PERL is not available)
|
|
|
8303 |
endif
|
|
|
8304 |
ifndef DEBUG
|
|
|
8305 |
\$(error ERROR: DEBUG is not defined)
|
|
|
8306 |
endif
|
|
|
8307 |
EOF
|
|
|
8308 |
|
|
|
8309 |
|
|
|
8310 |
print MAKEFILE <<EOF;
|
|
|
8311 |
|
|
|
8312 |
#
|
|
|
8313 |
# Basic definitions
|
|
|
8314 |
#
|
| 343 |
dpurdie |
8315 |
GBE_ROOT := $gbe_root
|
|
|
8316 |
GBE_ROOT_ABS := \$(abspath \$(GBE_ROOT))
|
|
|
8317 |
GBE_HOST := $::ScmHost
|
|
|
8318 |
GBE_HOSTMACH := $::GBE_MACHTYPE
|
|
|
8319 |
GBE_TARGET := $::ScmTarget
|
|
|
8320 |
GBE_MACHTYPE := $::ScmMachType
|
|
|
8321 |
GBE_PLATFORM := $::ScmPlatform
|
|
|
8322 |
GBE_PBASE := $::Pbase
|
|
|
8323 |
GBE_TYPE := \$(if \$(findstring 1,\$(DEBUG)),D,P)
|
| 227 |
dpurdie |
8324 |
EOF
|
|
|
8325 |
|
| 343 |
dpurdie |
8326 |
MakePrint( "GBE_ARGS := @ScmPlatformArgs\n" )
|
| 227 |
dpurdie |
8327 |
if ( scalar @ScmPlatformArgs );
|
|
|
8328 |
|
| 343 |
dpurdie |
8329 |
MakePrint( "GBE_PRODUCT := $ScmProduct\n" )
|
| 227 |
dpurdie |
8330 |
if ( $ScmProduct ne "" );
|
|
|
8331 |
|
| 343 |
dpurdie |
8332 |
MakePrint( "GBE_OS_COMMON := $::BUILDINFO{$ScmPlatform}{OS_COMMON}\n" )
|
| 227 |
dpurdie |
8333 |
if ( exists($::BUILDINFO{$ScmPlatform}{OS_COMMON}) );
|
|
|
8334 |
|
|
|
8335 |
|
|
|
8336 |
print MAKEFILE <<EOF;
|
|
|
8337 |
|
|
|
8338 |
SHELL := \$(GBE_BIN)/sh
|
|
|
8339 |
SHELLARGS :=
|
|
|
8340 |
EXTENDED_LINE := \$(GBE_BIN)/extend.lst
|
|
|
8341 |
export EXTENDED_LINE MAKE
|
|
|
8342 |
|
| 343 |
dpurdie |
8343 |
MFLAGS := --no-print --warn -r
|
|
|
8344 |
BUILDNAME := $::ScmBuildName
|
|
|
8345 |
BUILDVER := $::ScmBuildVersionFull
|
|
|
8346 |
BUILDVERNUM := $::ScmBuildVersion
|
| 227 |
dpurdie |
8347 |
BUILDPREVIOUSVER := $::ScmBuildPreviousVersion
|
| 343 |
dpurdie |
8348 |
DEPLOYPATCH := $ScmDeploymentPatch
|
|
|
8349 |
GBE_NOTOOLSTEST := $ScmNoToolsTest
|
| 227 |
dpurdie |
8350 |
|
|
|
8351 |
#
|
|
|
8352 |
# Ensure PWD is correctly set
|
|
|
8353 |
#
|
|
|
8354 |
PWD := \$(CURDIR)
|
|
|
8355 |
export PWD
|
|
|
8356 |
|
| 261 |
dpurdie |
8357 |
#
|
|
|
8358 |
# NODEPEND - Used to suppress generated dependency file checking
|
|
|
8359 |
# Mostly done in jmake.pl
|
|
|
8360 |
# EXPERT - Used to suppress dependency on this makefile
|
|
|
8361 |
#
|
|
|
8362 |
EOF
|
|
|
8363 |
|
| 285 |
dpurdie |
8364 |
MakePrint( "EXPERT\t\t?= " . ($ScmExpert ? '1' : '0' ) . "\n" );
|
|
|
8365 |
MakePrint( "NODEPEND\t?= 0\n" );
|
| 261 |
dpurdie |
8366 |
|
|
|
8367 |
print MAKEFILE <<EOF;
|
|
|
8368 |
|
|
|
8369 |
#
|
|
|
8370 |
# SCM_MAKEFILE - The name of the file to depend upon
|
|
|
8371 |
# Supressed in EXPERT mode
|
|
|
8372 |
#
|
|
|
8373 |
ifneq (\$(EXPERT),0)
|
|
|
8374 |
SCM_MAKEFILE :=
|
|
|
8375 |
else
|
|
|
8376 |
SCM_MAKEFILE := $Makefile
|
|
|
8377 |
endif
|
|
|
8378 |
EOF
|
|
|
8379 |
|
| 267 |
dpurdie |
8380 |
#
|
|
|
8381 |
# Setup the base directory for the packaging process
|
|
|
8382 |
# When building a deployable package the base directory is changed to match
|
|
|
8383 |
# that used by the deployment world. This is done so that the descpkg file
|
|
|
8384 |
# can be created in the correct location
|
|
|
8385 |
#
|
|
|
8386 |
my $PKGDIR = "pkg/$::Pbase";
|
|
|
8387 |
$PKGDIR = "build/deploy" if ( $DEPLOYPACKAGE );
|
|
|
8388 |
Verbose("Setting PKGDIR: $PKGDIR");
|
|
|
8389 |
|
| 261 |
dpurdie |
8390 |
print MAKEFILE <<EOF;
|
|
|
8391 |
|
| 227 |
dpurdie |
8392 |
#--------- Targets -------------------------------------------------------------
|
|
|
8393 |
|
|
|
8394 |
.PHONY: default all build install package unpackage uninstall \\
|
|
|
8395 |
clean unbuild clobber deploy
|
|
|
8396 |
|
| 373 |
dpurdie |
8397 |
default:
|
| 227 |
dpurdie |
8398 |
all: install package deploy
|
|
|
8399 |
build: make_init generate install_hdr depend make_lib \\
|
|
|
8400 |
install_lib make_install_shlib make_prog install_class
|
|
|
8401 |
install: build install_prog
|
|
|
8402 |
package: package_files package_hdr package_lib package_shlib package_prog \\
|
|
|
8403 |
package_class
|
|
|
8404 |
unpackage: unpackage_class unpackage_prog unpackage_shlib \\
|
|
|
8405 |
unpackage_lib unpackage_hdr unpackage_files
|
|
|
8406 |
uninstall: uninstall_class uninstall_prog uninstall_shlib \\
|
|
|
8407 |
uninstall_lib uninstall_hdr
|
|
|
8408 |
clean: make_clean unmake_prog unmake_test unmake_lib unobj \\
|
| 261 |
dpurdie |
8409 |
undepend ungenerate rmlitter unmake_dir
|
| 227 |
dpurdie |
8410 |
unbuild: clean uninstall
|
|
|
8411 |
clobber: unpackage unbuild
|
|
|
8412 |
deploy: install run_deploy
|
|
|
8413 |
|
|
|
8414 |
#--------- Macros --------------------------------------------------------------
|
|
|
8415 |
|
|
|
8416 |
OBJDIR = \$(GBE_PLATFORM)\$(GBE_TYPE).OBJ
|
|
|
8417 |
LIBDIR = \$(GBE_PLATFORM).LIB
|
|
|
8418 |
BINDIR = \$(GBE_PLATFORM)\$(GBE_TYPE).BIN
|
|
|
8419 |
CLSDIR = classes\$(GBE_TYPE)
|
|
|
8420 |
|
| 267 |
dpurdie |
8421 |
PKGDIR = \$(GBE_ROOT)/$PKGDIR
|
| 227 |
dpurdie |
8422 |
INCDIR_PKG = \$(PKGDIR)/include
|
|
|
8423 |
LIBDIR_PKG = \$(PKGDIR)/lib
|
|
|
8424 |
BINDIR_PKG = \$(PKGDIR)/bin
|
|
|
8425 |
CLSDIR_PKG = \$(PKGDIR)/classes
|
|
|
8426 |
|
|
|
8427 |
LOCALDIR = \$(GBE_ROOT)/local
|
|
|
8428 |
INCDIR_LOCAL = \$(LOCALDIR)/inc
|
|
|
8429 |
LIBDIR_LOCAL = \$(LOCALDIR)/lib
|
|
|
8430 |
BINDIR_LOCAL = \$(LOCALDIR)/bin
|
|
|
8431 |
CLSDIR_LOCAL = \$(LOCALDIR)/classes
|
|
|
8432 |
BINDIR_LOCAL_PATH = \$(GBE_ROOT_ABS)/local/bin/\$(GBE_PLATFORM)\$(GBE_TYPE)
|
|
|
8433 |
|
|
|
8434 |
INTERFACEDIR = \$(GBE_ROOT)/$ScmInterface
|
|
|
8435 |
INCDIR_INTERFACE= \$(INTERFACEDIR)/include
|
|
|
8436 |
LIBDIR_INTERFACE= \$(INTERFACEDIR)/lib
|
|
|
8437 |
BINDIR_INTERFACE= \$(INTERFACEDIR)/bin
|
|
|
8438 |
CLSDIR_INTERFACE= \$(INTERFACEDIR)/classes
|
|
|
8439 |
|
|
|
8440 |
.SUFFIXES: # Delete the default suffixes
|
|
|
8441 |
|
|
|
8442 |
EOF
|
|
|
8443 |
|
|
|
8444 |
MakePrintList( \@DEFINES );
|
|
|
8445 |
MakeNewLine();
|
|
|
8446 |
|
|
|
8447 |
#-------------------------------------------------------------------------------
|
|
|
8448 |
#
|
|
|
8449 |
#
|
| 261 |
dpurdie |
8450 |
MakeHeader ("Defines, flags and file sets");
|
| 227 |
dpurdie |
8451 |
|
|
|
8452 |
# Flags
|
| 261 |
dpurdie |
8453 |
foreach my $opt ( keys %ScmCompilerOpts )
|
|
|
8454 |
{
|
|
|
8455 |
MakeDefEntry ( $opt, "=", $ScmCompilerOpts{$opt} );
|
|
|
8456 |
}
|
| 227 |
dpurdie |
8457 |
|
| 261 |
dpurdie |
8458 |
MakeDefEntry( "CFLAGS", "=", \@CFLAGS, \@CFLAGS_PROD, \@CFLAGS_DEBUG );
|
|
|
8459 |
MakeDefEntry( "CLINTFLAGS", "=", \@CLINTFLAGS, \@CLINTFLAGS_PROD, \@CLINTFLAGS_DEBUG );
|
|
|
8460 |
MakeDefEntry( "CDEPENDFLAGS", "=", \@CFLAGS, \@CFLAGS_PROD, \@CFLAGS_DEBUG );
|
|
|
8461 |
MakeDefEntry( "CXXFLAGS", "=", \@CXXFLAGS, \@CXXFLAGS_PROD, \@CXXFLAGS_DEBUG );
|
|
|
8462 |
MakeDefEntry( "CXXLINTFLAGS", "=", \@CXXLINTFLAGS, \@CXXLINTFLAGS_PROD, \@CXXLINTFLAGS_DEBUG );
|
|
|
8463 |
MakeDefEntry( "CXXDEPENDFLAG", "=", \@CXXFLAGS, \@CXXFLAGS_PROD, \@CXXFLAGS_DEBUG );
|
| 267 |
dpurdie |
8464 |
MakeDefEntry( "ASFLAGS", "=", \@ASFLAGS, \@ASFLAGS_PROD, \@ASFLAGS_DEBUG );
|
|
|
8465 |
MakeDefEntry( "LDFLAGS", "=", \@LDFLAGS, \@LDFLAGS_PROD, \@LDFLAGS_DEBUG );
|
| 227 |
dpurdie |
8466 |
|
|
|
8467 |
|
|
|
8468 |
#-------------------------------------------------------------------------------
|
|
|
8469 |
#
|
|
|
8470 |
#
|
| 261 |
dpurdie |
8471 |
MakeHeader ("Tool Search Path",
|
|
|
8472 |
"Extend the PATH seen by all the tools to include",
|
|
|
8473 |
"The tools/bin directories discovered in Packages" );
|
|
|
8474 |
my $put_PATH;
|
|
|
8475 |
my $put_LD_LIBRARY_PATH;
|
|
|
8476 |
for my $path ( ToolExtensionPaths() )
|
|
|
8477 |
{
|
|
|
8478 |
MakePrint( "PATH := $path$::ScmPathSep\$(PATH)\n" );
|
|
|
8479 |
$put_PATH = 1;
|
| 227 |
dpurdie |
8480 |
|
| 261 |
dpurdie |
8481 |
if ( $::ScmHost eq "Unix" )
|
|
|
8482 |
{
|
| 227 |
dpurdie |
8483 |
MakePrint( "LD_LIBRARY_PATH ?= \n" );
|
|
|
8484 |
MakePrint( "LD_LIBRARY_PATH := $path$::ScmPathSep\$(LD_LIBRARY_PATH)\n" );
|
| 261 |
dpurdie |
8485 |
$put_LD_LIBRARY_PATH =1;
|
|
|
8486 |
}
|
| 227 |
dpurdie |
8487 |
}
|
|
|
8488 |
|
| 261 |
dpurdie |
8489 |
# Export the appropriate environment variables
|
|
|
8490 |
# Note: Windows has an issue with PATH and Path
|
|
|
8491 |
# Haven't got to the bottom of it yet, but it would appear that DLL
|
|
|
8492 |
# searching uses Path and other stuff uses PATH. Not too sure how we
|
|
|
8493 |
# end up with two (or more in the environment)
|
|
|
8494 |
#
|
|
|
8495 |
#
|
|
|
8496 |
if ( $put_LD_LIBRARY_PATH )
|
|
|
8497 |
{
|
| 343 |
dpurdie |
8498 |
MakePrint( "export LD_LIBRARY_PATH\n" );
|
| 261 |
dpurdie |
8499 |
}
|
| 227 |
dpurdie |
8500 |
|
| 261 |
dpurdie |
8501 |
if ( $put_PATH )
|
|
|
8502 |
{
|
| 343 |
dpurdie |
8503 |
MakePrint( "Path := \$(PATH)\n" );
|
|
|
8504 |
MakePrint( "export PATH Path\n" );
|
| 261 |
dpurdie |
8505 |
}
|
| 227 |
dpurdie |
8506 |
|
|
|
8507 |
#-------------------------------------------------------------------------------
|
|
|
8508 |
#
|
|
|
8509 |
#
|
| 261 |
dpurdie |
8510 |
MakeHeader ("Perl Module Search Path",
|
|
|
8511 |
"Extend the PERL5LIB seen by invocations of perl");
|
| 227 |
dpurdie |
8512 |
|
| 261 |
dpurdie |
8513 |
my $perl_module_found;
|
|
|
8514 |
for my $path ( ToolExtensionPaths() )
|
| 227 |
dpurdie |
8515 |
{
|
| 261 |
dpurdie |
8516 |
if (glob( "$path/*.pm"))
|
|
|
8517 |
{
|
| 227 |
dpurdie |
8518 |
MakePrint( "PERL5LIB := $path$::ScmPathSep\$(PERL5LIB)\n" );
|
| 261 |
dpurdie |
8519 |
$perl_module_found = 1;
|
|
|
8520 |
}
|
| 227 |
dpurdie |
8521 |
}
|
| 261 |
dpurdie |
8522 |
if ( $perl_module_found )
|
|
|
8523 |
{
|
| 227 |
dpurdie |
8524 |
MakePrint( "export PERL5LIB\n" );
|
| 261 |
dpurdie |
8525 |
}
|
| 227 |
dpurdie |
8526 |
|
| 261 |
dpurdie |
8527 |
#-------------------------------------------------------------------------------
|
|
|
8528 |
# Internal Helper Functions
|
|
|
8529 |
# Creating INCLUDE and LIBRARY paths
|
|
|
8530 |
#
|
|
|
8531 |
|
|
|
8532 |
# Assist in creating a list paths
|
|
|
8533 |
# $pList - Reference to an array to which $data will be added
|
|
|
8534 |
# $pSeen - Hash Ref to track tags that have been seen
|
|
|
8535 |
# $data - Data item to add, if tag is defined, but not seen
|
|
|
8536 |
# $tag - Resolved name for item
|
|
|
8537 |
#
|
| 227 |
dpurdie |
8538 |
sub PushPath
|
|
|
8539 |
{
|
|
|
8540 |
my ($pList, $pSeen, $data, $tag) = @_;
|
|
|
8541 |
if ( $tag )
|
|
|
8542 |
{
|
|
|
8543 |
unless ( exists $pSeen->{$tag} )
|
|
|
8544 |
{
|
|
|
8545 |
$pSeen->{$tag} = 1;
|
|
|
8546 |
push @{$pList}, $data;
|
|
|
8547 |
}
|
|
|
8548 |
}
|
|
|
8549 |
}
|
|
|
8550 |
|
|
|
8551 |
#
|
|
|
8552 |
# Search paths for include files and libraries
|
|
|
8553 |
# Currently symbolic paths are created, but there is very little need for this
|
|
|
8554 |
#
|
|
|
8555 |
sub MakePaths
|
|
|
8556 |
{
|
|
|
8557 |
my( $root ) = @_;
|
|
|
8558 |
my @pathlist;
|
|
|
8559 |
my %seen;
|
|
|
8560 |
|
|
|
8561 |
#
|
| 379 |
dpurdie |
8562 |
# Interface and Local directories are now treated quite
|
|
|
8563 |
# diffently. The Local is under our control.
|
| 227 |
dpurdie |
8564 |
#
|
|
|
8565 |
if ( $root =~ /INTERFACE/ ) {
|
| 379 |
dpurdie |
8566 |
|
|
|
8567 |
# eg. SCA_WIN32 and SCA_WIN32 and SCA_SOLARIS
|
|
|
8568 |
# SCA WIN32_i386 SPARC
|
|
|
8569 |
# WIN32 SCA SCA
|
|
|
8570 |
# . WIN32 SOLARIS
|
|
|
8571 |
# . .
|
|
|
8572 |
#..
|
|
|
8573 |
|
|
|
8574 |
#
|
|
|
8575 |
# For Interface Path List use the 'PARTS' as calculated within
|
|
|
8576 |
# the build file. Its good enough for everthing else in JATS
|
|
|
8577 |
#
|
|
|
8578 |
foreach ( @{$::BUILDINFO{$ScmPlatform}{PARTS}} ) {
|
| 227 |
dpurdie |
8579 |
PushPath( \@pathlist, \%seen, "$root/$_", $_ );
|
|
|
8580 |
}
|
|
|
8581 |
}
|
| 379 |
dpurdie |
8582 |
else
|
|
|
8583 |
{
|
|
|
8584 |
#
|
|
|
8585 |
# Local directory
|
|
|
8586 |
# The user can (should) only install stuff into a few known
|
|
|
8587 |
# locations.
|
|
|
8588 |
#
|
|
|
8589 |
foreach ( $ScmPlatform, $ScmProduct, $ScmTarget ) {
|
|
|
8590 |
PushPath( \@pathlist, \%seen, "$root/$_", $_ );
|
|
|
8591 |
}
|
|
|
8592 |
}
|
| 227 |
dpurdie |
8593 |
|
| 379 |
dpurdie |
8594 |
#
|
|
|
8595 |
# Add OS Common Directory
|
|
|
8596 |
### May need more testing before being added
|
|
|
8597 |
#
|
|
|
8598 |
#if ( exists($::BUILDINFO{$ScmPlatform}{OS_COMMON}) )
|
|
|
8599 |
#{
|
|
|
8600 |
# my $os_common = $::BUILDINFO{$ScmPlatform}{OS_COMMON};
|
|
|
8601 |
# PushPath( \@pathlist, \%seen, "$root/$os_common", $os_common );
|
|
|
8602 |
#}
|
| 227 |
dpurdie |
8603 |
|
| 379 |
dpurdie |
8604 |
#
|
|
|
8605 |
# Add the root directory too
|
|
|
8606 |
#
|
| 227 |
dpurdie |
8607 |
push @pathlist, "$root";
|
|
|
8608 |
return \@pathlist;
|
|
|
8609 |
}
|
| 379 |
dpurdie |
8610 |
|
| 227 |
dpurdie |
8611 |
|
|
|
8612 |
#-------------------------------------------------------------------------------
|
|
|
8613 |
#
|
|
|
8614 |
#
|
| 261 |
dpurdie |
8615 |
MakeHeader ("Include Search Paths",
|
| 367 |
dpurdie |
8616 |
"Package Include Paths for header files and libraries" );
|
| 227 |
dpurdie |
8617 |
|
| 367 |
dpurdie |
8618 |
MakeDefEntry( 'PINCDIRS', '=', '# includes');
|
|
|
8619 |
MakeDefEntry( 'PLIBDIRS', '=', '# libraries');
|
|
|
8620 |
|
|
|
8621 |
for my $package (@{$::ScmBuildPkgRules{$ScmPlatform} })
|
|
|
8622 |
{
|
|
|
8623 |
#
|
|
|
8624 |
# Skip the pseudo package that encapsulates the interface
|
|
|
8625 |
# directory. Currently the makefiles do this in a different
|
|
|
8626 |
# manner - to be resolved
|
|
|
8627 |
#
|
|
|
8628 |
# Just comment out the lines so that the data is visible
|
|
|
8629 |
# Its a hint to make use of the data
|
|
|
8630 |
#
|
|
|
8631 |
my $prefix = '';
|
|
|
8632 |
$prefix = '# ' if ( $package->{'TYPE'} eq 'interface' );
|
|
|
8633 |
$prefix = '# ' if ( $package->{'TYPE'} eq 'build' );
|
|
|
8634 |
|
|
|
8635 |
|
|
|
8636 |
my $name = $package->{'NAME'} . '/' . $package->{'VERSION'};
|
|
|
8637 |
my $base = $package->{'ROOT'};
|
|
|
8638 |
|
| 1328 |
dpurdie |
8639 |
my @doc;
|
|
|
8640 |
push (@doc, "From: $base");
|
|
|
8641 |
push (@doc, 'BuildPkgArchive via Interface' )if $package->{'TYPE'} eq 'build' ;
|
|
|
8642 |
push (@doc, 'Is Interface' ) if $package->{'TYPE'} eq 'interface' ;
|
| 367 |
dpurdie |
8643 |
|
| 1328 |
dpurdie |
8644 |
MakeHeader ("Source: $name", @doc);
|
|
|
8645 |
|
| 367 |
dpurdie |
8646 |
#
|
|
|
8647 |
# List include and library directories
|
|
|
8648 |
# Note: Need the True Path for windows.
|
|
|
8649 |
# Some makefile functions (wildcard) only work as expected
|
|
|
8650 |
# if the case of the pathname is correct. Really only a problem
|
|
|
8651 |
# with badly formed legecy packages where the Windows user
|
|
|
8652 |
# guessed at the package format.
|
|
|
8653 |
#
|
|
|
8654 |
# The conversion to a TruePath is done when ScmBuildPkgRules
|
|
|
8655 |
# is created. Create one, use many time.
|
|
|
8656 |
#
|
|
|
8657 |
#
|
|
|
8658 |
for my $type (qw (PINCDIRS PLIBDIRS) )
|
|
|
8659 |
{
|
|
|
8660 |
for my $path ( @{$package->{$type}} )
|
|
|
8661 |
{
|
|
|
8662 |
MakeDefEntry ( "$prefix$type", "+=", $base . $path);
|
|
|
8663 |
}
|
|
|
8664 |
}
|
|
|
8665 |
}
|
|
|
8666 |
|
|
|
8667 |
#-------------------------------------------------------------------------------
|
|
|
8668 |
#
|
|
|
8669 |
#
|
|
|
8670 |
MakeHeader ("Include Search Paths",
|
|
|
8671 |
"Local Include Paths",
|
|
|
8672 |
" LINKDIRS - Local include search path (short)",
|
|
|
8673 |
" INCDIRS - Include search path (complete)",
|
|
|
8674 |
" NODEPDIRS - ",
|
|
|
8675 |
" SRCDIRS - ",
|
|
|
8676 |
" LIBDIRS - Library search path",
|
|
|
8677 |
|
|
|
8678 |
);
|
|
|
8679 |
|
| 227 |
dpurdie |
8680 |
# Include search path
|
|
|
8681 |
#
|
|
|
8682 |
# user-local
|
| 367 |
dpurdie |
8683 |
# local
|
|
|
8684 |
# interface
|
|
|
8685 |
# BuildPkgArchive
|
|
|
8686 |
# LinkPkgArchive
|
| 227 |
dpurdie |
8687 |
# user-global
|
|
|
8688 |
#
|
|
|
8689 |
|
| 367 |
dpurdie |
8690 |
MakeDefEntry ( "\nLINCDIRS", "= ", \@L_INCDIRS ); # .. Local
|
| 261 |
dpurdie |
8691 |
MakeDefEntry ( "LINCDIRS", "+=", MakePaths( '$(INCDIR_LOCAL)' )); # .. Sandbox interface
|
|
|
8692 |
MakeDefEntry ( "LINCDIRS", "+=", MakePaths( '$(INCDIR_INTERFACE)' )); # .. Sandbox interface
|
|
|
8693 |
MakeDefEntry ( "LINCDIRS", "+=", \@G_INCDIRS ); # .. Global
|
| 227 |
dpurdie |
8694 |
|
| 367 |
dpurdie |
8695 |
MakeDefEntry ( "INCDIRS", "= ", '$(LINCDIRS)' ); # Local
|
|
|
8696 |
MakeDefEntry ( "INCDIRS", "+=", '$(PINCDIRS)' ); # Package
|
|
|
8697 |
MakeDefEntry ( "LINCDIRS", "+=", \@S_INCDIRS ); # System
|
| 227 |
dpurdie |
8698 |
|
|
|
8699 |
# Source search path
|
|
|
8700 |
|
| 261 |
dpurdie |
8701 |
MakeDefEntry( "\nNODEPDIRS", "=", \@NODEPDIRS );
|
| 227 |
dpurdie |
8702 |
|
| 367 |
dpurdie |
8703 |
MakeDefEntry( "\nSRCDIRS","= " , [ @L_SRCDIRS, @G_SRCDIRS ] ); # Local
|
|
|
8704 |
MakeDefEntry ( "SRCDIRS", "+=" , '$(PINCDIRS)' ); # Package
|
|
|
8705 |
MakeDefEntry ( "SRCDIRS", "+=" , \@S_INCDIRS ); # System
|
| 227 |
dpurdie |
8706 |
|
|
|
8707 |
# Library search path
|
|
|
8708 |
#
|
|
|
8709 |
# user-local
|
| 367 |
dpurdie |
8710 |
# local
|
|
|
8711 |
# interface
|
|
|
8712 |
# BuildPkgArchive
|
|
|
8713 |
# LinkPkgArchive
|
| 227 |
dpurdie |
8714 |
# user-global
|
|
|
8715 |
|
| 367 |
dpurdie |
8716 |
MakeDefEntry( "\nLIBDIRS", "= ", '$(LIBDIR)' ); # User Local
|
| 261 |
dpurdie |
8717 |
MakeDefEntry( "LIBDIRS", "+=", \@L_LIBDIRS ); # Local
|
|
|
8718 |
MakeDefEntry( "LIBDIRS", "+=", MakePaths( '$(LIBDIR_LOCAL)' )); # Sandbox/interface
|
|
|
8719 |
MakeDefEntry( "LIBDIRS", "+=", MakePaths( '$(LIBDIR_INTERFACE)' ));
|
|
|
8720 |
MakeDefEntry( "LIBDIRS", "+=", \@G_LIBDIRS ); # Global
|
| 367 |
dpurdie |
8721 |
MakeDefEntry( "LIBDIRS", "+=", '$(PLIBDIRS)' ); # Package
|
| 261 |
dpurdie |
8722 |
MakeDefEntry( "LIBDIRS", "+=", \@S_LIBDIRS ); # System
|
| 227 |
dpurdie |
8723 |
|
|
|
8724 |
#-------------------------------------------------------------------------------
|
|
|
8725 |
#
|
|
|
8726 |
# Subdir creation and deletion
|
|
|
8727 |
# Creation is done on the fly
|
|
|
8728 |
# Deletion is done AFTER the toolset functions have been invoked to create the
|
|
|
8729 |
# build artifacts so that the toolsets can create directories too
|
|
|
8730 |
|
|
|
8731 |
MakeHeader ("Subdir creation");
|
|
|
8732 |
CreateMkdirRules();
|
| 343 |
dpurdie |
8733 |
MkdirRule( '$(OBJDIR)', 'OBJDIR' ); # Object build directory
|
|
|
8734 |
MkdirRule( '$(OBJDIR)/'.$_ ) foreach (@SHLIBS); # Shared library build directory
|
|
|
8735 |
MkdirRule( '$(LIBDIR)', 'LIBDIR' ); # Library directory
|
|
|
8736 |
MkdirRule( '$(BINDIR)', 'BINDIR' ); # Binary directory
|
| 227 |
dpurdie |
8737 |
|
| 261 |
dpurdie |
8738 |
#
|
|
|
8739 |
# Create a directory for library merge tool to work within
|
|
|
8740 |
#
|
|
|
8741 |
MkdirRule( "\$(MLIBDIR)", 'MLIBDIR', '--Path=$(GBE_PLATFORM).MRG', '--RemoveAll' ) if (@MLIBS);
|
|
|
8742 |
|
| 227 |
dpurdie |
8743 |
#-------------------------------------------------------------------------------
|
|
|
8744 |
# Generate rules and recipes to create all the toolset specific parts
|
|
|
8745 |
# This is done fairly early to allow the toolsets to extend various
|
|
|
8746 |
# definitions that may be used later in the makefile construction
|
|
|
8747 |
#
|
|
|
8748 |
MakeHeader ("Construct Programs");
|
|
|
8749 |
|
|
|
8750 |
foreach my $i ( @PROGS )
|
|
|
8751 |
{
|
| 289 |
dpurdie |
8752 |
my $pProg = $PROGS->Get($i);
|
|
|
8753 |
my $pArgs = $pProg->getItems('ARGS');
|
|
|
8754 |
my $pObjs = $pProg->getItems('OBJS');
|
|
|
8755 |
my $pLibs = $pProg->getItems('LIBS');
|
| 227 |
dpurdie |
8756 |
|
| 289 |
dpurdie |
8757 |
#
|
|
|
8758 |
# Create a list of program object files
|
|
|
8759 |
#
|
|
|
8760 |
push @PROGOBJS, @$pObjs;
|
| 227 |
dpurdie |
8761 |
|
|
|
8762 |
MakePrint( "#---- (${i})\n\n" );
|
|
|
8763 |
if ( $ScmToolsetProgDependancies )
|
|
|
8764 |
{
|
| 261 |
dpurdie |
8765 |
#
|
|
|
8766 |
# Original style Prog Interface
|
| 271 |
dpurdie |
8767 |
# Write some dependency information here and some in the toolset
|
|
|
8768 |
# Problems:
|
|
|
8769 |
# 1) Errors in library dependency generation will be
|
|
|
8770 |
# reported after all the object files have been created
|
|
|
8771 |
# Thus the error message and the make-stop are seperated
|
|
|
8772 |
# by many,many lines of output. This makes it difficult
|
|
|
8773 |
# to see the error.
|
| 261 |
dpurdie |
8774 |
#
|
| 271 |
dpurdie |
8775 |
# 2) Lack of Flexability
|
|
|
8776 |
#
|
| 293 |
dpurdie |
8777 |
MakeEntry( "\$(BINDIR)/$i$::exe: ", "", "\\\n\t\t", ".$::o ", @$pObjs );
|
| 227 |
dpurdie |
8778 |
}
|
|
|
8779 |
else
|
|
|
8780 |
{
|
| 261 |
dpurdie |
8781 |
#
|
|
|
8782 |
# New Style Prog Interface
|
|
|
8783 |
# The toolset does it all
|
|
|
8784 |
#
|
|
|
8785 |
# Flag the progam packaging as a placeholder.
|
|
|
8786 |
# The toolset will replace/update it.
|
|
|
8787 |
#
|
| 227 |
dpurdie |
8788 |
PackageProgRemoveFiles( $i );
|
|
|
8789 |
}
|
|
|
8790 |
|
| 289 |
dpurdie |
8791 |
$if->LD ( $i, $pArgs, $pObjs, $pLibs );
|
|
|
8792 |
$if->LDLINT( $i, $pArgs, $pObjs, $pLibs );
|
| 227 |
dpurdie |
8793 |
}
|
|
|
8794 |
|
|
|
8795 |
#-------------------------------------------------------------------------------
|
|
|
8796 |
#
|
|
|
8797 |
#
|
|
|
8798 |
MakeHeader ("Construct Test Programs");
|
| 289 |
dpurdie |
8799 |
foreach my $i ( @TESTPROGS )
|
| 227 |
dpurdie |
8800 |
{
|
| 289 |
dpurdie |
8801 |
my $pProg = $TESTPROGS->Get($i);
|
|
|
8802 |
my $pArgs = $pProg->getItems('ARGS');
|
|
|
8803 |
my $pObjs = $pProg->getItems('OBJS');
|
|
|
8804 |
my $pLibs = $pProg->getItems('LIBS');
|
| 227 |
dpurdie |
8805 |
|
| 289 |
dpurdie |
8806 |
#
|
|
|
8807 |
# Create a list of program object files
|
|
|
8808 |
#
|
|
|
8809 |
push @TESTPROGOBJS, @$pObjs;
|
|
|
8810 |
|
| 227 |
dpurdie |
8811 |
MakePrint( "#---- (${i})\n\n" );
|
|
|
8812 |
if ( $ScmToolsetProgDependancies )
|
|
|
8813 |
{
|
| 293 |
dpurdie |
8814 |
MakeEntry( "\$(BINDIR)/$i$::exe: ", "", "\\\n\t\t", ".$::o ", @$pObjs );
|
| 227 |
dpurdie |
8815 |
}
|
|
|
8816 |
else
|
|
|
8817 |
{
|
|
|
8818 |
PackageProgRemoveFiles( $i );
|
|
|
8819 |
}
|
|
|
8820 |
|
| 289 |
dpurdie |
8821 |
$if->LD ( $i, $pArgs, $pObjs, $pLibs );
|
|
|
8822 |
$if->LDLINT( $i, $pArgs, $pObjs, $pLibs );
|
| 227 |
dpurdie |
8823 |
}
|
|
|
8824 |
|
|
|
8825 |
#-------------------------------------------------------------------------------
|
|
|
8826 |
#
|
|
|
8827 |
#
|
|
|
8828 |
MakeHeader ("Transfer Scripts to BINDIR");
|
|
|
8829 |
foreach my $i ( sort ( values %SCRIPTS ))
|
|
|
8830 |
{
|
|
|
8831 |
my $tname = "\$(BINDIR)/" . StripDir( $i );
|
|
|
8832 |
|
|
|
8833 |
|
|
|
8834 |
MakePrint( "$i:\t\tmakefile.pl\n" .
|
| 261 |
dpurdie |
8835 |
"\t\$(XX_PRE)if [ ! -f \"$i\" ]; then echo Script [$i] not found; exit 2; fi\n\n" );
|
| 227 |
dpurdie |
8836 |
|
|
|
8837 |
#
|
|
|
8838 |
# Create a rule to copy the script into the BIN directory
|
|
|
8839 |
# Mark the script as executable - It can't hurt and its there
|
|
|
8840 |
# to be run as part of a test.
|
|
|
8841 |
#
|
|
|
8842 |
MakePrint "$tname:\t\$(GBE_BINDIR) $i\n" .
|
|
|
8843 |
"\t\$(XX_PRE)\$(cp) -f $i $tname\n" .
|
|
|
8844 |
"\t\$(XX_PRE)\$(chmod) -f +wx $tname\n\n"
|
|
|
8845 |
}
|
|
|
8846 |
|
|
|
8847 |
#-------------------------------------------------------------------------------
|
|
|
8848 |
#
|
|
|
8849 |
#
|
|
|
8850 |
MakeHeader ("Construct Libraries");
|
|
|
8851 |
foreach my $i ( @LIBS )
|
|
|
8852 |
{
|
| 289 |
dpurdie |
8853 |
my $pLib = $LIBS->Get($i);
|
|
|
8854 |
my $pArgs = $pLib->getItems('ARGS');
|
|
|
8855 |
my $pObjs = $pLib->getItems('OBJS');
|
| 227 |
dpurdie |
8856 |
|
| 363 |
dpurdie |
8857 |
unless ( $ScmToolsetNillLibSrc )
|
|
|
8858 |
{
|
|
|
8859 |
Error ("Library has no component objects: $i")
|
|
|
8860 |
if ( scalar @$pObjs <= 0 );
|
|
|
8861 |
}
|
| 299 |
dpurdie |
8862 |
|
| 227 |
dpurdie |
8863 |
MakePrint "#---- (${i})\n\n";
|
| 289 |
dpurdie |
8864 |
$if->AR( $i, $pArgs, $pObjs, $pLib);
|
|
|
8865 |
$if->ARLINT( $i, $pArgs, $pObjs, $pLib );
|
| 227 |
dpurdie |
8866 |
}
|
|
|
8867 |
|
| 289 |
dpurdie |
8868 |
#-------------------------------------------------------------------------------
|
|
|
8869 |
#
|
|
|
8870 |
#
|
|
|
8871 |
MakeHeader ("Construct Merged Libraries");
|
| 227 |
dpurdie |
8872 |
sub MlibEntry
|
|
|
8873 |
{
|
| 289 |
dpurdie |
8874 |
my( $mlib, $plib, $pLibs ) = @_;
|
| 227 |
dpurdie |
8875 |
my @flib;
|
|
|
8876 |
|
| 289 |
dpurdie |
8877 |
MakePrint '$(LIBDIR)/' . GenLibName($mlib) . ":";
|
|
|
8878 |
foreach my $lib ( @$pLibs )
|
| 227 |
dpurdie |
8879 |
{
|
| 289 |
dpurdie |
8880 |
#
|
|
|
8881 |
# Each library name may contains one embedded option which
|
|
|
8882 |
# specifies the source directory
|
|
|
8883 |
# libname[,--Option | BaseSubdir]
|
|
|
8884 |
#
|
| 227 |
dpurdie |
8885 |
my ($slib, $sdir) = split( ',', $lib );
|
| 343 |
dpurdie |
8886 |
my $mode;
|
| 227 |
dpurdie |
8887 |
|
|
|
8888 |
#
|
| 283 |
dpurdie |
8889 |
# By default the librares are pulled from LOCAL unless the
|
|
|
8890 |
# library is built in this directory, in which case it will
|
| 289 |
dpurdie |
8891 |
# be used.
|
| 227 |
dpurdie |
8892 |
#
|
| 289 |
dpurdie |
8893 |
$sdir = ( $LIBS->Get($slib) ) ? '--Here' : '--Local'
|
|
|
8894 |
unless ( $sdir );
|
| 227 |
dpurdie |
8895 |
|
|
|
8896 |
#
|
|
|
8897 |
# --Interface - Pull library from the interface directory
|
|
|
8898 |
# --Local - Pull library from the local directory
|
|
|
8899 |
# --SubDir=xxxx - Pull library from specified subdirectory
|
| 283 |
dpurdie |
8900 |
# --Here - Pull from local directory if built locally
|
| 227 |
dpurdie |
8901 |
# otherwise - Pull library from specified subdirectory
|
|
|
8902 |
#
|
|
|
8903 |
if ($sdir eq '--Interface') {
|
|
|
8904 |
$sdir = '$(LIBDIR_INTERFACE)/$(GBE_PLATFORM)';
|
|
|
8905 |
|
| 343 |
dpurdie |
8906 |
|
|
|
8907 |
} elsif ($sdir eq '--InterfacePlain') {
|
|
|
8908 |
$sdir = '$(LIBDIR_INTERFACE)/$(GBE_PLATFORM)';
|
|
|
8909 |
$mode = 1;
|
|
|
8910 |
|
| 227 |
dpurdie |
8911 |
} elsif ( $sdir eq '--Local') {
|
|
|
8912 |
$sdir = $PackageInfo{'Lib'}{'IBase'} . # Base of Installed libs
|
|
|
8913 |
$PackageInfo{'Lib'}{'Dir'}; # Default subdir
|
|
|
8914 |
|
|
|
8915 |
} elsif ( $sdir =~ m~^--SubDir=(.*)~ ) {
|
|
|
8916 |
$sdir = $1 . '/$(LIBDIR)';
|
|
|
8917 |
|
| 283 |
dpurdie |
8918 |
} elsif ( $sdir eq '--Here') {
|
|
|
8919 |
$sdir = '$(LIBDIR)';
|
|
|
8920 |
|
| 227 |
dpurdie |
8921 |
} else {
|
|
|
8922 |
$sdir .= '/$(LIBDIR)';
|
|
|
8923 |
}
|
|
|
8924 |
|
| 343 |
dpurdie |
8925 |
MakePrint " \\\n\t\t${sdir}/" . GenLibName($slib, $mode);
|
| 227 |
dpurdie |
8926 |
push @flib, "${sdir}/${slib}";
|
|
|
8927 |
}
|
| 289 |
dpurdie |
8928 |
return \@flib;
|
| 227 |
dpurdie |
8929 |
}
|
|
|
8930 |
|
|
|
8931 |
foreach my $i ( @MLIBS )
|
|
|
8932 |
{
|
| 289 |
dpurdie |
8933 |
my $pLib = $MLIBS->Get($i);
|
|
|
8934 |
my $pArgs = $pLib->getItems('ARGS');
|
|
|
8935 |
my $pLibs = $pLib->getItems('LIBS');
|
| 227 |
dpurdie |
8936 |
|
| 261 |
dpurdie |
8937 |
MakePrint "#---- (${i})\n\n";
|
|
|
8938 |
|
| 227 |
dpurdie |
8939 |
unless ( defined &ToolsetARMerge )
|
|
|
8940 |
{
|
|
|
8941 |
Warning( "Merging of libraries not supported in this toolset yet" );
|
|
|
8942 |
Warning( "MergeLibrary: \"$i\" will not be created" );
|
|
|
8943 |
}
|
|
|
8944 |
else
|
|
|
8945 |
{
|
|
|
8946 |
#
|
|
|
8947 |
# Create the dependency rule
|
|
|
8948 |
# Target library : source library list
|
|
|
8949 |
# Recipe - generated by the toolset
|
|
|
8950 |
#
|
| 289 |
dpurdie |
8951 |
foreach ( @$pArgs )
|
| 227 |
dpurdie |
8952 |
{
|
|
|
8953 |
Warning( "Ignoring unknown argument to MergeLibrary. $_" );
|
|
|
8954 |
}
|
| 289 |
dpurdie |
8955 |
$pLibs = MlibEntry( $i, $pLib, $pLibs );
|
|
|
8956 |
$if->ARMerge( $i, $pArgs, $pLibs, $pLib );
|
| 227 |
dpurdie |
8957 |
}
|
|
|
8958 |
}
|
|
|
8959 |
|
| 289 |
dpurdie |
8960 |
#-------------------------------------------------------------------------------
|
|
|
8961 |
#
|
|
|
8962 |
#
|
|
|
8963 |
MakeHeader ("Construct Shared Libraries");
|
| 339 |
dpurdie |
8964 |
|
| 227 |
dpurdie |
8965 |
foreach my $i ( @SHLIBS )
|
|
|
8966 |
{
|
| 289 |
dpurdie |
8967 |
my $pShlib = $SHLIBS->Get($i);
|
|
|
8968 |
my $pArgs = $pShlib->getItems('ARGS');
|
|
|
8969 |
my $pObjs = $pShlib->getItems('OBJS');
|
|
|
8970 |
my $pLibs = $pShlib->getItems('LIBS');
|
|
|
8971 |
my $version = $pShlib->{VERSION};
|
| 227 |
dpurdie |
8972 |
|
| 289 |
dpurdie |
8973 |
$if->SHLD ( $i, $pArgs, $pObjs, $pLibs, $version );
|
|
|
8974 |
$if->SHLDLINT( $i, $pArgs, $pObjs, $pLibs, $version );
|
| 227 |
dpurdie |
8975 |
}
|
|
|
8976 |
|
|
|
8977 |
#-------------------------------------------------------------------------------
|
|
|
8978 |
# Construct Objects
|
|
|
8979 |
# For each object within OBJSOURCE construct the following:
|
|
|
8980 |
#
|
|
|
8981 |
# $(OBJDIR)/object-name: source-name [makefile]
|
|
|
8982 |
# Toolset ...
|
|
|
8983 |
#
|
|
|
8984 |
#
|
|
|
8985 |
#
|
|
|
8986 |
MakeHeader ("Construct Objects");
|
| 371 |
dpurdie |
8987 |
|
| 227 |
dpurdie |
8988 |
foreach my $i ( sort keys %OBJSOURCE )
|
|
|
8989 |
{
|
|
|
8990 |
my( $src, $sname, $ext, $type, @args );
|
|
|
8991 |
|
|
|
8992 |
$src = $OBJSOURCE{ $i };
|
|
|
8993 |
$sname = StripDir( $src );
|
|
|
8994 |
$ext = StripFile( $src );
|
|
|
8995 |
$ext = lc($ext)
|
|
|
8996 |
if ( $::ScmHost ne "Unix" );
|
| 381 |
dpurdie |
8997 |
$type = ($ScmSourceTypes{ $ext } || '')
|
| 227 |
dpurdie |
8998 |
unless (( $type = $SRC_TYPE{ $sname }) );
|
|
|
8999 |
|
|
|
9000 |
#
|
|
|
9001 |
# Object source is an object file
|
|
|
9002 |
# No need the generate the object, just create makefile rule
|
| 261 |
dpurdie |
9003 |
# [ddp] Not too sure how we get here
|
| 227 |
dpurdie |
9004 |
#
|
|
|
9005 |
if ( $ext eq ".$::o" )
|
|
|
9006 |
{
|
|
|
9007 |
MakePrint "$src:";
|
| 261 |
dpurdie |
9008 |
MakePrint " \$(SCM_MAKEFILE)";
|
| 227 |
dpurdie |
9009 |
MakeNewLine();
|
|
|
9010 |
next;
|
|
|
9011 |
}
|
|
|
9012 |
|
|
|
9013 |
#
|
|
|
9014 |
# Need to create object file
|
|
|
9015 |
#
|
|
|
9016 |
@args = split( /$;/, $SRC_ARGS{ StripDir( $sname ) } )
|
|
|
9017 |
if $SRC_ARGS{ $sname };
|
|
|
9018 |
|
|
|
9019 |
push( @args, "--Shared" )
|
|
|
9020 |
if ( exists $SHOBJ_LIB{$i} );
|
|
|
9021 |
|
|
|
9022 |
#
|
|
|
9023 |
# Convert relative paths to absolute paths if required by the
|
|
|
9024 |
# toolset. Some compilers need ABS paths to generate nice debug
|
|
|
9025 |
# information.
|
|
|
9026 |
#
|
|
|
9027 |
$src = AbsPath($src)
|
|
|
9028 |
if ( $UseAbsObjects );
|
|
|
9029 |
|
|
|
9030 |
#
|
|
|
9031 |
# Extract any user specified dependancies
|
| 261 |
dpurdie |
9032 |
# These will be added to the dependency list
|
| 227 |
dpurdie |
9033 |
#
|
|
|
9034 |
my @dlist;
|
|
|
9035 |
@dlist = split( /$;/, $SRC_DEPEND{$sname} )
|
|
|
9036 |
if ( exists $SRC_DEPEND{$sname} );
|
|
|
9037 |
|
| 261 |
dpurdie |
9038 |
#
|
|
|
9039 |
# Create the dependency part of the object rule
|
|
|
9040 |
# The source file MUST be the first dependent recipes
|
|
|
9041 |
# may assume that $< is the name source file
|
|
|
9042 |
#
|
|
|
9043 |
MakeEntry( "\$(OBJDIR)/$i.$::o: $src \$(SCM_MAKEFILE)", "", " \\\n\t", "", @dlist );
|
| 227 |
dpurdie |
9044 |
|
|
|
9045 |
if ( $type eq ".c" ) {
|
|
|
9046 |
$if->CC( $src, $i, \@args );
|
| 261 |
dpurdie |
9047 |
|
| 227 |
dpurdie |
9048 |
} elsif ( $type eq ".cc" ) {
|
|
|
9049 |
$if->CXX( $src, $i, \@args );
|
| 261 |
dpurdie |
9050 |
|
| 227 |
dpurdie |
9051 |
} elsif ( $type eq ".asm" ) {
|
|
|
9052 |
$if->AS( $src, $i, \@args );
|
| 261 |
dpurdie |
9053 |
|
| 227 |
dpurdie |
9054 |
} else {
|
|
|
9055 |
$if->EXT( $src, $i, \@args ) ||
|
|
|
9056 |
Warning( "Don't know how to build '$ext' images' for $src, $i" );
|
|
|
9057 |
MakeNewLine();
|
|
|
9058 |
}
|
|
|
9059 |
}
|
|
|
9060 |
|
|
|
9061 |
#-------------------------------------------------------------------------------
|
|
|
9062 |
# Construct Projects
|
|
|
9063 |
# Construct toolset specific projects
|
|
|
9064 |
#
|
|
|
9065 |
MakeHeader ("Construct Projects");
|
|
|
9066 |
while ( my($project, $entry) = each %PROJECTS)
|
|
|
9067 |
{
|
|
|
9068 |
$if->PROJECT( $entry );
|
|
|
9069 |
}
|
|
|
9070 |
|
|
|
9071 |
#-------------------------------------------------------------------------------
|
|
|
9072 |
# Automated tests
|
|
|
9073 |
#
|
|
|
9074 |
MakeHeader ("Automated tests");
|
|
|
9075 |
|
|
|
9076 |
my $idx = 0;
|
|
|
9077 |
my @test_set = ("makefile.pl");
|
|
|
9078 |
my @test_set_auto = ("makefile.pl");
|
|
|
9079 |
my @copy_set = ();
|
|
|
9080 |
|
|
|
9081 |
foreach my $pEntry ( @TESTS_TO_RUN )
|
|
|
9082 |
{ # Foreach test
|
|
|
9083 |
$idx++;
|
|
|
9084 |
$pEntry->{'index'} = $idx;
|
|
|
9085 |
$pEntry->{'test_name'} = "run_test_$idx";
|
|
|
9086 |
|
|
|
9087 |
#
|
|
|
9088 |
# If the test is being run within a 'FrameWork' then the underlying
|
|
|
9089 |
# toolset must instantiate the frame work.
|
|
|
9090 |
#
|
|
|
9091 |
# This may change. Perhaps frameworks shouldn't be a part of the
|
|
|
9092 |
# toolset. Perhaps they should be standalone. May change
|
|
|
9093 |
#
|
|
|
9094 |
if ( $pEntry->{framework} )
|
|
|
9095 |
{
|
|
|
9096 |
$if->TESTFRAMEWORK( $pEntry );
|
|
|
9097 |
}
|
|
|
9098 |
|
|
|
9099 |
#
|
|
|
9100 |
# Create a rule to run the test
|
|
|
9101 |
#
|
|
|
9102 |
|
|
|
9103 |
my $tdir_alias = $pEntry->{'testdir'};
|
|
|
9104 |
my $tdir = '$(' . $tdir_alias . ')';
|
|
|
9105 |
|
|
|
9106 |
my $test_name = $pEntry->{'test_name'};
|
|
|
9107 |
push @test_set, $test_name;
|
|
|
9108 |
push @test_set_auto, $test_name if ($pEntry->{'auto'} );
|
|
|
9109 |
|
|
|
9110 |
my $tprog = $tdir . '/' . StripDir( $pEntry->{'prog'} );
|
|
|
9111 |
|
|
|
9112 |
my $me = MakeEntry::New( *MAKEFILE, $test_name, '--Phony' );
|
|
|
9113 |
$me->AddDependancy( "\$(GBE_$tdir_alias)" );
|
|
|
9114 |
$me->AddDependancy( "\$(INTERFACEDIR)/set_$::ScmPlatform.sh" );
|
|
|
9115 |
$me->AddDependancy( $tprog ) if $pEntry->{'copyprog'};
|
|
|
9116 |
$me->AddDependancy( @{ $pEntry->{'copyin' } } );
|
|
|
9117 |
$me->AddDependancy( map { $tdir . '/' . StripDir($_) } @{ $pEntry->{'copyonce' } } );
|
|
|
9118 |
$me->AddDependancy( @{ $pEntry->{'preq'} } );
|
|
|
9119 |
$me->RecipePrefix ('$(XX_PRE)');
|
|
|
9120 |
$me->RecipeComment( "------ Running test [$idx] ..." );
|
|
|
9121 |
|
|
|
9122 |
#
|
|
|
9123 |
# Extend the PATH seen by the script to include the local/bin directory
|
|
|
9124 |
# Allows programs and tests that have been created elsewhere in the component
|
|
|
9125 |
# to be accessed within the script.
|
|
|
9126 |
#
|
|
|
9127 |
$me->AddShellRecipe ( ". \$(INTERFACEDIR)/set_$::ScmPlatform.sh" );
|
|
|
9128 |
|
|
|
9129 |
#
|
|
|
9130 |
# Copy in the files that we need
|
|
|
9131 |
#
|
|
|
9132 |
foreach my $file ( @{$pEntry->{'copyin'}} )
|
|
|
9133 |
{
|
|
|
9134 |
my $dst = $tdir . '/' . StripDir( $file );
|
|
|
9135 |
UniquePush( \@COPYIN, $dst );
|
|
|
9136 |
UniquePush( \@copy_set, $file );
|
|
|
9137 |
$me->AddShellRecipe ( "\$(cp) -f $file $dst" );
|
|
|
9138 |
$me->AddShellRecipe ( "\$(chmod) -f +wx $dst" );
|
|
|
9139 |
}
|
|
|
9140 |
|
|
|
9141 |
#
|
|
|
9142 |
# Insert and FrameWork Recipe bits
|
|
|
9143 |
#
|
|
|
9144 |
$me->AddShellRecipe ( @{$pEntry->{'ShellRecipe'}} );
|
|
|
9145 |
|
|
|
9146 |
$me->AddShellRecipe ( "cd $tdir" );
|
|
|
9147 |
$me->AddShellRecipe ( ["GBE_TYPE=\$(GBE_TYPE)",
|
|
|
9148 |
"GBE_HOST=\$(GBE_HOST)",
|
|
|
9149 |
"GBE_ROOT=\$(GBE_ROOT_ABS)",
|
|
|
9150 |
"PATH=.\\$::ScmPathSep\$(BINDIR_LOCAL_PATH)\\$::ScmPathSep\$\$PATH",
|
|
|
9151 |
$pEntry->{'command'},
|
|
|
9152 |
@{$pEntry->{'args'}},
|
|
|
9153 |
] );
|
|
|
9154 |
$me->Print();
|
|
|
9155 |
|
|
|
9156 |
|
|
|
9157 |
#
|
|
|
9158 |
# Create entries to handle the copy-once files
|
|
|
9159 |
#
|
|
|
9160 |
foreach my $file ( @{ $pEntry->{'copyonce' } } )
|
|
|
9161 |
{
|
|
|
9162 |
my $tname = $tdir . '/' . StripDir($file);
|
|
|
9163 |
my $me = MakeEntry::New( *MAKEFILE, $tname );
|
|
|
9164 |
$me->AddDependancy( $file );
|
|
|
9165 |
$me->AddRecipe ( "\$(call CopyFile,CopyIn,$tname,$file,$tdir,)" );
|
|
|
9166 |
$me->Print();
|
|
|
9167 |
|
|
|
9168 |
UniquePush( \@COPYIN, $tname );
|
|
|
9169 |
UniquePush( \@copy_set, $file );
|
|
|
9170 |
|
|
|
9171 |
}
|
|
|
9172 |
}
|
|
|
9173 |
|
|
|
9174 |
#
|
|
|
9175 |
# Generate a target that specifies the tests to be run
|
|
|
9176 |
# Each test is provided with a dummy name
|
|
|
9177 |
#
|
|
|
9178 |
push @test_set, @TESTPROJECT_TO_ARUN;
|
|
|
9179 |
push @test_set, @TESTPROJECT_TO_URUN;
|
|
|
9180 |
MakeEntry3("\nrun_tests", ":", \@test_set )
|
|
|
9181 |
if (@test_set);
|
|
|
9182 |
|
|
|
9183 |
push @test_set_auto, @TESTPROJECT_TO_ARUN;
|
|
|
9184 |
MakeEntry3("\nrun_unit_tests", ":", \@test_set_auto )
|
|
|
9185 |
if (@test_set_auto);
|
|
|
9186 |
|
|
|
9187 |
#
|
|
|
9188 |
# Generate sanity test for each copyin script
|
|
|
9189 |
# Simply to provide a nice error message for generated scripts
|
|
|
9190 |
# that do not exist at run-time
|
|
|
9191 |
#
|
|
|
9192 |
test_copy_in:
|
|
|
9193 |
foreach my $i ( @copy_set )
|
|
|
9194 |
{
|
|
|
9195 |
next if ( $SCRIPTS{$i} );
|
|
|
9196 |
foreach ( @SHLIB_TARGETS )
|
|
|
9197 |
{
|
|
|
9198 |
next test_copy_in if ( $i eq $_ );
|
|
|
9199 |
}
|
|
|
9200 |
MakePrint( "\n$i:\t\tmakefile.pl\n" .
|
|
|
9201 |
"\t\@if [ ! -f \"$i\" ]; then echo ERROR: CopyIn Script [$i] not found; exit 2; fi\n" );
|
|
|
9202 |
}
|
|
|
9203 |
|
| 261 |
dpurdie |
9204 |
#-------------------------------------------------------------------------------
|
|
|
9205 |
# Deploy rules
|
|
|
9206 |
#
|
|
|
9207 |
MakeHeader ("Deploy Rules");
|
| 227 |
dpurdie |
9208 |
|
| 261 |
dpurdie |
9209 |
print MAKEFILE <<EOF;
|
|
|
9210 |
.PHONY: run_deploy
|
|
|
9211 |
EOF
|
| 227 |
dpurdie |
9212 |
|
| 261 |
dpurdie |
9213 |
#
|
|
|
9214 |
# Build up the deployfile.pl command line from the available pieces
|
|
|
9215 |
#
|
|
|
9216 |
my $command_file = "";
|
|
|
9217 |
my @command_line;
|
|
|
9218 |
|
|
|
9219 |
if ( %DEPLOYPACKAGE )
|
|
|
9220 |
{
|
|
|
9221 |
$command_file = $DEPLOYPACKAGE{'cmdfile'};
|
|
|
9222 |
|
|
|
9223 |
push @command_line, "\$(XX_PRE)\$(GBE_PERL) -w $command_file";
|
|
|
9224 |
push @command_line, "-r \"\$(GBE_ROOT)\"";
|
|
|
9225 |
push @command_line, "-n \"$DEPLOYPACKAGE{'name'}\"";
|
|
|
9226 |
push @command_line, "-d \"$DEPLOYPACKAGE{'dir'}\"";
|
|
|
9227 |
push @command_line, "-v \"\$(BUILDVER)\"";
|
|
|
9228 |
push @command_line, "-t \"\$(GBE_TYPE)\"";
|
|
|
9229 |
push @command_line, "-o \"\$(BUILDPREVIOUSVER)\"";
|
|
|
9230 |
push @command_line, "-m \"\$(GBE_PLATFORM)\"";
|
|
|
9231 |
push @command_line, "-g \"\$(GBE_TARGET)\"";
|
|
|
9232 |
push @command_line, "-k \"\$(GBE_PRODUCT)\"" if ( $ScmProduct );
|
|
|
9233 |
push @command_line, "-p \"\$(DEPLOYPATCH)\"" if ( $ScmDeploymentPatch );
|
|
|
9234 |
|
|
|
9235 |
}
|
|
|
9236 |
|
|
|
9237 |
MakeEntry( "run_deploy:\t$command_file\n", "\n", "\t\t", " \\\n", @command_line );
|
|
|
9238 |
|
| 227 |
dpurdie |
9239 |
#-------------------------------------------------------------------------------
|
| 261 |
dpurdie |
9240 |
# Custom Rules
|
|
|
9241 |
#
|
|
|
9242 |
MakeHeader ("Custom Rules");
|
|
|
9243 |
MakePrintList ( \@RULES );
|
|
|
9244 |
|
|
|
9245 |
#-------------------------------------------------------------------------------
|
|
|
9246 |
# Generated Files
|
|
|
9247 |
#
|
|
|
9248 |
MakeHeader ("Generated Files");
|
|
|
9249 |
MakePrint ("\n.PHONY: phony_generate\n\n" );
|
|
|
9250 |
|
|
|
9251 |
foreach my $i ( @GENERATE_FILES )
|
|
|
9252 |
{
|
|
|
9253 |
my $gen_tag = $i->{'index'};
|
|
|
9254 |
|
|
|
9255 |
#
|
| 263 |
dpurdie |
9256 |
# If predelete is enabled, then create a list of files to delete
|
|
|
9257 |
#
|
|
|
9258 |
if ( $i->{'predelete'} )
|
|
|
9259 |
{
|
|
|
9260 |
MakeDefEntry( "generate_gen_$gen_tag", "=", $i->{'gen'} );
|
|
|
9261 |
MakePrint("\n")
|
|
|
9262 |
}
|
|
|
9263 |
|
|
|
9264 |
|
|
|
9265 |
#
|
| 261 |
dpurdie |
9266 |
# Generate the basic generate rule and recipe
|
|
|
9267 |
# together with the prerequisites
|
|
|
9268 |
#
|
|
|
9269 |
MakeEntry ( "", ":", "", " ", @{$i->{'gen'}} );
|
|
|
9270 |
|
|
|
9271 |
unless ( $i->{'clean'} && $i->{'shell'} )
|
|
|
9272 |
{
|
|
|
9273 |
MakeEntry ( "", "", " \\\n\t\t", "", @{$i->{'preq'}} );
|
|
|
9274 |
MakeEntry ( "", "", " \\\n\t\t", "", "phony_generate" ) if $i->{'preq_sus'};
|
|
|
9275 |
MakeEntry ( "", "", " \\\n\t\t", "", "\$(SCM_MAKEFILE)" );
|
|
|
9276 |
|
|
|
9277 |
MakePrint ("\n\t" . "\@\$(echo) [$i->{'text'}] generating.." );
|
| 263 |
dpurdie |
9278 |
if ( $i->{'predelete'} )
|
|
|
9279 |
{
|
|
|
9280 |
MakePrint ("\n\t" . "\$(XX_PRE)\$(call RmFiles,generate_gen_$gen_tag)" );
|
|
|
9281 |
}
|
| 261 |
dpurdie |
9282 |
MakePrint ("\n\t" . "\$(XX_PRE)\$(call generate_$gen_tag,)" );
|
|
|
9283 |
}
|
|
|
9284 |
|
|
|
9285 |
#
|
|
|
9286 |
# Generate 'clean' rules and recipes
|
|
|
9287 |
#
|
|
|
9288 |
if ( $i->{'clean'} )
|
|
|
9289 |
{
|
|
|
9290 |
MakePrint ("\n\nPHONY: clean_generate_$gen_tag" );
|
|
|
9291 |
MakePrint ("\nclean_generate_$gen_tag:" );
|
| 343 |
dpurdie |
9292 |
MakePrint ("\n\t" . "\$(XX_PRE)-\$(call generate_$gen_tag,$i->{'clean'})" );
|
| 261 |
dpurdie |
9293 |
}
|
|
|
9294 |
|
|
|
9295 |
#
|
|
|
9296 |
# Define a function to contain the body of the generation call
|
|
|
9297 |
# The first argument will be a 'clean' argument
|
|
|
9298 |
#
|
|
|
9299 |
MakePrint ("\n\ndefine generate_$gen_tag" );
|
|
|
9300 |
if ( $i->{'shell'} )
|
|
|
9301 |
{
|
|
|
9302 |
MakeEntry ("\n\t(" , "\\\n\t)\n", " \\\n\t", ";" , @{$i->{'toolargs'}} );
|
|
|
9303 |
}
|
|
|
9304 |
else
|
|
|
9305 |
{
|
|
|
9306 |
MakeEntry ("\n\t" . $i->{'tool'} . ' $1', "\n", " \\\n\t\t", "" , @{$i->{'toolargs'}} );
|
|
|
9307 |
}
|
|
|
9308 |
MakePrint ("endef\n\n" );
|
|
|
9309 |
}
|
|
|
9310 |
|
|
|
9311 |
#-------------------------------------------------------------------------------
|
|
|
9312 |
# Toolset Post Processing
|
|
|
9313 |
# Allow the toolset to perform any post processing, before we finally write
|
|
|
9314 |
# out any definitions.
|
|
|
9315 |
#
|
|
|
9316 |
# We will not interprete any more user directives, but new stuff may get added
|
|
|
9317 |
#
|
|
|
9318 |
#
|
|
|
9319 |
MakeHeader ("Toolset Post Processing");
|
|
|
9320 |
$if->Postprocess();
|
|
|
9321 |
|
|
|
9322 |
################################################################################
|
|
|
9323 |
# All interactions with the toolset are now complete
|
|
|
9324 |
# All lists are now complete
|
|
|
9325 |
#
|
|
|
9326 |
# Can now create internal definitions
|
|
|
9327 |
#
|
|
|
9328 |
################################################################################
|
|
|
9329 |
|
|
|
9330 |
#
|
|
|
9331 |
# Would be nice if this would work
|
|
|
9332 |
# Unfortunatelty we still need $if for the CCDEPENDS and CTAGS work
|
|
|
9333 |
# These must be defined AFTER the definitions
|
|
|
9334 |
#
|
|
|
9335 |
# Ideally we should construct our makefile in sections
|
|
|
9336 |
# and then we can order the sections when we write them out
|
|
|
9337 |
#
|
|
|
9338 |
#$if = 0; # Ensure the MakeIf class is not called
|
|
|
9339 |
# If this file is modified
|
|
|
9340 |
|
|
|
9341 |
#-------------------------------------------------------------------------------
|
| 227 |
dpurdie |
9342 |
# Sources
|
|
|
9343 |
#
|
|
|
9344 |
MakeHeader ( "Sources");
|
|
|
9345 |
MakeDefEntry( "CSRCS", "=", \@CSRCS );
|
|
|
9346 |
MakeDefEntry( "CXXSRCS", "=", \@CXXSRCS );
|
|
|
9347 |
MakeDefEntry( "ASSRCS", "=", \@ASSRCS );
|
|
|
9348 |
|
|
|
9349 |
#-------------------------------------------------------------------------------
|
|
|
9350 |
# Generated, Installed and Packaged components
|
|
|
9351 |
#
|
|
|
9352 |
MakeHeader ("Generated, Installed and Packaged components");
|
|
|
9353 |
MakeDefEntry( "INITS", "=", \@INITS ) if ( @INITS );
|
|
|
9354 |
MakeDefEntry( "GENERATED", "=", \@GENERATED ) if ( @GENERATED );
|
|
|
9355 |
MakeDefEntry( "GENERATED_NOTSRC","=", \@GENERATED_NOTSRC ) if ( @GENERATED_NOTSRC );
|
|
|
9356 |
MakeDefEntry( "GENERATEDCLEAN", "=", CreateNameList( 'clean_generate_', '', ListCleanGenerated() ));
|
|
|
9357 |
MakeDefEntry( "INSTALL_HDRS", "=", \%INSTALL_HDRS ) if ( %INSTALL_HDRS );
|
|
|
9358 |
MakeDefEntry( "INSTALL_CLSS", "=", \%INSTALL_CLSS ) if ( %INSTALL_CLSS );
|
|
|
9359 |
MakeDefEntry( "OBJS", "=", CreateNameList( '$(OBJDIR)/', ".$::o", \@OBJS) );
|
|
|
9360 |
MakeDefEntry( "SHOBJS", "=", CreateNameList( '$(OBJDIR)/', ".$::o", \%SHOBJ_LIB ));
|
| 289 |
dpurdie |
9361 |
MakeDefEntry( "PROGOBJS", "=", CreateNameList( '', ".$::o", \@PROGOBJS ));
|
|
|
9362 |
MakeDefEntry( "TESTPROGOBJS", "=", CreateNameList( '', ".$::o", \@TESTPROGOBJS ));
|
|
|
9363 |
MakeDefEntry( "LIBS", "=", $LIBS->AllTargets() ) if ($::a);
|
|
|
9364 |
MakeDefEntry( "MLIBS", "=", $MLIBS->AllTargets() ) if ($::a);
|
| 227 |
dpurdie |
9365 |
MakeDefEntry( "SHNAMES", "=", \@SHLIBS );
|
|
|
9366 |
MakeDefEntry( "SHDIRS", "=", CreateNameList( '$(OBJDIR)/', "", \@SHLIBS ));
|
|
|
9367 |
MakeDefEntry( "SHLIBS", "=", \@SHLIB_TARGETS );
|
|
|
9368 |
MakeDefEntry( "SCRIPTS", "=", CreateNameList( '$(BINDIR)/', "", \%SCRIPTS ));
|
|
|
9369 |
MakeDefEntry( "COPYIN", "=", \@COPYIN );
|
| 289 |
dpurdie |
9370 |
MakeDefEntry( "PROGS", "=", $PROGS->AllTargets() );
|
| 227 |
dpurdie |
9371 |
MakeDefEntry( "PROGS_EXTRA", "=", \@PROGS_EXTRA );
|
| 289 |
dpurdie |
9372 |
MakeDefEntry( "TESTPROGS", "=", $TESTPROGS->AllTargets());
|
| 227 |
dpurdie |
9373 |
MakeDefEntry( "LINTLIBS", "=", CreateNameList( 'lib_', '_lint', \@LINTLIBS ));
|
|
|
9374 |
MakeDefEntry( "LINTSHLIBS", "=", CreateNameList( 'shlib_', '_lint', \@LINTSHLIBS ));
|
|
|
9375 |
MakeDefEntry( "LINTPROGS", "=", CreateNameList( 'prog_', '_lint', \@PROGS ));
|
| 289 |
dpurdie |
9376 |
MakeDefEntry( "LINTPROGS", "+=", CreateNameList( 'prog_', '_lint', \@TESTPROGS ));
|
| 227 |
dpurdie |
9377 |
MakeDefEntry( "PROJECTS", "=", CreateNameList( 'Project_', '', ListGeneratedProjects(1) ));
|
|
|
9378 |
MakeDefEntry( "PROJECTSGEN", "=", CreateNameList( 'Project_', '', ListGeneratedProjects(0) ));
|
|
|
9379 |
MakeDefEntry( "PROJECTSCLEAN", "=", CreateNameList( 'ProjectClean_', '', \%PROJECTS ));
|
|
|
9380 |
|
| 261 |
dpurdie |
9381 |
MakeHeader ("Toolset components");
|
|
|
9382 |
MakeDefEntry( "USERGENERATED", "=", \@USERGENERATED ) if ( @USERGENERATED );
|
|
|
9383 |
MakeDefEntry( "TOOLSETGENERATED", "=", \@TOOLSETGENERATED ) if ( @TOOLSETGENERATED );
|
|
|
9384 |
MakeDefEntry( "TOOLSETOBJS", "=", \@TOOLSETOBJS ) if ( @TOOLSETOBJS );
|
|
|
9385 |
MakeDefEntry( "TOOLSETLIBS", "=", \@TOOLSETLIBS ) if ( @TOOLSETLIBS );
|
|
|
9386 |
MakeDefEntry( "TOOLSETPROGS", "=", \@TOOLSETPROGS ) if ( @TOOLSETPROGS );
|
|
|
9387 |
MakeDefEntry( "TOOLSETDIRS", "=", \@TOOLSETDIRS ) if ( @TOOLSETDIRS );
|
|
|
9388 |
MakeDefEntry( "TOOLSETDIRTREES", "=", \@TOOLSETDIRTREES ) if ( @TOOLSETDIRTREES );
|
| 227 |
dpurdie |
9389 |
|
|
|
9390 |
#--------- Determine compiler flag groups to use ----------------------------
|
|
|
9391 |
#
|
|
|
9392 |
# Allows the compiler options to be controlled for both the debug and
|
|
|
9393 |
# the production builds. Allows control over
|
|
|
9394 |
# 1) Optimisations
|
|
|
9395 |
# 2) Debug Information
|
|
|
9396 |
#
|
|
|
9397 |
MakeHeader ("Determine compiler flag groups to use");
|
|
|
9398 |
|
|
|
9399 |
print MAKEFILE <<EOF;
|
|
|
9400 |
|
|
|
9401 |
ifneq "\$(DEBUG)" "1"
|
|
|
9402 |
USE_OPTIMISE := \$(PROD_USE_OPTIMISE)
|
|
|
9403 |
USE_DEBUGINFO := \$(PROD_USE_DEBUGINFO)
|
|
|
9404 |
else
|
|
|
9405 |
USE_OPTIMISE := \$(DEBUG_USE_OPTIMISE)
|
|
|
9406 |
USE_DEBUGINFO := \$(DEBUG_USE_DEBUGINFO)
|
|
|
9407 |
endif
|
|
|
9408 |
|
|
|
9409 |
EOF
|
|
|
9410 |
|
| 261 |
dpurdie |
9411 |
#-------------------------------------------------------------------------------
|
|
|
9412 |
# Source browsing tools
|
|
|
9413 |
#
|
|
|
9414 |
MakeHeader ("Source browsing tools");
|
|
|
9415 |
print MAKEFILE <<EOF;
|
|
|
9416 |
.PHONY: ctags
|
|
|
9417 |
ctags:
|
|
|
9418 |
EOF
|
|
|
9419 |
$if->CTAGS()
|
|
|
9420 |
if (@CSRCS || @CXXSRCS);
|
| 227 |
dpurdie |
9421 |
|
| 261 |
dpurdie |
9422 |
#-------------------------------------------------------------------------------
|
|
|
9423 |
# Depend
|
|
|
9424 |
# If we are build C or C++ source files then create rules and recipes
|
|
|
9425 |
# to invoke a dependency generator.
|
| 227 |
dpurdie |
9426 |
#
|
| 261 |
dpurdie |
9427 |
# NODEPEND is used to disable, at make-time, the dependency generation
|
|
|
9428 |
# and inclusion process.
|
|
|
9429 |
#
|
|
|
9430 |
#
|
|
|
9431 |
MakeHeader ("Depend");
|
|
|
9432 |
if ($::o && (@CSRCS || @CXXSRCS))
|
|
|
9433 |
{
|
|
|
9434 |
$ScmDependTags = 1;
|
|
|
9435 |
print MAKEFILE <<EOF;
|
|
|
9436 |
depend: \$(OBJDIR)/depend
|
|
|
9437 |
|
|
|
9438 |
\$(OBJDIR)/depend: \$(SCM_MAKEFILE) \$(GBE_OBJDIR)
|
|
|
9439 |
\$(OBJDIR)/depend: \$(CSRCS) \$(CXXSRCS)
|
|
|
9440 |
ifeq (\$(NODEPEND),0)
|
|
|
9441 |
\@echo [\$@] Doing a make depend..
|
|
|
9442 |
-\$(XX_PRE)\$(rm) -f \$(OBJDIR)/depend
|
|
|
9443 |
EOF
|
|
|
9444 |
$if->CCDepend( "\$(OBJDIR)/depend", "\$(CSRCS)" )
|
|
|
9445 |
if ( @CSRCS );
|
|
|
9446 |
$if->CXXDepend( "\$(OBJDIR)/depend", "\$(CXXSRCS)" )
|
|
|
9447 |
if ( @CXXSRCS );
|
|
|
9448 |
MakePrint
|
|
|
9449 |
"\t-\@\$(touch) -f \$(OBJDIR)/depend\n";
|
|
|
9450 |
print MAKEFILE <<EOF;
|
|
|
9451 |
else
|
|
|
9452 |
\@echo [\$@] Skipping make depend..
|
|
|
9453 |
-\$(XX_PRE)\$(rm) -f \$(OBJDIR)/depend
|
|
|
9454 |
endif
|
|
|
9455 |
EOF
|
|
|
9456 |
}
|
|
|
9457 |
else
|
|
|
9458 |
{
|
|
|
9459 |
print MAKEFILE <<EOF;
|
|
|
9460 |
depend:
|
|
|
9461 |
EOF
|
|
|
9462 |
}
|
|
|
9463 |
|
|
|
9464 |
#
|
|
|
9465 |
# Rule to unmake the depend file
|
|
|
9466 |
#
|
|
|
9467 |
print MAKEFILE <<EOF;
|
|
|
9468 |
|
|
|
9469 |
undepend:
|
|
|
9470 |
-\$(XX_PRE)\$(rm) -f \$(OBJDIR)/depend
|
|
|
9471 |
EOF
|
|
|
9472 |
|
|
|
9473 |
#--------- IFLAG Documentation -------------------------------------------------
|
|
|
9474 |
#
|
|
|
9475 |
# IFLAG - iteration flag. This is setting by the calling process
|
|
|
9476 |
# and is a function of the phase being processed
|
| 227 |
dpurdie |
9477 |
# 0 No external dependencies.
|
|
|
9478 |
# 1 Source dependency list.
|
| 261 |
dpurdie |
9479 |
# 2 Shared library dependency list
|
|
|
9480 |
# 3 Application dependency list
|
| 227 |
dpurdie |
9481 |
#
|
|
|
9482 |
#
|
| 261 |
dpurdie |
9483 |
#--------- Dependencies --------------------------------------------------------
|
|
|
9484 |
# Include the 'depend' file if required
|
|
|
9485 |
#
|
|
|
9486 |
MakeHeader ("Dependency Inclusion");
|
|
|
9487 |
print MAKEFILE <<EOF;
|
|
|
9488 |
ifeq (\$(NODEPEND),0)
|
|
|
9489 |
ifdef IFLAG
|
|
|
9490 |
ifneq "\$(IFLAG)" "0"
|
|
|
9491 |
-include \$(OBJDIR)/depend
|
|
|
9492 |
endif
|
| 227 |
dpurdie |
9493 |
endif
|
|
|
9494 |
endif
|
|
|
9495 |
|
|
|
9496 |
EOF
|
|
|
9497 |
|
|
|
9498 |
#-------------------------------------------------------------------------------
|
|
|
9499 |
# Standard rules
|
|
|
9500 |
#
|
|
|
9501 |
MakeHeader ("Standard rules");
|
|
|
9502 |
|
| 373 |
dpurdie |
9503 |
print MAKEFILE <<EOF;
|
| 227 |
dpurdie |
9504 |
|
| 373 |
dpurdie |
9505 |
.PHONY: make_clean
|
| 227 |
dpurdie |
9506 |
make_clean:
|
|
|
9507 |
-\@echo "Removing generated files (objects, libraries, binaries etc)";
|
|
|
9508 |
|
|
|
9509 |
#
|
|
|
9510 |
# Under windows/cygwin, there is a problem with the rm being used
|
|
|
9511 |
# The expansion of wildcards will terminate the command if:
|
|
|
9512 |
# 1) No files exist to expand : Solution : touch a file of that type
|
|
|
9513 |
# 2) A directory is involved : Solution : cd to directory
|
|
|
9514 |
#
|
|
|
9515 |
# Cannot use make's wildcard function as this only operates in the current directory
|
|
|
9516 |
#
|
|
|
9517 |
.PHONY: rmlitter
|
|
|
9518 |
rmlitter:
|
| 315 |
dpurdie |
9519 |
-\$(AA_PRE)( echo "Removing litter";\\
|
| 227 |
dpurdie |
9520 |
\$(touch) _delete.bak _delete.tmp _delete.err ;\\
|
|
|
9521 |
\$(rm) -f core *.bak *.tmp *.err ;\\
|
| 293 |
dpurdie |
9522 |
for subdir in \$(SHDIRS) '' ; do \\
|
|
|
9523 |
if [ -d "\$\$subdir" ] ; then \\
|
| 227 |
dpurdie |
9524 |
( cd \$\$subdir ;\\
|
|
|
9525 |
\$(touch) _delete.err _delete.cmd ;\\
|
| 289 |
dpurdie |
9526 |
\$(rm) -r * ; );\\
|
|
|
9527 |
fi ;\\
|
|
|
9528 |
done;\\
|
| 293 |
dpurdie |
9529 |
for subdir in \$(OBJDIR) '' ; do \\
|
|
|
9530 |
if [ -d "\$\$subdir" ] ; then \\
|
| 289 |
dpurdie |
9531 |
( cd \$\$subdir ;\\
|
|
|
9532 |
\$(touch) _delete.err _delete.cmd ;\\
|
| 227 |
dpurdie |
9533 |
\$(rm) -r *.err *.cmd ; );\\
|
|
|
9534 |
fi ;\\
|
|
|
9535 |
done;\\
|
|
|
9536 |
)
|
|
|
9537 |
|
| 261 |
dpurdie |
9538 |
.PHONY: lint_init
|
|
|
9539 |
lint_init:
|
|
|
9540 |
|
| 227 |
dpurdie |
9541 |
EOF
|
|
|
9542 |
|
| 261 |
dpurdie |
9543 |
#
|
|
|
9544 |
# Dependencies for 'make_init'
|
|
|
9545 |
#
|
|
|
9546 |
#
|
|
|
9547 |
my @initdep;
|
|
|
9548 |
push @initdep, '$(INITS)' if ( @INITS );
|
| 227 |
dpurdie |
9549 |
|
| 261 |
dpurdie |
9550 |
#
|
|
|
9551 |
# Dependencies for 'make_dir'
|
|
|
9552 |
#
|
|
|
9553 |
my @mkdirdep;
|
| 289 |
dpurdie |
9554 |
push @mkdirdep, '$(GBE_OBJDIR)' if ( @CSRCS || @CXXSRCS || @OBJS || @PROGOBJS || @TESTPROGOBJS );
|
| 261 |
dpurdie |
9555 |
push @mkdirdep, '$(SHDIRS)' if ( %SHOBJ_LIB || @SHLIBS);
|
|
|
9556 |
push @mkdirdep, '$(GBE_LIBDIR)' if ( @LIBS || @MLIBS || @SHLIBS || %INSTALL_LIBS || %PACKAGE_LIBS );
|
| 289 |
dpurdie |
9557 |
push @mkdirdep, '$(GBE_BINDIR)' if ( @SHLIBS || %SCRIPTS || @PROGS || @TESTPROGS || %INSTALL_PROGS || %PACKAGE_PROGS );
|
| 227 |
dpurdie |
9558 |
|
| 261 |
dpurdie |
9559 |
#
|
|
|
9560 |
# Actions for for 'unobj'
|
|
|
9561 |
#
|
|
|
9562 |
my @unobjact;
|
|
|
9563 |
push @unobjact, RmFilesCmd( 'OBJS' ) if ( @OBJS );
|
|
|
9564 |
push @unobjact, RmFilesCmd( 'SHOBJS' ) if ( %SHOBJ_LIB );
|
|
|
9565 |
push @unobjact, RmFilesCmd( 'PROGOBJS' ) if ( @PROGOBJS );
|
| 289 |
dpurdie |
9566 |
push @unobjact, RmFilesCmd( 'TESTPROGOBJS' ) if ( @TESTPROGOBJS );
|
| 261 |
dpurdie |
9567 |
push @unobjact, RmFilesCmd( 'TOOLSETOBJS' ) if ( @TOOLSETOBJS );
|
| 227 |
dpurdie |
9568 |
|
| 261 |
dpurdie |
9569 |
#
|
|
|
9570 |
# Dependencies for 'make_lib'
|
|
|
9571 |
#
|
|
|
9572 |
my @libdep;
|
|
|
9573 |
push @libdep, '$(GBE_OBJDIR)', '$(GBE_LIBDIR)', '$(LIBS)' if ( @LIBS );
|
| 227 |
dpurdie |
9574 |
|
| 261 |
dpurdie |
9575 |
#
|
|
|
9576 |
# Dependencies for 'lint_lib'
|
|
|
9577 |
#
|
|
|
9578 |
my @liblintdep;
|
|
|
9579 |
push @liblintdep, 'lint_init', '$(GBE_OBJDIR)', '$(GBE_LIBDIR)', '$(LINTLIBS)' if ( @LIBS );
|
| 227 |
dpurdie |
9580 |
|
| 261 |
dpurdie |
9581 |
#
|
|
|
9582 |
# Dependencies for 'make_mlib'
|
|
|
9583 |
#
|
|
|
9584 |
my @mlibdep;
|
|
|
9585 |
push @mlibdep, '$(GBE_OBJDIR)', '$(GBE_LIBDIR)', '$(GBE_MLIBDIR)', '$(MLIBS)' if ( @MLIBS );
|
| 227 |
dpurdie |
9586 |
|
| 261 |
dpurdie |
9587 |
#
|
|
|
9588 |
# Dependencies for 'make_install_shlib' (tag)
|
|
|
9589 |
#
|
|
|
9590 |
my @shlibdep;
|
|
|
9591 |
push @shlibdep, '$(SHDIRS)', '$(SHLIBS)' if ( @SHLIBS );
|
| 227 |
dpurdie |
9592 |
|
| 261 |
dpurdie |
9593 |
#
|
|
|
9594 |
# Dependencies for 'lint_shlib'
|
|
|
9595 |
#
|
|
|
9596 |
my @shliblintdep;
|
|
|
9597 |
push @shliblintdep, 'lint_init', '$(GBE_LIBDIR)', '$(LINTSHLIBS)' if ( @SHLIBS );
|
| 227 |
dpurdie |
9598 |
|
| 261 |
dpurdie |
9599 |
#
|
|
|
9600 |
# Actions for 'unmake_lib'
|
|
|
9601 |
#
|
|
|
9602 |
my @unlibact;
|
|
|
9603 |
push @unlibact, RmFilesCmd( 'SHLIBS' ) if ( @SHLIBS );
|
|
|
9604 |
push @unlibact, RmFilesCmd( 'MLIBS' ) if ( @MLIBS );
|
|
|
9605 |
push @unlibact, RmFilesCmd( 'LIBS' ) if ( @LIBS );
|
|
|
9606 |
push @unlibact, RmFilesCmd( 'TOOLSETLIBS' ) if ( @TOOLSETLIBS );
|
| 227 |
dpurdie |
9607 |
|
| 261 |
dpurdie |
9608 |
#
|
|
|
9609 |
# Actions for 'unmake_mlib'
|
|
|
9610 |
#
|
|
|
9611 |
my @unmlibact;
|
|
|
9612 |
push @unmlibact, RmFilesCmd( 'MLIBS' ) if ( @MLIBS );
|
| 227 |
dpurdie |
9613 |
|
| 261 |
dpurdie |
9614 |
#
|
|
|
9615 |
# Dependencies for 'make_script'
|
|
|
9616 |
#
|
|
|
9617 |
my @scriptdep;
|
|
|
9618 |
push @scriptdep, '$(GBE_BINDIR)', '$(SCRIPTS)' if ( %SCRIPTS );
|
| 227 |
dpurdie |
9619 |
|
| 261 |
dpurdie |
9620 |
#
|
|
|
9621 |
# Actions for 'unmake_script'
|
|
|
9622 |
#
|
|
|
9623 |
my @unscriptact;
|
|
|
9624 |
push @unscriptact , RmFilesCmd( 'SCRIPTS' ) if ( %SCRIPTS );
|
|
|
9625 |
push @unscriptact , RmFilesCmd( 'COPYIN' ) if ( @COPYIN );
|
| 227 |
dpurdie |
9626 |
|
| 261 |
dpurdie |
9627 |
#
|
|
|
9628 |
# Dependencies for 'make_prog'
|
|
|
9629 |
#
|
|
|
9630 |
my @progdep;
|
|
|
9631 |
push @progdep, '$(GBE_OBJDIR)', '$(GBE_BINDIR)', '$(PROGS)' if ( @PROGS );
|
|
|
9632 |
push @progdep, '$(PROGS_EXTRA)' if (@PROGS_EXTRA);
|
| 227 |
dpurdie |
9633 |
|
| 261 |
dpurdie |
9634 |
#
|
|
|
9635 |
# Dependencies for 'make_prog' created for 'projects'
|
|
|
9636 |
#
|
|
|
9637 |
my @projectdep;
|
|
|
9638 |
push @projectdep, '$(PROJECTS)' if (ListGeneratedProjects(1) );
|
| 227 |
dpurdie |
9639 |
|
| 261 |
dpurdie |
9640 |
#
|
|
|
9641 |
# Dependencies for 'generate' created for 'projects'
|
|
|
9642 |
#
|
|
|
9643 |
my @projectgendep;
|
|
|
9644 |
push @projectgendep, '$(PROJECTSGEN)' if (ListGeneratedProjects(0) );
|
| 227 |
dpurdie |
9645 |
|
| 261 |
dpurdie |
9646 |
#
|
|
|
9647 |
# Dependencies for 'unmake_prog' created for 'projects'
|
|
|
9648 |
#
|
|
|
9649 |
my @projectcleandep;
|
|
|
9650 |
push @projectcleandep, '$(PROJECTSCLEAN)' if (%PROJECTS);
|
| 227 |
dpurdie |
9651 |
|
| 261 |
dpurdie |
9652 |
#
|
|
|
9653 |
# Dependencies for 'lint_prog'
|
|
|
9654 |
#
|
|
|
9655 |
my @proglintdep;
|
| 289 |
dpurdie |
9656 |
push @proglintdep, 'lint_init', '$(GBE_OBJDIR)', '$(GBE_BINDIR)', '$(LINTPROGS)' if ( @PROGS || @TESTPROGS );
|
| 227 |
dpurdie |
9657 |
|
| 261 |
dpurdie |
9658 |
#
|
|
|
9659 |
# Actions for 'unmake_prog'
|
|
|
9660 |
#
|
|
|
9661 |
my @unprogact;
|
|
|
9662 |
push @unprogact, RmFilesCmd( 'PROGS' ) if ( @PROGS );
|
|
|
9663 |
push @unprogact, RmFilesCmd( 'TOOLSETPROGS' ) if ( @TOOLSETPROGS );
|
| 227 |
dpurdie |
9664 |
|
| 261 |
dpurdie |
9665 |
#
|
|
|
9666 |
# Dependencies for 'lint_prog'
|
|
|
9667 |
#
|
|
|
9668 |
my @testprogdep;
|
| 289 |
dpurdie |
9669 |
push @testprogdep, '$(GBE_OBJDIR)', '$(GBE_BINDIR)', '$(TESTPROGS)' if ( @TESTPROGS );
|
| 227 |
dpurdie |
9670 |
|
|
|
9671 |
#
|
| 261 |
dpurdie |
9672 |
# Dependencies for 'run_tests' and friends
|
|
|
9673 |
#
|
|
|
9674 |
my @untestprogact;
|
| 289 |
dpurdie |
9675 |
push @untestprogact ,RmFilesCmd( 'TESTPROGS' ) if ( @TESTPROGS );
|
| 227 |
dpurdie |
9676 |
|
| 261 |
dpurdie |
9677 |
#
|
|
|
9678 |
# Dependencies for 'generated'
|
|
|
9679 |
#
|
|
|
9680 |
my @generatedep;
|
|
|
9681 |
push @generatedep, '$(GENERATED)' if ( @GENERATED );
|
|
|
9682 |
|
|
|
9683 |
#
|
|
|
9684 |
# Actions for 'ungenerate'
|
|
|
9685 |
#
|
|
|
9686 |
my @ungenact;
|
|
|
9687 |
push @ungenact, RmFilesCmd( 'GENERATED' ) if ( @GENERATED );
|
|
|
9688 |
push @ungenact, RmFilesCmd( 'GENERATED_NOTSRC' ) if ( @GENERATED_NOTSRC );
|
|
|
9689 |
push @ungenact, RmFilesCmd( 'TOOLSETGENERATED' ) if ( @TOOLSETGENERATED );
|
|
|
9690 |
push @ungenact, RmFilesCmd( 'USERGENERATED' ) if ( @USERGENERATED );
|
|
|
9691 |
|
|
|
9692 |
#
|
|
|
9693 |
# Dependencies for 'ungenerate'
|
|
|
9694 |
#
|
|
|
9695 |
my @ungeneratedep;
|
|
|
9696 |
push @ungeneratedep, '$(GENERATEDCLEAN)';
|
|
|
9697 |
|
| 227 |
dpurdie |
9698 |
#-------------------------------------------------------------------------------
|
| 261 |
dpurdie |
9699 |
# Function : PrintPhonyRule
|
| 227 |
dpurdie |
9700 |
#
|
| 261 |
dpurdie |
9701 |
# Description : Helper function to print some internal phony makefile targets
|
|
|
9702 |
# These are used to hold the basic makefile together
|
|
|
9703 |
#
|
|
|
9704 |
# Inputs : $target - Name of the phony target
|
|
|
9705 |
# $prereq - Prerequisites
|
|
|
9706 |
# Leading spaces removed
|
|
|
9707 |
# $recipe - Optional Reference to an array of recipes
|
|
|
9708 |
# Will be printed one per line
|
|
|
9709 |
#
|
|
|
9710 |
#
|
|
|
9711 |
sub PrintPhonyRule
|
| 227 |
dpurdie |
9712 |
{
|
| 261 |
dpurdie |
9713 |
my ($target, $prereq, $recipe) = @_;
|
|
|
9714 |
$prereq =~ s/^\s+//;
|
| 227 |
dpurdie |
9715 |
|
| 261 |
dpurdie |
9716 |
MakePadded( 2, '.PHONY:', $target, "\n");
|
|
|
9717 |
MakePadded( 2,"$target:", $prereq, "\n");
|
|
|
9718 |
MakePrint ("\t\t" . $_ . "\n") foreach ( @{$recipe} );
|
|
|
9719 |
MakePrint ("\n");
|
| 227 |
dpurdie |
9720 |
}
|
|
|
9721 |
|
| 261 |
dpurdie |
9722 |
# make_init - Test toolset presence and sanity
|
|
|
9723 |
# Will only be called ONCE for each platform in a recursive build
|
|
|
9724 |
# Should be used to ensure that the required toolset is present
|
|
|
9725 |
#
|
|
|
9726 |
PrintPhonyRule ('make_init', "@initdep" );
|
| 227 |
dpurdie |
9727 |
|
| 261 |
dpurdie |
9728 |
# make_dir - Create required subdirectories
|
|
|
9729 |
# Will be invoked as a part of most targets that create files
|
|
|
9730 |
# Will be invoked by the calling wrappers
|
|
|
9731 |
# Should not be invoked when cleaning
|
|
|
9732 |
#
|
|
|
9733 |
PrintPhonyRule ('make_dir', "@mkdirdep" );
|
|
|
9734 |
|
|
|
9735 |
|
|
|
9736 |
PrintPhonyRule ('generate', "@generatedep @projectgendep" );
|
|
|
9737 |
PrintPhonyRule ('ungenerate', "@ungeneratedep", \@ungenact);
|
|
|
9738 |
PrintPhonyRule ('unobj', "", \@unobjact);
|
|
|
9739 |
PrintPhonyRule ('make_lib', "@libdep" );
|
|
|
9740 |
PrintPhonyRule ('lint_lib', "@liblintdep" );
|
|
|
9741 |
PrintPhonyRule ('make_mlib', "@mlibdep" );
|
|
|
9742 |
PrintPhonyRule ('lint_shlib', "@shliblintdep" );
|
|
|
9743 |
PrintPhonyRule ('unmake_lib', "", \@unlibact );
|
|
|
9744 |
PrintPhonyRule ('unmake_mlib', "", \@unmlibact );
|
|
|
9745 |
PrintPhonyRule ('make_script', "@scriptdep" );
|
|
|
9746 |
PrintPhonyRule ('unmake_script', "", \@unscriptact );
|
|
|
9747 |
PrintPhonyRule ('make_prog', "@scriptdep @progdep @projectdep" );
|
|
|
9748 |
PrintPhonyRule ('lint_prog', "@proglintdep" );
|
|
|
9749 |
PrintPhonyRule ('run_tests', "@scriptdep @testprogdep" );
|
|
|
9750 |
PrintPhonyRule ('run_unit_tests', "@scriptdep @testprogdep" );
|
|
|
9751 |
PrintPhonyRule ('unmake_prog', "unmake_script @projectcleandep", \@unprogact );
|
|
|
9752 |
PrintPhonyRule ('make_test', "@scriptdep @testprogdep" );
|
|
|
9753 |
PrintPhonyRule ('unmake_test', "unmake_script", \@untestprogact );
|
|
|
9754 |
|
| 227 |
dpurdie |
9755 |
#-------------------------------------------------------------------------------
|
|
|
9756 |
# Package and Installation Summary
|
|
|
9757 |
#
|
|
|
9758 |
MakeHeader ("Package and Installation Summary");
|
|
|
9759 |
sub InstallTarget
|
|
|
9760 |
{
|
|
|
9761 |
my( $target, $hashp, $prereq, $fprereq ) = @_;
|
|
|
9762 |
my( $element );
|
|
|
9763 |
|
| 343 |
dpurdie |
9764 |
MakePrint ".PHONY:\t\t"."$target\n";
|
| 227 |
dpurdie |
9765 |
MakePrint "$target:";
|
|
|
9766 |
MakePrint "\t$fprereq" if ($fprereq);
|
|
|
9767 |
|
|
|
9768 |
foreach my $element ( sort keys %{$hashp} )
|
|
|
9769 |
{
|
|
|
9770 |
#
|
|
|
9771 |
# Skip placekeepers
|
|
|
9772 |
#
|
|
|
9773 |
next if ( $hashp->{$element}{'placekeeper'} );
|
|
|
9774 |
|
|
|
9775 |
#
|
|
|
9776 |
# Prepend any prerequisites (once)
|
|
|
9777 |
#
|
|
|
9778 |
if ( $prereq )
|
|
|
9779 |
{
|
|
|
9780 |
MakePrint " \\\n\t${prereq}";
|
|
|
9781 |
$prereq = 0;
|
|
|
9782 |
}
|
|
|
9783 |
|
|
|
9784 |
MakePrint " \\\n\t${element}";
|
|
|
9785 |
}
|
|
|
9786 |
MakePrint "\n\n";
|
|
|
9787 |
}
|
|
|
9788 |
|
|
|
9789 |
InstallTarget( "install_hdr", \%INSTALL_HDRS );
|
|
|
9790 |
InstallTarget( "install_lib", \%INSTALL_LIBS, 'make_mlib' );
|
| 261 |
dpurdie |
9791 |
InstallTarget( "make_install_shlib",\%INSTALL_SHLIBS, '', "@shlibdep" );
|
| 227 |
dpurdie |
9792 |
InstallTarget( "install_prog", \%INSTALL_PROGS, 'make_script' );
|
|
|
9793 |
InstallTarget( "install_class", \%INSTALL_CLSS );
|
|
|
9794 |
|
|
|
9795 |
InstallTarget( "package_files", \%PACKAGE_FILES );
|
|
|
9796 |
InstallTarget( "package_hdr", \%PACKAGE_HDRS );
|
|
|
9797 |
InstallTarget( "package_lib", \%PACKAGE_LIBS );
|
|
|
9798 |
InstallTarget( "package_shlib", \%PACKAGE_SHLIBS );
|
|
|
9799 |
InstallTarget( "package_prog", \%PACKAGE_PROGS, 'make_script' );
|
|
|
9800 |
InstallTarget( "package_class", \%PACKAGE_CLSS );
|
|
|
9801 |
|
|
|
9802 |
#-------------------------------------------------------------------------------
|
|
|
9803 |
# Installations
|
|
|
9804 |
|
|
|
9805 |
MakeHeader ("Installations");
|
|
|
9806 |
PackageRule ( \&InstallCmd, \%INSTALL_HDRS );
|
|
|
9807 |
PackageRule ( \&InstallCmd, \%INSTALL_CLSS );
|
|
|
9808 |
PackageRule ( \&InstallCmd, \%INSTALL_LIBS );
|
|
|
9809 |
PackageRule ( \&InstallCmd, \%INSTALL_SHLIBS );
|
|
|
9810 |
PackageRule ( \&InstallCmd, \%INSTALL_PROGS );
|
|
|
9811 |
|
|
|
9812 |
|
|
|
9813 |
#-------------------------------------------------------------------------------
|
|
|
9814 |
# Packaging
|
|
|
9815 |
#
|
|
|
9816 |
MakeHeader ("Packaging");
|
|
|
9817 |
PackageRule ( \&PackageCmd, \%PACKAGE_FILES );
|
|
|
9818 |
PackageRule ( \&PackageCmd, \%PACKAGE_HDRS );
|
|
|
9819 |
PackageRule ( \&PackageCmd, \%PACKAGE_CLSS );
|
|
|
9820 |
PackageRule ( \&PackageCmd, \%PACKAGE_LIBS );
|
|
|
9821 |
PackageRule ( \&PackageCmd, \%PACKAGE_SHLIBS );
|
|
|
9822 |
PackageRule ( \&PackageCmd, \%PACKAGE_PROGS );
|
|
|
9823 |
|
|
|
9824 |
#-------------------------------------------------------------------------------
|
|
|
9825 |
# Uninstall/unpackaging
|
|
|
9826 |
#
|
|
|
9827 |
MakeHeader ("Uninstall/unpackaging");
|
|
|
9828 |
|
|
|
9829 |
UnpackageRule( "uninstall_hdr", \&UninstallCmd, \%INSTALL_HDRS );
|
|
|
9830 |
UnpackageRule( "uninstall_lib", \&UninstallCmd, \%INSTALL_LIBS );
|
|
|
9831 |
UnpackageRule( "uninstall_shlib", \&UninstallCmd, \%INSTALL_SHLIBS );
|
|
|
9832 |
UnpackageRule( "uninstall_prog", \&UninstallCmd, \%INSTALL_PROGS );
|
|
|
9833 |
UnpackageRule( "uninstall_class", \&UninstallCmd, \%INSTALL_CLSS );
|
|
|
9834 |
|
|
|
9835 |
UnpackageRule( "unpackage_files", \&UnpackageCmd, \%PACKAGE_FILES );
|
|
|
9836 |
UnpackageRule( "unpackage_hdr", \&UnpackageCmd, \%PACKAGE_HDRS );
|
|
|
9837 |
UnpackageRule( "unpackage_lib", \&UnpackageCmd, \%PACKAGE_LIBS );
|
|
|
9838 |
UnpackageRule( "unpackage_shlib", \&UnpackageCmd, \%PACKAGE_SHLIBS );
|
|
|
9839 |
UnpackageRule( "unpackage_prog", \&UnpackageCmd, \%PACKAGE_PROGS );
|
|
|
9840 |
UnpackageRule( "unpackage_class", \&UnpackageCmd, \%PACKAGE_CLSS );
|
|
|
9841 |
|
| 261 |
dpurdie |
9842 |
#-------------------------------------------------------------------------------
|
| 267 |
dpurdie |
9843 |
# Distribution Sets
|
| 261 |
dpurdie |
9844 |
#
|
| 267 |
dpurdie |
9845 |
MakeHeader ("Distribution Sets");
|
|
|
9846 |
PackageSetRules();
|
|
|
9847 |
|
|
|
9848 |
#-------------------------------------------------------------------------------
|
|
|
9849 |
#
|
| 261 |
dpurdie |
9850 |
# Subdir deletion
|
|
|
9851 |
# This is done AFTER the toolset functions have been invoked to create the
|
|
|
9852 |
# build artifacts so that the toolsets can create directories too
|
|
|
9853 |
#
|
|
|
9854 |
# Note: Toolset directories are deleted first
|
|
|
9855 |
# Note: User Directories are deleted in the reverse order of creation
|
|
|
9856 |
#
|
|
|
9857 |
MakeHeader ("Subdir deletion");
|
| 285 |
dpurdie |
9858 |
MakePrint( ".PHONY:\t\tunmake_dir\n" );
|
| 261 |
dpurdie |
9859 |
MakePrint( "unmake_dir:\n" );
|
|
|
9860 |
MakePrint( "\t-\$(AA_PRE)echo Removing directories;" );
|
|
|
9861 |
MakePrint( " \\\n\t\$(rmdir) \$(TOOLSETDIRS);" ) if ( @TOOLSETDIRS );
|
|
|
9862 |
MakePrint( " \\\n\t\$(rm) -rf \$(TOOLSETDIRTREES);" ) if ( @TOOLSETDIRTREES );
|
|
|
9863 |
RmdirRules();
|
|
|
9864 |
MakeNewLine();
|
| 227 |
dpurdie |
9865 |
|
| 261 |
dpurdie |
9866 |
#--------- Toolset Rules -------------------------------------------------------
|
|
|
9867 |
MakeHeader ("Toolset Rules");
|
|
|
9868 |
MakePrintList ( \@TOOLSETRULES );
|
|
|
9869 |
|
|
|
9870 |
#--------- Maketags ------------------------------------------------------------
|
| 227 |
dpurdie |
9871 |
|
|
|
9872 |
Maketag( "make_init", @INITS );
|
| 261 |
dpurdie |
9873 |
Maketag( "make_dir", @mkdirdep );
|
|
|
9874 |
Maketag( "generate", @generatedep || @projectgendep || @USERGENERATED || ($ScmToolsetGenerate != 0) );
|
| 227 |
dpurdie |
9875 |
Maketag( "depend", $ScmDependTags != 0 );
|
| 261 |
dpurdie |
9876 |
Maketag( "make_lib", @libdep );
|
|
|
9877 |
Maketag( "make_mlib", @mlibdep );
|
|
|
9878 |
Maketag( "make_install_shlib", %INSTALL_SHLIBS || @shlibdep);
|
|
|
9879 |
Maketag( "make_script", @scriptdep );
|
|
|
9880 |
Maketag( "make_prog", @progdep || @projectdep );
|
|
|
9881 |
Maketag( "make_test", @testprogdep );
|
| 263 |
dpurdie |
9882 |
Maketag( "run_tests", @TESTS_TO_RUN || @TESTPROJECT_TO_URUN || $TESTS_TO_RUN);
|
| 227 |
dpurdie |
9883 |
Maketag( "run_unit_tests", $TESTS_TO_AUTORUN || @TESTPROJECT_TO_ARUN);
|
|
|
9884 |
Maketag( "install_hdr", %INSTALL_HDRS );
|
|
|
9885 |
Maketag( "install_class", %INSTALL_CLSS );
|
|
|
9886 |
Maketag( "install_lib", %INSTALL_LIBS );
|
|
|
9887 |
Maketag( "install_prog", %INSTALL_PROGS );
|
|
|
9888 |
Maketag( "deploy", %DEPLOYPACKAGE );
|
|
|
9889 |
Maketag( "package", %PACKAGE_FILES || %PACKAGE_HDRS || %PACKAGE_CLSS ||
|
|
|
9890 |
%PACKAGE_LIBS || %PACKAGE_SHLIBS || %PACKAGE_PROGS );
|
|
|
9891 |
|
| 261 |
dpurdie |
9892 |
#
|
|
|
9893 |
# Display tags in the MAKEFILE
|
|
|
9894 |
# Not used here - just for show
|
|
|
9895 |
#
|
|
|
9896 |
MakeHeader ("Maketags");
|
|
|
9897 |
foreach my $tag ( sort keys %MakeTags )
|
|
|
9898 |
{
|
|
|
9899 |
MakePadded( 2, "# $tag:", defined ($MakeTags{$tag}) ? 1 : 0, "\n");
|
|
|
9900 |
}
|
|
|
9901 |
|
| 227 |
dpurdie |
9902 |
#-------------------------------------------------------------------------------
|
|
|
9903 |
# End of Makefile
|
|
|
9904 |
#
|
|
|
9905 |
MakeHeader ("End of Makefile");
|
|
|
9906 |
close( MAKEFILE );
|
|
|
9907 |
|
|
|
9908 |
#
|
|
|
9909 |
# Save all platform information
|
|
|
9910 |
# Done after the makefile is written as toolsets can extend the data
|
|
|
9911 |
#
|
|
|
9912 |
WriteParsedConfig();
|
|
|
9913 |
|
|
|
9914 |
#
|
|
|
9915 |
# Write out any accumulated DPACKAGE data
|
|
|
9916 |
#
|
|
|
9917 |
JatsDPackage::DPackageSave();
|
|
|
9918 |
|
|
|
9919 |
return 0;
|
|
|
9920 |
}
|
|
|
9921 |
|
|
|
9922 |
#-------------------------------------------------------------------------------
|
| 387 |
dpurdie |
9923 |
# Function : QuoteForMake
|
|
|
9924 |
#
|
|
|
9925 |
# Description : Escape/Quote a pathname for make
|
|
|
9926 |
# Allow files with a $ in the name
|
|
|
9927 |
# Allow files with a space in the name
|
|
|
9928 |
# Allow files with a comma in the name
|
|
|
9929 |
# Allow for paths that have make-varible prefixes
|
|
|
9930 |
# $(GBE_...)/
|
|
|
9931 |
# as these may be generated internally
|
|
|
9932 |
#
|
| 392 |
dpurdie |
9933 |
# Must also allow $(GBE_TYPE) in the remainder
|
|
|
9934 |
#
|
| 387 |
dpurdie |
9935 |
# Inputs : uarg - Arg to quote
|
|
|
9936 |
#
|
|
|
9937 |
# Returns : Quoted arg
|
|
|
9938 |
#
|
|
|
9939 |
|
|
|
9940 |
sub QuoteForMake()
|
|
|
9941 |
{
|
|
|
9942 |
my ($uarg) = @_;
|
|
|
9943 |
|
|
|
9944 |
#
|
|
|
9945 |
# Split into two
|
|
|
9946 |
# $(xxx)/ - Makefile variables
|
|
|
9947 |
# Remainder - Stuff to quote
|
|
|
9948 |
#
|
|
|
9949 |
$uarg =~ m~^((\$\(.*?\)/)*)(.*)~;
|
|
|
9950 |
my $prefix = defined $1 ? $1 : '';
|
|
|
9951 |
my $arg = defined $3 ? $3 : '';
|
|
|
9952 |
|
| 392 |
dpurdie |
9953 |
$arg =~ s~\$(?!\(GBE_)~\$\$~g; # $, not followed by (GBE_ - id not $(GBE_
|
| 387 |
dpurdie |
9954 |
$arg =~ s~ ~\\ ~g;
|
|
|
9955 |
$arg =~ s~,~\$(comma)~g;
|
|
|
9956 |
return $prefix . $arg;
|
|
|
9957 |
}
|
|
|
9958 |
|
|
|
9959 |
|
|
|
9960 |
#-------------------------------------------------------------------------------
|
| 227 |
dpurdie |
9961 |
# Function : Maketag
|
|
|
9962 |
#
|
|
|
9963 |
# Description : Create Makefile tags to speed up recursive makes
|
|
|
9964 |
#
|
|
|
9965 |
# Inputs : tag_name
|
|
|
9966 |
# dep
|
|
|
9967 |
#
|
|
|
9968 |
# Returns :
|
|
|
9969 |
#
|
|
|
9970 |
sub Maketag
|
|
|
9971 |
{
|
|
|
9972 |
my( $tag, $dep ) = @_;
|
|
|
9973 |
$MakeTags{$tag} = 1 if ( defined($dep) && $dep );
|
|
|
9974 |
}
|
|
|
9975 |
|
|
|
9976 |
#-------------------------------------------------------------------------------
|
|
|
9977 |
# Function to create and delete directories within the build system
|
|
|
9978 |
#
|
|
|
9979 |
# To stop make regenerating directory dependent targets each time the
|
|
|
9980 |
# directory content is modified, rule should only be dependent on a internally
|
|
|
9981 |
# created alias file 'gbedir', which represents the time a dir was created not
|
|
|
9982 |
# last modified.
|
|
|
9983 |
#
|
|
|
9984 |
# Must use tags like GBE_BINDIR, GBE_LIBDIR and GBE_OBJDIR to ensure that the
|
|
|
9985 |
# directories are created correctly.
|
|
|
9986 |
#
|
|
|
9987 |
my %MkdirRuleData;
|
|
|
9988 |
my @MkdirRuleOrder;
|
|
|
9989 |
my $MkdirRulePrinting = 0;
|
|
|
9990 |
my $MkdirRuleGbeFile = ( $::ScmHost eq "Unix" ) ? ".gbedir" : "_gbedir";
|
|
|
9991 |
|
|
|
9992 |
#-------------------------------------------------------------------------------
|
|
|
9993 |
# Function : MkdirRule
|
|
|
9994 |
#
|
|
|
9995 |
# Description : Create Rules and Recipes to create a directory at make-time
|
|
|
9996 |
# Mark the information for such that the directories will
|
|
|
9997 |
# be deleted in a 'clean'
|
|
|
9998 |
#
|
|
|
9999 |
# Can be called before we start writing the makefile
|
|
|
10000 |
# Such entries will be retained and dumped at a known time
|
|
|
10001 |
#
|
|
|
10002 |
# Inputs : $subdir - Symbolic name of the subdir $(OBJDIR)
|
|
|
10003 |
# $alias - Optional script alias for the dir 'OBJDIR' --> GBE_OBJDIR
|
|
|
10004 |
# Options:
|
|
|
10005 |
# --Path=path Optional value of $subdir '$(GBE_PLATFORM)$(GBE_TYPE).OBJ'
|
|
|
10006 |
# --RemoveAll Remove all files on clean
|
|
|
10007 |
#
|
|
|
10008 |
# Returns : Nothing
|
|
|
10009 |
#
|
|
|
10010 |
|
|
|
10011 |
sub MkdirRule
|
|
|
10012 |
{
|
|
|
10013 |
my( $subdir, $alias, @opts ) = @_;
|
|
|
10014 |
|
|
|
10015 |
#
|
|
|
10016 |
# Create data entry once
|
|
|
10017 |
#
|
|
|
10018 |
$alias =~ s~^GBE_~~ if $alias;
|
|
|
10019 |
unless ( $MkdirRuleData{$subdir} )
|
|
|
10020 |
{
|
|
|
10021 |
my %data;
|
|
|
10022 |
|
|
|
10023 |
#
|
|
|
10024 |
# Parse options
|
|
|
10025 |
#
|
|
|
10026 |
foreach ( @opts )
|
|
|
10027 |
{
|
|
|
10028 |
if ( /^--Path=(.+)/ ) {
|
|
|
10029 |
$data{path} = $1;
|
|
|
10030 |
} elsif ( /^--RemoveAll/ ) {
|
|
|
10031 |
$data{remove_all} = 1;
|
|
|
10032 |
} else {
|
|
|
10033 |
Error ("MkdirRule: Unknown option: $_");
|
|
|
10034 |
}
|
|
|
10035 |
}
|
|
|
10036 |
$data{alias} = $alias if ( $alias );
|
|
|
10037 |
|
|
|
10038 |
$MkdirRuleData{$subdir} = \%data;
|
|
|
10039 |
push @MkdirRuleOrder, $subdir;
|
|
|
10040 |
}
|
|
|
10041 |
|
|
|
10042 |
#
|
|
|
10043 |
# Save or print
|
|
|
10044 |
#
|
|
|
10045 |
return unless ( $MkdirRulePrinting );
|
|
|
10046 |
|
|
|
10047 |
#
|
|
|
10048 |
# Create a definition of the physical directory
|
|
|
10049 |
#
|
|
|
10050 |
my $path = $MkdirRuleData{$subdir}{path};
|
| 261 |
dpurdie |
10051 |
MakePadded (2, $alias, ":= $path\n") if ( $path && $alias );
|
| 227 |
dpurdie |
10052 |
|
|
|
10053 |
# Create an alias to be used within rules
|
|
|
10054 |
# The defined aliase will be prefixed with 'GBE_'
|
|
|
10055 |
#
|
| 261 |
dpurdie |
10056 |
MakePadded (2, "GBE_$alias", ":= $subdir/$MkdirRuleGbeFile\n") if ( $alias );
|
| 227 |
dpurdie |
10057 |
|
|
|
10058 |
#
|
|
|
10059 |
# Create a recipe to create the directory
|
|
|
10060 |
# This is not as simple as it sounds
|
|
|
10061 |
# The touch is required.
|
|
|
10062 |
# Had 'timestamp' issues on solaris'. The 'echo' did not appear
|
|
|
10063 |
# to be enough. Perhaps the output was not flushed
|
|
|
10064 |
#
|
| 261 |
dpurdie |
10065 |
MakePadded (2, "$subdir", ": $subdir/$MkdirRuleGbeFile\n");
|
| 227 |
dpurdie |
10066 |
MakePrint
|
|
|
10067 |
"$subdir/$MkdirRuleGbeFile:\n".
|
|
|
10068 |
"\t\$(XX_PRE)if [ ! -d $subdir ]; then \$(mkdir) -p $subdir; fi; \\\n".
|
|
|
10069 |
"\t\$(echo) '# DO NOT REMOVE.' > \$@; \\\n".
|
|
|
10070 |
"\t\$(touch) \$@\n\n";
|
|
|
10071 |
}
|
|
|
10072 |
|
|
|
10073 |
#-------------------------------------------------------------------------------
|
|
|
10074 |
# Function : RmdirRules
|
|
|
10075 |
#
|
|
|
10076 |
# Description : Create the body of a recipe to delete the directoeis that
|
|
|
10077 |
# have been created.
|
|
|
10078 |
#
|
|
|
10079 |
# The rule header will have been written to the makefile
|
|
|
10080 |
#
|
|
|
10081 |
# Inputs : Uses $MkdirRuleData
|
|
|
10082 |
#
|
|
|
10083 |
# Returns : Nothing.
|
|
|
10084 |
# Prints to the makefile
|
|
|
10085 |
#
|
|
|
10086 |
sub RmdirRules
|
|
|
10087 |
{
|
|
|
10088 |
#
|
|
|
10089 |
# Determine the list of directories to delete
|
|
|
10090 |
# Sort such that subdirs are deleted files
|
|
|
10091 |
#
|
|
|
10092 |
foreach my $subdir ( reverse sort keys %MkdirRuleData )
|
|
|
10093 |
{
|
|
|
10094 |
MakePrint "\\\n"; # join to previous line
|
| 261 |
dpurdie |
10095 |
MakePrint "\tif [ -d $subdir ]; then \\\n";
|
|
|
10096 |
unless ( $MkdirRuleData{$subdir}{remove_all} )
|
|
|
10097 |
{
|
|
|
10098 |
MakePrint "\t\t\$(rm) -f $subdir/$MkdirRuleGbeFile; \\\n";
|
|
|
10099 |
MakePrint "\t\t\$(rmdir) $subdir; \\\n";
|
|
|
10100 |
}
|
|
|
10101 |
else
|
|
|
10102 |
{
|
|
|
10103 |
MakePrint "\t\t\$(rm) -rf $subdir; \\\n";
|
|
|
10104 |
}
|
| 227 |
dpurdie |
10105 |
MakePrint "\tfi;";
|
|
|
10106 |
}
|
|
|
10107 |
}
|
|
|
10108 |
|
|
|
10109 |
#-------------------------------------------------------------------------------
|
|
|
10110 |
# Function : CreateMkdirRules
|
|
|
10111 |
#
|
|
|
10112 |
# Description : Create Rules to make dirs at runtime
|
|
|
10113 |
# This function is called to instantiate those entries
|
|
|
10114 |
# That have been requested before the makefile has has
|
|
|
10115 |
# started to be created.
|
|
|
10116 |
#
|
|
|
10117 |
# Once this function has been called all new MkdirRule calls
|
|
|
10118 |
# will result in the recipes being created in-line.
|
|
|
10119 |
#
|
|
|
10120 |
# Inputs : Nothing
|
|
|
10121 |
#
|
|
|
10122 |
# Returns : Even Less
|
|
|
10123 |
#
|
|
|
10124 |
#
|
|
|
10125 |
sub CreateMkdirRules
|
|
|
10126 |
{
|
|
|
10127 |
$MkdirRulePrinting = 1;
|
|
|
10128 |
foreach my $subdir ( @MkdirRuleOrder )
|
|
|
10129 |
{
|
|
|
10130 |
my $data = $MkdirRuleData{$subdir};
|
|
|
10131 |
MkdirRule($subdir, $data->{alias}, $data->{path} );
|
|
|
10132 |
}
|
|
|
10133 |
}
|
|
|
10134 |
|
|
|
10135 |
#-------------------------------------------------------------------------------
|
|
|
10136 |
# Function : PackageRule
|
|
|
10137 |
#
|
|
|
10138 |
# Description : Generate rules and recipes to "install" and "package" files
|
|
|
10139 |
#
|
|
|
10140 |
# Inputs : codecmd - A code reference to the actual installer routine
|
|
|
10141 |
# hashp - A reference to a INSTALL or PACKAGE hash
|
|
|
10142 |
#
|
| 299 |
dpurdie |
10143 |
# hashp is a reference to a hash
|
| 227 |
dpurdie |
10144 |
# The key is the full path of the install target
|
|
|
10145 |
# The value is (another) hash that describes the install options
|
|
|
10146 |
#
|
|
|
10147 |
# Valid keys are:
|
|
|
10148 |
# src - Path of the source file [Mandatory]
|
|
|
10149 |
# dir - Target directory [Mandatory]
|
|
|
10150 |
#
|
|
|
10151 |
# defined - Copy the file only if value is defined
|
|
|
10152 |
# exe - Mark the file as executable
|
|
|
10153 |
# Mode - File modes. Default is -w
|
|
|
10154 |
# placekeeper - Marks SHARED library placekeepers
|
|
|
10155 |
# set - Distribution sets
|
|
|
10156 |
# type - Copy the file in DEBUG or PROD mode
|
|
|
10157 |
# Valid values are "D" or "P"
|
|
|
10158 |
# version - Shared library version information
|
|
|
10159 |
# RemoveOnly - Do not install the file. Entries are
|
|
|
10160 |
# created to allow the removal of the file
|
|
|
10161 |
#
|
|
|
10162 |
# Returns :
|
|
|
10163 |
#
|
|
|
10164 |
sub PackageRule
|
|
|
10165 |
{
|
|
|
10166 |
my ($codecmd, $hashp) = @_;
|
|
|
10167 |
|
|
|
10168 |
foreach my $dest ( keys %{$hashp} )
|
|
|
10169 |
{
|
|
|
10170 |
|
|
|
10171 |
my $entry = $hashp->{$dest};
|
|
|
10172 |
|
|
|
10173 |
#
|
|
|
10174 |
# Skip placekeepers
|
|
|
10175 |
#
|
|
|
10176 |
next if ( $entry->{'placekeeper'} );
|
|
|
10177 |
|
|
|
10178 |
#
|
|
|
10179 |
# Some entries are not installed via this mechanism, but can be removed
|
|
|
10180 |
# if they exist. Mark these as PHONY to keep targets happy
|
|
|
10181 |
#
|
|
|
10182 |
if ( $entry->{'RemoveOnly'} )
|
|
|
10183 |
{
|
|
|
10184 |
MakePrint ".PHONY:\t$dest\n";
|
|
|
10185 |
MakePrint "$dest:\n\n";
|
|
|
10186 |
next;
|
|
|
10187 |
}
|
|
|
10188 |
|
|
|
10189 |
my $fname = $entry->{'src'};
|
|
|
10190 |
my $fmode = $entry->{'Mode'};
|
|
|
10191 |
$fmode .= "+x" if ( $entry->{'exe'} );
|
|
|
10192 |
|
|
|
10193 |
#
|
|
|
10194 |
# User conditionional
|
|
|
10195 |
# Mark both the source and the target as PHONY if the condition is not met
|
|
|
10196 |
# This will ensure that the target need not be built.
|
|
|
10197 |
#
|
|
|
10198 |
my $udef = $entry->{'defined'};
|
|
|
10199 |
if ( $udef )
|
|
|
10200 |
{
|
|
|
10201 |
MakePrint "ifndef $udef \n";
|
|
|
10202 |
MakePrint ".PHONY:\t\t$dest\n";
|
|
|
10203 |
MakePrint ".PHONY:\t\t$fname\n";
|
|
|
10204 |
MakePrint "$dest:\n";
|
|
|
10205 |
MakePrint "else\n"
|
|
|
10206 |
}
|
|
|
10207 |
|
|
|
10208 |
#
|
|
|
10209 |
# Conditional installation for DEBUG/PRODUCTION
|
|
|
10210 |
#
|
|
|
10211 |
my $type = $entry->{'type'};
|
|
|
10212 |
if ( $type )
|
|
|
10213 |
{
|
|
|
10214 |
if ( $type eq "D" ) {
|
|
|
10215 |
MakePrint 'ifeq "$(DEBUG)" "0"'."\n";
|
|
|
10216 |
} elsif ( $type eq "P" ) {
|
|
|
10217 |
MakePrint 'ifneq "$(DEBUG)" "0"'."\n";
|
|
|
10218 |
} else {
|
|
|
10219 |
Error("INTERNAL: Unexpected packaging type: $type");
|
|
|
10220 |
}
|
|
|
10221 |
MakePrint ".PHONY:\t\t$dest\n";
|
|
|
10222 |
MakePrint "$dest:\n";
|
|
|
10223 |
MakePrint "else\n"
|
|
|
10224 |
}
|
|
|
10225 |
|
|
|
10226 |
#
|
|
|
10227 |
# The body of the copy
|
|
|
10228 |
#
|
|
|
10229 |
MakePadded( 4, "$dest:" );
|
|
|
10230 |
MakePrint "\t$fname\n";
|
|
|
10231 |
MakePrint $codecmd->( $dest, $fname, $entry->{'dir'}, $fmode );
|
|
|
10232 |
MakeNewLine();
|
|
|
10233 |
|
|
|
10234 |
|
|
|
10235 |
#
|
|
|
10236 |
# Unwind conditionals
|
|
|
10237 |
#
|
|
|
10238 |
MakePrint "endif\n" if ( $type );
|
|
|
10239 |
MakePrint "endif\n" if ( $udef );
|
|
|
10240 |
|
|
|
10241 |
#
|
|
|
10242 |
# Distribution sets
|
|
|
10243 |
#
|
|
|
10244 |
my $dist = $entry->{'set'};
|
|
|
10245 |
if ( $dist )
|
|
|
10246 |
{
|
| 267 |
dpurdie |
10247 |
foreach my $set ( split( ',', $dist ) )
|
|
|
10248 |
{
|
|
|
10249 |
push @{$PACKAGE_SETS{$set}{LIST}}, $dest;
|
| 227 |
dpurdie |
10250 |
}
|
|
|
10251 |
MakeNewLine();
|
|
|
10252 |
}
|
|
|
10253 |
}
|
|
|
10254 |
}
|
|
|
10255 |
|
|
|
10256 |
#-------------------------------------------------------------------------------
|
| 267 |
dpurdie |
10257 |
# Function : PackageSetRules
|
|
|
10258 |
#
|
|
|
10259 |
# Description : Generate the packageset rules
|
|
|
10260 |
# These appear to be a now-defuct feature
|
|
|
10261 |
#
|
|
|
10262 |
# By default all packaged files are a part of package_setALL
|
|
|
10263 |
#
|
|
|
10264 |
# Inputs : None
|
|
|
10265 |
# Takes data from %PACKAGE_SET
|
|
|
10266 |
#
|
|
|
10267 |
# Returns : Nothing
|
|
|
10268 |
#
|
|
|
10269 |
sub PackageSetRules
|
|
|
10270 |
{
|
|
|
10271 |
foreach my $set ( sort keys %PACKAGE_SETS )
|
|
|
10272 |
{
|
|
|
10273 |
my $me = MakeEntry::New( *MAKEFILE, "package_set$set", '--Phony' );
|
|
|
10274 |
$me->AddDependancy( @{$PACKAGE_SETS{$set}{LIST}} );
|
|
|
10275 |
$me->Print();
|
|
|
10276 |
}
|
|
|
10277 |
}
|
|
|
10278 |
|
|
|
10279 |
#-------------------------------------------------------------------------------
|
| 227 |
dpurdie |
10280 |
# Function : UnPackageRule
|
|
|
10281 |
#
|
|
|
10282 |
# Description : Generate rules and recipes to "uninstall" and "unpackage" files
|
|
|
10283 |
#
|
|
|
10284 |
# Inputs : target - Name of the target
|
|
|
10285 |
# codecmd - A code reference to the actual installer routine
|
|
|
10286 |
# hashp - A reference to a INSTALL or PACKAGE hash
|
|
|
10287 |
#
|
|
|
10288 |
# Returns :
|
|
|
10289 |
#
|
|
|
10290 |
sub UnpackageRule
|
|
|
10291 |
{
|
|
|
10292 |
my ($target, $codecmd, $hashp) = @_;
|
|
|
10293 |
|
|
|
10294 |
MakePrint ".PHONY:\t\t"."$target\n";
|
|
|
10295 |
MakePrint "$target:\t";
|
|
|
10296 |
|
|
|
10297 |
foreach my $dest ( sort keys %{$hashp} )
|
|
|
10298 |
{
|
|
|
10299 |
|
|
|
10300 |
my $entry = $hashp->{$dest};
|
|
|
10301 |
|
|
|
10302 |
#
|
|
|
10303 |
# Skip placekeepers
|
|
|
10304 |
#
|
|
|
10305 |
next if ( $entry->{'placekeeper'} );
|
|
|
10306 |
|
|
|
10307 |
MakePrint "\n" . $codecmd->($dest);
|
|
|
10308 |
}
|
|
|
10309 |
MakePrint "\n\n";
|
|
|
10310 |
}
|
|
|
10311 |
|
|
|
10312 |
|
|
|
10313 |
#
|
|
|
10314 |
# Internal macro interface, see RULE.STD for definitions:
|
|
|
10315 |
#
|
|
|
10316 |
sub RmFilesCmd
|
|
|
10317 |
{
|
|
|
10318 |
my ( $list ) = @_;
|
| 261 |
dpurdie |
10319 |
return "\$(call RmFiles,$list)";
|
| 227 |
dpurdie |
10320 |
}
|
|
|
10321 |
|
|
|
10322 |
sub InstallCmd
|
|
|
10323 |
{
|
|
|
10324 |
my( $dest, $file, $path, $fmode ) = @_;
|
|
|
10325 |
|
|
|
10326 |
$path =~ s~/$~~; # remove trailing "/"
|
|
|
10327 |
$fmode = "-w" # default, read-only
|
|
|
10328 |
if ( !defined( $fmode ) || $fmode eq "" );
|
|
|
10329 |
|
|
|
10330 |
return "\t\$(call InstallFile,$dest,$file,$path,$fmode)";
|
|
|
10331 |
}
|
|
|
10332 |
|
|
|
10333 |
sub UninstallCmd
|
|
|
10334 |
{
|
|
|
10335 |
my( $file ) = @_;
|
|
|
10336 |
|
|
|
10337 |
return "\t\$(call UninstallFile,$file)";
|
|
|
10338 |
}
|
|
|
10339 |
|
|
|
10340 |
sub PackageCmd
|
|
|
10341 |
{
|
|
|
10342 |
my( $dest, $file, $path, $fmode ) = @_;
|
|
|
10343 |
|
|
|
10344 |
$path =~ s~/$~~; # remove trailing "/"
|
|
|
10345 |
$fmode = "-w" # default, read-only
|
|
|
10346 |
if ( !defined( $fmode ) || $fmode eq "" );
|
|
|
10347 |
|
|
|
10348 |
return "\t\$(call PackageFile,$dest,$file,$path,$fmode)";
|
|
|
10349 |
}
|
|
|
10350 |
|
|
|
10351 |
sub UnpackageCmd
|
|
|
10352 |
{
|
|
|
10353 |
my( $file ) = @_;
|
|
|
10354 |
return "\t\$(call UnpackageFile,$file)";
|
|
|
10355 |
}
|
|
|
10356 |
|
|
|
10357 |
1;
|
|
|
10358 |
|