Subversion Repositories DevTools

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
227 dpurdie 1
# -*- mode: perl; indent-width: 4; show-tabs: yes; -*-
2
#
3
# Module name   : vcwce
4
# Module type   : Makefile system
5
# Compiler(s)   : ANSI C
6
# Environment(s): WCE
7
#
8
# Description:
9
#   Visual C/C++ for WCE
10
#
11
# Version   Who     Date        Description
12
#           APY     26/04/04    Created
13
#                   19/05/04    IFLAG3 support (changes marked IFLAG3)
14
#                   01/09/04    ToolsetPrinter()
15
#
16
# $Source: /cvsroot/etm/devl/CFG/TOOLSET/VCWCE,v $
17
# $Revision: 1.11 $ $Date: 2004/08/25 06:33:31 $ $State: Exp $
18
# $Author: ayoung $ $Locker:  $
19
#............................................................................#
20
 
21
use strict;
22
use warnings;
23
 
24
#
25
#   Global data
26
#
27
my $pdb_file = "\$(GBE_PBASE)";
28
my $pdb_first_lib;
29
my $target_file_lib;
30
my $target_file_dll;
31
my $target_file_exe;
32
my $pdb_none;
33
##############################################################################
34
#   ToolsetInit()
35
#       Runtime initialisation
36
#
37
##############################################################################
38
 
39
my( $WCEVersion )               = "";
40
my( $WCESubsystem )             = "";
41
my( $WCEPlatform )              = "";
42
my( $WCEPlatformDefine )        = "";
43
my( $WCEPlatformClean )         = "";
44
my( $WCETargetCPU )             = "";
45
my( $WCEHostCPU )               = "";
46
my( $WCEToolchain )             = "";
47
 
48
ToolsetInit();
49
 
