Subversion Repositories DevTools

Rev

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

Rev Author Line No. Line
227 dpurdie 1
# -*- mode: perl; indent-width: 4; show-tabs: yes; -*-
2
#
3
# Module name   : wc386
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
#       Watcom C/C++ toolset, using TNT70 and MASM
12
#
13
# Version   Who      Date        Description
14
# 1.0       APY      07/05/99    Created
15
# 1.2       APY      06/12/99    - Linker network options
16
#                                - Corrected DEBUG test within
17
#                                       linker command file generation.
18
# 1.3       APY      09/12/99    - ToolsetProg() calls added.
19
#                                - Build application dependency list
20
# 1.4       APY      06/01/00    Linker --Kdb support
261 dpurdie 21
#                    07/01/00    ifeq "$(IFLAG)" "3"
227 dpurdie 22
#                                  around -include directives
23
#                    14/03/00     vpath2()
24
#                    13/06/00    --Stack  
25
#           APY      13/11/00    ${exe} now embeddes '.' if required.
26
#                    26/02/02    remove generated asm list files
27
# 2.0       APY      26/02/02    Build system +v2 support.
28
#                                - prefixed 'exp' with '.' and
29
#                                  remove '.' from $(exe) references.
30
#                                - reconstructed isp creation
31
#                                - replaced ToolsetProg() with ToolsetGenerate().
32
#                                - ToolsetCC and ToolsetCXX switch processing
33
#                    30/04/02    --Isp must allow mutliple specifications.
34
#
35
# $Source: /cvsroot/etm/devl/CFG/TOOLSET/WC386,v $
36
# $Revision: 1.1 $ $Date: 2003/07/03 15:15:03 $ $State: Exp $
37
# $Author: ayoung $ $Locker:  $
38
#............................................................................#
39
 
40
##############################################################################
41
#   ToolsetInit()
42
#       Runtime initialisation
43
#
44
##############################################################################
45
 
46
ToolsetInit();
47
 
48
sub ToolsetInit
49
{
50
#.. standard.rul requirements
261 dpurdie 51
    $s = 'asm';
52
    $o = 'obj';
53
    $a = 'lib';
227 dpurdie 54
    $exe = ".exp";
55
 
56
#.. define WATCOM environment
57
    Init( "watcom" );
58
    ToolsetDefines( "wc386.def" );
59
    ToolsetRules( "wc386.rul" );
60
    ToolsetRules( "standard.rul" );
61
}
62
 
63
###############################################################################
64
#   ToolsetCC( $source, $obj, \@args )
65
#       This subroutine takes the user options and builds the rule(s)
66
#       required to compile the source file 'source' to 'obj'
67
#
68
###############################################################################
69
 
70
sub ToolsetCC
71
{
72
    my( $source, $obj, $pArgs ) = @_;
73
 
74
    Debug( "CC:  $source -> $obj" );
75
    foreach ( @$pArgs ) {
76
        Debug( "option:    $_" );
77
        if ( /--Shared$/ ) {                    # Building a 'shared' object
78
            $cflags = "$cflags \$(SHCFLAGS)";
79
            Debug( "CC:    as shared object" );
80
 
81
        } else {                                # unknown option
82
            Message( "CC: unknown option $_ -- ignored\n" );
83
        }
84
    }
85
 
86
    MakePrint( "\n\t\$(CC)\n" );
87
    MakePrint( "\$(OBJDIR)/$i.${o}:\tCFLAGS +=$cflags\n" )
88
        if ( $cflags );
89
}
90
 
91
###############################################################################
92
#   ToolsetCCDepend( $depend, \@sources )
93
#       This subroutine takes the user options and builds the
94
#       rule(s) required to build the dependencies for the source
95
#       files 'sources' to 'depend'.
96
#
97
###############################################################################
98
 
99
sub ToolsetCCDepend
100
{
101
    MakePrint( "\t\$(CCDEPEND)\n" );
102
}
103
 
104
 
105
###############################################################################
106
#   ToolsetCXX( $source, $obj, \@args )
107
#       This subroutine takes the user options and builds the rule(s)
108
#       required to compile the source file 'source' to 'obj'
109
#
110
###############################################################################
111
 
112
sub ToolsetCXX
113
{
114
    my( $source, $obj, $pArgs ) = @_;
115
    my( $cflags ) = "";
116
 
117
    Debug( "CCX: $source -> $obj" );
118
    foreach ( @$pArgs ) {
119
        Debug( "option:    $_" );
120
        if ( /--Shared$/ ) {                    # Building a 'shared' object
121
            $cflags = "$cflags \$(SHCXXFLAGS)";
122
            Debug( "CCX:    as shared object" );
123
 
124
        } else {
125
            Message( "CCX: unknown option $_ -- ignored\n" );
126
        }
127
    }
128
 
129
    MakePrint( "\n\t\$(CXX)\n" );
130
    MakePrint( "\$(OBJDIR)/$i.${o}:\tCXXFLAGS +=$cflags\n" )
131
        if ( $cflags );
132
}
133
 
