From 3fdc120b565fa1c5f2cc688e19ecc814735d053e Mon Sep 17 00:00:00 2001 From: clutton Date: Wed, 16 Apr 2014 11:51:18 +0300 Subject: [PATCH 1/2] Accorging to the GNU make manual user variables CFLAGS, and LDFLAGS are defined as an empty strings. $@ target, happens to be portable and useful - do not care about exit status Using .PHONY ensures that make won't go looking for nonexistent product files named after these targets. --- Makefile | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index cb25cdb..b661835 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,10 @@ -CFLAGS+= -Wall -I/usr/local/include -LDFLAGS+= -L/usr/local/lib/ -lssh2 +CFLAGS = -Wall -I/usr/local/include +LDFLAGS = -L/usr/local/lib/ -lssh2 all: beleth beleth: beleth.o lists.o ssh.o - $(CC) beleth.o lists.o ssh.o $(LDFLAGS) -o beleth + $(CC) beleth.o lists.o ssh.o $(LDFLAGS) -o $@ beleth.o: beleth.c @@ -13,4 +13,6 @@ lists.o: lists.c ssh.o: ssh.c clean: - rm *.o beleth + -rm *.o beleth + +.PHONY: clean From c8f65eef2b6d990ac807b90f82966034e2fed434 Mon Sep 17 00:00:00 2001 From: clutton Date: Wed, 16 Apr 2014 13:28:16 +0300 Subject: [PATCH 2/2] adding [un]install targets --- Makefile | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index b661835..a1f43f7 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,9 @@ -CFLAGS = -Wall -I/usr/local/include -LDFLAGS = -L/usr/local/lib/ -lssh2 +CFLAGS = -Wall -I/usr/local/include +LDFLAGS = -L/usr/local/lib/ -lssh2 + +prefix = /usr/local +exec_prefix = $(prefix) +bindir = $(exec_prefix)/bin all: beleth @@ -12,7 +16,14 @@ lists.o: lists.c ssh.o: ssh.c +install: + install -d $(DESTDIR)$(bindir) + install -m 0755 beleth $(DESTDIR)$(bindir) + +uninstall: + -rm $(DESTDIR)$(bindir)/beleth + clean: -rm *.o beleth -.PHONY: clean +.PHONY: clean install uninstall