18.3.6.4 Variables to Modify Command Lines

The following _PRE and _POST variables are optional. They exist simply to allow customization of the command line. You can run a make without defining any of them.

MP_EXTRA_CC_PRE MP_EXTRA_CC_POST
MP_EXTRA_BC_PRE MP_EXTRA_BC_POST
MP_EXTRA_AS_PRE MP_EXTRA_AS_POST
MP_EXTRA_AR_PRE MP_EXTRA_AR_POST
MP_EXTRA_LD_PRE MP_EXTRA_LD_POST

Many compilers (such as gcc-based ones) use their main shell program to call the linker/assembler. These command lines, then, have a first section (where MP_EXTRA_XX_PRE is located), and a second section, which is typically passed to the linker/assembler (where MP_EXTRA_XX_POST is located). That is why two macros per each tool are needed to allow you to modify the behavior of that tool.

An example of a link line in a gcc-based compiler is:

${MP_CC}  -omf=elf  ${MP_PROCESSOR_OPTION_LD} ${MP_EXTRA_LD_PRE} -o dist/$(CND_CONF}/${IMAGE_TYPE}/Explorer16PIC24DSC_1.${IMAGE_TYPE}.elf ${OBJECTFILES} -Wl,--defsym=__MPLAB_BUILD=1,--report-mem, -Tp24FJ128GA010.gld${MP_EXTRA_LD_POST}

In this case, the MP_EXTRA_LD_PRE is issued to the shell (before -Wl) and the MP_EXTRA_LD_POST is issued after. You need to pass valid options – see your language tool documentation. For the options to be included before the -Wl, you need a space as a separator:

MP_EXTRA_LD_PRE= -D_FOO -D_BAR

And for the options to be included after -Wl, you need a comma as a separator:

MP_EXTRA_LD_POST=--defsym=_FOO,--defsym=_BAR

If the toolchain does not support the use of a driver shell (like gcc), then simply use the _PRE variables.