From 02774004a2bda0e6ddd6c468c0c66261a4de2da0 Mon Sep 17 00:00:00 2001 From: Lephenixnoir Date: Wed, 27 Jan 2021 14:35:54 +0100 Subject: [PATCH] switch build system to CMake --- .gitignore | 3 +-- CMakeLists.txt | 17 +++++++++++++++++ Makefile | 46 ---------------------------------------------- giteapc.make | 16 ++++++++++++---- 4 files changed, 30 insertions(+), 52 deletions(-) create mode 100644 CMakeLists.txt delete mode 100644 Makefile diff --git a/.gitignore b/.gitignore index 95c2d6f..e437e15 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ # Build files -build/ -libprof.a +build*/ # GiteaPC configuration files giteapc-config-*.make diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..77e3712 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,17 @@ +# Build system for the libprof library for gint + +cmake_minimum_required(VERSION 3.18) +project(libprof 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(NAME "prof-${FXSDK_PLATFORM}") +add_library("${NAME}" STATIC libprof.c) +target_link_libraries("${NAME}" Gint::Gint) + +install(TARGETS "${NAME}" DESTINATION "${FXSDK_COMPILER_INSTALL}") +install(FILES libprof.h DESTINATION "${FXSDK_COMPILER_INSTALL}/include") + diff --git a/Makefile b/Makefile deleted file mode 100644 index e806cb5..0000000 --- a/Makefile +++ /dev/null @@ -1,46 +0,0 @@ -#! /usr/bin/make -f -# libprof Makefile - -cflags := -m3 -mb -ffreestanding -nostdlib -fstrict-volatile-bitfields -Wall \ - -Wextra -Os -I . -target ?= sh-elf -lib := libprof.a -header := libprof.h - -PREFIX ?= $(shell $(target)-gcc -print-search-dirs | grep install \ - | sed 's/install: //') - -ifeq "$(PREFIX)" "" -$(error "Cannot determine compiler install path") -endif - -src := $(wildcard *.c) -obj := $(src:%=build/%.o) - -# Rules - -all: $(lib) - -$(lib): $(obj) - $(target)-ar rcs $@ $^ - -build/%.c.o: %.c | build/ - $(target)-gcc -c $< -o $@ $(cflags) - -# Misc rules - -clean: - @ rm -rf build -distclean: clean - @ rm -f $(lib) - -%/: - mkdir -p $@ - -.PRECIOUS: %/ - -# Install - -install: $(lib) - cp $(lib) $(DESTDIR)$(PREFIX) - cp $(header) $(DESTDIR)$(PREFIX)/include 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