solstice

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

Makefile.core (7906B)


      1 # Copyright (C) 2018-2026 |Méso|Star> (contact@meso-star.com)
      2 # Copyright (C) 2016-2018 CNRS
      3 #
      4 # This program is free software: you can redistribute it and/or modify
      5 # it under the terms of the GNU General Public License as published by
      6 # the Free Software Foundation, either version 3 of the License, or
      7 # (at your option) any later version.
      8 #
      9 # This program is distributed in the hope that it will be useful,
     10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
     11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     12 # GNU General Public License for more details.
     13 #
     14 # You should have received a copy of the GNU General Public License
     15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
     16 
     17 .POSIX:
     18 .SUFFIXES: # Clean up default inference rules
     19 
     20 include config.mk
     21 
     22 LIBNAME = src/libscore.a
     23 
     24 default: library
     25 all: library tests
     26 
     27 ################################################################################
     28 # Build the library
     29 ################################################################################
     30 SRC =\
     31 src/solstice_args.c\
     32 src/solstice_atmosphere.c\
     33 src/solstice.c\
     34 src/solstice_draw.c\
     35 src/solstice_dump.c\
     36 src/solstice_entity.c\
     37 src/solstice_material.c\
     38 src/solstice_node.c\
     39 src/solstice_object.c\
     40 src/solstice_solve.c\
     41 src/solstice_spectrum.c\
     42 src/solstice_sun.c\
     43 src/solstice_sun_spectrum.c
     44 OBJ = $(SRC:.c=.o)
     45 DEP = $(SRC:.c=.d)
     46 
     47 # Headers to configure
     48 HDR=\
     49  src/solstice_args.h\
     50  src/solstice_version.h
     51 
     52 CFLAGS_LIB = $(CFLAGS_SO) $(INCS) -DSCORE_SHARED_BUILD
     53 LDFLAGS_LIB = $(LDFLAGS_SO) -Lsrc -lsprs -lsrcv $(LIBS)
     54 
     55 $(DEP) $(OBJ): src/.config_core
     56 
     57 library: $(DEP)
     58 	@$(MAKE) -fMakefile.core $$(for i in $(DEP); do echo -f $${i}; done) \
     59 		$(LIBNAME)
     60 
     61 $(LIBNAME): src/libscore.o
     62 	$(AR) -rc $@ $?
     63 	$(RANLIB) $@
     64 
     65 src/libscore.o: $(OBJ) $(DEP)
     66 	$(LD) -r $(OBJ) -o $@
     67 	$(OBJCOPY) $(OCPFLAGS) $@
     68 
     69 $(DEP): $(HDR)
     70 	@$(CC) $(CFLAGS_LIB) -MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@
     71 
     72 $(OBJ): $(HDR)
     73 	$(CC) $(CFLAGS_LIB) -c $(@:.o=.c) -o $@
     74 
     75 src/solstice_args.h: src/.config_core src/solstice_args.h.in
     76 	sed -e 's/@SOLSTICE_ARGS_DEFAULT_NREALISATIONS@/$(SOLSTICE_ARGS_DEFAULT_NREALISATIONS)/' \
     77 	    -e 's/@SOLSTICE_ARGS_DEFAULT_CAMERA_POS@/$(SOLSTICE_ARGS_DEFAULT_CAMERA_POS)/' \
     78 	    -e 's/@SOLSTICE_ARGS_DEFAULT_CAMERA_TGT@/$(SOLSTICE_ARGS_DEFAULT_CAMERA_TGT)/' \
     79 	    -e 's/@SOLSTICE_ARGS_DEFAULT_CAMERA_UP@/$(SOLSTICE_ARGS_DEFAULT_CAMERA_UP)/' \
     80 	    -e 's/@SOLSTICE_ARGS_DEFAULT_CAMERA_FOV@/$(SOLSTICE_ARGS_DEFAULT_CAMERA_FOV)/' \
     81 	    -e 's/@SOLSTICE_ARGS_DEFAULT_IMG_WIDTH@/$(SOLSTICE_ARGS_DEFAULT_IMG_WIDTH)/' \
     82 	    -e 's/@SOLSTICE_ARGS_DEFAULT_IMG_HEIGHT@/$(SOLSTICE_ARGS_DEFAULT_IMG_HEIGHT)/' \
     83 	    -e 's/@SOLSTICE_ARGS_DEFAULT_IMG_SPP@/$(SOLSTICE_ARGS_DEFAULT_IMG_SPP)/' \
     84 	    $@.in > $@
     85 
     86 src/solstice_version.h: src/.config_core src/solstice_version.h.in
     87 	sed -e 's/@VERSION_MAJOR@/$(VERSION_MAJOR)/' \
     88 	    -e 's/@VERSION_MINOR@/$(VERSION_MINOR)/' \
     89 	    -e 's/@VERSION_PATCH@/$(VERSION_PATCH)/' \
     90 	    $@.in > $@
     91 
     92 ################################################################################
     93 # Installation
     94 ################################################################################
     95 src/.config_core: config.mk
     96 	$(PKG_CONFIG) --atleast-version $(RSYS_VERSION)  rsys
     97 	$(PKG_CONFIG) --atleast-version $(S3DUT_VERSION) s3dut
     98 	$(PKG_CONFIG) --atleast-version $(SSP_VERSION)   star-sp
     99 	$(PKG_CONFIG) --atleast-version $(SSTL_VERSION)  sstl
    100 	$(PKG_CONFIG) --atleast-version $(YAML_VERSION)  yaml-0.1
    101 	$(PKG_CONFIG) --atleast-version $(SSOL_VERSION)  ssol
    102 	$(PKG_CONFIG) --atleast-version $(SANIM_VERSION) sanim
    103 	@echo "config done" > $@
    104 
    105 install:
    106 
    107 uninstall:
    108 
    109 clean: clean_test
    110 	rm -f $(DEP) $(OBJ) $(LIBNAME)
    111 	rm -f src/.config_core src/libscore.o
    112 
    113 lint:
    114 
    115 ################################################################################
    116 # Tests
    117 ################################################################################
    118 TEST_SRC =\
    119  src/test_solstice_args.c\
    120  src/test_solstice_simulation.c
    121 TEST_OBJ =\
    122  $(TEST_SRC:.c=.o)
    123 TEST_DEP =\
    124  $(TEST_SRC:.c=.d)
    125 TEST_TGT =\
    126  $(TEST_SRC:.c=.t)
    127 
    128 src/score-local.pc: score.pc.in src/.config_score_test
    129 	sed -e '1d'\
    130 	    -e 's#^includedir=.*#includedir=./src#'\
    131 	    -e 's#^libdir=.*#libdir=./#'\
    132 	    -e 's#@RSYS_VERSION@#$(RSYS_VERSION)#g'\
    133 	    -e 's#@S3DUT_VERSION@#$(S3DUT_VERSION)#g'\
    134 	    -e 's#@SSP_VERSION@#$(SSP_VERSION)#g'\
    135 	    -e 's#@SSTL_VERSION@#$(SSTL_VERSION)#g'\
    136 	    -e 's#@YAML_VERSION@#$(YAML_VERSION)#g'\
    137 	    -e 's#@SSOL_VERSION@#$(SSOL_VERSION)#g'\
    138 	    -e 's#@SANIM_VERSION@#$(SANIM_VERSION)#g'\
    139 	    score.pc.in > $@
    140 
    141 # Regular cflags
    142 PKG_CONFIG_LOCAL = PKG_CONFIG_PATH="./src:$${PKG_CONFIG_PATH}" $(PKG_CONFIG)
    143 INCS_TEST = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --cflags rsys score-local sprs-local srcv-local)
    144 LIBS_TEST = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --libs   rsys score-local sprs-local srcv-local)\
    145 	    -lm
    146 
    147 tests: library src/score-local.pc $(TEST_DEP) $(TEST_TGT)
    148 	@$(MAKE) -fMakefile.core \
    149 	$$(for i in $(TEST_DEP); do echo -f"$${i}"; done) \
    150 	$$(for i in $(TEST_TGT); do echo -f"$${i}"; done) \
    151 	test_list
    152 
    153 $(TEST_TGT):
    154 	@{ \
    155 	  exe="$$(basename "$@" ".t")"; \
    156 	  printf '%s: %s\n' "$${exe}" $(@:.t=.o); \
    157 	  printf 'test_list: %s\n' "$${exe}"; \
    158 	} > $@
    159 
    160 src/.config_score_test: config.mk
    161 	$(PKG_CONFIG) --atleast-version $(RSYS_VERSION)  rsys
    162 	$(PKG_CONFIG) --atleast-version $(S3DUT_VERSION) s3dut
    163 	$(PKG_CONFIG) --atleast-version $(SSP_VERSION)   star-sp
    164 	$(PKG_CONFIG) --atleast-version $(SSTL_VERSION)  sstl
    165 	$(PKG_CONFIG) --atleast-version $(YAML_VERSION)  yaml-0.1
    166 	$(PKG_CONFIG) --atleast-version $(SSOL_VERSION)  ssol
    167 	$(PKG_CONFIG) --atleast-version $(SANIM_VERSION) sanim
    168 	@echo "config done" > $@
    169 
    170 clean_test:
    171 	rm -f $(TEST_DEP) $(TEST_OBJ) $(TEST_TGT)
    172 	for i in $(TEST_SRC); do rm -f "$$(basename "$${i}" ".c")"; done
    173 	rm -f src/.config_score_test src/score-local.pc
    174 
    175 test: tests
    176 	@err=0; \
    177 	check() { name="$$1"; prog="$$2"; shift 2; \
    178 	  printf '%s' "$${name}"; \
    179 	  if PATH=./:"$${PATH}" "$${prog}" $$@ > /dev/null 2>&1; then \
    180 	    printf '\n'; \
    181 	  else \
    182 	    printf ': error %s\n' "$$?"; \
    183 	    err=$$((err+1)); \
    184 	  fi; \
    185 	}; \
    186 	\
    187 	for i in $(TEST_SRC); do \
    188 	  test="$$(basename "$${i}" ".c")"; \
    189 	  if [ "$${test}" != "test_solstice_simulation" ]; then \
    190 	    check "$${test}" "$${test}"; \
    191 	  else \
    192 	    check test_solstice_simulation_beam_down \
    193 	       test_solstice_simulation ./solstice yaml/ beam_down; \
    194 	    check test_solstice_simulation_test02 \
    195 	       test_solstice_simulation ./solstice yaml/ test02; \
    196 	    check test_solstice_simulation_test03 \
    197 	       test_solstice_simulation ./solstice yaml/ test03; \
    198 	    check test_solstice_simulation_test04 \
    199 	       test_solstice_simulation ./solstice yaml/ test04; \
    200 	    check test_solstice_simulation_test05 \
    201 	       test_solstice_simulation ./solstice yaml/ test05; \
    202 	    check test_solstice_simulation_test06 \
    203 	       test_solstice_simulation ./solstice yaml/ test06; \
    204 	    check test_solstice_simulation_test07 \
    205 	       test_solstice_simulation ./solstice yaml/ test07; \
    206 	    #check test_solstice_simulation_test08 \
    207 	    #   test_solstice_simulation ./solstice yaml/ test08; \
    208 	    #check test_solstice_simulation_test09 \
    209 	    #   test_solstice_simulation ./solstice yaml/ test09; \
    210 	  fi \
    211 	done; \
    212 	\
    213 	[ "$${err}" -eq 0 ]
    214 
    215 ################################################################################
    216 # Regular tests
    217 ################################################################################
    218 CFLAGS_TEST = $(CFLAGS_EXE) $(INCS_TEST)
    219 LDFLAGS_TEST = $(LDFLAGS_EXE) $(LIBS_TEST)
    220 
    221 $(TEST_DEP) : src/.config_score_test src/score-local.pc
    222 	@$(CC) $(CFLAGS_TEST) -MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@
    223 
    224 $(TEST_OBJ) : src/.config_score_test src/score-local.pc
    225 	$(CC) $(CFLAGS_TEST) -c $(@:.o=.c) -o $@
    226 
    227 test_solstice_args\
    228 test_solstice_simulation\
    229 : src/.config_score_test src/score-local.pc $(LIBNAME)
    230 	$(CC) $(CFLAGS_TEST) -o $@ src/$@.o $(LDFLAGS_TEST)