Subversion Repositories DevTools

Rev

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

Rev Author Line No. Line
227 dpurdie 1
# -*- mode: perl; indent-width: 4; show-tabs: yes; -*-
2
#
3
# Module name   : PD386
4
# Module type   : Makefile system
5
# Compiler(s)   : ANSI C
6
# Environment(s): AMX/EOS
7
#
8
#                       ! WARNING - do not detab !
9
#
10
# Description:
11
#       Paradigm C/C++ toolset
12
#
13
# Version   Who      Date        Description
14
# 1.0       APY      20/02/02    Created (from WatcomC)
15
#           APY      26/02/02    Build system +v2 support.
16
#                                - prefixed 'exp' with '.' and
17
#                                  remove '.' from $(exe) references.
18
#                                - reconstructed isp creation
19
#                                - replaced ToolsetProg() with ToolsetGenerate().
20
#                                - ToolsetCC and ToolsetCXX switch processing
21
#                    30/04/02    --Isp must allow mutliple specifications.
22
#                    17/07/02    - c0t32
23
#                    16/04/04    - GBE_TARGET, replaced with GBE_PLATFORM
24
#
25
# $Source: /cvsroot/etm/devl/CFG/TOOLSET/PD386,v $
26
# $Revision: 1.2 $ $Date: 2004/04/23 05:47:03 $ $State: Exp $
27
# $Author: ayoung $ $Locker:  $
28
#............................................................................#
29
 
30
##############################################################################
31
#   ToolsetInit()
32
#       Runtime initialisation
33
#
34
##############################################################################
35
 
36
ToolsetInit();
37
 
38
sub ToolsetInit
39
{
40
#.. standard.rul requirements
261 dpurdie 41
    $s = 'asm';
42
    $o = 'obj';
43
    $a = 'lib';
227 dpurdie 44
    $rom = ".rom";         # inter-immediate link stage image
45
    $bin = ".bin";         # binary (BOOTBIOS) image
46
    $axe = ".axe";         # debug image
47
 
48
#.. define environment
49
    Init( "paradigm" );
50
    ToolsetDefines( "pd386.def" );
51
    ToolsetRules( "pd386.rul" );
52
    ToolsetRules( "standard.rul" );
53
}
54
 
55
###############################################################################
56
#   ToolsetCC( $source, $obj, \@args )
57
#       This subroutine takes the user options and builds the rule(s)
58
#       required to compile the source file 'source' to 'obj'
59
#
60
###############################################################################
61
 
62
sub ToolsetCC
63
{
64
    my( $source, $obj, $pArgs ) = @_;
65
 
66
    Debug( "CC:  $source -> $obj" );
67
    foreach ( @$pArgs ) {
68
        Debug( "option:    $_" );
69
        if ( /--Shared$/ ) {                    # Building a 'shared' object
70
            $cflags = "$cflags \$(SHCFLAGS)";
71
            Debug( "CC:    as shared object" );
72
 
73
        } else {                                # unknown option
74
            Message( "CC: unknown option $_ -- ignored\n" );
75
        }
76
    }
77
 
78
    MakePrint( "\n\t\$(CC)\n" );
79
    MakePrint( "\$(OBJDIR)/$i.${o}:\tCFLAGS +=$cflags\n" )
80
        if ( $cflags );
81
}
82
 
83
###############################################################################
84
#   ToolsetCCDepend( $depend, \@sources )
85
#       This subroutine takes the user options and builds the
86
#       rule(s) required to build the dependencies for the source
87
#       files 'sources' to 'depend'.
88
#
89
###############################################################################
90
 
91
sub ToolsetCCDepend
92
{
93
    MakePrint( "\t\$(CCDEPEND)\n" );
94
}
95
 
96
 
97
###############################################################################
98
#   ToolsetCXX( $source, $obj, \@args )
99
#       This subroutine takes the user options and builds the rule(s)
100
#       required to compile the source file 'source' to 'obj'
101
#
102
###############################################################################
103
 
