Makefile (5764B)
1 # Copyright (C) 2024 |Méso|Star> (contact@meso-star.com) 2 # 3 # This program is free software: you can redistribute it and/or modify 4 # it under the terms of the GNU General Public License as published by 5 # the Free Software Foundation, either version 3 of the License, or 6 # (at your option) any later version. 7 # 8 # This program is distributed in the hope that it will be useful, 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 # GNU General Public License for more details. 12 # 13 # You should have received a copy of the GNU General Public License 14 # along with this program. If not, see <http://www.gnu.org/licenses/>. 15 16 .POSIX: 17 .SUFFIXES: # Clean up default inference rules 18 19 include config.mk 20 21 LIBS =\ 22 libsadist_radenv_1d.so\ 23 libsadist_solid_fluid.so\ 24 libsadist_solid_sphere.so\ 25 libsadist_spherical_source.so\ 26 libsadist_trilinear_profile.so\ 27 libsadist_unsteady_profile.so\ 28 29 # Default target 30 default: .config tests $(LIBS) 31 32 .config: 33 $(PKG_CONFIG) --atleast-version $(RSYS_VERSION) rsys 34 $(PKG_CONFIG) --atleast-version $(S3D_VERSION) s3d 35 $(PKG_CONFIG) --atleast-version $(S3DUT_VERSION) s3dut 36 $(PKG_CONFIG) --atleast-version $(SSP_VERSION) star-sp 37 $(PKG_CONFIG) --atleast-version $(SSTL_VERSION) sstl 38 @echo "config done" > $@ 39 40 clean: 41 rm -f .config src/*.o src/*.d 42 rm -f cube.stl ground.stl sphere.stl sshape.stl wall.stl 43 rm -f adiabatic_boundary.stl radiative_boundary.stl 44 rm -f probes.txt scene.txt scene2.txt 45 rm -f cuboid*.stl 46 rm -f $(LIBS) 47 for i in $(TEST_SRC); do rm -f "$$(basename "$${i}" ".c")"; done 48 49 test: tests $(LIBS) 50 @err=0; \ 51 check() { \ 52 cmd="$$1"; shift 1; \ 53 if [ -n "$$1" ]; then \ 54 printf '%s %s' "$${cmd}" "$$@"; \ 55 else \ 56 printf '%s' "$${cmd}"; \ 57 fi; \ 58 if "$${cmd}" "$$@" > /dev/null 2>&1; then \ 59 printf '\n'; \ 60 else \ 61 printf ': error %d\n' "$$?"; \ 62 err="$$((err+1))"; \ 63 fi \ 64 }; \ 65 check ./sadist_conducto_radiative; \ 66 check ./sadist_custom_conductive_path; \ 67 check ./sadist_probe_boundary; \ 68 check ./sadist_probe_boundary -p4; \ 69 check ./sadist_external_flux; \ 70 check ./sadist_flux_with_h; \ 71 check ./sadist_unsteady; \ 72 [ "$${err}" -eq 0 ] 73 74 ################################################################################ 75 # Libraries 76 ################################################################################ 77 src/sadist_lib_radenv_1d.o: config.mk src/sadist_lib_radenv_1d.c 78 $(CC) $(CFLAGS_SO) $$($(PC_CFLAGS) rsys) -c $(@:.o=.c) -o $@ 79 80 libsadist_radenv_1d.so: config.mk src/sadist_lib_radenv_1d.o 81 $(CC) $(CFLAGS_SO) $$($(PC_CFLAGS) rsys) -o $@ src/sadist_lib_radenv_1d.o \ 82 $(LDFLAGS_SO) $$($(PC_LIBS) rsys) 83 84 src/sadist_lib_solid_fluid.o: config.mk src/sadist_lib_solid_fluid.c 85 $(CC) $(CFLAGS_SO) $$($(PC_CFLAGS) rsys) -c $(@:.o=.c) -o $@ 86 87 libsadist_solid_fluid.so: config.mk src/sadist_lib_solid_fluid.o 88 $(CC) $(CFLAGS_SO) $$($(PC_CFLAGS) rsys) -o $@ src/sadist_lib_solid_fluid.o \ 89 $(LDFLAGS_SO) $$($(PC_LIBS) rsys) 90 91 src/sadist_lib_solid_sphere.o: config.mk src/sadist_lib_solid_sphere.c 92 $(CC) $(CFLAGS_SO) $$($(PC_CFLAGS) s3d star-sp sstl rsys) -c $(@:.o=.c) -o $@ 93 94 libsadist_solid_sphere.so: config.mk src/sadist_lib_solid_sphere.o 95 $(CC) $(CFLAGS_SO) $$($(PC_CFLAGS) s3d star-sp sstl rsys) \ 96 -o $@ src/sadist_lib_solid_sphere.o \ 97 $(LDFLAGS_SO) $$($(PC_LIBS) s3d star-sp sstl rsys) -lm 98 99 src/sadist_lib_spherical_source.o: config.mk src/sadist_lib_spherical_source.c 100 $(CC) $(CFLAGS_SO) $$($(PC_CFLAGS) rsys) -c $(@:.o=.c) -o $@ 101 102 libsadist_spherical_source.so: config.mk src/sadist_lib_spherical_source.o 103 $(CC) $(CFLAGS_SO) $$($(PC_CFLAGS) rsys) -o $@ src/sadist_lib_spherical_source.o \ 104 $(LDFLAGS_SO) $$($(PC_LIBS) rsys) 105 106 src/sadist_lib_trilinear_profile.o:\ 107 config.mk src/sadist.h src/sadist_lib_trilinear_profile.c 108 $(CC) $(CFLAGS_SO) $$($(PC_CFLAGS) rsys) -c $(@:.o=.c) -o $@ 109 110 libsadist_trilinear_profile.so: src/sadist_lib_trilinear_profile.o 111 $(CC) $(CFLAGS_SO) $$($(PC_CFLAGS) rsys) -o $@ src/sadist_lib_trilinear_profile.o \ 112 $(LDFLAGS_SO) $$($(PC_LIBS) rsys) 113 114 src/sadist_lib_unsteady_profile.o:\ 115 config.mk src/sadist.h src/sadist_lib_unsteady_profile.c 116 $(CC) $(CFLAGS_SO) $$($(PC_CFLAGS) rsys) -c $(@:.o=.c) -o $@ 117 118 libsadist_unsteady_profile.so: src/sadist_lib_unsteady_profile.o 119 $(CC) $(CFLAGS_SO) $$($(PC_CFLAGS) rsys) -o $@ src/sadist_lib_unsteady_profile.o \ 120 $(LDFLAGS_SO) $$($(PC_LIBS) rsys) -lm 121 122 ################################################################################ 123 # Tests 124 ################################################################################ 125 TEST_SRC=\ 126 src/sadist_conducto_radiative.c\ 127 src/sadist_custom_conductive_path.c\ 128 src/sadist_external_flux.c\ 129 src/sadist_flux_with_h.c\ 130 src/sadist_probe_boundary.c\ 131 src/sadist_unsteady.c 132 TEST_OBJ=$(TEST_SRC:.c=.o) 133 TEST_DEP=$(TEST_SRC:.c=.d) 134 TEST_TGT=$(TEST_SRC:.c=.t) 135 136 INCS_TEST = $$($(PKG_CONFIG) $(PCFLAGS) --cflags s3dut star-sp sstl rsys) 137 LIBS_TEST = $$($(PKG_CONFIG) $(PCFLAGS) --libs s3dut star-sp sstl rsys) -lm 138 CFLAGS_TEST = $(CFLAGS_EXE) $(INCS_TEST) 139 LDFLAGS_TEST = $(LDFLAGS_EXE) $(LIBS_TEST) 140 141 tests: $(TEST_DEP) $(TEST_TGT) 142 @$(MAKE) -fMakefile \ 143 $$(for i in $(TEST_DEP); do echo -f"$${i}"; done) \ 144 $$(for i in $(TEST_TGT); do echo -f"$${i}"; done) \ 145 test_list 146 147 $(TEST_OBJ) $(TEST_DEP): config.mk 148 149 .SUFFIXES: .c .d .o .t 150 151 .c.d: 152 @$(CC) $(CFLAGS_TEST) -MM -MT "$(@:.d=.o) $@" $< -MF $@ 153 154 .c.o: 155 $(CC) $(CFLAGS_TEST) -c $< -o $@ 156 157 .c.t: 158 @{ \ 159 exe="$$(basename "$@" ".t")"; \ 160 printf '%s: %s\n' "$${exe}" $(@:.t=.o); \ 161 printf 'test_list: %s\n' "$${exe}"; \ 162 } > $@ 163 164 sadist_conducto_radiative \ 165 sadist_custom_conductive_path \ 166 sadist_external_flux \ 167 sadist_flux_with_h \ 168 sadist_probe_boundary \ 169 sadist_unsteady \ 170 : config.mk 171 $(CC) $(CFLAGS_TEST) -o $@ src/$@.o $(LDFLAGS_TEST)