Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 2086 lines (1827 sloc) 55.8 KB
#!/bin/bash
#
# configure -- Build configuration script for Embedthis Products
#
# Copyright (c) Embedthis Software LLC, 2003-2009. All Rights Reserved.
#
# This script creates the buildConfig.h, buildConfig.make and buildConfig.sh
# configuration files. buildConfig.h is included in every C/C++ source file,
# buildConfig.make is included by all makefiles and buildConfig.sh is included
# by the bld program and some other scripts.
#
# The initial default settings are derrived from configuration files in the build directory.
#
###############################################################################
#
# Prefix for configuration files generated by configure
#
CONFIG=buildConfig
#
# This programs version
#
CONFIGURE_VERSION=3.7.0
#
# Default settings
#
BLD_DEFAULTS=standard
#
# O/S has cygpath (Windows)
#
HAS_CYGPATH=0
#
# Product name to configure
#
PRODUCT=
#
# Flags prefixes
#
FLAGS="C D I LD J"
###############################################################################
#
# Check the software installation and O/S
#
checkSetup() {
#
# Windows path conversion utility
#
type -p cygpath >/dev/null 2>&1
if [ $? = 0 ] ; then
HAS_CYGPATH=1
else
HAS_CYGPATH=0
fi
#
# Ensure we can write to key directories
#
for d in . build build/bin bin obj lib
do
if [ ! -d $d ] ; then
echo "Missing required directory \"$d\"" 1>&2
echo "Create this directory and retry" 1>&2
exit 255
fi
echo 2>/dev/null >$d/.test
if [ $? != 0 ] ; then
echo "Can't write to $d" 1>&2
echo "You do not have write permission for the $d directory." 1>&2
echo "Log in as root or modify the permissions of this directory" 1>&2
echo "and all its files." 1>&2
exit 255
fi
rm -f $d/.test
done
if [ ! -f ./configure -o ! -d build ] ; then
echo "configure: You must be in the top source directory." 1>&2
exit 255
fi
#
# Convert paths to be absolute with a drive spec on windows
#
BLD_TOP=`canonPath .`
BLD_TOOLS_DIR=${BLD_TOP}/build/bin
BLD_BIN_DIR=${BLD_TOP}/bin
if [ "$BLD_HOST_OS" = "WIN" ] ; then
BLD_LIB_DIR=${BLD_BIN_DIR}
BLD_MOD_DIR=${BLD_BIN_DIR}
else
BLD_LIB_DIR=${BLD_TOP}/lib
BLD_MOD_DIR=${BLD_TOP}/lib/modules
fi
#
# Sleuth the product. By convention products put a configure.PRODUCT file under the build directory.
#
PRODUCT_LIST=`echo build/configure.* | sed 's/[^. ]*\.//g'`
if [ "${PRODUCT_LIST%\*}" != "${PRODUCT_LIST}" ] ; then
echo "Can't find required file: build/configure.*" 1>&2
echo "Install this file and retry." 1>&2
exit 255
fi
}
#
# Link a file. If that fails, copy.
#
linkFile()
{
source=$1
dir=`dirname $2`
base=`basename $2`
rm -f $2
if [ "$base" != "$2" ] ; then
source=`echo $source | sed -e "s^${dir}/^^"`
fi
ln -s $source $2 2>/dev/null
if [ $? != 0 ] ; then
cp $1 $2
fi
}
setSystemConfiguration() {
[ "$BLD_HOST_SYSTEM" = "" ] && BLD_HOST_SYSTEM=`bash build/bin/config.guess`
[ "$BLD_BUILD_SYSTEM" = "" ] && BLD_BUILD_SYSTEM=`bash build/bin/config.guess`
parseSystemConfiguration HOST
parseSystemConfiguration BUILD
if [ "${BLD_HOST_SYSTEM}" != "${BLD_BUILD_SYSTEM}" ] ; then
BLD_CROSS=1
else
BLD_CROSS=0
fi
}
#
# Parse the system configuration. This is called for the host and build configurations.
#
parseSystemConfiguration() {
local cpu dist os rel system version unused value
#
# Parse the host system configuration
#
kind=$1
parseSystem BLD_${kind}_SYSTEM $system BLD_${kind}_CPU unused BLD_${kind}_OS
eval os=\$BLD_${kind}_OS
case $os in
WIN)
eval BLD_${kind}_UNIX=0
eval BLD_${kind}_WIN=1
;;
CYGWIN)
eval BLD_${kind}_UNIX=1
eval BLD_${kind}_WIN=1
;;
FREEBSD)
eval BLD_${kind}_UNIX=1
eval BLD_${kind}_WIN=0
;;
LINUX)
eval BLD_${kind}_UNIX=1
eval BLD_${kind}_WIN=0
;;
SOLARIS*)
eval BLD_${kind}_UNIX=1
eval ${os}=SOLARIS
eval BLD_${kind}_WIN=0
;;
MACOSX)
eval BLD_${kind}_UNIX=1
eval BLD_${kind}_WIN=0
;;
VXWORKS)
eval BLD_${kind}_UNIX=0
eval BLD_${kind}_WIN=0
;;
*)
eval BLD_${kind}_UNIX=0
eval BLD_${kind}_WIN=0
;;
esac
#
# Determine the CPU family
#
eval cpu=\$BLD_${kind}_CPU
case ${cpu} in
arm*|strongarm*)
eval BLD_${kind}_CPU_ARCH=MPR_CPU_ARM
;;
m68k**)
eval BLD_${kind}_CPU_ARCH=MPR_CPU_68K
;;
mips*)
eval BLD_${kind}_CPU_ARCH=MPR_CPU_MIPS
;;
ppc*|powerpc*)
eval BLD_${kind}_CPU_ARCH=MPR_CPU_PPC
;;
sparc*|sparclite)
eval BLD_${kind}_CPU_ARCH=MPR_CPU_SPARC
;;
x86_64*|amd64)
eval BLD_${kind}_CPU_ARCH=MPR_CPU_IX64
;;
x86*|i?86*)
eval BLD_${kind}_CPU_ARCH=MPR_CPU_IX86
;;
xscale*)
eval BLD_${kind}_CPU_ARCH=MPR_CPU_XSCALE
;;
simnt|sim)
eval BLD_${kind}_CPU_ARCH=MPR_CPU_SIMNT
;;
simsparc)
eval BLD_${kind}_CPU_ARCH=MPR_CPU_SIMSPARC
;;
sh*)
eval BLD_${kind}_CPU_ARCH=MPR_CPU_SH4
;;
universal)
eval BLD_${kind}_CPU_ARCH=MPR_CPU_UNIVERSAL
;;
*)
eval BLD_${kind}_CPU_ARCH=MPR_CPU_UNKNOWN
echo "configure: CPU architecture unknown. Porting $BLD_PRODUCT is required. " 1>&2
exit 2
;;
esac
eval value=\$BLD_${kind}_CPU
eval BLD_${kind}_CPU_MODEL=`echo $value | sed 's/[a-zA-Z-]*//'`
#
# Determine the O/S distribution. This is quite a bit of spelunking.
#
# /etc/debian_version
# /etc/redhat-release
# /etc/fedora-release
# /etc/gentoo-release
# /etc/SuSE-release
# /etc/slackware-release, /etc/slackware-version
# /etc/debian-release, /etc/debian-version
# /etc/release # Solars
# /etc/yellowdog-release
# /etc/mandrake-release
dist="unknown"
version="Unknown"
if [ $os = WIN -o $os = CYGWIN ] ; then
# Microsoft Windows XP [Version 5.1.2600]
# Microsoft Windows [Version 6.0.6000]
rel=`cmd /c ver | tail -1`
version=`echo $rel | sed 's/.*Version //;s/]//' | awk '{ print $1 }'`
version=${version%%.*}
# if [ "$version" = 6 ] ; then
# dist=vista
# elif [ "$version" = 5 ] ; then
# dist=xp
# fi
dist=MS
elif [ $os = LINUX ] ; then
if [ -f /etc/redhat-release ] ; then
case `cat /etc/redhat-release` in
Fedora*)
# Fedora Core release 4 (Stentz)
# Fedora Core release 6 (Zod)
# Fedora Core release 5.9 (FC6 Test3)
version=`cat /etc/redhat-release | awk '{ print $4 }'`
dist="fedora"
;;
"Red Hat Linux"*)
# Red Hat Linux release 9 (Shrike)
version=`cat /etc/redhat-release | awk '{ print $5 }'`
dist="rhl"
;;
"Red Hat Enterprise"*)
# Red Hat Enterprise Linux ES release 3 (Taroon Update 7)
# Red Hat Enterprise Linux ES release 4 (Nahant Update 4)
version=`cat /etc/redhat-release | awk '{ print $7 }'`
dist="rhel"
;;
esac
fi
if [ -f /etc/SuSE-release ] ; then
dist=suse
version=`cat /etc/SuSE-release | head -1 | awk '{ print $2 }'`
fi
if [ -f /etc/gentoo-release ] ; then
dist=suse
version=`cat /etc/gentoo-release | head -1 | awk '{ print $5 }'`
fi
if [ -f /etc/debian_version ] ; then
cat /proc/version | grep -i ubuntu >/dev/null
if [ $? = 0 ] ; then
dist=ubuntu
else
dist=debian
fi
if [ -f /etc/lsb-release ] ; then
version=`cat /etc/lsb-release | grep RELEASE | sed 's/.*=//'`
elif [ -f /etc/issue ] ; then
version=`cat /etc/issue | awk '{ print $2 }'`
fi
fi
elif [ $os = MACOSX ] ; then
version=`sw_vers | grep ProductVersion | awk '{ print $2 }'`
dist="Apple"
elif [ $os = VXWORKS ] ; then
dist="vxworks"
fi
eval BLD_${kind}_DIST=\"${dist}\"
eval BLD_${kind}_DIST_VER=\"${version}\"
}
#
# Parse any user defined environment variables
#
parseEnvVars() {
[ $quiet = 0 ] && echo -e " # Parse environment variables ..."
#
# Warn about a search path set to the root directory.
#
if [ "$SEARCH_PATH" = "/" -o "$SEARCH_PATH" = "." -o "$SEARCH_PATH" = "c:/" ] ; then
echo "Can't set SEARCH_PATH to \"/\" or \".\""
exit 255
fi
#
# If the user is overriding CC but doesn't set CXX, set it to the same
#
if [ "$CC" != "" -a "$CXX" = "" ] ; then
CXX="$CC"
fi
if [ "$LD" != "" -a "$LDXX" = "" ] ; then
LDXX="$CC"
fi
if [ -f "${BLD_TOP}/.embedthis" ] ; then
BLD_EMBEDTHIS=1
else
BLD_EMBEDTHIS=0
fi
#
# Set default tool value if corresponding environment variable is defined
#
for t in ANT AR BREW CC DOXYGEN CXX JAVAC JDK JAR LD LDXX MT MUNCH NM RANLIB RC STRIP
do
eval value="\$${t}"
if [ "$value" != "" ] ; then
if [ $BLD_CROSS = 1 ] ; then
eval CFG_HOST_${t}=\"$value\"
else
eval CFG_BUILD_${t}=\"$value\"
fi
fi
done
for t in AR CC CXX LD LDXX MT NM RANLIB RC STRIP
do
eval value="\$BUILD_${t}"
if [ "$value" != "" ] ; then
eval CFG_BUILD_${t}=\"$value\"
fi
done
for t in $FLAGS
do
eval value="\$BUILD_${t}FLAGS"
if [ "$value" != "" ] ; then
eval BLD_BUILD_${t}FLAGS=\"$value\"
fi
eval value="\$${t}FLAGS"
if [ "$value" != "" ] ; then
eval BLD_HOST_${t}FLAGS=\"$value\"
if [ "${BLD_HOST_SYSTEM}" = "${BLD_BUILD_SYSTEM}" ] ; then
eval BLD_BUILD_${t}FLAGS=\"$value\"
fi
fi
done
}
#
# Usage: parseSystem in-system out-cpu out-vendor out-os
#
parseSystem() {
local system cpu vendor kernel os lowOS
eval system=\$${1}
cpu=${system%%-*}
vendor=${system##${cpu}-}
vendor=${vendor%%-*}
kernel=${system##${cpu}-${vendor}-}
os=${kernel##*-}
kernel=${kernel%%-*}
if [ "$kernel" != "" ] ; then
os=$kernel
fi
os=`upper $os`
case "${os}" in
CYGWIN*|WIN)
os=WIN
;;
FREEBSD*)
os=FREEBSD
;;
SOLARIS*)
os=SOLARIS
;;
DARWIN*)
os=MACOSX
;;
esac
lowOS=`lower $os`
eval ${2}=$cpu
eval ${3}=$vendor
eval ${4}=$os
eval ${1}="${cpu}-${vendor}-${lowOS}"
[ "$verbose" -gt 2 ] && echo System set to "${cpu}-${vendor}-${lowOS}" >&2
}
#
# Convert a path to a canonical form: absolute (Windows: with drive spec)
#
canonPath() {
local path
path="$1"
if [ "$path" = "" ] ; then
echo "$path"
return
fi
if [ $HAS_CYGPATH = 1 ] ; then
#
# These conversions will ensure we get a drive spec and that we have
# forward slashes instead of back slashes
#
d=`cygpath -am "${path}"`
d=`cygpath -u "${d}"`
cygpath -am "${d}"
return
fi
if [ "${path##..}" != "${path}" ] ; then
cd .. ; echo `pwd`${path##..} ; cd - >/dev/null 2>&1
elif [ "${path##.}" != "${path}" ] ; then
echo `pwd`${path##.}
elif [ "${path##/}" != "${path}" ] ; then
# Absolute
echo "$path"
else
# Relative
echo `pwd`/${path#/}
fi
}
#
# Convert a path to be relative to $BLD_TOP. Used because gnu make on windows can't handle drive specs in dependencies.
#
relativePath() {
local base home dir i d c oldd parents
local count ccount seg commonDir commonLevels
home="$PWD"
dir="$1"
if [ "BLD_HOST_OS" = "WIN" ] ; then
dir=`canonPath "$dir" | tr '[A-Z]' '[a-z]'`
cwd=`canonPath "$PWD" | tr '[A-Z]' '[a-z]'`
else
dir=`canonPath "$dir"`
cwd=`canonPath "$PWD"`
fi
if [ "$dir" = "$cwd" ] ; then
echo "\${BLD_TOP}"
return
fi
if [ "$dir" != "${dir/BLD_TOP/}" ] ; then
echo "$dir"
return
fi
#
# Find longest common dir portion
#
declare -a dseg
d="$dir"
i=0
while [ "$d" != "${d##*/}" ] ; do
seg=${d%%/*} # Extract first path segment
dseg[$i]="${seg}"
d=${d#*/} # Strip first path segment
i=$((i + 1))
done
dseg[$i]="${d}"
declare -a cseg
c="$cwd"
i=0
while [ "$c" != "${c##*/}" ] ; do
seg=${c%%/*} # Extract first path segment
cseg[$i]="${seg}"
c=${c#*/} # Strip first path segment
i=$((i + 1))
done
cseg[$i]="${c}"
count=${#dseg[*]}
ccount=${#cseg[*]}
if [ $count -gt $ccount ] ; then
count=$ccount
fi
if [ "${BLD_HOST_OS}" = "WIN" ] ; then
if [ "${dseg[0]}" != "${cseg[0]}" ] ; then
echo "Path ${dir} on different drive" 1>&2
echo "to the current drive" 1>&2
echo "This configuration is not supported. Aborting." 1>&2
exit 255
fi
fi
#
# Find common parent dirs
#
commonDir=""
i=0
while [ $i -lt $count ] ; do
[ "${dseg[$i]}" != "${cseg[$i]}" ] && break
commonDir="$commonDir/${dseg[$i]}"
i=$((i + 1))
done
commonDir="${commonDir#/*}"
commonLevels=$i
#
# Find how many levels up to common parent for cwd
#
parents=""
i=$commonLevels
while [ $i -lt ${#cseg[*]} ] ; do
parents="../$parents"
i=$((i + 1))
done
base=`echo $dir | sed "s!^$commonDir!!"`
echo "\${BLD_TOP}/${parents}$base" | sed 's!\/\/!\/!g'
}
#
# Remove an old prefix from a path and prepend a new prefix
#
remapDir() {
dir="$1"
oldPath="$2"
newPath="$3"
if [ $HAS_CYGPATH = 1 ] ; then
dir=`cygpath -m "$dir"`
oldPath=`cygpath -m "$oldPath"`
newPath=`cygpath -m "$newPath"`
fi
if [ "${dir##$oldPath}" != "$dir" ]
then
echo "${newPath}${dir##$oldPath}"
else
echo "${dir}"
fi
}
#
# Convert the search path into a normal PATH style with ":" separators
#
convertSearchPath()
{
if [ "$1" != "" ] ; then
[ "$verbose" != 0 ] && echo "ConvertPath expanding $1" 1>&2
echo $1 | sed "s/[ ]'/=/g" | tr "=" "\n" | sed "s/'//g" |
sed "s/ /?/g" | grep -v '^$' | while read x
do
[ "$x" = "" ] && continue
# [ "$verbose" != 0 ] && echo -e "\nConvert: \"$x\" => \n \"`eval ls -d1 "$x" 2>/dev/null | sort -r`\"" 1>&2
eval ls -d1 "$x" 2>/dev/null | sort
done | grep -v '^$' | tr '\n' :
fi
}
findComponents() {
local with build host mandatory name path upperName os
SEARCH_PATH=`convertSearchPath "$SEARCH_PATH"`
for kind in BUILD HOST ; do
[ $quiet = 0 ] && echo -e " #\n # Search for `lower $kind` components"
for name in $BLD_COMPONENTS ; do
upperName=`upper ${name}`
eval with=\$CFG_${kind}_${upperName}_WITH
[ "$with" != 1 ] && continue
if [ ! -f "${BLD_TOP}/build/components/${name}" ] ; then
echo "Missing component file for: $name"
continue
fi
. "${BLD_TOP}/build/components/${name}"
eval path="\$CFG_${kind}_${upperName}"
eval mandatory=\$CFG_${kind}_${upperName}_MANDATORY
[ "$BLD_DISABLE_ALL" = 1 -a $mandatory != 1 ] && continue
[ $quiet = 0 ] && printf " # Scanning for %-12s" "${name}:"
#
# Invoke the component definition function
#
unset MSG
eval os=\$BLD_${kind}_OS
OS=$os NAME=$name KIND=$kind defineComponent "$path"
eval path="\$CFG_${kind}_${upperName}"
if [ "$mandatory" = 1 -a "$path" = "" ] ; then
echo -e "\nconfigure: Can't find mandatory component: $name $path" 1>&2
exit 255
fi
if [ "$path" != "" ] ; then
eval ${kind}_COMPONENTS=\"\$${kind}_COMPONENTS ${name}\"
[ $quiet = 0 ] && echo "$path"
else
if [ "$MSG" != "" ] ; then
[ $quiet = 0 ] && echo $MSG
else
[ $quiet = 0 ] && echo "optional component not found or not needed"
fi
fi
done
[ $BLD_CROSS = 0 ] && break
done
}
#
# Configure a component. Called by build/components/*
#
configureComponent() {
local cflags dflags dependencies kind iflags imports jflags ldflags libpaths libs name upperDep new
local path withlibs withpaths upper builtin tool priorMandatory priorPath emitter disable optional
kind=$KIND
builtin=0
tool=0
[ "$verbose" != 0 ] && echo configure $@
while [ "${1#--}" != "$1" ] ; do
case ${1#--} in
builtin)
builtin=1
;;
cflags)
shift ; cflags="$1"
;;
dependencies)
shift ; dependencies="$1"
;;
dflags)
shift ; dflags="$1"
;;
disable)
shift ; disable="$1"
;;
emitter)
shift ; emitter="$1"
;;
iflags)
shift ; iflags="$1"
;;
imports)
shift ; imports="$1"
;;
jflags)
shift ; jflags="$1"
;;
ldflags)
shift ; ldflags="$1"
;;
libpaths)
shift ; ldpaths=`canonPath "$1"`
;;
libs)
shift ; libs="$1"
;;
name)
shift ; name="$1"
;;
optional-dependencies)
shift ; optional="$1"
;;
path)
shift ; path="$1"
;;
tool)
tool=1
;;
withlibs)
shift ; withlibs="$1"
;;
withpaths)
shift ; withpaths=`canonPath "$1"`
;;
*)
;;
esac
shift
done
[ $BLD_CROSS = 0 ] && kind=BUILD
if [ "$name" = "" ] ; then
echo "configure: component missing name" 1>&2
exit 255
fi
if [ "$disable" != "" ] ; then
echo "configure: component missing name" 1>&2
return 0
fi
upper=`upper ${name}`
eval BLD_FEATURE_${upper}=1
eval mandatory="\$CFG_${kind}_${upper}_MANDATORY"
eval priorPath="\$CFG_${upper}"
if [ "$priorPath" != "" ] ; then
path="$priorPath"
fi
eval unset CFG_${kind}_${upper}
# if [ "$path" = 0 ] ; then
# if [ "$priorMandatory" = 1 ] ; then
# echo "configure: Can't locate mandatory component: $com" 1>&2
# exit 255
# fi
# fi
for dep in $dependencies
do
upperDep=`upper ${dep}`
if [ "`compath $dep`" = "" ] ; then
if [ "$mandatory" = 1 ] ; then
echo "configure: Missing dependency \"${dep}\" for mandatory component: ${name}" 1>&2
exit 255
fi
# TODO - can't return as SSL depends on matrixssl or openssl
# [ "$verbose" != 0 ] &&
# echo "configure: Missing dependency \"${dep}\". Disabling optional component: ${name}" 1>&2
# return 0
fi
done
if [ "$BLD_FEATURE_STATIC" = 1 ] ; then
for dep in $dependencies $optional
do
udep=`upper ${dep}`
eval present=\$CFG_${kind}_${udep}
if [ "$present" != "" ] ; then
eval extra=\$CFG_${kind}_${udep}_LIBPATHS
[ "$extra" != "" ] && libpaths="$libpaths $extra"
eval extra=\$CFG_${kind}_${udep}_LIBS
[ "$extra" != "" ] && libs="$libs $extra"
fi
done
else
for dep in $dependencies $optional
do
udep=`upper ${dep}`
eval present=\$CFG_${kind}_${udep}
if [ "$present" != "" ] ; then
eval extra=\$CFG_${kind}_${udep}_LIBPATHS
[ "$extra" != "" ] && libpaths="$libpaths $extra"
[ "$extra" != "" ] && withpaths="$withpaths $extra"
eval extra=\$CFG_${kind}_${udep}_LIBS
[ "$extra" != "" ] && libs="$libs $extra"
[ "$extra" != "" ] && withlibs="$withlibs $extra"
#
# Rationale. We aggregate up the "libs" because those are the libraries needed to use a component
#
# eval extra=\$CFG_${kind}_${udep}_WITHPATHS
# [ "$extra" != "" ] && withpaths="$withpaths $extra"
# eval extra=\$CFG_${kind}_${udep}_WITHLIBS
# [ "$extra" != "" ] && withlibs="$withlibs $extra"
fi
done
fi
#
# Cleanup leading spaces
#
libs=${libs# *}
libpaths=${libpaths# *}
withlibs=${withlibs# *}
withpaths=${withpaths# *}
#
# Imports must be relative because they are used as targets
#
new=""
for i in $imports ; do
new="$new `relativePath "$i"`"
done
imports="$new"
#
# Make unique (or echo $libs | tr ' ' '\n' | sort | uniq | tr '\n' '') if changing order is okay
#
libs=`unique $libs`
withlibs=`unique $withlibs`
eval CFG_${kind}_${upper}=\"${path}\"
eval CFG_${kind}_${upper}_BUILTIN=\"$builtin\"
eval CFG_${kind}_${upper}_CFLAGS=\"$cflags\"
eval CFG_${kind}_${upper}_DEPENDENCIES=\"$dependencies\"
eval CFG_${kind}_${upper}_DFLAGS=\"$dflags\"
eval CFG_${kind}_${upper}_EMITTER=$emitter
eval CFG_${kind}_${upper}_IFLAGS=\"$iflags\"
eval CFG_${kind}_${upper}_IMPORTS=\"'$imports'\"
eval CFG_${kind}_${upper}_JFLAGS=\"$jflags\"
eval CFG_${kind}_${upper}_LDFLAGS=\"$ldflags\"
eval CFG_${kind}_${upper}_LIBPATHS=\"$libpaths\"
eval CFG_${kind}_${upper}_LIBS=\"$libs\"
eval CFG_${kind}_${upper}_MANDATORY=\"$mandatory\"
eval CFG_${kind}_${upper}_OPTIONAL_DEPENDENCIES=\"$optional\"
eval CFG_${kind}_${upper}_WITHLIBS=\"$withlibs\"
eval CFG_${kind}_${upper}_WITHPATHS=\"$withpaths\"
}
#
# probe [--path path] [--base partial] [--dir] [--search searchPath].
#
# --path path Test first if this path exists, if so, return it.
# --base partial Test if this partial base file name exists along the search path
# --search path Use this instead of the default search path.
# --dir Return the directory portion. Otherwise return the full matching path.
#
# Can supply both dir and file options. Will search using dir first
probe()
{
local args d dir f base found path search trace SAVE_IFS OLD_PATH
trace=$verbose
args="$@"
dir=0
while [ "${1#--}" != "$1" ] ; do
case ${1#--} in
dir)
dir=1
;;
base)
shift ; base=$1
;;
path)
shift ; path=$1
;;
search)
shift ; search=$1
;;
verbose)
trace=$1
;;
esac
shift
done
if [ "$base" = "" -a "$path" = "" ] ; then
echo "probe: Component probe did not specifiy a base or path" >&2
exit 255
fi
[ "$trace" != 0 ] && echo "probe: search for component $args" 1>&2
if [ "$path" != "" ] ; then
if [ -f "$path" -o -x "$path" -o -d "$path" ] ; then
if [ "$dir" = 1 ] ; then
found=${found#${base}}
fi
found=`canonPath "${path}"`
[ "$trace" != 0 -a "$found" != "" ] && echo "probe: 1. found $PKG at $found" 1>&2
fi
fi
if [ "$found" = "" ] ; then
#
# Fast search using "type". Works for executables only.
#
[ "$search" = "" ] && search="$SEARCH_PATH"
OLD_PATH="$PATH"
PATH="$search:$PATH"
found=`type -P "$base" 2>/dev/null`
PATH=$OLD_PATH
if [ "$dir" = "1" ] ; then
found=${found%${base}}
found=${found%/}
fi
[ "$trace" != 0 -a "$found" != "" ] && echo "probe: 2. found $PKG at $found" 1>&2
fi
#
# Search manually along the search path
#
if [ "$found" = "" ] ; then
SAVE_IFS=$IFS
IFS=":"
for d in $search ; do
[ "$trace" != 0 -a "$found" != "" ] && echo "probe: 4. testing $d for $PKG" 1>&2
[ "${d}" = "/" ] && d=
f=${d}/${base}
if [ -f "${f}" -o -d "${f}" ] ; then
[ "${d}" = "" ] && d=/
if [ "$dir" = "1" ] ; then
found="$d"
else
found=${d}/${base}
fi
search=
[ "$trace" != 0 -a "$found" != "" ] && echo "probe: 3. found $PKG at $found" 1>&2
break
fi
done
IFS="$SAVE_IFS"
fi
[ "$trace" != 0 ] && echo "probe: found component at $found" 1>&2
if [ "$found" = "" ] ; then
[ "$trace" != 0 ] && echo "probe: 5. $PKG not found" 1>&2
echo $found
else
canonPath "${found%*/}"
fi
}
#
# Add a component to build with
#
with() {
local arg dir forOs kind kinds mandatory os name upperName lowerName components
mandatory=1
kinds="BUILD HOST"
while [ "${1#--}" != "$1" ] ; do
case ${1#--} in
build)
kinds="BUILD"
;;
host)
kinds="HOST"
;;
mandatory)
mandatory=1
;;
optional)
mandatory=0
;;
os=*)
forOs="${1#--*=}"
forOs=`upper ${forOs}`
;;
esac
shift
done
[ $BLD_CROSS = 0 ] && kinds=BUILD
for kind in $kinds ; do
eval os=\$BLD_${kind}_OS
for arg in $* ; do
name="${arg%=*}"
dir="${arg##*=}"
[ "$dir" = "${arg}" ] && dir=
upperName=`upper ${name}`
lowerName=`lower ${name}`
if [ "$forOs" = "" -o "$forOs" = "$os" ] ; then
components=" ${BLD_COMPONENTS} "
if [ "${components/ ${lowerName} /}" = "$components" ] ; then
BLD_COMPONENTS="$BLD_COMPONENTS $lowerName"
fi
eval CFG_${kind}_${upperName}=$dir
eval CFG_${kind}_${upperName}_WITH=1
eval CFG_${kind}_${upperName}_MANDATORY=$mandatory
fi
done
done
}
without() {
local name upperName lowerName components
name="$1"
upperName=`upper ${name}`
lowerName=`lower ${name}`
components=" ${BLD_COMPONENTS} "
if [ "${components/ $lowerName /}" = "$components" ] ; then
BLD_COMPONENTS="$BLD_COMPONENTS $lowerName"
fi
BLD_COMPONENTS="${components/ $lowerName / }"
eval CFG_WITHOUT_${upperName}=1
}
#
# Return a unique set of words without changing the order
#
unique() {
local result
set -f
for word in $*
do
case " $result " in
*\ $word\ *) ;;
*) result=${result:+"$result "}$word
;;
esac
done
echo $result
set +f
}
setConfiguration() {
local arch
arch=$BLD_HOST_CPU_ARCH
endian=$BLD_HOST_ENDIAN
if [ "$endian" = "" ] ; then
if [ $arch = "MPR_CPU_PPC" -o $arch = "MPR_CPU_SPARC" -o $arch = "MPR_CPU_MIPS" ] ; then
eval BLD_HOST_ENDIAN=MPR_BIG_ENDIAN
else
eval BLD_HOST_ENDIAN=MPR_LITTLE_ENDIAN
fi
fi
}
createBuildConfig() {
#
# Create the buildConfig.sh and buildConfig.make files
#
[ $quiet = 0 ] && echo " #"
rm -f $CONFIG.sh $CONFIG.make $CONFIG.h
for f in $CONFIG.sh $CONFIG.make $CONFIG.h
do
[ $quiet = 0 ] && echo " # Creating $f ..."
createConfig $f
done
[ $quiet = 0 ] && echo " # "
cp $CONFIG.make config.tmp
sed 's/'\''//g' < config.tmp | sed -e 's/""//g' >$CONFIG.make
sed 's/'\''//g' < config.tmp | sed 's/"//g' >$CONFIG.make
rm -f config.tmp
#
# Modify the $CONFIG.h file. Do the following edits:
# - Convert '#' to '//' comments
# - Convert X=Y to #define X Y
# - Convert all "'" to '"'
#
cp $CONFIG.h config.sav
egrep -v '^#|^ #' < config.sav | grep -v 'export' | sed 's/\([^=]*\)=\(.*\)/#define \1 \2/' | sed 's/'\''/"/g' | \
sed 's/^#define/ #define/' | sed 's/^ #/#/' >$CONFIG.h
chmod 444 $CONFIG.sh $CONFIG.make $CONFIG.h
rm -f config.sav config.tmp
echo -e "#!/bin/bash\n\nconfigure $CMD_LINE" >$CONFIG.args
[ $quiet = 0 -a $verbose != 0 ] && echo " # Creating $CONFIG.args ..."
}
#
# Create the buildConfig header
#
createConfigHeader()
{
NAME=$1
FILE=$2
rm -f $NAME
if [ "$NAME" = $CONFIG.h ]
then
cat >$FILE <<!EOF_CONFIG_HEADER_H
/*
* ${NAME} -- Build configuration file.
*
* WARNING: DO NOT EDIT. This file is generated by configure.
*
* Use "./configure --help" for available options.
*/
!EOF_CONFIG_HEADER_H
else
cat >$FILE <<!EOF_CONFIG_HEADER_SH_MAKE
#
# ${NAME} -- Build configuration file.
#
# WARNING: DO NOT EDIT. This file is generated by configure.
#
# Use "./configure --help" for available options.
#
################################################################################
!EOF_CONFIG_HEADER_SH_MAKE
fi
}
#
# Create a buildConfig.* file. NAME is the first arg.
#
createConfig()
{
local enabled kind
NAME=$1
rm -f $NAME
createConfigHeader $NAME $NAME
BLD_HOST_CPU_UPPER=`upper $BLD_HOST_CPU`
BLD_BUILD_CPU_UPPER=`upper $BLD_BUILD_CPU`
local upper=`upper $BLD_PRODUCT`
cat >>$NAME <<!EOF_CONFIG1
#
# Key Product Settigns
#
!EOF_CONFIG1
echo "BLD_${upper}_PRODUCT=1" >>$NAME
cat >>$NAME <<!EOF_CONFIG1a
BLD_PRODUCT="$BLD_PRODUCT"
BLD_NAME="$BLD_NAME"
BLD_VERSION="$BLD_VERSION"
BLD_NUMBER="$BLD_NUMBER"
BLD_TYPE="$BLD_TYPE"
BLD_TUNE=$BLD_TUNE
BLD_DEFAULTS="$BLD_DEFAULTS"
BLD_COMPONENTS="$BLD_COMPONENTS"
BLD_EMBEDTHIS=$BLD_EMBEDTHIS
#
# Other Product Settings
#
BLD_COMPANY="$BLD_COMPANY"
BLD_DEBUG=$BLD_DEBUG
BLD_DIRS="$BLD_DIRS"
BLD_CLEAN_INSTALL="$BLD_CLEAN_INSTALL"
BLD_LICENSE="$BLD_LICENSE"
BLD_COMMERCIAL="$BLD_COMMERCIAL"
#
# Host and Build System Settings.
#
BLD_HOST_SYSTEM="$BLD_HOST_SYSTEM"
BLD_BUILD_SYSTEM="$BLD_BUILD_SYSTEM"
BLD_CROSS="$BLD_CROSS"
#
# Host System Settings
#
BLD_HOST_OS="$BLD_HOST_OS"
BLD_HOST_CPU_ARCH=$BLD_HOST_CPU_ARCH
BLD_HOST_CPU="$BLD_HOST_CPU"
BLD_HOST_CPU_UPPER="$BLD_HOST_CPU_UPPER"
BLD_HOST_CPU_MODEL="$BLD_HOST_CPU_MODEL"
BLD_HOST_ENDIAN=$BLD_HOST_ENDIAN
BLD_HOST_DIST="$BLD_HOST_DIST"
BLD_HOST_DIST_VER="$BLD_HOST_DIST_VER"
BLD_HOST_UNIX=$BLD_HOST_UNIX
BLD_HOST_WIN=$BLD_HOST_WIN
!EOF_CONFIG1a
if [ "$BLD_HOST_OS" = VXWORKS ] ; then
echo "BLD_BUILD_CPU_VX=$BLD_BUILD_CPU_VX" >>$NAME
echo "BLD_BUILD_SYSTEM_VX=$BLD_BUILD_SYSTEM_VX" >>$NAME
fi
cat >>$NAME <<!EOF_CONFIG2
#
# Build System Settings for Build Tools
#
BLD_BUILD_OS="$BLD_BUILD_OS"
BLD_BUILD_CPU_ARCH=$BLD_BUILD_CPU_ARCH
BLD_BUILD_CPU="$BLD_BUILD_CPU"
BLD_BUILD_CPU_UPPER="$BLD_BUILD_CPU_UPPER"
BLD_BUILD_CPU_MODEL="$BLD_BUILD_CPU_MODEL"
BLD_BUILD_ENDIAN=$BLD_BUILD_ENDIAN
BLD_BUILD_UNIX=$BLD_BUILD_UNIX
BLD_BUILD_WIN=$BLD_BUILD_WIN
#
# System and Installation Directories
#
BLD_ROOT_PREFIX="$BLD_ROOT_PREFIX"
BLD_PREFIX="$BLD_PREFIX"
BLD_BIN_PREFIX="$BLD_BIN_PREFIX"
BLD_DOC_PREFIX="$BLD_DOC_PREFIX"
BLD_INC_PREFIX="$BLD_INC_PREFIX"
BLD_LIB_PREFIX="$BLD_LIB_PREFIX"
BLD_MOD_PREFIX="$BLD_MOD_PREFIX"
BLD_MAN_PREFIX="$BLD_MAN_PREFIX"
BLD_SAM_PREFIX="$BLD_SAM_PREFIX"
BLD_SRC_PREFIX="$BLD_SRC_PREFIX"
#
# Directories for native building
#
!EOF_CONFIG2
echo BLD_BUILD_ABS_BIN_DIR=\"`eval canonPath ${BLD_BIN_DIR}`\" >>$NAME
echo BLD_BUILD_ABS_LIB_DIR=\"`eval canonPath ${BLD_LIB_DIR}`\" >>$NAME
echo BLD_BUILD_ABS_OBJ_DIR=\"`eval canonPath ${BLD_OBJ_DIR}`\" >>$NAME
echo BLD_BUILD_ABS_MOD_DIR=\"`eval canonPath ${BLD_MOD_DIR}`\" >>$NAME
echo BLD_BUILD_ABS_INC_DIR=\"`eval canonPath ${BLD_INC_DIR}`\" >>$NAME
echo >>$NAME
createFeatureConfig $NAME
#
# These are used when Makefiles need to absolutely pick a build tool
# and need to use BLD_BUILD_EXE
#
echo -e "\n#\n# File extensions \n#" >>$NAME
for kind in BUILD HOST ; do
for t in ARCH EXE OBJ PIOBJ CLASS SHLIB SHOBJ ; do
eval value=\$BLD_${kind}_${t}
eval value=\"$value\"
echo BLD_${kind}_${t}=\"$value\" >>$NAME
done
[ $BLD_CROSS = 0 ] && break
done
if [ $BLD_CROSS = 0 ] ; then
createCrossConfig $NAME BUILD >>$NAME
else
cat >>$NAME <<!EOF_CONFIG2d
#
# Select Native or cross development flags
#
!EOF_CONFIG2d
if [ $NAME = $CONFIG.make ] ; then
echo 'BUILD_NATIVE ?= 1' >>$NAME
if [ "${BLD_CROSS}" = 1 ] ; then
echo 'BUILD_CROSS ?= 1' >>$NAME
fi
echo '' >>$NAME
echo 'BUILD_HOST_TARGETS:=0' >>$NAME
echo 'ifeq ($(BLD_CROSS),0)' >>$NAME
echo 'BUILD_HOST_TARGETS:=1' >>$NAME
echo 'endif' >>$NAME
echo 'ifneq ($(BUILDING_CROSS),1)' >>$NAME
echo 'BUILD_HOST_TARGETS:=1' >>$NAME
echo 'endif' >>$NAME
echo '' >>$NAME
echo 'ifneq ($(BUILDING_CROSS),1)' >>$NAME
elif [ $NAME = $CONFIG.sh ] ; then
echo ': ${BUILD_NATIVE:=1}' >>$NAME
if [ "${BLD_CROSS}" = 1 ] ; then
echo ': ${BUILD_CROSS:=1}' >>$NAME
fi
echo -e 'if [ "${BUILDING_CROSS}" != 1 ] ; then' >>$NAME
else
echo -e ' #if !BUILDING_CROSS' >>$NAME
fi
for kind in BUILD HOST
do
createCrossConfig $NAME $kind >>$NAME
if [ $kind = BUILD ] ; then
if [ $NAME = $CONFIG.h ] ; then
echo -e '\n #else' >>$NAME
else
echo -e '\nelse' >>$NAME
fi
fi
done
[ $NAME = $CONFIG.make ] && echo -e 'endif\n' >>$NAME
[ $NAME = $CONFIG.sh ] && echo -e 'fi\n' >>$NAME
[ $NAME = $CONFIG.h ] && echo -e ' #endif' >>$NAME
fi
if [ $NAME = $CONFIG.make ] ; then
echo 'EXPORT_OBJECTS ?= 1' >>$NAME
echo 'ifeq ($(EXPORT_OBJECTS),0)' >>$NAME
echo ' BLD_OBJ_DIR := .' >>$NAME
echo 'endif' >>$NAME
echo '' >>$NAME
elif [ $NAME = $CONFIG.sh ] ; then
echo 'if [ "${EXPORT_OBJECTS}" = 0 ] ; then' >>$NAME
echo ' BLD_OBJ_DIR=.' >>$NAME
echo 'fi' >>$NAME
echo '' >>$NAME
fi
if [ "$BLD_HOST_OS" = VXWORKS ] ; then
if [ "${NAME}" = "$CONFIG.sh" ] ; then
echo export WIND_HOME=\"${WIND_HOME}\" >>$NAME
echo export WIND_BASE=\"${WIND_BASE}\" >>$NAME
echo export WIND_HOST_TYPE=\"${WIND_HOST_TYPE}\" >>$NAME
else
echo export WIND_HOME=${WIND_HOME} >>$NAME
echo export WIND_BASE=${WIND_BASE} >>$NAME
echo export WIND_HOST_TYPE=${WIND_HOST_TYPE} >>$NAME
fi
echo >>$NAME
fi
}
createCrossConfig()
{
local name kind value
name=$1
kind=$2
echo -e "\n#\n# O/S and CPU settings\n#"
eval echo \$BLD_${kind}_OS=1
eval value=\$BLD_${kind}_OS ; echo BLD_OS=\"${value}\"
eval echo BLD_CPU_ARCH=\$BLD_${kind}_CPU_ARCH
eval value=\$BLD_${kind}_CPU ; echo BLD_CPU=\"${value}\"
eval value=\$BLD_${kind}_CPU_UPPER ; echo BLD_CPU_UPPER=\"${value}\"
eval value=\$BLD_${kind}_CPU_MODEL ; echo BLD_CPU_MODEL=\"${value}\"
eval value=\$BLD_${kind}_ENDIAN ; echo BLD_ENDIAN=${value}
eval value=\$BLD_${kind}_DIST ; echo BLD_DIST=\"${value}\"
eval value=\$BLD_${kind}_DIST_VER ; echo BLD_DIST_VER=\"${value}\"
eval echo BLD_UNIX_LIKE=\$BLD_${kind}_UNIX
eval echo BLD_WIN_LIKE=\$BLD_${kind}_WIN
echo -e "\n#\n# Compiler and linker flags\n#"
for t in $FLAGS
do
eval value=\$BLD_${kind}_${t}FLAGS
echo "BLD_${t}FLAGS=\"$value\""
done
echo -e "\n#\n# File extensions\n#"
eval v=\$BLD_${kind}_ARCH ; echo BLD_ARCH=\"${v}\"
eval v=\$BLD_${kind}_EXE ; echo BLD_EXE=\"${v}\"
eval v=\$BLD_${kind}_CLASS ; echo BLD_CLASS=\"${v}\"
eval v=\$BLD_${kind}_SHLIB ; echo BLD_SHLIB=\"${v}\"
eval v=\$BLD_${kind}_SHOBJ ; echo BLD_SHOBJ=\"${v}\"
if [ "${BLD_FEATURE_STATIC}" = "0" ] ; then
echo "BLD_LIB=\"${BLD_BUILD_SHOBJ}\""
echo "BLD_OBJ=\"$BLD_BUILD_PIOBJ\""
echo "BLD_PIOBJ=\"$BLD_BUILD_PIOBJ\""
else
echo "BLD_LIB=\"${BLD_BUILD_ARCH}\""
echo "BLD_OBJ=\"$BLD_BUILD_OBJ\""
echo "BLD_PIOBJ=\"$BLD_BUILD_PIOBJ\""
fi
echo -e "\n#\n# Output directories \n#" >>$NAME
echo 'BLD_TOOLS_DIR="${BLD_TOP}/build/bin"' >>$NAME
value=
if [ $kind = HOST ] ; then
eval value=/\${BLD_${kind}_SYSTEM}
fi
echo BLD_BIN_DIR=\"${BLD_BIN_DIR}${value}\"
echo BLD_LIB_DIR=\"${BLD_LIB_DIR}${value}\"
echo BLD_OBJ_DIR=\"${BLD_OBJ_DIR}${value}\"
echo BLD_MOD_DIR=\"${BLD_MOD_DIR}\"
echo BLD_INC_DIR=\"${BLD_INC_DIR}\"
echo BLD_ABS_BIN_DIR=\"`eval canonPath ${BLD_BIN_DIR}`${value}\"
echo BLD_ABS_LIB_DIR=\"`eval canonPath ${BLD_LIB_DIR}`${value}\"
echo BLD_ABS_OBJ_DIR=\"`eval canonPath ${BLD_OBJ_DIR}`${value}\"
echo BLD_ABS_MOD_DIR=\"`eval canonPath ${BLD_MOD_DIR}`\"
echo BLD_ABS_INC_DIR=\"`eval canonPath ${BLD_INC_DIR}`\"
if [ $name != $CONFIG.h ] ; then
#
# Set PATH, INCLUDE and LIB environment variables
#
echo -e "\n#\n# Setup environment variables\n#"
if [ "$BLD_BUILD_OS" = WIN ] ; then
for var in INCLUDE LIB
do
eval value=\"\$CFG_${kind}_${var}_PATH\"
if [ "${name}" = "$CONFIG.sh" ] ; then
echo "export" $var=\"${value}\;\$$var\"
else
echo "export" $var:=${value}\;\$$var
fi
echo
done
fi
top="$BLD_TOP"
if [ $HAS_CYGPATH = 1 ] ; then
top=`cygpath "${top}"`
fi
if [ "${BLD_HOST_OS}" = "LINUX" ] ; then
SYS_DIR=":/sbin:/usr/sbin:"
fi
if [ "${name}" = "$CONFIG.sh" ] ; then
echo "export PATH=\"\${PATH}:${top}/bin:${top}/lib:${top}/lib:${top}/build/bin${SYS_DIR}:${CFG_BUILD_PATH}\""
else
echo "export PATH:=${top}/bin:${top}/lib:${top}/lib:${top}/build/bin${SYS_DIR}:${CFG_BUILD_PATH}:\$(PATH)"
fi
fi
emitComponents $kind
}
emitComponents() {
local host p dir v emitter present
kind=$1
for p in $BLD_COMPONENTS
do
p=`upper ${p}`
eval present="\$CFG_${kind}_${p}"
eval dir=\$CFG_${p}_DIR
echo -e "\n#\n# ${p}\n#"
if [ "$present" = "" ] ; then
echo -e "BLD_FEATURE_${p}=0"
continue
else
echo -e "BLD_FEATURE_${p}=1"
fi
set | grep "^CFG_${kind}_${p}" | egrep -v "_EMITTER|_WITH_|_MANDATORY" | while read v
do
v=${v%=*}
eval value=\$$v
v=${v/CFG/BLD}
if [ "$value" != "" ] ; then
v=${v/_${kind}/}
if [ $name != $CONFIG.make ] ; then
if [ "${v}" = ${v/BUILTIN/} ] ; then
value=\"${value}\"
fi
fi
echo "${v#_}=$value"
fi
done
eval emitter="\$CFG_${kind}_${p}_EMITTER"
if [ "$emitter" != "" ] ; then
KIND=$kind $emitter
fi
done
echo
set | grep "^CFG_WITHOUT" | while read v
do
v=${v%=*}
v=${v/CFG/BLD}
v=${v/WITHOUT/FEATURE}
echo "${v#_}=0"
done
echo
}
showBuildConfig() {
local p
[ $quiet = 1 ] && return 0
echo " # Configuration for this build:"
echo " #"
echo " # Configuring Product: ${BLD_PRODUCT}"
echo " # Base configuration: build/${BLD_DEFAULTS}.defaults"
echo " # Version: ${BLD_VERSION}-${BLD_NUMBER}"
echo " # Host system: ${BLD_HOST_SYSTEM}"
echo " # Host O/S dist: ${BLD_HOST_DIST} (${BLD_HOST_DIST_VER})"
echo " # Build system: ${BLD_BUILD_SYSTEM}"
echo " # Debug Type: ${BLD_TYPE}"
echo " # Tune for: ${BLD_TUNE}"
if [ "$BLD_FEATURE_MULTITHREAD" = 1 ] ; then
echo " # Threading multi-threaded"
else
echo " # Threading single-threaded"
fi
if [ "$BLD_FEATURE_STATIC" = 1 ] ; then
echo " # Linking static"
else
echo " # Linking shared"
fi
echo -n " # Build components: "
for p in ${BUILD_COMPONENTS}
do
echo -n "$p "
done
echo
if [ $BLD_CROSS = 1 ] ; then
echo -n " # Host components: "
for p in ${HOST_COMPONENTS}
do
echo -n "$p "
done
echo
fi
}
postGen() {
local f
if [ "$BLD_HOST_OS" = "LINUX" -o "$BLD_HOST_OS" = "SOLARIS" -o "$BLD_HOST_OS" = "FREEBSD" ] ; then
if [ "`echo $LD_LIBRARY_PATH | grep bin`" = "" ] ; then
if [ $quiet = 0 -a ! -f ${BLD_TOP}/.embedthis ] ; then
echo -e " #\n # If you wish to debug natively in the build tree,"
echo -e " # you will need to set the LD_LIBRARY_PATH environment variable to include "
echo -e " # the \"bin\" directory. Try:"
echo -e " #\n # export LD_LIBRARY_PATH=`pwd`/bin"
echo -e " #\n # See \"INSTALL.TXT\" for details."
echo -e " #"
fi
fi
fi
for f in bld config.guess config.sub makedep priv
do
chmod +x "${BLD_TOP}/build/bin/$f"
done
#
# Touch all headers and remove objects to force a (somewhat) clean build
#
files=`echo src/include/*`
[ "$files" != 'src/include/*' ] && touch src/include/*
rm -f obj/*.o obj/*.obj bin/*.exe
rm -f lib/*.so lib/*.dylib lib/*.lib lib/*.dll lib/*.a
rm -f lib/modules/*.so lib/modules/*.dylib lib/modules/*.mod
[ -f .makedep ] && make -C bin clean 2>&1 >/dev/null
#
# Stop make regenerating dependencies if Embedthis debug build
#
if [ -f "${BLD_TOP}/.embedthis" -a "$BLD_TYPE" = "DEBUG" ] ; then
touch build/src/.makedep
fi
[ $quiet = 0 ] && echo
}
#
# Output the --help usage message
#
standardHelp()
{
cat <<!EOF_HELP
usage: configure [OPTIONS]...
Installation directories:
When doing a "make install" the --prefix and --binDir are used. The other
directory options are not yet fully supported.
--prefix=PATH Set the default base installation directory for
the product.
Default is /etc/${BLD_PRODUCT} on Unix, /${BLD_PRODUCT} on Windows.
--binDir=PATH Set the directory for binaries.
"make install" will install tools to this location.
--docDir=PATH Set the directory for the documentation.
--incDir=PATH Set the directory for include headers.
--libDir=PATH Set the directory for development libraries.
--modDir=PATH Set the directory for loadable modules.
--manDir=PATH Set the directory for the manual pages (UNIX only).
--samDir=PATH Set the directory for the samples.
--srcDir=PATH Set the directory for source files.
System Types:
--build=BUILD Configure for building on BUILD [Default is guessed].
BUILD format is cpu-vendor-os.
--host=HOST Cross-compile for ${BLD_PRODUCT} to run on HOST
[Default is set to BUILD]. HOST format is
cpu-vendor-os.
WARNING: WindRiver calls the build system the host system
and the host system, they call the target.
General Features:
--buildNumber=NUMBER Set the build number part of the version (1.0.0.X).
--defaults=FILE Set the file name of the defaults master in conf
--help Display this message.
--cygwin Use the cygwin compiler in preference if a Microsoft
Visual Studio compiler is also installed.
--endian=big|little Set the host CPU architecture endianness
Can also use --little-endian or --big-endian.
--name=NAME Set the full product name (BLD_NAME define).
--product=NAME Set the one word (no spaces) name of the product.
--quiet, -q, --silent Run quietly.
--search path Search this path first for components.
--setLibVersion=X.X.X Set the shared library version number.
--setVersion=X.X.X Set the product version number.
--type=BUILD Set the build type to (DEBUG|RELEASE).
Can also use --debug or --release
--tune=KIND Set the tune kind to (SIZE|BALANCED|SPEED).
Optional Build Features: (See more features below)
--disable-FEATURE Do not include the FEATURE.
--enable-FEATURE Include the FEATURE.
--enable-all Include all possible features and modules.
--disable-all Include as little as possible.
--enable-assert Build with assert checking.
--enable-doc Build the documentation.
--enable-floating-point Build with floating point support in JavaScript.
--enable-legacy-api Build with legacy API support for backwards compatibility.
--enable-log Build with error logging.
--enable-mmu Build for systems with virutal memory (MMU)
--enable-multi-thread Build multi-threaded.
--enable-rom Build with the ability to load files from ROM.
--enable-samples Build the samples
--enable-test Build all unit tests.
--shared Build an ${BLD_PRODUCT} shared library and program. [default]
Use either --shared or --static but not both.
--static Build a static ${BLD_PRODUCT} library and program. [default]
Environment Variables:
Some important environment variables that may be defined to control
building for the destination host. Note that environment variables will have
no effect when passed into makefiles, they must be passed via configure.
ANT Builder for java command.
AR Archiver command
BREW Brew SDK directory.
CC C/C++ compiler command.
DOXYGEN Doxygen documentation generation command.
JAVAC Java compiler command.
JDK Java SDK directory.
JAR Java archive tool
LD Linker command.
MUNCH The vxworks munch.bat command.
MT The windows manifest command.
NM The nm command.
RANLIB The ranlib command.
STRIP The strip command.
VXWORKS Wind River VxWorks SDK directory.
WTK Sun Java Wireless Toolkit directory.
CFLAGS Compiler flags for compilation
DFLAGS Compiler preprocessor defines for compilation
IFLAGS Preprocessor and include flags.
JFLAGS Java flags
LDFLAGS Linker flags. For example: use -L<dir> to specify
where to find libraries in non-standard directories.
These variables are for native compilation of tools needed by the build
process.
BUILD_CC C/C++ compiler to use for native /local compilation
and linking on the build system.
BUILD_LD Linker to use for native /local linking on the
build system.
BUILD_MT Windows manifest command.
Search paths are defined by PATH and the SEARCH_PATH set in build/env.config.
!EOF_HELP
}
lower() {
echo $* | tr '[:upper:]' '[:lower:]'
}
upper() {
echo $* | tr '[:lower:]' '[:upper:]'
}
compath() {
local upperName
upperName=`upper $*`
eval echo \$CFG_${KIND}_${upperName}
}
###############################################################################
#
# Main
#
quiet=0
verbose=0
CMD_LINE="$@"
. build/configure.*
checkSetup
#
# Parse command line args
#
while [ "${1#--}" != "$1" -o "${1#-}" != "$1" ] ; do
ARG="${1#*=}"
[ "$ARG" = "$1" ] && ARG=
case ${1#--} in
build=*)
system=`bash build/bin/config.sub "${ARG}"`
if [ $? != 0 -o "$system" = "" ]
then
echo "configure: Can't recognize build system: $ARG" 1>&2
exit 2
fi
BLD_BUILD_SYSTEM=${system}
;;
cygwin)
FORCE_CYGWIN_CC=1
;;
defaults=*)
BLD_DEFAULTS="${ARG}"
if [ ! -f "build/${BLD_DEFAULTS}.defaults" ] ; then
echo "configure: Can't find build/${BLD_DEFAULTS}.defaults" 1>&2
exit 2
fi
;;
help|-\?)
standardHelp
help
exit 0
;;
host=*)
system=`bash build/bin/config.sub "${ARG}"`
if [ $? != 0 -o "$system" = "" ]
then
echo "configure: Can't recognize host system configuration: $ARG" 1>&2
exit 2
fi
BLD_HOST_SYSTEM=${system}
;;
product=*)
BLD_PRODUCT="${ARG}"
args="$args $1"
;;
quiet|-q)
quiet=1
;;
verbose|-v)
verbose=1
;;
version|-V)
echo $CONFIGURE_VERSION
exit 0
;;
*)
args="$args $1"
;;
esac
shift
done
set -- $args
if [ $quiet = 0 ] ; then
echo -e "\n #\n # Running Embedthis Configure $CONFIGURE_VERSION"
echo -e " # "
echo -e " # Initializing configure ..."
fi
#
# Set the system configuration
#
setSystemConfiguration
#
# Read the base configuration
#
. build/$BLD_DEFAULTS.defaults
[ $quiet = 0 ] && echo -e " # Reading standard product configuration build/product.config ..."
[ $quiet = 0 ] && echo -e " # Reading build configuration build/$BLD_DEFAULTS.defaults ..."
#
# Parse command line args
#
while [ "${1#--}" != "$1" ] ; do
ARG="${1#*=}"
[ "$ARG" = "$1" ] && ARG=
case ${1#--} in
big-endian)
BLD_HOST_ENDIAN=MPR_BIG_ENDIAN
;;
binDir=*)
BLD_BIN_PREFIX=`canonPath "${ARG}"`
;;
buildNumber=*)
BLD_NUMBER="${ARG}"
;;
debug)
BLD_TYPE=DEBUG
BLD_DEBUG=1
;;
disable-assert)
BLD_FEATURE_ASSERT=0
;;
disable-doc)
BLD_FEATURE_DOC=0
BLD_OPTIONAL_TOOLS=`echo $BLD_OPTIONAL_TOOLS | sed 's/DOXYGEN//'`
;;
disable-floating-point)
BLD_FEATURE_FLOATING_POINT=0
;;
disable-legacy-api)
BLD_FEATURE_LEGACY_API=0
;;
disable-log)
BLD_FEATURE_LOG=0
;;
disable-mmu)
BLD_FEATURE_MMU=0
;;
disable-multi-thread|disable-multithread)
BLD_FEATURE_MULTITHREAD=0
;;
disable-rom-fs|disable-rom|disable-romfs)
BLD_FEATURE_ROMFS=0
;;
disable-run-as-service)
BLD_FEATURE_RUN_AS_SERVICE=0
;;
disable-samples)
BLD_FEATURE_SAMPLES=0
;;
disable-shared)
BLD_FEATURE_STATIC=1
;;
disable-static)
BLD_FEATURE_STATIC=0
;;
disable-test)
BLD_FEATURE_TEST=0
;;
enable-assert)
BLD_FEATURE_ASSERT=1
;;
enable-doc)
BLD_FEATURE_DOC=1
BLD_OPTIONAL_TOOLS=`echo $BLD_OPTIONAL_TOOLS | sed 's/DOXYGEN//'`
BLD_OPTIONAL_TOOLS=`echo $BLD_OPTIONAL_TOOLS DOXYGEN`
;;
enable-floating-point)
BLD_FEATURE_FLOATING_POINT=1
;;
enable-legacy-api)
BLD_FEATURE_LEGACY_API=1
;;
enable-log)
BLD_FEATURE_LOG=1
;;
enable-mmu)
BLD_FEATURE_MMU=1
;;
enable-multi-thread|enable-multithread)
BLD_FEATURE_MULTITHREAD=1
;;
enable-rom-fs|enable-rom|enable-romfs)
BLD_FEATURE_ROMFS=1
;;
enable-run-as-service)
BLD_FEATURE_RUN_AS_SERVICE=1
;;
enable-samples)
BLD_FEATURE_SAMPLES=1
;;
enable-shared|shared)
if [ "$BLD_HOST_OS" = VXWORKS ] ; then
echo -e "\nBuilding shared is not supported on VxWorks. Please use --static.\n"
exit 255
fi
BLD_FEATURE_STATIC=0
;;
enable-static|static)
BLD_FEATURE_STATIC=1
;;
enable-test)
BLD_FEATURE_TEST=1
;;
endian=*)
if [ "${ARG}" = "big" -o "${ARG}" = "BIG" ] ; then
BLD_HOST_ENDIAN=MPR_BIG_ENDIAN
elif [ "${ARG}" = "little" -o "${ARG}" = "LITTLE" ] ; then
BLD_HOST_ENDIAN=MPR_LITTLE_ENDIAN
else
echo -e "\nUnknown endian value. Use \"big\" or \"little\".\n"
exit 255
fi
;;
docDir=*)
BLD_DOC_PREFIX=`canonPath "${ARG}"`
;;
incDir=*)
BLD_INC_PREFIX=`canonPath "${ARG}"`
;;
libDir=*)
BLD_LIB_PREFIX=`canonPath "${ARG}"`
;;
little-endian)
BLD_HOST_ENDIAN=MPR_LITTLE_ENDIAN
;;
manDir=*)
BLD_MAN_PREFIX=`canonPath "${ARG}"`
;;
modDir=*)
BLD_MOD_PREFIX=`canonPath "${ARG}"`
;;
name=*)
BLD_NAME="${ARG}"
;;
prefix=*)
BLD_BIN_PREFIX=`remapDir "$BLD_BIN_PREFIX" "$BLD_PREFIX" "$ARG"`
BLD_DOC_PREFIX=`remapDir "$BLD_DOC_PREFIX" "$BLD_PREFIX" "$ARG"`
BLD_INC_PREFIX=`remapDir "$BLD_INC_PREFIX" "$BLD_PREFIX" "$ARG"`
BLD_LIB_PREFIX=`remapDir "$BLD_LIB_PREFIX" "$BLD_PREFIX" "$ARG"`
BLD_MOD_PREFIX=`remapDir "$BLD_MOD_PREFIX" "$BLD_PREFIX" "$ARG"`
BLD_ROOT_PREFIX=`remapDir "$BLD_ROOT_PREFIX" "$BLD_PREFIX" "$ARG"`
BLD_SAM_PREFIX=`remapDir "$BLD_SAM_PREFIX" "$BLD_PREFIX" "$ARG"`
BLD_SRC_PREFIX=`remapDir "$BLD_SRC_PREFIX" "$BLD_PREFIX" "$ARG"`
BLD_WEB_PREFIX=`remapDir "$BLD_WEB_PREFIX" "$BLD_PREFIX" "$ARG"`
BLD_MAN_PREFIX=`remapDir "$BLD_MAN_PREFIX" "$BLD_PREFIX" "$ARG"`
BLD_PREFIX=`canonPath "${ARG}"`
;;
product=*)
BLD_PRODUCT="${ARG}"
;;
release)
BLD_TYPE=RELEASE
BLD_DEBUG=1
;;
setVersion=*)
BLD_VERSION="${ARG}"
;;
silent)
quiet=1
;;
samDir=*)
BLD_SAM_PREFIX=`canonPath "${ARG}"`
;;
search=*)
SEARCH_PATH="SEARCH_PATH=${ARG}"
;;
srcDir=*)
BLD_SRC_PREFIX=`canonPath "${ARG}"`
;;
tune=*)
BLD_TUNE=`upper ${ARG}`
[ "$BLD_TUNE" = "SIZE" ] && BLD_TUNE=MPR_TUNE_SIZE
[ "$BLD_TUNE" = "BALANCED" ] && BLD_TUNE=MPR_TUNE_BALANCED
[ "$BLD_TUNE" = "SPEED" ] && BLD_TUNE=MPR_TUNE_SPEED
if [ "$BLD_TUNE" != "MPR_TUNE_SIZE" -a "$BLD_TUNE" != "MPR_TUNE_BALANCED" \
-a "$BLD_TUNE" != "MPR_TUNE_SPEED" ] ; then
echo "configure: unknown --tune option: $ARG" >&2
exit 2
fi
;;
type=*)
BLD_TYPE="${ARG}"
[ "$BLD_TYPE" = "debug" ] && BLD_TYPE=DEBUG
[ "$BLD_TYPE" = "release" ] && BLD_TYPE=RELEASE
if [ "$BLD_TYPE" != "DEBUG" -a "$BLD_TYPE" != "RELEASE" ] ; then
echo "configure: unknown --type option: $ARG" >&2
exit 2
fi
if [ "$BLD_TYPE" = "DEBUG" ] ; then
BLD_DEBUG=1
else
BLD_DEBUG=0
fi
;;
webDir=*)
BLD_WEB_PREFIX=`canonPath "${ARG}"`
;;
with-*)
with "${1#--*-}" "${ARG}"
;;
without-*)
without "${1#--*-}"
;;
*)
parseArg "${1}"
if [ $? != 0 ] ; then
echo "configure: unknown option: $_SWITCH. Try --help" >&2
exit 2
fi
;;
esac
shift
done
fixDependencies
parseEnvVars
findComponents
setConfiguration
createBuildConfig
showBuildConfig
postGen
exit 0