Makefile (4126B)
1 # Copyright (C) 2020-2022, 2024 |Méso|Star> (contact@meso-star.com) 2 # 3 # This program is free software: you can redistribute it and/or modify 4 # it under the terms of the GNU General Public License as published by 5 # the Free Software Foundation, either version 3 of the License, or 6 # (at your option) any later version. 7 # 8 # This program is distributed in the hope that it will be useful, 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 # GNU General Public License for more details. 12 # 13 # You should have received a copy of the GNU General Public License 14 # along with this program. If not, see <http://www.gnu.org/licenses/>. */ 15 16 .POSIX: 17 .SUFFIXES: # Clean up default inference rules 18 19 include config.mk 20 21 default: build_executable 22 23 ################################################################################ 24 # Program building 25 ################################################################################ 26 SRC =\ 27 src/green-args.c\ 28 src/green-compute.c\ 29 src/green-input.c\ 30 src/green-main.c\ 31 src/green-output.c 32 OBJ = $(SRC:.c=.o) 33 DEP = $(SRC:.c=.d) 34 35 # Headers to configure 36 HDR =\ 37 src/green-default.h\ 38 src/green-version.h 39 40 build_executable: .config $(HDR) $(DEP) 41 @$(MAKE) -fMakefile $$(for i in $(DEP); do echo -f $${i}; done) sgreen 42 43 $(DEP) $(HDR) $(OBJ): config.mk 44 45 sgreen: $(OBJ) 46 $(CC) $(CFLAGS) $(DPDC_CFLAGS) -o $@ $(OBJ) $(LDFLAGS) $(DPDC_LIBS) 47 48 .config: config.mk 49 @if ! $(PKG_CONFIG) --atleast-version $(RSYS_VERSION) rsys; then \ 50 echo "rsys $(RSYS_VERSION) not found" >&2; exit 1; fi 51 @if ! $(PKG_CONFIG) --atleast-version $(STARDIS_VERSION) stardis; then \ 52 echo "stardis $(STARDIS_VERSION) not found" >&2; exit 1; fi 53 @echo "config done" > $@ 54 55 src/green-default.h: src/green-default.h.in 56 sed -e 's#@GREEN_ARGS_DEFAULT_VERBOSE_LEVEL@#$(GREEN_ARGS_DEFAULT_VERBOSE_LEVEL)#g'\ 57 $@.in > $@ 58 59 src/green-version.h: src/green-version.h.in 60 sed -e 's/@GREEN_VERSION_MAJOR@/$(VERSION_MAJOR)/' \ 61 -e 's/@GREEN_VERSION_MINOR@/$(VERSION_MINOR)/' \ 62 -e 's/@GREEN_VERSION_PATCH@/$(VERSION_PATCH)/' \ 63 $@.in > $@ 64 65 .SUFFIXES: .c .d .o 66 .c.d: 67 @$(CC) $(CFLAGS) $(DPDC_CFLAGS) -MM -MT "$(@:.d=.o) $@" $< -MF $@ 68 69 .c.o: 70 $(CC) $(CFLAGS) $(DPDC_CFLAGS) -c $< -o $@ 71 72 ################################################################################ 73 # Manual pages 74 ################################################################################ 75 man: doc/sgreen.1 76 77 doc/sgreen.1: doc/sgreen.1.in 78 sed -e 's#@GREEN_ARGS_DEFAULT_VERBOSE_LEVEL@#$(GREEN_ARGS_DEFAULT_VERBOSE_LEVEL)#g'\ 79 $@.in > $@ 80 81 ################################################################################ 82 # Installation 83 ################################################################################ 84 install: build_executable man 85 @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/bin" sgreen 86 @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/share/man/man1" doc/sgreen.1 87 @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/share/man/man5" doc/sgreen-input.5 88 @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/share/man/man5" doc/sgreen-output.5 89 @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/share/doc/stardis-green" COPYING 90 @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/share/doc/stardis-green" README.md 91 92 uninstall: 93 rm -f "$(DESTDIR)$(PREFIX)/bin/sgreen" 94 rm -f "$(DESTDIR)$(PREFIX)/share/man/man1/sgreen.1" 95 rm -f "$(DESTDIR)$(PREFIX)/share/man/man5/sgreen-input.5" 96 rm -f "$(DESTDIR)$(PREFIX)/share/man/man5/sgreen-output.5" 97 rm -f "$(DESTDIR)$(PREFIX)/share/doc/stardis-green/COPYING" 98 rm -f "$(DESTDIR)$(PREFIX)/share/doc/stardis-green/README.md" 99 100 ################################################################################ 101 # Miscellaneous targets 102 ################################################################################ 103 all: build_library build_tests 104 105 clean: 106 rm -f $(OBJ) $(HDR) .config sgreen doc/sgreen.1 107 108 distclean: clean 109 rm -f $(DEP) 110 111 lint: man 112 shellcheck -o all make.sh 113 mandoc -Tlint -Wall doc/sgreen.1 || [ $$? -le 1 ] 114 mandoc -Tlint -Wall doc/sgreen-input.5 || [ $$? -le 1 ] 115 mandoc -Tlint -Wall doc/sgreen-output.5 || [ $$? -le 1 ]