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