134
###############################################################################
135
#   ToolsetCXXDepend( $depend, \@sources )
136
#       This subroutine takes the user options and builds the
137
#       rule(s) required to build the dependencies for the source
138
#       files 'sources' to 'depend'.
139
#
140
###############################################################################
141
 
142
sub ToolsetCXXDepend
143
{
287 dpurdie 144
    ToolsetCCDepend();
227 dpurdie 145
}
146
 
147
 
148
###############################################################################
149
#   ToolsetAS( $source, $obj, \@args )
150
#       This subroutine takes the user options and builds the rule(s)
151
#       required to compile the source file 'source' to 'obj'
152
#
153
###############################################################################
154
 
155
sub ToolsetAS
156
{
157
#.. Parse arguments
158
#
159
 
160
#.. Cleanup rules
161
#
162
#       name.lst                Generated 'list/xref' file.
163
#
164
    ToolsetGenerate( "\$(OBJDIR)/${name}.lst" );    
165
 
166
#.. Build rule (just append to standard rule)
167
#
168
    MakePrint( "\n\t\$(AS)\n" );
169
}
170
 
171
sub ToolsetASDepend
172
{
173
}
174
 
175
 
176
###############################################################################
177
#   ToolsetAR( $name, \@args, \@objs )
178
#       This subroutine takes the user options and builds the rules
179
#       required to build the library 'name'.
180
#
181
#   Arguments:
182
#       --Amx[=prefix]          local AMX configuration (defaults to platform)
183
#       --Isp=name              ISP module
184
#       --[wlib|386lib]         Librarian (todo)
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
        } elsif (/^--Isp=(.*)/) {               # ISP module
214
            push(@isp,"$1");
215
 
216
        } elsif (/^--Insight$/) {               # Enable insight
217
            $insight = 1;
218
        } elsif (/^--Insight=(.*)/) {           # Specific insight
219
            $insight = "$1";
220
 
221
 
222
        } else {
223
            Message( "AR: unknown option $_ -- ignored\n" );
224
        }
225
    }
226
 
227
#.. Standard library builds, plus AMX configuration
228
#
229
    MakeEntry( "\$(LIBDIR)/$name\$(GBE_TYPE).${a}:\t",
230
                  "", "\\\n\t\t", ".${o} ", @$pObjs );
231
 
232
#.. Build library with AMX configuration
233
#
234
    foreach (@isp) {
235
        AmxLibISP( $name, $_ );
236
    }
237
    AmxLib( $name, $amx, $insight )
238
        if ( $amx );
239
 
240
#.. Build library rule (just append to standard rule)
241
#
242
    MakePrint( "\n\t\$(AR)\n\n" );
243
}
244
 
245
 
246
###############################################################################
247
#   ToolsetLD( $name, \@args, \@objs, \@libraries )
248
#       This subroutine takes the user options and builds the rules
249
#       required to link the program 'name'.
250
#
251
#   Arguments:
252
#       --Eos                   EOS application
253
#       --Eosx                  Extended EOS application
254
#       --NetUdp                Networking with UDP support
255
#       --NetTcp                Networking with TCP support
256
#       --Amx[=prefix]          Local AMX configuration (defaults to platform)
257
#       --Isp=name              ISP module
258
#       --Insight[=prefix]      Enable insight (default to platform.icf)
259
#       --Tnt70                 Link TNT70 libs
260
#       --Rel                   n/a under DOS
261
#       --Abs                   n/a under DOS
262
#       --[Wlink|Pharlap]       linker (todo)
263
#       --Stack=#[k]            Stack size
264
#
265
#   Output:
266
#       $(BINDIR)/name${exe}:
267
#                       $(BINDIR)/name.dep
268
#           $(LD)
269
#
270
#       $(BINDIR)/name.dep:    $(SCM_PLATFORM).mk
271
#               $(LDDEPEND)
272
#
261 dpurdie 273
#       ifeq "$(IFLAG)" "3"
227 dpurdie 274
#       -include        "$(BINDIR)/name.dep"
275
#       endif
276
#
277
#       name_ld += ...
278
#           :
279
#
280
###############################################################################
281
 
