OpenLibm/README.md

61 lines
2.4 KiB
Markdown
Raw Normal View History

2020-10-24 14:03:04 +02:00
# Soft-FP sh3eb port of OpenLibm
2022-08-12 22:04:52 +02:00
This is a fork of [OpenLibm](https://github.com/JuliaMath/openlibm) with support for the sh3eb architecture, intended for add-in programming on SuperH CASIO calculators.
2020-10-24 14:03:04 +02:00
## Installing with GiteaPC
2022-08-12 22:04:52 +02:00
This library can be installed automatically as part of the fxSDK with [GiteaPC](https://gitea.planet-casio.com/Lephenixnoir/GiteaPC):
2022-08-12 22:04:52 +02:00
```bash
% giteapc install Lephenixnoir/OpenLibm
```
## Building manually
2020-10-24 14:03:04 +02:00
2022-08-12 22:04:52 +02:00
You will need a GCC toolchain built with `--target=sh3eb-elf`, such as the [`sh-elf-gcc`](https://gitea.planet-casio.com/Lephenixnoir/sh-elf-gcc) commonly used on Planète Casio.
2020-10-24 14:03:04 +02:00
2022-08-12 22:04:52 +02:00
You can install directly in the internal folder of your compiler, or somewhere else if you have a more detailed setup.
2020-10-24 14:03:04 +02:00
2022-08-12 22:04:52 +02:00
```bash
# Example 1: Use the compiler's internal folder
% COMPILER_DIR="$(sh-elf-gcc --print-file-name=.)"
% LIBDIR="$COMPILER_DIR"
% INCDIR="$COMPILER_DIR/include"
# Example 2: Using the fxSDK's custom setup
% LIBDIR="$(fxsdk path lib)"
% INCDIR="$(fxsdk path include)"
2020-10-24 14:03:04 +02:00
```
2022-08-12 22:04:52 +02:00
You can then build and install the static library and the headers.
2020-10-24 14:03:04 +02:00
2022-08-12 22:04:52 +02:00
```bash
% make USEGCC=1 TOOLPREFIX=sh-elf- AR=sh-elf-ar CC=sh-elf-gcc \
libdir="$LIBDIR" includedir="$INCDIR" \
install-static-superh install-headers-superh
2020-10-24 14:03:04 +02:00
```
2022-08-12 22:04:52 +02:00
The `-superh` targets differ from the the normal targets in the following ways:
2020-10-24 14:03:04 +02:00
2022-08-12 22:04:52 +02:00
* `install-static-superh` also creates a symlink `libm.a -> libopenlibm.a`.
* `install-headers-superh` installs directly in `$LIBDIR` instead of `$LIBDIR/openlibm` since OpenLibm headers reference each other without that prefix and enforcing the correct `-I` in every project is quite painful. In addition, it skips internal and non-SuperH headers.
2021-05-02 15:05:36 +02:00
2022-08-12 22:04:52 +02:00
## Using the library
2021-05-02 15:05:36 +02:00
2022-08-12 22:04:52 +02:00
Include the headers `<openlibm_complex.h>`, `<openlibm_fenv.h>` and `<openlibm_math.h>`. Or, if you are using a suitable libc like [fxlibc](https://gitea.planet-casio.com/Vhex-Kernel-Core/fxlibc/), include directly the standard headers `<complex.h>`, `<fenv.h>` and `<math.h>`.
2021-05-02 15:05:36 +02:00
2022-08-12 22:04:52 +02:00
Link with `-lm`. In a Makefile, update your `LDFLAGS`:
2021-05-02 15:05:36 +02:00
```
2022-08-12 22:04:52 +02:00
LDFLAGS += -lm
```
In CMake, use [`target_link_libraries()`](https://cmake.org/cmake/help/latest/command/target_link_libraries.html):
```cmake
target_link_libraries(<TARGET> PUBLIC -lm)
2021-05-02 15:05:36 +02:00
```
2020-10-24 14:03:04 +02:00
## README and Licensing
2022-08-12 22:04:52 +02:00
See the original README file in [README-OpenLibm.md](README-OpenLibm.md). OpenLibm contains code covered by various licenses, see [LICENSE.md](LICENSE.md).