summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorTobias Wiese <tobias@tobiaswiese.com>2020-08-07 17:40:14 +0200
committerTobias Wiese <tobias@tobiaswiese.com>2020-08-07 17:40:14 +0200
commite1cfd1c7d296cd691d2194187575f3302f66ef92 (patch)
tree7f871b9ad5e64f4067b5cd5662e2194f18924324 /Makefile
parentfc513db3e8bca6be022e95a75723143cb6eca36e (diff)
reorganize directory structure.
move the content of the src/ directory up into the root. There is no real need for putting those files inside an extra directory. Signed-off-by: Tobias Wiese <tobias@tobiaswiese.com>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile49
1 files changed, 40 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index b82db39..341cd46 100644
--- a/Makefile
+++ b/Makefile
@@ -1,14 +1,45 @@
-SHELL = /bin/sh
-prefix = /usr/local
+SHELL = /bin/sh
+prefix = /usr/local
-.PHONY: all clean
-all clean:
- @$(MAKE) -C src/ $@
+VERSION = $(shell git describe --dirty --always)
+DATE_FMT = +%b %d %Y %H:%M:%S UTC
+
+ifdef SOURCE_DATE_EPOCH
+ BUILD_DATE ?= $(shell \
+ date -u -d "@$(SOURCE_DATE_EPOCH)" "$(DATE_FMT)" 2>/dev/null \
+ || date -u -r "@$(SOURCE_DATE_EPOCH)" "$(DATE_FMT)" 2>/dev/null \
+ || date -u "$(DATE_FMT)")
+else
+ BUILD_DATE ?= $(shell date -u "$(DATE_FMT)")
+endif
+
+INSTALL = install
+
+CFLAGS += -Wall -DVERSION="\"$(VERSION)\"" -DBUILD_DATE="\"$(BUILD_DATE)\""
+LDFLAGS +=
+
+TARGETS := exchange
+MAINS := $(addsuffix .o, $(TARGETS))
+OBJ := $(MAINS)
+
+.PHONY: all
+all: $(TARGETS)
+
+.PHONY: clean
+clean:
+ rm -f $(OBJ) $(TARGETS)
.PHONY: distclean
distclean: clean
-.PHONY: install uninstall
-install uninstall:
- $(eval dd := $(shell test -z "$(DESTDIR)" || realpath -m "$(DESTDIR)"))
- @$(MAKE) -C src/ $@ DESTDIR=$(dd) prefix=$(prefix)
+.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 $@ $^