update README and CMake install rules

pull/2/head
Lephenixnoir 1 year ago
parent 64e7001d22
commit 8993049f4e
Signed by: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
  1. 3
      .gitignore
  2. 12
      CMakeLists.txt
  3. 115
      README.md

3
.gitignore vendored

@ -1,4 +1,5 @@
/build*/
/script
/prefix
*.txt
!CMakeLists.txt
script

@ -1,5 +1,5 @@
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
@ -123,8 +123,14 @@ endif()
add_library(fxlibc ${SOURCES})
target_include_directories(fxlibc PRIVATE include/)
# Install
set_target_properties(fxlibc PROPERTIES
OUTPUT_NAME "c") # libc.a
# TODO: Install in compiler vs. in another folder
# Install
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()

@ -1,10 +1,10 @@
# The FX C Library
This directory contains the sources of the FxLibc Library.
See the `make version` command to see for what release version you have.
This directory contains the sources of the FxLibc Library. See `CMakeLists.txt`
to see what release version you have.
The Fx C Library is the standard system C library implementation for all Casio
Fx calculator, and is an important part of what makes up programs on these
The FxLibc is the standard system C library implementation for all Casio
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
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
@ -13,59 +13,65 @@ system.
---
## Dependencies
Fx C library depends on a suitable GCC toolchain in the PATH. You can absolutely
not build `fxlibc` with your system compiler!
FxLibc requires a GCC compiler toolchain the PATH to build for any calculator.
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 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.
For Vhex and gint targets, the headers of the kernel are also required.
---
## Building and installating FxLibc
You can choose to build `fxlibc` standalone or with the support of the fx-9860G
II (monochrome calculators, aka Graph 85 family) Casio ABI, fx-CG 50 (color
calculators, aka Prizm or Graph 90 family), Vhex kernel ABI or all of them (this
will generate 3 distinct libraries).
## Building and installing FxLibc
FxLibc supports several targets:
* Vhex on SH targets (`vhex-sh`)
* CASIOWIN for fx-9860G-like calculators (`casiowin-fx`)
* 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
I/O abstraction (open, close, fcntl, stat, ...). (see "supported features" on
the wiki)
Each target supports different features depending on what the kernel/OS
provides.
#### 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:
* `static` generate static libraries.
* `dynamic` generate dynamic libraries (Only for the Vhex kernel).
Configure with CMake; specify the target with `-DFXLIBC_TARGET`. For SH
platforms, set the toolchain to `cmake/toolchain-sh.cmake`.
Note that the shared feature is not currently implemented because of
non-support of the shared library generation by the GCC compiler for SuperH
architecture. A workaround can be used but it requires a static library to do
the dynamic symbols resolving (Thanks Kristaba).
The FxLibc supports shared libraries when building with Vhex (TODO); set
`-DSHARED=1` to enable this behavior.
For more information about library build configuration, you can use the
`./configure --help` command.
You can either install FxLibc in the compiler's `include` folder, or installl
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
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
% make -C build
```
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.
To install, run the `install` target.
```
% make
% make install
% make -C build install
```
---
@ -77,28 +83,23 @@ welcome.
If you are interested in doing a port, or want to contribute to this project,
please, try to respect these constraints:
* Document your code.
* One function per files.
* Each file name content only the name of the function.
* Respect the Linux Coding style as much as possible (if you are not familiar
with this norm, you can use `indent -linux` utility to help to format).
* 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.
* One function per file (named like the function).
* Use the same formatting conventions as the rest of the code.
* Only use hardware-related code (DMA, SPU, etc) in target-specified files
when the target explicitly supports it.
---
### 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
to include `stdio.h` you mush use `#include <fxlibc/stdio.h>`.
* Link with:
* `-lfxlibc-fx9860g` for Casio ABI support for monochrome devices
* `-lfxlibc-fxcg50` for Casio ABI support for primz devices
* `-lfxlibc-vhex` for Vhex kernel support.
* `-lfxlibc` for standalone features
If you're installing in a custom folder, you also need `-I "$PREFIX/include"`
and `-L "$PREFIX/lib"`. If you're installing in the GCC install folder, you
don't need `-I` but you still need the `-L` as the default location for
libraries is at the root instead of in a `lib` subfolder.
---

Loading…
Cancel
Save