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.prs (6554B)


      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/libsprs.a
     23 
     24 default: library
     25 all: library tests
     26 
     27 ################################################################################
     28 # Build the library
     29 ################################################################################
     30 SRC =\
     31  src/parser/solparser_atmosphere.c\
     32  src/parser/solparser.c\
     33  src/parser/solparser_entity.c\
     34  src/parser/solparser_geometry.c\
     35  src/parser/solparser_image.c\
     36  src/parser/solparser_material.c\
     37  src/parser/solparser_medium.c\
     38  src/parser/solparser_mtl_data.c\
     39  src/parser/solparser_pivot.c\
     40  src/parser/solparser_spectrum.c\
     41  src/parser/solparser_sun.c
     42 OBJ = $(SRC:.c=.o)
     43 DEP = $(SRC:.c=.d)
     44 
     45 # Headers to configure
     46 HDR=
     47 
     48 CFLAGS_LIB = $(CFLAGS_SO) $(INCS) -DSPRSR_SHARED_BUILD
     49 LDFLAGS_LIB = $(LDFLAGS_SO) $(LIBS)
     50 
     51 $($(DEP) $(OBJ): src/.config_prs
     52 
     53 library: $(DEP)
     54 	@$(MAKE) -fMakefile.prs $$(for i in $(DEP); do echo -f $${i}; done) \
     55 		$(LIBNAME)
     56 
     57 $(LIBNAME): src/libsprs.o
     58 	$(AR) -rc $@ $?
     59 	$(RANLIB) $@
     60 
     61 src/libsprs.o: $(OBJ) $(DEP)
     62 	$(LD) -r $(OBJ) -o $@
     63 	$(OBJCOPY) $(OCPFLAGS) $@
     64 
     65 $(DEP): $(HDR)
     66 	@$(CC) $(CFLAGS_LIB) -MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@
     67 
     68 $(OBJ): $(HDR)
     69 	$(CC) $(CFLAGS_LIB) -c $(@:.o=.c) -o $@
     70 
     71 ################################################################################
     72 # Installation
     73 ################################################################################
     74 src/.config_prs: config.mk
     75 	$(PKG_CONFIG) --atleast-version $(RSYS_VERSION)  rsys
     76 	$(PKG_CONFIG) --exists                           yaml-0.1
     77 	@echo "config done" > $@
     78 
     79 install: library
     80 
     81 uninstall:
     82 
     83 clean: clean_test
     84 	rm -f $(DEP) $(OBJ) $(LIBNAME)
     85 	rm -f src/.config_prs src/libsprs.o
     86 
     87 lint:
     88 
     89 ################################################################################
     90 # Tests
     91 ################################################################################
     92 TEST_SRC =\
     93 src/parser/test_solparser.c\
     94 src/parser/test_solparser2.c\
     95 src/parser/test_solparser3.c\
     96 src/parser/test_solparser4.c\
     97 src/parser/test_solparser5.c\
     98 src/parser/test_solparser6.c\
     99 src/parser/test_solparser7.c\
    100 src/parser/test_solparser8.c\
    101 src/parser/test_solparser_mirror.c\
    102 src/parser/test_solparser_normal_map.c\
    103 src/parser/test_solparser_spectrum.c
    104 TEST_OBJ =\
    105  $(TEST_SRC:.c=.o)
    106 TEST_DEP =\
    107  $(TEST_SRC:.c=.d)
    108 TEST_TGT =\
    109  $(TEST_SRC:.c=.t)
    110 
    111 src/sprs-local.pc: sprs.pc.in config.mk
    112 	sed -e '1d'\
    113 	    -e 's#^includedir=.*#includedir=./src#'\
    114 	    -e 's#^libdir=.*#libdir=./src#'\
    115 	    -e 's#@RSYS_VERSION@#$(RSYS_VERSION)#g'\
    116 	    -e 's#@S3DUT_VERSION@#$(S3DUT_VERSION)#g'\
    117 	    -e 's#@SSP_VERSION@#$(SSP_VERSION)#g'\
    118 	    -e 's#@SSTL_VERSION@#$(SSTL_VERSION)#g'\
    119 	    -e 's#@YAML_VERSION@#$(YAML_VERSION)#g'\
    120 	    -e 's#@SSOL_VERSION@#$(SSOL_VERSION)#g'\
    121 	    -e 's#@SANIM_VERSION@#$(SANIM_VERSION)#g'\
    122 	    sprs.pc.in > $@
    123 
    124 # Regular cflags
    125 PKG_CONFIG_LOCAL = PKG_CONFIG_PATH="./src:$${PKG_CONFIG_PATH}" $(PKG_CONFIG)
    126 INCS_TEST = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --cflags rsys sprs-local)
    127 LIBS_TEST = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --libs   rsys sprs-local)\
    128  -lm
    129 
    130 tests: library src/sprs-local.pc $(TEST_DEP) $(TEST_TGT)
    131 	@$(MAKE) -fMakefile.prs \
    132 	$$(for i in $(TEST_DEP); do echo -f"$${i}"; done) \
    133 	$$(for i in $(TEST_TGT); do echo -f"$${i}"; done) \
    134 	test_list
    135 
    136 $(TEST_TGT):
    137 	@{ \
    138 	  exe="$$(basename "$@" ".t")"; \
    139 	  printf '%s: %s\n' "$${exe}" $(@:.t=.o); \
    140 	  printf 'test_list: %s\n' "$${exe}"; \
    141 	} > $@
    142 
    143 src/.config_sprs_test: config.mk
    144 	@echo "config done" > $@
    145 
    146 clean_test:
    147 	rm -f $(TEST_DEP) $(TEST_OBJ) $(TEST_TGT)
    148 	for i in $(TEST_SRC); do rm -f "$$(basename "$${i}" ".c")"; done
    149 	rm -f src/.config_sprs_test src/sprs-local.pc
    150 
    151 test: tests
    152 	@err=0; \
    153 	check() { name="$$1"; prog="$$2"; shift 2; \
    154 	  printf '%s' "$${name}"; \
    155 	  if PATH=./:"$${PATH}" "$${prog}" $$@ > /dev/null 2>&1; then \
    156 	    printf '\n'; \
    157 	  else \
    158 	    printf ': error %s\n' "$$?"; \
    159 	    err=$$((err+1)); \
    160 	  fi; \
    161 	}; \
    162 	\
    163 	for i in $(TEST_SRC); do \
    164 	  test="$$(basename "$${i}" ".c")"; \
    165 	  if [ "$${test}" != "test_solparser" ]; then \
    166 	    check "$${test}" "$${test}"; \
    167 	  else \
    168 	    check test_solstice_solparser_ok_0 \
    169 	       test_solparser src/parser/yaml/test_ok_0.yaml; \
    170 	    check test_solstice_solparser_ok_1 \
    171 	       test_solparser src/parser/yaml/test_ok_1.yaml; \
    172 	    check test_solstice_solparser_ok_2 \
    173 	       test_solparser src/parser/yaml/test_ok_2.yaml; \
    174 	    check test_solstice_solparser_ok_3 \
    175 	       test_solparser src/parser/yaml/test_ok_3.yaml; \
    176 	    check test_solstice_solparser_ok_4 \
    177 	       test_solparser src/parser/yaml/test_ok_4.yaml; \
    178 	    check test_solstice_solparser_ok_5 \
    179 	       test_solparser src/parser/yaml/test_ok_5.yaml; \
    180 	    check test_solstice_solparser_ok_6 \
    181 	       test_solparser src/parser/yaml/test_ok_6.yaml; \
    182 	    check test_solstice_solparser_ok_7 \
    183 	       test_solparser src/parser/yaml/test_ok_7.yaml; \
    184 	    check test_solstice_solparser_ko_0 \
    185 	       test_solparser -e src/parser/yaml/test_ko_0.yaml; \
    186 	  fi \
    187 	done; \
    188 	\
    189 	[ "$${err}" -eq 0 ]
    190 
    191 ################################################################################
    192 # Regular tests
    193 ################################################################################
    194 CFLAGS_TEST = $(CFLAGS_EXE) $(INCS_TEST)
    195 LDFLAGS_TEST = $(LDFLAGS_EXE) $(LIBS_TEST)
    196 
    197 $(TEST_DEP) : src/.config_sprs_test src/sprs-local.pc
    198 	@$(CC) $(CFLAGS_TEST) -MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@
    199 
    200 $(TEST_OBJ) : src/.config_sprs_test src/sprs-local.pc
    201 	$(CC) $(CFLAGS_TEST) -c $(@:.o=.c) -o $@
    202 
    203 test_solparser\
    204 test_solparser2\
    205 test_solparser3\
    206 test_solparser4\
    207 test_solparser5\
    208 test_solparser6\
    209 test_solparser7\
    210 test_solparser8\
    211 test_solparser_mirror\
    212 test_solparser_normal_map\
    213 test_solparser_spectrum\
    214 : src/.config_sprs_test src/sprs-local.pc $(LIBNAME)
    215 	$(CC) $(CFLAGS_TEST) -o $@ src/parser/$@.o $(LDFLAGS_TEST)