switch build system to CMake
This commit is contained in:
parent
09555bd3aa
commit
9408bc53bc
|
@ -0,0 +1,27 @@
|
|||
# Build system for the libimg library for gint
|
||||
|
||||
cmake_minimum_required(VERSION 3.18)
|
||||
project(libimg VERSION 2.2.1 LANGUAGES C)
|
||||
|
||||
find_package(Gint 2.2.1 REQUIRED)
|
||||
|
||||
add_compile_options(-Wall -Wextra -std=c11 -Os)
|
||||
include_directories("${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
|
||||
set(SOURCES
|
||||
src/alloc.c
|
||||
src/brightness.c
|
||||
src/dye.c
|
||||
src/flip.c
|
||||
src/render.c
|
||||
src/rotate-ip.c
|
||||
src/rotate.c
|
||||
src/upscale.c
|
||||
)
|
||||
|
||||
set(NAME "img-${FXSDK_PLATFORM}")
|
||||
add_library("${NAME}" STATIC ${SOURCES})
|
||||
target_link_libraries("${NAME}" Gint::Gint)
|
||||
|
||||
install(TARGETS "${NAME}" DESTINATION "${FXSDK_COMPILER_INSTALL}")
|
||||
install(FILES libimg.h DESTINATION "${FXSDK_COMPILER_INSTALL}/include")
|
72
Makefile
72
Makefile
|
@ -1,72 +0,0 @@
|
|||
#! /usr/bin/make -f
|
||||
# libimg Makefile
|
||||
|
||||
cflags := -ffreestanding -nostdlib -I.
|
||||
header := libimg.h
|
||||
|
||||
# {target,cflags,lib}-{fx,cg} are provided by libimg.conf
|
||||
include libimg.conf
|
||||
|
||||
# Files
|
||||
src := $(wildcard src/*.c)
|
||||
obj-fx := $(src:src/%=build-fx/%.o)
|
||||
obj-cg := $(src:src/%=build-cg/%.o)
|
||||
|
||||
# Compiler paths
|
||||
define compilerpath
|
||||
ifneq "$(lib-$1)" ""
|
||||
PREFIX-$1 := $$(shell $(target-$1)-gcc -print-search-dirs | grep install | \
|
||||
sed 's/install: //')
|
||||
ifeq "$$(PREFIX-$1)" ""
|
||||
$$(error "Cannot determine $1 compiler install path")
|
||||
endif
|
||||
endif
|
||||
endef
|
||||
|
||||
$(eval $(call compilerpath,fx))
|
||||
$(eval $(call compilerpath,cg))
|
||||
|
||||
#
|
||||
# Rules
|
||||
#
|
||||
|
||||
all: $(lib-fx) $(lib-cg)
|
||||
|
||||
all-fx: $(lib-fx)
|
||||
|
||||
all-cg: $(lib-cg)
|
||||
|
||||
libimg-fx.a: $(obj-fx)
|
||||
$(target-fx)-ar rcs $@ $^
|
||||
libimg-cg.a: $(obj-cg)
|
||||
$(target-cg)-ar rcs $@ $^
|
||||
|
||||
build-fx/%.c.o: src/%.c | build-fx/
|
||||
$(target-fx)-gcc -c $< -o $@ $(cflags) $(cflags-fx) -DFX9860G
|
||||
build-cg/%.c.o: src/%.c | build-cg/
|
||||
$(target-cg)-gcc -c $< -o $@ $(cflags) $(cflags-cg) -DFXCG50
|
||||
|
||||
clean:
|
||||
@ rm -rf build-fx build-cg
|
||||
distclean: clean
|
||||
@ rm -f $(lib-fx) $(lib-cg)
|
||||
|
||||
%/:
|
||||
@ mkdir -p $@
|
||||
|
||||
#
|
||||
# Installing
|
||||
#
|
||||
|
||||
install:
|
||||
if [[ ! -z $(lib-fx) ]]; then \
|
||||
cp $(lib-fx) $(DESTDIR)$(PREFIX-fx); \
|
||||
cp $(header) $(DESTDIR)$(PREFIX-fx)/include; \
|
||||
fi
|
||||
if [[ ! -z $(lib-cg) ]]; then \
|
||||
cp $(lib-cg) $(DESTDIR)$(PREFIX-cg); \
|
||||
cp $(header) $(DESTDIR)$(PREFIX-cg)/include; \
|
||||
fi
|
||||
|
||||
.PRECIOUS: %/
|
||||
.PHONY: all all-fx all-cg clean distclean install
|
16
giteapc.make
16
giteapc.make
|
@ -3,15 +3,23 @@
|
|||
-include giteapc-config.make
|
||||
|
||||
configure:
|
||||
@ true
|
||||
@ fxsdk build-fx -c
|
||||
@ fxsdk build-cg -c
|
||||
|
||||
build:
|
||||
@ make
|
||||
@ fxsdk build-fx
|
||||
@ fxsdk build-cg
|
||||
|
||||
install:
|
||||
@ make install
|
||||
@ fxsdk build-fx install
|
||||
@ fxsdk build-cg install
|
||||
|
||||
uninstall:
|
||||
@ make 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
|
||||
|
|
17
libimg.conf
17
libimg.conf
|
@ -1,17 +0,0 @@
|
|||
# libimg configuration file
|
||||
# Edit this file to select your configuration options.
|
||||
|
||||
# Library file name. You should not change these names, but you can comment
|
||||
# these two lines to disable the corresponding target (f.i. if you don't have
|
||||
# an fx-9860G-compatible compiler).
|
||||
lib-fx = libimg-fx.a
|
||||
lib-cg = libimg-cg.a
|
||||
|
||||
# Default toolchain for each platform. Modern setups use sh-elf. If you have
|
||||
# either sh3eb-elf or sh4eb-elf, set them here.
|
||||
target-fx = sh-elf
|
||||
target-cg = sh-elf
|
||||
|
||||
# Additional compiler flags for each platform.
|
||||
cflags-fx = -Wall -Wextra -Os -m3 -mb
|
||||
cflags-cg = -Wall -Wextra -Os -m4-nofpu -mb
|
Loading…
Reference in New Issue