104
sub ToolsetCXX
105
{
106
    my( $source, $obj, $pArgs ) = @_;
107
    my( $cflags ) = "";
108
 
109
    Debug( "CCX: $source -> $obj" );
110
    foreach ( @$pArgs ) {
111
        Debug( "option:    $_" );
112
        if ( /--Shared$/ ) {                    # Building a 'shared' object
113
            $cflags = "$cflags \$(SHCXXFLAGS)";
114
            Debug( "CCX:    as shared object" );
115
 
116
        } else {
117
            Message( "CCX: unknown option $_ -- ignored\n" );
118
        }
119
    }
120
 
121
    MakePrint( "\n\t\$(CXX)\n" );
122
    MakePrint( "\$(OBJDIR)/$i.${o}:\tCXXFLAGS +=$cflags\n" )
123
        if ( $cflags );
124
}
125
 
126
 
127
###############################################################################
128
#   ToolsetCXXDepend( $depend, \@sources )
129
#       This subroutine takes the user options and builds the
130
#       rule(s) required to build the dependencies for the source
131
#       files 'sources' to 'depend'.
132
#
133
###############################################################################
134
 
135
sub ToolsetCXXDepend
136
{
137
        #ToolsetCCDepend() handles both CC and CXX source
138
}
139
 
140
 
141
###############################################################################
142
#   ToolsetAS( $source, $obj, \@args )
143
#       This subroutine takes the user options and builds the rule(s)
144
#       required to compile the source file 'source' to 'obj'
145
#
146
#   Output:
147
#       [ $(OBJDIR)/name$.${o}:         source-file ]
148
#           $(AS)
149
#
150
###############################################################################
151
 
152
sub ToolsetAS
153
{
154
    my( $source, $obj, $pArgs ) = @_;
155
 
156
    Debug( "AS: $source -> $obj" );
157
    foreach ( @$pArgs ) {
158
        Debug( "option:    $_" );
159
        Message( "AS: unknown option $_ -- ignored\n" );
160
    }
161
 
162
#.. Cleanup rules
163
#       name.lst                Generated 'list/xref' file.
164
#
165
    ToolsetGenerate( "\$(OBJDIR)/${obj}.lst" );
166
 
167
#.. Build rule (just append to standard rule)
168
#
169
    MakePrint( "\n\t\$(AS)\n" );
170
}
171
 
172
sub ToolsetASDepend
173
{
174
}
175
 
176
 
177
###############################################################################
178
#   ToolsetAR( $name, \@args, \@objs )
179
#       This subroutine takes the user options and builds the rules
180
#       required to build the library 'name'.
181
#
182
#   Arguments:
183
#       --Amx[=prefix]          local AMX configuration (defaults to platform)
184
#       --Isp=name              ISP module
185
#
186
#   Output:
187
#       [ $(BINDIR)/name$.${a}:   .... ]
188
#           $(AR)
189
#
190
#       name_ld += ...  Linker command file
191
#           :
192
#
193
#       name_dp += ...  Dependency list
194
#           :
195
#
196
###############################################################################
197
 
198
sub ToolsetAR
199
{
200
    my( $name, $pArgs, $pObjs ) = @_;
201
    my( $amx, @isp, $insight );
202
 
203
    local( $name_ld );
204
 
205
#.. Parse arguments
206
#
207
    $amx = $insight = 0;                        # options
208
    foreach $_ ( @$pArgs ) {
209
        if (/^--Amx$/) {                        # Local AMX config
210
            $amx     = "\$(SCM_PLATFORM)";
211
        } elsif (/^--Amx=(.*)/) {               # Specific AMX config
212
            $amx     = "$1";
213
 
214
        } elsif (/^--Isp=(.*)/) {               # ISP module
215
            push( @isp, "$1" );
216
 
217
        } elsif (/^--Insight$/) {               # Enable insight
218
            $insight = 1;
219
        } elsif (/^--Insight=(.*)/) {           # Specific insight
220
            $insight = "$1";
221
 
222
        } else {
223
            Message( "AR: unknown option $_ -- ignored\n" );
224
        }
225
    }
226
 
227
#.. Cleanup rules
228
#
229
#       library.lst		Generated 'list' file.
230
#
231
    ToolsetGenerate( "\$(LIBDIR)/${name}\$(SCM_TYPE).lst" );    
232
 
233
#.. Standard library builds, plus AMX configuration
234
#
235
    MakeEntry( "\$(LIBDIR)/$name\$(GBE_TYPE).${a}:\t",
236
                  "", "\\\n\t\t", ".${o} ", @$pObjs );
237
 
238
    foreach (@isp) {
239
        AmxLibISP( $name, $_ );
240
    }
241
    AmxLib( $name, $amx, $insight )
242
        if ( $amx );
243
 
244
    MakePrint( "\n\t\$(AR)\n\n" );
245
}
246
 
