commit 133ed02422e744681e4e0cc7f42ee07202dd04bb parent 695aac9ac1d10ae816767c31223df6c24cbb1789 Author: Vincent Forest <vincent.forest@meso-star.com> Date: Fri, 19 Apr 2024 15:50:25 +0200 Merge branch 'release_0.6' Diffstat:
36 files changed, 470 insertions(+), 259 deletions(-)
diff --git a/.gitignore b/.gitignore @@ -0,0 +1,12 @@ +.gitignore +[Bb]uild* +*.sw[po] +*.[aod] +*.so +*~ +test* +!test*.[ch] +.config +.test +tags +*.pc diff --git a/Makefile b/Makefile @@ -0,0 +1,211 @@ +# Copyright (C) 2018-2021, 2023, 2024 |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 = libsenc2d.a +LIBNAME_SHARED = libsenc2d.so +LIBNAME = $(LIBNAME_$(LIB_TYPE)) + +################################################################################ +# Library building +################################################################################ +SRC =\ + src/senc2d_descriptor.c\ + src/senc2d_device.c\ + src/senc2d_enclosure.c\ + src/senc2d_scene.c\ + src/senc2d_scene_analyze.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) $(DPDC_CFLAGS) -o $@ $(OBJ) $(LDFLAGS_SO) $(DPDC_LIBS) + +$(LIBNAME_STATIC): libsenc2d.o + $(AR) -rc $@ $? + $(RANLIB) $@ + +libsenc2d.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 + @if ! $(PKG_CONFIG) --atleast-version $(S2D_VERSION) s2d; then \ + echo "s2d $(S2D_VERSION) not found" >&2; exit 1; fi + @echo "config done" > $@ + +.SUFFIXES: .c .d .o +.c.d: + @$(CC) $(CFLAGS_SO) $(DPDC_CFLAGS) -MM -MT "$(@:.d=.o) $@" $< -MF $@ + +.c.o: + $(CC) $(CFLAGS_SO) $(DPDC_CFLAGS) -DSENC2D_SHARED_BUILD -c $< -o $@ + +################################################################################ +# Installation +################################################################################ +pkg: + sed -e 's#@PREFIX@#$(PREFIX)#g'\ + -e 's#@VERSION@#$(VERSION)#g'\ + -e 's#@RSYS_VERSION@#$(RSYS_VERSION)#g'\ + -e 's#@S2D_VERSION@#$(S2D_VERSION)#g'\ + senc2d.pc.in > senc2d.pc + +senc2d-local.pc: senc2d.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'\ + -e 's#@S2D_VERSION@#$(S2D_VERSION)#g'\ + senc2d.pc.in > $@ + +install: build_library pkg + @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/lib" $(LIBNAME) + @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/lib/pkgconfig" senc2d.pc + @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/include/star" \ + src/senc2d.h src/senc2d_sXd_helper.h src/sencX2d.h src/sencX2d_undefs.h + @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/share/doc/star-enclosures-2d" \ + COPYING README.md + +uninstall: + rm -f "$(DESTDIR)$(PREFIX)/lib/$(LIBNAME)" + rm -f "$(DESTDIR)$(PREFIX)/lib/pkgconfig/senc2d.pc" + rm -f "$(DESTDIR)$(PREFIX)/share/doc/star-enclosures-2d/COPYING" + rm -f "$(DESTDIR)$(PREFIX)/share/doc/star-enclosures-2d/README.md" + rm -f "$(DESTDIR)$(PREFIX)/include/star/senc2d.h" + rm -f "$(DESTDIR)$(PREFIX)/include/star/senc2d_sXd_helper.h" + rm -f "$(DESTDIR)$(PREFIX)/include/star/sencX2d.h" + rm -f "$(DESTDIR)$(PREFIX)/include/star/sencX2d_undefs.h" + +################################################################################ +# Miscellaneous targets +################################################################################ +all: build_library build_tests + +clean: clean_test + rm -f $(OBJ) $(TEST_OBJ) $(TEST_OBJ_SSP) $(LIBNAME) + rm -f .config .test libsenc2d.o senc2d.pc senc2d-local.pc + +distclean: clean + rm -f $(DEP) $(TEST_DEP) $(TEST_DEP_SSP) + +lint: + shellcheck -o all make.sh + +################################################################################ +# Tests +################################################################################ +TEST_SRC =\ + src/test_senc2d_square_behind_square.c\ + src/test_senc2d_square_in_square.c\ + src/test_senc2d_square_on_square.c\ + src/test_senc2d_device.c\ + src/test_senc2d_enclosure.c\ + src/test_senc2d_inconsistant_square.c\ + src/test_senc2d_invalid_scenes.c\ + src/test_senc2d_many_enclosures.c\ + src/test_senc2d_many_segments.c\ + src/test_senc2d_multi_media.c\ + src/test_senc2d_scene.c\ + src/test_senc2d_some_enclosures.c\ + src/test_senc2d_some_segments.c\ + src/test_senc2d_unspecified_medium.c +TEST_OBJ = $(TEST_SRC:.c=.o) +TEST_DEP = $(TEST_SRC:.c=.d) + +# Tests that require Star-SP +TEST_SRC_SSP = src/test_senc2d_sample_enclosure.c +TEST_OBJ_SSP = $(TEST_SRC_SSP:.c=.o) +TEST_DEP_SSP = $(TEST_SRC_SSP:.c=.d) +SSP_FOUND = $(PKG_CONFIG) --atleast-version $(SSP_VERSION) star-sp + +PKG_CONFIG_LOCAL = PKG_CONFIG_PATH="./:$${PKG_CONFIG_PATH}" $(PKG_CONFIG) +SENC2D_CFLAGS = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --cflags senc2d-local.pc) +SENC2D_LIBS = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --libs senc2d-local.pc) + +build_tests: build_library $(TEST_DEP) .test + @if $(SSP_FOUND); then $(MAKE) $(TEST_DEP_SSP); fi; \ + $(MAKE) -fMakefile -f.test \ + $$(for i in $(TEST_DEP); do echo -f"$${i}"; done) \ + $$(if $(SSP_FOUND); then \ + for i in $(TEST_DEP_SSP); do echo -f"$${i}"; done; \ + fi) \ + test_bin + +test: build_tests + @$(SHELL) make.sh run_test $(TEST_SRC) + @if $(SSP_FOUND); then $(SHELL) make.sh run_test $(TEST_SRC_SSP); fi + +.test: Makefile + @{ $(SHELL) make.sh config_test $(TEST_SRC) ; \ + if $(SSP_FOUND); then $(SHELL) make.sh config_test $(TEST_SRC_SSP); fi } \ + > $@ + +clean_test: + @$(SHELL) make.sh clean_test $(TEST_SRC) $(TEST_SRC_SSP) + +$(TEST_DEP): config.mk senc2d-local.pc + @$(CC) $(CFLAGS_EXE) $(SENC2D_CFLAGS) $(RSYS_CFLAGS) \ + -MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@ + +$(TEST_DEP_SSP): config.mk senc2d-local.pc + @$(CC) $(CFLAGS_EXE) $(SENC2D_CFLAGS) $(RSYS_CFLAGS) $(SSP_CFLAGS) \ + -MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@ + +$(TEST_OBJ): config.mk senc2d-local.pc + $(CC) $(CFLAGS_EXE) $(SENC2D_CFLAGS) $(RSYS_CFLAGS) -c $(@:.o=.c) -o $@ + +$(TEST_OBJ_SSP): config.mk senc2d-local.pc + $(CC) $(CFLAGS_EXE) $(SENC2D_CFLAGS) $(RSYS_CFLAGS) $(SSP_CFLAGS) -c $(@:.o=.c) -o $@ + +test_senc2d_square_behind_square \ +test_senc2d_square_in_square \ +test_senc2d_square_on_square \ +test_senc2d_device \ +test_senc2d_inconsistant_square \ +test_senc2d_invalid_scenes \ +test_senc2d_multi_media \ +test_senc2d_scene \ +test_senc2d_some_enclosures \ +test_senc2d_some_segments \ +test_senc2d_unspecified_medium \ +: config.mk senc2d-local.pc $(LIBNAME) + $(CC) $(CFLAGS_EXE) -o $@ src/$@.o $(LDFLAGS_EXE) $(SENC2D_LIBS) $(RSYS_LIBS) + +test_senc2d_many_enclosures test_senc2d_many_segments: config.mk senc2d-local.pc $(LIBNAME) + $(CC) $(CFLAGS_EXE) -o $@ src/$@.o $(LDFLAGS_EXE) $(SENC2D_LIBS) $(RSYS_LIBS) -lm + +test_senc2d_enclosure: config.mk senc2d-local.pc $(LIBNAME) + $(CC) $(CFLAGS_EXE) -o $@ src/$@.o $(LDFLAGS_EXE) $(SENC2D_LIBS) $(RSYS_LIBS) $(S2D_LIBS) + +test_senc2d_sample_enclosure: config.mk senc2d-local.pc $(LIBNAME) + $(CC) $(CFLAGS_EXE) -o $@ src/$@.o $(LDFLAGS_EXE) $(SENC2D_LIBS) $(RSYS_LIBS) $(S2D_LIBS) $(SSP_LIBS) diff --git a/README.md b/README.md @@ -1,5 +1,4 @@ -Star-enclosures-2d -================== +# Star-enclosures-2d The purpose of Star-enclosures-2d is to extract enclosures from raw geometry. An enclosure is a set of segments enclosing a given area. The @@ -16,36 +15,42 @@ Also the convention regarding FRONT/BACK sides for input segments as well as the convention regarding normals' orientation for output segments can be set. -How to build ------------- +## Requirements -Star-enclosures-2d relies on the [CMake](http://www.cmake.org) and the -[RCMake](https://gitlab.com/vaplv/rcmake/) package to build. It also -depends on the [RSys](https://gitlab.com/vaplv/rsys/) and -[Star-2D](https://gitlab.com/meso-star/star-2d/) libraries. Additionaly, -one more library is needed to build tests -([Star-SP](https://gitlab.com/meso-star/star-sp/)). +- C compiler +- POSIX make +- pkg-config +- [RSys](https://gitlab.com/vaplv/rsys) +- [Star 2D](https://gitlab.com/meso-star/star-3d) +- [Star SamPling](https://gitlab.com/meso-star/star-sp) + (optinal for tests) -First ensure that CMake and a C compiler that implements the OpenMP 2.0 API -are installed on your system. Then install the RCMake package as well as -all the aforementioned prerequisites. Finally generate the project from -the `cmake/CMakeLists.txt` file by appending to the `CMAKE_PREFIX_PATH` -variable the install directories of its dependencies. +## Installation -Known Bugs ----------- +Edit config.mk as needed, then run: + + make clean install + +## Known Bugs In some rare circumstances, raytracing accuracy problems can lead to incorrect connex components pairing. This bug has already been fixed in star-enclosures-3d but is still present in star-enclosures-2d. -Release notes -------------- +## Release notes + +### Version 0.6 + +- Replace CMake by Makefile as build system. +- Update compiler and linker flags to increase the security and + robustness of generated binaries. +- Provide a pkg-config file to link the library as an external + dependency. ### Version 0.5.5 -Fixes the (rare) situation where temporary local variables could be used in a -unitialized way in the `senc2d_scene_create` function. +Fixes the (rare) situation where temporary local variables could be used +in a unitialized way in the `senc2d_scene_create` function. ### Version 0.5.4 @@ -58,8 +63,8 @@ Fix API break on filter function introduced by Star-2D 0.5. ### Version 0.5.2 -BugFix: enclosures including multiple media could end with invalid primitive -count. +BugFix: enclosures including multiple media could end with invalid +primitive count. ### Version 0.5.1 @@ -74,8 +79,8 @@ segments. - Compute volume (in m^2) and surface (in m) of enclosures. - Report overlapping segments. Only segments with a common vertex are - currently detected. Do not extract enclosures when overlapping segments are - detected. + currently detected. Do not extract enclosures when overlapping + segments are detected. - Make enclosure IDs consistent across runs. - Fix enclosure extraction when all segments Ny component is zero. - More robust on invalid scenes. @@ -83,8 +88,8 @@ segments. ### Version 0.4.2 - Fix global id of segments; releases 0.4.0 and 0.4.1 are broken -- Reintroduce an API call to get the global id in user space of a global unique - segment after deduplication +- Reintroduce an API call to get the global id in user space of a global + unique segment after deduplication ### Version 0.4.1 @@ -92,11 +97,11 @@ segments. ### Version 0.4 -- Change signature of the `senc2d_scene_add_geometry` API. Thus this release is - **not compatible** with previous ones. The `global_id` callback that was - ill-defined is removed and 2 callbacks are added to manage client-app data - when deduplicating geometry. These 2 callback allow a proper client-app - management of global ids. +- Change signature of the `senc2d_scene_add_geometry` API. Thus this + release is **not compatible** with previous ones. The `global_id` + callback that was ill-defined is removed and 2 callbacks are added to + manage client-app data when deduplicating geometry. These 2 callback + allow a proper client-app management of global ids. - Remove execution time for analysis steps from the log. ### Version 0.3.1 @@ -114,8 +119,9 @@ segments. ### Version 0.2.2 - BugFix when grouping components into enclosures. -- Add a warning message in log when edges that could surround a hole are found - (edges with at least one unshared vertex and different media on its sides). +- Add a warning message in log when edges that could surround a hole are + found (edges with at least one unshared vertex and different media on + its sides). ### Version 0.2.1 @@ -127,11 +133,11 @@ BugFix: needed data cleaning on computation canceling. - Allow to set the FRONT/BACK convention for input segments. - Allow to set the normal convention for output segments. -License -------- +## License + +Copyright © 2018-2021, 2023, 2024 +[|Méso|Star>](https://www.meso-star.com) (<contact@meso-star.com>). -Copyright © 2018-2021, 2023 [|Meso|Star>](https://www.meso-star.com) -(<contact@meso-star.com>). -Star-enclosures-2d is free software released under the GPLv3+ license: GNU GPL -version 3 or later. You are welcome to redistribute it under certain -conditions; refer to the COPYING file for details. +Star-enclosures-2d is free software released under the GPLv3+ license: +GNU GPL version 3 or later. You are welcome to redistribute it under +certain conditions; refer to the COPYING file for details. diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt @@ -1,189 +0,0 @@ -# Copyright (C) 2018-2021, 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-enclosures-2d C) -enable_testing() - -include(CMakeDependentOption) - -set(SENC2D_SOURCE_DIR ${PROJECT_SOURCE_DIR}/../src) -option(NO_TEST "Do not build tests" OFF) - -cmake_dependent_option(HUGE_ADDITIONAL_TESTS - "Build additional tests that involve millions of segments" OFF - "NOT NO_TEST" OFF) - -################################################################################ -# Check dependencies -################################################################################ -find_package(RCMake 0.4 REQUIRED) -find_package(Star2D 0.5 REQUIRED) -find_package(RSys 0.8.1 REQUIRED) -find_package(OpenMP 2.0 REQUIRED) - -if(NOT NO_TEST) - find_package(StarSP 0.12 QUIET) -endif() - -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${RCMAKE_SOURCE_DIR}) -include(rcmake) -include(rcmake_runtime) - -include_directories( - ${RSys_INCLUDE_DIR} - ${Star2D_INCLUDE_DIR}) -rcmake_append_runtime_dirs(_runtime_dirs RSys Star2D) - -if(StarSP_FOUND) - include_directories(${StarSP_INCLUDE_DIR}) - rcmake_append_runtime_dirs(_runtime_dirs RSys StarSP Star2D) -endif() - -################################################################################ -# Configure and define targets -################################################################################ -set(VERSION_MAJOR 0) -set(VERSION_MINOR 5) -set(VERSION_PATCH 5) -set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) - -set(SENC2D_FILES_SRC - senc2d_descriptor.c - senc2d_device.c - senc2d_enclosure.c - senc2d_scene.c - senc2d_scene_analyze.c) - -set(SENC2D_FILES_INC_API - senc2d.h - senc2d_sXd_helper.h - sencX2d.h - sencX2d_undefs.h) - -set(SENC2D_FILES_INC - senc2d_device_c.h - senc2d_enclosure_c.h - senc2d_enclosure_data.h - senc2d_internal_types.h - senc2d_scene_c.h - senc2d_scene_analyze_c.h - senc2d_side_range.h) - -set(SENC2D_FILES_DOC COPYING README.md) - -# Prepend each file by `SENC2D_SOURCE_DIR' -rcmake_prepend_path(SENC2D_FILES_SRC ${SENC2D_SOURCE_DIR}) -rcmake_prepend_path(SENC2D_FILES_INC ${SENC2D_SOURCE_DIR}) -rcmake_prepend_path(SENC2D_FILES_INC_API ${SENC2D_SOURCE_DIR}) -rcmake_prepend_path(SENC2D_FILES_DOC ${PROJECT_SOURCE_DIR}/../) - -if(CMAKE_COMPILER_IS_GNUCC) - set(MATH_LIB m) -endif() - -add_library(senc2d SHARED - ${SENC2D_FILES_SRC} - ${SENC2D_FILES_INC} - ${SENC2D_FILES_INC_API}) -target_link_libraries(senc2d RSys Star2D ${MATH_LIB}) - -set_target_properties(senc2d PROPERTIES -# C99 needed in case of printf %zu used -# C_STANDARD 99 - DEFINE_SYMBOL SENC2D_SHARED_BUILD - VERSION ${VERSION} - COMPILE_FLAGS ${OpenMP_C_FLAGS} - SOVERSION ${VERSION_MAJOR}) -rcmake_copy_runtime_libraries(senc2d) - -if(CMAKE_COMPILER_IS_GNUCC) - set_target_properties(senc2d PROPERTIES LINK_FLAGS "${OpenMP_C_FLAGS}") - target_link_libraries(senc2d m) -endif() - -rcmake_setup_devel(senc2d StarEnc2D ${VERSION} star/senc2d_version.h) - -################################################################################ -# Add tests -################################################################################ -if(NOT NO_TEST) - function(build_test _name) - add_executable(${_name} - ${SENC2D_SOURCE_DIR}/test_senc2d_utils.h - ${SENC2D_SOURCE_DIR}/${_name}.c) - foreach(other ${ARGN}) - target_sources(${_name} - PUBLIC ${STAR_GEOM_SOURCE_DIR}/${other}) - endforeach() - target_link_libraries(${_name} RSys senc2d) - 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_senc2d_square_behind_square) - new_test(test_senc2d_square_in_square) - new_test(test_senc2d_square_on_square) - new_test(test_senc2d_device) - new_test(test_senc2d_enclosure) - new_test(test_senc2d_inconsistant_square) - new_test(test_senc2d_invalid_scenes) - new_test(test_senc2d_multi_media) - new_test(test_senc2d_scene) - new_test(test_senc2d_some_enclosures) - new_test(test_senc2d_some_segments) - new_test(test_senc2d_unspecified_medium) - - if(NOT StarSP_FOUND) - message(STATUS - "StarSP is not found. Do not compile the" - "'test_senc2d_sample_enclosure' test.") - else() - new_test(test_senc2d_sample_enclosure) - target_link_libraries(test_senc2d_sample_enclosure StarSP Star2D) - endif() - - build_test(test_senc2d_many_enclosures) - build_test(test_senc2d_many_segments) - - target_link_libraries(test_senc2d_enclosure Star2D) - - rcmake_copy_runtime_libraries(test_senc2d_many_enclosures test_senc2d_utils2.h) - rcmake_copy_runtime_libraries(test_senc2d_many_segments test_senc2d_utils2.h) - rcmake_copy_runtime_libraries(test_senc2d_sample_enclosure) - - if(HUGE_ADDITIONAL_TESTS) - add_test(test_senc2d_many_enclosures test_senc2d_many_enclosures) - add_test(test_senc2d_many_segments test_senc2d_many_segments) - endif() -endif() - -################################################################################ -# Define output & install directories -################################################################################ -install(TARGETS senc2d - ARCHIVE DESTINATION bin - LIBRARY DESTINATION lib - RUNTIME DESTINATION bin) -install(FILES ${SENC2D_FILES_INC_API} DESTINATION include/star) -install(FILES ${SENC2D_FILES_DOC} DESTINATION share/doc/star-enclosures-2d) diff --git a/config.mk b/config.mk @@ -0,0 +1,89 @@ +VERSION = 0.6 +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) + +S2D_VERSION = 0.7 +S2D_CFLAGS = $$($(PKG_CONFIG) $(PCFLAGS) --cflags s2d) +S2D_LIBS = $$($(PKG_CONFIG) $(PCFLAGS) --libs s2d) + +# Optional dependency +SSP_VERSION = 0.14 +SSP_CFLAGS = $$($(PKG_CONFIG) $(PCFLAGS) --cflags star-sp) +SSP_LIBS = $$($(PKG_CONFIG) $(PCFLAGS) --libs star-sp) + +DPDC_CFLAGS = $(RSYS_CFLAGS) $(S2D_CFLAGS) -fopenmp +DPDC_LIBS = $(RSYS_LIBS) $(S2D_LIBS) -lm -fopenmp + +################################################################################ +# 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) 2018-2021, 2023, 2024 |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/senc2d.pc.in b/senc2d.pc.in @@ -0,0 +1,12 @@ +prefix=@PREFIX@ +includedir=${prefix}/include +libdir=${prefix}/lib + +Requires: rsys >= @RSYS_VERSION@ +Requires.private: s2d >= @S2D_VERSION@ +Name: senc2d +Description: Star ENClosures 2D library +Version: @VERSION@ +Libs: -L${libdir} -lsenc2d +Libs.private: -fopenmp -lm +CFlags: -I${includedir} diff --git a/src/senc2d.h b/src/senc2d.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2018-2021, 2023 |Méso|Star> (contact@meso-star.com) +/* Copyright (C) 2018-2021, 2023, 2024 |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 diff --git a/src/senc2d_descriptor.c b/src/senc2d_descriptor.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2018-2021, 2023 |Méso|Star> (contact@meso-star.com) +/* Copyright (C) 2018-2021, 2023, 2024 |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 diff --git a/src/senc2d_device.c b/src/senc2d_device.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2018-2021, 2023 |Méso|Star> (contact@meso-star.com) +/* Copyright (C) 2018-2021, 2023, 2024 |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 diff --git a/src/senc2d_device_c.h b/src/senc2d_device_c.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2018-2021, 2023 |Méso|Star> (contact@meso-star.com) +/* Copyright (C) 2018-2021, 2023, 2024 |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 diff --git a/src/senc2d_enclosure.c b/src/senc2d_enclosure.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2018-2021, 2023 |Méso|Star> (contact@meso-star.com) +/* Copyright (C) 2018-2021, 2023, 2024 |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 diff --git a/src/senc2d_enclosure_c.h b/src/senc2d_enclosure_c.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2018-2021, 2023 |Méso|Star> (contact@meso-star.com) +/* Copyright (C) 2018-2021, 2023, 2024 |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 diff --git a/src/senc2d_enclosure_data.h b/src/senc2d_enclosure_data.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2018-2021, 2023 |Méso|Star> (contact@meso-star.com) +/* Copyright (C) 2018-2021, 2023, 2024 |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 diff --git a/src/senc2d_internal_types.h b/src/senc2d_internal_types.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2018-2021, 2023 |Méso|Star> (contact@meso-star.com) +/* Copyright (C) 2018-2021, 2023, 2024 |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 diff --git a/src/senc2d_sXd_helper.h b/src/senc2d_sXd_helper.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2018-2021, 2023 |Méso|Star> (contact@meso-star.com) +/* Copyright (C) 2018-2021, 2023, 2024 |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 diff --git a/src/senc2d_scene.c b/src/senc2d_scene.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2018-2021, 2023 |Méso|Star> (contact@meso-star.com) +/* Copyright (C) 2018-2021, 2023, 2024 |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 diff --git a/src/senc2d_scene_analyze.c b/src/senc2d_scene_analyze.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2018-2021, 2023 |Méso|Star> (contact@meso-star.com) +/* Copyright (C) 2018-2021, 2023, 2024 |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 diff --git a/src/senc2d_scene_analyze_c.h b/src/senc2d_scene_analyze_c.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2018-2021, 2023 |Méso|Star> (contact@meso-star.com) +/* Copyright (C) 2018-2021, 2023, 2024 |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 diff --git a/src/senc2d_scene_c.h b/src/senc2d_scene_c.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2018-2021, 2023 |Méso|Star> (contact@meso-star.com) +/* Copyright (C) 2018-2021, 2023, 2024 |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 diff --git a/src/senc2d_side_range.h b/src/senc2d_side_range.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2018-2021, 2023 |Méso|Star> (contact@meso-star.com) +/* Copyright (C) 2018-2021, 2023, 2024 |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 diff --git a/src/sencX2d.h b/src/sencX2d.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2018-2021, 2023 |Méso|Star> (contact@meso-star.com) +/* Copyright (C) 2018-2021, 2023, 2024 |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 diff --git a/src/sencX2d_undefs.h b/src/sencX2d_undefs.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2018-2021, 2023 |Méso|Star> (contact@meso-star.com) +/* Copyright (C) 2018-2021, 2023, 2024 |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 diff --git a/src/test_senc2d_device.c b/src/test_senc2d_device.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2018-2021, 2023 |Méso|Star> (contact@meso-star.com) +/* Copyright (C) 2018-2021, 2023, 2024 |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 diff --git a/src/test_senc2d_enclosure.c b/src/test_senc2d_enclosure.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2018-2021, 2023 |Méso|Star> (contact@meso-star.com) +/* Copyright (C) 2018-2021, 2023, 2024 |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 diff --git a/src/test_senc2d_inconsistant_square.c b/src/test_senc2d_inconsistant_square.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2018-2021, 2023 |Méso|Star> (contact@meso-star.com) +/* Copyright (C) 2018-2021, 2023, 2024 |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 diff --git a/src/test_senc2d_sample_enclosure.c b/src/test_senc2d_sample_enclosure.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2018-2021, 2023 |Méso|Star> (contact@meso-star.com) +/* Copyright (C) 2018-2021, 2023, 2024 |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 diff --git a/src/test_senc2d_scene.c b/src/test_senc2d_scene.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2018-2021, 2023 |Méso|Star> (contact@meso-star.com) +/* Copyright (C) 2018-2021, 2023, 2024 |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 diff --git a/src/test_senc2d_some_enclosures.c b/src/test_senc2d_some_enclosures.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2018-2021, 2023 |Méso|Star> (contact@meso-star.com) +/* Copyright (C) 2018-2021, 2023, 2024 |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 diff --git a/src/test_senc2d_some_segments.c b/src/test_senc2d_some_segments.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2018-2021, 2023 |Méso|Star> (contact@meso-star.com) +/* Copyright (C) 2018-2021, 2023, 2024 |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 diff --git a/src/test_senc2d_square_behind_square.c b/src/test_senc2d_square_behind_square.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2018-2021, 2023 |Méso|Star> (contact@meso-star.com) +/* Copyright (C) 2018-2021, 2023, 2024 |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 diff --git a/src/test_senc2d_square_in_square.c b/src/test_senc2d_square_in_square.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2018-2021, 2023 |Méso|Star> (contact@meso-star.com) +/* Copyright (C) 2018-2021, 2023, 2024 |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 diff --git a/src/test_senc2d_square_on_square.c b/src/test_senc2d_square_on_square.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2018-2021, 2023 |Méso|Star> (contact@meso-star.com) +/* Copyright (C) 2018-2021, 2023, 2024 |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 diff --git a/src/test_senc2d_unspecified_medium.c b/src/test_senc2d_unspecified_medium.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2018-2021, 2023 |Méso|Star> (contact@meso-star.com) +/* Copyright (C) 2018-2021, 2023, 2024 |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 diff --git a/src/test_senc2d_utils.h b/src/test_senc2d_utils.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2018-2021, 2023 |Méso|Star> (contact@meso-star.com) +/* Copyright (C) 2018-2021, 2023, 2024 |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 diff --git a/src/test_senc2d_utils2.h b/src/test_senc2d_utils2.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2018-2021, 2023 |Méso|Star> (contact@meso-star.com) +/* Copyright (C) 2018-2021, 2023, 2024 |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