Skip to content

Commit b76387a

Browse files
author
José Valim
committed
Merge pull request #2249 from alco/makefile-version-check
Add a target to check minimum required Erlang version
2 parents 64c5acb + 9ed4d91 commit b76387a

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

Makefile

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ ELIXIRC := bin/elixirc --verbose --ignore-module-conflict
33
ERLC := erlc -I lib/elixir/include
44
ERL := erl -I lib/elixir/include -noshell -pa lib/elixir/ebin
55
VERSION := $(strip $(shell cat VERSION))
6+
MIN_ERLANG_VERSION := 17
67
Q := @
78
PREFIX := /usr/local
89
LIBDIR := lib
@@ -11,7 +12,7 @@ INSTALL_DIR = $(INSTALL) -m755 -d
1112
INSTALL_DATA = $(INSTALL) -m644
1213
INSTALL_PROGRAM = $(INSTALL) -m755
1314

14-
.PHONY: install compile erlang elixir dialyze test clean docs release_docs release_zip
15+
.PHONY: install compile erlang elixir dialyze test clean docs release_docs release_zip check_erlang_release
1516
.NOTPARALLEL: compile
1617

1718
#==> Templates
@@ -43,7 +44,16 @@ UNICODE:=lib/elixir/ebin/Elixir.String.Unicode.beam
4344

4445
default: compile
4546

46-
compile: lib/elixir/src/elixir.app.src erlang elixir
47+
compile: check_erlang_release lib/elixir/src/elixir.app.src erlang elixir
48+
49+
# this check should work for older versions like R16B
50+
# as well as new verions like 17.1 and 18
51+
check_erlang_release:
52+
@ erl -noshell -eval 'io:fwrite("~s", [erlang:system_info(otp_release)])' -s erlang halt | grep -q '^1[789]'; \
53+
if [ $$? != 0 ]; then \
54+
echo "At least Erlang 17.0 is required to build Elixir"; \
55+
exit 1; \
56+
fi
4757

4858
lib/elixir/src/elixir.app.src: src/elixir.app.src
4959
$(Q) rm -rf lib/elixir/src/elixir.app.src
@@ -61,7 +71,7 @@ elixir: kernel lib/eex/ebin/Elixir.EEx.beam mix ex_unit eex iex
6171

6272
kernel: $(KERNEL) VERSION
6373
$(KERNEL): lib/elixir/lib/*.ex lib/elixir/lib/*/*.ex
64-
$(Q) if [ ! -f $(KERNEL) ]; then \
74+
$(Q) if [ ! -f $(KERNEL) ]; then \
6575
echo "==> bootstrap (compile)"; \
6676
$(ERL) -s elixir_compiler core -s erlang halt; \
6777
fi

0 commit comments

Comments
 (0)