making giteapc compatibility

This commit is contained in:
Sylvain PILLOT 2022-05-05 22:05:33 +02:00
parent 400397aded
commit 497eac2c47
7 changed files with 235 additions and 67 deletions

47
CMakeLists.txt Normal file
View File

@ -0,0 +1,47 @@
# SDL_image_prizm: build system
cmake_minimum_required(VERSION 3.16)
project(LibSDL_image VERSION 1.2.12 LANGUAGES C)
# Libraries that libexample depends on
find_package(Gint 2.7.1 REQUIRED)
set(SOURCES
IMG.c
IMG_bmp.c
IMG_gif.c
IMG_jpg.c
IMG_lbm.c
IMG_pcx.c
IMG_png.c
IMG_pnm.c
IMG_tga.c
IMG_tif.c
IMG_webp.c
IMG_xcf.c
IMG_xpm.c
IMG_xv.c
)
include_directories(
"${PROJECT_SOURCE_DIR}"
"${FXSDK_COMPILER_INSTALL}/include"
"${FXSDK_COMPILER_INSTALL}/include/openlibm")
add_compile_options(-Os -lm -m4-nofpu -mb -std=c11 -ffreestanding -nostdlib -Wa,--dsp -lcPNG -lczlib -lSDL_prizm -DLOAD_GIF -DLOAD_LBM -DLOAD_PCX -DLOAD_PNM -DLOAD_TGA -DLOAD_XCF -DLOAD_BMP -DLOAD_PNG)
# Target name is "SDL_image_prizm", output file is "libSDL_image_prizm.a" (by default)
add_library(SDL_image_prizm STATIC ${SOURCES})
# After building, install the target (that is, SDL_image_prizm.a) in the compiler
install(TARGETS SDL_image_prizm
DESTINATION "${FXSDK_COMPILER_INSTALL}")
# Install zlib.h from the build dir
install(FILES "${PROJECT_SOURCE_DIR}/SDL/SDL_image.h"
DESTINATION "${FXSDK_COMPILER_INSTALL}/include")
# Install FindSDL_prizm.cmake so that users can do find_package(LibSDL_prizm)
install(FILES cmake/FindcSDL_image_prizm.cmake
DESTINATION "${FXSDK_CMAKE_MODULE_PATH}")

17
IMG.c
View File

