Created
February 25, 2016 17:29
-
-
Save mpenet/5492063faecfbbab1d8e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Build and slim Erlang | |
# Change the line below if you want to use a different version of Erlang | |
# (Keep in mind that patches may not apply cleanly) | |
erlang_version=otp_src_R14B03 | |
erlang_source_file:=$(PACKAGE_SOURCES)/$(erlang_version)/$(erlang_version).tar.gz | |
erlang_root=$(GTH_ERLANG_ROOT)/$(erlang_version) | |
target_prefix=/opt/erlang | |
ifneq ($(COR_TARGET), GTH3) | |
ifneq ($(COR_TARGET), STH3) | |
ifneq ($(COR_TARGET), GTH2D) | |
$(error no COR_TARGET set, or set to an unknown target, giving up) | |
endif | |
endif | |
endif | |
xconf_file=erl-xcomp-armle-linux-gnu.conf | |
install_prefix=$($(COR_TARGET)_INSTALL_BASE) | |
prefix=$(install_prefix)$(target_prefix) | |
ifeq (,$(findstring $(erlang_version),$(erlang_root))) | |
default: | |
@echo "Aborting because Erlang versions do not match" | |
@echo "erlang_root=$(erlang_root)" | |
@echo "erlang_version=$(erlang_version)" | |
@/bin/false | |
endif | |
# Build the actual code | |
# The 'unset' commands are needed because otp_build misbehaves if it realises | |
# it's being run by a makefile. See mail to erlang-bugs 2010-06-22/23 | |
build: $(erlang_version) | |
@if test -d $(prefix); then \ | |
echo "$(prefix) already contains a (partial?) Erlang dist. Aborting, because building over the top of a dist is known to break. Use 'make clean_target' to wipe $(prefix)" ; \ | |
exit 1 ; \ | |
fi | |
sh -c "unset MAKELEVEL; unset MAKEFLAGS; cd $(erlang_version); ./otp_build boot -a" | |
sh -c "cd $(erlang_version); make release RELEASE_ROOT=$(prefix)" | |
# untar, patch, run configure | |
$(erlang_version): $(erlang_source_file) | |
tar -xzf $(erlang_source_file) | |
sh -c "cd $(erlang_version); patch -p 1 < ../patches/better_to_erl_messages" | |
sh -c "cd $(erlang_version); patch -p 1 < ../patches/extern_inline_c99" | |
sh -c "cd $(erlang_version); patch -p 1 < ../patches/perl_5_22_defined_fix" | |
sh -c "cd $(erlang_version); ./otp_build configure --xcomp-conf=../$(xconf_file)" | |
install: run_otp_install slim strip | |
make zip_libraries # run in sub-make; dependencies appeared just now | |
.PHONY run_otp_install: | |
sh -c "cd $(prefix); umask 022; ./Install -cross -minimal /opt/erlang" | |
slim_binaries =$(addprefix $(prefix)/bin/, beam.smp dialyzer epmd erlc heart typer escript ct_run) | |
slim_binaries+=$(addprefix $(prefix)/erts*/bin/, \ | |
beam.smp dialyzer dyn_erl epmd erlc heart start typer escript ct_run *.src) | |
slim_sources +=$(prefix)/erts*/src/ | |
slim_sources +=$(prefix)/erts*/include/ | |
slim_sources +=$(prefix)/erts*/doc/ | |
slim_sources +=$(prefix)/erts*/man/ | |
slim_sources +=$(prefix)/erts*/lib/internal/README | |
slim_sources +=$(prefix)/lib/*/src/ | |
slim_sources +=$(prefix)/lib/*/examples/ | |
slim_sources +=$(prefix)/lib/*/include/ | |
slim_sources +=$(prefix)/lib/*/man/ | |
slim_sources +=$(prefix)/usr/ | |
slim_sources +=$(prefix)/misc/ | |
slim_applications +=$(prefix)/lib/appmon*/ | |
slim_applications +=$(prefix)/lib/asn1*/ | |
slim_applications +=$(prefix)/lib/common_test*/ | |
slim_applications +=$(prefix)/lib/compiler*/ | |
slim_applications +=$(prefix)/lib/cos*/ | |
slim_applications +=$(prefix)/lib/debugger*/ | |
slim_applications +=$(prefix)/lib/dialyzer*/ | |
slim_applications +=$(prefix)/lib/diameter*/ | |
slim_applications +=$(prefix)/lib/docbuilder*/ | |
slim_applications +=$(prefix)/lib/edoc*/ | |
slim_applications +=$(prefix)/lib/erl_docgen*/ | |
slim_applications +=$(prefix)/lib/erl_interface*/ | |
slim_applications +=$(prefix)/lib/et*/ | |
slim_applications +=$(prefix)/lib/eunit*/ | |
slim_applications +=$(prefix)/lib/gs*/ | |
slim_applications +=$(prefix)/lib/hipe*/ | |
slim_applications +=$(prefix)/lib/ic*/ | |
slim_applications +=$(prefix)/lib/inets*/ | |
slim_applications +=$(prefix)/lib/inviso*/ | |
slim_applications +=$(prefix)/lib/jinterface*/ | |
slim_applications +=$(prefix)/lib/megaco*/ | |
slim_applications +=$(prefix)/lib/mnesia*/ | |
slim_applications +=$(prefix)/lib/observer*/ | |
slim_applications +=$(prefix)/lib/orber*/ | |
slim_applications +=$(prefix)/lib/os_mon*/ | |
slim_applications +=$(prefix)/lib/otp_mibs*/ | |
slim_applications +=$(prefix)/lib/parsetools*/ | |
slim_applications +=$(prefix)/lib/percept*/ | |
slim_applications +=$(prefix)/lib/pman*/ | |
slim_applications +=$(prefix)/lib/public_key*/ | |
slim_applications +=$(prefix)/lib/reltool*/ | |
slim_applications +=$(prefix)/lib/runtime_tools*/ | |
slim_applications +=$(prefix)/lib/snmp*/ | |
slim_applications +=$(prefix)/lib/syntax_tools*/ | |
slim_applications +=$(prefix)/lib/test_server*/ | |
slim_applications +=$(prefix)/lib/toolbar*/ | |
slim_applications +=$(prefix)/lib/tools*/ | |
slim_applications +=$(prefix)/lib/typer*/ | |
slim_applications +=$(prefix)/lib/tv*/ | |
slim_applications +=$(prefix)/lib/webtool*/ | |
slim_applications +=$(prefix)/lib/wx*/ | |
slim_applications +=$(prefix)/lib/xmerl*/ | |
slim_applications +=$(prefix)/lib/stdlib*/ebin/win32reg.beam | |
slim_applications +=$(prefix)/lib/sasl*/ebin/systools*.beam | |
slim_applications +=$(prefix)/lib/sasl*/ebin/rb.beam | |
slim_applications +=$(prefix)/lib/sasl*/ebin/rb_format_supp.beam | |
slim_applications +=$(prefix)/lib/sasl*/ebin/erlsrv.beam | |
slim_applications +=$(prefix)/lib/kernel*/ebin/inet6_sctp.beam | |
slim_applications +=$(prefix)/lib/kernel*/ebin/array.beam | |
slim_other_junk +=$(prefix)/erts*/lib/ | |
slim_other_junk +=$(prefix)/Install | |
slim_other_junk +=$(prefix)/releases/ | |
slim_other_junk +=$(prefix)/bin/start_clean.boot | |
slim: | |
rm -f $(slim_binaries) | |
rm -rf $(slim_sources) | |
rm -rf $(slim_applications) | |
rm -rf $(slim_other_junk) | |
$(erlang_version)/bootstrap/bin/erl -noshell -noinput -eval "beam_lib:strip_release(\"$(prefix)\"),init:stop()" | |
rm -rf $(prefix)/bin/run_erl | |
rm -rf $(prefix)/bin/to_erl | |
sh -c "cd $(prefix)/bin; ln -s ../erts*/bin/run_erl ." | |
sh -c "cd $(prefix)/bin; ln -s ../erts*/bin/to_erl ." | |
zip_libraries: $(addsuffix .ez, $(wildcard $(prefix)/lib/*)) | |
%.ez: % | |
sh -c "cd `dirname $@`; zip -n .beam -mr $@ `basename $^`" | |
STRIP=$(CROSS_COMPILE)strip | |
strip: | |
$(STRIP) $(prefix)/erts*/bin/run_erl | |
$(STRIP) $(prefix)/erts*/bin/to_erl | |
$(STRIP) $(prefix)/erts*/bin/beam | |
$(STRIP) $(prefix)/erts*/bin/inet_gethost | |
$(STRIP) $(prefix)/erts*/bin/erlexec | |
$(STRIP) $(prefix)/erts*/bin/child_setup | |
$(STRIP) $(prefix)/bin/run_erl | |
$(STRIP) $(prefix)/bin/to_erl | |
clean: | |
rm -rf $(erlang_version) | |
# removes Erlang from the GTH/STH/GMH target directory | |
clean_target: | |
rm -rf $(prefix) | |
# even deletes downloaded source code | |
dist_clean: clean | |
rm $(erlang_source_file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment