| |||
| Home > Customizing Projects > Configuring linker options > Adding prelink and postlink commands | |||
Prelink and postlink makefile commands are run only when the linker is run. Prelink commands can be used to copy libraries or objects from other developers so that you do not have to build them yourself. Postlink commands might be used to convert the executable file into another format, for example to load to Flash or for loading by a specific operating system.
To add prelink and postlink commands to the build:
Select Project → Project Properties... to display the Project Properties window.
Right-click on the *BUILD group
in the List of Entries pane, the left pane, and select Expand
whole Tree from the context menu.
Select the Pre_Post_Link group
in the List of Entries pane.
Right-click on the Pre_link setting
in the Settings Values pane, the right pane, and select Edit
Value from the context menu.
Type @+echo This is before linkage and
then press Enter to confirm the value.
This string is output every time you build or rebuild, the application, but the command is not displayed when it is executed.
Right-click on the Post_link setting
in the Settings Values pane, and select Edit Value from
the context menu.
Type +copy $(PROGRAM) $\temp.axf and
then press Enter to confirm the value.
Type this exactly as shown. Your window looks like Figure 5.7.
This postlink command copies the output from the build, that
is dhrystone.axf, to another location. In this
example, you are sending the executable file temp.axf to the
current working directory, but it might be a predefined central
location for images to be debugged.
The copy command is displayed in the Build tab when executed.
Select File → Save and Close to regenerate the makefile(s) for the project, and close the Project Properties window.
Select Tools → Build... to rebuild the application.
Click on the Build tab, if necessary, to see the linker output, shown in Figure 5.8.
Makefile commands can include operating system commands.