From a6589c62a4aa858c2381c812ecfabd9568ad938c Mon Sep 17 00:00:00 2001 From: hasufell Date: Wed, 10 Jul 2013 14:27:40 +0200 Subject: [PATCH 1/3] MAKE: allow more verbose build output people can now run: make Q= to get a the maximum of build output --- Makefile | 53 +++++++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/Makefile b/Makefile index 1e7fa98fb7..976e13cab9 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,7 @@ ERLC := erlc -I lib/elixir/include ERL := erl -I lib/elixir/include -noshell -pa lib/elixir/ebin VERSION := $(strip $(shell cat VERSION)) INSTALL_PATH := /usr/local +Q := @ .PHONY: install compile erlang elixir dialyze test clean docs release_docs release_zip release_erl .NOTPARALLEL: compile @@ -14,15 +15,15 @@ define APP_TEMPLATE $(1): lib/$(1)/ebin/Elixir.$(2).beam lib/$(1)/ebin/$(1).app lib/$(1)/ebin/$(1).app: - @ cd lib/$(1) && ../../bin/elixir -e "Mix.Server.start_link(:dev)" -r mix.exs -e "Mix.Task.run('compile.app')" + $(Q) cd lib/$(1) && ../../bin/elixir -e "Mix.Server.start_link(:dev)" -r mix.exs -e "Mix.Task.run('compile.app')" lib/$(1)/ebin/Elixir.$(2).beam: $(wildcard lib/$(1)/lib/*.ex) $(wildcard lib/$(1)/lib/*/*.ex) $(wildcard lib/$(1)/lib/*/*/*.ex) @ echo "==> $(1) (compile)" - @ $$(ELIXIRC) "lib/$(1)/lib/**/*.ex" -o lib/$(1)/ebin + $(Q) $$(ELIXIRC) "lib/$(1)/lib/**/*.ex" -o lib/$(1)/ebin test_$(1): $(1) @ echo "==> $(1) (exunit)" - @ cd lib/$(1) && ../../bin/elixir -r "test/test_helper.exs" -pr "test/**/*_test.exs"; + $(Q) cd lib/$(1) && ../../bin/elixir -r "test/test_helper.exs" -pr "test/**/*_test.exs"; endef #==> Compilation tasks @@ -35,11 +36,11 @@ default: compile compile: lib/elixir/src/elixir.app.src erlang elixir lib/elixir/src/elixir.app.src: src/elixir.app.src - @ rm -rf lib/elixir/src/elixir.app.src - @ cp src/elixir.app.src lib/elixir/src/elixir.app.src + $(Q) rm -rf lib/elixir/src/elixir.app.src + $(Q) cp src/elixir.app.src lib/elixir/src/elixir.app.src erlang: - @ cd lib/elixir && $(REBAR) compile + $(Q) cd lib/elixir && $(REBAR) compile # Since Mix depends on EEx and EEx depends on # Mix, we first compile EEx without the .app @@ -48,21 +49,21 @@ elixir: kernel lib/eex/ebin/Elixir.EEx.beam mix ex_unit eex iex kernel: $(KERNEL) VERSION $(KERNEL): lib/elixir/lib/*.ex lib/elixir/lib/*/*.ex - @ if [ ! -f $(KERNEL) ]; then \ + $(Q) if [ ! -f $(KERNEL) ]; then \ echo "==> bootstrap (compile)"; \ $(ERL) -s elixir_compiler core -s erlang halt; \ fi @ echo "==> kernel (compile)"; - @ $(ELIXIRC) "lib/elixir/lib/**/*.ex" -o lib/elixir/ebin; - @ $(MAKE) unicode - @ rm -rf lib/elixir/ebin/elixir.app - @ cd lib/elixir && $(REBAR) compile + $(Q) $(ELIXIRC) "lib/elixir/lib/**/*.ex" -o lib/elixir/ebin; + $(Q) $(MAKE) unicode + $(Q) rm -rf lib/elixir/ebin/elixir.app + $(Q) cd lib/elixir && $(REBAR) compile unicode: $(UNICODE) $(UNICODE): lib/elixir/priv/unicode.ex lib/elixir/priv/UnicodeData.txt lib/elixir/priv/NamedSequences.txt @ echo "==> unicode (compile)"; @ echo "This step can take up to a minute to compile in order to embed the Unicode database" - @ $(ELIXIRC) lib/elixir/priv/unicode.ex -o lib/elixir/ebin; + $(Q) $(ELIXIRC) lib/elixir/priv/unicode.ex -o lib/elixir/ebin; $(eval $(call APP_TEMPLATE,ex_unit,ExUnit)) $(eval $(call APP_TEMPLATE,eex,EEx)) @@ -81,7 +82,7 @@ install: compile ln -sf $(INSTALL_PATH)/lib/elixir/bin/* $(INSTALL_PATH)/bin clean: - @ cd lib/elixir && $(REBAR) clean + $(Q) cd lib/elixir && $(REBAR) clean rm -rf ebin rm -rf lib/*/ebin rm -rf lib/*/test/tmp @@ -93,7 +94,7 @@ clean: rm -rf lib/elixir/test/ebin clean_exbeam: - @ rm -f lib/*/ebin/Elixir.*.beam + $(Q) rm -f lib/*/ebin/Elixir.*.beam #==> Release tasks @@ -120,8 +121,8 @@ release_docs: docs mv docs ../elixir-lang.github.com/docs/master release_erl: compile - @ rm -rf rel/elixir - @ cd rel && ../rebar generate + $(Q) rm -rf rel/elixir + $(Q) cd rel && ../rebar generate #==> Tests tasks @@ -129,29 +130,29 @@ test: test_erlang test_elixir test_erlang: compile @ echo "==> elixir (eunit)" - @ mkdir -p lib/elixir/test/ebin - @ $(ERLC) -pa lib/elixir/ebin -o lib/elixir/test/ebin lib/elixir/test/erlang/*.erl - @ $(ERL) -pa lib/elixir/test/ebin -s test_helper test -s erlang halt; + $(Q) mkdir -p lib/elixir/test/ebin + $(Q) $(ERLC) -pa lib/elixir/ebin -o lib/elixir/test/ebin lib/elixir/test/erlang/*.erl + $(Q) $(ERL) -pa lib/elixir/test/ebin -s test_helper test -s erlang halt; @ echo test_elixir: test_kernel test_ex_unit test_doc_test test_mix test_eex test_iex test_doc_test: compile @ echo "==> doctest (exunit)" - @ cd lib/elixir && ../../bin/elixir -r "test/doc_test.exs"; + $(Q) cd lib/elixir && ../../bin/elixir -r "test/doc_test.exs"; test_kernel: compile @ echo "==> kernel (exunit)" - @ cd lib/elixir && ../../bin/elixir -r "test/elixir/test_helper.exs" -pr "test/elixir/**/*_test.exs"; + $(Q) cd lib/elixir && ../../bin/elixir -r "test/elixir/test_helper.exs" -pr "test/elixir/**/*_test.exs"; .dialyzer.base_plt: @ echo "==> Adding Erlang/OTP basic applications to a new base PLT" - @ dialyzer --output_plt .dialyzer.base_plt --build_plt --apps erts kernel stdlib compiler syntax_tools inets crypto ssl + $(Q) dialyzer --output_plt .dialyzer.base_plt --build_plt --apps erts kernel stdlib compiler syntax_tools inets crypto ssl dialyze: .dialyzer.base_plt - @ rm -f .dialyzer_plt - @ cp .dialyzer.base_plt .dialyzer_plt + $(Q) rm -f .dialyzer_plt + $(Q) cp .dialyzer.base_plt .dialyzer_plt @ echo "==> Adding Elixir to PLT..." - @ dialyzer --plt .dialyzer_plt --add_to_plt -r lib/elixir/ebin lib/ex_unit/ebin lib/mix/ebin lib/iex/ebin lib/eex/ebin + $(Q) dialyzer --plt .dialyzer_plt --add_to_plt -r lib/elixir/ebin lib/ex_unit/ebin lib/mix/ebin lib/iex/ebin lib/eex/ebin @ echo "==> Dialyzing Elixir..." - @ dialyzer --plt .dialyzer_plt -r lib/elixir/ebin lib/ex_unit/ebin lib/mix/ebin lib/iex/ebin lib/eex/ebin + $(Q) dialyzer --plt .dialyzer_plt -r lib/elixir/ebin lib/ex_unit/ebin lib/mix/ebin lib/iex/ebin lib/eex/ebin From f9afc520ca8fdd6f56dd0fe7fa850b2be16e173a Mon Sep 17 00:00:00 2001 From: hasufell Date: Wed, 10 Jul 2013 14:52:48 +0200 Subject: [PATCH 2/3] MAKE: standardize install variables - convert to autotools-like variables commonly used in build scripts - respect DESTDIR (used for temporary install locations) - fix symlink logic to work with DESTDIR ${foo##bar} is posix, see: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html under "2.6.2 Parameter Expansion" - quote all variables that can contain whitespace (make does not take care of that!) --- Makefile | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 976e13cab9..973cb5e905 100644 --- a/Makefile +++ b/Makefile @@ -3,8 +3,13 @@ ELIXIRC := bin/elixirc --ignore-module-conflict $(ELIXIRC_OPTS) ERLC := erlc -I lib/elixir/include ERL := erl -I lib/elixir/include -noshell -pa lib/elixir/ebin VERSION := $(strip $(shell cat VERSION)) -INSTALL_PATH := /usr/local Q := @ +PREFIX := /usr/local +INSTALL = install +INSTALL_DIR = $(INSTALL) -m755 -d +INSTALL_DATA = $(INSTALL) -m644 +INSTALL_PROGRAM = $(INSTALL) -m755 + .PHONY: install compile erlang elixir dialyze test clean docs release_docs release_zip release_erl .NOTPARALLEL: compile @@ -73,13 +78,15 @@ $(eval $(call APP_TEMPLATE,iex,IEx)) install: compile @ echo "==> elixir (install)" for dir in lib/*; do \ - install -m755 -d $(INSTALL_PATH)/lib/elixir/$$dir/ebin; \ - install -m644 $$dir/ebin/* $(INSTALL_PATH)/lib/elixir/$$dir/ebin; \ + $(INSTALL_DIR) "$(DESTDIR)$(PREFIX)/lib/elixir/$$dir/ebin"; \ + $(INSTALL_DATA) $$dir/ebin/* "$(DESTDIR)$(PREFIX)/lib/elixir/$$dir/ebin"; \ + done + $(INSTALL_DIR) "$(DESTDIR)$(PREFIX)/lib/elixir/bin" + $(INSTALL_PROGRAM) $(filter-out %.bat, $(wildcard bin/*)) "$(DESTDIR)$(PREFIX)/lib/elixir/bin" + $(INSTALL_DIR) "$(DESTDIR)$(PREFIX)/bin" + for file in "$(DESTDIR)$(PREFIX)"/lib/elixir/bin/* ; do \ + ln -sf "../lib/elixir/bin/$${file##*/}" "$(DESTDIR)$(PREFIX)/bin/" ; \ done - install -m755 -d $(INSTALL_PATH)/lib/elixir/bin - install -m755 $(filter-out %.bat, $(wildcard bin/*)) $(INSTALL_PATH)/lib/elixir/bin - install -m755 -d $(INSTALL_PATH)/bin - ln -sf $(INSTALL_PATH)/lib/elixir/bin/* $(INSTALL_PATH)/bin clean: $(Q) cd lib/elixir && $(REBAR) clean From b0f9d7e9bce98a2b6fb4fe2ed20de706bb8f51c7 Mon Sep 17 00:00:00 2001 From: hasufell Date: Wed, 10 Jul 2013 14:54:53 +0200 Subject: [PATCH 3/3] MAKE: respect LIBDIR variable Some distributions do not use plain "lib", rather "lib64" and "lib32". Allow to control this variable. --- Makefile | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 973cb5e905..82c40b5068 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,7 @@ ERL := erl -I lib/elixir/include -noshell -pa lib/elixir/ebin VERSION := $(strip $(shell cat VERSION)) Q := @ PREFIX := /usr/local +LIBDIR := lib INSTALL = install INSTALL_DIR = $(INSTALL) -m755 -d INSTALL_DATA = $(INSTALL) -m644 @@ -78,14 +79,14 @@ $(eval $(call APP_TEMPLATE,iex,IEx)) install: compile @ echo "==> elixir (install)" for dir in lib/*; do \ - $(INSTALL_DIR) "$(DESTDIR)$(PREFIX)/lib/elixir/$$dir/ebin"; \ - $(INSTALL_DATA) $$dir/ebin/* "$(DESTDIR)$(PREFIX)/lib/elixir/$$dir/ebin"; \ + $(INSTALL_DIR) "$(DESTDIR)$(PREFIX)/$(LIBDIR)/elixir/$$dir/ebin"; \ + $(INSTALL_DATA) $$dir/ebin/* "$(DESTDIR)$(PREFIX)/$(LIBDIR)/elixir/$$dir/ebin"; \ done - $(INSTALL_DIR) "$(DESTDIR)$(PREFIX)/lib/elixir/bin" - $(INSTALL_PROGRAM) $(filter-out %.bat, $(wildcard bin/*)) "$(DESTDIR)$(PREFIX)/lib/elixir/bin" + $(INSTALL_DIR) "$(DESTDIR)$(PREFIX)/$(LIBDIR)/elixir/bin" + $(INSTALL_PROGRAM) $(filter-out %.bat, $(wildcard bin/*)) "$(DESTDIR)$(PREFIX)/$(LIBDIR)/elixir/bin" $(INSTALL_DIR) "$(DESTDIR)$(PREFIX)/bin" - for file in "$(DESTDIR)$(PREFIX)"/lib/elixir/bin/* ; do \ - ln -sf "../lib/elixir/bin/$${file##*/}" "$(DESTDIR)$(PREFIX)/bin/" ; \ + for file in "$(DESTDIR)$(PREFIX)"/$(LIBDIR)/elixir/bin/* ; do \ + ln -sf "../$(LIBDIR)/elixir/bin/$${file##*/}" "$(DESTDIR)$(PREFIX)/bin/" ; \ done clean: