atrtp

Thermodynamic properties of a medium in combustion
git clone git://git.meso-star.fr/atrtp.git
Log | Files | Refs | README | LICENSE

Makefile (4951B)


      1 # Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com)
      2 # Copyright (C) 2020, 2021 Centre National de la Recherche Scientifique
      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_STATIC = libatrtp.a
     23 LIBNAME_SHARED = libatrtp.so
     24 LIBNAME = $(LIBNAME_$(LIB_TYPE))
     25 
     26 ################################################################################
     27 # Library building
     28 ################################################################################
     29 SRC = src/atrtp.c src/atrtp_log.c
     30 OBJ = $(SRC:.c=.o)
     31 DEP = $(SRC:.c=.d)
     32 
     33 build_library: .config $(DEP)
     34 	@$(MAKE) -fMakefile $$(for i in $(DEP); do echo -f $${i}; done) \
     35 	$$(if [ -n "$(LIBNAME)" ]; then \
     36 	     echo "$(LIBNAME)"; \
     37 	   else \
     38 	     echo "$(LIBNAME_SHARED)"; \
     39 	   fi)
     40 
     41 $(DEP) $(OBJ): config.mk
     42 
     43 $(LIBNAME_SHARED): $(OBJ)
     44 	$(CC) $(CFLAGS_SO) $(RSYS_CFLAGS) -o $@ $(OBJ) $(LDFLAGS_SO) $(RSYS_LIBS)
     45 
     46 $(LIBNAME_STATIC): libatrtp.o
     47 	$(AR) -rc $@ $?
     48 	$(RANLIB) $@
     49 
     50 libatrtp.o: $(OBJ)
     51 	$(LD) -r $(OBJ) -o $@
     52 	$(OBJCOPY) $(OCPFLAGS) $@
     53 
     54 .config: config.mk
     55 	@if ! $(PKG_CONFIG) --atleast-version $(RSYS_VERSION) rsys; then \
     56 	  echo "rsys $(RSYS_VERSION) not found" >&2; exit 1; fi
     57 	@echo "config done" > $@
     58 
     59 .SUFFIXES: .c .d .o
     60 .c.d:
     61 	@$(CC) $(CFLAGS_SO) $(RSYS_CFLAGS) -MM -MT "$(@:.d=.o) $@" $< -MF $@
     62 
     63 .c.o:
     64 	$(CC) $(CFLAGS_SO) $(RSYS_CFLAGS) -DATRTP_SHARED_BUILD -c $< -o $@
     65 
     66 ################################################################################
     67 # Installation
     68 ################################################################################
     69 pkg:
     70 	sed -e 's#@PREFIX@#$(PREFIX)#g'\
     71 	    -e 's#@VERSION@#$(VERSION)#g'\
     72 	    -e 's#@RSYS_VERSION@#$(RSYS_VERSION)#g'\
     73 	    atrtp.pc.in > atrtp.pc
     74 
     75 atrtp-local.pc: atrtp.pc.in
     76 	sed -e '1d'\
     77 	    -e 's#^includedir=.*#includedir=./src/#'\
     78 	    -e 's#^libdir=.*#libdir=./#'\
     79 	    -e 's#@VERSION@#$(VERSION)#g'\
     80 	    -e 's#@RSYS_VERSION@#$(RSYS_VERSION)#g'\
     81 	    atrtp.pc.in > $@
     82 
     83 install: build_library pkg
     84 	@$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/lib" $(LIBNAME)
     85 	@$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/lib/pkgconfig" atrtp.pc
     86 	@$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/include/astoria" src/atrtp.h
     87 	@$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/share/doc/atrtp" COPYING README.md
     88 	@$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/share/man/man5" atrtp.5
     89 
     90 uninstall:
     91 	rm -f "$(DESTDIR)$(PREFIX)/lib/$(LIBNAME)"
     92 	rm -f "$(DESTDIR)$(PREFIX)/lib/pkgconfig/atrtp.pc"
     93 	rm -f "$(DESTDIR)$(PREFIX)/share/doc/atrtp/COPYING"
     94 	rm -f "$(DESTDIR)$(PREFIX)/share/doc/atrtp/README.md"
     95 	rm -f "$(DESTDIR)$(PREFIX)/include/astoria/atrtp.h"
     96 	rm -f "$(DESTDIR)$(PREFIX)/share/man/man5/atrtp.5"
     97 
     98 ################################################################################
     99 # Miscellaneous targets
    100 ################################################################################
    101 all: build_library build_tests
    102 
    103 clean: clean_test
    104 	rm -f $(OBJ) $(TEST_OBJ) $(LIBNAME)
    105 	rm -f .config .test libatrtp.o atrtp.pc atrtp-local.pc
    106 
    107 distclean: clean
    108 	rm -f $(DEP) $(TEST_DEP)
    109 
    110 lint:
    111 	shellcheck -o all make.sh
    112 	mandoc -Tlint -Wall atrtp.5
    113 
    114 ################################################################################
    115 # Tests
    116 ################################################################################
    117 TEST_SRC =\
    118  src/test_atrtp.c\
    119  src/test_atrtp_load.c
    120 TEST_OBJ = $(TEST_SRC:.c=.o)
    121 TEST_DEP = $(TEST_SRC:.c=.d)
    122 
    123 PKG_CONFIG_LOCAL = PKG_CONFIG_PATH="./:$${PKG_CONFIG_PATH}" $(PKG_CONFIG)
    124 ATRTP_CFLAGS = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --cflags atrtp-local.pc)
    125 ATRTP_LIBS = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --libs atrtp-local.pc)
    126 
    127 test: build_tests
    128 	@$(SHELL) make.sh run_test $(TEST_SRC)
    129 
    130 build_tests: build_library $(TEST_DEP) .test
    131 	@$(MAKE) -fMakefile -f.test $$(for i in $(TEST_DEP); do echo -f"$${i}"; done) test_bin
    132 
    133 .test: Makefile make.sh
    134 	@$(SHELL) make.sh config_test $(TEST_SRC) > $@
    135 
    136 clean_test:
    137 	$(SHELL) make.sh clean_test $(TEST_SRC)
    138 	rm -f test_file.atrtp
    139 
    140 $(TEST_DEP): config.mk atrtp-local.pc
    141 	@$(CC) $(CFLAGS_EXE) $(ATRTP_CFLAGS) $(RSYS_CFLAGS) \
    142 	-MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@
    143 
    144 $(TEST_OBJ): config.mk atrtp-local.pc
    145 	$(CC) $(CFLAGS_EXE) $(ATRTP_CFLAGS) $(RSYS_CFLAGS) -c $(@:.o=.c) -o $@
    146 
    147 test_atrtp test_atrtp_load: config.mk atrtp-local.pc $(LIBNAME)
    148 	$(CC) $(CFLAGS_EXE) -o $@ src/$@.o $(LDFLAGS_EXE) $(ATRTP_LIBS) $(RSYS_LIBS)