@ -149,22 +149,18 @@ SDL_Surface *IMG_Load_RW(SDL_RWops *src, int freesrc)
/* Load an image from an SDL datasource, optionally specifying the type */
SDL_Surface *IMG_LoadTyped_RW(SDL_RWops *src, int freesrc, char *type)
{
cSDL_LogToFile( "IMG_LoadTypeRW : %p - %d - %s", src, freesrc, type );
int i;
SDL_Surface *image;
/* Make sure there is something to do.. */
if ( src == NULL ) {
IMG_SetError("Passed a NULL data source");
cSDL_LogToFile( "IMG_LoadTypeRW : src is NULL !!!" );
return(NULL);
}
/* See whether or not this data source can handle seeking */
if ( SDL_RWseek(src, 0, RW_SEEK_CUR) < 0 ) {
IMG_SetError("Can't seek in this data source");
cSDL_LogToFile( "IMG_LoadTypeRW : can't seek in the file !!!" );
if(freesrc)
SDL_RWclose(src);
return(NULL);
@ -176,19 +172,14 @@ SDL_Surface *IMG_LoadTyped_RW(SDL_RWops *src, int freesrc, char *type)
if(type && IMG_string_equals(type, "TGA")) image = IMG_LoadTGA_RW(src);
else if(IMG_isCUR(src)) image = IMG_LoadCUR_RW(src);
else if(IMG_isICO(src)) image = IMG_LoadICO_RW(src);
//else if(IMG_isBMP(src)) cSDL_LogToFile( "IMG_LoadTypeRW : will now call IMG_LoadBMP_RW" ), image = IMG_LoadBMP_RW(src);
else if(type && IMG_string_equals(type, "BMP")) image = IMG_LoadBMP_RW(src);
else if(IMG_isBMP(src)) image = IMG_LoadBMP_RW(src);
else if(IMG_isGIF(src)) image = IMG_LoadGIF_RW(src);
else if(IMG_isJPG(src)) image = IMG_LoadJPG_RW(src);
else if(IMG_isLBM(src)) image = IMG_LoadLBM_RW(src);
else if(IMG_isPCX(src)) image = IMG_LoadPCX_RW(src);
//else if(IMG_isPNG(src)) cSDL_LogToFile( "IMG_LoadTypeRW : will now call IMG_LoadPNG_RW" ), image = IMG_LoadPNG_RW(src);
else if(type && IMG_string_equals(type, "PNG")) image = IMG_LoadPNG_RW(src);
else if(IMG_isPNG(src)) image = IMG_LoadPNG_RW(src);
else if(IMG_isPNM(src)) image = IMG_LoadPNM_RW(src);
else if(IMG_isLBM(src)) image = IMG_LoadLBM_RW(src);
else if(IMG_isTIF(src)) image = IMG_LoadTIF_RW(src);
else if(IMG_isXCF(src)) image = IMG_LoadXCF_RW(src);
else if(IMG_isXPM(src)) image = IMG_LoadXPM_RW(src);

View File

@ -1,10 +1,10 @@
INCLUDE = -I./include -I/home/sylvain/.local/share/giteapc/Lephenixnoir/sh-elf-gcc/lib/gcc/sh3eb-elf/11.1.0/include/openlibm/
CFLAGS = -O2 $(INCLUDE) -lm -m4-nofpu -mb -ffreestanding -nostdlib -lcPNG -lczlib -lSDL_prizm -Wa,--dsp -DLOAD_GIF -DLOAD_LBM -DLOAD_PCX -DLOAD_PNM -DLOAD_TGA -DLOAD_XCF -DLOAD_BMP -DLOAD_PNG
CFLAGS = -O2 $(INCLUDE) -lm -m4-nofpu -mb -ffreestanding -nostdlib -lcJPG -lcPNG -lczlib -lSDL_prizm -Wa,--dsp -DLOAD_GIF -LOAD_JPG -DLOAD_LBM -DLOAD_PCX -DLOAD_PNM -DLOAD_TGA -DLOAD_XCF -DLOAD_BMP -DLOAD_PNG
AR = sh-elf-gcc-ar
RANLIB = sh-elf-gcc-ranlib
CC = sh-elf-gcc
CONFIG_H =
CONFIG_H =
TARGET = libSDL_image_prizm.a
SOURCES = \
IMG.c \

28
README.md Normal file
View File

@ -0,0 +1,28 @@
# libSDL_image 1.2.12 repository for CASIO fx-CG 10/20 (a.k.a. PRIZM) and fx-CG 50 (or Graph 90+E)
Need to have a fully working gcc toolchain for SH3/SH4 architecture, such as fxSDK
**Note:** libSDL_image is configured to support PNG, so you need to have :
- a working libPNG, see here : [libPNG for PRIZM](https://gitea.planet-casio.com/Slyvtt/cPNG1_5_30),
- and also requires Zlib available, so the very first step is to get these libraries available and working prior to libPNG. You can get a working Zlib for CASIO fx-CG 10/20 (a.k.a. PRIZM) and fx-CG 50 (or Graph 90+E) here : [libZlib for PRIZM](https://gitea.planet-casio.com/Slyvtt/cZlib1_2_5).
- and a working copy of SDL 1.2 that you can get here : [libSDL for PRIZM](https://gitea.planet-casio.com/Slyvtt/cSDL1_2_15)
## Automatic installation using giteapc
You can also use the `gitea install Slyvtt/cSDL_image1_2_12` command to get an automatic install
when you compile a program for use with libSDL_image, do not forget to add a `-lSDL_image_prizm -lcPNG -lczlib -lSDL_prizm` option in your compilator command line.
and then a `#include <SDL/SDL_image.h>` in your C/C++ sources
## Manual compilation using a Makefile
Compilation is done by using the adhoc Makefile :
`make -f Makefile.prizm` in the main directory
It should produce the library libSDL_image_prizm.a and copy everything in the right place.
The following steps are not automatically done, so please proceed with the following manipulations :
* copy the library `libSDL_image_prizm.a` into your SH3/SH4 compiler lib folder
* copy `SDL_image.h` file contained in the SDL/ folder into the include/SDL folder of the SH3/SH4 compiler

View File

@ -2,34 +2,14 @@
<CodeBlocks_layout_file>
<FileVersion major="1" minor="0" />
<ActiveTarget name="Release" />
<File name="IMG_tga.c" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1174" topLine="0" />
</Cursor>
</File>
<File name="IMG_xxx.c" open="0" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1091" topLine="0" />
</Cursor>
</File>
<File name="SDL/SDL_image.h" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="5336" topLine="97" />
</Cursor>
</File>
<File name="IMG_pnm.c" open="0" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1229" topLine="2" />
</Cursor>
</File>
<File name="IMG_jpg.c" open="0" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1144" topLine="0" />
</Cursor>
</File>
<File name="IMG_png.c" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="18079" topLine="271" />
<Cursor1 position="10146" topLine="66" />
</Cursor>
<Folding>
<Collapse line="76" />
@ -39,42 +19,37 @@
<Collapse line="291" />
<Collapse line="303" />
<Collapse line="326" />
<Collapse line="333" />
<Collapse line="587" />
</Folding>
</File>
<File name="IMG_bmp.c" open="1" top="1" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="IMG_bmp.c" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="6205" topLine="97" />
<Cursor1 position="2507" topLine="101" />
</Cursor>
<Folding>
<Collapse line="35" />
<Collapse line="54" />
<Collapse line="84" />
<Collapse line="89" />
<Collapse line="107" />
<Collapse line="527" />
<Collapse line="536" />
<Collapse line="817" />
<Collapse line="831" />
<Collapse line="836" />
<Collapse line="847" />
<Collapse line="853" />
<Collapse line="859" />
<Collapse line="112" />
<Collapse line="532" />
<Collapse line="541" />
<Collapse line="834" />
<Collapse line="839" />
<Collapse line="850" />
<Collapse line="856" />
<Collapse line="862" />
</Folding>
</File>
<File name="IMG_tif.c" open="0" top="0" tabpos="15" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="IMG_webp.c" open="0" top="0" tabpos="12" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="728" topLine="0" />
<Cursor1 position="1078" topLine="0" />
</Cursor>
</File>
<File name="IMG_xpm.c" open="0" top="0" tabpos="13" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="IMG_tga.c" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1760" topLine="27" />
</Cursor>
</File>
<File name="IMG_gif.c" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1143" topLine="25" />
<Cursor1 position="1174" topLine="0" />
</Cursor>
</File>
<File name="IMG_lbm.c" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
@ -82,19 +57,14 @@
<Cursor1 position="1677" topLine="9" />
</Cursor>
</File>
<File name="IMG.c" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="IMG_xxx.c" open="0" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="5425" topLine="116" />
<Cursor1 position="1091" topLine="0" />
</Cursor>
<Folding>
<Collapse line="50" />
<Collapse line="79" />
<Collapse line="145" />
</Folding>
</File>
<File name="IMG_xcf.c" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="IMG_gif.c" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1105" topLine="0" />
<Cursor1 position="1143" topLine="25" />
</Cursor>
</File>
<File name="IMG_xv.c" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
@ -102,14 +72,71 @@
<Cursor1 position="1086" topLine="0" />
</Cursor>
</File>
<File name="IMG_tif.c" open="0" top="0" tabpos="15" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="728" topLine="0" />
</Cursor>
</File>
<File name="IMG.c" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1748" topLine="36" />
</Cursor>
<Folding>
<Collapse line="85" />
<Collapse line="144" />
</Folding>
</File>
<File name="IMG_pcx.c" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1468" topLine="24" />
</Cursor>
</File>
<File name="IMG_webp.c" open="0" top="0" tabpos="12" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="IMG_xpm.c" open="0" top="0" tabpos="13" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1078" topLine="0" />
<Cursor1 position="1760" topLine="27" />
</Cursor>
</File>
<File name="IMG_jpg.c" open="1" top="1" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="13830" topLine="105" />
</Cursor>
<Folding>
<Collapse line="61" />
<Collapse line="136" />
<Collapse line="147" />
<Collapse line="164" />
<Collapse line="176" />
<Collapse line="240" />
<Collapse line="252" />
<Collapse line="257" />
<Collapse line="261" />
<Collapse line="279" />
<Collapse line="291" />
<Collapse line="316" />
<Collapse line="321" />
<Collapse line="327" />
<Collapse line="355" />
<Collapse line="361" />
<Collapse line="367" />
<Collapse line="469" />
<Collapse line="475" />
<Collapse line="480" />
<Collapse line="486" />
</Folding>
</File>
<File name="Makefile.prizm" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="259" topLine="0" />
</Cursor>
</File>
<File name="IMG_pnm.c" open="0" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1229" topLine="2" />
</Cursor>
</File>
<File name="IMG_xcf.c" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1105" topLine="0" />
</Cursor>
</File>
</CodeBlocks_layout_file>

View File

@ -0,0 +1,49 @@
find_package(Gint 2.7 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=libSDL_image_prizm.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 "libSDL_image_prizm.a")
# Find the version.h header
execute_process(
COMMAND ${CMAKE_C_COMPILER} -print-file-name=include/zconf.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(libczlib
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(LibSDL_image_prizm_FOUND)
# This is an imported target, we don't build it, we just claim it's here
add_library(libSDL_image_prizm::libSDL_image_prizm UNKNOWN IMPORTED)
# Here we declare the compiler and linker flags that every user of LibExample
# needs to use.
set_target_properties(libSDL_image_prizm::libSDL_image_prizm 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 -lSDL_image_prizm
# Dependencies (for order on the command-line)
IMPORTED_LINK_INTERFACE_LIBRARIES Gint::Gint)
endif()

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
@ fxsdk build-cg -c
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