From 1b78e85c9b6097f0d1940793e5fed4e08c0794f9 Mon Sep 17 00:00:00 2001 From: Rickard Green Date: Wed, 3 Feb 2010 12:56:25 +0000 Subject: OTP-8323 Cross compilation improvements and other build system improvements. Most notable: Lots of cross compilation improvements. The old cross compilation support was more or less non-existing as well as broken. Please, note that the cross compilation support should still be considered as experimental. Also note that old cross compilation configurations cannot be used without modifications. For more information on cross compiling Erlang/OTP see the $ERL_TOP/xcomp/README file. Support for staged install using D ESTDIR. The old broken INSTALL_PREFIX has also been fixed. For more information see the $ERL_TOP/README file. Documentation of the release target of the top Makefile. For more information see the $ERL_TOP/README file. make install now by default creates relative symbolic links instead of absolute ones. For more information see the $ERL_TOP/README file. $ERL_TOP/configure --help=recursive now works and prints help for all applications with configure scripts. Doing make install, or make release directly after make all no longer triggers miscellaneous rebuilds. Existing bootstrap system is now used when doing make install, or make release without a preceding make all. The crypto and ssl applications use the same runtime library path when dynamically linking against libssl.so and libcrypto.so. The runtime library search path has also been extended. The configure scripts of erl_interface and odbc now search for thread libraries and thread library quirks the same way as erts do. The configure script of the odbc application now also looks for odbc libraries in lib64 and lib/64 directories when building on a 64-bit system. The config.h.in file in the erl_interface application is now automatically generated in instead of statically updated which reduces the risk of configure tests without any effect. --- make/cross_check_erl | 147 +++++++++++ make/install_bin | 702 +++++++++++++++++++++++++++++++++++++++++++++++++++ make/otp_ded.mk.in | 44 +++- make/unexpected_use | 29 +++ 4 files changed, 913 insertions(+), 9 deletions(-) create mode 100755 make/cross_check_erl create mode 100755 make/install_bin create mode 100755 make/unexpected_use (limited to 'make') diff --git a/make/cross_check_erl b/make/cross_check_erl new file mode 100755 index 0000000000..cb9dadfb32 --- /dev/null +++ b/make/cross_check_erl @@ -0,0 +1,147 @@ +#!/bin/sh +# +# %CopyrightBegin% +# +# Copyright Ericsson AB 2010. All Rights Reserved. +# +# The contents of this file are subject to the Erlang Public License, +# Version 1.1, (the "License"); you may not use this file except in +# compliance with the License. You should have received a copy of the +# Erlang Public License along with this software. If not, it can be +# retrieved online at http://www.erlang.org/. +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +# the License for the specific language governing rights and limitations +# under the License. +# +# %CopyrightEnd% +# +# Author: Rickard Green +# + +target= +build_otp= +erl_top= +force=no + +while [ $# -gt 0 ]; do + case "$1" in + -target) + shift + test $# -gt 0 || { echo "$0: Missing target" 1>&2; exit 1; } + target="$1";; + -otp) + shift + test $# -gt 0 || { echo "$0: Missing otp release" 1>&2; exit 1; } + build_otp="$1";; + -erl_top) + shift + test $# -gt 0 || { echo "$0: Missing erl top" 1>&2; exit 1; } + erl_top="$1";; + -force) + shift + test $# -gt 0 || { echo "$0: Missing force value" 1>&2; exit 1; } + force=$1;; + *) + echo "$0: Bad argument: $1" 1>&2 + exit 1;; + esac + shift +done + +test "X$target" != "X" || { echo "$0: Missing target" 1>&2; exit 1; } +test "X$build_otp" != "X" || { echo "$0: Missing otp release" 1>&2; exit 1; } +test "X$erl_top" != "X" || { echo "$0: Missing erl top" 1>&2; exit 1; } +test "X$force" != "X" || { echo "$0: Missing force value" 1>&2; exit 1; } + +cd $erl_top + +cat > cross_check_erl.erl <<\EOF +% +% Copyright Ericsson AB 2010. All Rights Reserved. +% +% The contents of this file are subject to the Erlang Public License, +% Version 1.1, (the "License"); you may not use this file except in +% compliance with the License. You should have received a copy of the +% Erlang Public License along with this software. If not, it can be +% retrieved online at http://www.erlang.org/. +% +% Software distributed under the License is distributed on an "AS IS" +% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +% the License for the specific language governing rights and limitations +% under the License. +% + +-module(cross_check_erl). + +-export([start/0]). + +start() -> + OTP = case catch erlang:system_info(otp_release) of + {'EXIT', _} -> "OTP"; + Rel -> "OTP-" ++ Rel + end, + io:format("~s~n", [OTP]), + init:stop(). + +EOF + +erlc cross_check_erl.erl 2>/dev/null \ + && used_otp=`erl -noshell -noinput -pa . -run cross_check_erl 2>/dev/null` + +res=$? + +rm -f cross_check_erl.erl cross_check_erl.beam + +test $res -eq 0 || { + cat 1>&2 <&2 <&2 + test "$tst" = "" || echo "{error,{arg,missing_files}}." > $tst + exit 1; +} +test "$bindir" != "" || { + echo " ERROR: Missing --bindir" 1>&2 + test "$tst" = "" || echo "{error,{arg,missing_bindir}}." > $tst + exit 1 +} +test "$exec_prefix" != "" || { + echo " ERROR: Missing --exec-prefix" 1>&2 + test "$tst" = "" || echo "{error,{arg,missing_exec_prefix}}." > $tst + exit 1 +} +test "$erlang_bindir" != "" || { + echo " ERROR: Missing erlang_bindir" 1>&2 + test "$tst" = "" || echo "{error,{arg,missing_erlang_bindir}}." > $tst + exit 1 +} + +# Make sure all paths are absolute +for dir_var in $path_variables; do + eval "dir_path=\"\$$dir_var\"" + + case "$dir_path" in + /*) ;; + "") + # Empty DESTDIR or EXTRA_PREFIX which is ok + case $dir_var in + DESTDIR|EXTRA_PREFIX) ;; + *) + echo " ERROR: Internal error: \$$dir_var is empty" 1>&2 + test "$tst" = "" || echo "{error,{empty,$dir_var}}." > $tst + exit 1;; + esac + continue;; + *) + case $dir_var in + bindir) flag="--bindir=";; + exec_prefix) flag="--exec-prefix=";; + erlang_bindir) flag="erlang_bindir=";; + DESTDIR) flag="DESTDIR=";; + EXTRA_PREFIX) flag="EXTRA_PREFIX=";; + *) flag="";; # Need to update the script... + esac + cat 1>&2 < $tst + exit 1;; + esac + case "$dir_path" in + *[!A-Za-z0-9/=_.-]*) DQ="\"";; + *) ;; + esac +done + +# We place temporary check files in the source dir and the target dir. These +# can later be used to verify that our modifications of the paths are +# successful. + +test "$dbg" = "true" || { + bchk_file="tmp-erlang-install-bin.$$" + ebchk_file="tmp-erlang-install-erl-bin.$$" + bchk="$DESTDIR$EXTRA_PREFIX$bindir/$bchk_file" + ebchk="$DESTDIR$EXTRA_PREFIX$erlang_bindir/$ebchk_file" + chk_txt="Temporary Erlang/OTP install file." + chk_err=no + + # Make sure we haven't got any old ones... + rm -f "$bchk" "$ebchk" + + { { echo "$chk_txt" > "$ebchk"; } 2>/dev/null && test -r "$ebchk"; } || { + cat 1>&2 < "$bchk"; } 2>/dev/null && test -r "$bchk"; } || { + cat 1>&2 <&2 <&2 < $tst + exit 1 + } +} + +dirty=no + +# Make all paths look good (remove all `.' dirs, `//', and trailing `/'). +for dir_var in $path_variables; do + eval "dir_path=\"\$$dir_var\"" + test "$dir_path" != "" || continue + + ndp= + save_IFS=$IFS + IFS=/ + for dir in $dir_path; do + case "$dir" in + "" | ".") continue;; + "..") + case $dir_var in + bindir|erlang_bindir|exec_prefix) dirty=yes;; + *) ;; + esac;; + *) ;; + esac + ndp="$ndp/$dir" + done + IFS=$save_IFS + test "$ndp" != "" || ndp="/" + eval "$dir_var=\"$ndp\"" +done + +iprfx="$DESTDIR$EXTRA_PREFIX" + +# Make sure we didn't mess up +{ $dbg test -f "$iprfx$bindir/$bchk_file" && + $dbg test -f "$iprfx$erlang_bindir/$ebchk_file"; } || { + cat 1>&2 < $tst + exit 1 +} + +# Now all paths look good... + + +# $ln_s should be either 'ln -s', 'ln', or 'cp -p'. We don't want to +# maks hard links, so make sure we got 'ln -s'; otherwise, use 'cp -p' + +# This is the fallback if we haven't got 'ln -s' +ln_s="cp -p" +type=copy +paths=absolute +abspath_reason=no_ln_s +src_dir="$iprfx$erlang_bindir" + +case "X${LN_S}X" in + Xln[\ \ ]*X|X*[\ \ ]ln[\ \ ]*X) + # Got `ln'; check that we also got `-s' flag + case "X${LN_S}X" in + X*[\ \ ]-sX|X*[\ \ ]-s[\ \ ]*X) + # Ok; seems like we got `ln -s' + ln_s="ln -s" + type=link + paths="$BINDIR_SYMLINKS" + test "$BINDIR_SYMLINKS" = "absolute" && abspath_reason=request + # $DESTDIR should *not* be part of src_dir when linking + src_dir="$EXTRA_PREFIX$erlang_bindir" + ;; + *) ;; + esac;; + *) ;; +esac + +case "$paths" in + absolute|relative) ;; + *) paths=undetermined;; +esac + +# Determine if we should use absolute or relative paths for links +test $paths != absolute && { + # If $paths is undetermined, use absolute paths unless both $bindir + # and $erlang_bindir are prefixed by $exec_prefix (which is the normal + # case) + test $paths = relative || paths=absolute + abspath_reason=not_prefix + resolved_bindir="$bindir" + resolved_erlang_bindir="$erlang_bindir" + resolved_exec_prefix="$exec_prefix" + case "$bindir" in + "$exec_prefix"*) + case "$erlang_bindir" in + "$exec_prefix"*) paths=relative;; + *) ;; + esac;; + *);; + esac + # Now paths=absolute|relative + + # If we got dirty paths (contains ..) and are going for relative links, + # we need to resolve the paths + test $dirty-$paths = yes-relative && { + # Need to resolve $bindir and $erlang_bindir paths + for dir_var in bindir erlang_bindir exec_prefix; do + eval "dir_path=\"\$$dir_var\"" + + ndp="/" + save_IFS=$IFS + IFS=/ + for dir in $dir_path; do + case "$dir" in + "") ;; + "..") + test "$ndp" != "/" || { + IFS=$save_IFS + paths=absolute + abspath_reason=unreasonable_path + break 2 + } + ndp=`dirname "$ndp" 2>/dev/null` || { + IFS=$save_IFS + paths=absolute + abspath_reason=dirname_failed + break 2 + };; + *) + if test "$ndp" = "/"; then + ndp="/$dir" + else + ndp="$ndp/$dir" + fi;; + esac + done + IFS=$save_IFS + test "$ndp" != "" || ndp="/" + eval "resolved_$dir_var=\"$ndp\"" + done + } + + # If we still are going for relative and relative symbolic links have + # not been explicitly requested check that the resolved paths still + # are prefixed by exec_prefix + test $paths = relative && test "$BINDIR_SYMLINKS" != "relative" && { + paths=absolute + abspath_reason=not_prefix + case "$resolved_bindir" in + "$resolved_exec_prefix"*) + case "$resolved_erlang_bindir" in + "$resolved_exec_prefix"*) + paths=relative;; + *) ;; + esac;; + *) ;; + esac + } + + # If we still are going for relative check that resolved paths are + # reachable (might not be if the directory structure contains symbolic + # directory links). + test $paths = relative && { + ($dbg test -r "$iprfx$resolved_bindir/$bchk_file" && + $dbg test -r "$iprfx$resolved_erlang_bindir/$ebchk_file" && + $dbg cd "$iprfx$resolved_bindir" && + $dbg test -r "./$bchk_file" && + $dbg cd "$iprfx$resolved_erlang_bindir" && + $dbg test -r "./$ebchk_file") || { + paths=absolute + abspath_reason=unreachable_absolute + } + } + + + # If we still are going for relative, calculate the relative path from + # $resolved_bindir to $resolved_erlang_bindir and verify that we + # can reach $erlang_bindir from $bindir via calculated relative path + test $paths = relative && { + relpath= + common= + + save_IFS=$IFS + IFS=/ + + build=false + for dir in $resolved_erlang_bindir; do + test "$dir" != "" || continue + test $build = false || { relpath="$relpath/$dir"; continue; } + cand="${common}/$dir" + case "$resolved_bindir" in + "$cand"*) common="$cand";; + *) relpath="$dir"; build=true;; + esac + done + + check= + build=false + test "$common" != "" || build=true + + for dir in $resolved_bindir; do + test "$dir" != "" || continue + test $build = true || { + check="${check}/$dir" + test "$check" != "$common" || build=true + continue + } + if test "$relpath" = ""; then + relpath=".." + else + relpath="../$relpath" + fi + done + + IFS=$save_IFS + + test "$relpath" != "" || { + cat 1>&2 < $tst + exit 1 + } + + # Verify that it works otherwise go for absolute links + if ($dbg cd "$iprfx$bindir" 2>/dev/null && \ + $dbg test -r "$relpath/$ebchk_file"); then + src_dir="$relpath" + else + abspath_reason=unreachable_relative + paths=absolute + fi + } +} + +# Don't need the temporary check files anymore +$dbg rm -f "$bchk" "$ebchk" + +# If we reverted to absolute paths we may have to abort or notify the user +# about this... +case "$paths-$BINDIR_SYMLINKS" in + absolute-absolute) # User requested absolute and got it + case "$abspath_reason" in + no_ln_s) + cat < $tst + exit 1;; # Abort... + *) + ;; + esac;; + + absolute-relative) # User forced relative symbolic links, but we need + # to revert to absolute symbolic links. Print error + # message and abort. + + case "$abspath_reason" in + no_ln_s) + cat 1>&2 <&2 <&2 <&2 <&2 <&2 <&2 <&2 < $tst + exit 1;; # Abort... + + absolute-*) # Notify the user that we reverted to absolute symbolic links + cat <&2 <&2 < $tst + exit 1 +} + +# Verify that the source files actually exist (done in a separate pass +# before we modify anything, so we leave it untouched if it should fail). +# Note that we will not find them under $src_dir if we use absolute symbolic +# links and $DESTDIR != "". In this case (actually all cases) they can then +# be found under $iprfx$erlang_bindir +test_src_dir="$src_dir" +test "$paths-$type" != "absolute-link" || test_src_dir="$iprfx$erlang_bindir" + +for file in "$@"; do + test "$file" != "" || continue + src_file="$test_src_dir/$file" + $dbg test -f "$src_file" || { + cat 1>&2 < $tst + exit 1 + } +done + +# Remove after possible old install (done in a separate pass since I think +# the output looks nicer than if mixed). Note that we cannot test for existance +# in a portable way, so force remove. +for file in "$@"; do + test "$file" != "" || continue + echo rm -f "$file" + $dbg rm -f "$file" +done + +# do it +for file in "$@"; do + echo $ln_s "$DQ$src_dir/$file$DQ" "$file" + $dbg $ln_s "$src_dir/$file" "$file" || { + test "$tst" = "" || echo "{error,{$type,\"$file\",failed}}." > $tst + exit 1 + } +done + +test "$tst" = "" || echo "{ok,{$paths,\"$iprfx$bindir\",\"$src_dir\"}}." > $tst + +exit 0 # Done diff --git a/make/otp_ded.mk.in b/make/otp_ded.mk.in index 0a91a42df5..e719312473 100644 --- a/make/otp_ded.mk.in +++ b/make/otp_ded.mk.in @@ -1,22 +1,48 @@ #-*-makefile-*- ; force emacs to enter makefile-mode # ---------------------------------------------------- -# Make include file for otp +# %CopyrightBegin% # -# Copyright (C) 1996, Ericsson Telecommunications -# Author: Lars Thorsen +# Copyright Ericsson AB 2009-2010. All Rights Reserved. +# +# The contents of this file are subject to the Erlang Public License, +# Version 1.1, (the "License"); you may not use this file except in +# compliance with the License. You should have received a copy of the +# Erlang Public License along with this software. If not, it can be +# retrieved online at http://www.erlang.org/. +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +# the License for the specific language governing rights and limitations +# under the License. +# +# %CopyrightEnd% + +# The version. +# +# Note that it is important that the version is +# explicitly expressed here. Some applications need to +# be able to check this value *before* configure has +# been run and generated otp_ded.mk +DED_MK_VSN = 1 +# ---------------------------------------------------- +# Variables needed for building Dynamic Erlang Drivers # ---------------------------------------------------- DED_CC = @CC@ +DED_GCC = @GCC@ DED_LD = @DED_LD@ DED_LDFLAGS = @DED_LDFLAGS@ -DED__NOWARN_CFLAGS = @DED_CFLAGS@ -DED_CFLAGS = @WFLAGS@ @DED_CFLAGS@ +DED__NOWARN_NOTHR_CFLAGS = @DED_CFLAGS@ +DED__NOTHR_CFLAGS = @WFLAGS@ @DED_CFLAGS@ +DED__NOWARN_CFLAGS = @DED_EMU_THR_DEFS@ @DED_CFLAGS@ +DED_THR_DEFS = @DED_THR_DEFS@ +DED_EMU_THR_DEFS = @DED_EMU_THR_DEFS@ +DED_WARN_FLAGS = @WFLAGS@ +DED_CFLAGS = @WFLAGS@ @DED_EMU_THR_DEFS@ @DED_CFLAGS@ DED_LIBS = @LIBS@ +DED_EXT = @DED_EXT@ ERLANG_OSTYPE = @ERLANG_OSTYPE@ -TARGET = @host@ PRIVDIR = ../priv OBJDIR = $(PRIVDIR)/obj/$(TARGET) LIBDIR = $(PRIVDIR)/lib/$(TARGET) -DED_SYS_INCLUDE = -I$(ERL_TOP)/erts/emulator/beam \ - -I$(ERL_TOP)/erts/emulator/sys/$(ERLANG_OSTYPE) - +DED_SYS_INCLUDE = @DED_SYS_INCLUDE@ DED_INCLUDES = $(DED_SYS_INCLUDE) diff --git a/make/unexpected_use b/make/unexpected_use new file mode 100755 index 0000000000..d7543a7d83 --- /dev/null +++ b/make/unexpected_use @@ -0,0 +1,29 @@ +#!/bin/sh +# +# %CopyrightBegin% +# +# Copyright Ericsson AB 2010. All Rights Reserved. +# +# The contents of this file are subject to the Erlang Public License, +# Version 1.1, (the "License"); you may not use this file except in +# compliance with the License. You should have received a copy of the +# Erlang Public License along with this software. If not, it can be +# retrieved online at http://www.erlang.org/. +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +# the License for the specific language governing rights and limitations +# under the License. +# +# %CopyrightEnd% +# + +prog=`basename "$0"` || prog="$0" + +cat 1>&2 <