| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
# We build where we are |
| 4 |
SDK_BUILD_BASE=$(pwd -P)/output |
| 5 |
|
| 6 |
if [ -z "$SDK_SRC_BASE" ] |
| 7 |
then |
| 8 |
echo Script variable SDK_SRC_BASE must be set in the calling \'configure\' script, |
| 9 |
echo to the root location of the sources, typically with such a pattern: |
| 10 |
echo 'SDK_SRC_BASE="$(cd "$(dirname "$0")"; pwd -P)"' |
| 11 |
echo "(see 'configure.template' from the argeo-build directory)" |
| 12 |
echo In order to build Argeo Build itself, explicitly set SDK_SRC_BASE as an environment variable |
| 13 |
exit 1 |
| 14 |
fi |
| 15 |
|
| 16 |
SDK_MK=$SDK_SRC_BASE/sdk.mk |
| 17 |
|
| 18 |
if [ -f "$SDK_MK" ]; |
| 19 |
then |
| 20 |
echo "File $SDK_MK already exists. Remove it in order to configure a new build location:" |
| 21 |
echo "rm $SDK_MK" |
| 22 |
exit 1 |
| 23 |
|
| 24 |
else |
| 25 |
|
| 26 |
if [ -z "$JAVA_HOME" ] |
| 27 |
then |
| 28 |
JAVA_HOME=$(dirname $(dirname $(readlink -f $(which java)))) |
| 29 |
echo "Environment variable JAVA_HOME not set, using $JAVA_HOME of $(which java)" |
| 30 |
fi |
| 31 |
|
| 32 |
# Create build directory, so that it can be used right away |
| 33 |
# and we check whether we have the rights |
| 34 |
mkdir -p $SDK_BUILD_BASE |
| 35 |
if [ ! -d "$SDK_BUILD_BASE" ]; |
| 36 |
then |
| 37 |
echo "Cannot create $SDK_BUILD_BASE, SDK configuration has failed." |
| 38 |
exit 2 |
| 39 |
fi |
| 40 |
|
| 41 |
# Generate sdk.mk |
| 42 |
cat > "$SDK_MK" <<EOF |
| 43 |
SDK_SRC_BASE := $SDK_SRC_BASE |
| 44 |
SDK_BUILD_BASE ?= $SDK_BUILD_BASE |
| 45 |
JAVA_HOME ?= $JAVA_HOME |
| 46 |
|
| 47 |
-include branch.mk |
| 48 |
-include sdk/branches/\$(BRANCH).bnd |
| 49 |
EOF |
| 50 |
|
| 51 |
# Add standard GNU paths |
| 52 |
for i in "$@"; do |
| 53 |
case $i in |
| 54 |
--prefix=*) |
| 55 |
echo "prefix := ${i#*=}" >> "$SDK_MK" |
| 56 |
shift |
| 57 |
;; |
| 58 |
--sysconfdir=*) |
| 59 |
echo "sysconfdir := ${i#*=}" >> "$SDK_MK" |
| 60 |
shift |
| 61 |
;; |
| 62 |
--localstatedir=*) |
| 63 |
echo "localstatedir := ${i#*=}" >> "$SDK_MK" |
| 64 |
shift |
| 65 |
;; |
| 66 |
esac |
| 67 |
done |
| 68 |
|
| 69 |
# Even when building in MSYS (that is, with proper '/' paths) |
| 70 |
# we still need at some places the Windows '\' path to output |
| 71 |
if command -v cygpath 2>&1 >/dev/null |
| 72 |
then |
| 73 |
echo "export SDK_BUILD_BASE_WIN=$(cygpath -w "$SDK_BUILD_BASE")" >> "$SDK_MK" |
| 74 |
fi |
| 75 |
|
| 76 |
echo SDK was configured. |
| 77 |
echo "JAVA_HOME : $JAVA_HOME" |
| 78 |
echo "Base for sources : $SDK_SRC_BASE" |
| 79 |
echo "Base for builds : $SDK_BUILD_BASE" |
| 80 |
fi |