star-meshtool

Mesh transformation
git clone git://git.meso-star.fr/star-meshtool.git
Log | Files | Refs | README | LICENSE

Makefile (2811B)


      1 # Copyright (C) 2025 |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: tool
     22 all: default
     23 
     24 ################################################################################
     25 # Library building
     26 ################################################################################
     27 SRC =\
     28  src/mtool.c\
     29  src/mtool_args.c\
     30  src/mtool_main.c
     31 OBJ = $(SRC:.c=.o)
     32 DEP = $(SRC:.c=.d)
     33 HDR = src/mtool_version.h
     34 
     35 CFLAGS_TOOL = $(CFLAGS) $(INCS)
     36 LDFLAGS_TOOL = $(LDFLAGS) $(LIBS)
     37 
     38 tool: .config $(DEP)
     39 	@$(MAKE) -fMakefile \
     40 	$$(for i in $(DEP); do printf -- '-f %s\n' "$${i}"; done) \
     41 	mesh-tool
     42 
     43 src/mtool_version.h: config.mk src/mtool_version.h.in
     44 	sed -e 's/@MTOOL_VERSION_MAJOR@/$(VERSION_MAJOR)/' \
     45 	    -e 's/@MTOOL_VERSION_MINOR@/$(VERSION_MINOR)/' \
     46 	    -e 's/@MTOOL_VERSION_PATCH@/$(VERSION_PATCH)/' \
     47 	    $@.in > $@
     48 
     49 $(DEP) $(OBJ): config.mk $(HDR)
     50 
     51 mesh-tool: $(OBJ)
     52 	$(CC) $(CFLAGS_TOOL) -o $@ $(OBJ) $(LDFLAGS_TOOL)
     53 
     54 .config: config.mk
     55 	$(PKG_CONFIG) --atleast-version $(RSYS_VERSION) rsys
     56 	$(PKG_CONFIG) --atleast-version $(SSTL_VERSION) sstl
     57 	@echo "config done" > $@
     58 
     59 .SUFFIXES: .c .d .o
     60 .c.d:
     61 	@$(CC) $(CFLAGS_TOOL) -MM -MT "$(@:.d=.o) $@" $< -MF $@
     62 
     63 .c.o:
     64 	$(CC) $(CFLAGS_TOOL) -c $< -o $@
     65 
     66 ################################################################################
     67 # Installation
     68 ################################################################################
     69 install: all
     70 	install() { mode="$$1"; prefix="$$2"; shift 2; \
     71 	  mkdir -p "$${prefix}"; \
     72 	  cp "$$@" "$${prefix}"; \
     73 	  printf '%s\n' "$${@}" | while read -r i; do \
     74 	    chmod "$${mode}" "$${prefix}/$${i##*/}"; \
     75 	  done; \
     76 	}; \
     77 	install 755 "$(DESTDIR)$(BINPREFIX)" mesh-tool; \
     78 	install 644 "$(DESTDIR)$(MANPREFIX)/man1" doc/mesh-tool.1; \
     79 	install 644 "$(DESTDIR)$(PREFIX)/share/doc/mesh-tool" COPYING README.md
     80 
     81 uninstall:
     82 	rm -f "$(DESTDIR)$(BINPREFIX)/mesh-tool"
     83 	rm -f "$(DESTDIR)$(MANPREFIX)/man1/mesh-tool.1"
     84 	rm -f "$(DESTDIR)$(PREFIX)/share/doc/mesh-tool/COPYING"
     85 	rm -f "$(DESTDIR)$(PREFIX)/share/doc/mesh-tool/README.md"
     86 
     87 clean:
     88 	rm -f $(HDR) $(OBJ) $(DEP) .config mesh-tool
     89 
     90 lint:
     91 	mandoc -Tlint -Wall doc/mesh-tool.1