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