star-geometry-3d

Clean and decorate 3D geometries
git clone git://git.meso-star.fr/star-geometry-3d.git
Log | Files | Refs | README | LICENSE

commit 9b99310b4b28eea45831a5786febc42ff3e3ab68
parent 2116fb472bdd78361bfbf51ed4e3004cd55ab044
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Thu, 14 Dec 2023 16:29:31 +0100

Replace CMake by POSIX make

The build procedure is written in POSIX make, which the user can
configure via the config.mk file. The make.sh script contains commands
that could be found directly in POSIX make, but which are placed here to
simplify writing the Makefile. Finally, a pkg-config file is provided to
link the library as an external dependency.

In addition to the features previously provided by its CMake
alternative, this Makefile supports the use of static libraries and
provides an uninstall target. It also enable compiler and linker options
that activate various hardening features aimed at increasing the
security and robustness of generated binaries. In any case, the main
motivation behind its writing is to use a good old well-established
standard with simple features, available on all UNIX systems, thus
simplifying its portability and support while being much lighter

Diffstat:
M.gitignore | 14+++++++-------
AMakefile | 227+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dcmake/CMakeLists.txt | 208-------------------------------------------------------------------------------
Aconfig.mk | 82+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amake.sh | 70++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asg3d.pc.in | 11+++++++++++
6 files changed, 397 insertions(+), 215 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -1,12 +1,12 @@ -compile_commands.json .gitignore -CMakeCache.txt -CMakeFiles -Makefile -tmp [Bb]uild* *.sw[po] -*.[ao] +*.[aod] +*.so *~ +test* +!test*.[ch] +.config +.test tags - +*.pc diff --git a/Makefile b/Makefile @@ -0,0 +1,227 @@ +# Copyright (C) 2019, 2020, 2023 |Méso|Star> (contact@meso-star.com) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +.POSIX: +.SUFFIXES: # Clean up default inference rules + +include config.mk + +LIBNAME_STATIC = libsg3d.a +LIBNAME_SHARED = libsg3d.so +LIBNAME = $(LIBNAME_$(LIB_TYPE)) + +################################################################################ +# Library building +################################################################################ +SRC =\ + src/sg3d_device.c\ + src/sg3d_geometry.c +OBJ = $(SRC:.c=.o) +DEP = $(SRC:.c=.d) + +build_library: .config $(DEP) + @$(MAKE) -fMakefile $$(for i in $(DEP); do echo -f $${i}; done) \ + $$(if [ -n "$(LIBNAME)" ]; then \ + echo "$(LIBNAME)"; \ + else \ + echo "$(LIBNAME_SHARED)"; \ + fi) + +$(DEP) $(OBJ): config.mk + +$(LIBNAME_SHARED): $(OBJ) + $(CC) $(CFLAGS_SO) $(RSYS_CFLAGS) -o $@ $(OBJ) $(LDFLAGS_SO) $(RSYS_LIBS) + +$(LIBNAME_STATIC): libsg3d.o + $(AR) -rc $@ $? + $(RANLIB) $@ + +libsg3d.o: $(OBJ) + $(LD) -r $(OBJ) -o $@ + $(OBJCOPY) $(OCPFLAGS) $@ + +.config: config.mk + @if ! $(PKG_CONFIG) --atleast-version $(RSYS_VERSION) rsys; then \ + echo "rsys $(RSYS_VERSION) not found" >&2; exit 1; fi + @echo "config done" > $@ + +.SUFFIXES: .c .d .o +.c.d: + @$(CC) $(CFLAGS_SO) $(RSYS_CFLAGS) -MM -MT "$(@:.d=.o) $@" $< -MF $@ + +.c.o: + $(CC) $(CFLAGS_SO) $(RSYS_CFLAGS) -DSG3D_SHARED_BUILD -c $< -o $@ + +################################################################################ +# Installation +################################################################################ +pkg: + sed -e 's#@PREFIX@#$(PREFIX)#g'\ + -e 's#@VERSION@#$(VERSION)#g'\ + -e 's#@RSYS_VERSION@#$(RSYS_VERSION)#g'\ + sg3d.pc.in > sg3d.pc + +sg3d-local.pc: sg3d.pc.in + sed -e '1d'\ + -e 's#^includedir=.*#includedir=./src/#'\ + -e 's#^libdir=.*#libdir=./#'\ + -e 's#@VERSION@#$(VERSION)#g'\ + -e 's#@RSYS_VERSION@#$(RSYS_VERSION)#g'\ + sg3d.pc.in > $@ + +install: build_library pkg + @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/lib" $(LIBNAME) + @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/lib/pkgconfig" sg3d.pc + @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/include/star" src/sg3d.h + @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/include/star" src/sg3d_sXd_helper.h + @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/include/star" src/sg3d_sencXd_helper.h + @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/include/star" src/sg3d_sdisXd_helper.h + @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/include/star" src/sgX3d.h + @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/include/star" src/sgX3d_undefs.h + @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/share/doc/star-geometry-3d" \ + COPYING README.md + +uninstall: + rm -f "$(DESTDIR)$(PREFIX)/lib/$(LIBNAME)" + rm -f "$(DESTDIR)$(PREFIX)/lib/pkgconfig/sg3d.pc" + rm -f "$(DESTDIR)$(PREFIX)/share/doc/star-geometry-3d/COPYING" + rm -f "$(DESTDIR)$(PREFIX)/share/doc/star-geometry-3d/README.md" + rm -f "$(DESTDIR)$(PREFIX)/include/star/sg3d.h" + rm -f "$(DESTDIR)$(PREFIX)/include/star/sg3d_sXd_helper.h" + rm -f "$(DESTDIR)$(PREFIX)/include/star/sg3d_sencXd_helper.h" + rm -f "$(DESTDIR)$(PREFIX)/include/star/sg3d_sdisXd_helper.h" + rm -f "$(DESTDIR)$(PREFIX)/include/star/sgX3d.h" + rm -f "$(DESTDIR)$(PREFIX)/include/star/sgX3d_undefs.h" + +################################################################################ +# Miscellaneous targets +################################################################################ +all: build_library build_tests + +clean: clean_test + rm -f $(OBJ) $(TEST_OBJ) $(TEST_OBJ_S3DUT) $(LIBNAME) + rm -f .config .config_test .test libsg3d.o sg3d.pc sg3d-local.pc + +distclean: clean + rm -f $(DEP) $(TEST_DEP) $(TEST_DEP_S3DUT) + +lint: + shellcheck -o all make.sh + +################################################################################ +# Tests +################################################################################ +TEST_SRC =\ + src/test_sg3d_cube_behind_cube.c\ + src/test_sg3d_cube_in_cube.c\ + src/test_sg3d_cube_on_cube.c\ + src/test_sg3d_device.c\ + src/test_sg3d_geometry_2.c\ + src/test_sg3d_geometry.c\ + src/test_sg3d_invalid_models.c\ + src/test_sg3d_multi_media.c\ + src/test_sg3d_unspecified_properties.c +TEST_OBJ = $(TEST_SRC:.c=.o) +TEST_DEP = $(TEST_SRC:.c=.d) + +PKG_CONFIG_LOCAL = PKG_CONFIG_PATH="./:$${PKG_CONFIG_PATH}" $(PKG_CONFIG) +SG3D_CFLAGS = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --cflags sg3d-local.pc) +SG3D_LIBS = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --libs sg3d-local.pc) + +# Regular Compiler and linker flags +TEST_CFLAGS = $(CFLAGS_EXE) $(SG3D_CFLAGS) $(RSYS_CFLAGS) +TEST_LIBS = $(LDFLAGS_EXE) $(SG3D_LIBS) $(RSYS_LIBS) + +build_tests: .config_test build_library $(TEST_DEP) .test + @$(MAKE) -fMakefile -f.test \ + $$(for i in $(TEST_DEP); do echo -f"$${i}"; done) \ + test_bin + +.config_test: config.mk + @if ! $(PKG_CONFIG) --atleast-version $(S3DUT_VERSION) s3dut; then \ + echo "s3dut $(S3DUT_VERSION) not found" >&2; exit 1; fi + @echo "config done" > $@ + +test: build_tests + @$(SHELL) make.sh run_test $(TEST_SRC) + +.test: Makefile + @$(SHELL) make.sh config_test $(TEST_SRC) > $@ + +clean_test: + @$(SHELL) make.sh clean_test $(TEST_SRC) + +################################################################################ +# Regular tests +################################################################################ +src/test_sg3d_cube_behind_cube.d \ +src/test_sg3d_cube_in_cube.d \ +src/test_sg3d_cube_on_cube.d \ +src/test_sg3d_device.d \ +src/test_sg3d_geometry_2.d \ +src/test_sg3d_geometry.d \ +src/test_sg3d_invalid_models.d \ +src/test_sg3d_multi_media.d \ +src/test_sg3d_unspecified_properties.d \ +: config.mk sg3d-local.pc + @$(CC) $(TEST_CFLAGS) -MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@ + +src/test_sg3d_cube_behind_cube.o \ +src/test_sg3d_cube_in_cube.o \ +src/test_sg3d_cube_on_cube.o \ +src/test_sg3d_device.o \ +src/test_sg3d_geometry_2.o \ +src/test_sg3d_geometry.o \ +src/test_sg3d_invalid_models.o \ +src/test_sg3d_multi_media.o \ +src/test_sg3d_unspecified_properties.o \ +: config.mk sg3d-local.pc + $(CC) $(TEST_CFLAGS) -c $(@:.o=.c) -o $@ + +test_sg3d_cube_behind_cube \ +test_sg3d_cube_in_cube \ +test_sg3d_cube_on_cube \ +test_sg3d_device \ +test_sg3d_geometry_2 \ +test_sg3d_geometry \ +test_sg3d_invalid_models \ +test_sg3d_multi_media \ +test_sg3d_unspecified_properties \ +: config.mk sg3d-local.pc $(LIBNAME) + $(CC) $(TEST_CFLAGS) -o $@ src/$@.o $(TEST_LIBS) + +################################################################################ +# Test based on Star-3DUT +################################################################################ +src/test_sg3d_many_enclosures.d \ +src/test_sg3d_many_triangles.d \ +src/test_sg3d_some_enclosures.d \ +src/test_sg3d_some_triangles.d \ +: config.mk sg3d-local.pc + @$(CC) $(TEST_CFLAGS) $(S3DUT_CFLAGS) -MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@ + +src/test_sg3d_many_enclosures.o \ +src/test_sg3d_many_triangles.o \ +src/test_sg3d_some_enclosures.o \ +src/test_sg3d_some_triangles.o \ +: config.mk sg3d-local.pc + $(CC) $(TEST_CFLAGS) $(S3DUT_CFLAGS) -c $(@:.o=.c) -o $@ + +test_sg3d_many_enclosures \ +test_sg3d_many_triangles \ +test_sg3d_some_enclosures \ +test_sg3d_some_triangles \ +: config.mk sg3d-local.pc $(LIBNAME) + $(CC) $(TEST_CFLAGS) $(S3DUT_CFLAGS) -o $@ src/$@.o $(TEST_LIBS) $(S3DUT_LIBS) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt @@ -1,208 +0,0 @@ -# Copyright (C) 2019, 2020, 2023 |Méso|Star> (contact@meso-star.com) -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - -cmake_minimum_required(VERSION 3.1) -project(star-geometry-3d C) -enable_testing() - -include(CMakeDependentOption) - -set(STAR_GEOM_SOURCE_DIR ${PROJECT_SOURCE_DIR}/../src) -option(NO_TEST - "Do not build tests" - OFF) - -cmake_dependent_option(SMALL_ADDITIONAL_TESTS - "Build small additional tests originally written for star-enclosures" OFF - "NOT NO_TEST" OFF) - -cmake_dependent_option(HUGE_ADDITIONAL_TESTS - "Build additional tests originally written for star-enclosures that involve \ -millions of triangles" OFF - "NOT NO_TEST" OFF) - -################################################################################ -# Check dependencies -################################################################################ -find_package(RCMake 0.4 REQUIRED) -find_package(RSys 0.8.1 REQUIRED) - -if(NOT NO_TEST) - find_package(Star3DUT 0.3.1 REQUIRED) -endif() - -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${RCMAKE_SOURCE_DIR}) -include(rcmake) -include(rcmake_runtime) - -include_directories( - ${RSys_INCLUDE_DIR} - ${StarEnc_INCLUDE_DIR}) - -if(NOT NO_TEST) - rcmake_append_runtime_dirs(_runtime_dirs RSys StarEnc Star3DUT) -else() - rcmake_append_runtime_dirs(_runtime_dirs RSys StarEnc) -endif() - -################################################################################ -# Configure and define targets -################################################################################ -set(VERSION_MAJOR 0) -set(VERSION_MINOR 1) -set(VERSION_PATCH 2) -set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) - -set(SG3D_FILES_SRC - sg3d_device.c - sg3d_geometry.c -) - -set(SG3D_FILES_INC_API - sg3d.h - sg3d_sXd_helper.h - sg3d_sencXd_helper.h - sg3d_sdisXd_helper.h - sgX3d.h - sgX3d_undefs.h -) - -set(SG3D_FILES_INC - sg3d_device.h - sg3d_geometry.h - sg3d_misc.h -) - -set(SG3D_FILES_DOC COPYING README.md) - -# Prepend each file by `STAR_GEOM_SOURCE_DIR' -rcmake_prepend_path(SG3D_FILES_SRC ${STAR_GEOM_SOURCE_DIR}) -rcmake_prepend_path(SG3D_FILES_INC ${STAR_GEOM_SOURCE_DIR}) -rcmake_prepend_path(SG3D_FILES_INC_API ${STAR_GEOM_SOURCE_DIR}) -rcmake_prepend_path(SG3D_FILES_DOC ${PROJECT_SOURCE_DIR}/../) - -if(CMAKE_COMPILER_IS_GNUCC) - set(MATH_LIB m) -endif() - -if(MSVC) - -endif() - -add_library(sg3d SHARED - ${SG3D_FILES_SRC} - ${SG3D_FILES_INC} - ${SG3D_FILES_INC_API}) -target_link_libraries(sg3d RSys ${MATH_LIB}) - -set_target_properties(sg3d PROPERTIES -# C99 needed in case of printf "PRTF_API" used -# C_STANDARD 99 - DEFINE_SYMBOL SG3D_SHARED_BUILD - VERSION ${VERSION} - SOVERSION ${VERSION_MAJOR}) -rcmake_copy_runtime_libraries(sg3d) - -rcmake_setup_devel(sg3d StarGeom3D ${VERSION} star/sg3d_version.h) - -################################################################################ -# Add tests -################################################################################ -if(NOT NO_TEST) - function(build_test _name) - add_executable(${_name} - ${STAR_GEOM_SOURCE_DIR}/${_name}.c - ${STAR_GEOM_SOURCE_DIR}/test_sg3d_utils.h) - foreach(other ${ARGN}) - target_sources(${_name} - PUBLIC ${STAR_GEOM_SOURCE_DIR}/${other}) - endforeach() - target_link_libraries(${_name} RSys sg3d) - endfunction() - - function(register_test _name) - add_test(${_name} ${ARGN}) - rcmake_set_test_runtime_dirs(${_name} _runtime_dirs) - endfunction() - - function(new_test _name) - build_test(${_name} ${ARGN}) - register_test(${_name} ${_name}) - endfunction() - - new_test(test_sg3d_device) - new_test(test_sg3d_geometry) - new_test(test_sg3d_geometry_2) - - build_test(test_sg3d_cube_behind_cube) - build_test(test_sg3d_cube_in_cube) - build_test(test_sg3d_cube_on_cube) - build_test(test_sg3d_invalid_models) - build_test(test_sg3d_multi_media) - build_test(test_sg3d_some_enclosures test_sg3d_utils2.h) - build_test(test_sg3d_some_triangles test_sg3d_utils2.h) - build_test(test_sg3d_unspecified_properties) - - build_test(test_sg3d_many_enclosures test_sg3d_utils2.h) - build_test(test_sg3d_many_triangles test_sg3d_utils2.h) - - target_link_libraries(test_sg3d_some_enclosures Star3DUT) - target_link_libraries(test_sg3d_some_triangles Star3DUT) - target_link_libraries(test_sg3d_many_enclosures Star3DUT) - target_link_libraries(test_sg3d_many_triangles Star3DUT) - - rcmake_copy_runtime_libraries(test_sg3d_device) - rcmake_copy_runtime_libraries(test_sg3d_geometry) - rcmake_copy_runtime_libraries(test_sg3d_geometry_2) - - rcmake_copy_runtime_libraries(test_sg3d_cube_behind_cube) - rcmake_copy_runtime_libraries(test_sg3d_cube_in_cube) - rcmake_copy_runtime_libraries(test_sg3d_cube_on_cube) - rcmake_copy_runtime_libraries(test_sg3d_invalid_models) - rcmake_copy_runtime_libraries(test_sg3d_multi_media) - rcmake_copy_runtime_libraries(test_sg3d_some_enclosures) - rcmake_copy_runtime_libraries(test_sg3d_some_triangles) - rcmake_copy_runtime_libraries(test_sg3d_unspecified_properties) - - rcmake_copy_runtime_libraries(test_sg3d_many_enclosures) - rcmake_copy_runtime_libraries(test_sg3d_many_triangles) - - if(SMALL_ADDITIONAL_TESTS) - add_test(test_sg3d_cube_behind_cube test_sg3d_cube_behind_cube) - add_test(test_sg3d_cube_in_cube test_sg3d_cube_in_cube) - add_test(test_sg3d_cube_on_cube test_sg3d_cube_on_cube) - add_test(test_sg3d_invalid_models test_sg3d_invalid_models) - add_test(test_sg3d_multi_media test_sg3d_multi_media) - add_test(test_sg3d_some_enclosures test_sg3d_some_enclosures) - add_test(test_sg3d_some_triangles test_sg3d_some_triangles) - add_test(test_sg3d_unspecified_properties test_sg3d_unspecified_properties) - endif() - - if(HUGE_ADDITIONAL_TESTS) - add_test(test_sg3d_many_enclosures test_sg3d_many_enclosures) - add_test(test_sg3d_many_triangles test_sg3d_many_triangles) - endif() - -endif() - -################################################################################ -# Define output & install directories -################################################################################ -install(TARGETS sg3d - ARCHIVE DESTINATION bin - LIBRARY DESTINATION lib - RUNTIME DESTINATION bin) -install(FILES ${SG3D_FILES_INC_API} DESTINATION include/star) -install(FILES ${SG3D_FILES_DOC} DESTINATION share/doc/star-geometry-3d) diff --git a/config.mk b/config.mk @@ -0,0 +1,82 @@ +VERSION = 0.1.2 +PREFIX = /usr/local + +LIB_TYPE = SHARED +#LIB_TYPE = STATIC + +BUILD_TYPE = RELEASE +#BUILD_TYPE = DEBUG + +################################################################################ +# Tools +################################################################################ +AR = ar +CC = cc +LD = ld +OBJCOPY = objcopy +PKG_CONFIG = pkg-config +RANLIB = ranlib + +################################################################################ +# Dependencies +################################################################################ +PCFLAGS_SHARED = +PCFLAGS_STATIC = --static +PCFLAGS = $(PCFLAGS_$(LIB_TYPE)) + +RSYS_VERSION = 0.14 +RSYS_CFLAGS = $$($(PKG_CONFIG) $(PCFLAGS) --cflags rsys) +RSYS_LIBS = $$($(PKG_CONFIG) $(PCFLAGS) --libs rsys) + +# Optional dependency +S3DUT_VERSION = 0.4 +S3DUT_CFLAGS = $$($(PKG_CONFIG) $(PCFLAGS) --cflags s3dut) +S3DUT_LIBS = $$($(PKG_CONFIG) $(PCFLAGS) --libs s3dut) + +################################################################################ +# Compilation options +################################################################################ +WFLAGS =\ + -Wall\ + -Wcast-align\ + -Wconversion\ + -Wextra\ + -Wmissing-declarations\ + -Wmissing-prototypes\ + -Wshadow + +CFLAGS_HARDENED =\ + -D_FORTIFY_SOURCES=2\ + -fcf-protection=full\ + -fstack-clash-protection\ + -fstack-protector-strong + +CFLAGS_COMMON =\ + -std=c89\ + -pedantic\ + -fvisibility=hidden\ + -fstrict-aliasing\ + $(CFLAGS_HARDENED)\ + $(WFLAGS) + +CFLAGS_RELEASE = -O3 -DNDEBUG $(CFLAGS_COMMON) +CFLAGS_DEBUG = -g $(CFLAGS_COMMON) +CFLAGS = $(CFLAGS_$(BUILD_TYPE)) + +CFLAGS_SO = $(CFLAGS) -fPIC +CFLAGS_EXE = $(CFLAGS) -fPIE + +################################################################################ +# Linker options +################################################################################ +LDFLAGS_HARDENED = -Wl,-z,relro,-z,now +LDFLAGS_DEBUG = $(LDFLAGS_HARDENED) +LDFLAGS_RELEASE = -s $(LDFLAGS_HARDENED) +LDFLAGS = $(LDFLAGS_$(BUILD_TYPE)) + +LDFLAGS_SO = $(LDFLAGS) -shared -Wl,--no-undefined +LDFLAGS_EXE = $(LDFLAGS) -pie + +OCPFLAGS_DEBUG = --localize-hidden +OCPFLAGS_RELEASE = --localize-hidden --strip-unneeded +OCPFLAGS = $(OCPFLAGS_$(BUILD_TYPE)) diff --git a/make.sh b/make.sh @@ -0,0 +1,70 @@ +#!/bin/sh + +# Copyright (C) 2019, 2020, 2023 |Méso|Star> (contact@meso-star.com) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +set -e + +config_test() +{ + for i in "$@"; do + test=$(basename "${i}" ".c") + test_list="${test_list} ${test}" + printf "%s: %s\n" "${test}" "src/${test}.o" + done + printf "test_bin: %s\n" "${test_list}" +} + +run_test() +{ + for i in "$@"; do + test=$(basename "${i}" ".c") + + printf "%s " "${test}" + if "./${test}" > /dev/null 2>&1; then + printf "\033[1;32mOK\033[m\n" + else + printf "\033[1;31mError\033[m\n" + fi + done 2> /dev/null +} + +clean_test() +{ + for i in "$@"; do + rm -f "$(basename "${i}" ".c")" + done +} + +install() +{ + prefix=$1 + shift 1 + + mkdir -p "${prefix}" + + for i in "$@"; do + dst="${prefix}/${i##*/}" + + if cmp -s "${i}" "${dst}"; then + printf "Up to date %s\n" "${dst}" + else + printf "Installing %s\n" "${dst}" + cp "${i}" "${prefix}" + fi + done +} + +"$@" diff --git a/sg3d.pc.in b/sg3d.pc.in @@ -0,0 +1,11 @@ +prefix=@PREFIX@ +includedir=${prefix}/include +libdir=${prefix}/lib + +Requires: rsys >= @RSYS_VERSION@ +Name: sg3d +Description: Star Geometry 3D library +Version: @VERSION@ +Libs: -L${libdir} -lsg3d +Libs.private: -lm +CFlags: -I${includedir}