summaryrefslogtreecommitdiff
blob: f3d7f8de43e4d5ec1eda6f2803070d3dfa611af9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
From b88cd2f027e77bd26d1334fc13c4eda796423d19 Mon Sep 17 00:00:00 2001
From: orbea <orbea@riseup.net>
Date: Wed, 24 Mar 2021 09:04:41 -0700
Subject: [PATCH] [build] Add an `install` target for binaries and man pages.

* Makefile (MANPAGES): New variable.
(install) <unix>: New target.
---
 Makefile |   19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 949402f..8352f61 100644
--- a/Makefile
+++ b/Makefile
@@ -194,7 +194,7 @@ else
                 $(LINK_LIBS) $(subst /,$(COMPILER_SEP),$(GRAPH_LIB)) \
                 $(GRAPH_LINK) $(MATH)
 
-  .PHONY: exes clean distclean
+  .PHONY: exes clean distclean install
 
 
   ###################################################################
@@ -317,6 +317,11 @@ else
   # EXES += fttimer
   # EXES += testname
 
+  # Not all demo programs have a man page; we thus check for existence in a
+  # loop.
+  #
+  MANPAGES := $(foreach man,$(EXES),$(wildcard $(TOP_DIR_2)/man/$(man).1))
+
   exes: $(EXES:%=$(BIN_DIR_2)/%$E)
 
 
@@ -567,6 +572,18 @@ else
                         $(GRAPH_LIB) $(COMMON_OBJ) $(FTCOMMON_OBJ)
 	  $(LINK_NEW)
 
+  ifeq ($(PLATFORM),unix)
+    install: exes
+	    $(MKINSTALLDIRS) $(DESTDIR)$(bindir) \
+                             $(DESTDIR)$(mandir)/man1
+	    $(foreach bin,$(EXES), \
+              $(LIBTOOL) --mode=install \
+                $(INSTALL) $(BIN_DIR_2)/$(bin) \
+                           $(DESTDIR)$(bindir)/$(bin);)
+	    $(foreach man,$(MANPAGES), \
+              $(INSTALL) $(man) \
+                         $(DESTDIR)$(mandir)/man1/$(notdir $(man));)
+  endif
 endif
 
 
-- 
GitLab