Merge pull request #13 from CoelacanthusHex/fix-makefile

chore: refine Makefile with Makefile Conventions
This commit is contained in:
markqvist 2023-05-31 18:20:45 +02:00 committed by GitHub
commit bb4b1917d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 14 deletions

View File

@ -1,33 +1,35 @@
.DEFAULT_GOAL := all .DEFAULT_GOAL := all
.PHONY: all clean install uninstall tncattach .PHONY: all clean install uninstall tncattach
compiler = gcc RM ?= rm
flags = -Wall -std=gnu11 -static-libgcc INSTALL ?= install
CC ?= gcc
CFLAGS ?= -Wall -std=gnu11 -static-libgcc
LDFLAGS ?=
PREFIX ?= /usr/local
all: tncattach all: tncattach
rebuild: clean all rebuild: clean all
clean: clean:
@echo "Cleaning tncattach build..." @echo "Cleaning tncattach build..."
@rm -f tncattach $(RM) -f tncattach
tncattach: tncattach:
@echo "Making tncattach..." @echo "Making tncattach..."
@echo "Compiling with: ${compiler}" @echo "Compiling with: $(CC)"
${compiler} ${flags} tncattach.c Serial.c TCP.c KISS.c TAP.c -o tncattach -Wall $(CC) $(CFLAGS) $(LDFLAGS) tncattach.c Serial.c TCP.c KISS.c TAP.c -o tncattach
install: install:
@echo "Installing tncattach..." @echo "Installing tncattach..."
@chmod a+x tncattach $(INSTALL) -d $(DESTDIR)/$(PREFIX)/bin
cp ./tncattach /usr/local/sbin/ $(INSTALL) -Dm755 tncattach $(DESTDIR)/$(PREFIX)/bin/tncattach
@echo "Installing man page..." @echo "Installing man page..."
@mkdir -p /usr/local/man/man8 gzip -9 tncattach.8
@install -m 644 -o root -g root tncattach.8 /usr/local/man/man8/tncattach.8 $(INSTALL) -d $(DESTDIR)/$(PREFIX)/share/man/man8
@echo "Updating mandb..." $(INSTALL) -Dm644 tncattach.8.gz $(DESTDIR)/$(PREFIX)/share/man/man8/tncattach.8.gz
@mandb -f /usr/local/man/man8/tncattach.8 2> /dev/null 1> /dev/null
@echo "Done"
uninstall: uninstall:
@echo "Uninstalling tncattach" @echo "Uninstalling tncattach"
rm /usr/local/sbin/tncattach $(RM) $(DESTDIR)/$(PREFIX)/bin/tncattach
rm /usr/local/man/man8/tncattach.8 $(RM) $(DESTDIR)/$(PREFIX)/share/man/man8/tncattach.8.gz