Subversion Repositories DevTools

Rev

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

# -*- mode: mak; -*-
##############################################################################
# Copyright (c) VIX TECHNOLOGY (AUST) LTD
#
# File:         TOOLSET/pd386.rul[e]
# Contents:     Paradigm/386 rules
#
# Revision History:
#       20/02/02 APY    Created
#       26/02/02 APY    Added depend post processing to append OBJDIR
#       27/02/02 APY    ; appended to several directives, forcing use of
#                       exe' during execution.  Required by WIN32
#                       toolsets (see xx_term variables),
#       09/04/02        - __PARADIGM__ defined within asm sessions
#                       - trimmed white space
#       20/04/02        - realpath() usage required by debugger.
##############################################################################

##############################################################################
#..     Remove "undef" warnings
#
cc_includes     +=
cc_defines      +=
cxx_includes    +=
cxx_defines     +=
as_includes     +=
as_defines      +=

###############################################################################
#..     C Compiler definition
# Paradigm C++ 6.00.003 Copyright (c) 1998, 2001 Paradigm Systems.
# Syntax is: PCC32 [ options ] file[s]     * = default; -x- = turn switch x off
# -3    * 80386 Instructions        -4      80486 Instructions
# -Ax     Disable extensions        -B      Compile via assembly
# -C      Allow nested comments     -Dxxx   Define macro
# -Exxx   Alternate Assembler name  -Hxxx   Use pre-compiled headers
# -Ixxx   Include files directory   -K      Default char is unsigned
# -Lxxx   Libraries directory       -M      Generate link map
# -N      Check stack overflow      -Ox     Optimizations
# -P      Force C++ compile         -R      Produce browser info
# -RT   * Generate RTTI             -S      Produce assembly output
# -Txxx   Set assembler option      -Uxxx   Undefine macro
# -Vx     Virtual table control     -X      Suppress autodep. output
# -aN     Align on N bytes          -b    * Treat enums as integers
# -c    * Compile only              -d      Merge duplicate strings
# -exxx   Executable file name      -fxx    Floating point options
# -gN     Stop after N warnings     -iN     Max. identifier length
# -jN     Stop after N errors       -k    * Standard stack frame
# -lx     Set linker option         -nxxx   Output file directory
# -oxxx   Object file name          -p      Pascal calls
# -tWxxx  Create Windows app        -u    * Underscores on externs
# -v      Source level debugging    -wxxx   Warning control
# -xxxx   Exception handling        -y      Produce line number info
# -zxxx   Set segment names
#

cc              = @pcc32
cc_init         =
cc_o_switch     =
cc_source       = 
cc_cmdfile      = $(subst /,\\,$(basename $@).cmd)
cc_flags        = @$(cc_cmdfile)
cc_term         = ;                             # ; force use of 'sh.exe'                                

pd_includes     += $(paradigm)/include

# Options:
#
#       -f-     no floating point
#       -j#     stop after # errors
#       -v      generate debug information
#       -0x     optimisation
#       -w      Enable warnings
#       -w-aus  suppress warning for unused variables
#       -w-par  suppress warning for unused function parameters
#       -w-pro  suppress warning for function pointer without protoype
#

pd_flags        =  -c -w -j50 -D__STDC__=1
pd_flags        += -f- -Hu
ifeq "$(DEBUG)" "1"
pd_flags        += -Od -r- -v -R -DDEBUG
else
ifdef PD_NOOPTIM
pd_flags        += -Od -r- -v
else
pd_flags        += -O2 -X -w-aus -w-par -w-pro
endif
endif
ifdef ALVL
pd_flags        += -DALVL=$(ALVL)
endif
ifdef DLVL
pd_flags        += -DDLVL=$(DLVL)
endif
pd_flags        += -D__SOURCE__=\"$(notdir $<)\"
pd_flags        += -D__LOCATE32__

define cc_pre
        @echo [\$<] compiling..
        @$(cmdfile) -ko$(cc_cmdfile) "\
                $(patsubst %,%\\n,$(pd_flags)) \
                $(patsubst %,%\\n,$(CFLAGS)) \
                $(patsubst %,-D%\\n,$(cc_defines)) \                
                $(patsubst %,-I%\\n,$(subst /,\\\\,$(INCDIRS))) \
                $(patsubst %,-I%\\n,$(subst /,\\\\,$(cc_includes))) \
                $(patsubst %,-I%\\n,$(subst /,\\\\,$(pd_includes))) \
                $(subst /,\\\\,-o$@)\\n\
                @(realpath,$(subst /,\\,$<))"
endef

ifndef LEAVETMP
define cc_post
        @$(rm) -f $(cc_cmdfile)
endef
else
define cc_post
endef
endif

###############################################################################
#..     C/C++ dependencies
#       depend and depend.err
#
pd_depend       =  -D__PARADIGM__=600 -D__STDC__
pd_depend       += -D__BORLANDC__=0x530 -D__TURBOC__=0x530
pd_depend       += -D__386__ -D_M_IX86
pd_depend       += -DMSDOS -D__MSDOS__ -D__DOS__
ifeq "$(DEBUG)" "1"
pd_depend       += -DDEBUG
else
pd_depend       += -D__PCOPT__
endif
ifdef ALVL
pd_depend       += -DALVL=$(ALVL)
endif
ifdef DLVL
pd_depend       += -DDLVL=$(DLVL)
endif
pd_depend       += -D__SOURCE__=\"$(notdir $<)\"