247
 
248
###############################################################################
249
#   ToolsetLD( $name, \@args, \@objs, \@libraries )
250
#       This subroutine takes the user options and builds the rules
251
#       required to link the program 'name'.
252
#
253
#   Arguments:
254
#       --Eos			EOS application
255
#       --Eosx			Extended EOS application
256
#	--NetUdp                Networking with UDP support
257
#       --NetTcp                Networking with TCP support
258
#       --Amx[=prefix]          Local AMX configuration (defaults to platform)
259
#       --Isp=name              ISP module
260
#       --Insight[=prefix]      Enable insight (default to platform.icf)
261
#       --Stack=#[k]            Stack size
262
#
263
#       Linker specific:
264
#       --Exe
265
#       --Bin                   Download image
266
#       --Axe                   Absolute image (PDREMOTE)
267
#       --Axe=monitor           Axe with using explicit monitor
268
#       --Section=...           Linker sector order directives
269
#
270
#   Output:
271
#	$(BINDIR)/name.exe:	<< Generated by makelib
272
#                       $(BINDIR)/name.dep \
273
#       	        $(BINDIR)/name.[axe|bin]
274
#
275
#       $(BINDIR)/name.dep:     $(SCM_PLATFORM).mk
276
#               $(LDDEPEND)
277
#
261 dpurdie 278
#       ifeq "$(IFLAG)" "3"
227 dpurdie 279
#       -include        "$(BINDIR)/name.dep"
280
#       endif
281
#
282
# 	$(BINDIR)/name.[axe|bin]
283
#                       objs ...
284
#               {$(LDAXE)|$(LDBIN)}
285
#
286
#       name_ld += ...
287
#           :
288
#
289
###############################################################################
290
 
