aboutsummaryrefslogtreecommitdiffstats
path: root/testing/shards/makefile-install.patch
blob: 953a321176e2548c4a2f50359f2237c00a707941 (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
From 92bca3f71124749e80fb7a41918a90287681785d Mon Sep 17 00:00:00 2001
From: Jakub Jirutka <jakub@jirutka.cz>
Date: Wed, 28 Mar 2018 00:42:00 +0200
Subject: [PATCH] Makefile: Add install rules

Upstream-Issue: https://github.com/crystal-lang/shards/pull/197
---
 Makefile  | 19 +++++++++++++++++++
 README.md |  8 +++++---
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 0440a4b..4acf4d3 100644
--- a/Makefile
+++ b/Makefile
@@ -4,6 +4,11 @@ VERSION := $(shell cat VERSION)
 OS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
 ARCH := $(shell uname -m)
 
+DESTDIR := /
+PREFIX := /usr/local
+BINDIR := $(DESTDIR)$(PREFIX)/bin
+MANDIR := $(DESTDIR)$(PREFIX)/share/man
+
 ifeq ($(OS),linux)
 	CRFLAGS := --link-flags "-static -L/opt/crystal/embedded/lib"
 endif
@@ -12,6 +17,7 @@ ifeq ($(OS),darwin)
 	CRFLAGS := --link-flags "-L."
 endif
 
+MANPAGES := $(wildcard src/man/*.[1-8])
 SOURCES := $(wildcard src/*.cr src/**/*.cr)
 TEMPLATES := $(wildcard src/templates/*.ecr)
 
@@ -58,3 +64,16 @@ test_unit:
 test_integration: all
 	$(CRYSTAL) run test/integration/*_test.cr -- --parallel=1
 
+.PHONY: install
+install: install-bin install-man
+
+.PHONY: install-bin
+install-bin: bin/shards
+	mkdir -p $(BINDIR)
+	cp bin/shards $(BINDIR)/
+
+.PHONY: install-man
+install-man:
+	mkdir -p $(MANDIR)/man1 $(MANDIR)/man5
+	cp $(filter %.1,$(MANPAGES)) $(MANDIR)/man1/
+	cp $(filter %.5,$(MANPAGES)) $(MANDIR)/man5/