ccdep           = @$(SCM_BIN)/mkdepend
ccdep_init      =
ccdep_o_switch  = -f -
ccdep_source    = $(filter %.c %.cc %.cpp, $+) > $(subst /,/,$@).tmp 2> $@.err
ccdep_flags     = -MM \
                $(patsubst %,%,$(CFLAGS)) \
                $(patsubst %,-D%,$(cc_defines)) \
                $(patsubst %,%,$(pd_depend)) \
                $(patsubst %,-I %,$(INCDIRS)) \
                $(patsubst %,-Y %,$(cc_includes)) \
                $(patsubst %,-Y %,$(pd_includes)) \
                $(patsubst %,-Y %,$(NODEPDIRS))

ccdep_pre       =

define ccdep_post
        -sed s/\^/\$$\(OBJDIR\)\\// $(subst /,/,$@).tmp | grep \\.${o} > $(subst /,/,$@)
        @rm $(subst /,/,$@).tmp 
endef

#..     C++ Compiler definition
#
cxx             = @pcc32
cxx_init        =
cxx_o_switch    = -P
cxx_object      = -o$@
cxx_source      =
cxx_cmdfile     = $(subst /,\\,$(basename $@).cmd)
cxx_flags       = @$(cxx_cmdfile)
cxx_term        = ;                             # ; force use of 'sh.exe'                               

define cxx_pre
        @echo [\$<] compiling..
        @$(cmdfile) -ko$(cxx_cmdfile) "\
                $(patsubst %,%\\n,$(CXXFLAGS)) \
                $(patsubst %,-D%\\n,$(cxx_defines)) \
                $(patsubst %,%\\n,$(pd_flags)) \
                $(patsubst %,-I%\\n,$(subst /,\\\\,$(INCDIRS))) \
                $(patsubst %,-I%\\n,$(subst /,\\\\,$(cxx_includes))) \
                $(patsubst %,-I%\\n,$(subst /,\\\\,$(pd_includes))) \
                $(subst /,\\\\,$(cxx_object))\\n\
                @(realpath,$(subst /,\\,$<))"
endef

ifndef LEAVETMP
define cxx_post
        @$(rm) -f $(cxx_cmdfile)
endef
else
define cxx_post
endef
endif


###############################################################################
#..     Assembler definition
#
# PASM32 [options] source [,object] [,listing] [,xref]
# /a,/s          Alphabetic or Source-code segment ordering
# /c             Generate cross-reference in listing
# /dSYM[=VAL]    Define symbol SYM = 0, or = value VAL
# /e,/r          Emulated or Real floating-point instructions
# /h,/?          Display this help screen
# /iPATH         Search PATH for include files
# /jCMD          Jam in an assembler directive CMD (eg. /jIDEAL)
# /kh#           Hash table capacity # symbols
# /l,/la         Generate listing: l=normal listing, la=expanded listing
# /ml,/mx,/mu    Case sensitivity on symbols: ml=all, mx=globals, mu=none
# /mv#           Set maximum valid length for symbols
# /m#            Allow # multiple passes to resolve forward references
# /n             Suppress symbol tables in listing
# /p             Check for code segment overrides in protected mode
# /q             Suppress OBJ records not needed for linking
# /t             Suppress messages if successful assembly
# /uxxxx         Set version emulation, version xxxx
# /w0,/w1,/w2    Set warning level: w0=none, w1=w2=warnings on
# /w-xxx,/w+xxx  Disable (-) or enable (+) warning xxx
# /x             Include false conditionals in listing
# /z             Display source line with error message
# /zi,/zd,/zn    Debug info: zi=full, zd=line numbers only, zn=none
#

as              = @pasm32
as_init         =
as_flags        = @$(as_cmdfile)
as_o_switch     =
as_object       = $(subst /,\\,$@)
as_list         = $(subst /,\\,$(basename $@).lst)
as_source       = $(subst /,\\,$<) ,$(as_object) ,$(as_list)
as_cmdfile      = $(subst /,\\,$(basename $@).cmd)
as_term         = ;                             # ; force use of 'sh.exe'                                

as_i_switch     = /i
as_includes     += $(paradigm)/include

pasm_flags      = /c /ml /t
ifeq "$(DEBUG)" "1"
pasm_flags      += /w2 /zi /DDEBUG
endif
pasm_flags      += /D__PARADIGM__               # Target C/C++ compiler
ifdef DLVL
pasm_flags      += /DDLVL=$(DLVL)
endif
ifdef ALVL
pasm_flags      += /DALVL=$(ALVL)
endif
as_defines      := $(addprefix /D,$(as_defines))
as_defines      += $(pasm_flags)