50
sub ToolsetInit
51
{
52
    my( $wceroot, $sdkroot );
53
    my( $compiler, $linker );
54
    my( @defines ) = ();
55
    my( @cflags, @cflags_debug, @cflags_prod ) = ();
56
    my( @libflags, @ldflags, @ldflags_debug, @ldflags_prod ) = ();
57
 
58
#.. Standard.rul requirements
59
#
60
    $::s = "asm";
61
    $::o = "obj";
62
    $::a = "lib";
63
    $::so = "dll";
64
    $::exe = ".exe";
65
 
66
#.. Toolset configuration
67
#
68
    $::ScmToolsetVersion = "1.0.0";             # our version
69
    $::ScmToolsetGenerate = 0;                  # generate optional
70
    $::ScmToolsetIFLAG3 = 1;                    # supports IFLAG3
71
 
72
#.. Parse arguments
73
#
74
    Debug( "vcwce(ToolsetArgs=@::ScmToolsetArgs)" );
75
 
76
    foreach ( @::ScmToolsetArgs ) {
77
        Message( "vcwce toolset: unknown option $_ -- ignored\n" );
78
    }
79
 
80
    Debug( "vcwce(PlatformArgs=@::ScmPlatformArgs)" );
81
 
82
    foreach ( @::ScmPlatformArgs ) {
83
        if (/^--Version=(.*)/) {                # OS Version
84
            $WCEVersion     = "$1";
85
 
86
        } elsif (/^--SDK=(.*)/) {               # SDK
87
            $WCEPlatform    = "$1";
88
 
89
        } elsif (/^--Target=(.*)/) {            # CPU
90
            $WCETargetCPU   = "$1";
91
 
92
        } elsif (/^--Host=(.*)/) {              # Emulator host CPU
93
            $WCEHostCPU     = "$1";
94
 
95
        } elsif (/^--Toolchain=(.*)/) {         # Toolchain
96
            $WCEToolchain   = "$1";
97
 
98
        } elsif (/^--product=(.*)/) {           # GBE product
99
 
100
        } elsif (/^--NoDinkumware/) {           # Deprecated switch
101
        } else {
102
            Message( "vcwce toolset: unknown platform argument $_ -- ignored\n" );
103
        }
104
    }
105
 
106
#.. Select toolchain, based on targetCPU
107
#
108
#
109
#   The following table shows the processors that eMbedded Visual C++
110
#   currently supports.
111
#
112
#   ARM         ARMV4, ARMV4I, ARMV4T
113
#   MIPS        MIPSII, MIPSII_FP, MIPSIV, MIPSIV_FP, MIPS16
114
#   Hitachi     SH3, SH4
115
#   x86         x86, x86 emulation
116
#..
117
    Error ("TOOLSET/vcwce - Version undefined")
118
        if ($WCEVersion eq "");
119
 
120
    Error ("TOOLSET/vcwce - SDK undefined")
121
        if ($WCEPlatform eq "");
122
 
123
    Error ("TOOLSET/vcwce - TargetCPU undefined")
124
        if ($WCETargetCPU eq "");
125
 
126
    Error ("TOOLSET/vcwce - HostCPU undefined")
127
        if ($WCEPlatform eq "emulator" && $WCEHostCPU eq "");
128
 
129
# .. Generate CE Platform definition based on the selected SDK
130
#    The following is a list of known defintions for some SDKs
131
#    In the EVC studio these are $(CePlatform)
132
#..
133
    my %PlatformSDKDefinitions =
134
    (
135
        'H/PC 2000'         => 'WIN32_PLATFORM_HPC2000',
136
        'H/PC Pro 2.11'     => 'WIN32_PLATFORM_HPCPRO',
137
        'Pocket PC'         => 'WIN32_PLATFORM_PSPC',
138
        'Pocket PC 2002'    => 'WIN32_PLATFORM_PSPC=310',
139
        'POCKET PC 2003'    => 'WIN32_PLATFORM_PSPC=400',
140
        'Smartphone 2002'   => 'WIN32_PLATFORM_WFSP=100',
141
        'IT-3000'           => 'WCE_PLATFORM_PX780J_ARMV4I',
142
        'PCM7220'           => 'WCE_PLATFORM_SOCERXS',
143
        'ADVANTECH_X86_420' => 'WCE_PLATFORM_ADVANTECH_X86_420',
144
        'SOM_4450_2'        => 'WCE_PLATFORM_SOM_4450_2',
145
        'adv_som_4455_wlan' => 'WCE_PLATFORM_adv_som_4455_wlan',
146
        'PsionTeklogixCE420'=> 'WCE_PLATFORM_STANDARDSDK',
147
        'PsionTeklogixCE500'=> 'WCE_PLATFORM_STANDARDSDK',
148
        'PA961'             => 'WCE_PLATFORM_PA961',
149
        'PA962'             => 'WCE_PLATFORM_PA962',
150
        'PA962 WINCE 500'   => 'WCE_PLATFORM_PA962',
151
    );
152
 
153
    $WCEPlatformDefine = $PlatformSDKDefinitions{$WCEPlatform};
154
 
155
    Error ("TOOLSET/vcwce - SDK not defined. Extend table",
156
           "SDK: $WCEPlatform" )
157
        unless ( defined $WCEPlatformDefine );
158
 
159
    $WCEPlatformClean = $WCEPlatform;
160
    $WCEPlatformClean =~ s/\s/_/g;
161
 
162
    $WCESubsystem = "windowsce," . int($WCEVersion/100) . "." . $WCEVersion%100
163
        if ( !defined($WCESubsystem) || $WCESubsystem eq "" );
164
 
165
    if ( $WCETargetCPU eq "armv4" ) {
166
        $compiler           = "clarm";
167
        $linker             = "link";
168
 
169
        @defines            = ( '-DARM', '-D_ARM_', '-DARMV4' );
170
 
171
        @cflags             = ( '-QRarch4', '-GX' );
172
        @cflags_debug       = ( '-M$(CECrtDebug)' );
173
        @cflags_prod        = ( '-M$(CECrtMT)' );
174
 
175
        push( @ldflags,     '-base:0x00010000' );
176
        push( @ldflags,     '-stack:0x10000,0x1000' );
177
        push( @ldflags,     '-entry:WinMainCRTStartup' );
178
        push( @ldflags,     '$(CENoDefaultLib)' );
179
        push( @ldflags,     '-Subsystem:$(CESubsystem)' );
180
        push( @ldflags,     '-align:4096' );
181
        push( @ldflags,     '-MACHINE:ARM' );
182
        push( @ldflags,     'commctrl.lib' );
183
        push( @ldflags,     'coredll.lib' );
184
        push( @ldflags,     'aygshell.lib' );
185
 
186
        push( @libflags,    '-MACHINE:ARM' );
187
 
188
    } elsif ( $WCETargetCPU eq "armv4i" ) {
189
        $compiler           = "clarm";
190
        $linker             = "link";
191
 
192
        @defines            = ( '-DARM', '-D_ARM_', '-DARMV4I' );
193
 
194
        @cflags             = ( '/QRarch4T' );
195
        @cflags             = ( '/QRinterwork-return' );
196
        @cflags_debug       = ( '-M$(CECrtDebug)' );
197
        @cflags_prod        = ( '-M$(CECrtMT)' );
198
 
199
        push( @ldflags,     '-base:0x00010000' );
200
        push( @ldflags,     '-stack:0x10000,0x1000' );
201
        push( @ldflags,     '-entry:WinMainCRTStartup' );
202
        push( @ldflags,     '$(CENoDefaultLib)' );
203
        push( @ldflags,     '-Subsystem:$(CESubsystem)' );
204
        push( @ldflags,     '-MACHINE:THUMB' );
205
        push( @ldflags,     'commctrl.lib' );
206
        push( @ldflags,     'coredll.lib' );
207
 
208
        push( @libflags,    '-MACHINE:THUMB' );
209
 
210
 
211
    } elsif ( $WCETargetCPU eq "armv4t" ) {
212
        $compiler           = "clthumb";
213
        $linker             = "link";
214
 
215
        @cflags             = ( '/QRarch4t' );
216
        @defines            = ( '-DARM', '-D_ARM_', '-DARMV4T' );
217
 
218
    } elsif ( $WCETargetCPU eq "mips16" ) {
219
        $compiler           = "clmips";
220
        $linker             = "link";
221
 
222
        @cflags             = ( '/QMmips16' );
223
        @defines            = ( '-DMIPS', '-D_MIPS_' );
224
 
225
    } elsif ( $WCETargetCPU eq "mips16ii" ) {
226
        $compiler           = "clmips";
227
        $linker             = "link";
228
 
229
        @cflags             = ( '/QMmips16' );
230
        @defines            = ( '-DMIPS', '-D_MIPS_' );
231
 
232
    } elsif ( $WCETargetCPU eq "mipsii_fp" ) {
233
        $compiler           = "clmips";
234
        $linker             = "link";
235
 
236
        @cflags             = ( '/QMFWCE' );
237
        @defines            = ( '-DMIPS', '-D_MIPS_' );
238
 
239
    } elsif ( $WCETargetCPU eq "mipsiv" ) {
240
        $compiler           = "clmips";
241
        $linker             = "link";
242
 
243
        @defines            = ( '-DMIPS', '-D_MIPS_' );
244
 
245
    } elsif ( $WCETargetCPU eq "mipsiv_fp" ) {
246
        $compiler           = "clmips";
247
        $linker             = "link";
248
 
249
        @cflags             = ( '/QMFWCE' );
250
        @defines            = ( '-DMIPS', '-D_MIPS_' );
251
 
252
    } elsif ( $WCETargetCPU eq "sh3" ) {
253
        if ( $WCEVersion >= 400 ) {             # SDK specific
254
            $compiler       = "clsh";
255
        } else {
256
            $compiler       = "shcl";
257
        }
258
        $linker             = "link";
259
 
260
        @cflags             = ( '-Qsh3' );
261
        @defines            = ( '-DSHx', '-DSH3', '-D_SH3_' );
262
 
263
    } elsif ( $WCETargetCPU eq "sh4" ) {
264
        if ( $WCEVersion >= 400 ) {             # SDK specific
265
            $compiler       = "clsh";
266
        } else {
267
            $compiler       = "shcl";
268
        }
269
        $linker             = "link";
270
 
271
        @cflags             = ( '-Qsh4' );
272
        @defines            = ( '-DSHx', '-DSH4', '-D_SH4_' );
273
 
274
    } elsif ( $WCETargetCPU eq "x86" ) {
275
        $compiler           = "cl";
276
        $linker             = "link";
277
 
278
        @cflags             = ( '-Gs8192', '-GF' );
279
        @defines            = ( '-D_X86_', '-Dx86', '-D_i386_' );
280
 
281
        push( @ldflags, '-section:.shared,rws' );
282
        push( @ldflags, '-base:0x00100000' );
283
        push( @ldflags, '-stack:0x10000,0x1000' );
284
        push( @ldflags, '-entry:WinMainCRTStartup' );
285
        push( @ldflags, '-Subsystem:$(CESubsystem)' );
286
        push( @ldflags, '-MACHINE:IX86' );
287
        push( @ldflags, '$(CENoDefaultLib)' );
288
        push( @ldflags, '-nodefaultlib:oldnames.lib' );
289
        push( @ldflags, '$(CEx86Corelibc)' );
290
        push( @ldflags, 'coredll.lib' );
291
        push( @ldflags, 'commctrl.lib' );
292
        push( @ldflags, 'aygshell.lib' );
293
 
294
        push( @libflags,'-MACHINE:IX86' );
295
 
296
    } elsif ( $WCETargetCPU eq "emulator" ) {
297
 
298
        if ( $WCEHostCPU eq "x86" ) {
299
            $compiler       = "cl";
300
            $linker         = "link";
301
 
302
            @defines        = ( '-D_X86_', '-Dx86', '-D_i386_' );
303
 
304
            @cflags         = ( '-Gs8192', '-GF', '-GX' );
305
 
306
            push( @ldflags, '-base:0x00010000' );
307
            push( @ldflags, '-stack:0x10000,0x1000' );
308
            push( @ldflags, '-entry:WinMainCRTStartup' );
309
            push( @ldflags, '-Subsystem:$(CESubsystem)' );
310
            push( @ldflags, '-MACHINE:IX86' );
311
            push( @ldflags, '$(CENoDefaultLib)' );
312
            push( @ldflags, '-nodefaultlib:oldnames.lib' );
313
            push( @ldflags, '$(CEx86Corelibc)' );
314
            push( @ldflags, 'commctrl.lib' );
315
            push( @ldflags, 'coredll.lib' );
316
            push( @ldflags, 'aygshell.lib' );
317
 
318
            push( @libflags,'-MACHINE:IX86' );
319
 
320
        } else {
321
            Error ("TOOLSET/vcwce - unknown HostCPU '$WCEHostCPU'");
322
        }
323
 
324
    } else {
325
        Error ("TOOLSET/vcwce - unknown TargetCPU '$WCETargetCPU'");
326
    }
327
 
328
#.. Define eMebbed C/C+ environment
329
#
330
    Init( "vcembedded" );
331
 
332
    if ( $WCEVersion >= 400 ) {                 # SDK specific
333
        $wceroot = '\\Microsoft eMbedded C++ 4.0';
334
        $sdkroot = '\\Windows CE Tools'.'\\wce'.$WCEVersion.'\\'.$WCEPlatform;
335
 
336
    } else {
337
        $wceroot = '\\Microsoft eMbedded Tools';
338
        $sdkroot = '\\Windows CE Tools'.'\\wce'.$WCEVersion.'\\'.$WCEPlatform;
339
    }
340
 
341
    Debug( "\twceroot           = $wceroot" );
342
    Debug( "\tsdkroot           = $sdkroot" );
343
    Debug( "\tWCEVersion        = $WCEVersion" );
344
    Debug( "\tWCESubsystem      = $WCESubsystem" );
345
    Debug( "\tWCEPlatform       = $WCEPlatform" );
346
    Debug( "\tWCEPlatformDefine = $WCEPlatformDefine" );
347
    Debug( "\tWCEPlatformClean  = $WCEPlatformClean" );
348
    Debug( "\tWCETargetCPU      = $WCETargetCPU" );
349
    Debug( "\tWCEHostCPU        = $WCEHostCPU" );
350
 
351
    PlatformDefine( "
352
#################################################
353
# Default paths, toolchain and flags
354
#
355
#..
356
 
357
PROGRAMFILES        ?= C:\\Program Files
358
 
359
ifndef WCEROOT
360
WCEROOT		:= \$(PROGRAMFILES)\\" . $wceroot ."
361
export WCEROOT
362
endif
363
 
364
ifndef SDKROOT
365
SDKROOT		:= \$(PROGRAMFILES)\\" . $sdkroot ."
366
export SDKROOT
367
endif
368
 
369
WCE_VERSION	:= $WCEVersion
370
WCE_SUBSYSTEM	:= $WCESubsystem
371
WCE_PLATFORM	:= $WCEPlatform
372
WCE_PLATFORM_SDK_DEF := $WCEPlatformDefine
373
WCE_PLATFORM2	:= $WCEPlatformClean
374
WCE_TARGETCPU	:= $WCETargetCPU
375
WCE_HOSTCPU	:= $WCEHostCPU
376
");
377
 
378
    PlatformDefine( "
379
CESubsystem	:= \$(WCE_SUBSYSTEM)
380
CEVersion	:= \$(WCE_VERSION)
381
CEPlatform	:= \$(WCE_PLATFORM)
382
");
383
 
384
if ( $WCEVersion < 201 ) {
385
    PlatformDefine( '
386
CECrt		:= L
387
CECrtDebug	:= Ld
388
CECrtMT		:= T
389
CENoDefaultLib	:= \
390
		-nodefaultlib:corelibc.lib
391
CEx86Corelibc	:=
392
');
393
} else {
394
    PlatformDefine( '
395
CECrt		:= C
396
CECrtDebug	:= C
397
CECrtMT		:= C
398
CENoDefaultLib	:= \\
399
		-nodefaultlib:libc.lib\
400
		-nodefaultlib:libcd.lib\
401
		-nodefaultlib:libcmt.lib\
402
		-nodefaultlib:libcmtd.lib\
403
		-nodefaultlib:msvcrt.lib\
404
		-nodefaultlib:msvcrtd.lib
405
CEx86Corelibc	:= corelibc.lib
406
' );
407
}
408
 
409
    PlatformDefine( "WCE_EMULATOR\t".   ":= 1" )
410
        if ( $WCETargetCPU eq "emulator" );
411
 
412
    PlatformEntry( "WCE_DEFINES\t=",    "\n", "\\\n\t", "", @defines )
413
        if ( scalar @defines );
414
 
415
    PlatformEntry( "WCE_CFLAGS\t=",     "\n", "\\\n\t", "", @cflags )
416
        if ( scalar @cflags );
417
 
418
    PlatformEntry( "WCE_CFLAGSD\t=",    "\n", "\\\n\t", "", @cflags_debug )
419
        if ( scalar @cflags_debug );
420
 
421
    PlatformEntry( "WCE_CFLAGSP\t=",    "\n", "\\\n\t", "", @cflags_prod )
422
        if ( scalar @cflags_prod );
423
 
424
    PlatformEntry( "WCE_LDFLAGS\t=",    "\n", "\\\n\t", "", @ldflags )
425
        if ( scalar @ldflags );
426
 
427
    PlatformEntry( "WCE_LIBFLAGS\t=",    "\n", "\\\n\t", "", @libflags )
428
        if ( scalar @libflags );
429
 
430
    PlatformEntry( "WCE_LDFLAGSD\t=",   "\n", "\\\n\t", "", @ldflags_debug )
431
        if ( scalar @ldflags_debug );
432
 
433
    PlatformEntry( "WCE_LDFLAGSP\t=",   "\n", "\\\n\t", "", @ldflags_prod )
434
        if ( scalar @ldflags_prod );
435
 
436
    PlatformDefine( "
437
WCE_CC		:= $compiler
438
WCE_LINK	:= $linker
439
" );
440
 
441
 
442
    ToolsetDefines( "vcwce.def" );
443
    ToolsetRules( "vcwce.rul" );
444
    ToolsetRules( "standard.rul" );
445
 
446
#.. define PCLint envrionment
447
    ToolsetRequire( "pclint" );                 # using pclint
448
    PlatformDefine ("LINT_COFILE\t= co-msc60.lnt");
449
    PlatformDefine ("LINT_PRJ_FILE\t=lint.vcembedded");
450
 
451
#.. Cleanup rules
452
#
453
    ToolsetGenerate( "\$(OBJDIR)/vc60.idb" );
454
    ToolsetGenerate( "\$(OBJDIR)/vc60.pch" );
455
    ToolsetGenerate( "\$(OBJDIR)/vc60.pdb" );
456
    ToolsetGenerate( "\$(PDB)" );
457
    ToolsetGenerate( "\$(PDB).tmp" );
458
 
459
 
460
#
461
#   The PDB files need to be compiled up with absolute paths to the source files
462
#   The easiest way to do this is with the makefile rules created with absolute
463
#   paths. Set a global flag to enable this option
464
#
465
    $::UseAbsObjects = 1;
466
 
467
 
468
#.. Extend the CompilerOption directive
469
#   Create a standard data structure
470
#   This is a hash of hashes
471
#       The first hash is keyed by CompileOption keyword
472
#       The second hash contains pairs of values to set or remove
473
#
474
    %::ScmToolsetCompilerOptions =
475
    (
476
        'rtti'               => { 'USE_RTTI', 1 },
477
        'nopdb'              => { 'PDB_NONE', 1 },
478
        'pdb'                => { 'PDB_NONE', undef },
479
    );
480
 
481
    #
482
    #   Set default options
483
    #
484
#    $::ScmCompilerOpts{'THREADMODE'} = 'D';
485
}
486
 
487
##############################################################################
488
#   ToolsetPreprocess()
489
#       Process collected data before the makefile is generated
490
#       This, optional, routine is called from within MakefileGenerate()
491
#       It allows the toolset to massage any of the collected data before
492
#       the makefile is created
493
#
494
##############################################################################
495
sub ToolsetPreprocess
496
{
497
    #
498
    #   Extract the current state of PDB_NONE
499
    #   Are PDB files to be constructed.
500
    #
501
    $pdb_none = $::ScmCompilerOpts{'PDB_NONE'};
502
}
503
 
504
##############################################################################
505
#   ToolsetPostprocess
506
#       Process collected data as the makefile is generated
507
#       This, optional, routine is called from within MakefileGenerate()
508
#       It allows the toolset to massage any of the collected data before
509
#       the makefile is finally closed created
510
#
511
##############################################################################
512
 
513
sub ToolsetPostprocess
514
{
515
 
516
    #
517
    #   Specify the name of the global PDB file. This is used for all
518
    #   compiles other than those associated with building a DLL
519
    #
520
    #   The name of the PDB will be based on either
521
    #       The name of base package
522
    #       The name of the first static library created
523
    #
524
 
525
MakePrint("
526
#--------- Toolset Postprocessed Information --------------------------------
527
#
528
#   Export the name of the common PDB file
529
#   All compiler information will be placed in this file
530
#   The name of the file MUST be the same as the name of the output library
531
#
532
PDB		= \$(OBJDIR)/$pdb_file\$(GBE_TYPE).pdb
533
" );
534
 
535
    #
536
    #   Add values to the perl environment
537
    #   May be used by post processing tools to create Visual Studio Projects
538
    #
539
    $::TS_pdb_file = "\$(OBJDIR)/$pdb_file\$(GBE_TYPE).pdb" unless( $pdb_none );
540
    $::TS_sbr_support = 1;
541
 
542
    #
543
    #   Prioritorise target: EXE, DLL, LIB
544
    #
545
    for my $tgt ( $target_file_exe, $target_file_dll, $target_file_lib  )
546
    {
547
        if ( $tgt )
548
        {
549
            $::TS_target_file = $tgt;
550
            last;
551
        }
552
    }
553
}
554
 
555
###############################################################################
556
#   ToolsetCC( $source, $obj, \@args )
557
#       This subroutine takes the user options and builds the rule(s)
558
#       required to compile the source file 'source' to 'obj'
559
#
560
###############################################################################
561
 
562
sub ToolsetCC
563
{
564
    ToolsetCC_common( "CC", @_ );
565
}
566
 
567
sub ToolsetCC_common
568
{
569
    my( $name, $source, $obj, $pArgs ) = @_;
570
    my( $cflags, $pdb );
571
 
572
    foreach $_ ( @$pArgs ) {
573
        if (/--Shared$/) {                      # Building a 'shared' object
574
            $cflags = "$cflags \$(SHCFLAGS)";
575
            $pdb = $::SHOBJ_LIB{$obj}
576
                if (exists $::SHOBJ_LIB{$obj} );
577
 
578
        } else {
579
            Message( "vcwce $name: unknown option $_ -- ignored\n" );
580
        }
581
    }
582
 
583
    MakePrint( "\n\t\$($name)\n" );
584
    MakePadded( 4, "\$(OBJDIR)/$obj.$::o:", "\tCFLAGS +=$cflags\n" )
585
        if ( $cflags );                         # object specific CFLAGS
586
 
587
    if ( $pdb && !$pdb_none )
588
    {
589
        #
590
        #   Determine the name of the PDB file
591
        #   If we are building a shared library then the name of the PDB
592
        #   MUST NOT be the same as the name of the library as there is
593
        #   some stange interaction with the linker ( 50% of the time )
594
        #   This is OK as the file will not be published
595
        #
596
        #   If building a static library then create a PDB of the same
597
        #   name as it may be published directly.
598
        #
599
        my $pdb_file;
600
        if ($cflags )
601
        {
602
            $pdb_file = "\$(OBJDIR)/${pdb}\$(GBE_TYPE)_shlib.pdb";
603
        }
604
        else
605
        {
606
            $pdb_file = "\$(OBJDIR)/${pdb}\$(GBE_TYPE).pdb";
607
        }    
608
 
609
        MakePadded( 4, "\$(OBJDIR)/$obj.$::o:", "\tPDB = $pdb_file\n" );
610
        ToolsetGenerate( $pdb_file );
611
        ToolsetGenerate( $pdb_file . ".tmp" );
612
    }
613
 
614
    #
615
    #   Remove possible Source Browser Files
616
    #
617
    ToolsetGenerate( "\$(OBJDIR)/$obj.sbr" );
618
    MakePrint( "\n" );
619
}
620
 
621
 
622
###############################################################################
623
#   ToolsetCCDepend( $depend, \@sources )
624
#       This subroutine takes the user options and builds the
625
#       rule(s) required to build the dependencies for the source
626
#       files 'sources' to 'depend'.
627
#
628
###############################################################################
629
 
630
sub ToolsetCCDepend
631
{
632
    MakePrint( "\t\$(CCDEPEND)\n" );
633
}
634
 
635
 
636
###############################################################################
637
#   ToolsetCXX( $source, $obj, \@args )
638
#       This subroutine takes the user options and builds the rule(s)
639
#       required to compile the source file 'source' to 'obj'
640
#
641
###############################################################################
642
 
643
sub ToolsetCXX
644
{
645
    ToolsetCC_common( "CXX", @_ );
646
}
647
 
648
###############################################################################
649
#   ToolsetCXXDepend( $depend, \@sources )
650
#       This subroutine takes the user options and builds the
651
#       rule(s) required to build the dependencies for the source
652
#       files 'sources' to 'depend'.
653
#
654
###############################################################################
655
 
656
sub ToolsetCXXDepend
657
{
658
    MakePrint( "\t\$(CCDEPEND)\n" );
659
}
660
 
661
 
662
###############################################################################
663
#   ToolsetAS( $source, $obj, \@args )
664
#       This subroutine takes the user options and builds the rule(s)
665
#       required to compile the source file 'source' to 'obj'
666
#
667
###############################################################################
668
 
669
sub ToolsetAS
670
{
671
    MakePrint( "\n\t\$(AS)\n" );
672
}
673
 
674
sub ToolsetASDepend
675
{
676
}
677
 
678
###############################################################################
679
#   ToolsetAR( $name, \@args, \@objs )
680
#       This subroutine takes the user options and builds the rules
681
#       required to build the library 'name'.
682
#
683
#   Arguments:
684
#       --Def=name              Library definition module
685
#
686
#   Output:
687
#       [ $(LIBDIR)/name$.${a}:   .... ]
688
#           $(AR)
689
#
690
###############################################################################
691
 
692
sub ToolsetAR
693
{
694
    my( $name, $pArgs, $pObjs ) = @_;
695
    my( $def );
696
    my ( $res, @reslist );
697
    my $lib_base = "\$(LIBDIR)/${name}\$(GBE_TYPE)";
698
    my $lib_name = "$lib_base.${a}";
699
 
700
 
701
#.. Parse arguments
702
#
703
    $def = "";                                  # options
704
    $res = "";
705
 
706
    foreach $_ ( @$pArgs ) {
707
        if (/^--Def=(.*)/) {                    # library definition
708
            $def = "$1";
709
 
710
        } elsif (/^--Resource=(.*)/) {          # Resource definition
711
            ($res, @reslist) = ToolsetRClist( "$name", $1 );
712
 
713
        } else {                                # unknown
714
            Message( "vcwce AR: unknown option $_ -- ignored\n" );
715
        }
716
    }
717
 
718
#.. Resource Creation
719
#
720
    MakePrint( "#.. Library Resource ($name)\n\n" );
721
    ToolsetRCrecipe( $res, @reslist )
722
        if ( $res );
723
 
724
#.. Target
725
#
726
    MakePrint( "#.. Library ($name)\n\n" );     # label
727
 
728
    MakePrint( "$lib_name:\tLIBDEF=$def\n" ) if ($def);
729
    MakeEntry( "$lib_name:\t", "", "\\\n\t\t", ".$::o", @$pObjs );
730
    MakePrint( "\\\n\t\t$def" ) if ($def);
731
    MakePrint( "\\\n\t\t$res" ) if ($res);
732
    MakePrint( "\n\t\$(AR)" );
733
 
734
#
735
#   Track the name of the possible target file
736
#   Used when creating Visual Studio projects
737
#
738
    $target_file_lib = $lib_name;
739
 
740
#
741
#   To assist in debugging the static library it is nice to
742
#   keep the PDB file used to build the library, with the library.
743
#
744
#   If the library is being packaged or installed then add the PDB
745
#   file to the package / installation
746
#
747
#   NOTE: Due to the limitations of JATS/MicroSoft only one static
748
#   library can be built with a PDB file. The name of the PDB file
749
#   will be taken from the first static library encountered
750
#
751
    unless ( $pdb_first_lib )
752
    {
753
        $pdb_first_lib = $name;
754
        $pdb_file = $name;
755
    }
756
    else
757
    {
758
        Warning( "Multiple static libraries created with a common PDB file: $pdb_file, $name" )
759
            unless( $pdb_none );
760
    }
761
 
762
    PackageLibAddFiles( $name, "\$(OBJDIR)/$pdb_file\$(GBE_TYPE).pdb", "Class=debug" )
763
        unless( $pdb_none );
764
}
765
 
766
 
767
###############################################################################
768
#   ToolsetARLINT( $name, \@args, \@objs )
769
#       This subroutine takes the user options and builds the rules
770
#       required to build the library 'name'.
771
#
772
#   Arguments:
773
#       --xxx                   No arguments currently defined
774
#
775
#   Output:
776
#       [ $(LIBDIR)/name$_lint:   .... ]
777
#           $(ARLINT)
778
#
779
###############################################################################
780
 
781
sub ToolsetARLINT
782
{
783
    PCLintAR( @_ );
784
}
785
 
786
 
787
###############################################################################
788
#   ToolsetARMerge( $name, \@args, \@libs )
789
#       This subroutine takes the user options and builds the rules
790
#       required to build the library 'name' by merging the specified
791
#       libaries
792
#
793
#   Arguments:
794
#       --xxx                   No arguments currently defined
795
#
796
#   Output:
797
#       [ $(LIBDIR)/name$.${a}:   .... ]
798
#           ...
799
#
800
###############################################################################
801
 
802
sub ToolsetARMerge
803
{
804
    my ($name, $pArgs, $pLibs) = @_;
805
    MakePrint( "\n\t\$(ARMERGE)\n\n" );
806
 
807
    #
808
    #   Package up the PDB's with the library
809
    #   Note: The PDBs will be found in the OBJDIR
810
    #
811
    unless( $pdb_none )
812
    {
813
        for ( @{$pLibs} )
814
        {
815
            s~\$\(LIBDIR\)~\$(OBJDIR)~;
816
            PackageLibAddFiles( $name, "$_\$(GBE_TYPE).pdb", "Class=debug" );
817
        }
818
    }
819
}
820
 
821
 
822
###############################################################################
823
#   ToolsetSHLD $name, \@args, \@objs, \@libraries )
824
#       This subroutine takes the user options and builds the rules
825
#       required to link a shared library
826
#
827
#   Arguments:
828
#       --Def=xxxx.def[,opts]           # Definition file
829
#           --MutualDll                 # SubOption: Generate a Mutual DLL
830
#       --MutualDll                     # Generate a Mutual DLL (requires --Def=xxx)
831
#       --StubOnly                      # Only generate the stub library (requires --Def=xxx)
832
#       --Resource=xxxx.rc              # Resource file
833
#       --ResourceOnly                  # Only resources in this DLL
834
#       --Implib                        # Alternate ruleset
835
#       --NoPDB                         # Do not package the PDB file
836
#       --NoImplib                      # Do not package the import library
837
#       --Entry=xxxxx                   # Entry point
838
#       --NoAddLibs                     # Do not add libraries
839
#
840
#   Output:
841
#
842
#       There is two supported rule sets differentiated by --Implib
843
#       The two are very similar and generated exportable files of:
844
#
845
#       --Implib
846
#           ${name}.lib         - Stub lib adresses the versioned DLL
847
#           ${name}.${ver}.dll
848
#
849
#       Default
850
#           ${name}.lib         - Stub lib addresses UN-versioned DLL
851
#           ${name}.dll
852
#           ${name}.${ver}.dll
853
#
854
#       Note: Each DLL has an associated PDB file
855
#
856
#       Generation is identical for both rulesets. The default form does
857
#       not export any stub library associated with the versioned DLL.
858
#
859
#   Implementation notes
860
#   The process of creating a DLL and associated import library (LIB) is
861
#
862
#           ${name}.${ver}.dep
863
#           ${name}.${ver}.pdb          - Exported
864
#           ${name}.${ver}.ilk
865
#           ${name}.${ver}.dll          - Exported
866
#           ${name}.${ver}.map
867
#           ${name}.lib                 - Exported + Optional
868
#           ${name}.exp
869
#
870
#       Where:    lib = name
871
#
872
#       #.. Rules ($lib)
873
#
874
#       $(LIBDIR)/${lib}.lib:               $(LIBDIR)/${lib}.${ver}.dll
875
#       $(LIBDIR)/${lib}.pdb:               $(LIBDIR)/${lib}.${ver}.dll
876
#       $(LIBDIR)/${lib}.${ver}.pdb:        $(LIBDIR)/${lib}.${ver}.dll
877
#
878
#       $(LIBDIR)/${lib}.${ver}.dep:        SHBASE=${name}
879
#       $(LIBDIR)/${lib}.${ver}.dep:        SHNAME=${lib}.${ver}
880
#       $(LIBDIR)/${lib}.${ver}.dep:        \$(LIBDIR)
881
#       $(LIBDIR)/${lib}.${ver}.dep:        Makefile
882
#           $(SHLDDEPEND)
883
#
884
#       $(LIBDIR)/${lib}.${ver}.${so}:      SHBASE=${name}
885
#       $(LIBDIR)/${lib}.${ver}.${so}:      SHNAME=${lib}.${ver}
886
#       $(LIBDIR)/${lib}.${ver}.${so}:      CFLAGS+=$(SHCFLAGS)
887
#       $(LIBDIR)/${lib}.${ver}.${so}:      CXXLAGS+=$(SHCXXFLAGS)
888
#       $(LIBDIR)/${lib}.${ver}.${so}:      ${def}
889
#       $(LIBDIR)/${lib}.${ver}.${so}:      $(OBJDIR)/${name} \
890
#                       object list ... \
891
#                       $(LIBDIR)/${lib}.${ver}.dep
892
#           $(SHLD)
893
#           @$(cp) -f $(LIBDIR)/${lib}.${ver}.pdb $(LIBDIR)/${lib}.pdb
894
#
895
#       ifneq "$(findstring $(IFLAG),23)" ""
896
#       -include        "$(LIBDIR)/${lib}.${ver}.dep"
897
#       endif
898
#
899
#       #.. Linker commands ($lib)
900
#
901
#       ${lib}_ld       += ...
902
#               standard flags                          \
903
#               -implib:$${lib}.lib
904
#
905
#       #.. Linker commands ($lib)
906
#
907
#       ${lib}_shdp     += ...
908
#
909
###############################################################################
910
 
911
sub ToolsetSHLD
912
{
913
    our( $name, $pArgs, $pObjs, $pLibs ) = @_;
914
    our( $def, $mutual_dll, $res, @reslist, $doimplib, $stub_only );
915
    our( $no_implib, $no_pdb, $resource_only );
916
    our( $entry, $noaddlibs );
917
 
918
#.. Parse arguments
919
#
920
    $def = "";                                  # options
921
    $doimplib = 0;
922
    $res = "";
923
    $no_pdb = $pdb_none;
924
 
925
    foreach $_ ( @$pArgs ) {
926
        if (/^--Def=(.*?)(\,(.*))?$/) {         # Library definition
927
            #
928
            #   Locate the Def file.
929
            #   If it is a generate file so it will be in the SRCS hash
930
            #   Otherwise the user will have to use Src to locate the file
931
            #
932
            $def = MakeSrcResolve($1);
933
 
934
            #
935
            #   Process sub options to --Def
936
            #
937
            next unless ($2);
938
            if ( $3 =~ /^--MutualDll$/ ) {
939
                $mutual_dll = 1;
940
            } else {
941
                Message( "vcwce SHLD: unknown option $_ -- ignored\n" );
942
            }
943
 
944
        } elsif (/^--Resource=(.*)/) {          # Resource definition
945
            ($res, @reslist) = ToolsetRClist( "$name/$name", $1 );
946
 
947
        } elsif (/^--ResourceOnly/) {          # Resource definition
948
            $resource_only = 1;
949
 
950
        } elsif (/^--Implib$/) {
951
            $doimplib = 1;
952
 
953
        } elsif (/^--NoImplib$/) {
954
            $no_implib = 1;
955
 
956
        } elsif (/^--NoPDB$/) {
957
            $no_pdb = 1;
958
 
959
        } elsif (/^--Entry=(.*)/) {
960
            $entry = $1;
961
 
962
        } elsif (/^--NoAddLib/) {
963
            $noaddlibs = 1;
964
 
965
        } elsif (/^--MutualDll$/) {
966
            $mutual_dll = 1;
967
 
968
        } elsif (/^--Stubonly/) {
969
            $stub_only = 1;
970
 
971
        } else {                                # unknown
972
            Message( "vcwce SHLD: unknown option $_ -- ignored\n" );
973
        }
974
    }
975
 
976
    #
977
    #   Sanity test
978
    #
979
    Error ("vcwce SHLD:Stubonly option requires --Def=file ")
980
        if ( $stub_only && ! $def );
981
 
982
    Error ("vcwce SHLD:MutualDll option requires --Def=file ")
983
        if ( $mutual_dll && ! $def );
984
 
985
 
986
 
987
#.. Build rules
988
#
989
#   base    -   Basic name of the DLL
990
#   name    -   Name of the Export library (Optional)
991
#   lib     -   Name of the DLL
992
#
993
    sub BuildSHLD
994
    {
995
        my ($base, $name, $lib) = @_;
996
        my $full = $lib.".$::so";
997
        my $link_with_def;
998
 
999
    #.. Cleanup rules
1000
    #
1001
    #   dep     Dependency file
1002
    #   ld      Linker command file
1003
    #   map     Map file
1004
    #   pdb     Microsoft C/C++ program database
1005
    #   ilk     Microsoft Linker Database
1006
    #
1007
        ToolsetGenerate( "\$(LIBDIR)/${lib}.ld" );
1008
        ToolsetGenerate( "\$(LIBDIR)/${lib}.dep" );
1009
        ToolsetGenerate( "\$(LIBDIR)/${lib}.map" );
1010
        ToolsetGenerate( "\$(LIBDIR)/${lib}.exp" );
1011
        ToolsetGenerate( "\$(LIBDIR)/${lib}.ilk" );
1012
        ToolsetGenerate( "\$(LIBDIR)/${full}" );
1013
 
1014
    #.. Linker rules
1015
    #
1016
        my ($io) = ToolsetPrinter::New();
1017
 
1018
        my $import_lib;
1019
        my $export_file;
1020
 
1021
        if ( $name && $def && ($mutual_dll || $stub_only ) )
1022
        {
1023
            #
1024
            #   Creating an Export library from user .DEF file
1025
            #   It is possible to create the stub library in the LIB phase
1026
            #   which allows DLLs with mutual imports
1027
            #
1028
            $io->Label( "Import(stub) library for mutual exports", $name );
1029
            $export_file = "\$(LIBDIR)/${name}.exp";
1030
 
1031
            #
1032
            #   Rules and recipe to generate the stub library
1033
            #
1034
            $io->Prt( "\$(LIBDIR)/${name}.exp:\t\$(LIBDIR)/${name}.${a}\n" );
1035
            $io->Prt( "\$(LIBDIR)/${name}.${a}:\tLIBDEF=$def\n" );
1036
            $io->Prt( "\$(LIBDIR)/${name}.${a}:\tLIBNAME=$lib\n" );
1037
            $io->Entry( "\$(LIBDIR)/${name}.${a}: \\\n\t\t\$(OBJDIR)/${base}",
1038
                                            "", " \\\n\t\t", ".$::o", @$pObjs );
1039
            $io->Prt( " \\\n\t\t$def" );
1040
            $io->Prt( "\n\t\t\$(AR)\n" );
1041
            $io->Newline();
1042
 
1043
            #
1044
            #   Files to be cleanup up
1045
            #
1046
            ToolsetGenerate( "\$(LIBDIR)/${name}.exp" );
1047
            ToolsetGenerate( "\$(LIBDIR)/${name}.${a}" );
1048
 
1049
            #
1050
            #   If the DLL is being packaged/installed then add the static
1051
            #   stub library to the packaging lists as a static library
1052
            #   This will allow the stub library to be installed with the
1053
            #   static libraries and thus allow DLL's with mutual imports
1054
            #
1055
            PackageShlibAddLibFiles ($base, "\$(LIBDIR)/${name}.${a}" )
1056
                unless ($resource_only);
1057
 
1058
            #
1059
            #   Add the stub library to the list of libraries being created
1060
            #   Note: Don't do if not created with .DEF file
1061
            #
1062
            push @::LIBS, $base;
1063
 
1064
        }
1065
        else
1066
        {
1067
            #
1068
            #   The stub library is created as part of the DLL generation
1069
            #   Whether we like it or not - so we need to control the name
1070
            #   and location
1071
            #
1072
            my $slname = ($name) ? $name : $lib;
1073
            $import_lib = "\$(LIBDIR)/${slname}.${a}";
1074
 
1075
            $io->Label( "Import(stub) library", $slname );
1076
            $io->Prt( "$import_lib:\t\$(LIBDIR)/${full}\n" );
1077
            $io->Newline();
1078
 
1079
            ToolsetGenerate( $import_lib );
1080
            ToolsetGenerate( "\$(LIBDIR)/${slname}.exp" );
1081
 
1082
            #
1083
            #   Package the generated stub library, if it is being
1084
            #   created on request.
1085
            #
1086
            #   Package it with the shared libaries and not the static
1087
            #   libraries as it will be created with the shared library
1088
            #
1089
            PackageShlibAddFiles ($base, $import_lib, 'Class=lib' )
1090
                if ($name && ! $no_implib && ! $resource_only);
1091
 
1092
            #
1093
            #   Indicate that we will be linking with a DEF file
1094
            #
1095
            $link_with_def = 1 if ( $def );
1096
        }
1097
 
1098
        #
1099
        #   If we are only creating a stub library, then the hard work has been
1100
        #   done.
1101
        #
1102
        return
1103
            if ($stub_only);
1104
 
1105
        $io->Label( "Shared library", $name );
1106
 
1107
        #
1108
        #   The process of creating a DLL will generate PDB file
1109
        #   Control the name of the PDB file
1110
        #
1111
        my $pdb_file = "\$(LIBDIR)/${lib}.pdb";
1112
        unless( $no_pdb )
1113
        {
1114
            $io->Prt( "$pdb_file:\t\$(LIBDIR)/${full}\n" );
1115
            ToolsetGenerate( $pdb_file );
1116
        }
1117
 
1118
        #
1119
        #   Package the PDB file up with the DLL
1120
        #   Package the DLL - now that we know its proper name
1121
        #
1122
        PackageShlibAddFiles( $base, $pdb_file, 'Class=debug' ) unless $no_pdb ;
1123
        PackageShlibAddFiles( $base, "\$(LIBDIR)/${full}" );
1124
 
1125
        #
1126
        #   Generate Shared Library dependency information
1127
        #
1128
        $io->SHLDDEPEND( $lib, $name, $lib );   # std SHLDDEPEND rules
1129
 
1130
        #
1131
        #   Generate rules and recipes to create the body of the shared
1132
        #   library. Several build variables are overiden when creating
1133
        #   a shared library.
1134
        #
1135
        $io->Prt( "\$(LIBDIR)/${full}:\tSHBASE=${lib}\n" );
1136
        $io->Prt( "\$(LIBDIR)/${full}:\tSHNAME=${lib}\n" );
1137
        $io->Prt( "\$(LIBDIR)/${full}:\tCFLAGS+=\$(SHCFLAGS)\n" );
1138
        $io->Prt( "\$(LIBDIR)/${full}:\tCXXLAGS+=\$(SHCXXFLAGS)\n" );
1139
        $io->Prt( "\$(LIBDIR)/${full}:\t$export_file\n" ) if ($export_file );
1140
        $io->Prt( "\$(LIBDIR)/${full}:\t$res\n" ) if ( $res );
1141
 
1142
        $io->Entry( "\$(LIBDIR)/${full}: \\\n\t\t\$(OBJDIR)/${base}",
1143
            "", " \\\n\t\t", ".$::o", @$pObjs );
1144
 
1145
        $io->Prt( " \\\n\t\t$def" ) if ( $link_with_def );
1146
        $io->Prt( " \\\n\t\t\$(LIBDIR)/${lib}.dep\n" );
1147
        $io->Prt( "\t\$(SHLD)\n" );
1148
 
1149
        $io->Newline();
1150
 
1151
        #.. Linker command file
1152
        #
1153
        #       Now the fun part... piecing together a variable ${name}_shld
1154
        #       which ends up in the command file.
1155
        #
1156
        $io->SetTag( "${lib}_shld" );          # command tag
1157
 
1158
        $io->Label( "Linker commands", $name ); # label
1159
 
1160
        $io->Cmd( "-dll" );
1161
        $io->Cmd( "-noentry" )if ($resource_only);
1162
        $io->Cmd( "-def:$def" ) if ($link_with_def);
1163
        $io->Cmd( "-out:\$(subst /,\\\\,\$(LIBDIR)/${full})" );
1164
        $io->Cmd( "-implib:\$(subst /,\\\\,$import_lib)" ) if ($import_lib);
1165
        $io->Cmd( "-pdb:\$(subst /,\\\\,$pdb_file)" ) unless ( $no_pdb );
1166
        $io->Cmd( "-debug:none" )                     if ($no_pdb);
1167
        $io->Cmd( "-pdb:none" )                       if ($no_pdb);
1168
        $io->Cmd( "-entry:$entry" )                   if ($entry);
1169
        $io->Cmd( "-map:\$(subst /,\\\\,\$(LIBDIR)/${lib}).map" );
1170
        $io->Cmd( "\$(subst /,\\\\,$res)" ) if ( $res );
1171
        $io->Cmd( "\$(subst /,\\\\,$export_file)" ) if ( $export_file );
1172
 
1173
                                                # object list
1174
        $io->ObjList( $name, $pObjs, \&ToolsetObjRecipe );
1175
 
1176
                                                # library list
1177
        $io->LibList( $name, $pLibs, \&ToolsetLibRecipe );
1178
 
1179
        $io->Newline();
1180
 
1181
        #.. Dependency link,
1182
        #
1183
        #       Now piece together a variable $(name_dp) which ends up in
1184
        #       the command file building the application dependency list.
1185
        #
1186
        $io->SetTag( "${lib}_shdp" );          # command tag
1187
 
1188
        $io->DepRules( $name, $pLibs,           # library depends rules
1189
            \&ToolsetLibRecipe, "\$(LIBDIR)/${full}" );
1190
 
1191
        $io->Newline();
1192
    }
1193
 
1194
    ToolsetLibStd( $pLibs )                    # push standard libraries
1195
        unless ( $noaddlibs );
1196
 
1197
    if ( $doimplib ) {
1198
        #
1199
        #   --Implib flavor will create
1200
        #       a) Import library   $name$(GBE_TYPE).lib
1201
        #       b) Versioned DLL    $name$(GBE_TYPE).xx.xx.xx.dll
1202
        #
1203
        $target_file_dll = "\$(LIBDIR)/$name\$(GBE_TYPE).$::SHLIB_VER{ $name }.$::so";
1204
        BuildSHLD(
1205
            "$name",                                    # Base Name
1206
            "$name\$(GBE_TYPE)",                        # Name of Export Lib
1207
            "$name\$(GBE_TYPE).$::SHLIB_VER{ $name }"); # Name of the DLL + PDB
1208
 
1209
    } else {
1210
        #
1211
        #   Original flavor will create
1212
        #       a) Import library   $name$(GBE_TYPE).lib    ---+
1213
        #       b) Unversioned DLL  $name$(GBE_TYPE).dll    <--+
1214
        #       c) Versioned DLL    $name$(GBE_TYPE).xx.xx.xx.dll
1215
        #
1216
        MakePrint(
1217
            "# .. Versioned image\n\n".
1218
            "\$(LIBDIR)/${name}\$(GBE_TYPE).$::so:\t".
1219
            "\$(LIBDIR)/${name}\$(GBE_TYPE).$::SHLIB_VER{ $name }.$::so\n".
1220
            "\n" );
1221
 
1222
        $target_file_dll = "\$(LIBDIR)/$name\$(GBE_TYPE).$::so";
1223
        BuildSHLD( "$name", "$name\$(GBE_TYPE)" , "$name\$(GBE_TYPE)" );
1224
        BuildSHLD( "$name", ""                  , "$name\$(GBE_TYPE).$::SHLIB_VER{ $name }" );
1225
    }
1226
 
1227
    #.. Resource File
1228
    #
1229
    ToolsetRCrecipe( $res, @reslist )
1230
        if ( $res );
1231
}
1232
 
1233
 
1234
###############################################################################
1235
#   ToolsetSHLDLINT $name, \@args, \@objs, \@libraries )
1236
#       This subroutine takes the user options and builds the rules
1237
#       required to lint the program 'name'.
1238
#
1239
#   Arguments:
1240
#       (none)
1241
#
1242
#   Output:
1243
#       [ $(LIBDIR)/$name_lint:   .... ]
1244
#           $(SHLIBLINT)
1245
#
1246
###############################################################################
1247
 
1248
sub ToolsetSHLDLINT
1249
{
1250
    PCLintSHLIB( @_ );
1251
}
1252
 
1253
 
1254
###############################################################################
1255
#   ToolsetLD( $name, \@args, \@objs, \@libraries )
1256
#       This subroutine takes the user options and builds the rules
1257
#       required to link the program 'name'.
1258
#
1259
#   Arguments:
1260
#       (none)
1261
#
1262
#   Output:
1263
#       $(BINDIR)/name: \
1264
#                       OBJS .... \
1265
#                       $(BINDIR)/name.dep
1266
#           $(LD)
1267
#
1268
#       $(BINDIR)/name.dep: $(BINDIR)
1269
#       $(BINDIR)/name.dep: $(GBE_PLATFORM).mk
1270
#           $(LDDEPEND)
1271
#
1272
#       ifeq "$(IFLAG)" "3"
1273
#       -include        "$(BINDIR)/name.dep"
1274
#       endif
1275
#
1276
#       name_ld += ...
1277
#           :
1278
#
1279
#       name_dp += ...
1280
#           :
1281
#
1282
###############################################################################
1283
 
1284
sub ToolsetLD
1285
{
1286
    my ( $name, $pArgs, $pObjs, $pLibs ) = @_;
1287
    my ( $full ) = $name."$::exe";
1288
    my ( $res, @reslist );
1289
    my $no_pdb =$pdb_none;
1290
    our( $entry, $noaddlibs );
1291
 
1292
#.. Parse arguments
1293
#
1294
    foreach ( @$pArgs ) {
1295
        if (/^--Resource=(.*)/) {               # Resource definition
1296
            ($res, @reslist) = ToolsetRClist( $name, $1 );
1297
 
1298
        } elsif (/^--NoPDB$/) {
1299
            $no_pdb = 1;
1300
 
1301
        } elsif (/^--Entry=(.*)/) {
1302
            $entry = $1;
1303
 
1304
        } elsif (/^--NoAddLib/) {
1305
            $noaddlibs = 1;
1306
 
1307
        } else {
1308
            Message( "vcwce LD: unknown option $_ -- ignored\n" );
1309
 
1310
        }
1311
    }
1312
 
1313
#.. Cleanup rules
1314
#
1315
#   dep     Dependency file
1316
#   ld      Linker command file
1317
#   map     Map file
1318
#   pdb     Microsoft C/C++ program database
1319
#   ilk     Microsoft Linker Database
1320
#   res     Compiled resource script
1321
#
1322
    ToolsetGenerate( "\$(BINDIR)/${name}.dep" );
1323
    ToolsetGenerate( "\$(BINDIR)/${name}.ld" );
1324
    ToolsetGenerate( "\$(BINDIR)/${name}.map" );
1325
    ToolsetGenerate( "\$(BINDIR)/${name}.pdb" );
1326
    ToolsetGenerate( "\$(BINDIR)/${name}.ilk" );
1327
 
1328
#.. Linker command
1329
#
1330
    my ($io) = ToolsetPrinter::New();
1331
 
1332
    $io->Prt( "\\\n\t\t$res " ) if ( $res );
1333
    $io->Prt( "\\\n\t\t\$(BINDIR)/${name}.dep\n".
1334
              "\t\$(LD)\n\n" );
1335
 
1336
 
1337
    $io->LDDEPEND( $name );                     # standard LDDEPEND rules
1338
 
1339
#.. Linker command file
1340
#
1341
#       Now piece together a variable $(name_ld) which ends up in
1342
#       the command file linking the application.
1343
#
1344
    $io->SetTag( "${name}_ld" );                # macro tag
1345
 
1346
    $io->Label( "Linker commands", $name );     # label
1347
 
1348
    $io->Cmd( "-out:\$(subst /,\\\\,\$(BINDIR)/${full})" );
1349
    $io->Cmd( "-pdb:\$(subst /,\\\\,\$(BINDIR)/${name}).pdb" ) unless ($no_pdb);
1350
    $io->Cmd( "-debug:none" )                                  if ($no_pdb);
1351
    $io->Cmd( "-pdb:none" )                                    if ($no_pdb);
1352
    $io->Cmd( "-entry:$entry" )                                if ($entry);
1353
    $io->Cmd( "-map:\$(subst /,\\\\,\$(BINDIR)/${name}).map" );
1354
    $io->Cmd( "\$(subst /,\\\\,$res)" ) if ( $res );
1355
 
1356
    ToolsetLibStd( $pLibs )                     # push standard libraries
1357
        unless ( $noaddlibs );
1358
 
1359
                                                # object list
1360
    $io->ObjList( $name, $pObjs, \&ToolsetObjRecipe );
1361
 
1362
                                                # library list
1363
    $io->LibList( $name, $pLibs, \&ToolsetLibRecipe );
1364
 
1365
    $io->Newline();
1366
 
1367
#.. Dependencies
1368
#
1369
#       Now piece together a variable $(name_dp) which ends up in
1370
#       the command file building the application dependency list.
1371
#
1372
    $io->SetTag( "${name}_dp" );                # macro tag
1373
 
1374
    $io->DepRules( $name, $pLibs,               # library depends rules
1375
        \&ToolsetLibRecipe, "\$(BINDIR)/${full}" );
1376
 
1377
    $io->Newline();
1378
 
1379
#.. Compile up the resource file
1380
#
1381
    ToolsetRCrecipe( $res, @reslist )
1382
        if ( $res );
1383
 
1384
#.. Package up the PDB file with the program
1385
#
1386
    PackageProgAddFiles ( $name, "\$(BINDIR)/${name}.pdb", "Class=debug" ) unless ( $no_pdb );
1387
 
1388
#
1389
#   Track the name of the possible target file
1390
#   Used when creating Visual Studio projects
1391
#
1392
    $target_file_exe = "\$(BINDIR)/${full}";
1393
}
1394
 
1395
 
1396
###############################################################################
1397
#   ToolsetLD( $name, \@args, \@objs, \@libraries, \@csrc, \@cxxsrc )
1398
#       This subroutine takes the user options and builds the rules
1399
#       required to lint the program 'name'.
1400
#
1401
#   Arguments:
1402
#       (none)
1403
#
1404
#   Output:
1405
#       [ $(BINDIR)/$name_lint:   .... ]
1406
#           $(LDLINT)
1407
#
1408
###############################################################################
1409
 
1410
sub ToolsetLDLINT
1411
{
1412
    PCLintLD( @_ );
1413
}
1414
 
1415
 
1416
########################################################################
1417
#
1418
#   Push standard "system" libraries. This is a helper function
1419
#   used within this toolset.
1420
#
1421
#   Arguments:
1422
#       $plib       Reference to library array.
1423
#
1424
########################################################################
1425
 
1426
sub ToolsetLibStd
1427
{
1428
    my ($plib) = @_;
1429
 
1430
    #
1431
    #   Only add libraries if required
1432
    #
1433
    return unless( $::ScmCompilerOpts{'ADDLINKLIBS'} );
1434
 
1435
}
1436
 
1437
 
1438
########################################################################
1439
#
1440
#   Generate a linker object recipe.  This is a helper function used 
1441
#   within this toolset.
1442
#
1443
#   Arguments:
1444
#       $io         I/O stream
1445
#
1446
#       $target     Name of the target
1447
#
1448
#       $obj        Library specification
1449
#
1450
########################################################################
1451
 
1452
sub ToolsetObjRecipe
1453
{
1454
    my ($io, $target, $obj) = @_;
1455
 
1456
    $io->Cmd( "\$(subst /,\\\\,\$(strip $obj)).$::o" );
1457
}
1458
 
1459
 
1460
########################################################################
1461
#
1462
#   Generate a linker/depend library recipe.  This is a helper function
1463
#   used within this toolset.
1464
#
1465
#   Arguments:
1466
#       $io         I/O stream
1467
#
1468
#       $target     Name of the target
1469
#
1470
#       $lib        Library specification
1471
#
1472
#       $dp         If building a depend list, the full target name.
1473
#
1474
########################################################################
1475
 
1476
sub ToolsetLibRecipe
1477
{
1478
    my ($io, $target, $lib, $dp) = @_;
1479
 
1480
    return                                      # ignore (compat)
1481
        if ( $lib eq "rt" ||        $lib eq "thread" ||
1482
             $lib eq "pthread" ||   $lib eq "nsl" ||
1483
             $lib eq "socket" );
1484
 
1485
    if ( !defined($dp) ) {                      # linker
1486
        $io->Cmd( "\$(subst /,\\\\,\$(strip $lib)).$::a" );
1487
 
1488
    } else {                                    # depend
1489
        $io->Cmd( "$dp:\t@(vlib2,$lib,VC_LIB)" );
1490
    }
1491
}
1492
 
1493
 
1494
########################################################################
1495
#
1496
#   Parse resource file data
1497
#   This is a helper function used within this toolset
1498
#
1499
#   Arguments   : $1  BaseName
1500
#                 $2  The users resource list
1501
#                     This is a list of comma seperated files
1502
#                     The first file is the main resource script
1503
#
1504
#   Returns     : An array of resource files with full pathnames
1505
#                 [0] = The output file
1506
#                 [1] = The input file
1507
#                 [..] = Other input files
1508
#
1509
########################################################################
1510
 
1511
sub ToolsetRClist
1512
{
1513
    my ($name, $files) = @_;
1514
    my @result;
1515
 
1516
    #
1517
    #   Generate the name of the output file
1518
    #
1519
    push @result, "\$(OBJDIR)/$name.res";
1520
 
1521
    #
1522
    #   Process each user file
1523
    #
1524
    for (split( ',', $files ))
1525
    {
1526
        #
1527
        #   Locate the file.
1528
        #   If it is a generate file so it will be in the SRCS hash
1529
        #   Other wise the use will have to use Src to locate the file
1530
        #
1531
        push @result, MakeSrcResolve($_);
1532
    }
1533
 
1534
    #
1535
    #   Return the array to the user
1536
    #
1537
    return @result;
1538
}
1539
 
1540
 
1541
########################################################################
1542
#
1543
#   Generate a resource file recipe
1544
#   This is a helper function used within this tool
1545
#
1546
#   Arguments   : $1  Output resource file
1547
#                 ..  Input resource files
1548
#
1549
########################################################################
1550
 
1551
sub ToolsetRCrecipe
1552
{
1553
    my ($out, @in) = @_;
1554
 
1555
    #
1556
    #   Cleanup
1557
    #
1558
    ToolsetGenerate( $out );
1559
 
1560
    #
1561
    #   Recipe
1562
    #
1563
    MakePrint( "\n#.. Compile Resource file: $out\n\n" );
1564
    MakePrint( "$out:\t\$(GBE_PLATFORM).mk\n" );
1565
    MakeEntry( "$out:\t", "", "\\\n\t\t", " ", @in );
1566
    MakePrint( "\n\t\$(RC)\n" );
1567
    MakePrint( "\n" );
1568
}
1569
 
1570
########################################################################
1571
#
1572
#   Generate a project from the provided project file
1573
#
1574
#   Arguments   : $name             - Base name of the project
1575
#                 $project          - Path to the project file
1576
#                 $pArgs            - Project specific options
1577
#
1578
########################################################################
1579
 
1580
my $project_defines_done = 0;
1581
sub ToolsetPROJECT
1582
{
1583
    my( $name, $project, $pArgs ) = @_;
1584
 
1585
    #
1586
    #   Process options
1587
    #
1588
    foreach ( @$pArgs ) {
1589
        Message( "vcwce PROJECT: unknown option $_ -- ignored\n" );
1590
    }
1591
    my ($io) = ToolsetPrinter::New();
1592
 
1593
    #
1594
    #   Setup toolset pecific difinitions. Once
1595
    #
1596
    unless( $project_defines_done )
1597
    {
1598
        $project_defines_done = 1;
1599
        $io->PrtLn( "ifeq \"\$(DEBUG)\" \"1\"");
1600
        $io->PrtLn( "PROJECT_CMD\t:= DEBUG");
1601
        $io->PrtLn( "else");
1602
        $io->PrtLn( "PROJECT_CMD\t:= RELEASE");
1603
        $io->PrtLn( "endif");
1604
        $io->Newline();
1605
    }
1606
 
1607
    #
1608
    #   Generate the recipe to create the project
1609
    #
1610
    $io->Label( "Build project", $name );
1611
    $io->PrtLn( "Project_$name: $project" );
255 dpurdie 1612
    $io->PrtLn( "\t\$(XX_PRE)( \$(show_environment); \\" );
1613
    $io->PrtLn( "\tevc $project /make \"ALL - \$(PROJECT_CMD)\" /use_env /CEConfig=\"\$(WCE_PLATFORM)\" /out $name\$(GBE_TYPE).log; \\" );
227 dpurdie 1614
    $io->PrtLn( "\tret=\$\$?; \\" );
1615
    $io->PrtLn( "\t\$(GBE_BIN)/cat $name\$(GBE_TYPE).log; \\" );
1616
    $io->PrtLn( "\texit \$\$ret )" );
1617
    $io->Newline();
1618
 
1619
    #
1620
    #   Generate the recipe to clean the project
1621
    #
1622
    $io->Label( "Clean project", $name );
1623
    $io->PrtLn( "ProjectClean_$name: $project" );
1624
    $io->PrtLn( "\t-\$(XX_PRE)evc $project /make \"ALL - \$(PROJECT_CMD)\" /clean /use_env /CEConfig=\"\$(WCE_PLATFORM)\"" );
1625
    $io->PrtLn( "\t-\$(XX_PRE)\$(rm) $name\$(GBE_TYPE).log" );
1626
    $io->Newline();
1627
 
1628
}
1629
 
1630
 
1631
#.. Successful termination
1632
1;
1633