Subversion Repositories DevTools

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
227 dpurdie 1
#
2
# Module name   : vcwin32
3
# Module type   : Makefile system
4
# Compiler(s)   : ANSI C
5
# Environment(s): WIN32
6
#
7
# Description:
8
#       Visual C/C++ for WIN32
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 = 'vcwin32';                           # Toolset name : Error reporting
227 dpurdie 25
 
26
##############################################################################
27
#   Version information
28
#
29
my $toolset_info;
30
my $toolset_version = 'MSVC6';
31
my %ToolsetVersion =
32
    (
255 dpurdie 33
        'MSVC6'      =>  { 'def'        => 'vcwin32.def' ,
343 dpurdie 34
                           'buildcmd'   => 'msdev =DSW= /make =TYPE= /useenv /out =LOG=' ,
35
                           'cleancmd'   => 'msdev =DSW= /make =TYPE= /clean /useenv' ,
255 dpurdie 36
                           'tmp'        => 'vc60',
37
                           'VSCOMPILER' => '1',
343 dpurdie 38
                           'def_targets' => [ 'ALL - RELEASE','ALL - DEBUG' ],
255 dpurdie 39
                           },
227 dpurdie 40
 
255 dpurdie 41
        'MS.NET2003' =>  { 'def'        => 'vcwin32_net2003.def' ,
42
                           'buildcmd'   => 'devenv =DSW= /build =TYPE= /useenv /out =LOG=' ,
43
                           'cleancmd'   => 'devenv =DSW= /clean =TYPE= /useenv' ,
44
                           'tmp'        => 'vc70',
45
                           'VSCOMPILER' => '2',
46
                           },
47
 
48
        'MS.NET2005' =>  { 'def'        => 'vcwin32_net2005.def' ,
49
                           'buildcmd'   => 'devenv =DSW= /build =TYPE= /useenv /out =LOG=' ,
50
                           'cleancmd'   => 'devenv =DSW= /clean =TYPE= /useenv' ,
51
                           'tmp'        => 'vc80',
52
                           'VSCOMPILER' => '3',
53
                           'GenManifest' => '1',
54
                           },
291 dpurdie 55
 
56
        'MS.NET2008' =>  { 'def'        => 'vcwin32_net2008.def' ,
57
                           'buildcmd'   => 'devenv =DSW= /build =TYPE= /useenv /out =LOG=' ,
58
                           'cleancmd'   => 'devenv =DSW= /clean =TYPE= /useenv' ,
59
                           'tmp'        => 'vc90',
60
                           'VSCOMPILER' => '3',
61
                           'GenManifest' => '1',
62
                           },
347 dpurdie 63
 
64
        'MS.NET2010' =>  { 'def'        => 'vcwin32_net2010.def' ,
65
                           'buildcmd'   => 'devenv =DSW= /build =TYPE= /useenv /out =LOG=' ,
66
                           'cleancmd'   => 'devenv =DSW= /clean =TYPE= /useenv' ,
67
                           'tmp'        => 'vc100',
68
                           'VSCOMPILER' => '3',
69
                           'GenManifest' => '1',
70
                           },
291 dpurdie 71
 
347 dpurdie 72
 
227 dpurdie 73
    );
74
 
75
 
76
##############################################################################
77
#   ToolsetInit()
78
#       Runtime initialisation
79
#
80
##############################################################################
81
 
82
ToolsetInit();
83
 
84
sub ToolsetInit
85
{
86
 
87
#.. Parse arguments (Toolset arguments)
88
#
343 dpurdie 89
    Debug( "$toolset_name(@::ScmToolsetArgs)" );
227 dpurdie 90
 
91
    foreach $_ ( @::ScmToolsetArgs ) {
92
        if (/^--Version=(.*)/) {           # MS SDK Version
93
            $toolset_version = $1;
94
 
95
        } else {
343 dpurdie 96
            Message( "$toolset_name toolset: unknown option $_ -- ignored\n" );
227 dpurdie 97
        }
98
    }
99
 
100
#.. Parse arguments (platform arguments)
101
#
343 dpurdie 102
    Debug( "$toolset_name(@::ScmPlatformArgs)" );
227 dpurdie 103
 
104
    foreach $_ ( @::ScmPlatformArgs ) {
105
        if (/^--product=(.*)/) {                # GBE product
106
 
107
        } elsif (/^--Version=(.*)/) {           # MS SDK Version
108
            $toolset_version = $1;
109
 
110
        } elsif (/^--NoDinkumware/) {           # Dinkumware package test
111
 
112
        } else {
343 dpurdie 113
            Message( "$toolset_name toolset: unknown platform argument $_ -- ignored\n" );
227 dpurdie 114
        }
115
    }
116
 
117
#.. Validate SDK version
255 dpurdie 118
#   Currently three versions are supported
227 dpurdie 119
#       1) MSVC6            - As provided via Visual Studio
120
#       2) MSVS.net 2003    - Used to create .NET applications
255 dpurdie 121
#       2) MSVS.net 2005    - Used to create .NET applications
227 dpurdie 122
#
123
    $toolset_info = $ToolsetVersion{$toolset_version};
124
    Error( "Unknown version: $toolset_version" ) unless ( defined $toolset_info );
125
 
126
 
127
#.. Standard.rul requirements
128
#
129
    $::s = 'asm';
130
    $::o = 'obj';
131
    $::a = 'lib';
132
    $::so = 'dll';
133
    $::exe = '.exe';
134
 
135
#.. Toolset configuration
136
#
137
    $::ScmToolsetVersion = "1.0.0";             # our version
138
    $::ScmToolsetGenerate = 0;                  # generate optional
261 dpurdie 139
    $::ScmToolsetProgDependancies = 0;          # handle Prog dependancies myself
227 dpurdie 140
 
141
#.. define Visual C/C+ environment
142
    Init( "visualc" );
143
    ToolsetDefines( $toolset_info->{'def'} );
255 dpurdie 144
    PlatformDefine ("VSCOMPILER\t= $toolset_info->{'VSCOMPILER'}" );
227 dpurdie 145
    ToolsetRequire( "exctags" );                # and Exuberant Ctags
146
    ToolsetRules( "vcwin32.rul" );
147
    ToolsetRules( "standard.rul" );
148
 
149
#.. define PCLint envrionment
150
    ToolsetRequire( "pclint" );                 # using pclint
151
    PlatformDefine ("LINT_COFILE\t= co-msc60.lnt");
152
    PlatformDefine ("LINT_PRJ_FILE\t=lint.visualc");
153
 
154
#.. Cleanup rules
155
#
156
    ToolsetGenerate( "\$(OBJDIR)/$toolset_info->{'tmp'}.idb" );     # vc60.idb
157
    ToolsetGenerate( "\$(OBJDIR)/$toolset_info->{'tmp'}.pch" );
158
    ToolsetGenerate( "\$(OBJDIR)/$toolset_info->{'tmp'}.pdb" );
159
    ToolsetGenerate( "\$(PDB)" );
160
    ToolsetGenerate( "\$(PDB).tmp" );
161
 
162
 
163
#
164
#   The PDB files need to be compiled up with absolute paths to the source files
165
#   The easiest way to do this is with the makefile rules created with absolute
166
#   paths. Set a global flag to enable this option
167
#
168
    $::UseAbsObjects = 1;
169
 
170
 
171
#.. Extend the CompilerOption directive
172
#   Create a standard data structure
173
#   This is a hash of hashes
174
#       The first hash is keyed by CompileOption keyword
175
#       The second hash contains pairs of values to set or remove
176
#
177
    %::ScmToolsetCompilerOptions =
178
    (
179
        #
180
        #   Control the thread model to use
181
        #   This will affect the compiler options and the linker options
182
        #
183
        'multithread_static' => { 'THREADMODE' , 'T' },      # -MT
184
        'multithread_dll'    => { 'THREADMODE' , 'D' },      # -MD Default
185
        'multithread_none'   => { 'THREADMODE' , 'L' },      # -ML
186
 
187
        'subsystem:windows'  => { 'LDSUBSYSTEM' , 'windows' },
188
        'subsystem:console'  => { 'LDSUBSYSTEM' , 'console' },
189
 
190
        'rtti'               => { 'USE_RTTI', 1 },
191
        'nopdb'              => { 'PDB_NONE', 1 },
192
        'pdb'                => { 'PDB_NONE', undef },
193
        'noaddlibs'          => { 'ADDLINKLIBS' , undef },      # Don't add link libs
194
        'addlibs'            => { 'ADDLINKLIBS' , '1' },        # default
195
        'noprecompilehdrs'   => { 'PRECOMPILEHDRS' , undef },   # Don't precompile headers
196
        'precompilehdrs'     => { 'PRECOMPILEHDRS' , '1' },     # default
197
 
198
        #
199
        #   Mimic some of the behavior of version-1 JATS
200
        #
201
        'jats_v1'            => { 'USE_JATS_V1' => '1' },
202
    );
203
 
204
    #
205
    #   Set default options
206
    #
207
    $::ScmCompilerOpts{'THREADMODE'} = 'D';
208
    $::ScmCompilerOpts{'ADDLINKLIBS'} = '1';
209
    $::ScmCompilerOpts{'PRECOMPILEHDRS'} = '1';
210
}
211
 
