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