summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Wu <lekensteyn@gmail.com>2013-07-09 18:37:22 +0200
committerPeter Wu <lekensteyn@gmail.com>2013-07-09 18:37:22 +0200
commitcac24b714c2fd65a0df1ec3da490941f0bc84a6b (patch)
treeb080ce8656796158b5c8430fd85ec483fb7ff9e5
parent3edbde6581b7905a721139ed682f2d4e6a30239f (diff)
downloadfemtomail-cac24b714c2fd65a0df1ec3da490941f0bc84a6b.tar.gz
Makefile: cleanup, add uninstall target
Dump objects in current directory, variable `srcdir` (default `.`) is taken as source directory. Use `DESTDIR` only in the `install*`, `uninstall` and `setcap` targets, not as output directory for produced binaries from `$(CC)`.
-rw-r--r--Makefile29
1 files changed, 16 insertions, 13 deletions
diff --git a/Makefile b/Makefile
index 0066b05..134f568 100644
--- a/Makefile
+++ b/Makefile
@@ -1,9 +1,9 @@
-SBINDIR ?= /usr/sbin
-OBJDIR ?= .
+srcdir ?= .
+sbindir ?= /usr/sbin
DESTDIR ?=
INSTALL ?= install
-RM ?= rm
+RM ?= rm -f
LN ?= ln
SETCAP ?= setcap
@@ -12,24 +12,27 @@ ifneq ($(MAILBOX_PATH),)
override CFLAGS += -DMAILBOX_PATH=\"$(MAILBOX_PATH)\"
endif
-all: $(OBJDIR)/femtomail
-.PHONY: all install install-link-sendmail setcap clean
+all: femtomail
+.PHONY: all install install-link-sendmail setcap clean uninstall
-$(OBJDIR)/femtomail: femtomail.c
+femtomail: $(srcdir)/femtomail.c
ifeq ($(USERNAME),)
$(error USERNAME must be set and non-empty)
endif
- $(CC) -DUSERNAME=\"$(USERNAME)\" $(CFLAGS) -o $(DESTDIR)$@ $<
+ $(CC) -DUSERNAME=\"$(USERNAME)\" $(CFLAGS) -o $@ $<
clean:
- $(RM) $(OBJDIR)/femtomail
+ $(RM) femtomail
-install: $(OBJDIR)/femtomail
- $(INSTALL) -m 755 -d $(DESTDIR)$(SBINDIR)
- $(INSTALL) -m 755 $(OBJDIR)/femtomail $(DESTDIR)$(SBINDIR)/femtomail
+install: femtomail
+ $(INSTALL) -m 755 -d $(DESTDIR)$(sbindir)
+ $(INSTALL) -m 755 femtomail $(DESTDIR)$(sbindir)/femtomail
install-link-sendmail: install
- $(LN) -s femtomail $(DESTDIR)$(SBINDIR)/sendmail
+ $(LN) -s femtomail $(DESTDIR)$(sbindir)/sendmail
+
+uninstall:
+ $(RM) $(DESTDIR)$(sbindir)
setcap: install
- $(SETCAP) cap_setuid,cap_setgid=ep $(DESTDIR)$(SBINDIR)/femtomail
+ $(SETCAP) cap_setuid,cap_setgid=ep $(DESTDIR)$(sbindir)/femtomail