switch build system to CMake

This commit is contained in:
Lephenixnoir 2021-01-27 14:35:54 +01:00
parent 05e6463139
commit 02774004a2
Signed by: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
4 changed files with 30 additions and 52 deletions

3
.gitignore vendored
View File

@ -1,6 +1,5 @@
# Build files
build/
libprof.a
build*/
# GiteaPC configuration files
giteapc-config-*.make

17
CMakeLists.txt Normal file
View File

@ -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")

View File

@ -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

View File

@ -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