Subversion Repositories DevTools

Rev

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

# -*- mode: perl; tabs: 8; indent-width: 4; show-tabs: yes; -*-
#
# Module name   : djgpp
# Module type   : Makefile system
# Compiler(s)   : ANSI C
# Environment(s): DJGPP/EOS2
#
# Description:
#       DJGPP C/C++ toolset using GO32 and MASM
#
# Version   Who      Date        Description
# 1.0       APY      01/02/00    Created
#
# $Name:  $
# $Source: /cvsroot/etm/devl/CFG/TOOLSET/DJGPP,v $
# $Revision: 1.2 $ $Date: 2004/05/06 09:06:44 $ $State: Exp $
# $Author: ayoung $ $Locker:  $
#............................................................................#

##############################################################################
#   ToolsetInit()
#       Runtime initialisation
#
##############################################################################

ToolsetInit();

sub ToolsetInit
{
#.. standard.rul requirements
    $s = 'asm';
    $o = 'o';
    $a = 'a';
    $exe = ".exe";

#.. define DJGPP environment
    Init( "djgpp" );
    ToolsetDefines( "djgpp.def" );
    ToolsetRules( "djgpp.rul" );
    ToolsetRules( "standard.rul" );
}


###############################################################################
#   ToolsetCC( $source, $obj, \@args )
#       This subroutine takes the user options and builds the rule(s)
#       required to compile the source file 'source' to 'obj'
#
###############################################################################

sub ToolsetCC
{
    MakePrint( "\n\t\$(CC)\n" );
}

###############################################################################
#   ToolsetCCDepend( $depend, \@sources )
#       This subroutine takes the user options and builds the
#       rule(s) required to build the dependencies for the source
#       files 'sources' to 'depend'.
#
###############################################################################

sub ToolsetCCDepend
{
    MakePrint( "\t\$(CCDEPEND)\n" );
}


###############################################################################
#   ToolsetCXX( $source, $obj, \@args )
#       This subroutine takes the user options and builds the rule(s)
#       required to compile the source file 'source' to 'obj'
#
###############################################################################

sub ToolsetCXX
{
    MakePrint( "\n\t\$(CXX)\n" );
}

###############################################################################
#   ToolsetCXXDepend( $depend, \@sources )
#       This subroutine takes the user options and builds the
#       rule(s) required to build the dependencies for the source
#       files 'sources' to 'depend'.
#
###############################################################################

sub ToolsetCXXDepend
{
    #ToolsetCCDepend() handles both CC and CXX source
}


###############################################################################
#   ToolsetAS( $source, $obj, \@args )
#       This subroutine takes the user options and builds the rule(s)
#       required to compile the source file 'source' to 'obj'
#
###############################################################################

sub ToolsetAS
{
    MakePrint( "\n\t\$(AS)\n" );
}

sub ToolsetASDepend
{
}


###############################################################################
#   ToolsetAR( $name, \@args, \@objs )
#       This subroutine takes the user options and builds the rules
#       required to build the library 'name'.
#
#   Arguments:
#       --Eos2[=prefix]         Local EOS configuration (defaults to platform)
#       --Isp=name              ISP module
#
#   Output:
#       [ $(BINDIR)/name$.${a}:   .... ]
#           $(AR)
#
#       name_ld += ...  Linker command file
#           :
#
#       name_dp += ...  Dependency list
#           :
#
###############################################################################

sub ToolsetAR
{
    my( $name, $pArgs, $pObjs ) = @_;
    my( $amx );

    local( $name_ld );

#.. Parse arguments
#
    $eos = 0;                                   # options
    foreach $_ ( @$pArgs ) {
        if (/^--Amx$/) {                        # Local AMX config
            Error( "AR: --Amx support not available\n" );
        } elsif (/^--Amx=(.*)/) {               # Specific AMX config
            Error( "AR: --Amx support not available\n" );
        } elsif (/^--Insight$/) {               # Enable insight
            Error( "AR: --Insight support not available\n" );
        } elsif (/^--Insight=(.*)/) {           # Specific insight
            Error( "AR: --Insight support not available\n" );

        } elsif (/^--Eos2$/) {                  # Local EOS config
            $eos    = "\$(SCM_PLATFORM)";
        } elsif (/^--Eos2=(.*)/) {              # Specific EOS config
            $eos    = "$1";

        } elsif (/^--Isp=(.*)/) {               # ISP module
            Eos2LibISP( $name, "$1" );

        } else {
            Message( "AR: unknown option $_ -- ignored\n" );
        }
    }

#.. Target
#
    MakeEntry( "\$(LIBDIR)/$name\$(GBE_TYPE).${a}:\t", "", "\\\n\t\t", "", @$pObjs );

#.. Build library with EOS2 configuration
#
    if ( $eos ) {
        Eos2Lib( $name, $eos );
    }

#.. Build library rule (just append to standard rule)
#
    MakePrint( "\n\t\$(AR)\n\n" );
}


