htsky

Load and structure a vertically stratified atmosphere
git clone git://git.meso-star.fr/htsky.git
Log | Files | Refs | README | LICENSE

Makefile (4516B)


      1 # Copyright (C) 2018, 2019, 2020, 2021 |Méso|Star> (contact@meso-star.com)
      2 # Copyright (C) 2018, 2019 Centre National de la Recherche Scientifique
      3 # Copyright (C) 2018, 2019 Université Paul Sabatier
      4 #
      5 # This program is free software: you can redistribute it and/or modify
      6 # it under the terms of the GNU General Public License as published by
      7 # the Free Software Foundation, either version 3 of the License, or
      8 # (at your option) any later version.
      9 #
     10 # This program is distributed in the hope that it will be useful,
     11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
     12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     13 # GNU General Public License for more details.
     14 #
     15 # You should have received a copy of the GNU General Public License
     16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
     17 
     18 .POSIX:
     19 .SUFFIXES: # Clean up default inference rules
     20 
     21 include config.mk
     22 
     23 LIBNAME_STATIC = libhtsky.a
     24 LIBNAME_SHARED = libhtsky.so
     25 LIBNAME = $(LIBNAME_$(LIB_TYPE))
     26 
     27 ################################################################################
     28 # Library building
     29 ################################################################################
     30 SRC =\
     31  src/htsky_atmosphere.c\
     32  src/htsky.c\
     33  src/htsky_cloud.c\
     34  src/htsky_dump_cloud_vtk.c\
     35  src/htsky_log.c\
     36  src/htsky_svx.c
     37 OBJ = $(SRC:.c=.o)
     38 DEP = $(SRC:.c=.d)
     39 
     40 build_library: .config $(DEP)
     41 	@$(MAKE) -fMakefile $$(for i in $(DEP); do echo -f $${i}; done) \
     42 	$$(if [ -n "$(LIBNAME)" ]; then \
     43 	     echo "$(LIBNAME)"; \
     44 	   else \
     45 	     echo "$(LIBNAME_SHARED)"; \
     46 	   fi)
     47 
     48 $(DEP) $(OBJ): config.mk
     49 
     50 $(LIBNAME_SHARED): $(OBJ)
     51 	$(CC) $(CFLAGS) $(DPDC_CFLAGS) -o $@ $(OBJ) $(LDFLAGS) $(DPDC_LIBS)
     52 
     53 $(LIBNAME_STATIC): libhtsky.o
     54 	$(AR) -rc $@ $?
     55 	$(RANLIB) $@
     56 
     57 libhtsky.o: $(OBJ)
     58 	$(LD) -r $(OBJ) -o $@
     59 	$(OBJCOPY) $(OCPFLAGS) $@
     60 
     61 .config: config.mk
     62 	@if ! $(PKG_CONFIG) --atleast-version $(HTCP_VERSION) htcp; then \
     63 	  echo "htcp $(HTCP_VERSION) not found" >&2; exit 1; fi
     64 	@if ! $(PKG_CONFIG) --atleast-version $(HTGOP_VERSION) htgop; then \
     65 	  echo "htgop $(HTGOP_VERSION) not found" >&2; exit 1; fi
     66 	@if ! $(PKG_CONFIG) --atleast-version $(HTMIE_VERSION) htmie; then \
     67 	  echo "htmie $(HTMIE_VERSION) not found" >&2; exit 1; fi
     68 	@if ! $(PKG_CONFIG) --atleast-version $(RSYS_VERSION) rsys; then \
     69 	  echo "rsys $(RSYS_VERSION) not found" >&2; exit 1; fi
     70 	@if ! $(PKG_CONFIG) --atleast-version $(SVX_VERSION) svx; then \
     71 	  echo "svx $(SVX_VERSION) not found" >&2; exit 1; fi
     72 	@echo "config done" > $@
     73 
     74 .SUFFIXES: .c .d .o
     75 .c.d:
     76 	@$(CC) $(CFLAGS) $(DPDC_CFLAGS) -MM -MT "$(@:.d=.o) $@" $< -MF $@
     77 
     78 .c.o:
     79 	$(CC) $(CFLAGS) $(DPDC_CFLAGS) -DHTSKY_SHARED_BUILD -c $< -o $@
     80 
     81 ################################################################################
     82 # Installation
     83 ################################################################################
     84 pkg:
     85 	sed -e 's#@PREFIX@#$(PREFIX)#g'\
     86 	    -e 's#@VERSION@#$(VERSION)#g'\
     87 	    -e 's#@HTCP_VERSION@#$(HTCP_VERSION)#g'\
     88 	    -e 's#@HTGOP_VERSION@#$(HTGOP_VERSION)#g'\
     89 	    -e 's#@HTMIE_VERSION@#$(HTMIE_VERSION)#g'\
     90 	    -e 's#@RSYS_VERSION@#$(RSYS_VERSION)#g'\
     91 	    -e 's#@SVX_VERSION@#$(SVX_VERSION)#g'\
     92 	    htsky.pc.in > htsky.pc
     93 
     94 htmie-local.pc: htmie.pc.in
     95 	sed -e '1d'\
     96 	    -e 's#^includedir=.*#includedir=./src/#'\
     97 	    -e 's#^libdir=.*#libdir=./#'\
     98 	    -e 's#@VERSION@#$(VERSION)#g'\
     99 	    -e 's#@HTCP_VERSION@#$(HTCP_VERSION)#g'\
    100 	    -e 's#@HTGOP_VERSION@#$(HTGOP_VERSION)#g'\
    101 	    -e 's#@HTMIE_VERSION@#$(HTMIE_VERSION)#g'\
    102 	    -e 's#@RSYS_VERSION@#$(RSYS_VERSION)#g'\
    103 	    -e 's#@SVX_VERSION@#$(SVX_VERSION)#g'\
    104 	    htsky.pc.in > $@
    105 
    106 install: build_library pkg
    107 	@$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/lib" $(LIBNAME)
    108 	@$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/lib/pkgconfig" htsky.pc
    109 	@$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/include/high_tune" src/htsky.h
    110 	@$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/share/doc/htsky" COPYING README.md
    111 
    112 uninstall:
    113 	rm -f "$(DESTDIR)$(PREFIX)/lib/$(LIBNAME)"
    114 	rm -f "$(DESTDIR)$(PREFIX)/lib/pkgconfig/htsky.pc"
    115 	rm -f "$(DESTDIR)$(PREFIX)/share/doc/htsky/COPYING"
    116 	rm -f "$(DESTDIR)$(PREFIX)/share/doc/htsky/README.md"
    117 	rm -f "$(DESTDIR)$(PREFIX)/include/high_tune/htsky.h"
    118 
    119 ################################################################################
    120 # Miscellaneous targets
    121 ################################################################################
    122 all: build_library
    123 
    124 clean:
    125 	rm -f $(OBJ) $(LIBNAME) .config libhtsky.o htsky.pc
    126 
    127 distclean: clean
    128 	rm -f $(DEP)
    129 
    130 lint:
    131 	shellcheck -o all make.sh