Rev 5709 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
# -*- 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 OPTIONSendif################################################################################.. 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 $@).cmdcc_flags = -d$(cc_cmdfile)cc_defines = $(mri_compiler_define) $(MRI_DEFINES)cc_filter := $(wildcard $(GBE_ROOT)/warnings.mri)ifdef cc_filtercc_redirect = 1cc_error_filter = $(awk) -f $(GBE_ROOT)/warnings.mriendifmri_includes += $(MRI_INC)mri_flags += -c $(mri_compiler_flags)ifdef USE_32BIT_RELATIVEmri_flags += -Mlendififdef LEAVETMPmri_flags += -H -Fsmendifmri_compiler_strict_ansi ?= -A -nxmri_compiler_no_strict_ansi ?= -A -xifdef USE_STRICT_ANSImri_flags += $(mri_compiler_strict_ansi)elsemri_flags += $(mri_compiler_no_strict_ansi)endifmri_compiler_opt ?= -Ol -OR -Or -Os -Oe -nObmri_compiler_no_opt ?= -nOl -nOR -nOgmri_compiler_no_gopt ?= -nOgmri_compiler_gopt ?= -Ogifdef USE_OPTIMISEifdef NO_OPT_GLOBALmri_flags += $(mri_compiler_no_gopt)elsemri_flags += $(mri_compiler_gopt)endifmri_flags += $(mri_compiler_opt)elsemri_flags += $(mri_compiler_no_opt)endifmri_compiler_flags_debug ?= -g -DDEBUG -Kfmri_compiler_flags_no_debug ?= -DNDEBUG -U_DEBUG -UDEBUG # Compiler bug. _DEBUG is defined by defaultifdef USE_DEBUGINFOmri_flags += $(mri_compiler_flags_debug)elsemri_flags += $(mri_compiler_flags_no_debug)endififdef ALVLmri_flags += -DALVL=$(ALVL)endififdef DLVLmri_flags += -DDLVL=$(DLVL)endifmri_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 *;\fiendefifndef LEAVETMPdefine cc_post@$(rm) -f $(cc_cmdfile)endefelsedefine cc_postendefendif################################################################################.. C/C++ dependencies# depend and depend.err#mri_depend = -D__STDC__ifdef USE_DEBUGINFOmri_depend += -DDEBUGelsemri_depend += -DNDEBUGendififdef ALVLmri_depend += -DALVL=$(ALVL)endififdef DLVLmri_depend += -DDLVL=$(DLVL)endifmri_depend += -D__SOURCE__=$(notdir $<)ccdep = $(XX_PRE) $(GBE_BIN)/mkdependccdep_init =ccdep_o_switch = -f -ccdep_source = $(filter %.c %.cc %.cpp, $+) > $(subst /,\\,$@) 2> $@.errccdep_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 $@).cmdcxx_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))"endefifndef LEAVETMPdefine cxx_post@$(rm) -f $(cxx_cmdfile)endefelsedefine cxx_postendefendif################################################################################.. 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 = -Ias_o_switch = -o$@as_source = <$<as_cmdfile =asm68_flags = -fP=$(mri_cpu_type) -frel32 -DCcCpu=$(mri_cpu_code) -fdasm68_flags += $(ASFLAGS)ifdef as_definesasm68_flags += $(addprefix -D,$(as_defines))endififdef USE_DEBUGINFOasm68_flags += -DDEBUGelseasm68_flags += -DNDEBUGendifas_flags = $(asm68_flags)ifdef as_includesas_flags += "-I$(subst $(space),;,$(strip $(as_includes)))"endifas_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 *;\fiendefdefine as_postendef#.. Archiver#ar = $(XX_PRE) $(mri_librarian)ar_init =ar_cmdfile = $(basename $@).arar_logfile = $(basename $@).ar.logar_flags =ar_o_switch = < $(ar_cmdfile)ar_term = > $(ar_logfile)define ar_pre@$(echo) '[$@] Creating library archive..' ; \$(rm) -f $@ ;\$(cmdfile) -ko$(ar_cmdfile) \create $@\\n\$(patsubst %,addmod %\\n,$(filter %.obj, $^))\save\\n end\\nendefifndef LEAVETMPdefine ar_post@$(rm) -f $(ar_logfile) $(ar_cmdfile)endefelsedefine ar_postendefendif#.. Archive Merge#armerge = $(XX_PRE) $(mri_librarian)armerge_init =armerge_cmdfile = $(basename $@).armergearmerge_logfile = $(basename $@).armerge.logarmerge_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\\nendefifndef LEAVETMPdefine armerge_post@$(rm) -f $(armerge_logfile) $(armerge_cmdfile)endefelsedefine armerge_postendefendif#.. Linker#shld = $(XX_PRE) $(mri_linker)shld_cmdfile = $(basename $@).ldshldabs_flags = -m -c$(shld_cmdfile)shldabs_o_switch = -o$(basename $@).abs > $(basename $@).mapdefine shld_pre@$(echo) '[$@] Linking program ..' ;\export MRI_LIB; \MRI_LIB="$(subst $(space),;,$(LIBDIRS))"; \$(cmdfile) -ko$(shld_cmdfile) "$($(notdir $(SHBASE))_shld)"endefifndef LEAVETMPdefine shld_post@$(rm) -f $(shld_cmdfile)endefelsedefine shld_postendefendifdefine 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.asmendef## 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=247endef## 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=binendef## 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) -fd -fNOPCR -frel32 -I $(OBJDIR) -I $(dir $2) -o$3 <$2$(XX_PRE) $(rm) -f $4$(XX_PRE) $(cp) $(OBJDIR)/head.inc $4endef## 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).bdxendef#