summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile13
-rw-r--r--src/Makefile20
2 files changed, 24 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index ec85e7e..b82db39 100644
--- a/Makefile
+++ b/Makefile
@@ -1,9 +1,14 @@
SHELL = /bin/sh
+prefix = /usr/local
.PHONY: all clean
+all clean:
+ @$(MAKE) -C src/ $@
-all:
- @$(MAKE) -C src/
+.PHONY: distclean
+distclean: clean
-clean:
- @$(MAKE) -C src/ $@
+.PHONY: install uninstall
+install uninstall:
+ $(eval dd := $(shell test -z "$(DESTDIR)" || realpath -m "$(DESTDIR)"))
+ @$(MAKE) -C src/ $@ DESTDIR=$(dd) prefix=$(prefix)
diff --git a/src/Makefile b/src/Makefile
index 972f55e..339522d 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,8 +1,9 @@
-CC := gcc
-CFLAGS := -Wall
-LDFLAGS :=
+INSTALL = install
-CFLAGS += -DVERSIN="\"$(shell git describe --dirty --always)\""
+VERSION = $(shell git describe --dirty --always)
+
+CFLAGS += -Wall -DVERSION="\"$(VERSION)\""
+LDFLAGS +=
TARGETS := exchange
MAINS := $(addsuffix .o, $(TARGETS))
@@ -13,7 +14,16 @@ all: $(TARGETS)
.PHONY: clean
clean:
- rm -rf $(OBJ) $(TARGETS)
+ rm -f $(OBJ) $(TARGETS)
+
+.PHONY: install
+install: $(TARGETS)
+ $(INSTALL) -Dt "$(DESTDIR)$(prefix)/bin" $(TARGETS)
+
+.PHONY: uninstall
+uninstall:
+ cd $(DESTDIR)$(prefix)/bin && rm -f $(TARGETS)
+
$(TARGETS): % : %.o
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^