Change how top-level phony rules are overridden
A common pattern previously in use was for a shared makefile to define a
top-level phony rule (the sort of thing that srcbuild
or a !Mk
file would
use as the target to pass to amu
) but with a macro expansion within the
rule name. This allowed clients to override the rule by assigning any value
to the macro.
However, this approach makes it relatively difficult for clients to be adapted to support cross-compilation. This is because when cross-compiling, the shared makefiles utilise nested invocations of the make tool in order to facilitate an out-of-tree build directory layout. Therefore, clients need to determine whether they are cross-compiling, and if so, whether they are in the context of the inner or outer make invocation, before they can decide whether or not to redefine the phony target. This can be achieved in as little as 3 extra lines:
CURDIR ?= objs
ifeq (objs,$(notdir ${CURDIR}))
# redefinitions of top-level phony rules placed here
endif
but this wasn't universally popular. Instead, taking inspiration from
INSTTYPE
, we can chain from each ${PHONY}
rule to a ${PHONY}_custom
rule
and have the client makefile define the ${PHONY}_custom
rule instead.
Crucially, in the cross-compiling case, the shared makefile can then take
care of ensuring this only happens on the inner make
invocation.
In summary:
When setting CUSTOMEXP
to custom
, clients should henceforth
- define
export_hdrs_custom
andexport_libs_custom
rather than redefineexport
- define
export_hdrs_custom
rather than redefineexport_hdrs
- define
export_libs_custom
rather than redefineexport_libs
When setting CUSTOMROM
to custom
, clients should henceforth
- define
install_rom_custom
rather than redefineinstall_rom
- define
rom_custom
rather than redefinerom
- define
rom_link_custom
rather than redefinerom_link
When setting CUSTOMSA
to custom
, clients should henceforth
- define
install_custom
rather than redefineinstall
- define
standalone_custom
rather than redefinestandalone
CUSTOMDBG
and CUSTOMGPA
are now removed. These were not being used by
any client makefiles, but it seems probable that the rules they related to
(debug
and gpa_debug
respectively) would have needed overriding in
precisely the same circumstances as install
and standalone
, so in
future CUSTOMSA
should be used for these also.
Merge requests have also been raised for all the affected client makefiles to prepare them for this change. These should be merged first:
- RiscOS/Sources/FileSys/ADFS/ADFSFiler!6 (merged)
- RiscOS/Sources/Networking/AUN/AUNMsgs!2 (merged)
- RiscOS/Sources/Networking/Ethernet/EtherCPSW!4 (merged)
- RiscOS/Sources/Networking/Ethernet/EtherGENET!3 (merged)
- RiscOS/Sources/Networking/Ethernet/EtherK!1 (merged)
- RiscOS/Sources/Networking/Ethernet/EtherUSB!4 (merged)
- RiscOS/Sources/Networking/Ethernet/EtherY!1 (merged)
- RiscOS/Sources/FileSys/FSLock!5 (merged)
- RiscOS/Sources/Networking/Fetchers/Gopher!2 (closed)
- RiscOS/Sources/SystemRes/InetRes!24 (merged)
- RiscOS/Sources/Kernel!69 (merged)
- RiscOS/Sources/Internat/Territory/TerritoryModule!2 (merged)
- RiscOS/Sources/Toolbox/ToolAction!3 (merged)
- RiscOS/Sources/HWSupport/USB/USBDriver!11 (merged)
- RiscOS/Sources/Desktop/Wimp!35 (merged)
Once this MR is merged, amu
will start to emit warnings when building each of them about redefinition of the affected phony targets in those client makefiles, however, those are harmless and can safely be ignored. It is proposed that as and when each of those makefiles is updated to support cross-compilation, the redundant phony target rules be removed.
A ROM build has been completed successfully to ensure the merge requests work in conjunction.