Skip to content

Commit

Permalink
Allow compiling in release, static, or with LDFLAGS
Browse files Browse the repository at this point in the history
  • Loading branch information
maxfierke committed Dec 29, 2018
1 parent 5951f90 commit 3b29d4e
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,43 @@ CRYSTAL_BIN ?= $(shell which crystal)
SHARDS_BIN ?= $(shell which shards)
FINCHER_BIN ?= $(shell which fincher)
PREFIX ?= /usr/local
RELEASE ?=
STATIC ?=
SOURCES = src/*.cr src/**/*.cr

override CRFLAGS += $(if $(RELEASE),--release,--debug)$(if $(STATIC),--static )$(if $(LDFLAGS),--link-flags="$(LDFLAGS)" )

.PHONY: all
all: build
build: deps $(SOURCES)

bin/fincher: deps $(SOURCES)
mkdir -p bin
$(CRYSTAL_BIN) build --debug -o bin/fincher src/cli.cr $(CRFLAGS)
release: deps $(SOURCES)
mkdir -p dist
$(CRYSTAL_BIN) build --release -o dist/fincher src/cli.cr $(CRFLAGS)
$(CRYSTAL_BIN) build -o bin/fincher src/cli.cr $(CRFLAGS)

.PHONY: build
build: bin/fincher

.PHONY: deps
deps:
$(SHARDS_BIN) check || $(SHARDS_BIN) install

.PHONY: clean
clean:
rm -f ./bin/fincher*
rm -rf ./dist
test: build

.PHONY: test
test: deps $(SOURCES)
$(CRYSTAL_BIN) spec

.PHONY: spec
spec: test
install: build

.PHONY: install
install: bin/fincher
mkdir -p $(PREFIX)/bin
cp ./bin/fincher $(PREFIX)/bin
reinstall: build

.PHONY: reinstall
reinstall: bin/fincher
cp ./bin/fincher $(FINCHER_BIN) -rf

0 comments on commit 3b29d4e

Please sign in to comment.