212
##############################################################################
213
#   ToolsetPreprocess()
214
#       Process collected data before the makefile is generated
215
#       This, optional, routine is called from within MakefileGenerate()
216
#       It allows the toolset to massage any of the collected data before
217
#       the makefile is created
218
#
219
##############################################################################
220
sub ToolsetPreprocess
221
{
222
    #
223
    #   Extract the current state of PDB_NONE
224
    #   Are PDB files to be constructed.
225
    #
226
    $pdb_none = $::ScmCompilerOpts{'PDB_NONE'};
227
}
228
 
229
##############################################################################
230
#   ToolsetPostprocess
231
#       Process collected data as the makefile is generated
232
#       This, optional, routine is called from within MakefileGenerate()
233
#       It allows the toolset to massage any of the collected data before
234
#       the makefile is finally closed created
235
#
236
##############################################################################
237
 
238
sub ToolsetPostprocess
239
{
267 dpurdie 240
    MakeHeader('Toolset Postprocessed Information');
227 dpurdie 241
 
242
    #
243
    #   Specify the name of the global PDB file. This is used for all
244
    #   compiles other than those associated with building a DLL
245
    #
246
    #   The name of the PDB will be based on either
247
    #       The name of base package
248
    #       The name of the first static library created
249
    #
250
 
251
MakePrint("
252
#
253
#   Export the name of the common PDB file
254
#   All compiler information will be placed in this file
255
#   The name of the file MUST be the same as the name of the output library
256
#
257
PDB		= \$(OBJDIR)/$pdb_file\$(GBE_TYPE).pdb
258
" );
259
 
260
    #
261
    #   Add values to the perl environment
262
    #   May be used by post processing tools to create Visual Studio Projects
263
    #
264
    $::TS_pdb_file = "\$(OBJDIR)/$pdb_file\$(GBE_TYPE).pdb" unless( $pdb_none );
265
    $::TS_sbr_support = 1;
266
 
267
    #
268
    #   Prioritorise target: EXE, DLL, LIB
269
    #
270
    for my $tgt ( $target_file_exe, $target_file_dll, $target_file_lib  )
271
    {
272
        if ( $tgt )
273
        {
274
            $::TS_target_file = $tgt;
275
            last;
276
        }
277
    }
278
}
279
 
280
 
281
###############################################################################
282
#   ToolsetCTAGS()
283
#       This subroutine takes the user options and builds the rules
284
#       required to build the CTAGS database.
285
#
286
#   Arguments:
287
#       --xxx                   No arguments currently defined
288
#
289
#   Output:
290
#       [ctags:]
291
#           $(EXCTAGS)
292
#
293
###############################################################################
294
 
295
sub ToolsetCTAGS
296
{
297
    EXCTAGS( @_ );
298
}
299
 
300
 
301
###############################################################################
302
#   ToolsetCC( $source, $obj, \@args )
303
#       This subroutine takes the user options and builds the rule(s)
304
#       required to compile the source file 'source' to 'obj'
305
#
306
###############################################################################
307
 
308
sub ToolsetCC
309
{
310
    ToolsetCC_common( "CC", @_ );
311
}
312
 
313
sub ToolsetCC_common
314
{
315
    my( $name, $source, $obj, $pArgs ) = @_;
316
    my( $cflags, $pdb );
317
 
318
    foreach $_ ( @$pArgs ) {
319
        if (/--Shared$/) {                      # Building a 'shared' object
320
            $cflags = "$cflags \$(SHCFLAGS)";
321
            $pdb = $::SHOBJ_LIB{$obj}
322
                if (exists $::SHOBJ_LIB{$obj} );
323
 
324
        } else {
343 dpurdie 325
            Message( "$toolset_name $name: unknown option $_ -- ignored\n" );
227 dpurdie 326
        }
327
    }
328
 
329
    MakePrint( "\n\t\$($name)\n" );
330
    MakePadded( 4, "\$(OBJDIR)/$obj.$::o:", "\tCFLAGS +=$cflags\n" )
331
        if ( $cflags );                         # object specific CFLAGS
332
 
333
    if ( $pdb && !$pdb_none )
334
    {
335
        #
336
        #   Determine the name of the PDB file
337
        #   If we are building a shared library then the name of the PDB
338
        #   MUST NOT be the same as the name of the library as there is
339
        #   some stange interaction with the linker ( 50% of the time )
340
        #   This is OK as the file will not be published
341
        #
342
        #   If building a static library then create a PDB of the same
343
        #   name as it may be published directly.
344
        #
345
        my $pdb_file;
346
        if ($cflags )
347
        {
348
            $pdb_file = "\$(OBJDIR)/${pdb}\$(GBE_TYPE)_shlib.pdb";
349
        }
350
        else
351
        {
352
            $pdb_file = "\$(OBJDIR)/${pdb}\$(GBE_TYPE).pdb";
353
        }    
354
 
355
        MakePadded( 4, "\$(OBJDIR)/$obj.$::o:", "\tPDB = $pdb_file\n" );
356
        ToolsetGenerate( $pdb_file );
357
        ToolsetGenerate( $pdb_file . ".tmp" );
358
    }
359
 
360
    #
361
    #   Remove possible Source Browser Files
362
    #
363
    ToolsetGenerate( "\$(OBJDIR)/$obj.sbr" );
364
    MakePrint( "\n" );
365
}
366
 
367
 
368
###############################################################################
369
#   ToolsetCCDepend( $depend, \@sources )
370
#       This subroutine takes the user options and builds the
371
#       rule(s) required to build the dependencies for the source
372
#       files 'sources' to 'depend'.
373
#
374
###############################################################################
375
 
376
sub ToolsetCCDepend
377
{
378
    MakePrint( "\t\$(CCDEPEND)\n" );
379
}
380
 
381
 
382
###############################################################################
383
#   ToolsetCXX( $source, $obj, \@args )
384
#       This subroutine takes the user options and builds the rule(s)
385
#       required to compile the source file 'source' to 'obj'
386
#
387
###############################################################################
388
 
389
sub ToolsetCXX
390
{
391
    ToolsetCC_common( "CXX", @_ );
392
}
393
 
394
###############################################################################
395
#   ToolsetCXXDepend( $depend, \@sources )
396
#       This subroutine takes the user options and builds the
397
#       rule(s) required to build the dependencies for the source
398
#       files 'sources' to 'depend'.
399
#
400
###############################################################################
401
 
402
sub ToolsetCXXDepend
403
{
287 dpurdie 404
    ToolsetCCDepend();
227 dpurdie 405
}
406
 
407
 
408
###############################################################################
409
#   ToolsetAS( $source, $obj, \@args )
410
#       This subroutine takes the user options and builds the rule(s)
411
#       required to compile the source file 'source' to 'obj'
412
#
413
###############################################################################
414
 
415
sub ToolsetAS
416
{
417
    MakePrint( "\n\t\$(AS)\n" );
418
}
419
 
420
sub ToolsetASDepend
421
{
422
}
423
 
424
###############################################################################
425
#   ToolsetAR( $name, \@args, \@objs )
426
#       This subroutine takes the user options and builds the rules
427
#       required to build the library 'name'.
428
#
429
#   Arguments:
430
#       --Def=name              Library definition module
431
#
432
#   Output:
433
#       [ $(LIBDIR)/name$.${a}:   .... ]
434
#           $(AR)
435
#
436
###############################################################################
437
 
438
sub ToolsetAR
439
{
440
    my( $name, $pArgs, $pObjs ) = @_;
441
    my( $def );
442
    my ( $res, @reslist );
443
    my $lib_base = "\$(LIBDIR)/${name}\$(GBE_TYPE)";
444
    my $lib_name = "$lib_base.${a}";
445
 
446
 
447
#.. Parse arguments
448
#
449
    $def = "";                                  # options
450
    $res = "";
451
 
452
    foreach $_ ( @$pArgs ) {
453
        if (/^--Def=(.*)/) {                    # library definition
454
            $def = "$1";
455
 
456
        } elsif (/^--Resource=(.*)/) {          # Resource definition
457
            ($res, @reslist) = ToolsetRClist( "$name", $1 );
458
 
459
        } else {                                # unknown
343 dpurdie 460
            Message( "$toolset_name AR: unknown option $_ -- ignored\n" );
227 dpurdie 461
        }
462
    }
463
 
464
#.. Resource Creation
465
#
466
    MakePrint( "#.. Library Resource ($name)\n\n" );
467
    ToolsetRCrecipe( $res, @reslist )
468
        if ( $res );
469
 
470
#.. Target
471
#
472
    MakePrint( "#.. Library ($name)\n\n" );     # label
473
 
474
    MakePrint( "$lib_name:\tLIBDEF=$def\n" ) if ($def);
475
    MakeEntry( "$lib_name:\t", "", "\\\n\t\t", ".$::o", @$pObjs );
476
    MakePrint( "\\\n\t\t$def" ) if ($def);
477
    MakePrint( "\\\n\t\t$res" ) if ($res);
478
    MakePrint( "\n\t\$(AR)" );
479
 
480
#
481
#   Track the name of the possible target file
482
#   Used when creating Visual Studio projects
483
#
484
    $target_file_lib = $lib_name;
485
 
486
#
487
#   To assist in debugging the static library it is nice to
488
#   keep the PDB file used to build the library, with the library.
489
#
490
#   If the library is being packaged or installed then add the PDB
491
#   file to the package / installation
492
#
493
#   NOTE: Due to the limitations of JATS/MicroSoft only one static
494
#   library can be built with a PDB file. The name of the PDB file
495
#   will be taken from the first static library encountered
496
#
497
    unless ( $pdb_first_lib )
498
    {
499
        $pdb_first_lib = $name;
500
        $pdb_file = $name;
501
    }
502
    else
503
    {
504
        Warning( "Multiple static libraries created with a common PDB file: $pdb_file, $name" )
505
            unless( $pdb_none );
506
    }
507
 
508
    PackageLibAddFiles( $name, "\$(OBJDIR)/$pdb_file\$(GBE_TYPE).pdb", "Class=debug" )
509
        unless( $pdb_none );
510
}
511
 
512
 
513
###############################################################################
514
#   ToolsetARLINT( $name, \@args, \@objs )
515
#       This subroutine takes the user options and builds the rules
516
#       required to build the library 'name'.
517
#
518
#   Arguments:
519
#       --xxx                   No arguments currently defined
520
#
521
#   Output:
522
#       [ $(LIBDIR)/name$_lint:   .... ]
523
#           $(ARLINT)
524
#
525
###############################################################################
526
 
527
sub ToolsetARLINT
528
{
529
    PCLintAR( @_ );
530
}
531
 
532
 
533
###############################################################################
534
#   ToolsetARMerge( $name, \@args, \@libs )
535
#       This subroutine takes the user options and builds the rules
536
#       required to build the library 'name' by merging the specified
537
#       libaries
538
#
539
#   Arguments:
540
#       --xxx                   No arguments currently defined
541
#
542
#   Output:
543
#       [ $(LIBDIR)/name$.${a}:   .... ]
544
#           ...
545
#
546
###############################################################################
547
 
548
sub ToolsetARMerge
549
{
550
    my ($name, $pArgs, $pLibs) = @_;
551
    MakePrint( "\n\t\$(ARMERGE)\n\n" );
552
 
553
    #
554
    #   Package up the PDB's with the library
555
    #   Note: The PDBs will be found in the OBJDIR
556
    #
557
    unless( $pdb_none )
558
    {
559
        for ( @{$pLibs} )
560
        {
561
            s~\$\(LIBDIR\)~\$(OBJDIR)~;
562
            PackageLibAddFiles( $name, "$_\$(GBE_TYPE).pdb", "Class=debug" );
563
        }
564
    }
565
}
566
 
567
 
568
###############################################################################
289 dpurdie 569
#   ToolsetSHLD $name, \@args, \@objs, \@libraries, $_ver )
227 dpurdie 570
#       This subroutine takes the user options and builds the rules
571
#       required to link a shared library
572
#
573
#   Arguments:
574
#       --Def=xxxx.def[,opts]           # Definition file
575
#           --MutualDll                 # SubOption: Generate a Mutual DLL
576
#       --MutualDll                     # Generate a Mutual DLL (requires --Def=xxx)
577
#       --StubOnly                      # Only generate the stub library (requires --Def=xxx)
578
#       --Resource=xxxx.rc              # Resource file
579
#       --ResourceOnly                  # Only resources in this DLL
580
#       --Implib                        # Alternate ruleset
581
#       --NoPDB                         # Do not package the PDB file
582
#       --NoImplib                      # Do not package the import library
583
#       --Entry=xxxxx                   # Entry point
584
#       --NoAddLibs                     # Do not add libraries
585
#
586
#   Output:
587
#
588
#       There is two supported rule sets differentiated by --Implib
589
#       The two are very similar and generated exportable files of:
590
#
591
#       --Implib
592
#           ${name}.lib         - Stub lib adresses the versioned DLL
593
#           ${name}.${ver}.dll
594
#
595
#       Default
596
#           ${name}.lib         - Stub lib addresses UN-versioned DLL
597
#           ${name}.dll
598
#           ${name}.${ver}.dll
599
#
600
#       Note: Each DLL has an associated PDB file
601
#
602
#       Generation is identical for both rulesets. The default form does
603
#       not export any stub library associated with the versioned DLL.
604
#
605
#   Implementation notes
606
#   The process of creating a DLL and associated import library (LIB) is
607
#
608
#           ${name}.${ver}.dep
609
#           ${name}.${ver}.pdb          - Exported
610
#           ${name}.${ver}.ilk
611
#           ${name}.${ver}.dll          - Exported
612
#           ${name}.${ver}.map
613
#           ${name}.lib                 - Exported + Optional
614
#           ${name}.exp
615
#
616
#       Where:    lib = name
617
#
618
#       #.. Rules ($lib)
619
#
620
#       $(LIBDIR)/${lib}.lib:               $(LIBDIR)/${lib}.${ver}.dll
621
#       $(LIBDIR)/${lib}.pdb:               $(LIBDIR)/${lib}.${ver}.dll
622
#       $(LIBDIR)/${lib}.${ver}.pdb:        $(LIBDIR)/${lib}.${ver}.dll
623
#
624
#       $(LIBDIR)/${lib}.${ver}.dep:        SHBASE=${name}
625
#       $(LIBDIR)/${lib}.${ver}.dep:        SHNAME=${lib}.${ver}
626
#       $(LIBDIR)/${lib}.${ver}.dep:        \$(LIBDIR)
627
#       $(LIBDIR)/${lib}.${ver}.dep:        Makefile
628
#           $(SHLDDEPEND)
629
#
630
#       $(LIBDIR)/${lib}.${ver}.${so}:      SHBASE=${name}
631
#       $(LIBDIR)/${lib}.${ver}.${so}:      SHNAME=${lib}.${ver}
632
#       $(LIBDIR)/${lib}.${ver}.${so}:      CFLAGS+=$(SHCFLAGS)
633
#       $(LIBDIR)/${lib}.${ver}.${so}:      CXXLAGS+=$(SHCXXFLAGS)
634
#       $(LIBDIR)/${lib}.${ver}.${so}:      ${def}
635
#       $(LIBDIR)/${lib}.${ver}.${so}:      $(OBJDIR)/${name} \
636
#                       object list ... \
637
#                       $(LIBDIR)/${lib}.${ver}.dep
638
#           $(SHLD)
639
#           @$(cp) -f $(LIBDIR)/${lib}.${ver}.pdb $(LIBDIR)/${lib}.pdb
640
#
641
#       ifneq "$(findstring $(IFLAG),23)" ""
642
#       -include        "$(LIBDIR)/${lib}.${ver}.dep"
643
#       endif
644
#
645
#       #.. Linker commands ($lib)
646
#
647
#       ${lib}_ld       += ...
648
#               standard flags                          \
649
#               -implib:$${lib}.lib
650
#
651
#       #.. Linker commands ($lib)
652
#
653
#       ${lib}_shdp     += ...
654
#
655
###############################################################################
656
 
657
sub ToolsetSHLD
658
{
289 dpurdie 659
    our( $name, $pArgs, $pObjs, $pLibs, $_ver ) = @_;
227 dpurdie 660
    our( $def, $mutual_dll, $res, @reslist, $doimplib, $stub_only );
661
    our( $no_implib, $no_pdb, $resource_only );
662
    our( $entry, $noaddlibs );
663
 
664
#.. Parse arguments
665
#
666
    $def = "";                                  # options
667
    $doimplib = 0;
668
    $res = "";
669
    $no_pdb = $pdb_none;
670
 
671
    foreach $_ ( @$pArgs ) {
672
        if (/^--Def=(.*?)(\,(.*))?$/) {         # Library definition
673
            #
674
            #   Locate the Def file.
675
            #   If it is a generate file so it will be in the SRCS hash
676
            #   Otherwise the user will have to use Src to locate the file
677
            #
678
            $def = MakeSrcResolve($1);
679
 
680
            #
681
            #   Process sub options to --Def
682
            #
683
            next unless ($2);
684
            if ( $3 =~ /^--MutualDll$/ ) {
685
                $mutual_dll = 1;
686
            } else {
343 dpurdie 687
                Message( "$toolset_name SHLD: unknown option $_ -- ignored\n" );
227 dpurdie 688
            }
689
 
690
        } elsif (/^--Resource=(.*)/) {          # Resource definition
691
            ($res, @reslist) = ToolsetRClist( "$name/$name", $1 );
692
 
693
        } elsif (/^--ResourceOnly/) {          # Resource definition
694
            $resource_only = 1;
695
 
696
        } elsif (/^--Implib$/) {
697
            $doimplib = 1;
698
 
699
        } elsif (/^--NoImplib$/) {
700
            $no_implib = 1;
701
 
702
        } elsif (/^--NoPDB$/) {
703
            $no_pdb = 1;
704
 
705
        } elsif (/^--Entry=(.*)/) {
706
            $entry = $1;
707
 
708
        } elsif (/^--NoAddLib/) {
709
            $noaddlibs = 1;
710
 
711
        } elsif (/^--MutualDll$/) {
712
            $mutual_dll = 1;
713
 
714
        } elsif (/^--Stubonly/) {
715
            $stub_only = 1;
716
        } else {                                # unknown
343 dpurdie 717
            Message( "$toolset_name SHLD: unknown option $_ -- ignored\n" );
227 dpurdie 718
        }
719
    }
720
 
721
    #
722
    #   Sanity test
723
    #
343 dpurdie 724
    Error ("$toolset_name SHLD:Stubonly option requires --Def=file ")
227 dpurdie 725
        if ( $stub_only && ! $def );
726
 
343 dpurdie 727
    Error ("$toolset_name SHLD:MutualDll option requires --Def=file ")
227 dpurdie 728
        if ( $mutual_dll && ! $def );
729
 
730
 
731
 
732
#.. Build rules
733
#
734
#   base    -   Basic name of the DLL
735
#   name    -   Name of the Export library (Optional)
736
#   lib     -   Name of the DLL
737
#
738
    sub BuildSHLD
739
    {
740
        my ($base, $name, $lib) = @_;
741
        my $full = $lib.".$::so";
742
        my $link_with_def;
743
 
744
    #.. Cleanup rules
745
    #
746
    #   ld      Linker command file
747
    #   map     Map file
748
    #   pdb     Microsoft C/C++ program database
749
    #   ilk     Microsoft Linker Database
750
    #
751
        ToolsetGenerate( "\$(LIBDIR)/${lib}.ld" );
752
        ToolsetGenerate( "\$(LIBDIR)/${lib}.map" );
753
        ToolsetGenerate( "\$(LIBDIR)/${lib}.exp" );
754
        ToolsetGenerate( "\$(LIBDIR)/${lib}.ilk" );
755
        ToolsetGenerate( "\$(LIBDIR)/${full}" );
255 dpurdie 756
        ToolsetGenerate( "\$(LIBDIR)/${full}.manifest" ) if $toolset_info->{'GenManifest'};
227 dpurdie 757
 
758
    #.. Linker rules
759
    #
760
        my ($io) = ToolsetPrinter::New();
761
 
762
        my $import_lib;
763
        my $export_file;
764
 
765
        if ( $name && $def && ($mutual_dll || $stub_only ) )
766
        {
767
            #
768
            #   Creating an Export library from user .DEF file
769
            #   It is possible to create the stub library in the LIB phase
770
            #   which allows DLLs with mutual imports
771
            #
772
            $io->Label( "Import(stub) library for mutual exports", $name );
773
            $export_file = "\$(LIBDIR)/${name}.exp";
774
 
775
            #
776
            #   Rules and recipe to generate the stub library
777
            #
778
            $io->Prt( "\$(LIBDIR)/${name}.exp:\t\$(LIBDIR)/${name}.${a}\n" );
779
            $io->Prt( "\$(LIBDIR)/${name}.${a}:\tLIBDEF=$def\n" );
780
            $io->Prt( "\$(LIBDIR)/${name}.${a}:\tLIBNAME=$lib\n" );
781
            $io->Entry( "\$(LIBDIR)/${name}.${a}: \\\n\t\t\$(OBJDIR)/${base}",
782
                                            "", " \\\n\t\t", ".$::o", @$pObjs );
783
            $io->Prt( " \\\n\t\t$def" );
784
            $io->Prt( "\n\t\t\$(AR)\n" );
785
            $io->Newline();
786
 
787
            #
788
            #   Files to be cleanup up
789
            #
790
            ToolsetGenerate( "\$(LIBDIR)/${name}.exp" );
791
            ToolsetGenerate( "\$(LIBDIR)/${name}.${a}" );
792
 
793
            #
794
            #   If the DLL is being packaged/installed then add the static
795
            #   stub library to the packaging lists as a static library
796
            #   This will allow the stub library to be installed with the
797
            #   static libraries and thus allow DLL's with mutual imports
798
            #
799
            PackageShlibAddLibFiles ($base, "\$(LIBDIR)/${name}.${a}" )
800
                unless ($resource_only);
801
 
802
            #
803
            #   Add the stub library to the list of libraries being created
804
            #   Note: Don't do if not created with .DEF file
805
            #
806
            push @::LIBS, $base;
807
 
808
        }
809
        else
810
        {
811
            #
812
            #   The stub library is created as part of the DLL generation
813
            #   Whether we like it or not - so we need to control the name
814
            #   and location
815
            #
816
            my $slname = ($name) ? $name : $lib;
817
            $import_lib = "\$(LIBDIR)/${slname}.${a}";
818
 
819
            $io->Label( "Import(stub) library", $slname );
820
            $io->Prt( "$import_lib:\t\$(LIBDIR)/${full}\n" );
821
            $io->Newline();
822
 
823
            ToolsetGenerate( $import_lib );
824
            ToolsetGenerate( "\$(LIBDIR)/${slname}.exp" );
825
 
826
            #
827
            #   Package the generated stub library, if it is being
828
            #   created on request.
829
            #
830
            #   Package it with the shared libaries and not the static
831
            #   libraries as it will be created with the shared library
832
            #
833
            PackageShlibAddFiles ($base, $import_lib, 'Class=lib' )
834
                if ($name && ! $no_implib && ! $resource_only);
835
 
836
            #
837
            #   Indicate that we will be linking with a DEF file
838
            #
839
            $link_with_def = 1 if ( $def );
840
        }
841
 
842
        #
843
        #   If we are only creating a stub library, then the hard work has been
844
        #   done.
845
        #
846
        return
847
            if ($stub_only);
848
 
849
        $io->Label( "Shared library", $name );
850
 
851
        #
852
        #   The process of creating a DLL will generate PDB file
853
        #   Control the name of the PDB file
854
        #
855
        my $pdb_file = "\$(LIBDIR)/${lib}.pdb";
856
        unless( $no_pdb )
857
        {
858
            $io->Prt( "$pdb_file:\t\$(LIBDIR)/${full}\n" );
859
            ToolsetGenerate( $pdb_file );
860
        }
861
 
862
        #
863
        #   Package the PDB file up with the DLL
864
        #   Package the DLL - now that we know its proper name
865
        #
866
        PackageShlibAddFiles( $base, $pdb_file, 'Class=debug' ) unless $no_pdb ;
867
        PackageShlibAddFiles( $base, "\$(LIBDIR)/${full}" );
868
 
869
        #
870
        #   Generate Shared Library dependency information
871
        #
335 dpurdie 872
        my $dep = $io->SetShldTarget( $lib );
227 dpurdie 873
 
874
        #
875
        #   Generate rules and recipes to create the body of the shared
876
        #   library. Several build variables are overiden when creating
877
        #   a shared library.
878
        #
879
        $io->Prt( "\$(LIBDIR)/${full}:\tSHBASE=${lib}\n" );
880
        $io->Prt( "\$(LIBDIR)/${full}:\tSHNAME=${lib}\n" );
881
        $io->Prt( "\$(LIBDIR)/${full}:\tCFLAGS+=\$(SHCFLAGS)\n" );
882
        $io->Prt( "\$(LIBDIR)/${full}:\tCXXLAGS+=\$(SHCXXFLAGS)\n" );
883
        $io->Prt( "\$(LIBDIR)/${full}:\t$export_file\n" ) if ($export_file );
884
        $io->Prt( "\$(LIBDIR)/${full}:\t$res\n" ) if ( $res );
885
 
335 dpurdie 886
        $io->Entry( "\$(LIBDIR)/${full}: $dep \\\n\t\t\$(OBJDIR)/${base}",
227 dpurdie 887
            "", " \\\n\t\t", ".$::o", @$pObjs );
888
 
889
        $io->Prt( " \\\n\t\t$def" ) if ( $link_with_def );
261 dpurdie 890
        $io->Prt( "\n\t\$(SHLD)\n" );
227 dpurdie 891
 
892
        $io->Newline();
893
 
894
        #.. Linker command file
895
        #
896
        #       Now the fun part... piecing together a variable ${name}_shld
897
        #       which ends up in the command file.
898
        #
899
        $io->SetTag( "${lib}_shld" );          # command tag
900
 
901
        $io->Label( "Linker commands", $name ); # label
902
 
903
        $io->Cmd( "-dll" );
904
        $io->Cmd( "-noentry" )if ($resource_only);
291 dpurdie 905
        $io->Cmd( "-machine:X86" );
227 dpurdie 906
        $io->Cmd( "-base:0x10000000" );
907
        $io->Cmd( "-def:$def" ) if ($link_with_def);
908
        $io->Cmd( "-out:\$(subst /,\\\\,\$(LIBDIR)/${full})" );
909
        $io->Cmd( "-implib:\$(subst /,\\\\,$import_lib)" ) if ($import_lib);
910
        $io->Cmd( "-pdb:\$(subst /,\\\\,$pdb_file)" )       unless ( $no_pdb );
911
        $io->Cmd( "-debug:none" )                           if ($no_pdb);
912
        $io->Cmd( "-pdb:none" )                             if ($no_pdb);
913
        $io->Cmd( "-entry:$entry" )                         if ($entry);
914
        $io->Cmd( "-map:\$(subst /,\\\\,\$(LIBDIR)/${lib}).map" );
915
        $io->Cmd( "-nodefaultlib:LIBC" );
916
        $io->Cmd( "\$(subst /,\\\\,$res)" ) if ( $res );
917
        $io->Cmd( "\$(subst /,\\\\,$export_file)" ) if ( $export_file );
918
 
919
                                                # object list
920
        $io->ObjList( $name, $pObjs, \&ToolsetObjRecipe );
921
 
922
                                                # library list
923
        $io->LibList( $name, $pLibs, \&ToolsetLibRecipe );
924
 
925
        $io->Newline();
926
 
927
        #.. Dependency link,
335 dpurdie 928
        #   Create a library dependency file
929
        #       Create command file to build applicaton dependency list
930
        #       from the list of dependent libraries
227 dpurdie 931
        #
335 dpurdie 932
        #       Create makefile directives to include the dependency
933
        #       list into the makefile.
227 dpurdie 934
        #
335 dpurdie 935
        $io->DepRules( $pLibs, \&ToolsetLibRecipe, "\$(LIBDIR)/${full}" );
936
        $io->SHLDDEPEND( $name, $lib );
227 dpurdie 937
    }
938
 
939
    ToolsetLibStd( $pLibs )                    # push standard libraries
940
        unless ( $noaddlibs );
941
 
942
    if ( $doimplib ) {
943
        #
944
        #   --Implib flavor will create
945
        #       a) Import library   $name$(GBE_TYPE).lib
946
        #       b) Versioned DLL    $name$(GBE_TYPE).xx.xx.xx.dll
947
        #
289 dpurdie 948
        $target_file_dll = "\$(LIBDIR)/$name\$(GBE_TYPE).$_ver.$::so";
227 dpurdie 949
        BuildSHLD(
289 dpurdie 950
            "$name",                        # Base Name
951
            "$name\$(GBE_TYPE)",            # Name of Export Lib
952
            "$name\$(GBE_TYPE).$_ver");      # Name of the DLL + PDB
227 dpurdie 953
 
954
    } else {
955
        #
956
        #   Original flavor will create
957
        #       a) Import library   $name$(GBE_TYPE).lib    ---+
958
        #       b) Unversioned DLL  $name$(GBE_TYPE).dll    <--+
959
        #       c) Versioned DLL    $name$(GBE_TYPE).xx.xx.xx.dll
960
        #
961
        MakePrint(
962
            "# .. Versioned image\n\n".
289 dpurdie 963
            "\$(LIBDIR)/${name}\$(GBE_TYPE).$_ver.$::so:\t".
227 dpurdie 964
            "\$(LIBDIR)/${name}\$(GBE_TYPE).$::so\n".
965
            "\n" );
966
 
967
        $target_file_dll = "\$(LIBDIR)/$name\$(GBE_TYPE).$::so";
289 dpurdie 968
        BuildSHLD( "$name", ""                  , "$name\$(GBE_TYPE).$_ver" );
227 dpurdie 969
        BuildSHLD( "$name", "$name\$(GBE_TYPE)" , "$name\$(GBE_TYPE)" );
970
    }
971
 
972
    #.. Resource File
973
    #
974
    ToolsetRCrecipe( $res, @reslist )
975
        if ( $res );
976
}
977
 
978
 
979
###############################################################################
980
#   ToolsetSHLDLINT $name, \@args, \@objs, \@libraries )
981
#       This subroutine takes the user options and builds the rules
982
#       required to lint the program 'name'.
983
#
984
#   Arguments:
985
#       (none)
986
#
987
#   Output:
988
#       [ $(LIBDIR)/$name_lint:   .... ]
989
#           $(SHLIBLINT)
990
#
991
###############################################################################
992
 
993
sub ToolsetSHLDLINT
994
{
995
    PCLintSHLIB( @_ );
996
}
997
 
998
###############################################################################
261 dpurdie 999
# Function        : ToolsetLD
227 dpurdie 1000
#
261 dpurdie 1001
# Description     : Takes the user options and builds the rules required to
1002
#                   link the program 'name'.
227 dpurdie 1003
#
261 dpurdie 1004
# Inputs          : $name           - base name of the program
1005
#                   $pArgs          - Ref to program arguments
1006
#                   $pObjs          - Ref to program objects
1007
#                   $pLibs          - Ref to program library list
227 dpurdie 1008
#
261 dpurdie 1009
# Returns         : Nothing
227 dpurdie 1010
#
261 dpurdie 1011
# Output:         : Rules and recipes to create a program
1012
#                       Create program rules and recipes
1013
#                       Create linker input script
1014
#                       Create library dependency list
1015
#                       Include library dependency information
227 dpurdie 1016
#
1017
sub ToolsetLD
1018
{
1019
    my ( $name, $pArgs, $pObjs, $pLibs ) = @_;
1020
    my ( $res, @reslist );
1021
    my $no_pdb =$pdb_none;
1022
    our( $entry, $noaddlibs );
1023
 
1024
#.. Parse arguments
1025
#
1026
    foreach ( @$pArgs ) {
1027
        if (/^--Resource=(.*)/) {               # Resource definition
1028
            ($res, @reslist) = ToolsetRClist( $name, $1 );
1029
 
1030
        } elsif (/^--NoPDB$/) {
1031
            $no_pdb = 1;
1032
 
1033
        } elsif (/^--Entry=(.*)/) {
1034
            $entry = $1;
1035
 
1036
        } elsif (/^--NoAddLib/) {
1037
            $noaddlibs = 1;
1038
 
1039
        } else {
343 dpurdie 1040
            Message( "$toolset_name LD: unknown option $_ -- ignored\n" );
227 dpurdie 1041
 
1042
        }
1043
    }
1044
 
261 dpurdie 1045
#.. Names of important files
1046
#
1047
    my $base = "\$(BINDIR)/${name}";
1048
    my $full = $base . $::exe;
1049
    my $map  = $base . '.map';
1050
    my $pdb  = $base . '.pdb';
1051
 
1052
 
227 dpurdie 1053
#.. Cleanup rules
1054
#
255 dpurdie 1055
#   ld              Linker command file
1056
#   map             Map file
1057
#   pdb             Microsoft C/C++ program database
1058
#   ilk             Microsoft Linker Database
1059
#   res             Compiled resource script
261 dpurdie 1060
#   exe.manifest    Manifest file (VS2005)
227 dpurdie 1061
#
261 dpurdie 1062
    ToolsetGenerate( $map );
1063
    ToolsetGenerate( $pdb );
1064
    ToolsetGenerate( $base . '.ld' );
1065
    ToolsetGenerate( $base . '.ilk' );
1066
    ToolsetGenerate( $full . '.manifest' ) if $toolset_info->{'GenManifest'};
227 dpurdie 1067
 
359 dpurdie 1068
    #
1069
    #   Under some conditions the creation of a program will also create
1070
    #   an exp and lib files. May be related to an attempt to create a prog
1071
    #   and a dll from the same code
1072
    #
1073
    ToolsetGenerate( $base . '.exp' );
1074
    ToolsetGenerate( $base . '.lib' );
1075
 
1076
 
335 dpurdie 1077
#.. Toolset Printer
227 dpurdie 1078
#
1079
    my ($io) = ToolsetPrinter::New();
335 dpurdie 1080
    my $dep = $io->SetLdTarget( $name );
227 dpurdie 1081
 
335 dpurdie 1082
#.. Linker command
1083
#
261 dpurdie 1084
    $io->Prt( "$full : $dep " );
1085
    $io->Entry( "", "", "\\\n\t", ".$::o ", @$pObjs );
1086
    $io->Prt( "\\\n\t$res " ) if ( $res );
1087
    $io->Prt( "\n\t\$(LD)\n\n" );
227 dpurdie 1088
 
1089
 
1090
#.. Linker command file
1091
#
1092
#       Now piece together a variable $(name_ld) which ends up in
1093
#       the command file linking the application.
1094
#
1095
    $io->SetTag( "${name}_ld" );                # macro tag
1096
 
1097
    $io->Label( "Linker commands", $name );     # label
1098
 
261 dpurdie 1099
    $io->Cmd( "-out:\$(subst /,\\\\,$full)" );
1100
    $io->Cmd( "-pdb:\$(subst /,\\\\,$pdb)" )        unless ($no_pdb);
1101
    $io->Cmd( "-debug:none" )                       if ($no_pdb);
1102
    $io->Cmd( "-pdb:none" )                         if ($no_pdb);
1103
    $io->Cmd( "-entry:$entry" )                     if ($entry);
1104
    $io->Cmd( "-map:\$(subst /,\\\\,$map)" );
227 dpurdie 1105
    $io->Cmd( "-nodefaultlib:LIBC" );
291 dpurdie 1106
    $io->Cmd( "-machine:X86" );
261 dpurdie 1107
    $io->Cmd( "\$(subst /,\\\\,$res)" )             if ( $res );
227 dpurdie 1108
 
261 dpurdie 1109
    ToolsetLibStd( $pLibs ) unless ( $noaddlibs );      # push standard libraries
1110
    $io->ObjList( $name, $pObjs, \&ToolsetObjRecipe );  # object list
1111
    $io->LibList( $name, $pLibs, \&ToolsetLibRecipe );  # library list
1112
    $io->Newline();
227 dpurdie 1113
 
335 dpurdie 1114
    #.. Dependency link,
1115
    #   Create a library dependency file
1116
    #       Create command file to build applicaton dependency list
1117
    #       from the list of dependent libraries
1118
    #
1119
    #       Create makefile directives to include the dependency
1120
    #       list into the makefile.
1121
    #
1122
    $io->DepRules( $pLibs, \&ToolsetLibRecipe, $full );
1123
    $io->LDDEPEND();
227 dpurdie 1124
 
1125
#.. Compile up the resource file
1126
#
1127
    ToolsetRCrecipe( $res, @reslist )
1128
        if ( $res );
1129
 
335 dpurdie 1130
#.. Package up the PDB file with the program
227 dpurdie 1131
#
261 dpurdie 1132
    PackageProgAddFiles ( $name, $full );
1133
    PackageProgAddFiles ( $name, $pdb, "Class=debug" ) unless ( $no_pdb );
227 dpurdie 1134
 
1135
#
1136
#   Track the name of the possible target file
1137
#   Used when creating Visual Studio projects
1138
#
261 dpurdie 1139
    $target_file_exe = $full;
227 dpurdie 1140
}
1141
 
1142
 
1143
###############################################################################
1144
#   ToolsetLD( $name, \@args, \@objs, \@libraries, \@csrc, \@cxxsrc )
1145
#       This subroutine takes the user options and builds the rules
1146
#       required to lint the program 'name'.
1147
#
1148
#   Arguments:
1149
#       (none)
1150
#
1151
#   Output:
1152
#       [ $(BINDIR)/$name_lint:   .... ]
1153
#           $(LDLINT)
1154
#
1155
###############################################################################
1156
 
1157
sub ToolsetLDLINT
1158
{
1159
    PCLintLD( @_ );
1160
}
1161
 
1162
 
1163
########################################################################
1164
#
1165
#   Push standard "system" libraries. This is a helper function
1166
#   used within this toolset.
1167
#
1168
#   Arguments:
1169
#       $plib       Reference to library array.
1170
#
1171
########################################################################
1172
 
1173
sub ToolsetLibStd
1174
{
1175
    my ($plib) = @_;
1176
 
1177
    #
1178
    #   Only add libraries if required
1179
    #
1180
    return unless( $::ScmCompilerOpts{'ADDLINKLIBS'} );
1181
 
1182
 
1183
    #
1184
    #   Appears to be a kludge that no one is happy to remove
1185
    #   If we are inluding cs or csx libraries then add some more
1186
    #
1187
    foreach (@$plib) {
1188
        if ( $_ eq 'csx$(GBE_TYPE)' || $_ eq 'cs$(GBE_TYPE)' )
1189
        {                                       # .. core services
1190
            UniquePush( $plib, "KERNEL32" );
1191
            UniquePush( $plib, "WINUX32\$(GBE_TYPE)" );
1192
            UniquePush( $plib, "WS2_32" );
1193
            last;
1194
        }
1195
    }
1196
 
1197
    #
1198
    #   Multithreaded DLL
1199
    #
1200
    push @$plib, "--ifeq=THREADMODE:D";
1201
    push @$plib, "--ifdebug";
1202
    push @$plib, "MSVCRTD";
1203
 
1204
    push @$plib, "--ifeq=THREADMODE:D";
1205
    push @$plib, "--ifprod";
1206
    push @$plib, "MSVCRT";
1207
 
1208
    #
1209
    #   Static Multithread library
1210
    #
1211
    push @$plib, "--ifeq=THREADMODE:T";
1212
    push @$plib, "--ifdebug";
1213
    push @$plib, "LIBCMTD";
1214
 
1215
    push @$plib, "--ifeq=THREADMODE:T";
1216
    push @$plib, "--ifprod";
1217
    push @$plib, "LIBCMT";
1218
 
1219
    #
1220
    #   User library
1221
    #
1222
    push @$plib, "USER32";
1223
}
1224
 
1225
 
1226
########################################################################
1227
#
1228
#   Generate a linker object recipe.  This is a helper function used 
1229
#   within this toolset.
1230
#
1231
#   Arguments:
1232
#       $io         I/O stream
1233
#
1234
#       $target     Name of the target
1235
#
1236
#       $obj        Library specification
1237
#
1238
########################################################################
1239
 
1240
sub ToolsetObjRecipe
1241
{
1242
    my ($io, $target, $obj) = @_;
1243
 
1244
    $io->Cmd( "\$(subst /,\\\\,\$(strip $obj)).$::o" );
1245
}
1246
 
1247
 
1248
########################################################################
1249
#
1250
#   Generate a linker/depend library recipe.  This is a helper function
1251
#   used within this toolset.
1252
#
1253
#   Arguments:
1254
#       $io         I/O stream
1255
#
1256
#       $target     Name of the target
1257
#
1258
#       $lib        Library specification
1259
#
1260
#       $dp         If building a depend list, the full target name.
1261
#
1262
########################################################################
1263
 
1264
sub ToolsetLibRecipe
1265
{
1266
    my ($io, $target, $lib, $dp) = @_;
1267
 
1268
    return                                      # ignore (compat)
1269
        if ( $lib eq "rt" ||        $lib eq "thread" ||
1270
             $lib eq "pthread" ||   $lib eq "nsl" ||
1271
             $lib eq "socket" );
1272
 
1273
    if ( !defined($dp) ) {                      # linker
1274
        $io->Cmd( "\$(subst /,\\\\,\$(strip $lib)).$::a" );
1275
 
1276
    } else {                                    # depend
1277
        $io->Cmd( "$dp:\t@(vlib2,$lib,LIB)" );
1278
    }
1279
}
1280
 
1281
 
1282
########################################################################
1283
#
1284
#   Parse resource file data
1285
#   This is a helper function used within this toolset
1286
#
1287
#   Arguments   : $1  BaseName
1288
#                 $2  The users resource list
1289
#                     This is a list of comma seperated files
1290
#                     The first file is the main resource script
1291
#
1292
#   Returns     : An array of resource files with full pathnames
1293
#                 [0] = The output file
1294
#                 [1] = The input file
1295
#                 [..] = Other input files
1296
#
1297
########################################################################
1298
 
1299
sub ToolsetRClist
1300
{
1301
    my ($name, $files) = @_;
1302
    my @result;
1303
 
1304
    #
1305
    #   Generate the name of the output file
1306
    #
1307
    push @result, "\$(OBJDIR)/$name.res";
1308
 
1309
    #
1310
    #   Process each user file
1311
    #
279 dpurdie 1312
    for (split( '\s*,\s*', $files ))
227 dpurdie 1313
    {
1314
        #
1315
        #   Locate the file.
1316
        #   If it is a generate file so it will be in the SRCS hash
1317
        #   Other wise the use will have to use Src to locate the file
1318
        #
1319
        push @result, MakeSrcResolve($_);
1320
    }
1321
 
1322
    #
1323
    #   Return the array to the user
1324
    #
1325
    return @result;
1326
}
1327
 
1328
 
1329
########################################################################
1330
#
1331
#   Generate a resource file recipe
1332
#   This is a helper function used within this tool
1333
#
1334
#   Arguments   : $1  Output resource file
1335
#                 ..  Input resource files
1336
#
1337
########################################################################
1338
 
1339
sub ToolsetRCrecipe
1340
{
1341
    my ($out, @in) = @_;
1342
 
1343
    #
1344
    #   Cleanup
1345
    #
1346
    ToolsetGenerate( $out );
1347
 
1348
    #
1349
    #   Recipe
1350
    #
1351
    MakePrint( "\n#.. Compile Resource file: $out\n\n" );
1352
    MakePrint( "$out:\t\$(GBE_PLATFORM).mk\n" );
1353
    MakeEntry( "$out:\t", "", "\\\n\t\t", " ", @in );
1354
    MakePrint( "\n\t\$(RC)\n" );
1355
    MakePrint( "\n" );
1356
}
1357
 
1358
########################################################################
1359
#
1360
#   Generate a project from the provided project solution file
1361
#   This is aimed at .NET work
1362
#
1363
#   Arguments   : $name             - Base name of the project
1364
#                 $solution         - Path to the solutionn file
1365
#                 $pArgs            - Project specific options
1366
#
1367
########################################################################
1368
 
1369
my $project_defines_done = 0;
1370
sub ToolsetPROJECT
1371
{
1372
    my( $name, $solution ,$pArgs ) = @_;
1373
    my $buildcmd = $toolset_info->{'buildcmd'};
1374
    my $cleancmd = $toolset_info->{'cleancmd'};
343 dpurdie 1375
    my $release = ${$toolset_info->{'def_targets'}}[0] || 'RELEASE';
1376
    my $debug =   ${$toolset_info->{'def_targets'}}[1] || 'DEBUG';
227 dpurdie 1377
 
1378
    #
1379
    #   Process options
1380
    #
1381
    foreach ( @$pArgs ) {
343 dpurdie 1382
        if ( m/^--TargetProd*=(.+)/ ) {
1383
            $release = $1;
1384
 
1385
        } elsif ( m/^--TargetDebug=(.+)/ ) {
1386
            $debug = $1;
1387
 
1388
        } else {
1389
            Message( "$toolset_name PROJECT: unknown option $_ -- ignored\n" );
1390
        }
227 dpurdie 1391
    }
1392
 
1393
    my ($io) = ToolsetPrinter::New();
1394
 
1395
    #
343 dpurdie 1396
    #   Setup toolset specific difinitions. Once
227 dpurdie 1397
    #
1398
    unless( $project_defines_done )
1399
    {
1400
        $project_defines_done = 1;
343 dpurdie 1401
        $io->PrtLn( 'project_target = $(if $(findstring 1,$(DEBUG)),$2,$1)' );
227 dpurdie 1402
        $io->Newline();
1403
    }
1404
 
1405
    #
1406
    #   Process the build and clean commands
1407
    #       Substitute arguments
1408
    #           =TYPE=
1409
    #           =LOG=
1410
    #           =DSW=
1411
    #
343 dpurdie 1412
    $buildcmd =~ s~=TYPE=~"\$(call project_target,$release,$debug)"~g;
227 dpurdie 1413
    $buildcmd =~ s~=LOG=~$name\$(GBE_TYPE).log~g;
1414
    $buildcmd =~ s~=DSW=~$solution~g;
1415
 
343 dpurdie 1416
    $cleancmd =~ s~=TYPE=~"\$(call project_target,$release,$debug)"~g;
227 dpurdie 1417
    $cleancmd =~ s~=LOG=~$name\$(GBE_TYPE).log~g;
1418
    $cleancmd =~ s~=DSW=~$solution~g;
1419
 
1420
    #
1421
    #   Generate the recipe to create the project
343 dpurdie 1422
    #   Use the set_<PLATFORM>.sh file to extend the DLL search path
227 dpurdie 1423
    #
1424
    $io->Label( "Build project", $name );
1425
    $io->PrtLn( "Project_$name: $solution \$(INTERFACEDIR)/set_$::ScmPlatform.sh" );
1426
 
1427
    $io->PrtLn( "\t\$(XX_PRE)( \$(rm) -f $name\$(GBE_TYPE).log; \\" );
1428
    $io->PrtLn( "\t. \$(INTERFACEDIR)/set_$::ScmPlatform.sh; \\" );
255 dpurdie 1429
    $io->PrtLn( "\t\$(show_environment); \\" );
227 dpurdie 1430
    $io->PrtLn( "\t$buildcmd; \\" );
1431
    $io->PrtLn( "\tret=\$\$?; \\" );
1432
    $io->PrtLn( "\t\$(GBE_BIN)/cat $name\$(GBE_TYPE).log; \\" );
1433
    $io->PrtLn( "\texit \$\$ret )" );
1434
    $io->Newline();
1435
 
1436
    #
1437
    #   Generate the recipe to clean the project
1438
    #
1439
    $io->Label( "Clean project", $name );
1440
    $io->PrtLn( "ProjectClean_$name: $solution" );
1441
    $io->PrtLn( "\t-\$(XX_PRE)$cleancmd" );
1442
    $io->PrtLn( "\t-\$(XX_PRE)\$(rm) -f $name\$(GBE_TYPE).log" );
1443
    $io->Newline();
1444
 
1445
}
1446
 
1447
 
1448
#.. Successful termination
1449
1;
1450