Makefile (4098B)
1 # Copyright (C) 2021-2023 Centre National de la Recherche Scientifique 2 # Copyright (C) 2021-2023 INSA Lyon 3 # Copyright (C) 2021-2023 Institut Mines Télécom Albi-Carmaux 4 # Copyright (C) 2021-2023 |Méso|Star> (contact@meso-star.com) 5 # Copyright (C) 2021-2023 Institut Pascal 6 # Copyright (C) 2021-2023 PhotonLyX (info@photonlyx.com) 7 # Copyright (C) 2021-2023 Université de Lorraine 8 # Copyright (C) 2021-2023 Université Paul Sabatier 9 # Copyright (C) 2021-2023 Université Toulouse - Jean-Jaurès 10 # 11 # This program is free software: you can redistribute it and/or modify 12 # it under the terms of the GNU General Public License as published by 13 # the Free Software Foundation, either version 3 of the License, or 14 # (at your option) any later version. 15 # 16 # This program is distributed in the hope that it will be useful, 17 # but WITHOUT ANY WARRANTY; without even the implied warranty of 18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 # GNU General Public License for more details. 20 # 21 # You should have received a copy of the GNU General Public License 22 # along with this program. If not, see <http://www.gnu.org/licenses/>. 23 24 .POSIX: 25 .SUFFIXES: # Clean up default inference rules 26 27 include config.mk 28 29 DOC = sgs_compute_sensitivity_translation 30 31 SCRIPTS = mc.sh fd.sh 32 TMPC = src/sgs_compute_sensitivity_translation.c 33 34 SRC =\ 35 src/sgs_args.c\ 36 src/sgs.c\ 37 src/sgs_geometry_box.c\ 38 src/sgs_geometry.c\ 39 src/sgs_log.c\ 40 src/sgs_main.c\ 41 $(TMPC) 42 43 NOWEB=\ 44 src/$(DOC).nw 45 46 OBJ = $(SRC:.c=.o) 47 DEP = $(SRC:.c=.d) 48 TEX = $(NOWEB:.nw=.tex) 49 50 ################################################################################ 51 # Program 52 ################################################################################ 53 build_executable: .config_program $(DEP) 54 @$(MAKE) -fMakefile $$(for i in $(DEP); do echo -f $${i}; done) sgs 55 56 $(OBJ): config.mk 57 58 sgs: $(OBJ) 59 $(CC) $(CFLAGS) -o $@ $(OBJ) $(LDFLAGS) -lm 60 61 .config_program: config.mk configure.sh 62 @echo "configure $(MAKE)" 63 @$(SHELL) configure.sh program && echo "config done" > $@ || exit 1 64 65 $(TMPC): $(NOWEB) config.mk 66 $(TANGLE) $(TANGLE_FLAGS) -R$$(basename "$@" | sed 's/_/\\_/g') $(NOWEB) | cpif $@ 67 68 $(SCRIPTS): $(NOWEB) 69 $(TANGLE) $(TANGLE_FLAGS) -R$$(basename "$@" | sed 's/_/\\_/g') $(NOWEB) | cpif $@ 70 71 .SUFFIXES: .c .d .o 72 .c.d: 73 @$(CC) $(CFLAGS) -MM -MT "$(@:.d=.o) $@" $< -MF $@ 74 75 .c.o: 76 $(CC) $(CFLAGS) -c $< -o $@ 77 78 ################################################################################ 79 # Latex 80 ################################################################################ 81 pdf: $(DOC).pdf 82 83 results.mc: mc.sh sgs 84 $(SHELL) mc.sh > $@ 85 86 results.fd: fd.sh results.mc 87 $(SHELL) fd.sh < results.mc > $@ 88 89 $(DOC).pdf: .config_document $(TEX) $(DOC).bbl 90 $(LATEX) src/$(DOC).tex && $(LATEX) src/$(DOC).tex 91 92 .config_document: config.mk configure.sh 93 @$(SHELL) configure.sh document && echo "config done" > $@ || exit 1 94 95 $(DOC).bbl: $(TEX) src/biblio.bib 96 $(LATEX) src/$(DOC).tex && rm -f $(DOC).pdf && BIBINPUTS=src/ $(BIBTEX) $(DOC) 97 98 $(TEX): weave.all 99 @touch $@ 100 101 weave.all: $(NOWEB) noweave_backend.sh config.mk 102 $(WEAVE) $(WEAVE_FLAGS) -backend "sh noweave_backend.sh" $(NOWEB) 103 104 ################################################################################ 105 # Miscellaneous targets 106 ################################################################################ 107 install: build_executable $(DOC).pdf 108 mkdir -p $(DESTDIR)$(PREFIX)/bin 109 mkdir -p $(DESTDIR)$(PREFIX)/share/doc/star-gs 110 cp sgs $(DESTDIR)$(PREFIX)/bin 111 cp $(DOC).pdf COPYING README.md $(DESTDIR)$(PREFIX)/share/doc/star-gs 112 113 uninstall: 114 rm -f $(DESTDIR)$(PREFIX)/bin/sgs 115 rm -f $(DESTDIR)$(PREFIX)/share/doc/star-gs/COPYING 116 rm -f $(DESTDIR)$(PREFIX)/share/doc/star-gs/README.md 117 rm -f $(DESTDIR)$(PREFIX)/share/doc/star-gs/$(DOC).pdf 118 119 clean: 120 rm -f $(OBJ) $(SCRIPTS) $(TEX) $(TMPC) sgs .config_program .config_document\ 121 ./*.aux ./*.bbl ./*.idx ./*.log ./*.dvi ./*.glo ./*.lof ./*.toc ./*.out\ 122 ./*.blg ./*.nav ./*.snm ./*.vrb weave* $(DOC).pdf 123 124 distclean: clean 125 @rm -f $(DEP) results.fd results.mc 126 127 lint: $(SCRIPTS) 128 shellcheck -o all configure.sh noweave_backend.sh $(SCRIPTS)