Make

Building with libSFX involves three major parts∶

  • (GNU)Make is invoked and does its thing ... which in this case mostly involves:
  • Assembling source files to object code files with ca65
  • Linking the object code files into an sfc image with ld65

These three steps are configured with the Makefile, libSFX.cfg and Map.cfg respectively.

The simplest possible project doesn’t need the latter two, as all configurable settings fall back to reasonable defaults.

Make needs some input, but in the simplest case it’s not much∶

Makefile

# Include libSFX.make
libsfx_dir    := ../..
include $(libsfx_dir)/libSFX.make

These are the two crucial statements needed to kick off the libSFX.make build script∶

  • The “libsfx_dir” variable must point to the libSFX root directory.
  • The second statement includes “libSFX.make”, which contain the rules needed to transform source files to object code and link the final binary.

There are also a couple of special configuration variables that was best suited to put in the makefile, mostly because they are needed by both the assembler and the linker.

The makefile can of course be used like makefiles usually are – to define rules and prerequisites for your particular project.  In a lot of cases this will not be necessary for source code files, since libSFX.make will recursively add all source files with the appropriate file extensions (.s, .s700, .sgs) if none are explicitly added.

Configuration variables

name Sets the name of the output file.

name := Mode7-Madness

debug If set debug information ($name.dsym, $name.dmap) will be written.  Also, in debug configuration the “break” macro will output the otherwise unused WDM instruction which is used by the bsnes+ emulator to break the debugger.

debug := 1

libsfx packages List of optional packages to link, as well as make available to the assembler with additional macros, memory locations et cetera.

libsfx_packages := LZ4 Mouse

stack size Set space reserved for 65816 stack at memory location 00:2000 and downwards.  Default is 100 bytes.

stack_size := 200

zpad size Set space reserved for zero page scratchpad, addressable at label “ZPAD”.  Default is 10 bytes.

zpad_size := 20

znmi size Set space reserved for zero page scratchpad for use inside interrupts.  Addressable at label “ZNMI”.  Default is 10 bytes.

znmi_size := 20

rpad size Set space reserved for LORAM scratchpad, addressable at label “RPAD”.  Default is 100 bytes.

rpad_size := 20

obj dir Set custom directory for intermediate build files.  Default is “.build”.

obj_dir := build

src 65816 source files.  If not set libSFX.make will automatically add all files named *.s.

src smp SPC700 source files.  If not set libSFX.make will automatically add all files named *.s700.

src gsu GSU-1 source files.  If not set libSFX.make will automatically add all files named *.sgs.