Subversion Repositories DevTools

Rev

Rev 7299 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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