1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
|
#! /bin/sh
# **************************************************************************
# dime-config -- a utility for retrieving configuration information about
# the installed Dime library.
#
# Authors:
# Lars J. Aas <larsa@coin3d.org>
# Morten Eriksen <mortene@coin3d.org>
#
program="$0"
me=`echo "$0" | sed 's,^.*[/\\],,g'`
wd=`echo "$0" | sed 's,/[^/]*$,,'`
prefix=`cd "$wd/.."; pwd`
hello=`echo hello | fmt -t -w70 2>&1`
if test x"$hello" = x"hello"; then
# 'fmt -t' works
preformat="fmt -t -w76"
sedformat='$ q; s/$/ \\/'
else
# sed script replacing "fmt -w76 | sed '2,$ s/^/ /g; $ q; 1,$ s/$/ \\/'"
preformat="cat"
sedformat='/^............................................................................./ {
G
s/^\([^\
]\{1,76\}\) \(.*\)\(\
\)/\1 \\\3 \2/
P
D
}'
if test xhello != x"`echo hello | sed -e $sedformat 2>&1`"; then
sedformat="s/a/a/"
fi
fi
usage="\
Usage: $me [OPTIONS]
Options:
--alternate=<string>
--cppflags
--cflags
--cxxflags
--ldflags
--libs
--includedir
--frameworkdir
--datadir
--msvcrt
--have-feature <featurename>
--compile <sourcefile> [<sourcefile>]...
--link <program> <object> [<object>]...
--build <program> <sourcefile> [<sourcefile>]...
--version
--usage | --help"
alternate=default
for arg
do
case $arg in
--alternate=*) alternate=`echo $arg | cut -d= -f2-` ;;
--debug) alternate=debug ;;
esac
done
if test -f $prefix/share/Dime/conf/dime-$alternate.cfg; then
configfile="$prefix/share/Dime/conf/dime-$alternate.cfg"
. $configfile
elif test -f $prefix/share/Dime/conf/dime-default.cfg; then
configfile="$prefix/share/Dime/conf/dime-default.cfg"
. $configfile
else
echo >&2 "$me: no default Dime config available"
exit 1
fi
while test $# -gt 0
do
case $1 in
--usage | --help) echo "$usage" ;;
--version) echo "$version" ;;
--cppflags) echo "$cppflags" ;;
--cflags) echo "$cflags" ;;
--cxxflags) echo "$cxxflags" ;;
--ldflags) echo "$ldflags" ;;
--libs) echo "$libs" ;;
--msvcrt) echo "$msvcrt" ;;
--includedir) echo "$includedir" ;;
--frameworkdir) echo "$frameworkdir" ;;
--datadir) echo "$datadir" ;;
--have-feature)
exitcode=1
eval "test x\${have_$2} = x1 && exitcode=0"
exit $exitcode
;;
--compile)
shift
if test $# -eq 1; then
echo $compiler $CPPFLAGS $cppflags $CXXFLAGS $cxxflags -c $1 \
| $preformat | sed "$sedformat"
$compiler \
$CPPFLAGS $cppflags \
$CXXFLAGS $cxxflags \
-c $1 || exit $?
else
for arg in $@; do
$program --alternate="$alternate" --compile $arg || exit $?
done
fi
exit 0
;;
--link)
shift
progname=$1
shift
echo $compiler $LDFLAGS $ldflags -o $progname $@ $libs $LIBS \
| $preformat | sed "$sedformat"
$compiler \
$LDFLAGS $ldflags \
-o $progname $@ \
$libs $LIBS || exit $?
case $host in
*-darwin*)
echo "$me: making Mac OS X application"
mkdir $progname.app 2>/dev/null
mkdir $progname.app/Contents 2>/dev/null
mkdir $progname.app/Contents/MacOS 2>/dev/null
if test -d $progname.app/Contents/MacOS &&
mv -f $progname $progname.app/Contents/MacOS/ &&
echo "APPL????" >$progname.app/Contents/PkgInfo; then
:
else
echo >&2 "$me: failed to make Mac OS X application"
echo >&2 " - problem is probably user permission or disk space related"
exit 1
fi
;;
esac
exit 0
;;
--build)
# FIXME: support -I and -framework <name> in addition to -l and -L
shift
progname=$1
objs=
extraldflags=
extralibs=
shift
for arg in $@; do
case $arg in
*.c | *.cpp | *.cxx | *.cc | *.c++)
basename=`echo "$arg" | sed -e 's/\.[^\.]*$//'`
$program --alternate="$alternate" --compile $arg || exit $?
objfile=`ls $basename.o $basename.obj 2>/dev/null`
objs="$objs $objfile"
;;
-L*)
extraldflags="$extraldflags $arg"
;;
-l*)
extralibs="$extralibs $arg"
;;
esac
done
echo $compiler $LDFLAGS $ldflags $extraldflags \
-o $progname $objs $extralibs $libs $LIBS \
| $preformat | sed "$sedformat"
$compiler \
$CPPFLAGS $cppflags \
$CXXFLAGS $cxxflags \
$LDFLAGS $ldflags $extraldflags \
-o $progname $objs \
$extralibs $libs $LIBS || exit $?
case $host in
*-darwin*)
echo "$me: making Mac OS X application"
mkdir $progname.app 2>/dev/null
mkdir $progname.app/Contents 2>/dev/null
mkdir $progname.app/Contents/MacOS 2>/dev/null
if test -d $progname.app/Contents/MacOS &&
mv -f $progname $progname.app/Contents/MacOS/ &&
echo "APPL????" >$progname.app/Contents/PkgInfo; then
:
else
echo >&2 "$me: failed to make Mac OS X application"
echo >&2 " - problem is probably user permission or disk space related"
exit 1
fi
;;
esac
exit 0
;;
# ignore some options
--alternate=*) ;;
--debug) ;;
*)
echo >&2 "$me: Invalid option: \"$1\""
echo >&2 "$usage"
exit 1
;;
esac
shift
done
exit 0
|