282
sub ToolsetLD
283
{
284
    my( $name, $pArgs, $pObjs, $pLibs ) = @_;
285
    my( $linker, $flags, $amx, $insight, $tnt70 );
286
    my( $cond );
287
    local( $varname );
288
 
289
#.. Parse arguments
290
#
291
    $stack = 0;
292
    $linker = "wlink";                          # linker
293
    $amx = $flags = $insight = $tnt70 = 0;      # options
294
 
295
    foreach $_ ( @$pArgs )
296
    {
297
    #.. EOS
298
    #
299
        if (/--Eos$/) {                         # EOS standard
300
            $flags     = $flags | $EOS_LNK;
301
        } elsif (/^--Eosx$/) {                  # EOS extended
302
            $flags     = $flags | $EOS_LNK | $EOS_EXT;
303
 
304
    #.. Networking
305
    #
306
        } elsif (/^--NetUdp$/) {
307
            $flags     = $flags | $NET_UDP;
308
        } elsif (/^--NetTcp$/) {
309
            $flags     = $flags | $NET_TCP;
310
 
311
    #.. AMX
312
    #
313
        } elsif (/^--Amx$/) {                   # Local AMX config
314
            $amx     = "\$(SCM_PLATFORM)";
315
        } elsif (/^--Amx=(.*)/) {               # Specific AMX config
316
            $amx     = "$1";
317
 
318
        } elsif (/^--Isp=(.*)/) {               # ISP module
319
            AmxLinkISP( $name, "$1", $pObjs, $pLibs );
320
 
321
        } elsif (/^--Insight$/) {               # Enable insight
322
            $insight = "\$(SCM_PLATFORM)";
323
        } elsif (/^--Insight=(.*)/) {           # Specific insight
324
            $insight = "$1";
325
 
326
    #.. Target specific
327
    #
328
        } elsif (/^--Rom=(.*)/) {               # ROM image
329
            Message( "LD: not suitable under WC386 '$_' -- ignored\n" );
330
        } elsif (/^--Bin=(.*)/) {               # Download image
331
            Message( "LD: not suitable under WC386 '$_' -- ignored\n" );
332
        } elsif (/^--Abs/) {
333
            Message( "LD: not suitable under WC386 '$_' -- ignored\n" );
334
        } elsif (/^--Kdb/) {                    # Kernel debugger
335
            $flags = $flags | $EOS_KDB;
336
            $laddr = "$1";                      # Load address
337
 
338
    #.. Toolset specific
339
    #
340
        } elsif (/^--Tnt70=(.*)/) {             # Link TNT70
341
            $tnt70   = 1;
342
        } elsif (/^--wlink$/) {                 # use wlink linker (default)
343
            $linker  = "wlink";
344
        } elsif (/^--386link$/) {               # use 386linker
345
            $linker  = "386link";
346
        } elsif (/^--Stack=(.*)/) {             # stack size
347
            $stack   = "$1";
348
 
349
        } else {
350
            Message( "LD: unknown option $_ -- ignored\n" );
351
        }
352
    }
353
 
354
#.. Command file, EOS and/or AMX dependencies
355
#
356
#   Library search order,
357
#       Application
358
#       EOS
359
#       AMX
360
#       Toolset (TNT/WATCOM)
361
#
362
    if ( $flags ) {
363
        EosLink( $name, $flags, $pObjs, $pLibs );
364
        if ( $amx ) {
365
            AmxLinkCfg( $name, $amx, $insight, $pObjs, $pLibs );
366
        } else {
367
            AmxLinkStd( $name, $pObjs, $pLibs );
368
        }
369
    } elsif ( $amx ) {
370
        AmxLinkCfg( $name, $amx, $insight, $pObjs, $pLibs );
371
    }
372
    push( @$pLibs, "\$(tnt70)/lib/dosx32" )
373
        if ($flags || $amx || $tnt70);
374
    push( @$pLibs, "\$(watcom)/lib386/dos/clib3r" );
375
    push( @$pLibs, "\$(watcom)/lib386/dos/emu387" );
376
    push( @$pLibs, "\$(watcom)/lib386/math387r" );
377
 
378
#.. Cleanup rules
379
#
380
    ToolsetGenerate( "\$(BINDIR)/${name}.ld" );
381
    ToolsetGenerate( "\$(BINDIR)/${name}.dep" );
382
    ToolsetGenerate( "\$(BINDIR)/${name}.map" );
383
 
384
#.. Linker command file
385
#
386
#       Now the fun part... piecing together a variable $(name_ld)
387
#       which ends up in the command file.
388
#
389
    MakePrint( "\\\n\t\t\$(BINDIR)/${name}.dep\n" .
390
               "\t\$(LD)\n\n" );
391
 
392
    MakePrint( "\$(BINDIR)/${name}.dep:\t\$(SCM_PLATFORM).mk\n".
393
               "\t\$(LDDEPEND)\n\n" );
394
 
261 dpurdie 395
    MakePrint( "ifeq \"\$(IFLAG)\" \"3\"\n" .
227 dpurdie 396
               "-include\t\$(BINDIR)/${name}.dep\n" .
397
               "endif\n\n" );
398
 
399
    $varname = "${name}_ld";
400
    sub VarCmd {                                # with line feed ...
261 dpurdie 401
        MakeQuote ("$varname += @_\\n\n");
227 dpurdie 402
    }
403
    sub VarCmd2 {                               # without line feed ...
261 dpurdie 404
        MakeQuote ("$varname += @_\n");
227 dpurdie 405
    }
406
    sub VarPrt {
261 dpurdie 407
        MakePrint ("@_\n");
227 dpurdie 408
    }
409
 
410
        VarCmd( "FORMAT	Pharlap Extended" );
411
        VarPrt( "ifeq \"\$(DEBUG)\" \"1\"" );
412
        VarCmd( "DEBUG	Watcom All" );
413
        VarPrt( "endif" );
414
 
415
    foreach $i ( @$pObjs ) {
416
        VarCmd( "FILE	\$(subst /,\\\\,\$(strip $i)).${o}" );
417
    }
418
 
419
        VarCmd2( "\$(patsubst %,LIBPATH	%\\n,\$(subst /,\\\\,\$(LIBDIRS)))" );
420
 
421
                                             # Libraries
422
    $cond = "";
423
    foreach $_ ( @$pLibs ) {
424
        if (/^--ifdef=(.*)/) {               # .. conditionals
425
            $cond = "$1";
426
            VarPrt( "ifdef $cond\n" );
427
            next;
428
        } elsif (/^--ifndef=(.*)/) {
429
            $cond = "$1";
430
            VarPrt( "ifndef $cond\n" );
431
            next;
432
        } elsif (/^--*/) {                   # .. unknown
433
            Message( "LD: unknown lib option $_ -- ignored\n" );
434
            next;
435
        }
436
 
437
                                             # .. entry
438
        VarCmd( "LIBRARY	\$(subst /,\\\\,\$(strip $_)).${a}" );
439
 
440
        if ($cond) {                         # .. end condition
441
            VarPrt("endif\t# $cond\n");
442
            $cond = "";
443
        }
444
    }
445
 
446
        VarCmd( "OPTION	CaseExact" );
447
        VarCmd( "OPTION	NoDefaultLibs" );
448
        VarCmd( "OPTION	Offset=0x1000" );
449
        VarCmd( "OPTION	Map=\$(subst /,\\\\,\$(BINDIR)/${name}.map)" );
450
        VarCmd( "OPTION	Stack=$stack" )
451
            if ($stack);
452
        VarCmd( "OPTION	Verbose" );
453
        VarCmd( "RUNTIME	Privileged" );
454
 
455
    if ($flags || $amx) {
456
        VarCmd( "RUNTIME	RealBreak=_cj_psedata" );
457
        VarCmd( "RUNTIME	MinReal=0x8000" );
458
        VarCmd( "RUNTIME	MaxReal=0x8000" );
459
        VarCmd( "RUNTIME	NiStack=18" );
460
    } else {
461
        VarCmd( "RUNTIME	RealBreak=0" );
462
    }
463
 
464
        VarCmd( "NAME	\$(subst /,\\\\,\$(BINDIR)/${name}${exe})" );
465
        VarPrt( "" );
466
 
467
#.. Dependency link,
468
#
469
#       Now piece together a variable $(name_dp) which ends up in
470
#       the command file building the application dependency list.
471
#
472
    $varname = "${name}_dp";
473
 
474
    $cond = "";
475
    foreach $_ ( @$pLibs ) {
476
        if (/^--ifdef=(.*)/) {               # .. conditionals
477
            $cond = "$1";
478
            VarPrt( "ifdef $cond\n" );
479
            next;
480
        } elsif (/^--ifndef=(.*)/) {
481
            $cond = "$1";
482
            VarPrt( "ifndef $cond\n" );
483
            next;
484
        } elsif (/^--*/) {                   # .. unknown
485
            Message( "LD: unknown lib option $_ -- ignored\n" );
486
            next;
487
        }
488
 
489
                                             # .. entry
490
        VarCmd("\$(BINDIR)/${name}${exe}:	@(vpath2,$_.${a},WC386_LIB)" );
491
 
492
        if ($cond) {                         # .. end condition
493
            VarPrt("endif\t# $cond\n");
494
            $cond = "";
495
        }
496
    }
497
}
498
 
499
#.. Successful termination
500
1;
501