Commit 3d3228a9 authored by Ben Avison's avatar Ben Avison Committed by ROOL

Standardise autogeneration of source files using objasm within CModule clients

Various components use objasm for its general macro abilities in order to
generate intermediate source or header files. To date, this has required
writing of custom rules, which then need separate implementations for
cross-compilation use.

There is no standardisation of destination directory (it may be generating
source or header files in any arbitrary language) so the solution here is to
specify each target using a subdirectory, basename and extension, and leave
CModule to deal with whether or not the extension should be in prefix or
suffix position, depending on the host OS. Only one such autogenerated file
is currently supported per makefile:

```
ASM2TXT = <basename> <optional extension>
ASM2TXT_SUBDIR = <optional subdirectory, each element followed by ${SEP}>
```

The source file passed to objasm is derived from `<basename>`, prefixed by
`s.` or suffixed by `.s` as appropriate.
parent eda4759d
......@@ -67,6 +67,8 @@ INCLUDED_CMODULE = YES
# 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)
# ASM2TXT (opt) (source file to be autogenerated using objasm as a text generator; second word if present is "extension" subdirectory to place output into)
# ASM2TXT_SUBDIR (opt) (non-"extension" subdirectory to place ASM2TXT file into)
# MODULEWRAP (opt) (set to "yes" to build and link with the modulewrap veneer from RISC_OSLib)
#
#
......@@ -237,6 +239,12 @@ else
# Makefile invoked from objs subdirectory
ASM2TXT_BASE := $(word 1,${ASM2TXT})
ASM2TXT_EXT := $(word 2,${ASM2TXT})
ifneq ("${ASM2TXT_EXT}","")
ASM2TXT_EXT := .${ASM2TXT_EXT}
endif
ifeq ("${INCLUDED_STDTOOLS}","")
include StdTools
endif
......@@ -253,6 +261,11 @@ ifeq ("${INCLUDED_DBGRULES}","")
include DbgRules
endif
ifneq ("${ASM2TXT}","")
${ASM2TXT_SUBDIR}${ASM2TXT_BASE}${ASM2TXT_EXT}: ${ASM2TXT_BASE}.o
${LDBIN} $@ $^
endif
#
# General rules
#
......
......@@ -83,6 +83,8 @@ INCLUDED_CMODULE = YES
# 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)
# ASM2TXT (opt) (source file to be autogenerated using objasm as a text generator; second word if present is "extension" subdirectory to place output into)
# ASM2TXT_SUBDIR (opt) (non-"extension" subdirectory to place ASM2TXT file into)
# MODULEWRAP (opt) (set to "yes" to build and link with the modulewrap veneer from RISC_OSLib)
#
#
......@@ -216,6 +218,12 @@ ifneq ($(filter debug%,${MAKECMDGOALS}),)
CMHGFLAGS += ${CMHGDFLAGS} # Affects both object and header generation
endif
ASM2TXT_BASE := $(word 1,${ASM2TXT})
ASM2TXT_EXT := $(word 2,${ASM2TXT})
ifneq ("${ASM2TXT_EXT}","")
ASM2TXT_EXT := ${ASM2TXT_EXT}.
endif
ifeq ("${INCLUDED_STDTOOLS}","")
include StdTools
endif
......@@ -232,6 +240,12 @@ ifeq ("${INCLUDED_DBGRULES}","")
include DbgRules
endif
ifneq ("${ASM2TXT}","")
${ASM2TXT_SUBDIR}${ASM2TXT_EXT}${ASM2TXT_BASE}: o.${ASM2TXT_BASE} ${DIRS}
${LD} -bin -o $@ o.${ASM2TXT_BASE}
${SETTYPE} $@ Text
endif
#
# General rules
#
......@@ -271,6 +285,9 @@ clean ::
@IfThere rm Then ${WIPE} rm ${WFLAGS}
@IfThere h.${CMHGFILE} Then ${ECHO} ${RM} h.${CMHGFILE}
@IfThere h.${CMHGFILE} Then ${RM} h.${CMHGFILE}
ifneq ("${ASM2TXT}","")
@-${RM} ${ASM2TXT_SUBDIR}${ASM2TXT_EXT}${ASM2TXT_BASE}
endif
ifeq ("${MODULEWRAP}","yes")
@-${RM} s.modulewrap
endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment