# Copyright 2008 Castle Technology Ltd # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # Makefile fragment for assembler modules, previously built using AAsm but now using objasm # Such modules are characterised by the use of position-independent code # and multiple source files (if applicable) linked at the assembly stage # (using LNK and GET directives) rather than at the link stage. INCLUDED_AASMMODULE = YES # # $Id$ # # This makefile provides the following phony targets: # # all rom install_rom resources # export export_libs export_hdrs standalone install # clean debug gpa_debug # # # This fragment uses the following macros set by the master makefile. # # # COMPONENT (the name of the component) # TARGET (opt) (the leafname of the module - otherwise ${COMPONENT}) # RESFSDIR (opt) (actual directory to export resources to - otherwise ${RESDIR}.${TARGET}) # ROM_MODULE (opt) (output filename - otherwise rm.${MACHINE}.${TARGET}) # ROM_OBJECT (opt) (object file for romming - otherwise o.${MACHINE}.${TARGET}) # ROM_LIBS (opt) (libraries to link again ROM_OBJECT to generate ROM_MODULE) # ROM_DEPEND (opt) (any extra dependency to assert on ROM_MODULE) # DBG_MODULE (opt) (output filename for debug - otherwise rm.${MACHINE}.${TARGET}D # DBG_OBJECT (opt) (object file for debug - otherwise o.${MACHINE}.${TARGET}D # DBG_LIBS (opt) (libraries to link against DBG_OBJECT to generate DBG_MODULE - otherwise ${ROM_LIBS}) # SA_MODULE (opt) (output filename for softload - otherwise rm.${MACHINE}.${TARGET}SA # SA_OBJECT (opt) (object file for softload - otherwise o.${MACHINE}.${TARGET}SA # SA_LIBS (opt) (libraries to link against SA_OBJECT to generate SA_MODULE - otherwise ${ROM_LIBS}) # SA_DEPEND (opt) (any extra dependency to assert on SA_MODULE and DBG_MODULE) # DIRS (opt) (magic target to ensure object directories are present - otherwise o._dirs) # HEADER[1-3] (opt) (leafname of file in hdr to copy to on export_hdrs) # ASMCHEADER[1-3] (opt) (C-from-assembly auto-generated header files to export, no Hdr. prefix - otherwise none) # CHEADER[1-3] (opt) (C header files to export - otherwise none) # C_EXP_HDR (opt) (C header target directory - otherwise .Interface.h) # EXP_HDR (opt) (directory for exported assembler interface headers) # CUSTOMEXP (opt) (set to "custom" to override the export rules) # CUSTOMRES (opt) (set to "custom" to override the resources rules, or "no" for no resources) # CUSTOMROM (opt) (set to "custom" to override the rom rules) # CUSTOMSA (opt) (set to "custom" to override the standalone rules) # CUSTOMDBG (opt) (set to "custom" to override the debug rules) # CUSTOMGPA (opt) (set to "custom" to override the GPA rules) # # # It relies on the following from the build system: # # # INSTDIR (installation directory for ROM_MODULE or disc install) # (if INSTDIR was not specified by the build system) # RESDIR (installation directory for resources - cf. RESFSDIR) # (export directory for assembler interface headers) # (export directory for C interface headers) # CMDHELP (optional, set to None to exclude syntax errors from Messages) # PHASE (export phase discriminator) # # # It relies on the following generic tool macros from the Tools makefile # # CP + CPFLAGS (copy, cp etc.) # AS + ASFLAGS (assembler) # MKDIR (cdir/mkdir -p) # RM + WIPE (deletions) # ECHO # LD (linker) # # TARGET ?= ${COMPONENT} INSTDIR ?= ROM_MODULE ?= rm.${MACHINE}.${TARGET} ROM_SOURCE ?= s.${TARGET} ROM_OBJECT ?= o.${MACHINE}.${TARGET} DIRS ?= o._dirs EXP_HDR ?= RESFSDIR ?= ${RESDIR}.${TARGET} RESAPPDIR ?= ${RESDIR}.^.Apps.${APP} C_EXP_HDR ?= .Interface.h SA_MODULE ?= rm.${MACHINE}.${TARGET}SA SA_OBJECT ?= o.${MACHINE}.${TARGET}SA MERGEDMDIR ?= o.${MACHINE}._Messages_ MERGEDMSGS ?= ${MERGEDMDIR}.${TARGET} ifeq (${CMDHELP},None) SA_FLAGS ?= -PD "standalone SETL {TRUE}" -PD "MergedMsgs SETS \"${MERGEDMSGS}\"" -PD "international_help SETL {FALSE}" else SA_FLAGS ?= -PD "standalone SETL {TRUE}" -PD "MergedMsgs SETS \"${MERGEDMSGS}\"" endif SA_LIBS ?= ${ROM_LIBS} DBG_MODULE ?= rm.${MACHINE}.${TARGET}D DBG_OBJECT ?= o.${MACHINE}.${TARGET}D DBG_LIBS ?= ${ROM_LIBS} GPA_FILE ?= gpa.${MACHINE}.${TARGET} GPA_AIF ?= aif.${MACHINE}.${TARGET} TOKENS ?= Hdr:Tokens TOKENSOURCE ?= s.TokHelpSrc ifneq (${RESOURCES},) CUSTOMRES = ${RESOURCES} # The old name for CUSTOMRES endif # # Exported headers # # Need these to stop complaints about the rules below ASMCHEADER1 ?= _!_x_!_ ASMCHEADER2 ?= _!_x_!_ ASMCHEADER3 ?= _!_x_!_ CHEADER1 ?= _!_x_!_ CHEADER2 ?= _!_x_!_ CHEADER3 ?= _!_x_!_ all: rom debug standalone ${DIRS} :: ${MKDIR} o.${MACHINE} ${MKDIR} rm.${MACHINE} ${TOUCH} $@ # # ROM build rules # rom${CUSTOMROM}: ${ROM_MODULE} @${ECHO} ${COMPONENT}: rom module built install_rom${CUSTOMROM}: ${ROM_MODULE} ${CP} ${ROM_MODULE} ${INSTDIR}.${TARGET} ${CPFLAGS} ${CP} ${ROM_MODULE}_gpa ${INSTDIR}.${TARGET}_gpa ${CPFLAGS} @${ECHO} ${COMPONENT}: rom module installed ${ROM_MODULE}: ${ROM_OBJECT} ${ROM_LIBS} ${DIRS} ${ROM_DEPEND} ${LD} -rmf -o $@ ${ROM_OBJECT} ${ROM_LIBS} ${LD} -aif -bin -d -Entry 0 -o ${ROM_MODULE}_aif ${ROM_OBJECT} ${ROM_LIBS} ${TOGPA} -s ${ROM_MODULE}_aif ${ROM_MODULE}_gpa ${ROM_OBJECT}: ${ROM_SOURCE} ${TOKHELPSRC} ${DIRS} ${AS} ${ASFLAGS} -g -o $@ ${ROM_SOURCE} # # Standalone builds # standalone${CUSTOMSA}: ${SA_MODULE} @${ECHO} ${COMPONENT}: standalone module built ${SA_MODULE}: ${SA_OBJECT} ${SA_LIBS} ${DIRS} ${SA_DEPEND} ${LD} -rmf -o $@ ${SA_OBJECT} ${SA_LIBS} ${MODSQZ} -f ${MODSQZFLAGS} $@ ${CHMOD} -R a+rx rm ${SA_OBJECT}: ${ROM_SOURCE} ${MERGEDMSGS} ${TOKHELPSRC} ${DIRS} ${AS} ${ASFLAGS} -o $@ ${ROM_SOURCE} ${SA_FLAGS} ${MERGEDMSGS}${PRIVATEMSGS}: ${MKDIR} ${MERGEDMDIR} ${TOKENCHECK} LocalRes:Messages IfThere LocalRes:CmdHelp Then ${TOKENCHECK} LocalRes:CmdHelp IfThere LocalRes:CmdHelp Then ${FAPPEND} $@ LocalRes:Messages LocalRes:CmdHelp Else IfThere LocalRes:Messages Then ${CP} LocalRes:Messages $@ ${CPFLAGS} install${CUSTOMSA}: ${SA_MODULE} ${MKDIR} ${INSTDIR} ${CP} ${SA_MODULE} ${INSTDIR}.${TARGET} ${CPFLAGS} ${CHMOD} a=rx $@ @${ECHO} ${COMPONENT}: standalone module installed debug${CUSTOMDBG}: ${DBG_MODULE} @${ECHO} ${COMPONENT}: standalone debug module built ${DBG_MODULE}: ${DBG_OBJECT} ${DBG_LIBS} ${DIRS} ${SA_DEPEND} ${LD} -rmf -o $@ ${DBG_OBJECT} ${DBG_LIBS} ${DBG_OBJECT}: ${ROM_SOURCE} ${MERGEDMSGS} ${TOKHELPSRC} ${DIRS} ${AS} ${ASFLAGS} ${ASDFLAGS} -g -pd "debugging SETL {TRUE}" -o $@ ${ROM_SOURCE} ${SA_FLAGS} gpa_debug${CUSTOMGPA}: ${GPA_FILE} @${ECHO} ${COMPONENT}: GPA debug listing generated ${GPA_FILE}: ${GPA_AIF} ${MKDIR} gpa.${MACHINE} ${TOGPA} -s ${GPA_AIF} ${GPA_FILE} ${GPA_AIF}: ${DBG_OBJECT} ${MKDIR} aif.${MACHINE} ${LD} -aif -bin -d -o ${GPA_AIF} ${DBG_OBJECT} # # Clean the module # clean :: @IfThere rm.${MACHINE} Then ${ECHO} ${WIPE} rm.${MACHINE} ${WFLAGS} @IfThere rm.${MACHINE} Then ${WIPE} rm.${MACHINE} ${WFLAGS} @-IfThere rm.* Then Else IfThere rm Then ${ECHO} ${WIPE} rm ${WFLAGS} @-IfThere rm.* Then Else IfThere rm Then ${WIPE} rm ${WFLAGS} @IfThere o Then ${ECHO} ${WIPE} o ${WFLAGS} @IfThere o Then ${WIPE} o ${WFLAGS} @IfThere aif.${MACHINE} Then ${ECHO} ${WIPE} aif.${MACHINE} ${WFLAGS} @IfThere aif.${MACHINE} Then ${WIPE} aif.${MACHINE} ${WFLAGS} @-IfThere aif.* Then Else IfThere aif Then ${ECHO} ${WIPE} aif ${WFLAGS} @-IfThere aif.* Then Else IfThere aif Then ${WIPE} aif ${WFLAGS} @IfThere gpa Then ${ECHO} ${WIPE} gpa ${WFLAGS} @IfThere gpa Then ${WIPE} gpa ${WFLAGS} @-${RM} ${TOKENSOURCE} @${ECHO} ${COMPONENT}: cleaned # # Export phases # export_hdrs: ${EXPORTS} @If "${HEADER1}"<>"" Then ${ECHO} ${CP} hdr.${HEADER1} ${EXP_HDR}.${HEADER1} ${CPFLAGS} @If "${HEADER1}"<>"" Then ${CP} hdr.${HEADER1} ${EXP_HDR}.${HEADER1} ${CPFLAGS} @If "${HEADER2}"<>"" Then ${ECHO} ${CP} hdr.${HEADER2} ${EXP_HDR}.${HEADER2} ${CPFLAGS} @If "${HEADER2}"<>"" Then ${CP} hdr.${HEADER2} ${EXP_HDR}.${HEADER2} ${CPFLAGS} @If "${HEADER3}"<>"" Then ${ECHO} ${CP} hdr.${HEADER3} ${EXP_HDR}.${HEADER3} ${CPFLAGS} @If "${HEADER3}"<>"" Then ${CP} hdr.${HEADER3} ${EXP_HDR}.${HEADER3} ${CPFLAGS} @${ECHO} ${COMPONENT}: header export complete export_libs: @${ECHO} ${COMPONENT}: library export complete export${CUSTOMEXP}: export_${PHASE} @${NOP} export_:: export_libs export_hdrs @${NOP} ${C_EXP_HDR}.${ASMCHEADER1} :: hdr.${ASMCHEADER1} ${HDR2H} hdr.${ASMCHEADER1} $@ ${C_EXP_HDR}.${ASMCHEADER2} :: hdr.${ASMCHEADER2} ${HDR2H} hdr.${ASMCHEADER2} $@ ${C_EXP_HDR}.${ASMCHEADER3} :: hdr.${ASMCHEADER3} ${HDR2H} hdr.${ASMCHEADER3} $@ ${C_EXP_HDR}.${CHEADER1} :: h.${CHEADER1} ${CP} h.${CHEADER1} $@ ${CPFLAGS} ${C_EXP_HDR}.${CHEADER2} :: h.${CHEADER2} ${CP} h.${CHEADER2} $@ ${CPFLAGS} ${C_EXP_HDR}.${CHEADER3} :: h.${CHEADER3} ${CP} h.${CHEADER3} $@ ${CPFLAGS} # # Resources rules # resources${CUSTOMRES}:: ${RESOURCEEXTRA} resources-${CMDHELP} @${ECHO} ${COMPONENT}: resources copied to Messages module ifeq (${CUSTOMRES},no) resources: @${ECHO} ${COMPONENT}: no resources to export endif resources_common:: ${MKDIR} ${RESFSDIR} ${TOKENCHECK} LocalRes:Messages ${CP} LocalRes:Messages ${RESFSDIR}.Messages ${CPFLAGS} resources-None: resources_common @${NOP} resources-: resources_common IfThere LocalRes:CmdHelp Then ${TOKENCHECK} LocalRes:CmdHelp IfThere LocalRes:CmdHelp Then ${CAT} LocalRes:CmdHelp { >> ${RESFSDIR}.Messages } resources_res:: ${CP} LocalRes:Res ${RESFSDIR}.Res ${CPFLAGS} resources_sprites:: ${INSTRES} -I LocalUserIFRes:,LocalRes:,Resources ${RESFSDIR} Sprites [Sprites11] [Sprites22] resources_templates:: ${CP} LocalRes:Templates ${RESFSDIR}.Templates ${CPFLAGS} # # Build the help tokens # ${TOKENSOURCE}: ${HELPSRC} ${TOKENS} ${TOKENISE} ${TOKENS} ${HELPSRC} $@ EOFSTDMAKEFILE=$Id$ # EOF