Subversion Repositories DevTools

Rev

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

###############################################################################
# Copyright (c) VIX TECHNOLOGY (AUST) LTD
#
# File:         TOOLSET/delphi7.rul[e]
# Contents:     Rules to build Delphi
#
###############################################################################


###############################################################################
#..     Parse user options
#       Global options already parsed
#       These options extend the global options
#
ifdef OPTIONS

ifneq "$(findstring wall,$(OPTIONS))" ""        # Enable all warnings
USE_WALL        = 1
endif

endif

#
################################################################################
#Syntax: dcc32 [options] filename [options]
#
#  -A<unit>=<alias> = Set unit alias  -LU<package> = Use package
#  -B = Build all units               -M = Make modified units
#  -CC = Console target               -N<path> = DCU output directory
#  -CG = GUI target                   -O<paths> = Object directories
#  -D<syms> = Define conditionals     -P = look for 8.3 file names also
#  -E<path> = EXE output directory    -Q = Quiet compile
#  -F<offset> = Find error            -R<paths> = Resource directories
#  -GD = Detailed map file            -U<paths> = Unit directories
#  -GP = Map file with publics        -V = Debug information in EXE
#  -GS = Map file with segments       -VR = Generate remote debug (RSM)
#  -H = Output hint messages          -W = Output warning messages
#  -I<paths> = Include directories    -Z = Output 'never build' DCPs
#  -J = Generate .obj file            -$<dir> = Compiler directive
#  -JP = Generate C++ .obj file       --help = Show this help screen
#  -K<addr> = Set image base addr     --version = Show name and version
#
#Compiler switches: -$<letter><state> (defaults are shown below)
#  A8  Aligned record fields           P+  Open string params
#  B-  Full boolean Evaluation         Q-  Integer overflow checking
#  C+  Evaluate assertions at runtime  R-  Range checking
#  D+  Debug information               T-  Typed @ operator
#  G+  Use imported data references    U-  Pentium(tm)-safe divide
#  H+  Use long strings by default     V+  Strict var-strings
#  I+  I/O checking                    W-  Generate stack frames
#  J-  Writeable structured consts     X+  Extended syntax
#  L+  Local debug symbols             Y+  Symbol reference info
#  M-  Runtime type info               Z1  Minimum size of enum types
#  O+  Optimization
################################################################################

#
# Calculate definitions common to all the build modes
#     Definitions
#     Include Paths
#     Object Directories
#     Resource Dirs
#     Unit Dirs
#
dcc_defines =
dcc_delphi_core =
dcc_flags = $(CFLAGS)

ifeq "$(DEBUG)" "1"
dcc_defines     += -DDEBUG -$$D+ -$$L+
dcc_delphi_core += $(DELPHI7)/Lib/Debug $(DELPHI7)/Lib
else
dcc_delphi_core += $(DELPHI7)/Lib
dcc_defines     += -$$D
endif

dcc_includes = $(INCDIRS) $(dcc_delphi_core)
dcc_resources = $(OBJDIR) $(dcc_delphi_core)
dcc_units = $(LIBDIRS) $(dcc_delphi_core)


dcc_defines     += -D__SOURCE__=\"$(notdir $(PSOURCE))\"

ifdef USE_WALL
dcc_flags += -W -H
endif

dcc_common_flags = -Q -Z -GP -GS \
        $(dcc_flags) \
        $(dcc_defines) \
        $(patsubst %,-I%,$(dcc_includes)) \
        $(patsubst %,-R%,$(dcc_resources) $(dcc_includes)) \
        $(patsubst %,-U%,$(dcc_units))

