Merge pull request 'Build system update' (#1) from Lephenixnoir/cZlib1_2_5:master into master
Reviewed-on: https://gitea.planet-casio.com/Slyvtt/cZlib1_2_5/pulls/1
This commit is contained in:
commit
0890fbeb8e
|
@ -0,0 +1,2 @@
|
|||
/build-fx
|
||||
/build-cg
|
|
@ -1,43 +0,0 @@
|
|||
# Makefile to build the SDL library
|
||||
|
||||
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 -Wa,--dsp
|
||||
AR = sh-elf-gcc-ar
|
||||
RANLIB = sh-elf-gcc-ranlib
|
||||
CC = sh-elf-gcc
|
||||
|
||||
CONFIG_H =
|
||||
TARGET = libczlib.a
|
||||
SOURCES = \
|
||||
adler32.c \
|
||||
compress.c \
|
||||
crc32.c \
|
||||
deflate.c \
|
||||
gzclose.c \
|
||||
gzlib.c \
|
||||
gzread.c \
|
||||
gzwrite.c \
|
||||
infback.c \
|
||||
inffast.c \
|
||||
inflate.c \
|
||||
inftrees.c \
|
||||
trees.c \
|
||||
uncompr.c \
|
||||
zutil.c
|
||||
|
||||
|
||||
OBJECTS = $(SOURCES:.c=.o)
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
$(TARGET): $(OBJECTS)
|
||||
#cp $(CONFIG_H).default $(CONFIG_H)
|
||||
$(AR) cr $@ $^
|
||||
$(RANLIB) $@
|
||||
#$(STRIP) --strip-unneeded $@
|
||||
|
||||
.c.o:
|
||||
$(CC) $(INCLUDE) $(CFLAGS) -c $< -o $@
|
||||
|
||||
clean:
|
||||
rm -f $(OBJECTS) $(TARGET)
|
23
README.md
23
README.md
|
@ -2,18 +2,23 @@
|
|||
|
||||
Need to have a fully working gcc toolchain for SH3/SH4 architecture.
|
||||
|
||||
Compilation is done by using the adhoc Makefile :
|
||||
`make -f Makefile.prizm` in the main directory
|
||||
Compilation is done for all targets with a single:
|
||||
|
||||
It should produce the library libczlib.a
|
||||
```bash
|
||||
% fxsdk build-fx install
|
||||
```
|
||||
|
||||
The following steps are not automatically done, so please proceed with the following manipulations :
|
||||
* copy the library `libczlib.a` into your SH3/SH4 compiler lib folder
|
||||
* copy `zlib.h` and `zconf.h` files contained in the include folder into the include folder of the SH3/SH4 compiler
|
||||
You can also use the `giteapc install Slyvtt/cZlib1_2_5` command to get an automatic install.
|
||||
|
||||
You can also use the `gitea install Slyvtt/cZlib1_2_5` command to get an automatic install
|
||||
## Using in a program
|
||||
|
||||
when you compile a program for use with Zlib, do not forget to add a `-lczlib` option in your compilator command line.
|
||||
With CMake:
|
||||
|
||||
and then a `#include <zlib.h>` in your C/C++ sources
|
||||
```cmake
|
||||
find_package(czlib 1.2.5 REQUIRED)
|
||||
target_link_libraries(<TARGET> PRIVATE czlib::czlib)
|
||||
```
|
||||
|
||||
With make, link with `-lczlib`.
|
||||
|
||||
In the C/C++ source, `#include <zlib.h>`.
|
||||
|
|
|
@ -1,49 +1,17 @@
|
|||
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=libczlib.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 "libczlib.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(FindSimpleLibrary)
|
||||
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(Libczlib_FOUND)
|
||||
# This is an imported target, we don't build it, we just claim it's here
|
||||
add_library(libczlib::libczlib UNKNOWN IMPORTED)
|
||||
# Here we declare the compiler and linker flags that every user of LibExample
|
||||
# needs to use.
|
||||
set_target_properties(libczlib::libczlib 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 -lczlib
|
||||
# Dependencies (for order on the command-line)
|
||||
IMPORTED_LINK_INTERFACE_LIBRARIES Gint::Gint)
|
||||
|
||||
find_simple_library(libczlib.a zlib.h "ZLIB_VERSION"
|
||||
PATH_VAR CZLIB_PATH
|
||||
VERSION_VAR CZLIB_VERSION)
|
||||
|
||||
find_package_handle_standard_args(czlib
|
||||
REQUIRED_VARS CZLIB_PATH CZLIB_VERSION
|
||||
VERSION_VAR CZLIB_VERSION)
|
||||
|
||||
if(czlib_FOUND)
|
||||
add_library(czlib::czlib UNKNOWN IMPORTED)
|
||||
set_target_properties(czlib::czlib PROPERTIES
|
||||
IMPORTED_LOCATION "${CZLIB_PATH}"
|
||||
INTERFACE_LINK_OPTIONS -lczlib)
|
||||
endif()
|
||||
|
|
|
@ -4,23 +4,17 @@
|
|||
|
||||
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
|
||||
|
||||
|
|
Loading…
Reference in New Issue