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 (5469B)


      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 default: executable
     23 all: executable man test
     24 
     25 LIBSCORE = src/libscore.a
     26 LIBSRCV = src/libsrcv.a
     27 LIBSPRS = src/libsprs.a
     28 
     29 ################################################################################
     30 # Program building
     31 ################################################################################
     32 CMD_SRC =\
     33 src/main.c
     34 CMD_OBJ = $(CMD_SRC:.c=.o)
     35 CMD_DEP = $(CMD_SRC:.c=.d)
     36 
     37 # Headers to configure
     38 HDR=\
     39  src/solstice_args.h\
     40  src/solstice_version.h
     41 
     42 CFLAGS_CMD = $(CFLAGS_EXE) $(INCS)
     43 LDFLAGS_CMD = $(LDFLAGS_EXE) -Lsrc -lscore -lsprs -lsrcv $(LIBS)
     44 
     45 $(CMD_DEP) $(CMD_OBJ): src/.config
     46 
     47 executable: libscore libsrcv libsprs $(CMD_DEP)
     48 	@$(MAKE) -fMakefile $$(for i in $(CMD_DEP); do echo -f $${i}; done) solstice
     49 
     50 solstice: $(CMD_OBJ) ${LIBSCORE} ${LIBSRCV} ${LIBSPRS}
     51 	$(CC) $(CFLAGS_CMD) -o $@ $(CMD_OBJ) $(LDFLAGS_CMD)
     52 
     53 $(CMD_DEP): $(HDR)
     54 	@$(CC) $(CFLAGS_CMD) -MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@
     55 
     56 $(CMD_OBJ): $(HDR)
     57 	$(CC) $(CFLAGS_CMD) -c $(@:.o=.c) -o $@
     58 
     59 libscore: libsrcv libsprs $(HDR)
     60 	$(MAKE) -fMakefile.core library
     61 
     62 libsrcv:
     63 	$(MAKE) -fMakefile.rcv library
     64 
     65 libsprs:
     66 	$(MAKE) -fMakefile.prs library
     67 
     68 src/solstice_args.h:
     69 	$(MAKE) -fMakefile.core $@
     70 
     71 src/solstice_version.h:
     72 	$(MAKE) -fMakefile.core $@
     73 
     74 src/.config: config.mk
     75 	$(PKG_CONFIG) --atleast-version $(RSYS_VERSION)  rsys
     76 	@echo "config done" > $@
     77 
     78 ################################################################################
     79 # Tests
     80 ################################################################################
     81 test: executable
     82 	$(MAKE) -fMakefile.prs test
     83 	$(MAKE) -fMakefile.rcv test
     84 	$(MAKE) -fMakefile.core test
     85 
     86 ################################################################################
     87 # Man pages
     88 ################################################################################
     89 man: doc/solstice.1
     90 
     91 doc/solstice.1: doc/solstice.1.in
     92 	sed -e 's/@SOLSTICE_ARGS_DEFAULT_NREALISATIONS@/$(SOLSTICE_ARGS_DEFAULT_NREALISATIONS)/' \
     93 	    -e 's/@SOLSTICE_ARGS_DEFAULT_CAMERA_POS@/$(SOLSTICE_ARGS_DEFAULT_CAMERA_POS)/' \
     94 	    -e 's/@SOLSTICE_ARGS_DEFAULT_CAMERA_TGT@/$(SOLSTICE_ARGS_DEFAULT_CAMERA_TGT)/' \
     95 	    -e 's/@SOLSTICE_ARGS_DEFAULT_CAMERA_UP@/$(SOLSTICE_ARGS_DEFAULT_CAMERA_UP)/' \
     96 	    -e 's/@SOLSTICE_ARGS_DEFAULT_CAMERA_FOV@/$(SOLSTICE_ARGS_DEFAULT_CAMERA_FOV)/' \
     97 	    -e 's/@SOLSTICE_ARGS_DEFAULT_IMG_WIDTH@/$(SOLSTICE_ARGS_DEFAULT_IMG_WIDTH)/' \
     98 	    -e 's/@SOLSTICE_ARGS_DEFAULT_IMG_HEIGHT@/$(SOLSTICE_ARGS_DEFAULT_IMG_HEIGHT)/' \
     99 	    -e 's/@SOLSTICE_ARGS_DEFAULT_IMG_SPP@/$(SOLSTICE_ARGS_DEFAULT_IMG_SPP)/' \
    100 	    $@.in > $@
    101 
    102 ################################################################################
    103 # Installation
    104 ################################################################################
    105 install: executable man
    106 	install() { mode="$$1"; prefix="$$2"; shift 2; \
    107 	  mkdir -p "$${prefix}"; \
    108 	  cp "$$@" "$${prefix}"; \
    109 	  chmod "$${mode}" "$${prefix}/$${@##*/}"; \
    110 	}; \
    111 	install 755 "$(DESTDIR)$(PREFIX)/bin" solstice; \
    112 	install 644 "$(DESTDIR)$(PREFIX)/share/doc/solstice" COPYING; \
    113 	install 644 "$(DESTDIR)$(PREFIX)/share/doc/solstice" README.md; \
    114 	install 644 "$(DESTDIR)$(PREFIX)/share/man/man1" doc/solstice.1; \
    115 	install 644 "$(DESTDIR)$(PREFIX)/share/man/man5" doc/solstice-input.5; \
    116 	install 644 "$(DESTDIR)$(PREFIX)/share/man/man5" doc/solstice-output.5; \
    117 	install 644 "$(DESTDIR)$(PREFIX)/share/man/man5" doc/solstice-receiver.5
    118 	$(MAKE) -fMakefile.core install
    119 	$(MAKE) -fMakefile.rcv install
    120 	$(MAKE) -fMakefile.prs install
    121 
    122 uninstall:
    123 	rm -f "$(DESTDIR)$(PREFIX)/bin/solstice"
    124 	rm -f "$(DESTDIR)$(PREFIX)/share/doc/solstice/COPYING"
    125 	rm -f "$(DESTDIR)$(PREFIX)/share/doc/solstice/README.md"
    126 	rm -f "$(DESTDIR)$(PREFIX)/share/man/man1/solstice.1"
    127 	rm -f "$(DESTDIR)$(PREFIX)/share/man/man5/solstice-receiver.5"
    128 	rm -f "$(DESTDIR)$(PREFIX)/share/man/man5/solstice-input.5"
    129 	rm -f "$(DESTDIR)$(PREFIX)/share/man/man5/solstice-output.5"
    130 	$(MAKE) -fMakefile.core uninstall
    131 	$(MAKE) -fMakefile.rcv uninstall
    132 	$(MAKE) -fMakefile.prs uninstall
    133 
    134 ################################################################################
    135 # Miscellaneous targets
    136 ################################################################################
    137 clean:
    138 	rm -f $(HDR) $(CMD_OBJ) $(CMD_DEP)
    139 	rm -f solstice doc/solstice.1
    140 	$(MAKE) -fMakefile.core clean
    141 	$(MAKE) -fMakefile.rcv clean
    142 	$(MAKE) -fMakefile.prs clean
    143 
    144 lint: man
    145 	mandoc -Tlint -Wall doc/solstice.1 || [ $$? -le 1 ]
    146 	mandoc -Tlint -Wall doc/solstice-receiver.5 || [ $$? -le 1 ]
    147 	mandoc -Tlint -Wall doc/solstice-input.5 || [ $$? -le 1 ]
    148 	mandoc -Tlint -Wall doc/solstice-output.5 || [ $$? -le 1 ]
    149 	$(MAKE) -fMakefile.core lint
    150 	$(MAKE) -fMakefile.rcv lint
    151 	$(MAKE) -fMakefile.prs lint