From 9408bc53bc508c86d95026f92698b526102578a8 Mon Sep 17 00:00:00 2001 From: Lephenixnoir Date: Wed, 27 Jan 2021 16:04:19 +0100 Subject: [PATCH] switch build system to CMake --- CMakeLists.txt | 27 +++++++++++++++++++ Makefile | 72 -------------------------------------------------- giteapc.make | 16 ++++++++--- libimg.conf | 17 ------------ 4 files changed, 39 insertions(+), 93 deletions(-) create mode 100644 CMakeLists.txt delete mode 100644 Makefile delete mode 100644 libimg.conf diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..fcd3408 --- /dev/null +++ b/CMakeLists.txt @@ -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") diff --git a/Makefile b/Makefile deleted file mode 100644 index 53a4790..0000000 --- a/Makefile +++ /dev/null @@ -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 diff --git a/giteapc.make b/giteapc.make index 78d8663..4727cfa 100644 --- a/giteapc.make +++ b/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 diff --git a/libimg.conf b/libimg.conf deleted file mode 100644 index d0eeb52..0000000 --- a/libimg.conf +++ /dev/null @@ -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