Subversion Repositories DevTools

Rev

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

# -*- mode: mak; -*-
###############################################################################
# File:         TOOLSET/sunworks.rul[e]
# Contents:     SunWorks rules
#
###############################################################################

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


###############################################################################
#..     Toolset defaults
#

###############################################################################
#..     Parse user options
#       Global options already parsed
#       These options extend the global options
#
CC_PURIFY =

suncc_filter    := "$(notdir $(wildcard $(GBE_ROOT)/warnings.sunworks))"
ifeq ($(strip $(suncc_filter)), "warnings.sunworks")
suncc_filter    = $(GBE_ROOT)/warnings.sunworks
else
suncc_filter    =
endif

ifdef OPTIONS

ifneq "$(findstring warnings,$(OPTIONS))" ""    # Show all warnings
suncc_filter    =
endif

ifneq "$(findstring purify,$(OPTIONS))" ""      # Enable purify
CC_PURIFY        += purify
endif

ifneq "$(findstring purecov,$(OPTIONS))" ""     # Enable pure coverage
CC_PURIFY       += purecov
endif

ifneq "$(findstring quantify,$(OPTIONS))" ""    # Enable quantify
CC_PURIFY       += quantify
endif

ifneq "$(findstring ccdepend,$(OPTIONS))" ""    # Build depends using CC
USE_CCDEPEND    = 1
endif
endif

###############################################################################
#..     Common compiler and linker flags
#
ifdef THREADMODE
common_flags         += -mt
endif
ifdef MISALIGN
common_flags         += -misalign
endif
ifdef COMPILE32
common_flags         += -xtarget=generic
endif
ifdef COMPILE64
common_flags         += -m64 -KPIC
  ifndef ISA_SPARC
  common_flags       += -xmodel=medium
  endif
endif


###############################################################################
#..     C Compiler definition
#
ifndef SUNWSPRO_SC
    $(error Internal: SUNWSPRO_SC has not been defined by the build system)
endif
ifndef AR_PATH
    $(error Internal: AR_PATH has not been defined by the build system)
endif

#
#       Ensure that AR can be found in the path
#       Place the compiler in the path for good measure

#
PATH := $(AR_PATH):$(SUNWSPRO_SC)/bin:$(PATH)
export PATH

CCOMPILER       := cc

ifdef FORCE_C_COMPILE
 CCOMPILER      := cc
endif

ifdef FORCE_CC_COMPILE
 CCOMPILER      := CC
endif

ifeq "$(CCOMPILER)" "cc"
 CFLAGS         := $(CFLAGS) -erroff=E_WHITE_SPACE_IN_DIRECTIVE
endif

LIBDIRS         += $(SUNWSPRO_SC)/lib

SHCFLAGS        += -KPIC
SHCXXFLAGS      += -KPIC
     
ifdef suncc_filter
cc_redirect_stderr = 1
cc_error_filter = $(awk) -f $(suncc_filter)
endif

cc              = $(CC_PRE)$(CC_PURIFY) $(SUNWSPRO_SC)/bin/$(CCOMPILER)
cc_init         =
cc_o_switch     = -o $@
cc_source       = $<
cc_flags        = \
                $(patsubst %,%,$(CFLAGS)) \
                $(patsubst %,-D%,$(cc_defines)) \
                $(patsubst %,%,$(suncc_flags)) \
                $(patsubst %,-I%,$(INCDIRS)) \
                $(patsubst %,-I%,$(cc_includes)) \
                $(patsubst %,-I%,$(suncc_includes))

suncc_includes  +=

suncc_flags     = -c
suncc_flags     += $(common_flags)
ifdef suncc_filter
suncc_flags     += +w2
else
suncc_flags     += +w
endif
ifdef USE_DEBUGINFO
suncc_flags       += -g -DDEBUG -xs
endif
ifdef USE_OPTIMISE
suncc_flags     += -xO2
endif
ifdef ALVL
suncc_flags     += -DALVL=$(ALVL)
endif
ifdef DLVL
suncc_flags     += -DDLVL=$(DLVL)
endif
suncc_flags     += -D__SOURCE__=\"$(notdir $<)\"

