schiff

Estimate the radiative properties of soft particless
git clone git://git.meso-star.com/schiff.git
Log | Files | Refs | README | LICENSE

Makefile (4829B)


      1 # Copyright (C) 2015, 2016, 2026 Centre National de la Recherche Scientifique
      2 # Copyright (C) 2026 Clermont Auvergne INP
      3 # Copyright (C) 2026 Institut Mines Télécom Albi-Carmaux
      4 # Copyright (C) 2017, 2019-2021, 2026 |Méso|Star> (contact@meso-star.com)
      5 # Copyright (C) 2026 Université de Lorraine
      6 # Copyright (C) 2026 Université de Toulouse
      7 #
      8 # This program is free software: you can redistribute it and/or modify
      9 # it under the terms of the GNU General Public License as published by
     10 # the Free Software Foundation, either version 3 of the License, or
     11 # (at your option) any later version.
     12 #
     13 # This program is distributed in the hope that it will be useful,
     14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     16 # GNU General Public License for more details.
     17 #
     18 # You should have received a copy of the GNU General Public License
     19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
     20 
     21 .POSIX:
     22 .SUFFIXES: # Clean up default inference rules
     23 
     24 include config.mk
     25 
     26 default: program
     27 all: default
     28 
     29 ################################################################################
     30 # Star-3D building
     31 ################################################################################
     32 SRC =\
     33  src/schiff.c\
     34  src/schiff_args.c\
     35  src/schiff_geometry.c\
     36  src/schiff_mesh.c\
     37  src/schiff_optical_properties.c
     38 OBJ = $(SRC:.c=.o)
     39 DEP = $(SRC:.c=.d)
     40 
     41 CFLAGS_PROG = $(CFLAGS) $(INCS)
     42 LDFLAGS_PROG = $(LDFLAGS) $(LIBS)
     43 
     44 program: .config $(DEP)
     45 	@$(MAKE) -fMakefile $$(for i in $(DEP); do echo -f "$${i}"; done) schiff
     46 
     47 $(DEP): src/schiff_args.h src/schiff_version.h
     48 $(DEP) $(OBJ): config.mk
     49 
     50 schiff: $(OBJ)
     51 	$(CC) $(CFLAGS_PROG) -o $@ $(OBJ) $(LDFLAGS_PROG)
     52 
     53 .config: config.mk
     54 	$(PKG_CONFIG) --atleast-version $(RSYS_VERSION) rsys
     55 	$(PKG_CONFIG) --atleast-version $(S3D_VERSION) s3d
     56 	$(PKG_CONFIG) --atleast-version $(SSCHIFF_VERSION) sschiff
     57 	$(PKG_CONFIG) --atleast-version $(SSP_VERSION) star-sp
     58 	$(PKG_CONFIG) --atleast-version $(YAML_VERSION) yaml-0.1
     59 	echo "config done" > $@
     60 
     61 src/schiff_args.h: src/schiff_args.h.in
     62 src/schiff_version.h: src/schiff_version.h.in
     63 doc/schiff.1: doc/schiff.1.in
     64 
     65 src/schiff_version.h src/schiff_args.h doc/schiff.1: config.mk
     66 	@sed -e 's#@SCHIFF_ARGS_DEFAULT_NINSAMPLES@#$(SCHIFF_ARGS_DEFAULT_NINSAMPLES)#g' \
     67 	     -e 's#@SCHIFF_ARGS_DEFAULT_NREALISATIONS@#$(SCHIFF_ARGS_DEFAULT_NREALISATIONS)#g' \
     68 	     -e 's#@SCHIFF_ARGS_DEFAULT_NANGLES@#$(SCHIFF_ARGS_DEFAULT_NANGLES)#g' \
     69 	     -e 's#@SCHIFF_ARGS_DEFAULT_NANGLES_INV@#$(SCHIFF_ARGS_DEFAULT_NANGLES_INV)#g' \
     70 	     -e 's#@VERSION_MAJOR@#$(VERSION_MAJOR)#g' \
     71 	     -e 's#@VERSION_MINOR@#$(VERSION_MINOR)#g' \
     72 	     -e 's#@VERSION_PATCH@#$(VERSION_PATCH)#g' \
     73 	     $@.in > $@
     74 
     75 .SUFFIXES: .c .d .o
     76 .c.d:
     77 	$(CC) $(CFLAGS_PROG) -MM -MT "$(@:.d=.o) $@" $< -MF $@
     78 
     79 .c.o:
     80 	$(CC) $(CFLAGS_PROG) -c $< -o $@
     81 
     82 ################################################################################
     83 # Installation
     84 ################################################################################
     85 install: program doc/schiff.1
     86 	install() { mode="$$1"; prefix="$$2"; shift 2; \
     87 	  mkdir -p "$${prefix}"; \
     88 	  cp "$$@" "$${prefix}"; \
     89 	  printf '%s\n' "$${@}" | while read -r i; do \
     90 	    chmod "$${mode}" "$${prefix}/$${i##*/}"; \
     91 	  done; \
     92 	}; \
     93 	install 755 "$(DESTDIR)$(BINPREFIX)" schiff; \
     94 	install 644 "$(DESTDIR)$(MANPREFIX)/man1" doc/schiff.1; \
     95 	install 644 "$(DESTDIR)$(MANPREFIX)/man5" doc/schiff-geometry.5; \
     96 	install 644 "$(DESTDIR)$(MANPREFIX)/man5" doc/schiff-output.5; \
     97 	install 644 "$(DESTDIR)$(PREFIX)/share/doc/schiff" COPYING README.md
     98 
     99 uninstall:
    100 	rm -f "$(DESTDIR)$(BINPREFIX)/schiff"
    101 	rm -f "$(DESTDIR)$(MANPREFIX)/man1/schiff.1"
    102 	rm -f "$(DESTDIR)$(MANPREFIX)/man5/schiff-geometry.5"
    103 	rm -f "$(DESTDIR)$(MANPREFIX)/man5/schiff-output.5"
    104 	rm -f "$(DESTDIR)$(PREFIX)/share/doc/schiff/COPYING"
    105 	rm -f "$(DESTDIR)$(PREFIX)/share/doc/schiff/README.md"
    106 
    107 clean:
    108 	rm -f $(OBJ) $(DEP) $(LIBNAME)
    109 	rm -f src/schiff_version.h src/schiff_args.h doc/schiff.1
    110 	rm -f .config schiff
    111 
    112 lint: doc/schiff.1
    113 	shellcheck -o all src/test_schiff_cylinder.sh
    114 	shellcheck -o all src/test_schiff_sphere.sh
    115 	mandoc -Tlint -Wwarning doc/schiff.1
    116 	mandoc -Tlint -Wwarning doc/schiff-geometry.5
    117 	mandoc -Tlint -Wwarning doc/schiff-output.5
    118 
    119 ################################################################################
    120 # Test
    121 ################################################################################
    122 test: program
    123 	@err=0; \
    124 	run() { \
    125 	  test="$$(basename "$$1" ".sh")"; \
    126 	  printf '%s' "$${test}"; \
    127 	  if sh -c "export PATH=$${PWD}:$${PATH} && sh '$$1'" > /dev/null 2>&1; then \
    128 	    printf '\n'; \
    129 	  else \
    130 	    printf ': error %s\n' "$$?"; \
    131 	    err=$$((err+1)); \
    132 	  fi \
    133 	}; \
    134 	run src/test_schiff_cylinder.sh; \
    135 	run src/test_schiff_sphere.sh; \
    136 	[ "$${err}" -eq 0 ]