summary refs log tree commit diff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile20
1 files changed, 15 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index df078b0..9c7135c 100644
--- a/Makefile
+++ b/Makefile
@@ -14,13 +14,14 @@ VERSION ::= 1.0.0
 PREFIX ?= /usr/local
 BINDIR ::= $(DESTDIR)$(PREFIX)/bin
 LIBDIR ::= $(DESTDIR)$(PREFIX)/lib
+MANDIR ::= $(DESTDIR)$(PREFIX)/share/man
 
 # Override on non-FHS environments
 DYNINST_LIB ?= $(LIBDIR)
 # Override to . for local development
 AFL_DYNINST_LIB ?= $(LIBDIR)
 
-CPPFLAGS = -DPROG=\"afl-dyninst\" -DVERSION=\"$(VERSION)\"\
+CPPFLAGS = -DVERSION=\"$(VERSION)\"\
 	-DAFL_DYNINST_LIB=\"$(AFL_DYNINST_LIB)/libafldyninst.so\"\
 	-DDYNINSTAPI_RT_LIB=\"$(DYNINST_LIB)/libdyninstAPI_RT.so\"
 CXXFLAGS += -std=c++11 -Wextra -Werror
@@ -29,8 +30,9 @@ LDLIBS += -ldyninstAPI
 
 BIN ::= afl-dyninst afl-dyninst-env
 LIB ::= libafldyninst.so
+MAN ::= afl-dyninst.1
 
-all: $(BIN) $(LIB)
+all: $(BIN) $(LIB) $(MAN)
 
 afl-dyninst: afl-dyninst.cc
 
@@ -41,10 +43,13 @@ afl-dyninst-env: afl-dyninst-env.m4
 %.so: %.cc
 	$(CXX) $(CXXFLAGS) $(LDFLAGS) -shared $< -o $@
 
+%.1: %
+	help2man --no-info --output=$@ `realpath $<`
+
 clean:
-	rm -f $(BIN) $(LIB)
+	rm -f $(BIN) $(LIB) $(MAN)
 
-install: $(BIN:%=$(BINDIR)/%) $(LIB:%=$(LIBDIR)/%)
+install: $(BIN:%=$(BINDIR)/%) $(LIB:%=$(LIBDIR)/%) $(MAN:%.1:$(MANDIR)/man1/%.1)
 
 $(BINDIR)/%: %
 	install -Dm 755 $< $@
@@ -52,5 +57,10 @@ $(BINDIR)/%: %
 $(LIBDIR)/%: %
 	install -Dm 644 $< $@
 
+$(MANDIR)/man1/%.1 : %.1
+	install -Dm 644 $< $@
+
 uninstall:
-	rm -f $(BIN:%=$(BINDIR)/%) $(LIB:%=$(LIBDIR)/%)
+	rm -f $(BIN:%=$(BINDIR)/%)
+	rm -f $(LIB:%=$(LIBDIR)/%)
+	rm -f $(MAN:%.1:$(MANDIR)/man1/%.1)