define cc_pre
        @echo [$<] compiling..
endef

define cc_post
endef

###############################################################################
#..     C/C++ dependencies
#
suncc_depend    +=
ifndef USE_CCDEPEND
suncc_depend    += -MM -D__STDC__ -Dunix -Dsun -D$(HOST_CPU)
else
suncc_depend    += -xM1
endif
ifdef USE_DEBUGINFO
suncc_depend    += -DDEBUG
endif
ifdef ALVL
suncc_depend    += -DALVL=$(ALVL)
endif
ifdef DLVL
suncc_depend    += -DDLVL=$(DLVL)
endif

ifndef USE_CCDEPEND
ccdep           = $(XX_PRE) $(GBE_BIN)/mkdepend
ccdep_init      =
ccdep_o_switch  = -o.${o} -f -
else
ccdep           = $(XX_PRE) $(SUNWSPRO_SC)/bin/CC
ccdep_init      =
ccdep_o_switch  = -E
endif

ccdep_source    = $(filter %.c %.cc %.cpp, $+) > $(subst /,/,$@).tmp 2> $(OBJDIR)/depend.err

ccdep_flags     = \
                $(patsubst %,%,$(CFLAGS)) \
                $(patsubst %,-D%,$(cc_defines)) \
                $(patsubst %,%,$(suncc_depend))
ifndef USE_CCDEPEND
ccdep_flags     += \
                $(patsubst %,-I %,$(INCDIRS)) \
                $(patsubst %,-I %,$(cc_includes)) \
                $(patsubst %,-Y %,$(suncc_includes)) \
                -Y $(SUNWSPRO_SC)/include/CC/Cstd \
                -Y $(SUNWSPRO_SC)/include/CC \
                -Y /usr/include
else
ccdep_flags     += \
                $(patsubst %,-I%,$(INCDIRS)) \
                $(patsubst %,-I%,$(cc_includes))
endif

        #
        #   Parse the depend output:
        #
        #   s/^.*/\(.*\.${o}\:\)/$(OBJDIR)/\1/g
        #        replace all object rules which contain / seperated
        #        subdirs with a stripped prefixed object name.
        #
        #        eg. subdir/dir/object.o:        $(OBJDIR)/object.o
        #
        #   s/^\([^/].*\.${o}\:\)/$(OBJDIR)/\1/g
        #        prefix all object rules without subdirs.
        #
        #        eg. object.o:                   $(OBJDIR)/object.o
        #..

ccdep_pre       =

ccdep_sed       = \
        -sed -e 's/^.*\/\(.*\.${o}\:\)/\$$\(OBJDIR\)\/\1/g' \
             -e 's/^\([^/]*\.${o}\:\)/\$$\(OBJDIR\)\/\1/g' \
                $(subst /,/,$@).tmp > $@ 2>> $(OBJDIR)/depend.err;
ifdef SHNAMES
ccdep_sedsh     = \
        sed  -e 's/^.*\/\(.*\.${o}\:\)/\$$\(OBJDIR\)\/$(shname)\/\1/g' \
             -e 's/^\([^/]*\.${o}\:\)/\$$\(OBJDIR\)\/$(shname)\/\1/g' \
                $(subst /,/,$@).tmp >> $@ 2>> $(OBJDIR)/depend.err;
ccdep_sed       += \
                $(foreach shname,$(SHNAMES),$(ccdep_sedsh))
endif

ifndef LEAVETMP
define ccdep_post
        @$(ccdep_sed)
        @rm $(subst /,/,$@).tmp
endef
else
define ccdep_post
        @$(ccdep_sed)
endef
endif

#..     C++ Compiler definition
#
ifdef suncc_filter
cxx_redirect_stderr = 1
cxx_error_filter = $(awk) -f $(suncc_filter)
endif

cxx             = $(CC_PRE)$(CC_PURIFY) $(SUNWSPRO_SC)/bin/CC
cxx_init        =
cxx_o_switch    = -o $@
cxx_source      = $<
cxx_flags       = \
                $(patsubst %,%,$(CXXFLAGS)) \
                $(patsubst %,-d%,$(cxx_defines)) \
                $(patsubst %,%,$(suncc_flags)) \
                $(patsubst %,-I%,$(INCDIRS)) \
                $(patsubst %,-I%,$(cxx_includes)) \
                $(patsubst %,-I%,$(suncc_includes))

