Skip to content

Commit 2d86bd1

Browse files
makenowjustAry Borenszweig
authored and
Ary Borenszweig
committedDec 13, 2016
Improve Makefile to hack crystal
- Use spaces instead of tab as an indent of no command line - Add "optional variables" and "recipes" section for help outputs - Output colored llvm-config information (this is same color of ./bin/crystal's "Using compiled compiler at" information)
1 parent 4336aab commit 2d86bd1

File tree

1 file changed

+39
-8
lines changed

1 file changed

+39
-8
lines changed
 

‎Makefile

+39-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
-include Makefile.local # for optional local options e.g. threads
22

3+
# Recipes for this Makefile
4+
5+
## Build the compiler
6+
## $ make
7+
## Clean up built files then build the compiler
8+
## $ make clean crystal
9+
## Build the compiler in release mode
10+
## $ make crystal release=1
11+
## Run all specs in verbose mode
12+
## $ make specs verbose=1
13+
14+
LLVM_CONFIG ?= ## llvm-config command path to use
15+
16+
release ?= ## Compile in release mode
17+
stats ?= ## Enable statistics output
18+
threads ?= ## Maximum number of threads to use
19+
debug ?= ## Add symbolic debug info
20+
verbose ?= ## Run specs in verbose mode
21+
322
O := .build
423
SOURCES := $(shell find src -name '*.cr')
524
SPEC_SOURCES := $(shell find spec -name '*.cr')
@@ -8,12 +27,14 @@ VERBOSE := $(if $(verbose),-v )
827
EXPORTS := $(if $(release),,CRYSTAL_CONFIG_PATH=`pwd`/src)
928
SHELL = bash
1029
LLVM_CONFIG_FINDER := \
11-
[ -n "$(LLVM_CONFIG)" ] && command -v "$(LLVM_CONFIG)" || \
12-
command -v llvm-config-3.9 || command -v llvm-config39 || (command -v llvm-config > /dev/null && (case "$(llvm-config --version)" in 3.9*) command -v llvm-config;; *) false;; esac)) || \
13-
command -v llvm-config-3.8 || command -v llvm-config38 || (command -v llvm-config > /dev/null && (case "$(llvm-config --version)" in 3.8*) command -v llvm-config;; *) false;; esac)) || \
14-
command -v llvm-config-3.6 || command -v llvm-config36 || \
15-
command -v llvm-config-3.5 || command -v llvm-config35 || \
16-
command -v llvm-config
30+
[ -n "$(LLVM_CONFIG)" ] && command -v "$(LLVM_CONFIG)" || \
31+
command -v llvm-config-3.9 || command -v llvm-config39 || \
32+
(command -v llvm-config > /dev/null && (case "$(llvm-config --version)" in 3.9*) command -v llvm-config;; *) false;; esac)) || \
33+
command -v llvm-config-3.8 || command -v llvm-config38 || \
34+
(command -v llvm-config > /dev/null && (case "$(llvm-config --version)" in 3.8*) command -v llvm-config;; *) false;; esac)) || \
35+
command -v llvm-config-3.6 || command -v llvm-config36 || \
36+
command -v llvm-config-3.5 || command -v llvm-config35 || \
37+
command -v llvm-config
1738
LLVM_CONFIG := $(shell $(LLVM_CONFIG_FINDER))
1839
LLVM_EXT_DIR = src/llvm/ext
1940
LLVM_EXT_OBJ = $(LLVM_EXT_DIR)/llvm_ext.o
@@ -26,18 +47,28 @@ CXXFLAGS += $(if $(debug),-g -O0)
2647
ifeq (${LLVM_CONFIG},)
2748
$(error Could not locate llvm-config, make sure it is installed and in your PATH, or set LLVM_CONFIG)
2849
else
29-
$(info Using $(LLVM_CONFIG) [version=$(shell $(LLVM_CONFIG) --version)])
50+
$(info $(shell printf '\033[33m')Using $(LLVM_CONFIG) [version=$(shell $(LLVM_CONFIG) --version)]$(shell printf '\033[0m'))
3051
endif
3152

3253
.PHONY: all
33-
all: crystal
54+
all: crystal ## Build all files (currently crystal only) [default]
3455

3556
.PHONY: help
3657
help: ## Show this help
58+
@echo
3759
@printf '\033[34mtargets:\033[0m\n'
3860
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) |\
3961
sort |\
4062
awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'
63+
@echo
64+
@printf '\033[34moptional variables:\033[0m\n'
65+
@grep -E '^[a-zA-Z_-]+ \?=.*?## .*$$' $(MAKEFILE_LIST) |\
66+
sort |\
67+
awk 'BEGIN {FS = " \\?=.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'
68+
@echo
69+
@printf '\033[34mrecipes:\033[0m\n'
70+
@grep -E '^##.*$$' $(MAKEFILE_LIST) |\
71+
awk 'BEGIN {FS = "## "}; /^## [a-zA-Z_-]/ {printf " \033[36m%s\033[0m\n", $$2}; /^## / {printf " %s\n", $$2}'
4172

4273
.PHONY: spec
4374
spec: all_spec ## Run all specs

0 commit comments

Comments
 (0)
Please sign in to comment.