about summary refs log tree commit diff
path: root/Makefile
diff options
context:
space:
mode:
authorNguyễn Gia Phong <cnx@loang.net>2024-11-05 12:47:14 +0900
committerNguyễn Gia Phong <cnx@loang.net>2024-11-05 16:27:39 +0900
commit1fe6579eb183c8762c6ce41fc2ace742c8f5a5c9 (patch)
tree169abf126dbd3ff291e93194252a17ca3d91cd00 /Makefile
parent3aa0dbdc85f9a4cadac0152ed1bfb4cad7c3174b (diff)
downloadafl-dyninst-1fe6579eb183c8762c6ce41fc2ace742c8f5a5c9.tar.gz
Rework afl-dyninst's CLI
It is now compatible with help2man,
hence the new barebone manual page.
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)