From 92bca3f71124749e80fb7a41918a90287681785d Mon Sep 17 00:00:00 2001 From: Jakub Jirutka 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/