define as_pre
        @$(cmdfile) -ko$(as_cmdfile) "\
                $(patsubst %,%\\n,$(ASFLAGS)) \
                $(patsubst %,%\\n,$(as_defines)) \
                $(patsubst %,$(as_i_switch)%\\n,$(subst /,\\\\,$(INCDIRS))) \
                $(patsubst %,$(as_i_switch)%\\n,$(subst /,\\\\,$(as_includes)))"
endef

ifndef LEAVETMP
define as_post
        @$(rm) -f $(as_cmdfile)
endef
else
define as_post
endef
endif

#..     Archiver (AR)
#
#       /C      case-sensitive symbol support
#       /E      create an extended dictionary
#       /P      page size
#
ar              = @plib
ar_init         =
ar_cmdfile      = $(subst /,\\,$(basename $@).ar)
ar_flags        = /E /P512
ar_o_switch     = $(subst /,\\,$@) @$(ar_cmdfile)
ar_term         = ;                             # ; force use of 'sh.exe'                                

define ar_pre
        @$(cmdfile) -ko$(ar_cmdfile) \
                $(patsubst %,+% \&\\n,$(subst /,\\\\,$^)) \
                ,$(subst /,\\,$(basename $@).lst); \
        $(rm) -f $@
endef

ifndef LEAVETMP
define ar_post
        @$(rm) -f $(ar_cmdfile)
endef
else
define ar_post
endef
endif


#..     Linker (LD)
#
# PLINK32 objfiles, exefile, mapfile, libfiles, deffile, resfiles
# @xxxx indicates use response file xxxx
# -m      Map file with publics     -x       No map
# -s      Detailed segment map      -L       Specify library search paths
# -M      Map with mangled names    -j       Specify object search paths
# -c      Case sensitive link       -v       Full symbolic debug information
# -Enn    Max number of errors      -n       No default libraries
# -P-     Disable code packing      -H:xxxx  Specify app heap reserve size
# -B:xxxx Specify image base addr   -Hc:xxxx Specify app heap commit size
# -wxxx   Warning control           -S:xxxx  Specify app stack reserve size
# -Txx    Specify output file type  -Sc:xxxx Specify app stack commit size
# -Tpx          PE image            -Af:nnnn Specify file alignment
#               (x: e=EXE, d=DLL)   -Ao:nnnn Specify object alignment
# -ax     Specify application type  -o       Import by ordinals
#         -ap Windowing Compatible  -Vd.d    Specify Windows version
#         -aa Uses Windowing API    -r       Verbose link
#
#   Now the fun part... piecing together a variable $(name_ld)
#   which ends up in the command file.
#
ld              = @plink32
ld_cmdfile      = $(subst /,\\,$(basename $@).ld)
ld_flags        = @$(ld_cmdfile)
ld_o_switch     =
ld_term         = ;                             # ; force use of 'sh.exe'                                

plink_flags     += -s                           # Detailed segment map                   
plink_flags     += -n                           # No default libraries                   
plink_flags     += -c                           # Case sensitive link                   
plink_flags     += -Tpe                         # PE style                                                  
ifeq "$(DEBUG)" "1"
plink_flags     += -v                           # Full symbolic debug information
endif

define ld_pre
        @echo [\$@] linking..
        @export PD386_LIB; \
                PD386_LIB="$(subst $(space),;,$(LIBDIRS))"; \
        $(cmdfile) -ko$(ld_cmdfile) "\
                $(patsubst %,% +\\n,$(plink_flags)) \              
                $($(notdir $(basename $@))_ld)"
endef

ifndef LEAVETMP
define ld_post
        @$(rm) -f $(ld_cmdfile)
endef
else
define ld_post
endef
endif

define LDDEPEND
        @export PD386_LIB; \
                PD386_LIB="$(subst $(space),;,$(LIBDIRS))"; \
        $(cmdfile) -ko$(BINDIR)/$(notdir $(basename $@)).dep \
                "$($(notdir $(basename $@))_dp)"
endef

#..     Locate (LD2 - Linker 2nd phase)
#
#       Usage: LOCATE32 [Options] Application [ConfigFile...]
#
#       As the locate32 command line interface is limited to 
#       explicit arguments without '@' command file support and 
#       to allow the section configuration file to be resolved 
#       a link time, we must locate the config file during the
#       ld2_pre stage.
#..
ld2             = locate32
ld2_config      = $(basename $@).cfg
ld2_flags       = $(LOCATEOPT)
ld2_term        = ;                             # ; force use of 'sh.exe'                                

define ld2_pre
        @echo [\$@] locating..
        @export LOCATE32_CFG; \
                LOCATE32_CFG="$(subst $(space),;,.;$(INCDIRS))"; \
        $(cmdfile) -ko$(ld2_config) \
                "@(vpath2,$(LOCATECFG),LOCATE32_CFG)\\n"
endef

ifndef LEAVETMP
define ld2_post
        @$(rm) -f $(ld2_config)
endef
else
define ld2_post
endef
endif

define LD2
        @$(show_environment)
        $(ld2_pre)
        $(ld2) $(ld2_flags) $< `cat $(ld2_config)` $(ld2_term)
        $(ld2_post)
endef

#