star-gs

Literate program for a geometric sensitivity calculation
git clone git://git.meso-star.fr/star-gs.git
Log | Files | Refs | README | LICENSE

commit b9294d551a74f0aeee1c4b9c7a6ae61de239127c
parent fb0abb0bd546fedfdbaf5ce95b437659abda6d83
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Thu, 13 Oct 2022 15:54:25 +0200

Write a POSIX Makefile as an alternative to CMake

Diffstat:
M.gitignore | 9+++------
AMakefile | 85+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aconfig.mk | 43+++++++++++++++++++++++++++++++++++++++++++
3 files changed, 131 insertions(+), 6 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -1,12 +1,9 @@ .gitignore -CMakeCache.txt -CMakeFiles -Makefile tmp [Bb]uild* *.sw[po] -*.[ao] -*.orig +*.[aod] *~ tags - +.config +sgs diff --git a/Makefile b/Makefile @@ -0,0 +1,85 @@ +# Copyright (C) 2021 +# CNRS/RAPSODEE, +# CNRS/LMAP, +# |Meso|Star> (contact@meso-star.com), +# UPS/Laplace. +# +# 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 + +SRC =\ + src/sgs_args.c\ + src/sgs.c\ + src/sgs_compute_4v_s.c\ + src/sgs_compute_sensitivity_translation.c\ + src/sgs_geometry_box.c\ + src/sgs_geometry.c\ + src/sgs_geometry_slope.c\ + src/sgs_geometry_step.c\ + src/sgs_log.c\ + src/sgs_main.c + +OBJ = $(SRC:.c=.o) +DEP = $(SRC:.c=.d) + +build_executable: .config $(DEP) + @$(MAKE) -fMakefile $$(for i in $(DEP); do echo -f $${i}; done) sgs + +$(OBJ): config.mk + +sgs: $(OBJ) + @echo "LD $@" + @$(CC) $(CFLAGS) -o $@ $(OBJ) $(LDFLAGS) + +.config: config.mk + @echo "Find packages"; rm -f $@ + @$(PKG_CONFIG) --atleast-version $(RSYS_VERSION) rsys \ + || (echo "RSys $(RSYS_VERSION) not found" >&2; exit 1) + @$(PKG_CONFIG) --atleast-version $(STAR-3D_VERSION) s3d \ + || (echo "Star-3D $(STAR-3D_VERSION) not found" >&2; exit 1) + @$(PKG_CONFIG) --atleast-version $(STAR-SP_VERSION) star-sp \ + || (echo "Star-SP $(STAR-SP_VERSION) not found" >&2; exit 1) + @$(PKG_CONFIG) --atleast-version $(STAR-MC_VERSION) smc \ + || (echo "Star-MC $(STAR-MC_VERSION) not found" >&2; exit 1) + @echo "config done" > $@ + +.SUFFIXES: .c .d .o +.c.d: + @echo "DEP $@" + @$(CC) $(CFLAGS) -MM -MT "$(@:.d=.o) $@" $< -MF $@ + +.c.o: + @echo "CC $@" + @$(CC) $(CFLAGS) -c $< -o $@ + +install: build_executable + mkdir -p $(DESTDIR)$(PREFIX)/bin + mkdir -p $(DESTDIR)$(PREFIX)/share/doc/star-gs + cp sgs $(DESTDIR)$(PREFIX)/bin + cp COPYING README.md $(DESTDIR)$(PREFIX)/share/doc/star-gs + +uninstall: + rm -f $(DESTDIR)$(PREFIX)/bin/ + rm -f $(DESTDIR)$(PREFIX)/share/doc/star-gs/COPYING + rm -f $(DESTDIR)$(PREFIX)/share/doc/star-gs/README.md + +clean: + @rm -f $(OBJ) sgs .config + +distclean: clean + @rm -f $(DEP) diff --git a/config.mk b/config.mk @@ -0,0 +1,43 @@ +VERSION = 0.0.0 + +PREFIX = /usr/local +PKG_CONFIG = pkg-config + +################################################################################ +# Dependencies +################################################################################ +RSYS_VERSION = 0.12 +RSYS_INC = $$($(PKG_CONFIG) --cflags rsys) +RSYS_LIB = $$($(PKG_CONFIG) --libs rsys) + +STAR-3D_VERSION = 0.8 +STAR-3D_INC = $$($(PKG_CONFIG) --cflags s3d) +STAR-3D_LIB = $$($(PKG_CONFIG) --libs s3d) + +STAR-MC_VERSION = 0.5 +STAR-MC_INC = $$($(PKG_CONFIG) --cflags smc) +STAR-MC_LIB = $$($(PKG_CONFIG) --libs smc) + +STAR-SP_VERSION = 0.12 +STAR-SP_INC = $$($(PKG_CONFIG) --cflags star-sp) +STAR-SP_LIB = $$($(PKG_CONFIG) --libs star-sp) + +INCS=$(RSYS_INC) $(STAR-3D_INC) $(STAR-MC_INC) $(STAR-SP_INC) +LIBS=$(RSYS_LIB) $(STAR-3D_LIB) $(STAR-MC_LIB) $(STAR-SP_LIB) + +################################################################################ +# Compilation options +################################################################################ +CC = cc + +CPPFLAGS = -DNDEBUG +WFLAGS =\ + -Wall\ + -Wconversion\ + -Wextra\ + -Wmissing-declarations\ + -Wmissing-prototypes\ + -Wshadow +CFLAGS = -O3 -std=c89 -pedantic -fPIC -fvisibility=hidden -fstrict-aliasing\ + -Wl,--no-undefined $(WFLAGS) $(CPPFLAGS) $(INCS) # Compiler options +LDFLAGS = $(LIBS) # Linker options