

.. _target-specifics:

****************
Target specifics
****************

This chapter details the Amiga and A2560 targets.

.. index:: Amiga, Amiga; NDK, NDK; Amiga

Amiga
=====

The installation provides the Amiga NDK (Native Development Kit) and an Amiga
extension library to supplement the C library. The NDK supplied is version 3.2.

If you want to use a different Amiga NDK, search for "ndk" at `Aminet
<http://aminet.net>`_.

The extension library project is available at
`Calypsi Amiga <https://github.com/hth313/Calypsi-Amiga>`_.

Using the ``--target=amiga`` command-line option enables Amiga headers and
knowledge of its system libraries. This provides direct access to Amiga
system headers and ensures proper parameter passing to Amiga library
entry points.

.. note::

   If you use a different Amiga NDK, treat its headers as system headers
   using ``#include <header.h>``. Specify the path with ``--include-system``
   to place them *before* compiler-supplied header files.

.. index:: Amiga library; auto open, auto open; Amiga library

Auto open libraries
-------------------

Amiga libraries must be opened before use. The compile-time runtime
automatically opens certain libraries when you make function calls to them.
This includes ``dos.library``, ``intuition.library``, and ``graphics.library``.
The ``exec.library`` does not require opening, as it is always present at
address ``4`` on the Amiga.

.. note::
   No specific version is requested when opening such libraries. If a specific
   version is required, open the library manually and handle any failures.

Amiga C runtime
---------------

The following cleanups occur automatically upon a normal application ``exit()``:

 #. All memory allocated using ``malloc()`` is released.

 #. All opened files are flushed and closed.

 #. Automatically opened libraries are closed. This includes ``dos``,
    ``graphics`` and ``intuition`` libraries.

Errors from Amiga DOS calls, made on behalf of the C library, are translated
to C-style error codes and stored in the ``errno`` variable.

.. index:: Foenix A2560, A2560

Foenix A2560
============

The installation provides board support for the
`Foenix A2560 <https://github.com/hth313/Calypsi-m68k-Foenix>`_.

Using the command-line option ``--target=a2560k`` or ``--target=a2560u``
makes specific header files available for access:

.. code-block:: C

   #include <mcp.h>
   #include <foenix.h>

A2560 linker rule files are included in the installation directory.
They follow an ``a2560`` prefix naming convention (e.g., ``a2560u+.scm``).
You can refer to these files by name without specifying the full path.
The linker first checks the current directory, then the installation
directory if not found.

To modify a ``.scm`` file, copy it to your project and edit as required.

When linking, specify the same ``--target=a2560k`` or ``--target=a2560u``
option. This enables access to additional target-specific board support
libraries, which are named with an ``sdk`` prefix instead of ``clib``.