###############################################################################
#   ToolsetLD( $name, \@args, \@objs, \@libraries )
#       This subroutine takes the user options and builds the rules
#       required to link the program 'name'.
#
#   Arguments:
#       --Eos                   EOS application
#       --Eosx                  Extended EOS application
#       --Eos[=prefix]          EOS application, plus configuration
#       --Eosx[=prefix]         Extended EOS application, plus configuration
#       --NetUdp                Networking with UDP support
#       --NetTcp                Networking with TCP support
#       --Isp=name              ISP module
#       --Coff                  COFF format (default)
#       --Insight[=prefix]      n/a
#       --Amx[=prefix]          n/a
#       --Insight[=prefix]      n/a
#       --Rel                   n/a
#       --Abs                   n/a
#
#   Output:
#       $(BINDIR)/name.exe:
#                       $(BINDIR)/name.dep
#           $(LD)
#
#       $(BINDIR)/name.dep:    $(SCM_PLATFORM).mk
#               $(LDDEPEND)
#
#       ifeq "$(IFLAG)" "3"
#       -include        "$(BINDIR)/name.dep"
#       endif
#
#       name_ld += ...
#           :
#
###############################################################################

sub ToolsetLD
{
    my( $name, $pArgs, $pObjs, $pLibs ) = @_;
    my( $flags, $eos );
    local( $varname );

#.. Parse arguments
#
    $eos = $flags = 0;                          # options
    foreach $_ ( @$pArgs )
    {
    #.. EOS
    #
        if (/--Eos$/) {                         # EOS standard
            $flags      = $flags | $EOS_LNK;
        } elsif (/^--Eos=(.*)$/) {              # plus config
            $flags      = $flags | $EOS_LNK;
            $eos        = "\$(SCM_PLATFORM)";
        } elsif (/^--Eosx$/) {                  # EOS extended
            $flags      = $flags | $EOS_LNK | $EOS_EXT;
        } elsif (/^--Eosx=(.*)$/) {             # plus config
            $flags      = $flags | $EOS_LNK | $EOS_EXT;
            $eos        = "\$(SCM_PLATFORM)";

        } elsif (/^--Isp=(.*)/) {               # ISP module
            AmxLinkISP( $name, "$1", $pObjs, $pLibs );

        } elsif (/^--Kdb/) {                    # Kernel debugger
            $flags = $flags | $EOS_KDB;

    #.. Networking
    #
        } elsif (/^--NetUdp$/) {
            $flags     = $flags | $NET_UDP;
        } elsif (/^--NetTcp$/) {
            $flags     = $flags | $NET_TCP;

    #.. Compat stuff
    #
        } elsif (/^--Amx/) {                    # Local AMX config
            Error( "LD: --Amx support not available\n" );
        } elsif (/^--Insight/) {                # Enable insight
            Error( "LD: --Insight support not available\n" );

    #.. Target specific
    #
        } elsif (/^--Rom=(.*)/) {               # ROM image
            Message( "LD: not suitable under WC386 '$_' -- ignored\n" );
        } elsif (/^--Bin=(.*)/) {               # Download image
            Message( "LD: not suitable under WC386 '$_' -- ignored\n" );
        } elsif (/^--Abs/) {                    # Absolute image
            Message( "LD: not suitable under WC386 '$_' -- ignored\n" );

    #.. Toolset specific
    #

    #.. Default, ignore
    #
        } else {
            Message( "LD: unknown option $_ -- ignored\n" );
        }
    }

#.. Command file EOS dependencies
#
#   Library search order,
#       Application
#       EOS
#       EOS/RTX
#       Toolset
#
    if ( $flags ) {
        EosLink( $name, $flags, $pObjs, $pLibs );
        if ( $eos ) {
            Eos2LinkCfg( $name, $eos, $pObjs, $pLibs );
        } else {
            Eos2LinkStd( $name, $pObjs, $pLibs );
        }
    } elsif ( $eos ) {
        Eos2LinkCfg( $name, $eos, $pObjs, $pLibs );
    }

#.. Cleanup rules
#
    ToolsetGenerate( "\$(BINDIR)/${name}.ld" );
    ToolsetGenerate( "\$(BINDIR)/${name}.dep" );
    ToolsetGenerate( "\$(BINDIR)/${name}.map" );

#.. Linker command file
#
#       Now the fun part... piecing together a variable $(name_ld)
#       which ends up in the command file.
#
    MakePrint( "\\\n\t\t\$(BINDIR)/${name}.dep\n" .
               "\t\$(LD)\n\n" );

    MakePrint( "\$(BINDIR)/${name}.dep:\t\$(SCM_PLATFORM).mk\n".
               "\t\$(LDDEPEND)\n\n" );
               
    MakePrint( "ifeq \"\$(IFLAG)\" \"3\"\n" .
               "-include\t\$(BINDIR)/${name}.dep\n" .
               "endif\n\n" );

    $varname = "${name}_ld";
    sub VarCmd {                                # with line feed ...
        MakeQuote ("$varname += @_\\n\n");
    }
    sub VarCmd2 {                               # without line feed ...
        MakeQuote ("$varname += @_\n");
    }
    sub VarPrt {
        MakePrint ("@_\n");
    }

    foreach $i ( @$pObjs ) {
        VarCmd( "\$(strip $i).${o}" );
    }
    foreach $i ( @$pLibs ) {
        VarCmd( "@(vpath,$i.${a},DJGPP_LIB)" );
    }

    if ($flags || $eos) {
    } else {
    }

        VarCmd( "-o \$(BINDIR)/${name}${exe}" );
        VarPrt( "" );

#.. Dependency link,
#
#       Now piece together a variable $(name_dp) which ends up in
#       the command file building the application dependency list.
#
    $varname = "${name}_dp";

    foreach $i ( @$pLibs ) {
          VarCmd("\$(BINDIR)/${name}${exe}:     @(vpath,$i.${a},DJGPP_LIB)" );
    }
}

#.. Successful termination
1;