rngrd

Describe a surface and its physical properties
git clone git://git.meso-star.fr/rngrd.git
Log | Files | Refs | README | LICENSE

Makefile (6481B)


      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 = librngrd.a
     29 LIBNAME_SHARED = librngrd.so
     30 LIBNAME = $(LIBNAME_$(LIB_TYPE))
     31 
     32 ################################################################################
     33 # Library building
     34 ################################################################################
     35 SRC = src/rngrd.c src/rngrd_log.c src/rngrd_mesh.c src/rngrd_properties.c
     36 OBJ = $(SRC:.c=.o)
     37 DEP = $(SRC:.c=.d)
     38 
     39 build_library: .config $(DEP)
     40 	@$(MAKE) -fMakefile $$(for i in $(DEP); do echo -f $${i}; done) \
     41 	$$(if [ -n "$(LIBNAME)" ]; then \
     42 	     echo "$(LIBNAME)"; \
     43 	   else \
     44 	     echo "$(LIBNAME_SHARED)"; \
     45 	   fi)
     46 
     47 $(DEP) $(OBJ): config.mk
     48 
     49 $(LIBNAME_SHARED): $(OBJ)
     50 	$(CC) $(CFLAGS_SO) $(DPDC_CFLAGS) -o $@ $(OBJ) $(LDFLAGS_SO) $(DPDC_LIBS)
     51 
     52 $(LIBNAME_STATIC): librngrd.o
     53 	$(AR) -rc $@ $?
     54 	$(RANLIB) $@
     55 
     56 librngrd.o: $(OBJ)
     57 	$(LD) -r $(OBJ) -o $@
     58 	$(OBJCOPY) $(OCPFLAGS) $@
     59 
     60 .config: config.mk
     61 	@if ! $(PKG_CONFIG) --atleast-version $(MRUMTL_VERSION) mrumtl; then \
     62 	  echo "mrumtl $(MRUMTL_VERSION) not found" >&2; exit 1; fi
     63 	@if ! $(PKG_CONFIG) --atleast-version $(RNSL_VERSION) rnsl; then \
     64 	  echo "rnsl $(RNSL_VERSION) not found" >&2; exit 1; fi
     65 	@if ! $(PKG_CONFIG) --atleast-version $(RSYS_VERSION) rsys; then \
     66 	  echo "rsys $(RSYS_VERSION) not found" >&2; exit 1; fi
     67 	@if ! $(PKG_CONFIG) --atleast-version $(S3D_VERSION) s3d; then \
     68 	  echo "s3d $(S3D_VERSION) not found" >&2; exit 1; fi
     69 	@if ! $(PKG_CONFIG) --atleast-version $(SBUF_VERSION) sbuf; then \
     70 	  echo "sbuf $(SBUF_VERSION) not found" >&2; exit 1; fi
     71 	@if ! $(PKG_CONFIG) --atleast-version $(SMSH_VERSION) smsh; then \
     72 	  echo "smsh $(SMSH_VERSION) not found" >&2; exit 1; fi
     73 	@if ! $(PKG_CONFIG) --atleast-version $(SSF_VERSION) ssf; then \
     74 	  echo "ssf $(SSF_VERSION) not found" >&2; exit 1; fi
     75 	@echo "config done" > $@
     76 
     77 .SUFFIXES: .c .d .o
     78 .c.d:
     79 	@$(CC) $(CFLAGS_SO) $(DPDC_CFLAGS) -MM -MT "$(@:.d=.o) $@" $< -MF $@
     80 
     81 .c.o:
     82 	$(CC) $(CFLAGS_SO) $(DPDC_CFLAGS) -DRNGRD_SHARED_BUILD -c $< -o $@
     83 
     84 ################################################################################
     85 # Installation
     86 ################################################################################
     87 pkg:
     88 	sed -e 's#@PREFIX@#$(PREFIX)#g'\
     89 	    -e 's#@VERSION@#$(VERSION)#g'\
     90 	    -e 's#@MRUMTL_VERSION@#$(MRUMTL_VERSION)#g'\
     91 	    -e 's#@RNSL_VERSION@#$(RNSL_VERSION)#g'\
     92 	    -e 's#@RSYS_VERSION@#$(RSYS_VERSION)#g'\
     93 	    -e 's#@S3D_VERSION@#$(S3D_VERSION)#g'\
     94 	    -e 's#@SBUF_VERSION@#$(SBUF_VERSION)#g'\
     95 	    -e 's#@SMSH_VERSION@#$(SMSH_VERSION)#g'\
     96 	    -e 's#@SSF_VERSION@#$(SSF_VERSION)#g'\
     97 	    rngrd.pc.in > rngrd.pc
     98 
     99 rngrd-local.pc: rngrd.pc.in
    100 	sed -e '1d'\
    101 	    -e 's#^includedir=.*#includedir=./src/#'\
    102 	    -e 's#^libdir=.*#libdir=./#'\
    103 	    -e 's#@VERSION@#$(VERSION)#g'\
    104 	    -e 's#@MRUMTL_VERSION@#$(MRUMTL_VERSION)#g'\
    105 	    -e 's#@RNSL_VERSION@#$(RNSL_VERSION)#g'\
    106 	    -e 's#@RSYS_VERSION@#$(RSYS_VERSION)#g'\
    107 	    -e 's#@S3D_VERSION@#$(S3D_VERSION)#g'\
    108 	    -e 's#@SBUF_VERSION@#$(SBUF_VERSION)#g'\
    109 	    -e 's#@SMSH_VERSION@#$(SMSH_VERSION)#g'\
    110 	    -e 's#@SSF_VERSION@#$(SSF_VERSION)#g'\
    111 	    rngrd.pc.in > $@
    112 
    113 install: build_library pkg
    114 	@$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/lib" $(LIBNAME)
    115 	@$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/lib/pkgconfig" rngrd.pc
    116 	@$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/include/rad-net" src/rngrd.h
    117 	@$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/share/doc/rngrd" COPYING README.md
    118 	@$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/share/man/man5" rnsp.5
    119 
    120 uninstall:
    121 	rm -f "$(DESTDIR)$(PREFIX)/lib/$(LIBNAME)"
    122 	rm -f "$(DESTDIR)$(PREFIX)/lib/pkgconfig/rngrd.pc"
    123 	rm -f "$(DESTDIR)$(PREFIX)/share/doc/rngrd/COPYING"
    124 	rm -f "$(DESTDIR)$(PREFIX)/share/doc/rngrd/README.md"
    125 	rm -f "$(DESTDIR)$(PREFIX)/include/rad-net/rngrd.h"
    126 	rm -f "$(DESTDIR)$(PREFIX)/share/man/man5/rnsp.5"
    127 
    128 ################################################################################
    129 # Miscellaneous targets
    130 ################################################################################
    131 all: build_library build_tests
    132 
    133 clean: clean_test
    134 	rm -f $(OBJ) $(LIBNAME)
    135 	rm -f .config librngrd.o rngrd.pc rngrd-local.pc
    136 
    137 distclean: clean
    138 	rm -f $(DEP) src/test_rngrd.d
    139 
    140 lint:
    141 	shellcheck -o all make.sh
    142 	mandoc -Tlint -Wall rnsp.5 || [ $$? -le 1 ]
    143 
    144 ################################################################################
    145 # Tests
    146 ################################################################################
    147 TEST_SRC = src/test_rngrd.c
    148 TEST_OBJ = $(TEST_SRC:.c=.o)
    149 TEST_DEP = $(TEST_SRC:.c=.d)
    150 
    151 PKG_CONFIG_LOCAL = PKG_CONFIG_PATH="./:$${PKG_CONFIG_PATH}" $(PKG_CONFIG)
    152 RNGRD_CFLAGS = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --cflags rngrd-local.pc)
    153 RNGRD_LIBS = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --libs rngrd-local.pc)
    154 
    155 build_tests: build_library src/test_rngrd.d
    156 	@$(MAKE) -fMakefile -f src/test_rngrd.d test_rngrd
    157 
    158 clean_test:
    159 	rm -f test_rngrd src/test_rngrd.o
    160 
    161 $(TEST_DEP): config.mk rngrd-local.pc
    162 	@$(CC) $(CFLAGS_EXE) $(RNGRD_CFLAGS) $(RSYS_CFLAGS) \
    163 	-MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@
    164 
    165 src/test_rngrd.o: config.mk rngrd-local.pc
    166 	$(CC) $(CFLAGS_EXE) $(RNGRD_CFLAGS) $(RSYS_CFLAGS) -c $(@:.o=.c) -o $@
    167 
    168 test_rngrd: src/test_rngrd.o config.mk rngrd-local.pc $(LIBNAME)
    169 	$(CC) $(CFLAGS_EXE) -o $@ src/$@.o $(LDFLAGS_EXE) $(RNGRD_LIBS) $(RSYS_LIBS)