mirror of
https://git.planet-casio.com/Vhex-Kernel-Core/fxlibc.git
synced 2024-12-29 13:03:38 +01:00
update README and CMake install rules
This commit is contained in:
parent
64e7001d22
commit
8993049f4e
3 changed files with 72 additions and 64 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,4 +1,5 @@
|
||||||
/build*/
|
/build*/
|
||||||
|
/script
|
||||||
|
/prefix
|
||||||
*.txt
|
*.txt
|
||||||
!CMakeLists.txt
|
!CMakeLists.txt
|
||||||
script
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
cmake_minimum_required(VERSION 3.16)
|
cmake_minimum_required(VERSION 3.16)
|
||||||
project(FxLibC VERSION 1.0.0 LANGUAGES C ASM)
|
project(FxLibc VERSION 1.0.0 LANGUAGES C ASM)
|
||||||
|
|
||||||
# Options
|
# Options
|
||||||
|
|
||||||
|
@ -123,8 +123,14 @@ endif()
|
||||||
add_library(fxlibc ${SOURCES})
|
add_library(fxlibc ${SOURCES})
|
||||||
target_include_directories(fxlibc PRIVATE include/)
|
target_include_directories(fxlibc PRIVATE include/)
|
||||||
|
|
||||||
|
set_target_properties(fxlibc PROPERTIES
|
||||||
|
OUTPUT_NAME "c") # libc.a
|
||||||
|
|
||||||
# Install
|
# Install
|
||||||
|
|
||||||
# TODO: Install in compiler vs. in another folder
|
|
||||||
|
|
||||||
install(TARGETS fxlibc DESTINATION lib/)
|
install(TARGETS fxlibc DESTINATION lib/)
|
||||||
|
install(DIRECTORY include/ DESTINATION include/ PATTERN "target" EXCLUDE)
|
||||||
|
|
||||||
|
foreach(FOLDER IN LISTS TARGET_FOLDERS)
|
||||||
|
install(DIRECTORY include/target/${FOLDER}/ DESTINATION include/)
|
||||||
|
endforeach()
|
||||||
|
|
121
README.md
121
README.md
|
@ -1,10 +1,10 @@
|
||||||
# The FX C Library
|
# The FX C Library
|
||||||
|
|
||||||
This directory contains the sources of the FxLibc Library.
|
This directory contains the sources of the FxLibc Library. See `CMakeLists.txt`
|
||||||
See the `make version` command to see for what release version you have.
|
to see what release version you have.
|
||||||
|
|
||||||
The Fx C Library is the standard system C library implementation for all Casio
|
The FxLibc is the standard system C library implementation for all Casio
|
||||||
Fx calculator, and is an important part of what makes up programs on these
|
fx calculators, and is an important part of what makes up programs on these
|
||||||
devices. It provides the system API for all programs written in C and
|
devices. It provides the system API for all programs written in C and
|
||||||
C-compatible languages such as C++ and Objective-C; the runtime facilities of
|
C-compatible languages such as C++ and Objective-C; the runtime facilities of
|
||||||
other programming languages use the C library to access the underlying operating
|
other programming languages use the C library to access the underlying operating
|
||||||
|
@ -13,59 +13,65 @@ system.
|
||||||
---
|
---
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
Fx C library depends on a suitable GCC toolchain in the PATH. You can absolutely
|
FxLibc requires a GCC compiler toolchain the PATH to build for any calculator.
|
||||||
not build `fxlibc` with your system compiler!
|
You cannot build with your system compiler! The tutorial on Planète Casio
|
||||||
|
builds an `sh-elf` toolchain that supports all models using multilib.
|
||||||
|
|
||||||
* The tutorial on Planète Casio builds an sh-elf that works everywhere.
|
For Vhex and gint targets, the headers of the kernel are also required.
|
||||||
* For fx-9860G II, `sh3eb-elf` is strongly advised.
|
|
||||||
* For fx-CG 50, `sh4eb-elf` (with `-m4-nofpu`) is slightly better but `sh3eb-elf`
|
|
||||||
is completely fine.
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Building and installating FxLibc
|
## Building and installing FxLibc
|
||||||
You can choose to build `fxlibc` standalone or with the support of the fx-9860G
|
FxLibc supports several targets:
|
||||||
II (monochrome calculators, aka Graph 85 family) Casio ABI, fx-CG 50 (color
|
* Vhex on SH targets (`vhex-sh`)
|
||||||
calculators, aka Prizm or Graph 90 family), Vhex kernel ABI or all of them (this
|
* CASIOWIN for fx-9860G-like calculators (`casiowin-fx`)
|
||||||
will generate 3 distinct libraries).
|
* CASIOWIN for fx-CG-series calculators (`casiowin-cg`)
|
||||||
|
* gint for all targets (`gint`)
|
||||||
|
|
||||||
Each ABI support add many functionalities provided by the operating system, like
|
Each target supports different features depending on what the kernel/OS
|
||||||
I/O abstraction (open, close, fcntl, stat, ...). (see "supported features" on
|
provides.
|
||||||
the wiki)
|
|
||||||
|
|
||||||
#### Configuration and support
|
#### Configuration and support
|
||||||
The Fx C library supports these ABI:
|
|
||||||
* `fx9860g` for the support of Casio ABI used by fx9860g-like devices.
|
|
||||||
* `fxcg50` for the support of Casio ABI used by the fxcg50 device.
|
|
||||||
* `vhex` for the support of Vhex kernel ABI.
|
|
||||||
* (nothing) compile only standing functions.
|
|
||||||
|
|
||||||
The Fx C library support these format:
|
Configure with CMake; specify the target with `-DFXLIBC_TARGET`. For SH
|
||||||
* `static` generate static libraries.
|
platforms, set the toolchain to `cmake/toolchain-sh.cmake`.
|
||||||
* `dynamic` generate dynamic libraries (Only for the Vhex kernel).
|
|
||||||
|
|
||||||
Note that the shared feature is not currently implemented because of
|
The FxLibc supports shared libraries when building with Vhex (TODO); set
|
||||||
non-support of the shared library generation by the GCC compiler for SuperH
|
`-DSHARED=1` to enable this behavior.
|
||||||
architecture. A workaround can be used but it requires a static library to do
|
|
||||||
the dynamic symbols resolving (Thanks Kristaba).
|
|
||||||
|
|
||||||
For more information about library build configuration, you can use the
|
You can either install FxLibc in the compiler's `include` folder, or installl
|
||||||
`./configure --help` command.
|
in another location of your choice. In the second case, you will need a `-I`
|
||||||
|
option when using the library.
|
||||||
|
|
||||||
|
To use the compiler, set `PREFIX` like this:
|
||||||
|
|
||||||
|
```
|
||||||
|
% PREFIX=$(sh-elf-gcc -print-file-name=.)
|
||||||
|
```
|
||||||
|
|
||||||
|
To use another location, set `PREFIX` manually (recommended):
|
||||||
|
|
||||||
|
```
|
||||||
|
% PREFIX="$HOME/.sh-prefix/"
|
||||||
|
```
|
||||||
|
|
||||||
|
Example for a static Vhex build:
|
||||||
|
|
||||||
|
```
|
||||||
|
% cmake -B build-vhex-sh -DFXLIBC_TARGET=vhex-sh -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-sh.cmake -DCMAKE_INSTALL_PREFIX="$PREFIX"
|
||||||
|
```
|
||||||
|
|
||||||
#### Building
|
#### Building
|
||||||
Create a build directory and configure in it:
|
Build in the directory specified in `cmake -B`.
|
||||||
```
|
|
||||||
% mkdir build && cd build
|
|
||||||
% ../configure --static --support=vhex,fx9860g,fxcg50
|
|
||||||
```
|
|
||||||
|
|
||||||
Then build the source and install the library files to the selected directory.
|
|
||||||
You might need root access if you selected a target directory owned by root with
|
|
||||||
`--prefix`, or if you built your compiler as root.
|
|
||||||
|
|
||||||
```
|
```
|
||||||
% make
|
% make -C build
|
||||||
% make install
|
```
|
||||||
|
|
||||||
|
To install, run the `install` target.
|
||||||
|
|
||||||
|
```
|
||||||
|
% make -C build install
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
@ -77,28 +83,23 @@ welcome.
|
||||||
If you are interested in doing a port, or want to contribute to this project,
|
If you are interested in doing a port, or want to contribute to this project,
|
||||||
please, try to respect these constraints:
|
please, try to respect these constraints:
|
||||||
* Document your code.
|
* Document your code.
|
||||||
* One function per files.
|
* One function per file (named like the function).
|
||||||
* Each file name content only the name of the function.
|
* Use the same formatting conventions as the rest of the code.
|
||||||
* Respect the Linux Coding style as much as possible (if you are not familiar
|
* Only use hardware-related code (DMA, SPU, etc) in target-specified files
|
||||||
with this norm, you can use `indent -linux` utility to help to format).
|
when the target explicitly supports it.
|
||||||
* Header must respect the `/usr/include` architecture.
|
|
||||||
* Avoid modules hardware-specific code which can generate interruptions
|
|
||||||
(DMA, SPU, ...) except if you are absolutely sure that the operating
|
|
||||||
system can handle them.
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### Using Fx C Library
|
### Using FxLibc
|
||||||
|
|
||||||
To use Fx C library as your runtime environment, the bare minimum is:
|
Include headers normally (`#include <stdio.h>`); on SH platforms where
|
||||||
|
`sh-elf-gcc` is used, link with `-lc` (by default the `-nostdlib` flag is
|
||||||
|
used for a number of reasons).
|
||||||
|
|
||||||
* You must add `fxlibc/` instead of each include file (for example, if you want
|
If you're installing in a custom folder, you also need `-I "$PREFIX/include"`
|
||||||
to include `stdio.h` you mush use `#include <fxlibc/stdio.h>`.
|
and `-L "$PREFIX/lib"`. If you're installing in the GCC install folder, you
|
||||||
* Link with:
|
don't need `-I` but you still need the `-L` as the default location for
|
||||||
* `-lfxlibc-fx9860g` for Casio ABI support for monochrome devices
|
libraries is at the root instead of in a `lib` subfolder.
|
||||||
* `-lfxlibc-fxcg50` for Casio ABI support for primz devices
|
|
||||||
* `-lfxlibc-vhex` for Vhex kernel support.
|
|
||||||
* `-lfxlibc` for standalone features
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue