giteapc compatibility

This commit is contained in:
Sylvain PILLOT 2022-03-01 14:39:13 +01:00
parent 9f9e23d695
commit 2901370e3e
6 changed files with 166 additions and 4 deletions

7
.gitignore vendored Normal file
View File

@ -0,0 +1,7 @@
# Build files
build*/
# GiteaPC configuration files
giteapc-config-*.make
giteapc-config.make

68
CMakeLists.txt Normal file
View File

@ -0,0 +1,68 @@
# libustl: build system
cmake_minimum_required(VERSION 3.16)
project(libustl VERSION 2.3 LANGUAGES C)
# Libraries that libexample depends on
find_package(Gint 2.1 REQUIRED)
set(USTL_NAME "ustl")
set(USTL_STRING "ustl v2.1")
set(USTL_VERSION "2.1")
set(USTL_BUGREPORT "Mike Sharov <msharov@users.sourceforge.net>")
# Turn include/config.h.in into a proper config.h where the @VAR@ have
# been replaced; this is how version numbers are maintained. libexample_VERSION
# is set to "1.0" by the project() command.
# Note that the input (config.h.in) is relative to the source dir, but the
# output (config.h) is in the build dir, so it doesn't pollute the Git repo.
configure_file(./config.h.in include/config.h)
set(SOURCES
src/cmemlink.cc
src/fstream.cc
src/memblock.cc
src/memlink.cc
src/mistream.cc
src/ofstream.cc
src/sistream.cc
src/sostream.cc
src/ualgobase.cc
src/ubitset.cc
src/unew.cc
src/ustring.cc
)
include_directories(
"${PROJECT_SOURCE_DIR}/include"
"${PROJECT_BINARY_DIR}/include"
"${FXSDK_COMPILER_INSTALL}/include"
"${FXSDK_COMPILER_INSTALL}/include/openlibm")
add_compile_options(-Os -mb -m4a-nofpu -mhitachi -std=c++11 -fno-strict-aliasing -fno-exceptions -ffreestanding -frtti)
# Target name is "ustl", output file is "libustl.a" (by default)
add_library(ustl STATIC ${SOURCES})
# After building, install the target (that is, libustl.a) in the compiler
install(TARGETS ustl
DESTINATION "${FXSDK_COMPILER_INSTALL}")
# Also install the headers (our include folder gets merged with the existing
# one in the compiler's install folder). Only install files matching *.h to
# exclude config.h.in.
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include"
DESTINATION "${FXSDK_COMPILER_INSTALL}"
FILES_MATCHING PATTERN "*")
# Slyvtt : replaced "*.h" with "*" as some headers are in the C++ style, without .h extension
# So to avoid a "non-volontary" copy of config.h.in in the compiler's include folder,
# I decided to move config.h.in at the root of the project and set the copy line above accordingly
# Install config.h from the build dir
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/include/config.h"
DESTINATION "${FXSDK_COMPILER_INSTALL}/include/ustl")
# Install FindLibUstl.cmake so that users can do find_package(Libustl)
install(FILES cmake/FindUstl.cmake
DESTINATION "${FXSDK_CMAKE_MODULE_PATH}")

View File

@ -0,0 +1,12 @@
# µSTL 2.3 sources for Casio Graph 90+E
Need to have a fully working gcc toolchain for SH3/SH4 architecture.
Compilation is done by using the adhoc Makefile :
`make` in the main directory
It should produce the library libustl.a
The following steps are not automatically done, so please proceed with the following manipulations :
* copy the library libustl.a into your SH3/SH4 compiler lib folder
* copy all header files contained in the include foler into the include folder of the SH3/SH4 compiler

49
cmake/FindUstl.cmake Normal file
View File

@ -0,0 +1,49 @@
find_package(Gint 2.1 REQUIRED)
# Find libexample.a; if we had platform-specific versions we could look for
# libexample-${FXSDK_PLATFORM}.a instead.
execute_process(
COMMAND ${CMAKE_C_COMPILER} -print-file-name=libustl.a
OUTPUT_VARIABLE EX_PATH OUTPUT_STRIP_TRAILING_WHITESPACE)
# EX_PATH is now the full path if libustl.a exists, "libustl.a" otherwise
if(NOT "${EX_PATH}" STREQUAL "libustl.a")
# Find the version.h header
execute_process(
COMMAND ${CMAKE_C_COMPILER} -print-file-name=include/ustl/config.h
OUTPUT_VARIABLE EX_CONFIG OUTPUT_STRIP_TRAILING_WHITESPACE)
# Extract version information from the config.h header. This command prints
# the version on the line matching the regex and deletes every other line.
execute_process(
COMMAND sed -E "s/#define.*EX_VERSION\\s+\"(\\S+)\"$/\\1/p; d" ${EX_CONFIG}
OUTPUT_VARIABLE EX_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
# The commands above seem common for gint libraries, so the fxSDK provides a
# helper function to get that directly. We simply provide the archive name,
# header file name, macro name, and names for output variables.
# include(FindSimpleLibrary)
# find_simple_library(libexample.a include/example/config.h "EX_VERSION"
# PATH_VAR EX_PATH VERSION_VAR EX_VERSION)
# This CMake utility will handle the version comparisons and other checks. We
# just specify:
# -> Some variables that are defined only if the library is found (so if
# they're undefined, CMake will conclude libexample was not found)
# -> The version, so CMake can compare with the user's requested one
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LibUstl
REQUIRED_VARS EX_CONFIG EX_VERSION
VERSION_VAR EX_VERSION)
# We now have a LibExample_FOUND variable, let's create the target that users
# can link against with target_link_libraries()
if(LibUstl_FOUND)
# This is an imported target, we don't build it, we just claim it's here
add_library(LibUstl::LibUstl UNKNOWN IMPORTED)
# Here we declare the compiler and linker flags that every user of LibExample
# needs to use.
set_target_properties(LibUstl::LibUstl PROPERTIES
# If we specify where the library comes from, CMake will watch that file
# and relink any user application when the library is updated!
IMPORTED_LOCATION "${EX_PATH}"
# Linking options
INTERFACE_LINK_OPTIONS -lustl
# Dependencies (for order on the command-line)
IMPORTED_LINK_INTERFACE_LIBRARIES Gint::Gint)
endif()

View File

@ -2,13 +2,13 @@
#pragma once
// Define to the one symbol short name of this package.
#define USTL_NAME "ustl"
#define USTL_NAME "@USTL_NAME@"
// Define to the full name and version of this package.
#define USTL_STRING "ustl v2.1"
#define USTL_STRING "@USTL_STRING@"
// Define to the version of this package.
#define USTL_VERSION 0x210
#define USTL_VERSION @USTL_VERSION@
// Define to the address where bug reports for this package should be sent.
#define USTL_BUGREPORT "Mike Sharov <msharov@users.sourceforge.net>"
#define USTL_BUGREPORT "@USTL_BUGREPORT@"
/// Define to 1 if you want stream operations to throw exceptions on
/// insufficient data or insufficient space. All these errors should

26
giteapc.make Normal file
View File

@ -0,0 +1,26 @@
# giteapc: version=1 depends=Lephenixnoir/gint,Lephenixnoir/sh-elf-gcc,Lephenixnoir/fxsdk,Lephenixnoir/OpenLibm,Vhex-Kernel-Core/fxlibc
-include giteapc-config.make
configure:
@ fxsdk build-fx -c $(GINT_CMAKE_OPTIONS)
@ fxsdk build-cg -c $(GINT_CMAKE_OPTIONS)
build:
@ fxsdk build-fx
@ fxsdk build-cg
install:
@ fxsdk build-fx install
@ fxsdk build-cg install
uninstall:
@ if [ -e build-fx/install_manifest.txt ]; then \
xargs rm -f < build-fx/install_manifest.txt; \
fi
@ if [ -e build-cg/install_manifest.txt ]; then \
xargs rm -f < build-cg/install_manifest.txt; \
fi
.PHONY: configure build install uninstall