solstice

Compute collected power and efficiencies of a solar plant
git clone git://git.meso-star.com/solstice.git
Log | Files | Refs | README | LICENSE

commit ecebb8d03fa74e8d642736349d4680cd327b2b8b
parent 4a0f56a691eb27017d8f349f92350c1ad5af9a0c
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date:   Fri, 24 Apr 2026 18:33:23 +0200

Replace CMake with a POSIX Makefile

The build procedure is written in POSIX make and can be configured via
the config.mk file. A pkg-config file is also provided to link the
library as an external dependency.

Compared to the CMake alternative, this Makefile adds support for static
libraries and an uninstall target. It also enables compiler and linker
flags for various hardening features, improving the security and
robustness of generated binaries. More broadly, the motivation for this
rewrite is to rely on a well-established standard with a simple feature
set, available on all UNIX systems - reducing portability concerns and
maintenance burden while remaining significantly lighter.

Diffstat:
M.gitignore | 41+++++++++++++++++++++++++++++++++++------
AMakefile | 157+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
AMakefile.core | 265+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
AMakefile.prs | 245+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
AMakefile.rcv | 198+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dcmake/CMakeLists.txt | 201-------------------------------------------------------------------------------
Dcmake/LibYAMLConfig.cmake | 63---------------------------------------------------------------
Dcmake/doc/CMakeLists.txt | 151------------------------------------------------------------------------------
Dcmake/parser/CMakeLists.txt | 121-------------------------------------------------------------------------------
Dcmake/receivers/CMakeLists.txt | 73-------------------------------------------------------------------------
Aconfig.mk | 104+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ascore.pc.in | 19+++++++++++++++++++
Asprs.pc.in | 14++++++++++++++
Msrc/parser/solparser.h | 93+++++++++++++++++++++++++++++++++++++++++++------------------------------------
Msrc/receivers/srcvl.h | 23++++++++++++++++-------
Asrc/score.h | 60++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/solstice.h | 16++++++++++++----
Msrc/solstice_args.h.in | 14+++-----------
Asrcv.pc.in | 14++++++++++++++
19 files changed, 1193 insertions(+), 679 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -1,12 +1,41 @@ .gitignore -CMakeCache.txt -CMakeFiles -Makefile -tmp [Bb]uild* *.sw[po] -*.[ao] +*.[aodt] *.orig +*.so *~ tags - +src/solstice_args.h +src/solstice_version.h +src/.config +src/.config_core +src/.config_prs +src/.config_rcv +src/.config_score_test +src/.config_sprs_test +src/.config_srcv_test +solstice.pc +doc/solstice.1 +src/score-local.pc +src/score.pc +src/sprs-local.pc +src/sprs.pc +src/srcv-local.pc +src/srcv.pc +solstice +test_solparser +test_solparser2 +test_solparser3 +test_solparser4 +test_solparser5 +test_solparser6 +test_solparser7 +test_solparser8 +test_solparser_mirror +test_solparser_normal_map +test_solparser_spectrum +test_solstice_args +test_solstice_simulation +test_srcvl +test_srcvl2 diff --git a/Makefile b/Makefile @@ -0,0 +1,157 @@ +# Copyright (C) 2018-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 + +default: executable +all: executable man test + +LIBEXT_STATIC = a +LIBEXT_SHARED = so +LIBEXT = $(LIBEXT_$(LIB_TYPE)) +LIBSCORE = libscore.${LIBEXT} +LIBSRCV = libsrcv.${LIBEXT} +LIBSPRS = libsprs.${LIBEXT} + +################################################################################ +# Program building +################################################################################ +CMD_SRC =\ +src/main.c +CMD_OBJ = $(CMD_SRC:.c=.o) +CMD_DEP = $(CMD_SRC:.c=.d) + +# Headers to configure +HDR=\ + src/solstice_args.h\ + src/solstice_version.h + +PKG_CONFIG_LOCAL = PKG_CONFIG_PATH="./src:$${PKG_CONFIG_PATH}" $(PKG_CONFIG) +INCS_CMD = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --cflags rsys score sprs srcv) +LIBS_CMD = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --libs rsys score sprs srcv)\ + -lm +CFLAGS_CMD = $(CFLAGS_EXE) $(INCS_CMD) +LDFLAGS_CMD = $(LDFLAGS_EXE) $(LIBS_CMD) + +executable $(CMD_DEP) $(CMD_OBJ): src/.config + +executable: libscore libsrcv libsprs $(CMD_DEP) + @$(MAKE) -fMakefile $$(for i in $(CMD_DEP); do echo -f $${i}; done) solstice + +solstice: $(CMD_OBJ) ${LIBSCORE} ${LIBSRCV} ${LIBSPRS} + $(CC) $(CFLAGS_CMD) -o $@ $(CMD_OBJ) $(LDFLAGS_CMD) + +$(CMD_DEP): $(HDR) + @$(CC) $(CFLAGS_CMD) -MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@ + +$(CMD_OBJ): $(HDR) + $(CC) $(CFLAGS_CMD) -c $(@:.o=.c) -o $@ + +libscore: libsrcv libsprs $(HDR) + $(MAKE) -fMakefile.core library + +libsrcv: + $(MAKE) -fMakefile.rcv library + +libsprs: + $(MAKE) -fMakefile.prs library + +src/solstice_args.h: + $(MAKE) -fMakefile.core $@ + +src/solstice_version.h: + $(MAKE) -fMakefile.core $@ + +src/.config: config.mk + $(PKG_CONFIG) --atleast-version $(RSYS_VERSION) rsys + @echo "config done" > $@ + +################################################################################ +# Tests +################################################################################ +test: executable + $(MAKE) -fMakefile.core test + $(MAKE) -fMakefile.prs test + $(MAKE) -fMakefile.rcv test + +################################################################################ +# Man pages +################################################################################ +man: doc/solstice.1 + +doc/solstice.1: doc/solstice.1.in + sed -e 's/@SOLSTICE_ARGS_DEFAULT_NREALISATIONS@/$(SOLSTICE_ARGS_DEFAULT_NREALISATIONS)/' \ + -e 's/@SOLSTICE_ARGS_DEFAULT_CAMERA_POS@/$(SOLSTICE_ARGS_DEFAULT_CAMERA_POS)/' \ + -e 's/@SOLSTICE_ARGS_DEFAULT_CAMERA_TGT@/$(SOLSTICE_ARGS_DEFAULT_CAMERA_TGT)/' \ + -e 's/@SOLSTICE_ARGS_DEFAULT_CAMERA_UP@/$(SOLSTICE_ARGS_DEFAULT_CAMERA_UP)/' \ + -e 's/@SOLSTICE_ARGS_DEFAULT_CAMERA_FOV@/$(SOLSTICE_ARGS_DEFAULT_CAMERA_FOV)/' \ + -e 's/@SOLSTICE_ARGS_DEFAULT_IMG_WIDTH@/$(SOLSTICE_ARGS_DEFAULT_IMG_WIDTH)/' \ + -e 's/@SOLSTICE_ARGS_DEFAULT_IMG_HEIGHT@/$(SOLSTICE_ARGS_DEFAULT_IMG_HEIGHT)/' \ + -e 's/@SOLSTICE_ARGS_DEFAULT_IMG_SPP@/$(SOLSTICE_ARGS_DEFAULT_IMG_SPP)/' \ + $@.in > $@ + +################################################################################ +# Installation +################################################################################ +install: executable man + install() { mode="$$1"; prefix="$$2"; shift 2; \ + mkdir -p "$${prefix}"; \ + cp "$$@" "$${prefix}"; \ + chmod "$${mode}" "$${prefix}/$${@##*/}"; \ + }; \ + install 755 "$(DESTDIR)$(PREFIX)/bin" solstice; \ + install 644 "$(DESTDIR)$(PREFIX)/share/doc/solstice" COPYING; \ + install 644 "$(DESTDIR)$(PREFIX)/share/doc/solstice" README.md; \ + install 644 "$(DESTDIR)$(PREFIX)/share/man/man1" doc/solstice.1; \ + install 644 "$(DESTDIR)$(PREFIX)/share/man/man5" doc/solstice-input.5; \ + install 644 "$(DESTDIR)$(PREFIX)/share/man/man5" doc/solstice-output.5; \ + install 644 "$(DESTDIR)$(PREFIX)/share/man/man5" doc/solstice-receiver.5 + $(MAKE) -fMakefile.core install + $(MAKE) -fMakefile.rcv install + $(MAKE) -fMakefile.prs install + +uninstall: + rm -f "$(DESTDIR)$(PREFIX)/bin/solstice" + rm -f "$(DESTDIR)$(PREFIX)/share/doc/solstice/COPYING" + rm -f "$(DESTDIR)$(PREFIX)/share/doc/solstice/README.md" + rm -f "$(DESTDIR)$(PREFIX)/share/man/man1/solstice.1" + rm -f "$(DESTDIR)$(PREFIX)/share/man/man5/solstice-receiver.5" + rm -f "$(DESTDIR)$(PREFIX)/share/man/man5/solstice-input.5" + rm -f "$(DESTDIR)$(PREFIX)/share/man/man5/solstice-output.5" + $(MAKE) -fMakefile.core uninstall + $(MAKE) -fMakefile.rcv uninstall + $(MAKE) -fMakefile.prs uninstall + +################################################################################ +# Miscellaneous targets +################################################################################ +clean: + rm -f $(HDR) $(CMD_OBJ) $(CMD_DEP) + rm -f solstice doc/solstice.1 + $(MAKE) -fMakefile.core clean + $(MAKE) -fMakefile.rcv clean + $(MAKE) -fMakefile.prs clean + +lint: man + mandoc -Tlint -Wall doc/solstice.1 || [ $$? -le 1 ] + mandoc -Tlint -Wall doc/solstice-receiver.5 || [ $$? -le 1 ] + mandoc -Tlint -Wall doc/solstice-input.5 || [ $$? -le 1 ] + mandoc -Tlint -Wall doc/solstice-output.5 || [ $$? -le 1 ] + $(MAKE) -fMakefile.core lint + $(MAKE) -fMakefile.rcv lint + $(MAKE) -fMakefile.prs lint diff --git a/Makefile.core b/Makefile.core @@ -0,0 +1,265 @@ +# Copyright (C) 2018-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 = libscore.a +LIBNAME_SHARED = libscore.so +LIBNAME = $(LIBNAME_$(LIB_TYPE)) + +default: library +all: library tests + +################################################################################ +# Build the library +################################################################################ +SRC =\ +src/solstice_args.c\ +src/solstice_atmosphere.c\ +src/solstice.c\ +src/solstice_draw.c\ +src/solstice_dump.c\ +src/solstice_entity.c\ +src/solstice_material.c\ +src/solstice_node.c\ +src/solstice_object.c\ +src/solstice_solve.c\ +src/solstice_spectrum.c\ +src/solstice_sun.c\ +src/solstice_sun_spectrum.c +OBJ = $(SRC:.c=.o) +DEP = $(SRC:.c=.d) + +# Headers to configure +HDR=\ + src/solstice_args.h\ + src/solstice_version.h + +CFLAGS_LIB = $(CFLAGS_SO) $(INCS) -DSCORE_SHARED_BUILD +LDFLAGS_LIB = $(LDFLAGS_SO) -L. -lsprs -lsrcv $(LIBS) + +$(LIBNAME_SHARED) $(DEP) $(OBJ): src/.config_core + +library: $(DEP) + @$(MAKE) -fMakefile.core $$(for i in $(DEP); do echo -f $${i}; done) \ + $$(if [ -n "$(LIBNAME)" ]; then \ + echo "$(LIBNAME)"; \ + else \ + echo "$(LIBNAME_SHARED)"; \ + fi) + +$(LIBNAME_SHARED): $(OBJ) + $(CC) $(CFLAGS_LIB) -o $@ $(OBJ) $(LDFLAGS_LIB) + +$(LIBNAME_STATIC): src/libscore.o + $(AR) -rc $@ $? + $(RANLIB) $@ + +src/libscore.o: $(OBJ) $(DEP) + $(LD) -r $(OBJ) -o $@ + $(OBJCOPY) $(OCPFLAGS) $@ + +$(DEP): $(HDR) src/score.pc + @$(CC) $(CFLAGS_LIB) -MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@ + +$(OBJ): $(HDR) src/score.pc + $(CC) $(CFLAGS_LIB) -c $(@:.o=.c) -o $@ + +src/solstice_args.h: src/.config src/solstice_args.h.in + sed -e 's/@SOLSTICE_ARGS_DEFAULT_NREALISATIONS@/$(SOLSTICE_ARGS_DEFAULT_NREALISATIONS)/' \ + -e 's/@SOLSTICE_ARGS_DEFAULT_CAMERA_POS@/$(SOLSTICE_ARGS_DEFAULT_CAMERA_POS)/' \ + -e 's/@SOLSTICE_ARGS_DEFAULT_CAMERA_TGT@/$(SOLSTICE_ARGS_DEFAULT_CAMERA_TGT)/' \ + -e 's/@SOLSTICE_ARGS_DEFAULT_CAMERA_UP@/$(SOLSTICE_ARGS_DEFAULT_CAMERA_UP)/' \ + -e 's/@SOLSTICE_ARGS_DEFAULT_CAMERA_FOV@/$(SOLSTICE_ARGS_DEFAULT_CAMERA_FOV)/' \ + -e 's/@SOLSTICE_ARGS_DEFAULT_IMG_WIDTH@/$(SOLSTICE_ARGS_DEFAULT_IMG_WIDTH)/' \ + -e 's/@SOLSTICE_ARGS_DEFAULT_IMG_HEIGHT@/$(SOLSTICE_ARGS_DEFAULT_IMG_HEIGHT)/' \ + -e 's/@SOLSTICE_ARGS_DEFAULT_IMG_SPP@/$(SOLSTICE_ARGS_DEFAULT_IMG_SPP)/' \ + $@.in > $@ + +src/solstice_version.h: src/.config src/solstice_version.h.in + sed -e 's/@VERSION_MAJOR@/$(VERSION_MAJOR)/' \ + -e 's/@VERSION_MINOR@/$(VERSION_MINOR)/' \ + -e 's/@VERSION_PATCH@/$(VERSION_PATCH)/' \ + $@.in > $@ + +################################################################################ +# Installation +################################################################################ +pkg: src/score.pc + +src/score.pc: score.pc.in src/.config_core + sed -e 's#@PREFIX@#$(PREFIX)#g'\ + -e 's#@VERSION@#$(VERSION)#g'\ + -e 's#@RSYS_VERSION@#$(RSYS_VERSION)#g'\ + -e 's#@S3DUT_VERSION@#$(S3DUT_VERSION)#g'\ + -e 's#@SSP_VERSION@#$(SSP_VERSION)#g'\ + -e 's#@SSTL_VERSION@#$(SSTL_VERSION)#g'\ + -e 's#@YAML_VERSION@#$(YAML_VERSION)#g'\ + -e 's#@SSOL_VERSION@#$(SSOL_VERSION)#g'\ + -e 's#@SANIM_VERSION@#$(SANIM_VERSION)#g'\ + score.pc.in > $@ + +src/.config_core: config.mk + $(PKG_CONFIG) --atleast-version $(RSYS_VERSION) rsys + $(PKG_CONFIG) --atleast-version $(S3DUT_VERSION) s3dut + $(PKG_CONFIG) --atleast-version $(SSP_VERSION) star-sp + $(PKG_CONFIG) --atleast-version $(SSTL_VERSION) sstl + $(PKG_CONFIG) --atleast-version $(YAML_VERSION) yaml-0.1 + $(PKG_CONFIG) --atleast-version $(SSOL_VERSION) ssol + $(PKG_CONFIG) --atleast-version $(SANIM_VERSION) sanim + @echo "config done" > $@ + +install: library pkg + install() { mode="$$1"; prefix="$$2"; shift 2; \ + mkdir -p "$${prefix}"; \ + cp "$$@" "$${prefix}"; \ + chmod "$${mode}" "$${prefix}/$${@##*/}"; \ + }; \ + if [ "$(LIB_TYPE)" = "SHARED" ]; then \ + install 755 "$(DESTDIR)$(LIBPREFIX)" $(LIBNAME); \ + install 644 "$(DESTDIR)$(LIBPREFIX)/pkgconfig" src/score.pc; \ + fi; \ + +uninstall: + if [ "$(LIB_TYPE)" = "SHARED" ]; then \ + rm -f "$(DESTDIR)$(LIBPREFIX)/$(LIBNAME)" \ + rm -f "$(DESTDIR)$(LIBPREFIX)/pkgconfig/score.pc" \ + fi; \ + +clean: clean_test + rm -f $(DEP) $(OBJ) $(LIBNAME) + rm -f src/.config_core src/libscore.o src/score.pc + +lint: + +################################################################################ +# Tests +################################################################################ +TEST_SRC =\ + src/test_solstice_args.c\ + src/test_solstice_simulation.c +TEST_OBJ =\ + $(TEST_SRC:.c=.o) +TEST_DEP =\ + $(TEST_SRC:.c=.d) +TEST_TGT =\ + $(TEST_SRC:.c=.t) + +src/score-local.pc: score.pc.in src/.config_score_test + sed -e '1d'\ + -e 's#^includedir=.*#includedir=./src/#'\ + -e 's#^libdir=.*#libdir=./#'\ + -e 's#@RSYS_VERSION@#$(RSYS_VERSION)#g'\ + -e 's#@S3DUT_VERSION@#$(S3DUT_VERSION)#g'\ + -e 's#@SSP_VERSION@#$(SSP_VERSION)#g'\ + -e 's#@SSTL_VERSION@#$(SSTL_VERSION)#g'\ + -e 's#@YAML_VERSION@#$(YAML_VERSION)#g'\ + -e 's#@SSOL_VERSION@#$(SSOL_VERSION)#g'\ + -e 's#@SANIM_VERSION@#$(SANIM_VERSION)#g'\ + score.pc.in > $@ + +# Regular cflags +PKG_CONFIG_LOCAL = PKG_CONFIG_PATH="./src:$${PKG_CONFIG_PATH}" $(PKG_CONFIG) +INCS_TEST = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --cflags rsys score-local sprs srcv) +LIBS_TEST = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --libs rsys score-local sprs srcv)\ + -lm + +tests: library src/score-local.pc $(TEST_DEP) $(TEST_TGT) + @$(MAKE) -fMakefile.core \ + $$(for i in $(TEST_DEP); do echo -f"$${i}"; done) \ + $$(for i in $(TEST_TGT); do echo -f"$${i}"; done) \ + test_list + +$(TEST_TGT): + @{ \ + exe="$$(basename "$@" ".t")"; \ + printf '%s: %s\n' "$${exe}" $(@:.t=.o); \ + printf 'test_list: %s\n' "$${exe}"; \ + } > $@ + +src/.config_score_test: config.mk + $(PKG_CONFIG) --atleast-version $(RSYS_VERSION) rsys + $(PKG_CONFIG) --atleast-version $(S3DUT_VERSION) s3dut + $(PKG_CONFIG) --atleast-version $(SSP_VERSION) star-sp + $(PKG_CONFIG) --atleast-version $(SSTL_VERSION) sstl + $(PKG_CONFIG) --atleast-version $(YAML_VERSION) yaml-0.1 + $(PKG_CONFIG) --atleast-version $(SSOL_VERSION) ssol + $(PKG_CONFIG) --atleast-version $(SANIM_VERSION) sanim + @echo "config done" > $@ + +clean_test: + rm -f $(TEST_DEP) $(TEST_OBJ) $(TEST_TGT) + for i in $(TEST_SRC); do rm -f "$$(basename "$${i}" ".c")"; done + rm -f src/.config_score_test src/score-local.pc + +test: tests + @err=0; \ + check() { name="$$1"; prog="$$2"; shift 2; \ + printf '%s' "$${name}"; \ + if PATH=./:"$${PATH}" "$${prog}" $$@ > /dev/null 2>&1; then \ + printf '\n'; \ + else \ + printf ': error %s\n' "$$?"; \ + err=$$((err+1)); \ + fi; \ + }; \ + \ + for i in $(TEST_SRC); do \ + test="$$(basename "$${i}" ".c")"; \ + if [ "$${test}" != "test_solstice_simulation" ]; then \ + check "$${test}" "$${test}"; \ + else \ + check test_solstice_simulation_beam_down \ + test_solstice_simulation ./solstice yaml/ beam_down; \ + check test_solstice_simulation_test02 \ + test_solstice_simulation ./solstice yaml/ test02; \ + check test_solstice_simulation_test03 \ + test_solstice_simulation ./solstice yaml/ test03; \ + check test_solstice_simulation_test04 \ + test_solstice_simulation ./solstice yaml/ test04; \ + check test_solstice_simulation_test05 \ + test_solstice_simulation ./solstice yaml/ test05; \ + check test_solstice_simulation_test06 \ + test_solstice_simulation ./solstice yaml/ test06; \ + check test_solstice_simulation_test07 \ + test_solstice_simulation ./solstice yaml/ test07; \ + #check test_solstice_simulation_test08 \ + # test_solstice_simulation ./solstice yaml/ test08; \ + #check test_solstice_simulation_test09 \ + # test_solstice_simulation ./solstice yaml/ test09; \ + fi \ + done; \ + \ + [ "$${err}" -eq 0 ] + +################################################################################ +# Regular tests +################################################################################ +CFLAGS_TEST = $(CFLAGS_EXE) $(INCS_TEST) +LDFLAGS_TEST = $(LDFLAGS_EXE) -L. -lsprs -Lsrcv $(LIBS_TEST) + +$(TEST_DEP) : src/.config_score_test src/score-local.pc + @$(CC) $(CFLAGS_TEST) -MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@ + +$(TEST_OBJ) : src/.config_score_test src/score-local.pc + $(CC) $(CFLAGS_TEST) -c $(@:.o=.c) -o $@ + +test_solstice_args\ +test_solstice_simulation\ +: src/.config_score_test src/score-local.pc $(LIBNAME) + $(CC) $(CFLAGS_TEST) -o $@ src/$@.o $(LDFLAGS_TEST) diff --git a/Makefile.prs b/Makefile.prs @@ -0,0 +1,245 @@ +# Copyright (C) 2018-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 = libsprs.a +LIBNAME_SHARED = libsprs.so +LIBNAME = $(LIBNAME_$(LIB_TYPE)) + +default: library +all: library tests + +################################################################################ +# Build the library +################################################################################ +SRC =\ + src/parser/solparser_atmosphere.c\ + src/parser/solparser.c\ + src/parser/solparser_entity.c\ + src/parser/solparser_geometry.c\ + src/parser/solparser_image.c\ + src/parser/solparser_material.c\ + src/parser/solparser_medium.c\ + src/parser/solparser_mtl_data.c\ + src/parser/solparser_pivot.c\ + src/parser/solparser_spectrum.c\ + src/parser/solparser_sun.c +OBJ = $(SRC:.c=.o) +DEP = $(SRC:.c=.d) + +# Headers to configure +HDR= + +CFLAGS_LIB = $(CFLAGS_SO) $(INCS) -DSPRSR_SHARED_BUILD +LDFLAGS_LIB = $(LDFLAGS_SO) $(LIBS) + +$(LIBNAME_SHARED) $(DEP) $(OBJ): src/.config_prs + +library: $(DEP) + @$(MAKE) -fMakefile.prs $$(for i in $(DEP); do echo -f $${i}; done) \ + $$(if [ -n "$(LIBNAME)" ]; then \ + echo "$(LIBNAME)"; \ + else \ + echo "$(LIBNAME_SHARED)"; \ + fi) + +$(LIBNAME_SHARED): $(OBJ) + $(CC) $(CFLAGS_LIB) -o $@ $(OBJ) $(LDFLAGS_LIB) + +$(LIBNAME_STATIC): src/libsprs.o + $(AR) -rc $@ $? + $(RANLIB) $@ + +src/libsprs.o: $(OBJ) $(DEP) + $(LD) -r $(OBJ) -o $@ + $(OBJCOPY) $(OCPFLAGS) $@ + +$(DEP): $(HDR) src/sprs.pc + @$(CC) $(CFLAGS_LIB) -MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@ + +$(OBJ): $(HDR) src/sprs.pc + $(CC) $(CFLAGS_LIB) -c $(@:.o=.c) -o $@ + +################################################################################ +# Installation +################################################################################ +pkg: src/sprs.pc + +src/sprs.pc: sprs.pc.in src/.config_prs + sed -e 's#@PREFIX@#$(PREFIX)#g'\ + -e 's#@VERSION@#$(VERSION)#g'\ + -e 's#@RSYS_VERSION@#$(RSYS_VERSION)#g'\ + -e 's#@YAML_VERSION@#$(YAML_VERSION)#g'\ + sprs.pc.in > $@ + +src/.config_prs: config.mk + $(PKG_CONFIG) --atleast-version $(RSYS_VERSION) rsys + $(PKG_CONFIG) --exists yaml-0.1 + @echo "config done" > $@ + +install: library pkg + install() { mode="$$1"; prefix="$$2"; shift 2; \ + mkdir -p "$${prefix}"; \ + cp "$$@" "$${prefix}"; \ + chmod "$${mode}" "$${prefix}/$${@##*/}"; \ + }; \ + if [ "$(LIB_TYPE)" = "SHARED" ]; then \ + install 755 "$(DESTDIR)$(LIBPREFIX)" $(LIBNAME); \ + install 644 "$(DESTDIR)$(LIBPREFIX)/pkgconfig" src/score.pc; \ + fi; \ + +uninstall: + if [ "$(LIB_TYPE)" = "SHARED" ]; then \ + rm -f "$(DESTDIR)$(LIBPREFIX)/$(LIBNAME)" \ + rm -f "$(DESTDIR)$(LIBPREFIX)/pkgconfig/score.pc" \ + fi; \ + +clean: clean_test + rm -f $(DEP) $(OBJ) $(LIBNAME) + rm -f src/.config_prs src/libsprs.o src/sprs.pc + +lint: + +################################################################################ +# Tests +################################################################################ +TEST_SRC =\ +src/parser/test_solparser.c\ +src/parser/test_solparser2.c\ +src/parser/test_solparser3.c\ +src/parser/test_solparser4.c\ +src/parser/test_solparser5.c\ +src/parser/test_solparser6.c\ +src/parser/test_solparser7.c\ +src/parser/test_solparser8.c\ +src/parser/test_solparser_mirror.c\ +src/parser/test_solparser_normal_map.c\ +src/parser/test_solparser_spectrum.c +TEST_OBJ =\ + $(TEST_SRC:.c=.o) +TEST_DEP =\ + $(TEST_SRC:.c=.d) +TEST_TGT =\ + $(TEST_SRC:.c=.t) + +src/sprs-local.pc: sprs.pc.in config.mk + sed -e '1d'\ + -e 's#^includedir=.*#includedir=./src/#'\ + -e 's#^libdir=.*#libdir=./#'\ + -e 's#@RSYS_VERSION@#$(RSYS_VERSION)#g'\ + -e 's#@S3DUT_VERSION@#$(S3DUT_VERSION)#g'\ + -e 's#@SSP_VERSION@#$(SSP_VERSION)#g'\ + -e 's#@SSTL_VERSION@#$(SSTL_VERSION)#g'\ + -e 's#@YAML_VERSION@#$(YAML_VERSION)#g'\ + -e 's#@SSOL_VERSION@#$(SSOL_VERSION)#g'\ + -e 's#@SANIM_VERSION@#$(SANIM_VERSION)#g'\ + sprs.pc.in > $@ + +# Regular cflags +PKG_CONFIG_LOCAL = PKG_CONFIG_PATH="./src:$${PKG_CONFIG_PATH}" $(PKG_CONFIG) +INCS_TEST = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --cflags rsys sprs-local) +LIBS_TEST = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --libs rsys sprs-local)\ + -lm + +tests: library src/sprs-local.pc $(TEST_DEP) $(TEST_TGT) + @$(MAKE) -fMakefile.prs \ + $$(for i in $(TEST_DEP); do echo -f"$${i}"; done) \ + $$(for i in $(TEST_TGT); do echo -f"$${i}"; done) \ + test_list + +$(TEST_TGT): + @{ \ + exe="$$(basename "$@" ".t")"; \ + printf '%s: %s\n' "$${exe}" $(@:.t=.o); \ + printf 'test_list: %s\n' "$${exe}"; \ + } > $@ + +src/.config_sprs_test: config.mk + @echo "config done" > $@ + +clean_test: + rm -f $(TEST_DEP) $(TEST_OBJ) $(TEST_TGT) + for i in $(TEST_SRC); do rm -f "$$(basename "$${i}" ".c")"; done + rm -f src/.config_sprs_test src/sprs-local.pc + +test: tests + @err=0; \ + check() { name="$$1"; prog="$$2"; shift 2; \ + printf '%s' "$${name}"; \ + if PATH=./:"$${PATH}" "$${prog}" $$@ > /dev/null 2>&1; then \ + printf '\n'; \ + else \ + printf ': error %s\n' "$$?"; \ + err=$$((err+1)); \ + fi; \ + }; \ + \ + for i in $(TEST_SRC); do \ + test="$$(basename "$${i}" ".c")"; \ + if [ "$${test}" != "test_solparser" ]; then \ + check "$${test}" "$${test}"; \ + else \ + check test_solstice_solparser_ok_0 \ + test_solparser src/parser/yaml/test_ok_0.yaml; \ + check test_solstice_solparser_ok_1 \ + test_solparser src/parser/yaml/test_ok_1.yaml; \ + check test_solstice_solparser_ok_2 \ + test_solparser src/parser/yaml/test_ok_2.yaml; \ + check test_solstice_solparser_ok_3 \ + test_solparser src/parser/yaml/test_ok_3.yaml; \ + check test_solstice_solparser_ok_4 \ + test_solparser src/parser/yaml/test_ok_4.yaml; \ + check test_solstice_solparser_ok_5 \ + test_solparser src/parser/yaml/test_ok_5.yaml; \ + check test_solstice_solparser_ok_6 \ + test_solparser src/parser/yaml/test_ok_6.yaml; \ + check test_solstice_solparser_ok_7 \ + test_solparser src/parser/yaml/test_ok_7.yaml; \ + check test_solstice_solparser_ko_0 \ + test_solparser -e src/parser/yaml/test_ko_0.yaml; \ + fi \ + done; \ + \ + [ "$${err}" -eq 0 ] + +################################################################################ +# Regular tests +################################################################################ +CFLAGS_TEST = $(CFLAGS_EXE) $(INCS_TEST) +LDFLAGS_TEST = $(LDFLAGS_EXE) $(LIBS_TEST) + +$(TEST_DEP) : src/.config_sprs_test src/sprs-local.pc + @$(CC) $(CFLAGS_TEST) -MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@ + +$(TEST_OBJ) : src/.config_sprs_test src/sprs-local.pc + $(CC) $(CFLAGS_TEST) -c $(@:.o=.c) -o $@ + +test_solparser\ +test_solparser2\ +test_solparser3\ +test_solparser4\ +test_solparser5\ +test_solparser6\ +test_solparser7\ +test_solparser8\ +test_solparser_mirror\ +test_solparser_normal_map\ +test_solparser_spectrum\ +: src/.config_sprs_test src/sprs-local.pc $(LIBNAME) + $(CC) $(CFLAGS_TEST) -o $@ src/parser/$@.o $(LDFLAGS_TEST) diff --git a/Makefile.rcv b/Makefile.rcv @@ -0,0 +1,198 @@ +# Copyright (C) 2018-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 = libsrcv.a +LIBNAME_SHARED = libsrcv.so +LIBNAME = $(LIBNAME_$(LIB_TYPE)) + +default: library +all: library tests + +################################################################################ +# Build the library +################################################################################ +SRC =\ +src/receivers/srcvl.c +OBJ = $(SRC:.c=.o) +DEP = $(SRC:.c=.d) + +# Headers to configure +HDR= + +CFLAGS_LIB = $(CFLAGS_SO) $(INCS) -DSRCVL_SHARED_BUILD +LDFLAGS_LIB = $(LDFLAGS_SO) $(LIBS) + +$(LIBNAME_SHARED) $(DEP) $(OBJ): src/.config_rcv + +library: $(DEP) + @$(MAKE) -fMakefile.rcv $$(for i in $(DEP); do echo -f $${i}; done) \ + $$(if [ -n "$(LIBNAME)" ]; then \ + echo "$(LIBNAME)"; \ + else \ + echo "$(LIBNAME_SHARED)"; \ + fi) + +$(LIBNAME_SHARED): $(OBJ) + $(CC) $(CFLAGS_LIB) -o $@ $(OBJ) $(LDFLAGS_LIB) + +$(LIBNAME_STATIC): src/libsrcv.o + $(AR) -rc $@ $? + $(RANLIB) $@ + +src/libsrcv.o: src/.config_rcv $(OBJ) $(DEP) + $(LD) -r $(OBJ) -o $@ + $(OBJCOPY) $(OCPFLAGS) $@ + +$(DEP): $(HDR) src/srcv.pc + @$(CC) $(CFLAGS_LIB) -MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@ + +$(OBJ): $(HDR) src/srcv.pc + $(CC) $(CFLAGS_LIB) -c $(@:.o=.c) -o $@ + +################################################################################ +# Installation +################################################################################ +pkg: src/srcv.pc + +src/srcv.pc: srcv.pc.in src/.config_rcv + sed -e 's#@PREFIX@#$(PREFIX)#g'\ + -e 's#@VERSION@#$(VERSION)#g'\ + -e 's#@RSYS_VERSION@#$(RSYS_VERSION)#g'\ + -e 's#@YAML_VERSION@#$(YAML_VERSION)#g'\ + srcv.pc.in > $@ + +src/.config_rcv: config.mk + $(PKG_CONFIG) --atleast-version $(RSYS_VERSION) rsys + $(PKG_CONFIG) --atleast-version $(YAML_VERSION) yaml-0.1 + @echo "config done" > $@ + +install: library pkg + install() { mode="$$1"; prefix="$$2"; shift 2; \ + mkdir -p "$${prefix}"; \ + cp "$$@" "$${prefix}"; \ + chmod "$${mode}" "$${prefix}/$${@##*/}"; \ + }; \ + if [ "$(LIB_TYPE)" = "SHARED]" ; then \ + install 755 "$(DESTDIR)$(LIBPREFIX)" $(LIBNAME); \ + install 644 "$(DESTDIR)$(LIBPREFIX)/pkgconfig" src/score.pc; \ + fi; \ + +uninstall: + if [ "$(LIB_TYPE)" = "SHARED" ]; then \ + rm -f "$(DESTDIR)$(LIBPREFIX)/$(LIBNAME)" \ + rm -f "$(DESTDIR)$(LIBPREFIX)/pkgconfig/score.pc" \ + fi; \ + +clean: clean_test + rm -f $(DEP) $(OBJ) $(LIBNAME) + rm -f src/.config_rcv src/libsrcv.o src/srcv.pc + +lint: + +################################################################################ +# Tests +################################################################################ +TEST_SRC =\ + src/receivers/test_srcvl.c\ + src/receivers/test_srcvl2.c +TEST_OBJ =\ + $(TEST_SRC:.c=.o) +TEST_DEP =\ + $(TEST_SRC:.c=.d) +TEST_TGT =\ + $(TEST_SRC:.c=.t) + +src/srcv-local.pc: srcv.pc.in src/.config_srcv_test + sed -e '1d'\ + -e 's#^includedir=.*#includedir=./src/#'\ + -e 's#^libdir=.*#libdir=./#'\ + -e 's#@RSYS_VERSION@#$(RSYS_VERSION)#g'\ + -e 's#@YAML_VERSION@#$(YAML_VERSION)#g'\ + srcv.pc.in > $@ + +# Regular cflags +PKG_CONFIG_LOCAL = PKG_CONFIG_PATH="./src:$${PKG_CONFIG_PATH}" $(PKG_CONFIG) +INCS_TEST = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --cflags rsys srcv-local) +LIBS_TEST = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --libs rsys srcv-local)\ + -lm + +tests: library src/srcv-local.pc $(TEST_DEP) $(TEST_TGT) + @$(MAKE) -fMakefile.rcv \ + $$(for i in $(TEST_DEP); do echo -f"$${i}"; done) \ + $$(for i in $(TEST_TGT); do echo -f"$${i}"; done) \ + test_list + +$(TEST_TGT): + @{ \ + exe="$$(basename "$@" ".t")"; \ + printf '%s: %s\n' "$${exe}" $(@:.t=.o); \ + printf 'test_list: %s\n' "$${exe}"; \ + } > $@ + +src/.config_srcv_test: config.mk + @echo "config done" > $@ + +clean_test: + rm -f $(TEST_DEP) $(TEST_OBJ) $(TEST_TGT) + for i in $(TEST_SRC); do rm -f "$$(basename "$${i}" ".c")"; done + rm -f src/.config_srcv_test src/srcv-local.pc + +test: tests + @err=0; \ + check() { name="$$1"; prog="$$2"; shift 2; \ + printf '%s' "$${name}"; \ + if PATH=./:"$${PATH}" "$${prog}" $$@ > /dev/null 2>&1; then \ + printf '\n'; \ + else \ + printf ': error %s\n' "$$?"; \ + err=$$((err+1)); \ + fi; \ + }; \ + \ + for i in $(TEST_SRC); do \ + test="$$(basename "$${i}" ".c")"; \ + if [ "$${test}" != "test_srcvl" ]; then \ + check "$${test}" "$${test}"; \ + else \ + check test_srcvl_ok \ + test_srcvl src/receivers/yaml/test_ok.yaml; \ + check test_srcvl_ko \ + test_srcvl -e src/receivers/yaml/test_ko.yaml; \ + fi \ + done; \ + \ + [ "$${err}" -eq 0 ] + +################################################################################ +# Regular tests +################################################################################ +CFLAGS_TEST = $(CFLAGS_EXE) $(INCS_TEST) +LDFLAGS_TEST = $(LDFLAGS_EXE) $(LIBS_TEST) + +$(TEST_DEP) : src/.config_srcv_test src/srcv-local.pc + @$(CC) $(CFLAGS_TEST) -MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@ + +$(TEST_OBJ) : src/.config_srcv_test src/srcv-local.pc + $(CC) $(CFLAGS_TEST) -c $(@:.o=.c) -o $@ + +test_srcvl\ +test_srcvl2\ +: src/.config_srcv_test src/srcv-local.pc $(LIBNAME) + $(CC) $(CFLAGS_TEST) -o $@ src/receivers/$@.o $(LDFLAGS_TEST) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt @@ -1,201 +0,0 @@ -# Copyright (C) 2018, 2019, 2021 |Meso|Star> (contact@meso-star.com) -# Copyright (C) 2016-2018 CNRS -# -# 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(solstice C) -enable_testing() - -option(NO_TEST "Do not build tests" OFF) - -if(CMAKE_HOST_UNIX) - set(SOLSTICE_DOC "TROFF" CACHE STRING - "Type of documentation to generate and install.") -else() - set(SOLSTICE_DOC "HTML" CACHE STRING - "Type of documentation to generate and install.") -endif() - -set_property(CACHE SOLSTICE_DOC PROPERTY STRINGS - "HTML" - "TROFF" - "TROFF & HTML" - "NONE") - -set(SOLSTICE_SOURCE_DIR ${PROJECT_SOURCE_DIR}/../src/) - -################################################################################ -# Check dependencies -################################################################################ -get_filename_component(_current_source_dir ${CMAKE_CURRENT_LIST_FILE} PATH) -set(LibYAML_DIR ${_current_source_dir}/) - -find_package(LibYAML REQUIRED) -find_package(RCMake 0.4 REQUIRED) -find_package(RSys 0.10 REQUIRED) -find_package(SolAnim 0.2.3 REQUIRED) -find_package(SolSolver 0.9 REQUIRED) -find_package(Star3DUT 0.3.1 REQUIRED) -find_package(StarSP 0.12 REQUIRED) -find_package(StarSTL 0.3.3 REQUIRED) - -if(MSVC) - find_package(MuslGetopt REQUIRED) - include_directories(${MuslGetopt_INCLUDE_DIR}) -endif() - -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${RCMAKE_SOURCE_DIR}) -include(rcmake) -include(rcmake_runtime) - -include_directories( - ${RSys_INCLUDE_DIR} - ${MuslGetopt_INCLUDE_DIR} - ${SolAnim_INCLUDE_DIR} - ${SolSolver_INCLUDE_DIR} - ${StarSP_INCLUDE_DIR} - ${StarSTL_INCLUDE_DIR} - ${Star3DUT_INCLUDE_DIR} - ${CMAKE_CURRENT_BINARY_DIR}) - -################################################################################ -# Build subprojects -################################################################################ -if(NOT SOLSTICE_DOC STREQUAL "NONE") - add_subdirectory(doc) -endif() -add_subdirectory(parser) -add_subdirectory(receivers) - -################################################################################ -# Generate files -################################################################################ -set(SOLSTICE_ARGS_DEFAULT_NREALISATIONS "10000") -set(SOLSTICE_ARGS_DEFAULT_CAMERA_POS "0,0,0") -set(SOLSTICE_ARGS_DEFAULT_CAMERA_TGT "0,0,-1") -set(SOLSTICE_ARGS_DEFAULT_CAMERA_UP "0,1,0") -set(SOLSTICE_ARGS_DEFAULT_CAMERA_FOV "70") # In degrees -set(SOLSTICE_ARGS_DEFAULT_IMG_WIDTH "800") -set(SOLSTICE_ARGS_DEFAULT_IMG_HEIGHT "600") -set(SOLSTICE_ARGS_DEFAULT_IMG_SPP "1") - -configure_file(${SOLSTICE_SOURCE_DIR}/solstice_args.h.in - ${CMAKE_CURRENT_BINARY_DIR}/solstice_args.h @ONLY) -configure_file(${SOLSTICE_SOURCE_DIR}/../doc/solstice.1.txt.in - ${CMAKE_CURRENT_BINARY_DIR}/doc/solstice.1.txt @ONLY) - -set(VERSION_MAJOR 0) -set(VERSION_MINOR 9) -set(VERSION_PATCH 1) -set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) - -configure_file(${SOLSTICE_SOURCE_DIR}/solstice_version.h.in - ${CMAKE_CURRENT_BINARY_DIR}/solstice_version.h @ONLY) - -################################################################################ -# Configure and define targets -################################################################################ -set(SOLSTICE_FILES_SRC - solstice.c - solstice_args.c - solstice_atmosphere.c - solstice_draw.c - solstice_dump.c - solstice_entity.c - solstice_material.c - solstice_node.c - solstice_object.c - solstice_solve.c - solstice_spectrum.c - solstice_sun.c - solstice_sun_spectrum.c) -set(SOLSTICE_FILES_INC - solstice.h - solstice_args.h.in - solstice_c.h - solstice_sun_spectrum.h - solstice_version.h.in) -set(SOLSTICE_FILES_DOC COPYING README.md) - -# Prepend each file in the `SOLSTICE_FILES_<SRC|INC>' list by `SOLSTICE_SOURCE_DIR' -rcmake_prepend_path(SOLSTICE_FILES_SRC ${SOLSTICE_SOURCE_DIR}) -rcmake_prepend_path(SOLSTICE_FILES_INC ${SOLSTICE_SOURCE_DIR}) -rcmake_prepend_path(SOLSTICE_FILES_DOC ${PROJECT_SOURCE_DIR}/../) - -if(CMAKE_COMPILER_IS_GNUCC) - set(MATH_LIB m) -endif() - -if(MSVC) - set(GETOPT_LIB MuslGetopt) -endif() - -add_library(sollib STATIC ${SOLSTICE_FILES_SRC} ${SOLSTICE_FILES_INC}) -add_executable(solstice ${SOLSTICE_SOURCE_DIR}/main.c) -target_link_libraries(solstice ${MATH_LIB} ${GETOPT_LIB} - LibYAML RSys sollib solparser SolAnim SolSolver srcvl Star3DUT StarSP StarSTL) -set_target_properties(solstice PROPERTIES - VERSION ${VERSION} - SOVERSION ${VERSION_MAJOR}) -rcmake_copy_runtime_libraries(solstice) - -################################################################################ -# Tests -################################################################################ -if(NOT NO_TEST) - function(build_test _name) - add_executable(${_name} - ${SOLSTICE_SOURCE_DIR}/${_name}.c - ${SOLSTICE_SOURCE_DIR}/test_solstice_utils.h) - target_link_libraries(${_name} ${MATH_LIB} ${GETOPT_LIB} RSys sollib) - endfunction() - - function(new_test _name) - build_test(${_name}) - add_test(${_name} ${_name}) - endfunction() - - new_test(test_solstice_args) - - build_test(test_solstice_simulation) - function(add_test_simulation _name) - add_test(NAME test_solstice_simulation_${_name} - COMMAND test_solstice_simulation - $<TARGET_FILE:solstice> - ${SOLSTICE_SOURCE_DIR}/../yaml/ - ${_name}) - endfunction() - - add_test_simulation(beam_down) - add_test_simulation(test01) - add_test_simulation(test02) - add_test_simulation(test03) - add_test_simulation(test04) - add_test_simulation(test05) - add_test_simulation(test06) - add_test_simulation(test07) - add_test_simulation(test08) - -endif() - -################################################################################ -# Define output & install directories -################################################################################ -install(TARGETS solstice - ARCHIVE DESTINATION bin - LIBRARY DESTINATION lib - RUNTIME DESTINATION bin) -install(FILES ${SOLSTICE_FILES_DOC} DESTINATION share/doc/solstice) -rcmake_install_runtime_libraries(solstice) diff --git a/cmake/LibYAMLConfig.cmake b/cmake/LibYAMLConfig.cmake @@ -1,63 +0,0 @@ -# Copyright (C) 2018, 2019, 2021 |Meso|Star> (contact@meso-star.com) -# Copyright (C) 2016-2018 CNRS -# -# 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) - -# Try to find the LibYAML devel. Once done this will define: -# - LibYAML_FOUND: system has LibYAML -# - LibYAML_INCLUDE_DIR: the include directory -# - LibYAML: Link this to use LibYAML - -find_path(LibYAML_INCLUDE_DIR yaml.h) -unset(LibYAML_LIBRARY CACHE) -unset(LibYAML_LIBRARY_DEBUG CACHE) -unset(LibYAML_LIBRARY_RELWITHDEBINFO CACHE) -unset(LibYAML_LIBRARY_MINSIZEREL CACHE) -find_library(LibYAML_LIBRARY yaml DOC - "Path to the LibYAML library used during release builds." - PATH_SUFFIXES bin) -find_library(LibYAML_LIBRARY_DEBUG yaml-dbg DOC - "Path to the LibYAML library used during debug builds." - PATH_SUFFIXES bin) -if(NOT LibYAML_LIBRARY_DEBUG) - set(LibYAML_LIBRARY_DEBUG ${LibYAML_LIBRARY}) -endif() - -# Create the imported library target -if(CMAKE_HOST_WIN32) - set(_property IMPORTED_IMPLIB) -else(CMAKE_HOST_WIN32) - set(_property IMPORTED_LOCATION) -endif(CMAKE_HOST_WIN32) -add_library(LibYAML SHARED IMPORTED) -set_target_properties(LibYAML PROPERTIES - ${_property} ${LibYAML_LIBRARY_DEBUG} - ${_property}_DEBUG ${LibYAML_LIBRARY_DEBUG} - ${_property}_RELEASE ${LibYAML_LIBRARY}) - -# Check the package -include(FindPackageHandleStandardArgs) -if(CMAKE_HOST_WIN32) - FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibYAML DEFAULT_MSG - LibYAML_INCLUDE_DIR - LibYAML_LIBRARY_DEBUG - LibYAML_LIBRARY) -else() - FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibYAML DEFAULT_MSG - LibYAML_INCLUDE_DIR - LibYAML_LIBRARY) -endif() - diff --git a/cmake/doc/CMakeLists.txt b/cmake/doc/CMakeLists.txt @@ -1,151 +0,0 @@ -# Copyright (C) 2018, 2019, 2021 |Meso|Star> (contact@meso-star.com) -# Copyright (C) 2016-2018 CNRS -# -# 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) - -string(REGEX MATCH ".*HTML.*" _html ${SOLSTICE_DOC}) -string(REGEX MATCH ".*ROFF.*" _roff ${SOLSTICE_DOC}) - -set(SOLSTICE_DOC_DIR ${PROJECT_SOURCE_DIR}/../doc) - -################################################################################ -# Look for asciidoc and a2x programs -################################################################################ -if(_html) - find_program(ASCIIDOC NAMES asciidoc asciidoc.py) - if(NOT ASCIIDOC) - unset(_html) - message(WARNING - "The `asciidoc' program is missing. " - "The solstice HTML documentation cannot be generated.") - endif() -endif() - -if(_roff) - find_program(A2X NAMES a2x a2x.py) - if(NOT A2X) - unset(_roff) - message(WARNING - "The `a2x' program is missing. " - "The solstice man pages cannot be generated.") - endif() -endif() - -################################################################################ -# Copy doc files -################################################################################ -set(MAN_NAMES - solstice-input.5 - solstice-output.5 - solstice-receiver.5) - -if(_roff OR _html) - set(MAN_FILES) - foreach(_name IN LISTS MAN_NAMES) - set(_src ${SOLSTICE_DOC_DIR}/${_name}.txt) - set(_dst ${CMAKE_CURRENT_BINARY_DIR}/${_name}.txt) - add_custom_command( - OUTPUT ${_dst} - COMMAND ${CMAKE_COMMAND} -E copy ${_src} ${_dst} - DEPENDS ${_src} - COMMENT "Copy the asciidoc ${_src}" - VERBATIM) - list(APPEND MAN_FILES ${_dst}) - endforeach() - add_custom_target(man-copy ALL DEPENDS ${MAN_FILES}) -endif() - -list(APPEND MAN_NAMES solstice.1) - -################################################################################ -# ROFF man pages -################################################################################ -if(_roff) - set(A2X_OPTS -dmanpage -fmanpage) - set(MAN_FILES) - set(MAN5_FILES) - set(MAN1_FILES) - foreach(_name IN LISTS MAN_NAMES) - set(_man ${CMAKE_CURRENT_BINARY_DIR}/${_name}) - set(_txt ${CMAKE_CURRENT_BINARY_DIR}/${_name}.txt) - - add_custom_command( - OUTPUT ${_man} - COMMAND ${A2X} ${A2X_OPTS} ${_txt} - DEPENDS man-copy ${_txt} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMENT "Build ROFF man page ${_man}" - VERBATIM) - list(APPEND MAN_FILES ${_man}) - - string(REGEX MATCH "^.*.5$" _man5 ${_man}) - string(REGEX MATCH "^.*.1$" _man1 ${_man}) - if(_man1) - list(APPEND MAN1_FILES ${_man1}) - elseif(_man5) - list(APPEND MAN5_FILES ${_man5}) - else() - message(FATAL_ERROR "Unexpected man type") - endif() - endforeach() - add_custom_target(man-roff ALL DEPENDS ${MAN_FILES}) - - install(FILES ${MAN1_FILES} DESTINATION share/man/man1) - install(FILES ${MAN5_FILES} DESTINATION share/man/man5) -endif() - -################################################################################ -# HTML documentation -################################################################################ -if(_html) - set(ASCIIDOC_OPTS - -bxhtml11 - -dmanpage - --attribute themedir=${SOLSTICE_DOC_DIR} - --theme=solstice-man) - - set(MAN_FILES) - set(MAN5_FILES) - set(MAN1_FILES) - foreach(_name IN LISTS MAN_NAMES) - set(_man ${CMAKE_CURRENT_BINARY_DIR}/${_name}.html) - set(_txt ${CMAKE_CURRENT_BINARY_DIR}/${_name}.txt) - - add_custom_command( - OUTPUT ${_man} - COMMAND ${ASCIIDOC} ${ASCIIDOC_OPTS} ${_txt} - DEPENDS man-copy ${_txt} ${SOLSTICE_DOC_DIR}/solstice-man.css - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMENT "Build HTML man page ${_man}" - VERBATIM) - list(APPEND MAN_FILES ${_man}) - - string(REGEX MATCH "^.*.5.html$" _man5 ${_man}) - string(REGEX MATCH "^.*.1.html$" _man1 ${_man}) - if(_man1) - list(APPEND MAN1_FILES ${_man1}) - elseif(_man5) - list(APPEND MAN5_FILES ${_man5}) - else() - message(FATAL_ERROR "Unexpected man type") - endif() - endforeach() - add_custom_target(man-html ALL DEPENDS ${MAN_FILES}) - - install(FILES ${MAN1_FILES} DESTINATION share/doc/solstice/html) - install(FILES ${MAN5_FILES} DESTINATION share/doc/solstice/html) -endif() - diff --git a/cmake/parser/CMakeLists.txt b/cmake/parser/CMakeLists.txt @@ -1,121 +0,0 @@ -# Copyright (C) 2018, 2019, 2021 |Meso|Star> (contact@meso-star.com) -# Copyright (C) 2016-2018 CNRS -# -# 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(solstice-parser C) - -set(SOLPARSER_SOURCE_DIR ${PROJECT_SOURCE_DIR}/../../src/parser) - -################################################################################ -# Define include directories -################################################################################ -include_directories( - ${LibYAML_INCLUDE_DIR} - ${RSys_INCLUDE_DIR} - ${SOLPARSER_SOURCE_DIR}/../) - -################################################################################ -# Configure and define targets -################################################################################ -set(SOLPARSER_FILES_SRC - solparser.c - solparser_atmosphere.c - solparser_entity.c - solparser_image.c - solparser_geometry.c - solparser_material.c - solparser_medium.c - solparser_mtl_data.c - solparser_pivot.c - solparser_sun.c - solparser_spectrum.c) -set(SOLPARSER_FILES_INC - solparser.h - solparser_c.h - solparser_atmosphere.h - solparser_entity.h - solparser_geometry.h - solparser_image.h - solparser_material.h - solparser_medium.h - solparser_mtl_data.h - solparser_pivot.h - solparser_shape.h - solparser_sun.h - solparser_spectrum.h) - -# Prepend each file in the `SOLPARSER_FILES_<SRC|INC>' list by `SOLPARSER_SOURCE_DIR' -rcmake_prepend_path(SOLPARSER_FILES_SRC ${SOLPARSER_SOURCE_DIR}) -rcmake_prepend_path(SOLPARSER_FILES_INC ${SOLPARSER_SOURCE_DIR}) -rcmake_prepend_path(SOLPARSER_FILES_DOC ${PROJECT_SOURCE_DIR}/../) - -if(CMAKE_COMPILER_IS_GNUCC) - set(MATH_LIB m) -endif() - -add_library(solparser STATIC ${SOLPARSER_FILES_SRC} ${SOLPARSER_FILES_INC}) -target_link_libraries(solparser LibYAML ${MATH_LIB}) - -################################################################################ -# Tests -################################################################################ -if(NOT NO_TEST) - function(build_test _name) - add_executable(${_name} - ${SOLPARSER_SOURCE_DIR}/${_name}.c - ${SOLPARSER_SOURCE_DIR}/../test_solstice_utils.h) - target_link_libraries(${_name} LibYAML ${MATH_LIB} RSys solparser) - endfunction() - - function(new_test _name) - build_test(${_name}) - add_test(${_name} ${_name}) - endfunction() - - build_test(test_solparser) - add_test(test_solparser_ok_0 test_solparser - ${SOLPARSER_SOURCE_DIR}/yaml/test_ok_0.yaml) - add_test(test_solparser_ok_1 test_solparser - ${SOLPARSER_SOURCE_DIR}/yaml/test_ok_1.yaml) - add_test(test_solparser_ok_2 test_solparser - ${SOLPARSER_SOURCE_DIR}/yaml/test_ok_2.yaml) - add_test(test_solparser_ok_3 test_solparser - ${SOLPARSER_SOURCE_DIR}/yaml/test_ok_3.yaml) - add_test(test_solparser_ok_4 test_solparser - ${SOLPARSER_SOURCE_DIR}/yaml/test_ok_4.yaml) - add_test(test_solparser_ok_5 test_solparser - ${SOLPARSER_SOURCE_DIR}/yaml/test_ok_5.yaml) - add_test(test_solparser_ok_6 test_solparser - ${SOLPARSER_SOURCE_DIR}/yaml/test_ok_6.yaml) - add_test(test_solparser_ok_7 test_solparser - ${SOLPARSER_SOURCE_DIR}/yaml/test_ok_7.yaml) - add_test(test_solparser_ko test_solparser -e - ${SOLPARSER_SOURCE_DIR}/yaml/test_ko_0.yaml) - - new_test(test_solparser2) - new_test(test_solparser3) - new_test(test_solparser4) - new_test(test_solparser5) - new_test(test_solparser6) - new_test(test_solparser7) - new_test(test_solparser8) - new_test(test_solparser_normal_map) - new_test(test_solparser_spectrum) - new_test(test_solparser_mirror) - - rcmake_copy_runtime_libraries(test_solparser) -endif() - diff --git a/cmake/receivers/CMakeLists.txt b/cmake/receivers/CMakeLists.txt @@ -1,73 +0,0 @@ -# Copyright (C) 2018, 2019, 2021 |Meso|Star> (contact@meso-star.com) -# Copyright (C) 2016-2018 CNRS -# -# 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(srcvl C) - -set(SRCVL_SOURCE_DIR ${PROJECT_SOURCE_DIR}/../../src/receivers) - -################################################################################ -# Define include directories -################################################################################ -include_directories( - ${LibYAML_INCLUDE_DIR} - ${RSys_INCLUDE_DIR} - ${SRCVL_SOURCE_DIR}/../) - -################################################################################ -# Configure and define targets -################################################################################ -set(SRCVL_FILES_SRC srcvl.c) -set(SRCVL_FILES_INC srcvl.h) - -rcmake_prepend_path(SRCVL_FILES_SRC ${SRCVL_SOURCE_DIR}) -rcmake_prepend_path(SRCVL_FILES_INC ${SRCVL_SOURCE_DIR}) - -if(CMAKE_COMPILER_IS_GNUCC) - set(MATH_LIB m) -endif() - -add_library(srcvl STATIC ${SRCVL_FILES_SRC} ${SRCVL_FILES_INC}) -target_link_libraries(srcvl LibYAML ${MATH_LIB}) - -################################################################################ -# Tests -################################################################################ -if(NOT NO_TEST) - function(build_test _name) - add_executable(${_name} - ${SRCVL_SOURCE_DIR}/${_name}.c - ${SRCVL_SOURCE_DIR}/../test_solstice_utils.h) - target_link_libraries(${_name} LibYAML ${MATH_LIB} RSys srcvl) - endfunction() - - function(new_test _name) - build_test(${_name}) - add_test(${_name} ${_name}) - endfunction() - - build_test(test_srcvl) - add_test(test_srcvl_ok test_srcvl - ${SRCVL_SOURCE_DIR}/yaml/test_ok.yaml) - add_test(test_srvvl_ko test_srcvl -e - ${SRCVL_SOURCE_DIR}/yaml/test_ko.yaml) - - new_test(test_srcvl2) - rcmake_copy_runtime_libraries(test_srcvl) - -endif() - - diff --git a/config.mk b/config.mk @@ -0,0 +1,104 @@ +VERSION_MAJOR = 0 +VERSION_MINOR = 9 +VERSION_PATCH = 1 +VERSION = $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH) + +PREFIX = /usr/local +LIBPREFIX = $(PREFIX)/lib +INCPREFIX = $(PREFIX)/include + +#LIB_TYPE = SHARED +LIB_TYPE = STATIC + +BUILD_TYPE = RELEASE +#BUILD_TYPE = DEBUG + +################################################################################ +# Defaults +################################################################################ +SOLSTICE_ARGS_DEFAULT_NREALISATIONS = 10000 +SOLSTICE_ARGS_DEFAULT_CAMERA_POS = 0,0,0 +SOLSTICE_ARGS_DEFAULT_CAMERA_TGT = 0,0,-1 +SOLSTICE_ARGS_DEFAULT_CAMERA_UP = 0,1,0 +SOLSTICE_ARGS_DEFAULT_CAMERA_FOV = 70 +SOLSTICE_ARGS_DEFAULT_IMG_WIDTH = 800 +SOLSTICE_ARGS_DEFAULT_IMG_HEIGHT = 600 +SOLSTICE_ARGS_DEFAULT_IMG_SPP = 1 + +################################################################################ +# 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.15 +S3DUT_VERSION = 0.4 +SSP_VERSION = 0.15 +SSTL_VERSION = 0.7 +YAML_VERSION = 0.2 +SSOL_VERSION = 0.9 +SANIM_VERSION = 0.2 + +INCS = $$($(PKG_CONFIG) $(PCFLAGS) --cflags rsys s3dut star-sp sstl yaml-0.1 ssol sanim)\ + -fopenmp +LIBS = $$($(PKG_CONFIG) $(PCFLAGS) --libs rsys s3dut star-sp sstl yaml-0.1 ssol sanim)\ + -fopenmp -lm + +################################################################################ +# 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 = -O2 -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/score.pc.in b/score.pc.in @@ -0,0 +1,19 @@ +prefix=@PREFIX@ +includedir=${prefix}/include +libdir=${prefix}/lib + +Requires: \ + rsys >= @RSYS_VERSION@ +Requires.private:\ + s3dut >= @S3DUT_VERSION@,\ + star-sp >= @SSP_VERSION@,\ + sstl >= @SSTL_VERSION@,\ + yaml-0.1 >= @YAML_VERSION@,\ + ssol >= @SSOL_VERSION@,\ + sanim >= @SANIM_VERSION@ +Name: score +Description: Solstice Core +Version: @VERSION@ +Libs: -L${libdir} -lscore +Libs.private: -fopenmp -lm +CFlags: -I${includedir} -fopenmp diff --git a/sprs.pc.in b/sprs.pc.in @@ -0,0 +1,14 @@ +prefix=@PREFIX@ +includedir=${prefix}/include +libdir=${prefix}/lib + +Requires: \ + rsys >= @RSYS_VERSION@ +Requires.private:\ + yaml-0.1 >= @YAML_VERSION@ +Name: sprs +Description: Solstice Parser +Version: @VERSION@ +Libs: -L${libdir} -lsprs +Libs.private: -lm +CFlags: -I${includedir} diff --git a/src/parser/solparser.h b/src/parser/solparser.h @@ -22,6 +22,15 @@ #include <rsys/rsys.h> #include <stddef.h> +/* Library symbol management */ +#if defined(SPRSR_SHARED_BUILD) /* Build shared library */ + #define SPRSR_API extern EXPORT_SYM +#elif defined(SPRSR_STATIC) /* Use/build static library */ + #define SPRSR_API extern LOCAL_SYM +#else /* Use shared library */ + #define SPRSR_API extern IMPORT_SYM +#endif + struct mem_allocator; struct solparser; @@ -46,193 +55,193 @@ struct solparser_geometry_iterator { /******************************************************************************* * Solstice parser API. ******************************************************************************/ -extern LOCAL_SYM res_T +SPRSR_API res_T solparser_create (struct mem_allocator* allocator, /* May be NULL <=> use default allocator */ struct solparser** parser); -extern LOCAL_SYM void +SPRSR_API void solparser_ref_get (struct solparser* parser); -extern LOCAL_SYM void +SPRSR_API void solparser_ref_put (struct solparser* parser); -extern LOCAL_SYM res_T +SPRSR_API res_T solparser_setup (struct solparser* parser, const char* stream_name, /* May be NULL */ FILE* stream); /* Return RES_BAD_OP if there is no more YAML document to parse */ -extern LOCAL_SYM res_T +SPRSR_API res_T solparser_load (struct solparser* parser); /* Return NULL if no entity is found */ -extern LOCAL_SYM const struct solparser_anchor* +SPRSR_API const struct solparser_anchor* solparser_find_anchor (struct solparser* parser, const char* anchor_name); /* Return NULL if no entity is found */ -extern LOCAL_SYM const struct solparser_entity* +SPRSR_API const struct solparser_entity* solparser_find_entity (struct solparser* parser, const char* entity_name); -extern LOCAL_SYM const struct solparser_anchor* +SPRSR_API const struct solparser_anchor* solparser_get_anchor (const struct solparser* parser, const struct solparser_anchor_id anchor); -extern LOCAL_SYM const struct solparser_entity* +SPRSR_API const struct solparser_entity* solparser_get_entity (const struct solparser* parser, const struct solparser_entity_id entity); -extern LOCAL_SYM const struct solparser_image* +SPRSR_API const struct solparser_image* solparser_get_image (const struct solparser* parser, const struct solparser_image_id image); -extern LOCAL_SYM const struct solparser_geometry* +SPRSR_API const struct solparser_geometry* solparser_get_geometry (const struct solparser* parser, const struct solparser_geometry_id geom); -extern LOCAL_SYM const struct solparser_material* +SPRSR_API const struct solparser_material* solparser_get_material (const struct solparser* parser, const struct solparser_material_id mtl); -extern LOCAL_SYM const struct solparser_material_double_sided* +SPRSR_API const struct solparser_material_double_sided* solparser_get_material_double_sided (const struct solparser* parser, const struct solparser_material_double_sided_id mtl2); -extern LOCAL_SYM const struct solparser_material_dielectric* +SPRSR_API const struct solparser_material_dielectric* solparser_get_material_dielectric (const struct solparser* parser, const struct solparser_material_dielectric_id dielectric); -extern LOCAL_SYM const struct solparser_material_matte* +SPRSR_API const struct solparser_material_matte* solparser_get_material_matte (const struct solparser* parser, const struct solparser_material_matte_id matte); -extern LOCAL_SYM const struct solparser_material_mirror* +SPRSR_API const struct solparser_material_mirror* solparser_get_material_mirror (const struct solparser* parser, const struct solparser_material_mirror_id mirror); -extern LOCAL_SYM const struct solparser_material_thin_dielectric* +SPRSR_API const struct solparser_material_thin_dielectric* solparser_get_material_thin_dielectric (const struct solparser* parser, const struct solparser_material_thin_dielectric_id thin_dielectric); -extern LOCAL_SYM const struct solparser_medium* +SPRSR_API const struct solparser_medium* solparser_get_medium (const struct solparser* parser, const struct solparser_medium_id medium); -extern LOCAL_SYM const struct solparser_object* +SPRSR_API const struct solparser_object* solparser_get_object (const struct solparser* parser, const struct solparser_object_id obj); -extern LOCAL_SYM const struct solparser_shape* +SPRSR_API const struct solparser_shape* solparser_get_shape (const struct solparser* parser, const struct solparser_shape_id shape); -extern LOCAL_SYM const struct solparser_shape_cuboid* +SPRSR_API const struct solparser_shape_cuboid* solparser_get_shape_cuboid (const struct solparser* parser, const struct solparser_shape_cuboid_id cuboid); -extern LOCAL_SYM const struct solparser_shape_cylinder* +SPRSR_API const struct solparser_shape_cylinder* solparser_get_shape_cylinder (const struct solparser* parser, const struct solparser_shape_cylinder_id cylinder); -extern LOCAL_SYM const struct solparser_shape_imported_geometry* +SPRSR_API const struct solparser_shape_imported_geometry* solparser_get_shape_obj (const struct solparser* parser, const struct solparser_shape_imported_geometry_id impgeom); -extern LOCAL_SYM const struct solparser_shape_paraboloid* +SPRSR_API const struct solparser_shape_paraboloid* solparser_get_shape_parabol (const struct solparser* parser, const struct solparser_shape_paraboloid_id paraboloid); -extern LOCAL_SYM const struct solparser_shape_paraboloid* +SPRSR_API const struct solparser_shape_paraboloid* solparser_get_shape_parabolic_cylinder (const struct solparser* parser, const struct solparser_shape_paraboloid_id paraboloid); -extern LOCAL_SYM const struct solparser_shape_hyperboloid* +SPRSR_API const struct solparser_shape_hyperboloid* solparser_get_shape_hyperbol (const struct solparser* parser, const struct solparser_shape_hyperboloid_id hyperboloid); -extern LOCAL_SYM const struct solparser_shape_hemisphere* +SPRSR_API const struct solparser_shape_hemisphere* solparser_get_shape_hemisphere (const struct solparser* parser, const struct solparser_shape_hemisphere_id hemisphere); -extern LOCAL_SYM const struct solparser_shape_plane* +SPRSR_API const struct solparser_shape_plane* solparser_get_shape_plane (const struct solparser* parser, const struct solparser_shape_plane_id plane); -extern LOCAL_SYM const struct solparser_shape_sphere* +SPRSR_API const struct solparser_shape_sphere* solparser_get_shape_sphere (const struct solparser* parser, const struct solparser_shape_sphere_id sphere); -extern LOCAL_SYM const struct solparser_shape_imported_geometry* +SPRSR_API const struct solparser_shape_imported_geometry* solparser_get_shape_stl (const struct solparser* parser, const struct solparser_shape_imported_geometry_id impgeom); -extern LOCAL_SYM const struct solparser_sun* +SPRSR_API const struct solparser_sun* solparser_get_sun (const struct solparser* parser); -extern LOCAL_SYM const struct solparser_atmosphere* +SPRSR_API const struct solparser_atmosphere* solparser_get_atmosphere (const struct solparser* parser); -extern LOCAL_SYM const struct solparser_x_pivot* +SPRSR_API const struct solparser_x_pivot* solparser_get_x_pivot (const struct solparser* parser, const struct solparser_pivot_id x_pivot); -extern LOCAL_SYM const struct solparser_zx_pivot* +SPRSR_API const struct solparser_zx_pivot* solparser_get_zx_pivot (const struct solparser* parser, const struct solparser_pivot_id zx_pivot); -extern LOCAL_SYM const struct solparser_spectrum* +SPRSR_API const struct solparser_spectrum* solparser_get_spectrum (const struct solparser* parser, const struct solparser_spectrum_id spectrum); -extern LOCAL_SYM int +SPRSR_API int solparser_has_spectrum (const struct solparser* parser); /******************************************************************************* * Entity interator ******************************************************************************/ -extern LOCAL_SYM void +SPRSR_API void solparser_entity_iterator_begin (struct solparser* parser, struct solparser_entity_iterator* it); -extern LOCAL_SYM void +SPRSR_API void solparser_entity_iterator_end (struct solparser* parser, struct solparser_entity_iterator* it); @@ -265,12 +274,12 @@ solparser_entity_iterator_get(struct solparser_entity_iterator* it) /******************************************************************************* * Material iterator ******************************************************************************/ -extern LOCAL_SYM void +SPRSR_API void solparser_material_iterator_begin (struct solparser* parser, struct solparser_material_iterator* it); -extern LOCAL_SYM void +SPRSR_API void solparser_material_iterator_end (struct solparser* parser, struct solparser_material_iterator* it); @@ -303,11 +312,11 @@ solparser_material_iterator_get(struct solparser_material_iterator* it) /******************************************************************************* * Geometry iterator ******************************************************************************/ -extern LOCAL_SYM void +SPRSR_API void solparser_geometry_iterator_begin (struct solparser* parser, struct solparser_geometry_iterator* it); -extern LOCAL_SYM void +SPRSR_API void solparser_geometry_iterator_end (struct solparser* parser, struct solparser_geometry_iterator* it); diff --git a/src/receivers/srcvl.h b/src/receivers/srcvl.h @@ -19,6 +19,15 @@ #include <rsys/rsys.h> +/* Library symbol management */ +#if defined(SRCVL_SHARED_BUILD) /* Build shared library */ + #define SRCVL_API extern EXPORT_SYM +#elif defined(SRCVL_STATIC) /* Use/build static library */ + #define SRCVL_API extern LOCAL_SYM +#else /* Use shared library */ + #define SRCVL_API extern IMPORT_SYM +#endif + enum srcvl_side { SRCVL_FRONT = BIT(0), SRCVL_BACK = BIT(1), @@ -44,35 +53,35 @@ struct srcvl; /******************************************************************************* * Solstice Receiver API ******************************************************************************/ -extern LOCAL_SYM res_T +SRCVL_API res_T srcvl_create (struct mem_allocator* allocator, /* May be NULL <=> use default allocator */ struct srcvl** rcvl); -extern LOCAL_SYM void +SRCVL_API void srcvl_ref_get (struct srcvl* rcvl); -extern LOCAL_SYM void +SRCVL_API void srcvl_ref_put (struct srcvl* rcvl); -extern LOCAL_SYM res_T +SRCVL_API res_T srcvl_setup_stream (struct srcvl* rcvl, const char* stream_name, /* May be NULL */ FILE* stream); /* Return RES_BAD_OP if there is no more YAML document to parse */ -extern LOCAL_SYM res_T +SRCVL_API res_T srcvl_load (struct srcvl* rcvl); -extern LOCAL_SYM size_t +SRCVL_API size_t srcvl_count (const struct srcvl* rcvl); -extern LOCAL_SYM void +SRCVL_API void srcvl_get (const struct srcvl* rcvl, const size_t i, diff --git a/src/score.h b/src/score.h @@ -0,0 +1,60 @@ +/* Copyright (C) 2018-2026 |Meso|Star> (contact@meso-star.com) + * Copyright (C) 2016-2018 CNRS + * + * 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/>. */ + +#ifndef SCORE_H +#define SCORE_H + +#include <rsys/rsys.h> + +struct mem_allocator; +struct solstice; +struct solstice_args; + +/* Library symbol management */ +#if defined(SCORE_SHARED_BUILD) /* Build shared library */ + #define SCORE_API extern EXPORT_SYM +#elif defined(SCORE_STATIC) /* Use/build static library */ + #define SCORE_API extern LOCAL_SYM +#else /* Use shared library */ + #define SCORE_API extern IMPORT_SYM +#endif + +SCORE_API res_T +solstice_init + (struct mem_allocator* allocator, /* May be NULL <=> use default allocator */ + const struct solstice_args* args, + struct solstice* solstice); + +SCORE_API void +solstice_release + (struct solstice* solstice); + +SCORE_API res_T +solstice_run + (struct solstice* solstice); + +SCORE_API res_T +solstice_args_init + (struct solstice_args* args, + const int argc, + char** argv); + +SCORE_API void +solstice_args_release + (struct solstice_args* args); + +#endif /* SCORE_H */ + diff --git a/src/solstice.h b/src/solstice.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2018, 2019, 2021 |Meso|Star> (contact@meso-star.com) +/* Copyright (C) 2018-2026 |Meso|Star> (contact@meso-star.com) * Copyright (C) 2016-2018 CNRS * * This program is free software: you can redistribute it and/or modify @@ -27,6 +27,14 @@ #include <rsys/mem_allocator.h> #include <rsys/str.h> +/* Library symbol management */ +#if defined(SCORE_SHARED_BUILD) /* Build shared library */ + #define SCORE_API extern EXPORT_SYM +#elif defined(SCORE_STATIC) /* Use/build static library */ + #define SCORE_API extern LOCAL_SYM +#else /* Use shared library */ + #define SCORE_API extern IMPORT_SYM +#endif struct solparser; struct solstice_node; struct ssol_device; @@ -202,17 +210,17 @@ struct solstice { struct mem_allocator* allocator; }; -extern LOCAL_SYM res_T +SCORE_API res_T solstice_init (struct mem_allocator* allocator, /* May be NULL <=> use default allocator */ const struct solstice_args* args, struct solstice* solstice); -extern LOCAL_SYM void +SCORE_API void solstice_release (struct solstice* solstice); -extern LOCAL_SYM res_T +SCORE_API res_T solstice_run (struct solstice* solstice); diff --git a/src/solstice_args.h.in b/src/solstice_args.h.in @@ -16,8 +16,10 @@ #ifndef SOLSTICE_ARGS_H #define SOLSTICE_ARGS_H -#include <rsys/math.h> +#include "score.h" + #include <solstice/ssol.h> +#include <rsys/math.h> struct solstice_args_spherical { double azimuth; /* In radians */ @@ -135,15 +137,5 @@ static const struct solstice_args SOLSTICE_ARGS_NULL = SOLSTICE_ARGS_NULL__; static const struct solstice_args SOLSTICE_ARGS_DEFAULT = SOLSTICE_ARGS_DEFAULT__; -extern LOCAL_SYM res_T -solstice_args_init - (struct solstice_args* args, - const int argc, - char** argv); - -extern LOCAL_SYM void -solstice_args_release - (struct solstice_args* args); - #endif /* SOLSTICE_ARGS_H */ diff --git a/srcv.pc.in b/srcv.pc.in @@ -0,0 +1,14 @@ +prefix=@PREFIX@ +includedir=${prefix}/include +libdir=${prefix}/lib + +Requires: \ + rsys >= @RSYS_VERSION@ +Requires.private:\ + yaml-0.1 >= @YAML_VERSION@ +Name: srcv +Description: Solstice Receiver +Version: @VERSION@ +Libs: -L${libdir} -lsrcv +Libs.private: -lm +CFlags: -I${includedir}