# -*- mode: mak; -*- ############################################################################### # COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED. # # File: TOOLSET/mos_mri.rul[e] # Contents: MRI 68k/CF rules as used for the MOS # Make definitions for the Microtec tools. # # Description: # MRI 68k/CF toolset for MOS # This file provides Toolset rules for the target makefiles # The file is dropped into the target makefile # # Revision History: # 12-Feb-04 DDP Started Work ############################################################################### ############################################################################### #.. Remove "undef" warnings # cc_includes += cc_defines += as_includes += as_defines += cxx_includes += cxx_defines += ############################################################################### #.. Parse user options # Global options already parsed # These options extend the global options # ifdef OPTIONS endif ############################################################################### #.. C Compiler definition # # # Compiler flags # -A, - Sets ANSI-compliant mode. -nA disables all ANSI features. This # is not the same as strict ansi, so don't use it. # -c - Produces an object file but not an executable file. # -Feo - Writes diagnostic messages to standard output. # -Fsm - Includes high-level source code as comments in the assembly output file. # -g - Generates debugging information. # -H - Saves assembly file. # -Og - Enables global-flow optimizations. (-nOg is default) # -Ol - Enables local optimizations. # -OR - Allocates heavily used variables to registers. # -Ob - Performs optimizations that assume that global memory objects are not changed through aliases. # Do not use. More troible than its worth. # -Oe - Generates only one exit (return) from a function. # -Or - Enables instruction scheduling optimization. # -Os - Optimizes in favor of code size rather than execution time. # -v - Detects and issues warnings for features in the source files that can cause problems. # -x - Enables Microtec Compiler extensions to C and C++. (default) # -Kf - Generate stack frame for all functions. # # # The following options are specified within $(mri_compiler_flags) and are considered global # -pxxxx - Produces code for a specified processor. # -mac - Take advantage of the ColdFire MAC unit. # -mdiv - Take advantage of the ColdFire DIV unit. # -Gf - Generates fully qualified path names for input files. # -KhA5 - Reserves one or more registers. # -Ku - Treats plain char variables as unsigned. # -Mcp - Use PC-relative addressing for all code references. # -Md5 - Use register-relative addressing for all static data references. # -Ml - Use 32-bit displacements for register An-relative or PC-relative addressing. # -nQ - The -nQ option does not suppress any messages. # -nze - Disable C++ exception handling. # -Wa,-fNOPCR - Passes options to the assembler. # -Xp - Allocates space for global variables that have not been explicitly initialized. # -zc - Allows // comments in C code. # cc = $(CC_PRE) $(mri_compiler) cc_init = cc_o_switch = cc_object = -o$@ cc_source = $< cc_cmdfile = $(basename $@).cmd cc_flags = -d$(cc_cmdfile) cc_defines = $(mri_compiler_define) $(MRI_DEFINES) cc_filter := $(wildcard $(GBE_ROOT)/warnings.mri) ifdef cc_filter cc_redirect = 1 cc_error_filter = $(awk) -f $(GBE_ROOT)/warnings.mri endif mri_includes += $(MRI_INC) mri_flags += -c $(mri_compiler_flags) ifdef USE_32BIT_RELATIVE mri_flags += -Ml endif ifdef LEAVETMP mri_flags += -H -Fsm endif mri_compiler_strict_ansi ?= -A -nx mri_compiler_no_strict_ansi ?= -A -x ifdef USE_STRICT_ANSI mri_flags += $(mri_compiler_strict_ansi) else mri_flags += $(mri_compiler_no_strict_ansi) endif mri_compiler_opt ?= -Ol -OR -Or -Os -Oe -nOb mri_compiler_no_opt ?= -nOl -nOR -nOg mri_compiler_no_gopt ?= -nOg mri_compiler_gopt ?= -Og ifdef USE_OPTIMISE ifdef NO_OPT_GLOBAL mri_flags += $(mri_compiler_no_gopt) else mri_flags += $(mri_compiler_gopt) endif mri_flags += $(mri_compiler_opt) else mri_flags += $(mri_compiler_no_opt) endif mri_compiler_flags_debug ?= -g -DDEBUG -Kf mri_compiler_flags_no_debug ?= -DNDEBUG -U_DEBUG -UDEBUG # Compiler bug. _DEBUG is defined by default ifdef USE_DEBUGINFO mri_flags += $(mri_compiler_flags_debug) else mri_flags += $(mri_compiler_flags_no_debug) endif ifdef ALVL mri_flags += -DALVL=$(ALVL) endif ifdef DLVL mri_flags += -DDLVL=$(DLVL) endif mri_flags += -D__SOURCE__=$(notdir $<) # # Before executing the compiler we must # 1) Create a command file to contain all the command line arguments # 2) Work around a bug in the MicroTex 68K compiler # The bug is that the compiler uses temp files, but it does not # ensure that the files are empty before it uses them. # The work around is to generate the temp files in a known directory # and to delete all temp files before we compile. # define cc_pre @$(echo) '[$<] compiling..' ; \ $(cmdfile) -ko$(cc_cmdfile) "\ $(patsubst %,%\\n,$(CFLAGS)) \ $(patsubst %,-D%\\n,$(cc_defines)) \ $(patsubst %,%\\n,$(mri_flags)) \ -J$(subst /,\\\\,$(dir $<))\\n \ $(patsubst %,-J%\\n,$(subst /,\\\\,$(INCDIRS))) \ $(patsubst %,-J%\\n,$(subst /,\\\\,$(cc_includes))) \ $(patsubst %,-J%\\n,$(subst /,\\\\,$(mri_includes))) \ $(subst /,\\\\,$(cc_object))";\ if [ -n "$(MRI_TMP)" ] ; then\ if [ ! -d $(MRI_TMP) ] ; then mkdir -p $(MRI_TMP) ; fi;\ touch $(MRI_TMP)/xxx;\ cd "$(MRI_TMP)" && rm -f *;\ fi $(call show_cmdfile,$(cc_cmdfile)) endef ifndef LEAVETMP define cc_post @$(rm) -f $(cc_cmdfile) endef else define cc_post endef endif ############################################################################### #.. C/C++ dependencies # depend and depend.err # mri_depend = -D__STDC__ ifdef USE_DEBUGINFO mri_depend += -DDEBUG else mri_depend += -DNDEBUG endif ifdef ALVL mri_depend += -DALVL=$(ALVL) endif ifdef DLVL mri_depend += -DDLVL=$(DLVL) endif mri_depend += -D__SOURCE__=$(notdir $<) ccdep = $(XX_PRE) $(GBE_BIN)/mkdepend ccdep_init = ccdep_o_switch = -f - ccdep_source = $(filter %.c %.cc %.cpp, $+) > $(subst /,\\,$@) 2> $@.err ccdep_flags = -MM -b -p \$$\(OBJDIR\)/ \ $(foreach shname,$(SHNAMES),-p '$$(OBJDIR)/$(shname)/') \ -o .$(o) \ $(patsubst %,%,$(CFLAGS)) \ $(patsubst %,-D%,$(cc_defines)) \ $(patsubst %,%,$(mri_depend)) \ $(patsubst %,-I %,$(INCDIRS)) \ $(patsubst %,-Y %,$(cc_includes)) \ $(patsubst %,-Y %,$(mri_includes)) \ $(patsubst %,-Y %,$(NODEPDIRS)) ccdep_pre = ccdep_post = #.. C/C++ Lint definitions # lint_flags += \ $(patsubst %,%,$(mri_depend)) \ $(patsubst %,%,$(CLINTFLAGS)) \ $(patsubst %,-D%,$(cc_defines)) \ $(subst $(spacealt),$(space),$(patsubst %,-I"%",$(INCDIRS))) \ $(subst $(spacealt),$(space),$(patsubst %,-I"%",$(cc_includes))) \ $(subst $(spacealt),$(space),$(patsubst %,-I"%",$(mri_includes))) lint_libpath = $(MRI_LIB) #.. C++ Compiler definition # cxx = $(CC_PRE) $(mri_cpp_compiler) cxx_init = cxx_o_switch = cxx_object = -o$@ cxx_source = $< cxx_cmdfile = $(basename $@).cmd cxx_flags = -d$(cxx_cmdfile) define cxx_pre @$(echo) '[$<] compiling..' ; \ $(cmdfile) -ko$(cxx_cmdfile) "\ $(patsubst %,%\\n,$(CFLAGS)) \ $(patsubst %,-D%\\n,$(cc_defines)) \ $(patsubst %,%\\n,$(mri_flags)) \ -J$(subst /,\\\\,$(dir $<))\\n \ $(patsubst %,-J%\\n,$(subst /,\\\\,$(INCDIRS))) \ $(patsubst %,-J%\\n,$(subst /,\\\\,$(cc_includes))) \ $(patsubst %,-J%\\n,$(subst /,\\\\,$(mri_includes))) \ $(subst /,\\\\,$(cxx_object))" endef ifndef LEAVETMP define cxx_post @$(rm) -f $(cxx_cmdfile) endef else define cxx_post endef endif ############################################################################### #.. Assembler definition # # Note: All the options go on the command line at present so this # passes a minimal set of definitions. (v4.3) # as = $(XX_PRE) $(mri_assembler) as_init = as_i_switch = -I as_o_switch = -o$@ as_source = <$< as_cmdfile = asm68_flags = -fP=$(mri_cpu_type)$(mri_coprocessor_type) -frel32 -DCcCpu=$(mri_cpu_code) asm68_flags += $(ASFLAGS) ifdef as_defines asm68_flags += $(addprefix -D,$(as_defines)) endif ifdef USE_DEBUGINFO asm68_flags += -DDEBUG else asm68_flags += -DNDEBUG endif as_flags = $(asm68_flags) ifdef as_includes as_flags += "-I$(subst $(space),;,$(strip $(as_includes)))" endif as_flags += $(patsubst %,-I%,$(INCDIRS)) define as_pre @$(echo) '[$@] Assembling file..' ; \ if [ -n "$(MRI_TMP)" ] ; then\ if [ ! -d $(MRI_TMP) ] ; then mkdir -p $(MRI_TMP) ; fi;\ touch $(MRI_TMP)/xxx;\ cd "$(MRI_TMP)" && rm -f *;\ fi endef define as_post endef #.. Archiver # ar = $(XX_PRE) $(mri_librarian) ar_init = ar_cmdfile = $(basename $@).ar ar_logfile = $(basename $@).ar.log ar_flags = ar_o_switch = < $(ar_cmdfile) ar_term = > $(ar_logfile) define ar_pre @$(echo) '[$@] Creating library archive..' ; \ $(rm) -f $@ ;\ $(cmdfile) -ko$(ar_cmdfile) \ create $(@D)\\$(@F)\\n\ $(patsubst %,addmod %\\n,$(filter %.obj, $^))\ save\\n end\\n endef ifndef LEAVETMP define ar_post @$(rm) -f $(ar_logfile) $(ar_cmdfile) endef else define ar_post endef endif #.. Archive Merge # armerge = $(XX_PRE) $(mri_librarian) armerge_init = armerge_cmdfile = $(basename $@).armerge armerge_logfile = $(basename $@).armerge.log armerge_flags = armerge_o_switch = < $(armerge_cmdfile) > $(armerge_logfile) define armerge_pre @$(echo) '[$@] Creating a Merged library..' ; \ $(rm) -f $@ ;\ $(cmdfile) -ko$(armerge_cmdfile) \ create $@\\n\ $(patsubst %,addlib %\\n,$^)\ save\\n end\\n endef ifndef LEAVETMP define armerge_post @$(rm) -f $(armerge_logfile) $(armerge_cmdfile) endef else define armerge_post endef endif #.. Linker # shld = $(XX_PRE) $(mri_linker) shld_cmdfile = $(basename $@).ld shldabs_flags = -m -c$(shld_cmdfile) shldabs_o_switch = -o$(basename $@).abs > $(basename $@).map define shld_pre @$(echo) '[$@] Linking program ..' ;\ export MRI_LIB; \ MRI_LIB="$(subst $(space),;,$(LIBDIRS))"; \ $(cmdfile) -ko$(shld_cmdfile) "$($(notdir $(SHBASE))_shld)" endef ifndef LEAVETMP define shld_post @$(rm) -f $(shld_cmdfile) endef else define shld_post endef endif define SHLDABS $(show_environment) $(shld_pre) $(shld) $(shldabs_flags) $(shldabs_o_switch); rv=$$?; [ $$rv = 0 ] || rm -f $@; exit $$rv $(shld_post) endef # # Create Library dependency file # define SHLDDEPEND $(XX_PRE) export MRI_LIB; \ MRI_LIB="$(subst $(space),;,$(LIBDIRS))"; \ $(cmdfile) -ko$@ "$($(DPLIST))"; endef # # Use the BRT utility to generate relocation information # Assumes that the variable BRTROOT has been set to provide the root of all file names # define BRT @$(echo) "[$@] Generate Relocation information.." $(XX_PRE)$(TOOL_BRT) $(OBJDIR)/$(BRTROOT)_0.abs $(OBJDIR)/$(BRTROOT)_o.abs $(OBJDIR)/$(BRTROOT)_rtab_cd.asm $(OBJDIR)/$(BRTROOT)_rtab_d.asm endef # # Use the modcrc utility to convert an .abs files (really s19) into a .thx file # define MODCRC @$(echo) "[$@] Add CRC information.." $(XX_PRE)$(TOOL_MODCRC) -m=$(basename $@) -t=247 endef # # Use the modcrc utility to convert an .abs files (really s19) into a .bin file # define MODCRC_BIN @$(echo) "[$@] Add CRC information to BIN.." $(XX_PRE)$(TOOL_MODCRC) -m=$(basename $@) -o=bin endef # # Convert the .rel file into a head.obj file # This is done as an atomic step # NOTE: This is a function and not a definition # Args: $1 - Rel file # $2 - head.asm file # $3 - output objfile # $4 - saved head.inc file # # Assumes that include files required by head.asm are in the same # directory as head.asm. # define AS_HEAD @$(echo) "[$@] Creating module header.." $(XX_PRE) $(TOOL_REL) i -d$1 -t$(OBJDIR) $(XX_PRE) $(as) -fP=$(mri_cpu_type)$(mri_coprocessor_type) -fNOPCR -frel32 -I $(OBJDIR) -I $(dir $2) -o$3 <$2 $(XX_PRE) $(rm) -f $4 $(XX_PRE) $(cp) $(OBJDIR)/head.inc $4 endef # # Create VisionClick files # Args: $1 Path of the source ABS file # $2 Output visionclick path file # $3 Vclick drive prefix # Use convert twice: Sometimes fails if both files generated together # define VCLICK $(XX_PRE) $(echo) "[$@] Create VISIONCLICK files.." ;\ $(TOOL_VPATHS) $1 -o $2 -p $3 ;\ $(est32)/convert -e $(basename $1).abs -c $(basename $1).ab ;\ $(est32)/convert -e $(basename $1).abs -b $(basename $1).bdx endef #