define cxx_pre
        @echo [$<] compiling..
endef

define cxx_post
endef

###############################################################################
#..     Assembler definition
#

#..     Assembler (CC)
#
as              = $(XX_PRE) $(SUNWSPRO_SC)/bin/CC
as_init         =
as_i_switch     = -I$(space)
as_o_switch     =
as_object       = -o $@
as_source       = $<
as_cmdfile      = $(basename $@).cmd
as_flags        = @$(as_cmdfile)

as_flags        = -Wall -x assembler-with-cpp -c
ifdef USE_DEBUGINFO
as_flags        += -g -DDEBUG
endif
ifdef DLVL
as_flags        += -DDLVL=$(DLVL)
endif
ifdef ALVL
as_flags        += -DALVL=$(ALVL)
endif
as_defines      := $(addprefix -D,$(as_defines))
as_defines      += $(as_flags)

define as_pre
        @echo [$@] compiling
        @$(cmdfile) -ko$(as_cmdfile) "\
                $(patsubst %,%\\n,$(ASFLAGS)) \
                $(patsubst %,%\\n,$(as_defines)) \
                $(patsubst %,$(as_i_switch)%\\n,$(INCDIRS)) \
                $(patsubst %,$(as_i_switch)%\\n,$(as_includes)) \
                $(as_object)\\n"
endef

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

###############################################################################
#..     Archiver definition
#

#..     Archiver
#
ar              = $(XX_PRE) $(SUNWSPRO_SC)/bin/CC
ar_init         =
ar_flags        = -xar -o
ar_o_switch     = $@ $^

define ar_pre
        @echo [$@] Building library..
endef

define ar_post
endef


#..     Archive Merge
#
armerge         = $(XX_PRE) $(GBE_TOOLS)/armerge
armerge_init    =
armerge_flags   = -d $(MLIBDIR) -t unix
armerge_o_switch= $@ $^

define armerge_pre
        @echo [$@] Building merged library..
        -@$(rm) -f $@
endef

armerge_post    =

#..     Linked (shared library support)
#
#       The following are detailed within the context of TARGET definition:
#
#       SHNAME  Defines the shared library soname (eg lib.so.1.1)
#       SHBASE  Defines the base library linkname (eg lib.so)
#
shld            = $(CC_PRE) $(SUNWSPRO_SC)/bin/CC
shld_init       =
shld_o_switch   = -o $@

shld_flags      += +w -G -h'$(SHNAME)'
ifdef USE_DEBUGINFO
shld_flags      += -g
endif
shld_flags      += $(common_flags)
shld_flags      += \
                $(patsubst %,-L%,$(LIBDIRS)) \
                $(patsubst %,-%,$(LDFLAGS)) \
                $($(notdir $(SHBASE))_shld)

define shld_pre
        @echo [$@] Linking shared library ..
endef

define shld_post
endef

define SHLDDEPEND
        $(AA_PRE)export CC_LIB; \
                CC_LIB="$(subst $(space),;,$(LIBDIRS))"; \
        $(cmdfile) -o$@ "$($(DPLIST))"
endef

#..     Linker
#
ld              = $(CC_PRE)$(CC_PURIFY) $(SUNWSPRO_SC)/bin/CC
ld_init         =
ld_o_switch     = -o $@

ld_flags        += +w
ifdef USE_DEBUGINFO
ld_flags        += -g
endif
ld_flags        += $(common_flags)
ld_flags        += \
                $(patsubst %,-L%,$(LIBDIRS)) \
                $(patsubst %,-%,$(LDFLAGS)) \
                $($(notdir $(basename $@))_ld)

define ld_pre
        @echo [$@] Linking application ..
endef

define ld_post
endef

define LDDEPEND
        $(AA_PRE)export CC_LIB; \
                CC_LIB="$(subst $(space),;,$(LIBDIRS))"; \
        $(cmdfile) -o$@ "$($(DPLIST))"
endef

#