rnatm

Load and structure data describing an atmosphere
git clone git://git.meso-star.fr/rnatm.git
Log | Files | Refs | README | LICENSE

Makefile (6773B)


      1 # Copyright (C) 2022, 2023, 2025 Centre National de la Recherche Scientifique
      2 # Copyright (C) 2022, 2023, 2025 Institut Pierre-Simon Laplace
      3 # Copyright (C) 2022, 2023, 2025 Institut de Physique du Globe de Paris
      4 # Copyright (C) 2022, 2023, 2025 |Méso|Star> (contact@meso-star.com)
      5 # Copyright (C) 2022, 2023, 2025 Observatoire de Paris
      6 # Copyright (C) 2022, 2023, 2025 Université de Reims Champagne-Ardenne
      7 # Copyright (C) 2022, 2023, 2025 Université de Versaille Saint-Quentin
      8 # Copyright (C) 2022, 2023, 2025 Université Paul Sabatier
      9 #
     10 # This program is free software: you can redistribute it and/or modify
     11 # it under the terms of the GNU General Public License as published by
     12 # the Free Software Foundation, either version 3 of the License, or
     13 # (at your option) any later version.
     14 #
     15 # This program is distributed in the hope that it will be useful,
     16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
     17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     18 # GNU General Public License for more details.
     19 #
     20 # You should have received a copy of the GNU General Public License
     21 # along with this program. If not, see <http://www.gnu.org/licenses/>.
     22 
     23 .POSIX:
     24 .SUFFIXES: # Clean up default inference rules
     25 
     26 include config.mk
     27 
     28 LIBNAME_STATIC = librnatm.a
     29 LIBNAME_SHARED = librnatm.so
     30 LIBNAME = $(LIBNAME_$(LIB_TYPE))
     31 
     32 default: library
     33 all: default util
     34 
     35 ################################################################################
     36 # Library building
     37 ################################################################################
     38 SRC =\
     39  src/rnatm.c\
     40  src/rnatm_log.c\
     41  src/rnatm_mesh.c\
     42  src/rnatm_octree.c\
     43  src/rnatm_octrees_storage.c\
     44  src/rnatm_properties.c\
     45  src/rnatm_radcoef.c\
     46  src/rnatm_voxel_partition.c\
     47  src/rnatm_write_vtk.c
     48 OBJ = $(SRC:.c=.o)
     49 DEP = $(SRC:.c=.d)
     50 
     51 CFLAGS_LIB = $(CFLAGS_SO) $(INCS) -DRNATM_SHARED_BUILD
     52 LDFLAGS_LIB = $(LDFLAGS_SO) $(LIBS)
     53 
     54 library: .config $(DEP)
     55 	@$(MAKE) -fMakefile $$(for i in $(DEP); do echo -f $${i}; done) \
     56 	$$(if [ -n "$(LIBNAME)" ]; then \
     57 	     echo "$(LIBNAME)"; \
     58 	   else \
     59 	     echo "$(LIBNAME_SHARED)"; \
     60 	   fi)
     61 
     62 $(DEP) $(OBJ): config.mk
     63 
     64 $(LIBNAME_SHARED): $(OBJ)
     65 	$(CC) $(CFLAGS_LIB) -o $@ $(OBJ) $(LDFLAGS_LIB)
     66 
     67 $(LIBNAME_STATIC): librnatm.o
     68 	$(AR) -rc $@ $?
     69 	$(RANLIB) $@
     70 
     71 librnatm.o: $(OBJ)
     72 	$(LD) -r $(OBJ) -o $@
     73 	$(OBJCOPY) $(OCPFLAGS) $@
     74 
     75 .config: config.mk
     76 	$(PKG_CONFIG) --atleast-version $(RNSF_VERSION) rnsf
     77 	$(PKG_CONFIG) --atleast-version $(RNSL_VERSION) rnsl
     78 	$(PKG_CONFIG) --atleast-version $(RSYS_VERSION) rsys
     79 	$(PKG_CONFIG) --atleast-version $(SARS_VERSION) sars
     80 	$(PKG_CONFIG) --atleast-version $(SBUF_VERSION) sbuf
     81 	$(PKG_CONFIG) --atleast-version $(SCK_VERSION) sck
     82 	$(PKG_CONFIG) --atleast-version $(SMSH_VERSION) smsh
     83 	$(PKG_CONFIG) --atleast-version $(SSF_VERSION) ssf
     84 	$(PKG_CONFIG) --atleast-version $(SUVM_VERSION) suvm
     85 	$(PKG_CONFIG) --atleast-version $(SVX_VERSION) svx
     86 	echo "config done" > $@
     87 
     88 .SUFFIXES: .c .d .o
     89 .c.d:
     90 	@$(CC) $(CFLAGS_LIB) -MM -MT "$(@:.d=.o) $@" $< -MF $@
     91 
     92 .c.o:
     93 	$(CC) $(CFLAGS_LIB) -c $< -o $@
     94 
     95 ################################################################################
     96 # Tests
     97 ################################################################################
     98 UTIL_SRC = src/rnatm_main.c
     99 UTIL_OBJ = $(UTIL_SRC:.c=.o)
    100 UTIL_DEP = $(UTIL_SRC:.c=.d)
    101 
    102 PKG_CONFIG_LOCAL = PKG_CONFIG_PATH="./:$${PKG_CONFIG_PATH}" $(PKG_CONFIG)
    103 INCS_UTIL = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --cflags rnatm-local rsys)
    104 LIBS_UTIL = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --libs rnatm-local rsys)
    105 
    106 CFLAGS_UTIL = $(CFLAGS_EXE) $(INCS_UTIL)
    107 LDFLAGS_UTIL = $(LDFLAGS_EXE) $(LIBS_UTIL)
    108 
    109 util: library $(UTIL_DEP)
    110 	@$(MAKE) -fMakefile -f src/rnatm_main.d rnatm
    111 
    112 $(UTIL_DEP): config.mk rnatm-local.pc
    113 	@$(CC) $(CFLAGS_UTIL) -MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@
    114 
    115 $(UTIL_OBJ): config.mk rnatm-local.pc
    116 	$(CC) $(CFLAGS_UTIL) -c $(@:.o=.c) -o $@
    117 
    118 rnatm: src/rnatm_main.o config.mk rnatm-local.pc $(LIBNAME)
    119 	$(CC) $(CFLAGS_UTIL) -o $@ src/rnatm_main.o $(LDFLAGS_UTIL)
    120 
    121 ################################################################################
    122 # Miscellaneous
    123 ################################################################################
    124 pkg:
    125 	sed -e 's#@PREFIX@#$(PREFIX)#g'\
    126 	    -e 's#@VERSION@#$(VERSION)#g'\
    127 	    -e 's#@RNSF_VERSION@#$(RNSF_VERSION)#g'\
    128 	    -e 's#@RNSL_VERSION@#$(RNSL_VERSION)#g'\
    129 	    -e 's#@RSYS_VERSION@#$(RSYS_VERSION)#g'\
    130 	    -e 's#@SARS_VERSION@#$(SARS_VERSION)#g'\
    131 	    -e 's#@SBUF_VERSION@#$(SBUF_VERSION)#g'\
    132 	    -e 's#@SCK_VERSION@#$(SCK_VERSION)#g'\
    133 	    -e 's#@SMSH_VERSION@#$(SMSH_VERSION)#g'\
    134 	    -e 's#@SSF_VERSION@#$(SSF_VERSION)#g'\
    135 	    -e 's#@SUVM_VERSION@#$(SUVM_VERSION)#g'\
    136 	    -e 's#@SVX_VERSION@#$(SVX_VERSION)#g'\
    137 	    rnatm.pc.in > rnatm.pc
    138 
    139 rnatm-local.pc: rnatm.pc.in
    140 	sed -e '1d'\
    141 	    -e 's#^includedir=.*#includedir=./src/#'\
    142 	    -e 's#^libdir=.*#libdir=./#'\
    143 	    -e 's#@VERSION@#$(VERSION)#g'\
    144 	    -e 's#@RNSF_VERSION@#$(RNSF_VERSION)#g'\
    145 	    -e 's#@RNSL_VERSION@#$(RNSL_VERSION)#g'\
    146 	    -e 's#@RSYS_VERSION@#$(RSYS_VERSION)#g'\
    147 	    -e 's#@SARS_VERSION@#$(SARS_VERSION)#g'\
    148 	    -e 's#@SBUF_VERSION@#$(SBUF_VERSION)#g'\
    149 	    -e 's#@SCK_VERSION@#$(SCK_VERSION)#g'\
    150 	    -e 's#@SMSH_VERSION@#$(SMSH_VERSION)#g'\
    151 	    -e 's#@SSF_VERSION@#$(SSF_VERSION)#g'\
    152 	    -e 's#@SUVM_VERSION@#$(SUVM_VERSION)#g'\
    153 	    -e 's#@SVX_VERSION@#$(SVX_VERSION)#g'\
    154 	    rnatm.pc.in > $@
    155 
    156 install: library util pkg
    157 	install() { mode="$$1"; prefix="$$2"; shift 2; \
    158 	  mkdir -p "$${prefix}"; \
    159 	  cp "$$@" "$${prefix}"; \
    160 	  chmod "$${mode}" "$${prefix}/$${@##*/}"; \
    161 	}; \
    162 	install 755 "$(DESTDIR)$(BINPREFIX)" rnatm; \
    163 	install 755 "$(DESTDIR)$(LIBPREFIX)" $(LIBNAME); \
    164 	install 644 "$(DESTDIR)$(LIBPREFIX)/pkgconfig" rnatm.pc; \
    165 	install 644 "$(DESTDIR)$(INCPREFIX)/rad-net" src/rnatm.h; \
    166 	install 644 "$(DESTDIR)$(MANPREFIX)/man1" doc/rnatm.1; \
    167 	install 644 "$(DESTDIR)$(MANPREFIX)/man5" doc/rngt.5; \
    168 	install 644 "$(DESTDIR)$(MANPREFIX)/man5" doc/rnpfi.5; \
    169 	install 644 "$(DESTDIR)$(PREFIX)/share/doc/rnatm" COPYING; \
    170 	install 644 "$(DESTDIR)$(PREFIX)/share/doc/rnatm" README.md
    171 
    172 uninstall:
    173 	rm -f "$(DESTDIR)$(BINPREFIX)/rnatm"
    174 	rm -f "$(DESTDIR)$(LIBPREFIX)/$(LIBNAME)"
    175 	rm -f "$(DESTDIR)$(LIBPREFIX)/pkgconfig/rnatm.pc"
    176 	rm -f "$(DESTDIR)$(INCPREFIX)/rad-net/rnatm.h"
    177 	rm -f "$(DESTDIR)$(MANPREFIX)/man1/rnatm.1"
    178 	rm -f "$(DESTDIR)$(MANPREFIX)/man5/rngt.5"
    179 	rm -f "$(DESTDIR)$(MANPREFIX)/man5/rnpfi.5"
    180 	rm -f "$(DESTDIR)$(PREFIX)/share/doc/rnatm/COPYING"
    181 	rm -f "$(DESTDIR)$(PREFIX)/share/doc/rnatm/README.md"
    182 
    183 clean:
    184 	rm -f $(DEP) $(OBJ) $(LIBNAME)
    185 	rm -f $(UTIL_DEP) $(UTIL_OBJ) rnatm
    186 	rm -f .config librnatm.o rnatm.pc rnatm-local.pc
    187 
    188 lint:
    189 	mandoc -Tlint -Wall doc/rnatm.1 || [ $$? -le 1 ]
    190 	mandoc -Tlint -Wall doc/rngt.5 || [ $$? -le 1 ]
    191 	mandoc -Tlint -Wall doc/rnpfi.5 || [ $$? -le 1 ]