#
# Rule to create a program
# Defs:
#       PSOURCE         - Path to the source
#       PFLAGS          - Flags from the Prog directive
#       PACKAGES        - Packages to be used
#       $@              - Path to the output
#
# Delphi has a mind of its own
# Must check that its doing what we want to prevent the user doing silly things
#
define DCC
        @echo [$(notdir $(PSOURCE))] compiling prog..
        $(AA_PRE)-rm -f $@
        $(XX_PRE)$(DELPHI7)/bin/dcc32 $(dcc_common_flags) -E$(BINDIR) $(PFLAGS) -N$(OBJDIR) $(patsubst %,-LU%,$(PACKAGES)) $(subst /,\\,$(PSOURCE))
        $(AA_PRE)if [ ! -f $@ ] ; then echo "[Make] (E) Build artifact not found: $@"; exit 1; fi
endef

#
# Rule to create a Shared Library
# Defs:
#       PSOURCE         - Path to the source
#       PFLAGS          - Flags from the Prog directive
#       SHLIBBASE       - Base name of the shared library
#       PACKAGES        - Packages to be used
#       $@              - Path to the output
#
# Delphi has a mind of its own
# Must check that its doing what we want to prevent the user doing silly things
#
# Put any DCUs that are created into the OBJ directory
# Since they are created as a side effect we can hide them away
#
define SHDCC
        @echo [$(notdir $(PSOURCE))] compiling library..
        $(AA_PRE)-rm -f $@
        $(XX_PRE)$(DELPHI7)/bin/dcc32 $(dcc_common_flags) -E$(LIBDIR) -LE$(LIBDIR)  $(PFLAGS) -LN$(LIBDIR) -N$(OBJDIR)/$(SHLIBBASE) $(patsubst %,-LU%,$(PACKAGES)) $(subst /,\\,$(PSOURCE))
        $(AA_PRE)if [ ! -f $@ ] ; then echo "[Make] (E) Build artifact not found: $@"; exit 1; fi
endef

#
# Rule to create a .LIB from a .DLL
# Defs:
#       TMPFILE         - PAth of temp file
#
define IMPLIB
        @echo [$(notdir $(notdir $@))] create import library..
        $(AA_PRE)if [ ! -x "$(BCB_IMPDEF_PATH)/impdef.exe" ] ; then echo "[Make] (E) Need, from borland builder: $(BCB_IMPDEF_PATH)/impdef"; exit 1; fi
        $(AA_PRE)if [ ! -x "$(MS_LINK_PATH)/link.exe" ] ; then echo "[Make] (E) Need, from MS VC6: $(MS_LINK_PATH)/link"; exit 1; fi
        $(AA_PRE)-rm -f $@ $(TMPFILE)
        $(XX_PRE)$(BCB_IMPDEF_PATH)/impdef $(TMPFILE) $<
        $(XX_PRE)$(MS_LINK_PATH)/link /lib /machine:ix86 /def:$(TMPFILE) /out:$@
        $(AA_PRE)if [ ! -f $@ ] ; then echo "[Make] (E) Build artifact not found: $@"; exit 1; fi
endef

#
# Rule to create a Unit
# Defs:
#       PSOURCE         - Path to the source
#       $@              - Path to the output
#
# Delphi has a mind of its own
# Must check that its doing what we want to prevent the user doing silly things
#
define DCC_AR
        @echo [$(notdir $(PSOURCE))] compiling unit..
        $(AA_PRE)-rm -f $@
        $(XX_PRE)$(DELPHI7)/bin/dcc32 $(dcc_common_flags) -E$(BINDIR) $(PFLAGS) -N$(LIBDIR) $(patsubst %,-LU%,$(PACKAGES)) $(subst /,\\,$(PSOURCE))
        $(AA_PRE)if [ ! -f $@ ] ; then echo "[Make] (E) Build artifact not found: $@"; exit 1; fi
endef

#
# Rule to compile a resource file
#       $@ - Target
#       $< - source file ( first prereq: MUST BE )
#
define DRES
        @echo [$(notdir $(@))] Compile Resource..
        $(XX_PRE)$(DELPHI7)/bin/brcc32 -fo$@ -x $< $(patsubst %,-i%,$(dcc_includes))
endef