291
sub ToolsetLD
292
{
293
    my( $name, $pArgs, $pObjs, $pLibs ) = @_;
294
    my( $linker, $flags, $amx, $insight, $type, $idx );
295
    my( $cond );
296
    local( $varname );
297
 
298
#.. Parse arguments
299
#
300
    $stack = 0;
301
    $amx = $flags = $insight = 0;            # Options
302
 
303
    $type = ${axe};
304
    $section = "\$(GBE_PLATFORM).loc";
305
    $monitor = "\$(paradigm)/pdremote.rom/pdrem32";
306
    $bootcode = "\$(paradigm)/bin/biosboot.exe";
307
 
308
    foreach $_ ( @$pArgs )
309
    {
310
    #.. EOS
311
    #
312
       if (/--Eos$/) {                       # EOS standard
313
           $flags = $flags | $EOS_LNK;
314
       } elsif (/^--Eosx$/) {                # EOS extended
315
           $flags = $flags | $EOS_LNK | $EOS_EXT;
316
 
317
    #.. Networking
318
    #
319
        } elsif (/^--NetUdp$/) {
320
            $flags = $flags | $NET_UDP;
321
        } elsif (/^--NetTcp$/) {
322
            $flags = $flags | $NET_TCP;
323
 
324
    #.. AMX
325
    #
326
        } elsif (/^--Amx$/) {                # Local AMX config
327
            $amx = "\$(SCM_PLATFORM)";
328
        } elsif (/^--Amx=(.*)/) {            # Specific AMX config
329
            $amx = "$1";
330
 
331
        } elsif (/^--Isp=(.*)/) {            # ISP module
332
            AmxLinkISP( $name, "$1", $pObjs, $pLibs );
333
 
334
        } elsif (/^--Insight$/) {            # Enable insight
335
            $insight = "\$(SCM_PLATFORM)";
336
        } elsif (/^--Insight=(.*)/) {        # Specific insight
337
            $insight = "$1";
338
 
339
    #.. Target specific
340
    #
341
        } elsif (/^--Rom=/) {                # ROM image
342
            Message( "LD: linker option '$_' not supported -- ignored\n" );
343
 
344
	} elsif (/^--Bin/) {		     # Download image
345
            $type = ${bin};
346
 
347
        } elsif (/^--Axe/ || /^--Abs/) {     # PD. PDMONITOR image
348
            $type = ${axe};
349
 
350
        } elsif (/^--Axe=(.*)/) {            # PD, explicited PDMONITOR image
351
            $type = ${axe};
352
            $monitor = "$1";
353
 
354
        } elsif (/^--Biosboot=(.*)/) {       # PD, explicited BIOSBOOT image
355
            $type = ${bin};
356
            $bootcode = "$1";
357
 
358
        } elsif (/^--Section=(.*)/) {        # LOCATE32 section config
359
            $section = "$1";
360
 
361
        } elsif (/^--Kdb/) {                 # Kernel debugger
362
            $flags = $flags | $EOS_KDB;
363
 
364
    #.. Toolset specific
365
    #
366
        } elsif (/^--Stack=(.*)/) {          # stack size
367
            $stack = "$1";
368
 
369
        } else {
370
            Message( "LD: unknown option $_ -- ignored\n" );
371
        }
372
    }
373
 
374
#.. Command file, EOS and/or AMX dependencies
375
#
376
#   Library search order,
377
#       Application
378
#       EOS
379
#       AMX
380
#       Toolset (TNT/WATCOM)
381
#
382
    if ( $flags ) {
383
        EosLink( $name, $flags, $pObjs, $pLibs );
384
        if ( $amx ) {
385
            AmxLinkCfg( $name, $amx, $insight, $pObjs, $pLibs );
386
        } else {
387
            AmxLinkStd( $name, $pObjs, $pLibs );
388
        }
389
    } elsif ( $amx ) {
390
        AmxLinkCfg( $name, $amx, $insight, $pObjs, $pLibs );
391
    }
392
 
393
    push( @$pLibs, "\$(paradigm)/lib/noeh32" ); # toolset libraries
394
    push( @$pLibs, "\$(paradigm)/lib/embed32" );
395
    push( @$pLibs, "\$(paradigm)/lib/cw32" );
396
 
397
#.. Cleanup rules (generic)
398
#
399
    ToolsetGenerate( "\$(BINDIR)/${name}.ld" );
400
    ToolsetGenerate( "\$(BINDIR)/${name}.dep" );
401
    ToolsetGenerate( "\$(BINDIR)/${name}.map" );
402
 
403
#.. Linker command file
404
#
405
# PLINK32 objfiles, exefile, mapfile, libfiles, deffile, resfiles
406
# @xxxx indicates use response file xxxx
407
# -m      Map file with publics     -x       No map
408
# -s      Detailed segment map      -L       Specify library search paths
409
# -M      Map with mangled names    -j       Specify object search paths
410
# -c      Case sensitive link       -v       Full symbolic debug information
411
# -Enn    Max number of errors      -n       No default libraries
412
# -P-     Disable code packing      -H:xxxx  Specify app heap reserve size
413
# -B:xxxx Specify image base addr   -Hc:xxxx Specify app heap commit size
414
# -wxxx   Warning control           -S:xxxx  Specify app stack reserve size
415
# -Txx    Specify output file type  -Sc:xxxx Specify app stack commit size
416
# -Tpx          PE image            -Af:nnnn Specify file alignment
417
#               (x: e=EXE, d=DLL)   -Ao:nnnn Specify object alignment
418
# -ax     Specify application type  -o       Import by ordinals
419
#         -ap Windowing Compatible  -Vd.d    Specify Windows version
420
#         -aa Uses Windowing API    -r       Verbose link
421
#
422
#   Now the fun part... piecing together a variable $(name_ld)
423
#   which ends up in the command file.
424
#
425
# Outputs:
426
#   name.rom/     
427
#    name.exe     these files represent the link stage of the development, 
428
#                 where all of the objects are linked together.
429
#
430
#   name.map      Linker map
431
#
432
#   name.axe      Absolute image
433
#
434
#   name.rtb      RtTarget binary file
435
#
436
#   name.loc      Locator map
437
#
438
    $varname = "${name}_ld";
439
    sub LdCmd {                              # with line feed ...
261 dpurdie 440
        MakeQuote ("$varname +=@_\\n\n");
227 dpurdie 441
    }                                        
442
    sub LdTxt {                              # without line feed ...
261 dpurdie 443
        MakeQuote ("$varname +=@_\n");
227 dpurdie 444
    }
445
    sub LdPrt {
261 dpurdie 446
        MakeQuote ("@_");
227 dpurdie 447
    }
448
 
449
  if ( $type eq ${axe} || $type eq ${bin} )
450
  {
451
					     # Additional generated images
452
    ToolsetGenerate( "\$(BINDIR)/${name}${type}" );
453
    ToolsetGenerate( "\$(BINDIR)/${name}.exe" );
454
    ToolsetGenerate( "\$(BINDIR)/${name}.loc" );
455
    ToolsetGenerate( "\$(BINDIR)/${name}.rtb" );
456
 
457
				             # Rules
458
    MakePrint( " \\\n\t\t\$(BINDIR)/${name}.dep" );
459
    MakePrint( " \\\n\t\t\$(BINDIR)/${name}${type}" );
460
    MakePrint( " \n\n" );
461
 
462
    MakePrint( "\$(BINDIR)/${name}.dep:\t\$(SCM_PLATFORM).mk\n".
463
               "\t\$(LDDEPEND)\n\n" );
464
 
261 dpurdie 465
    MakePrint( "ifeq \"\$(IFLAG)\" \"3\"\n" .
227 dpurdie 466
               "-include\t\$(BINDIR)/${name}.dep\n" .
467
               "endif\n\n" );
468
 
469
					     # Linker
470
    MakePrint( "\$(BINDIR)/${name}${rom}:\t\$(BINDIR)/${name}.dep" );
471
    foreach $i ( @$pObjs ) {
472
        MakePrint( " \\\n\t\t$i.${o}" );
473
    }
474
    MakePrint( "\n\t\$(LD)\n\n" );
475
 
476
                                             # Locate32
477
                  # If building a bin,
478
                  #    name.axe,    deleted, image can not be loaded.
479
                  #    name.rtb,    renamed to 'name.bin'.
480
                  #
481
    MakePrint( "\$(BINDIR)/${name}${type}:\tLOCATEOPT=-D__PDREMOTE__=".
482
	 "\$(subst /,\\\\,$monitor)\n" )
483
         if ( $type eq ${axe});
484
    MakePrint( "\$(BINDIR)/${name}${type}:\tLOCATEOPT=-D__PDBOOTCODE__=".
485
	 "\$(subst /,\\\\,$bootcode)\n" )
486
         if ( $type eq ${bin});
487
    MakePrint( "\$(BINDIR)/${name}${type}:\tLOCATECFG=$section\n" );
488
    MakePrint( "\$(BINDIR)/${name}${type}:\t\$(BINDIR)/${name}${rom}\n" );
489
    MakePrint( "\t\$(LD2)\n" );
490
    if ( $type eq ${bin} ) 
491
    {
492
       MakePrint( "\t@\$(rm) -f \$(BINDIR)/${name}${axe}\n");
493
       MakePrint( "\t@\$(rm) -f \$(BINDIR)/${name}${bin}\n");
494
       MakePrint( "\t@\$(mv) \$(BINDIR)/${name}.rtb \$(BINDIR)/${name}${bin}\n");
495
    }
496
    MakePrint( "\n" );
497
 
498
    #   Piece together a variable $(name_ld) which ends up 
499
    #   in the PLINK32 command file.  Note the order of arguments 
500
    #   is criticial and must be seperated by a comma(,) with 
501
    #   plus(+) used for line continuation.
502
    #
503
    $varname = "${name}_ld";
504
 
505
                                             # Objects,
506
					     # .. startup code
507
        # C0T32: C run time library entry point for "tiny" NT apps.
508
        # C0X32: C run time library entry point for NT apps.
509
        #
510
    if (($flags & $EOS_LNK) || $amx) {
511
        LdTxt( "\$(subst /,\\\\,\$(paradigm)/lib/c0t32).${o}" );
512
    } else {
513
        LdTxt( "\$(subst /,\\\\,\$(paradigm)/lib/c0x32).${o}" );
514
    }
515
 
516
                                             # .. users objects
517
    foreach $i ( @$pObjs ) {
518
        LdTxt( "+\\n\$(subst /,\\\\,\$(strip $i)).${o}" )
519
    }
520
        LdCmd( "" );
521
 
522
                                             # Output files
523
        LdCmd( "\$(subst /,\\\\,\$(BINDIR)/${name}${rom})" );
524
        LdCmd( "\$(subst /,\\\\,\$(BINDIR)/${name}.map)" );
525
 
526
                                             # Libraries
527
    foreach $_ ( @$pLibs ) {
528
        if (/^--ifdef=(.*)/) {               # .. conditionals
529
            $cond = "$1";
530
            LdPrt( "ifdef $cond\n" );
531
            next;
532
        } elsif (/^--ifndef=(.*)/) {
533
            $cond = "$1";
534
            LdPrt( "ifndef $cond\n" );
535
            next;
536
        } elsif (/^--*/) {                   # .. unknown
537
            Message( "LD: unknown lib option $_ -- ignored\n" );
538
            next;
539
        }
540
 
541
                                             # ... entry
542
                                             # Note the line continuation !
543
        LdCmd("\@(dosify,@(vpath2,$_.${a},PD386_LIB)) +");
544
 
545
        if ($cond) {                         # .. end condition
546
            LdPrt("endif\t# $cond\n");
547
            $cond = "";
548
        }
549
    }
550
    MakePrint( "\n" );                       # .. terminate library list
551
 
552
    #   Now Piece together a variable $(name_dp) which ends up in the 
553
    #   command file building the application dependency list. Note
554
    #   the dependency are on the 'rom' image not the 'exe'.
555
    #
556
    $varname = "${name}_dp";
557
 
558
    $cond = "";
559
    foreach $_ ( @$pLibs ) {
560
        if (/^--ifdef=(.*)/) {               # .. conditionals
561
            $cond = "$1";
562
            LdPrt( "ifdef $cond\n" );
563
            next;
564
        } elsif (/^--ifndef=(.*)/) {
565
            $cond = "$1";
566
            LdPrt( "ifndef $cond\n" );
567
            next;
568
        } elsif (/^--*/) {                   # .. unknown
569
            Message( "LD: unknown lib option $_ -- ignored\n" );
570
            next;
571
        }
572
 
573
                                             # ... entry
574
        LdCmd("\$(BINDIR)/${name}${rom}:\t@(vpath2,$_.${a},PD386_LIB)" );
575
 
576
        if ($cond) {                         # .. end condition
577
            LdPrt("endif\t# $cond\n");
578
            $cond = "";
579
        }
580
    }
581
  }
582
  else  # "rom"
583
  {
584
  }
585
}
586
 
587
#.. Successful termination
588
1;
589