Commit 5e83cb7e authored by Ben Avison's avatar Ben Avison

Incremental step in cross-compilation support

Detail:
  ModuleDB:
  * Correct capitalisation of resgen's TARGET to match its main source file
  GNUmakefiles/AAsmModule:
  * Targets now given ,ffa filetype suffix
  * Support source directory layouts s/<subdir>/<leaf> as used by the
    kernel and printer drivers - define SYMLINK_EXT_FIRST to enable
  * Prevent relinking when running make on an up-to-date component due to
    a difference between amu and GNU make's handling of double-colon rules
  * Support linking with GNU toolchain
  * Fix installation rule (mixup between MERGEDMDIR and MERGEDRDIR)
  * Support up to 16 assembler and 8 C-from-assembler headers, up from 3
    of each (here's looking at you, kernel) - long-term, it might be worth
    changing this to a scheme like that used by CModule to remove any
    limits
  * Fix C-from-assembler exports to have .h suffix
  GNUmakefiles/AppLibs:
  * Define INCLUDE_OSLIB to permit OSLib header search paths to be
    specified in an OS-agnostic way
  GNUmakefiles/CApp:
  * Prevent relinking when running make on an up-to-date component due to
    a difference between amu and GNU make's handling of double-colon rules
  GNUmakefiles/CLibrary:
  * Prevent rearchiving when running make on an up-to-date component due
    to a difference between amu and GNU make's handling of double-colon
    rules
  * Don't use .hdr suffix on exported assembler header files
  * Correct order of dependencies for export_libs phony target
  GNUmakefiles/StdTools:
  * Definition for the module filetype suffix
  * Add LDBIN tool for GNU/Norcroft-agnostic binary link, useful for
    linking position-independent binary code, such as relocatable modules
    (i.e. ones that don't require the linker to create a __RelocCode
    function)
  * FAPPEND function now works if the same file is used for the
    destination as for one of the sources (this is used by CModule)
  GNUmakefiles/CModule, ModStdRule, ModuleLibs:
  * Finally created cross-compilation versions of the last major shared
    makefiles! Warning: these have received limited testing to date.
  Makefiles/AAsmModule:
  * Support up to 16 assembler and 8 C-from-assembler headers
  Makefiles/AppLibs, ModuleLibs:
  * Define INCLUDE_OSLIB
  Makefiles/StdTools:
  * Add LDBIN tool


Version 7.24. Tagged as 'BuildSys-7_24'
parent 0f5172d0
......@@ -49,7 +49,7 @@ INCLUDED_AASMMODULE = YES
# 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)
# SOURCES_TO_LINK (opt) (files which need be linked to by the link farm, in addition to contents of hdr and s directories)
# SOURCES_TO_SYMLINK opt) (files which need be linked to by the link farm, in addition to contents of hdr and s directories)
#
#
# It relies on the following from the build system:
......@@ -79,14 +79,14 @@ INCLUDED_AASMMODULE = YES
TARGET ?= ${COMPONENT}
INSTDIR ?= ${INSTALLDIR}
ROM_MODULE ?= ${TARGET}
ROM_MODULE ?= ${TARGET}${SUFFIX_MODULE}
ROM_SOURCE ?= ${TARGET}.s
ROM_OBJECT ?= ${TARGET}.o
DIRS ?= _dirs
EXP_HDR ?= ${EXPORTDIR}
C_EXP_HDR ?= ${CEXPORTDIR}/Interface
SA_MODULE ?= ${TARGET}SA
SA_MODULE ?= ${TARGET}SA${SUFFIX_MODULE}
SA_OBJECT ?= ${TARGET}SA.o
INSTRAM_FILES ?= ${INSTRES_FILES}
INSTRAM_DEPENDS ?= ${INSTRES_DEPENDS}
......@@ -103,7 +103,7 @@ SA_FLAGS ?= -PD "standalone SETL {TRUE}" -PD "MergedMsgs SETS \"${MERGEDMSGS}\
endif
SA_LIBS ?= ${ROM_LIBS}
DBG_MODULE ?= ${TARGET}D
DBG_MODULE ?= ${TARGET}D${SUFFIX_MODULE}
DBG_OBJECT ?= ${TARGET}D.o
DBG_LIBS ?= ${ROM_LIBS}
......@@ -143,10 +143,15 @@ clean::
@rm -rf objs
@echo ${COMPONENT}: cleaned
else
ifneq (,${SYMLINK_EXT_FIRST})
SYMLINK_SED_PATTERN = 's,^\([^/]*\)/\(.*\),\2.\1,'
else
SYMLINK_SED_PATTERN = 's,\([^/]*\)/\([^/]*\)$$,\2.\1,'
endif
all debug export export_hdrs export_libs gpa_debug install install_rom links resources rom standalone: ${SYMLINK_DEPEND}
$(foreach linksource,${SOURCES_TO_SYMLINK}, \
$(shell \
linkdest=`echo ${linksource} | sed -e 's,\([^/]*\)/\([^/]*\)$$,\2.\1,' -e 's,^,objs/,'`; \
linkdest=`echo ${linksource} | sed -e ${SYMLINK_SED_PATTERN} -e 's,^,objs/,'`; \
linkdestdir=`echo $$linkdest | sed -e 's,/[^/]*$$,,'`; \
linkbackpath=`echo $$linkdestdir | sed -e 's,[^/]*,..,g'`; \
[ -d ${linksource} ] || [ -L $$linkdest ] || mkdir -p $$linkdestdir; \
......@@ -170,7 +175,12 @@ endif
all: rom debug standalone
${DIRS} ::
# GNU make seems to treat any double-colon rule with no dependencies as
# always out-of-date, therefore always rebuilds it and anything which in turn
# depends on the target of the double-colon rule. So use a single-colon rule
# instead. If any cross builds need to create extra directories on a
# per-component basis, we'll cross that bridge when we get to it.
${DIRS}:
${TOUCH} $@
#
......@@ -185,9 +195,13 @@ install_rom${CUSTOMROM}: ${ROM_MODULE}
@${ECHO} ${COMPONENT}: rom module installed
${ROM_MODULE}: ${ROM_DEPEND} ${DIRS} ${ROM_LIBS} ${ROM_OBJECT}
ifeq (GNU,${TOOLCHAIN})
${LDBIN} $@ ${ROM_OBJECT} ${ROM_LIBS}
else
${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
endif
${ROM_OBJECT}: ${DIRS} ${TOKHELPSRC} ${ROM_SOURCE}
${AS} ${ASFLAGS} -depend $(subst .o,.d,$@) -g -o $@ ${ROM_SOURCE}
......@@ -199,7 +213,11 @@ standalone${CUSTOMSA}: ${SA_MODULE}
@${ECHO} ${COMPONENT}: standalone module built
${SA_MODULE}: ${SA_DEPEND} ${DIRS} ${SA_LIBS} ${SA_OBJECT}
ifeq (GNU,${TOOLCHAIN})
${LDBIN} $@ ${SA_OBJECT} ${SA_LIBS}
else
${LD} -rmf -o $@ ${SA_OBJECT} ${SA_LIBS}
endif
${MODSQZ} -f ${MODSQZFLAGS} $@
${SA_OBJECT}: ${DIRS} ${TOKHELPSRC} ${MERGEDMSGS} ${ROM_SOURCE}
......@@ -208,11 +226,12 @@ ${SA_OBJECT}: ${DIRS} ${TOKHELPSRC} ${MERGEDMSGS} ${ROM_SOURCE}
ifeq ($(filter no custom,${CUSTOMRES}),)
${MERGEDMSGS}:
${MKDIR} ${MERGEDRDIR}/tmp
${TOUCH} ${MERGEDMDIR}/tmp/Messages
${TOUCH} ${MERGEDMDIR}/tmp/CmdHelp
${INSTRES} -I Resources.${USERIF}.${LOCALE},Resources.${USERIF}.UK,Resources.${LOCALE},Resources.UK,Resources ${MERGEDMDIR} [Messages] [CmdHelp]
${CAT} ${MERGEDMDIR}/tmp/Messages ${MERGEDMDIR}/tmp/CmdHelp > $@
${WIPE} ${MERGEDMDIR}/tmp
${MKDIR} ${MERGEDRDIR}/${TARGET}
${TOUCH} ${MERGEDRDIR}/tmp/Messages
${TOUCH} ${MERGEDRDIR}/tmp/CmdHelp
${INSTRES} -I Resources.${USERIF}.${LOCALE},Resources.${USERIF}.UK,Resources.${LOCALE},Resources.UK,Resources ${MERGEDRDIR} [Messages] [CmdHelp]
${CAT} ${MERGEDRDIR}/tmp/Messages ${MERGEDMRDIR}/tmp/CmdHelp > $@
${WIPE} ${MERGEDRDIR}/tmp
else
${MERGEDMSGS}::
@${NOP}
......@@ -227,7 +246,11 @@ debug${CUSTOMDBG}: ${DBG_MODULE}
@${ECHO} ${COMPONENT}: standalone debug module built
${DBG_MODULE}: ${DBG_OBJECT} ${DBG_LIBS} ${DIRS} ${SA_DEPEND}
ifeq (GNU,${TOOLCHAIN})
${LDBIN} $@ ${DBG_OBJECT} ${DBG_LIBS}
else
${LD} -rmf -o $@ ${DBG_OBJECT} ${DBG_LIBS}
endif
${DBG_OBJECT}: ${ROM_SOURCE} ${MERGEDMSGS} ${TOKHELPSRC} ${DIRS}
${AS} ${ASFLAGS} ${ASDFLAGS} -g -pd "debugging SETL {TRUE}" -depend $(subst .o,.d,$@) -o $@ ${ROM_SOURCE} ${SA_FLAGS}
......@@ -252,6 +275,32 @@ export_hdrs: ${EXPORTS}
@if [ -e ${HEADER2}.hdr ]; then ${CP} ${HEADER2}.hdr ${EXP_HDR}/${HEADER2} ${CPFLAGS}; fi
@if [ -e ${HEADER3}.hdr ]; then ${ECHO} ${CP} ${HEADER3}.hdr ${EXP_HDR}/${HEADER3} ${CPFLAGS}; fi
@if [ -e ${HEADER3}.hdr ]; then ${CP} ${HEADER3}.hdr ${EXP_HDR}/${HEADER3} ${CPFLAGS}; fi
@if [ -e ${HEADER4}.hdr ]; then ${ECHO} ${CP} ${HEADER4}.hdr ${EXP_HDR}/${HEADER4} ${CPFLAGS}; fi
@if [ -e ${HEADER4}.hdr ]; then ${CP} ${HEADER4}.hdr ${EXP_HDR}/${HEADER4} ${CPFLAGS}; fi
@if [ -e ${HEADER5}.hdr ]; then ${ECHO} ${CP} ${HEADER5}.hdr ${EXP_HDR}/${HEADER5} ${CPFLAGS}; fi
@if [ -e ${HEADER5}.hdr ]; then ${CP} ${HEADER5}.hdr ${EXP_HDR}/${HEADER5} ${CPFLAGS}; fi
@if [ -e ${HEADER6}.hdr ]; then ${ECHO} ${CP} ${HEADER6}.hdr ${EXP_HDR}/${HEADER6} ${CPFLAGS}; fi
@if [ -e ${HEADER6}.hdr ]; then ${CP} ${HEADER6}.hdr ${EXP_HDR}/${HEADER6} ${CPFLAGS}; fi
@if [ -e ${HEADER7}.hdr ]; then ${ECHO} ${CP} ${HEADER7}.hdr ${EXP_HDR}/${HEADER7} ${CPFLAGS}; fi
@if [ -e ${HEADER7}.hdr ]; then ${CP} ${HEADER7}.hdr ${EXP_HDR}/${HEADER7} ${CPFLAGS}; fi
@if [ -e ${HEADER8}.hdr ]; then ${ECHO} ${CP} ${HEADER8}.hdr ${EXP_HDR}/${HEADER8} ${CPFLAGS}; fi
@if [ -e ${HEADER8}.hdr ]; then ${CP} ${HEADER8}.hdr ${EXP_HDR}/${HEADER8} ${CPFLAGS}; fi
@if [ -e ${HEADER9}.hdr ]; then ${ECHO} ${CP} ${HEADER9}.hdr ${EXP_HDR}/${HEADER9} ${CPFLAGS}; fi
@if [ -e ${HEADER9}.hdr ]; then ${CP} ${HEADER9}.hdr ${EXP_HDR}/${HEADER9} ${CPFLAGS}; fi
@if [ -e ${HEADER10}.hdr ]; then ${ECHO} ${CP} ${HEADER10}.hdr ${EXP_HDR}/${HEADER10} ${CPFLAGS}; fi
@if [ -e ${HEADER10}.hdr ]; then ${CP} ${HEADER10}.hdr ${EXP_HDR}/${HEADER10} ${CPFLAGS}; fi
@if [ -e ${HEADER11}.hdr ]; then ${ECHO} ${CP} ${HEADER11}.hdr ${EXP_HDR}/${HEADER11} ${CPFLAGS}; fi
@if [ -e ${HEADER11}.hdr ]; then ${CP} ${HEADER11}.hdr ${EXP_HDR}/${HEADER11} ${CPFLAGS}; fi
@if [ -e ${HEADER12}.hdr ]; then ${ECHO} ${CP} ${HEADER12}.hdr ${EXP_HDR}/${HEADER12} ${CPFLAGS}; fi
@if [ -e ${HEADER12}.hdr ]; then ${CP} ${HEADER12}.hdr ${EXP_HDR}/${HEADER12} ${CPFLAGS}; fi
@if [ -e ${HEADER13}.hdr ]; then ${ECHO} ${CP} ${HEADER13}.hdr ${EXP_HDR}/${HEADER13} ${CPFLAGS}; fi
@if [ -e ${HEADER13}.hdr ]; then ${CP} ${HEADER13}.hdr ${EXP_HDR}/${HEADER13} ${CPFLAGS}; fi
@if [ -e ${HEADER14}.hdr ]; then ${ECHO} ${CP} ${HEADER14}.hdr ${EXP_HDR}/${HEADER14} ${CPFLAGS}; fi
@if [ -e ${HEADER14}.hdr ]; then ${CP} ${HEADER14}.hdr ${EXP_HDR}/${HEADER14} ${CPFLAGS}; fi
@if [ -e ${HEADER15}.hdr ]; then ${ECHO} ${CP} ${HEADER15}.hdr ${EXP_HDR}/${HEADER15} ${CPFLAGS}; fi
@if [ -e ${HEADER15}.hdr ]; then ${CP} ${HEADER15}.hdr ${EXP_HDR}/${HEADER15} ${CPFLAGS}; fi
@if [ -e ${HEADER16}.hdr ]; then ${ECHO} ${CP} ${HEADER16}.hdr ${EXP_HDR}/${HEADER16} ${CPFLAGS}; fi
@if [ -e ${HEADER16}.hdr ]; then ${CP} ${HEADER16}.hdr ${EXP_HDR}/${HEADER16} ${CPFLAGS}; fi
@${ECHO} ${COMPONENT}: header export complete
export_libs:
......@@ -267,26 +316,46 @@ export_:: export_hdrs export_libs
ASMCHEADER1 ?= _!_x_!_
ASMCHEADER2 ?= _!_x_!_
ASMCHEADER3 ?= _!_x_!_
ASMCHEADER4 ?= _!_x_!_
ASMCHEADER5 ?= _!_x_!_
ASMCHEADER6 ?= _!_x_!_
ASMCHEADER7 ?= _!_x_!_
ASMCHEADER8 ?= _!_x_!_
CHEADER1 ?= _!_x_!_
CHEADER2 ?= _!_x_!_
CHEADER3 ?= _!_x_!_
${C_EXP_HDR}/${ASMCHEADER1} :: ${ASMCHEADER1}.hdr
${C_EXP_HDR}/${ASMCHEADER1}.h :: ${ASMCHEADER1}.hdr
${HDR2H} ${ASMCHEADER1}.hdr $@
${C_EXP_HDR}/${ASMCHEADER2} :: ${ASMCHEADER2}.hdr
${C_EXP_HDR}/${ASMCHEADER2}.h :: ${ASMCHEADER2}.hdr
${HDR2H} ${ASMCHEADER2}.hdr $@
${C_EXP_HDR}.${ASMCHEADER3} :: ${ASMCHEADER3}.hdr
${C_EXP_HDR}/${ASMCHEADER3}.h :: ${ASMCHEADER3}.hdr
${HDR2H} ${ASMCHEADER3}.hdr $@
${C_EXP_HDR}.${CHEADER1}.h :: ${CHEADER1}.h
${C_EXP_HDR}/${ASMCHEADER4}.h :: ${ASMCHEADER4}.hdr
${HDR2H} ${ASMCHEADER4}.hdr $@
${C_EXP_HDR}/${ASMCHEADER5}.h :: ${ASMCHEADER5}.hdr
${HDR2H} ${ASMCHEADER5}.hdr $@
${C_EXP_HDR}/${ASMCHEADER6}.h :: ${ASMCHEADER6}.hdr
${HDR2H} ${ASMCHEADER6}.hdr $@
${C_EXP_HDR}/${ASMCHEADER7}.h :: ${ASMCHEADER7}.hdr
${HDR2H} ${ASMCHEADER7}.hdr $@
${C_EXP_HDR}/${ASMCHEADER8}.h :: ${ASMCHEADER8}.hdr
${HDR2H} ${ASMCHEADER8}.hdr $@
${C_EXP_HDR}/${CHEADER1}.h :: ${CHEADER1}.h
${CP} ${CHEADER1}.h $@ ${CPFLAGS}
${C_EXP_HDR}.${CHEADER2}.h :: ${CHEADER2}.h
${C_EXP_HDR}/${CHEADER2}.h :: ${CHEADER2}.h
${CP} ${CHEADER2}.h $@ ${CPFLAGS}
${C_EXP_HDR}.${CHEADER3}.h :: ${CHEADER3}.h
${C_EXP_HDR}/${CHEADER3}.h :: ${CHEADER3}.h
${CP} ${CHEADER3}.h $@ ${CPFLAGS}
#
......
......@@ -70,4 +70,8 @@ WILDLIB = ${LIBDIR}/Wild/Wild.a
DEBUGLIB = ${LIBDIR}/DebugLib/DebugLib.a
DEBUGLIBS = # ${DEBUGLIB} ${REMOTEDBLIB} ${TRACELIB} ${PDEBUGLIB} ${MODMALLOCLIB} ${WILDLIB} ${DDTLIB} ${DESKLIB}
# Library include paths, where these can't easily be specified explicitly
# If this list gets too long, it may be worth de-duplicating the definitions in AppLibs
INCLUDE_OSLIB = -I${LIBDIR}/OSLib/Core,${LIBDIR}/OSLib/Computer,${LIBDIR}/OSLib/User,${LIBDIR}/OSLib/Toolbox,{LIBDIR}/OSLib/Core/oslib,${LIBDIR}/OSLib/Computer/oslib,${LIBDIR}/OSLib/User/oslib,${LIBDIR}/OSLib/Toolbox/oslib
# EOF
......@@ -32,7 +32,7 @@ INCLUDED_CAPP = YES
# CUSTOMINSTALLAPP (opt) (set to "custom" to override the install rule for resource files)
# CUSTOMINSTALLTOOL (opt) (set to "custom" to override the install rule for target binary)
# CUSTOMINSTALLDBGAPP (opt) (set to "custom" to override the install rule for debug resources)
# SOURCES_TO_LINK (opt) (files which need be linked to by the link farm, in addition to contents of c and h directories)
# SOURCES_TO_SYMLINK (opt) (files which need be linked to by the link farm, in addition to contents of c and h directories)
#
#
# It relies on the following generic tool macros from the StdTools makefile
......@@ -147,7 +147,12 @@ endif
all: ${TARGET}${SUFFIX_ABSOLUTE}
@${ECHO} ${COMPONENT}: application built
${DIRS}::
# GNU make seems to treat any double-colon rule with no dependencies as
# always out-of-date, therefore always rebuilds it and anything which in turn
# depends on the target of the double-colon rule. So use a single-colon rule
# instead. If any cross builds need to create extra directories on a
# per-component basis, we'll cross that bridge when we get to it.
${DIRS}:
${TOUCH} $@
install: install_${INSTTYPE}
......
......@@ -35,7 +35,7 @@ INCLUDED_CLIBRARY = YES
# CUSTOMLIBZM (opt) (set to "custom" to override the module library rule)
# CUSTOMLIBD (opt) (set to "custom" to override the debug application library rule)
# CUSTOMLIBDZM (opt) (set to "custom" to override the debug module library rule)
# SOURCES_TO_LINK (opt) (files which need be linked to by the link farm, in addition to contents of c and h directories)
# SOURCES_TO_SYMLINK (opt) (files which need be linked to by the link farm, in addition to contents of c and h directories)
#
#
# It relies on the following from the build system:
......@@ -160,7 +160,12 @@ endif
all_libs: ${TARGET_LIBS}
@${ECHO} ${COMPONENT}: library built
${DIRS} ::
# GNU make seems to treat any double-colon rule with no dependencies as
# always out-of-date, therefore always rebuilds it and anything which in turn
# depends on the target of the double-colon rule. So use a single-colon rule
# instead. If any cross builds need to create extra directories on a
# per-component basis, we'll cross that bridge when we get to it.
${DIRS}:
${TOUCH} $@
export: export_${PHASE}
......@@ -177,14 +182,14 @@ create_exp_lib_dir:
.SUFFIXES: .exphdr .expasm .explib .h .Hdr .${LIBEXT}
.h.exphdr:; ${CP} $< ${EXPDIR}/$< ${CPFLAGS}
.Hdr.expasm:; ${CP} $< ${EXPDIR}/$< ${CPFLAGS}
.Hdr.expasm:; ${CP} $< ${EXPDIR}/$* ${CPFLAGS}
.${LIBEXT}.explib:; ${CP} $< ${EXPDIR}/$< ${CPFLAGS}
export_hdrs: create_exp_hdr_dirs ${DIRS} ${EXPORTING_ASMHDRS} ${EXPORTING_HDRS}
[ ! -f ../VersionNum ] || ${CP} ../VersionNum ${EXPDIR}/LibVersion ${CPFLAGS}
@${ECHO} ${COMPONENT}: header export complete
export_libs: create_exp_lib_dir ${DIRS} ${EXPORTING_LIBS} ${TARGET_LIBS}
export_libs: create_exp_lib_dir ${DIRS} ${TARGET_LIBS} ${EXPORTING_LIBS}
[ ! -f ../VersionNum ] || ${CP} ../VersionNum ${EXPDIR}/LibVersion ${CPFLAGS}
@${ECHO} ${COMPONENT}: library export complete
......
# Makefile fragment for C and C++ modules
INCLUDED_CMODULE = YES
#
# This makefile provides the following phony targets:
#
# all
# export export_hdrs export_libs
# resources
# rom rom_link
# standalone install
# debug gpa_debug
# prepro
# clean
#
#
# 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})
# ROM_TARGET (opt) (partially linked module leafname - otherwise ${TARGET}.aof)
# LNK_TARGET (opt) (fixed-position module leafname - otherwise ${TARGET}.linked)
# SA_TARGET (opt) (standalone module leafname - otherwise ${TARGET})
# DBG_TARGET (opt) (debug module leafname - otherwise ${TARGET}D)
# AIF_TARGET (opt) (GPA-intermediate leafname - otherwise ${TARGET}.aif)
# GPA_TARGET (opt) (GPA debug leafname - otherwise ${TARGET}.gpa)
# INSTDIR (opt) (the target directory - otherwise ${INSTALLDIR})
# C_EXP_HDR (opt) (C header target directory - otherwise ${CEXPORTDIR}/Interface)
# EXP_HDR (opt) (assembly header target directory - otherwise ${EXPORTDIR}
# DIRS (opt) (stamp object for directory creation - otherwise _dirs)
# HDRS (opt) (C header files to export, no .h suffix - otherwise ${TARGET})
# ASMHDRS (opt) (assembly header files to export, no .hdr suffix - otherwise none)
# ASMCHDRS (opt) (C-from-assembly auto-generated header files to export, no .hdr suffix - otherwise none)
# INSTRES_FILES (opt) (extra resource files in addition to Messages - use InstRes specification rules)
# INSTRAM_FILES (opt) (RAM build specific resources - otherwise ${INSTRES_FILES})
# INSTROM_FILES (opt) (ROM build specific resources - otherwise ${INSTRES_FILES})
# INSTR??_DEPENDS (opt) (any extra dependency to assert on INSTRES/INSTRAM/INSTROM_FILES)
# MERGEDRDIR (r/o) (directory for generating exported resources, for information only)
# MERGEDMSGS (r/o) (leafname of generated Messages file, for compatibility with AAsmModule)
# RESFSDIR (opt) (actual directory to export resources to - otherwise ${RESDIR}/${TARGET})
# RES_AREA (opt) (area name to use for embedded messages in standalone build - otherwise Resources)
# RES_OBJ (opt) (object file for embedded messages in standalone build, no .o suffix - otherwise ${TARGET}Msgs)
# RES_PATH (opt) (path relative to ResourceFS root to be suffixed by ${TARGET} - otherwise Resources)
# CMHGFILE (opt) (name of CMHG source file, no .cmhg suffix - otherwise ${TARGET}Hdr)
# CMHGAUTOHDR (opt) (header file, if any, from HDRS or ASMCHDRS, to which to append the SWI defines from CMHG)
# CMHGFILE_SWIPREFIX (opt) (name of SWI prefix used in CMHG file - otherwise ${TARGET})
# OBJS (opt) (object files, no .o suffixes - otherwise ${TARGET} ${CMHGFILE})
# ROM_OBJS (opt) (ROM build objects - otherwise ${OBJS})
# SA_OBJS (opt) (standalone build objects - otherwise ${OBJS})
# DBG_OBJS (opt) (debug build object files, no prefixes - otherwise ${OBJS})
# LIBS (opt) (extra libraries; ${CLIB} is always used)
# ROM_LIBS (opt) (libraries to link for ROM targets - otherwise ${LIBS})
# SA_LIBS (opt) (libraries to link for standalone targets - otherwise ${LIBS})
# DBG_LIBS (opt) (extra debug libraries in addition to SA_LIBS and DEBUGLIBS)
# ROM_DEPEND (opt) (any extra dependency to assert on ROM_TARGET)
# SA_DEPEND (opt) (any extra dependency to assert on SA_TARGET and DBG_TARGET)
# 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)
# RAMCDEFINES (opt) (additions to CDEFINES for RAM builds - requires ModStdRule to be included later)
# ROMCDEFINES (opt) (additions to CDEFINES for ROM builds - requires ModStdRule to be included later)
# RAMASMDEFINES (opt) (additions to ASMDEFINES for RAM builds - requires ModStdRule to be included later)
# ROMASMDEFINES (opt) (additions to ASMDEFINES for ROM builds - requires ModStdRule to be included later)
# CMHGDEPENDS (opt) (source files which need to include the .h file autogenerated from the CMHG file)
#
#
# It relies on the following from the build system:
#
#
# PHASE (export phase discriminator)
# CMDHELP (whether star command help/syntax strings are included)
# RESDIR (installation directory for resources - cf. RESFSDIR)
# FORCEROMLINK (set to force a relink of the ROM target, used in BBE)
# LINKDIR (installation directory for LNK_TARGET)
# ADDRESS (base address for LNK_TARGET)
# INSERTVERSION (awk script to substitute from VersionNum)
#
#
# It relies on the following generic tool macros from the StdTools makefile
#
#
# C + CFLAGS (C compiler; CDFLAGS also used in debug builds; -g implicit)
# CP + CPFLAGS (copy, cp etc.)
# WIPE + WFLAGS (recursive delete)
# RM (non-recursive delete)
# AS + ASFLAGS (assembler)
# LD + LDFLAGS (linker; LDDFLAGS also used in debug builds; -d implicit)
# LDRAMFLAGS (more linker flags)
# LDROMFLAGS (more linker flags)
# LDLINKFLAGS (flags for the rom_link phase)
# MODSQZ + MODSQZFLAGS (module binary compressor)
# CHMOD
# MKDIR (cdir/mkdir -p)
# ECHO
# TOUCH (create/touch)
# RESGEN
# TOGPA
#
#
# It relies on the following from the StdRules makefile
#
#
# .c.o .c++.o .cpp.o .s.o
#
#
# It relies on the following from the ModStdRule makefile
#
#
# .cmhg.h .cmhg.o
#
#
# It relies on the following from the DbgRules makefile
#
#
# CDFLAGS C++DFLAGS ASDFLAGS LDDFLAGS
# .c.od .c++.od .cpp.od .s.od
#
#
TARGET ?= ${COMPONENT}
ROM_TARGET ?= ${TARGET}
LNK_TARGET ?= ${TARGET}
SA_TARGET ?= ${TARGET}
DBG_TARGET ?= ${TARGET}D
AIF_TARGET ?= ${TARGET}
GPA_TARGET ?= ${TARGET}
INSTDIR ?= ${INSTALLDIR}
C_EXP_HDR ?= ${CEXPORTDIR}/Interface
EXP_HDR ?= ${EXPORTDIR}
DIRS ?= _dirs
HDRS ?= ${TARGET}
ASMHDRS ?=
ASMCHDRS ?=
INSTRAM_FILES ?= ${INSTRES_FILES}
INSTRAM_DEPENDS ?= ${INSTRES_DEPENDS}
INSTROM_FILES ?= ${INSTRES_FILES}
INSTROM_DEPENDS ?= ${INSTRES_DEPENDS}
MERGEDRDIR ?= _ResData_
MERGEDMSGS ?= ${MERGEDRDIR}/${TARGET}/Messages
RES_AREA ?= Resources
RES_OBJ ?= ${TARGET}Msgs
RES_PATH ?= Resources
RESFSDIR ?= ${RESDIR}/${TARGET}
CMHGFILE ?= ${TARGET}Hdr
CMHGFILE_SWIPREFIX ?= ${TARGET}
OBJS ?= ${TARGET}
ROM_OBJS ?= ${OBJS}
SA_OBJS ?= ${OBJS}
DBG_OBJS ?= ${OBJS}
ROM_OBJS += ${CMHGFILE}
SA_OBJS += ${CMHGFILE}
DBG_OBJS += ${CMHGFILE}
ifeq ($(filter no custom,${CUSTOMRES}),)
RESDIR ?= ${MERGEDRDIR} # Place to internally collect up contents of RES_OBJ
SA_OBJS += ${RES_OBJ}
DBG_OBJS += ${RES_OBJ}
endif
ROM_LIBS ?= ${LIBS}
SA_LIBS ?= ${LIBS}
ROM_LIBS += ${ROMCSTUBS}
ROM_SYMS = ${C_ABSSYM}
SA_LIBS += ${CLIB}
DBG_LIBS += ${DEBUGLIBS}
ROM_OBJS_ = $(addsuffix .o,${ROM_OBJS})
SA_OBJS_ = $(addsuffix .o,${SA_OBJS})
DBG_OBJS_ = $(addsuffix .od,${DBG_OBJS})
PP_OBJS_ = $(addsuffix .i,$(filter-out ${CMHGFILE} ${RES_OBJ},${DBG_OBJS}))
EXPORTING_HDRS = $(addsuffix .exphdr,${HDRS})
EXPORTING_ASMHDRS = $(addsuffix .expasm,${ASMHDRS})
EXPORTING_ASMCHDRS = $(addsuffix .expasmc,${ASMCHDRS})
ifeq ($(filter rom%,${MAKECMDGOALS}),)
CDEFINES += ${RAMCDEFINES}
ASMDEFINES += ${RAMASMDEFINES}
RES_FILES_ = ${INSTRAM_FILES}
RES_DEPENDS_ = ${INSTRAM_DEPENDS}
else
CDEFINES += ${ROMCDEFINES}
ASMDEFINES += ${ROMASMDEFINES}
RES_FILES_ = ${INSTROM_FILES}
RES_DEPENDS_ = ${INSTROM_DEPENDS}
endif
ifneq ($(filter debug%,${MAKECMDGOALS}),)
CMHGFLAGS += ${CMHGDFLAGS} # Affects both object and header generation
endif
SOURCES_TO_SYMLINK += $(wildcard c/*) $(wildcard c++/*) $(wildcard cmhg/*) $(wildcard h/*) $(wildcard hdr/*) $(wildcard s/*) VersionNum VersionASM
ifneq (objs,$(notdir ${CURDIR}))
# Makefile invoked from same directory
# Create link farm, then execute the makefile from within it
ifeq (clean,${MAKECMDGOALS})
# With a double-colon rule which can have additional actions assigned from the
# master makefile, we'd normally need the master makefile to include the
# ${CURDIR} check to ensure that it's performed on the same invocation as us.
# However, there's no real benefit to performing clean from within the objs
# directory, and it adds an ordering problem between the different double-colon
# rules (the one that deletes the objs directory has to be last otherwise the
# cwd is invalid for the others) so to simplify things, we only ever do cleans
# from the same directory as the Makefile.
clean::
@echo Cleaning...
@rm -rf objs
@echo ${COMPONENT}: cleaned
else
all export export_hdrs export_libs resources rom rom_link standalone install debug gpa_debug prepro links: ${SYMLINK_DEPEND}
$(foreach linksource,${SOURCES_TO_SYMLINK}, \
$(shell \
linkdest=`echo ${linksource} | sed -e 's,\([^/]*\)/\([^/]*\)$$,\2.\1,' -e 's,^,objs/,'`; \
linkdestdir=`echo $$linkdest | sed -e 's,/[^/]*$$,,'`; \
linkbackpath=`echo $$linkdestdir | sed -e 's,[^/]*,..,g'`; \
[ -d ${linksource} ] || [ -L $$linkdest ] || mkdir -p $$linkdestdir; \
[ -d ${linksource} ] || [ -L $$linkdest ] || ln -s $$linkbackpath/${linksource} $$linkdest; \
) \
)
@[ -L objs/Resources ] || ln -s ../Resources objs/Resources
@mkdir -p objs
ifneq (links,${MAKECMDGOALS})
@${MAKE} -C objs -f ../$(firstword ${MAKEFILE_LIST}) ${MAKECMDGOALS}
endif
endif
else
# Makefile invoked from objs subdirectory
ifeq ("${INCLUDED_STDTOOLS}","")
include StdTools
endif
ifeq ("${INCLUDED_MODULELIBS}","")
include ModuleLibs
endif
CFLAGS := ${C_MODULE} ${C_NO_STKCHK} ${CFLAGS}
ifeq ("${INCLUDED_MODSTDRULE}","")
include ModStdRule
endif
ifeq ("${INCLUDED_DBGRULES}","")
include DbgRules
endif
#
# General rules
#
all: ${DBG_TARGET}${SUFFIX_MODULE} ${SA_TARGET}${SUFFIX_MODULE} ${ROM_TARGET}.aof
@${ECHO} ${COMPONENT}: all built
# GNU make seems to treat any double-colon rule with no dependencies as
# always out-of-date, therefore always rebuilds it and anything which in turn
# depends on the target of the double-colon rule. So use a single-colon rule
# instead. If any cross builds need to create extra directories on a
# per-component basis, we'll cross that bridge when we get to it.
${DIRS}:
${TOUCH} $@
#
# Export phases
#
export${CUSTOMEXP}: export_${PHASE}
@${NOP}
export_: export_hdrs export_libs
@${NOP}
create_exp_hdr_dirs:
${MKDIR} ${C_EXP_HDR}
${MKDIR} ${EXP_HDR}
ifneq (${CMHGFILE},)
${CMHGAUTOHDR}_h_: ${DIRS} ${CMHGFILE}.h
${AWK} -- "/.ifndef ${CMHGFILE_SWIPREFIX}/,/endif/" ${CMHGFILE}.h > ${CMHGAUTOHDR}_h_
endif
ifneq ($(findstring ${CMHGAUTOHDR},${HDRS}),)
${CMHGAUTOHDR}.exphdr: ${CMHGAUTOHDR}_h_ ${CMHGAUTOHDR}.h
${FAPPEND} ${C_EXP_HDR}/${CMHGAUTOHDR}.h ${CMHGAUTOHDR}.h ${CMHGAUTOHDR}_h_
endif
ifneq ($(findstring ${CMHGAUTOHDR},${ASMCHDRS}),)
${CMHGAUTOHDR}.expasmc: ${CMHGAUTOHDR}_h_ ${CMHGAUTOHDR}.hdr
${HDR2H} ${CMHGAUTOHDR}.hdr ${C_EXP_HDR}/${CMHGAUTOHDR}.h
${FAPPEND} ${C_EXP_HDR}/${CMHGAUTOHDR}.h ${C_EXP_HDR}/${CMHGAUTOHDR}.h ${CMHGAUTOHDR}_h_
endif
ifneq (${CMHGDEPENDS},)
CMHGDEPENDS_ = $(addsuffix .o,${CMHGDEPENDS}) $(addsuffix .od,${CMHGDEPENDS}) $(addsuffix .i,${CMHGDEPENDS})
${CMHGDEPENDS_}: ${CMHGFILE}.h
endif
.SUFFIXES: .exphdr .expasm .expasmc .h .hdr
.h.exphdr:; ${CP} $< ${C_EXP_HDR}/$<
.hdr.expasm:; ${CP} $< ${EXP_HDR}/$*
.hdr.expasmc:; ${HDR2H} $< ${C_EXP_HDR}/$*.h
export_hdrs${CUSTOMEXP}: create_exp_hdr_dirs ${DIRS} ${EXPORTING_HDRS} ${EXPORTING_ASMHDRS} ${EXPORTING_ASMCHDRS}
@${ECHO} ${COMPONENT}: header export complete
export_libs${CUSTOMEXP}:
@${ECHO} ${COMPONENT}: no exported libraries
#
# Resources rules
#
resources${CUSTOMRES}:: resources-${CMDHELP}
@${ECHO} ${COMPONENT}: resources copied to Messages module
ifeq (${CUSTOMRES},no)
resources:
@${ECHO} ${COMPONENT}: no resources to export
endif
resources_extra: ${RES_DEPENDS_}
ifneq (${RES_FILES_},)
${INSTRES} -I Resources.${USERIF}.${LOCALE},Resources.${USERIF}.UK,Resources.${LOCALE},Resources.UK,Resources ${RESFSDIR} ${RES_FILES_}
endif
ifneq (,$(filter Messages,${INSTRES_VERSION}))
${INSERTVERSION} ${RESFSDIR}/Messages > ${RESFSDIR}/_Awk_
${CP} ${RESFSDIR}/_Awk_ ${RESFSDIR}/Messages ${CPFLAGS}
${RM} ${RESFSDIR}/_Awk_
endif
@${NOP}
resources_common:
${MKDIR} ${RESFSDIR}
${INSTRES} -I Resources.${USERIF}.${LOCALE},Resources.${USERIF}.UK,Resources.${LOCALE},Resources.UK,Resources ${RESFSDIR} [Messages]
resources_cmdhelp: ${MERGEDMSGS}
${CP} ${MERGEDMSGS} ${RESFSDIR}/Messages
resources-None: resources_common resources_extra
@${NOP}
resources-: resources_common resources_cmdhelp resources_extra
@${NOP}
${RES_OBJ}.o: ${DIRS} resources-${CMDHELP}
${INSTVIARG} ${MERGEDRDIR} ${RES_PATH} _ResGen_
${RESGEN} ${RES_AREA} $@ -via _ResGen_
${RES_OBJ}.od: ${RES_OBJ}.o
${CP} $< $@
#
# ROM build rules
#
rom${CUSTOMROM}: ${ROM_TARGET}.aof
@${ECHO} ${COMPONENT}: rom module built
rom_link${CUSTOMROM}: ${LNK_TARGET}.linked
${CP} ${LNK_TARGET}.linked ${LINKDIR}/${TARGET}
${CP} ${LNK_TARGET}_sym.linked ${LINKDIR}/${TARGET}_sym
@${ECHO} ${COMPONENT}: rom_link complete
${ROM_TARGET}.aof: ${ROM_DEPEND} ${DIRS} ${ROM_OBJS_} ${ROM_LIBS}
${LD} -o $@ -aof ${ROM_OBJS_} ${ROM_LIBS}
${LNK_TARGET}.linked: ${FORCEROMLINK} ${ROM_SYMS} ${ROM_TARGET}.aof
${LD} ${LDFLAGS} ${LDLINKFLAGS} -o $@ -rmf -base ${ADDRESS} ${ROM_TARGET}.aof ${ROM_SYMS} -Symbols ${LNK_TARGET}_sym.linked
#
# Standalone rules
#
install${CUSTOMSA}: ${SA_TARGET}${SUFFIX_MODULE}
${MKDIR} ${INSTDIR}
${CP} ${SA_TARGET}${SUFFIX_MODULE} ${INSTDIR}/${TARGET}${SUFFIX_MODULE}
@${ECHO} ${COMPONENT}: ram module installed
standalone${CUSTOMSA}: ${SA_TARGET}${SUFFIX_MODULE}
@${ECHO} ${COMPONENT}: ram module built
debug${CUSTOMDBG}: ${DBG_TARGET}${SUFFIX_MODULE}
@${ECHO} ${COMPONENT}: debug module built
gpa_debug${CUSTOMGPA}: ${GPA_TARGET}.gpa
@${ECHO} ${COMPONENT}: GPA debug built
prepro: ${DIRS} ${PP_OBJS_}
@${ECHO} ${COMPONENT}: sources preprocessed
${SA_TARGET}${SUFFIX_MODULE}: ${SA_DEPEND} ${DIRS} ${SA_OBJS_} ${SA_LIBS}
${LD} ${LDFLAGS} ${LDRAMFLAGS} -o $@ -rmf ${SA_OBJS_} ${SA_LIBS}
${MODSQZ} ${MODSQZFLAGS} $@
${DBG_TARGET}${SUFFIX_MODULE}: ${SA_DEPEND} ${DIRS} ${DBG_OBJS_} ${SA_LIBS} ${DBG_LIBS}
${LD} ${LDFLAGS} ${LDRAMFLAGS} -o $@ -rmf ${DBG_OBJS_} ${DBG_LIBS} ${SA_LIBS}
${GPA_TARGET}.gpa: ${AIF_TARGET}.aif
${TOGPA} -s aif.${AIF_TARGET} $@
${AIF_TARGET}.aif: ${DBG_TARGET}${SUFFIX_MODULE}
${LD} -aif -bin -d -o ${AIF_TARGET}.aif ${DBG_OBJS_} ${DBG_LIBS} ${SA_LIBS}
include $(wildcard *.d)
include $(wildcard *.dd)
endif
# EOF
# Makefile fragment for defining standard rules for various tools
# when building modules
INCLUDED_MODSTDRULE = YES
# Get the generic rules first
ifeq ("${INCLUDED_STDRULES}","")
include StdRules
endif
.SUFFIXES: .cmhg .od
# Generate C header definitions from CMHG source file
.cmhg.h:; ${CMHG} ${CINCLUDES} ${CMHGFLAGS} -d $@ $<
# CMHG source files -> object file
.cmhg.o:; ${CMHG} ${CINCLUDES} ${CMHGFLAGS} -o $@ $<
.cmhg.od:; ${CMHG} ${CINCLUDES} ${CMHGFLAGS} -o $@ $<
# EOF
# Makefile fragment for libraries linked against modules (RAM or ROM)
INCLUDED_MODULELIBS = YES
ANSILIB = ${LIBDIR}/CLib/ansilibm.a
ifeq (GNU,${TOOLCHAIN})
CLIB =
else
CLIB = ${LIBDIR}/CLib/stubs.a
endif
RLIB = ${LIBDIR}/RISC_OSLib/riscoslibm.a
RSTUBS = ${LIBDIR}/RISC_OSLib/rstubs.a
ROMSTUBS = ${LIBDIR}/RISC_OSLib/romstubs.a
ROMCSTUBS = ${LIBDIR}/RISC_OSLib/romcstubs.a
ABSSYM = ${LIBDIR}/RISC_OSLib/abssym.a
C_ABSSYM = ${LIBDIR}/RISC_OSLib/c_abssym.a
A_ABSSYM = ${LIBDIR}/RISC_OSLib/a_abssym.a
ASMUTILS = ${LIBDIR}/AsmUtils/AsmUtilsZM.a
ifeq (GNU,${TOOLCHAIN})
C++LIB =
else
C++LIB = ${LIBDIR}/c++lib/c++libz.a
endif
CLXLIB = ${LIBDIR}/CLX/clxlibz.a
TBOXLIB = ${LIBDIR}/tboxlibs/toolboxlib.a
FLEXLIB = ${LIBDIR}/tboxlibs/flexlibzm.a
EVENTLIB = ${LIBDIR}/tboxlibs/eventlibm.a
WIMPLIB = ${LIBDIR}/tboxlibs/wimplib.a
RENDERLIB = ${LIBDIR}/tboxlibs/renderlib.a
TBOXLIBS = ${EVENTLIB} ${TBOXLIB} ${RENDERLIB} ${WIMPLIB}
TBOXINTLIB = ${LIBDIR}/tboxlibint/tboxlibm.a
TBOXINTDBGLIB = ${LIBDIR}/tboxlibint/debuglibm.a
SOCK4LIB = ${LIBDIR}/TCPIPLibs/socklibzm.a
SOCK5LIB = ${LIBDIR}/TCPIPLibs/socklib5zm.a
INETLIB = ${LIBDIR}/TCPIPLibs/inetlibzm.a
UNIXLIB = ${LIBDIR}/TCPIPLibs/unixlibzm.a
RPCLIB = ${LIBDIR}/TCPIPLibs/rpc/rpc_datazm.a ${LIBDIR}/TCPIPLibs/rpc/rpclibzm.a
CRYPTLIB = ${LIBDIR}/SSLeay/ssl.a ${LIBDIR}/SSLeay/libcrypto.a
NET4LIBS = ${UNIXLIB} ${INETLIB} ${SOCK4LIB}
NET5LIBS = ${UNIXLIB} ${INETLIB} ${SOCK5LIB}
ABCLIB = ${LIBDIR}/ABCLib/ABCLib.a
CALLXLIB = ${LIBDIR}/callx/callxzm.a
CONLIB = ${LIBDIR}/ConfigLib/ConfigLibzm.a
DDTLIB = ${LIBDIR}/DDTLib/DDTLibzm.a
DESKLIB = ${LIBDIR}/Desk/Desk_M.a
FETCHLIB = ${LIBDIR}/Fetchers/FetchLibZM.a
JSLIB = ${LIBDIR}/JSLib/JSLibzm.a
LDAPLIBS = ${LIBDIR}/LDAP/LDAPzm.a ${LIBDIR}/LDAP/LBERzm.a
MODMALLOCLIB = ${LIBDIR}/ModMalloc/ModMalloczm.a
NCMALIB = ${LIBDIR}/NCMALib/NCMALibZM.a
NSPRLIB = ${LIBDIR}/NSPRLib/NSPRLibzm.a
OSLIB = ${LIBDIR}/OSLib/OSLib.a
PDEBUGLIB = ${LIBDIR}/PDebug/PDebugzm.a
PRISMLIB = ${LIBDIR}/PRISMLib/PRISMLibzm.a
REMOTEDBLIB = ${LIBDIR}/remotedb/remotedbzm.a
RMVSN = ${LIBDIR}/RMVersion/RMVersionZ.a