Changed scripts/Config to grab the version from lib/libsde.in instead of lib/functions.in
[opensde-nopast.git] / lib / parse-config
blobd3f30376371ab4a72fe4a6ea36f159135113de68
1 #!/bin/sh
2 # --- SDE-COPYRIGHT-NOTE-BEGIN ---
3 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
5 # Filename: lib/parse-config
6 # Copyright (C) 2006 - 2008 The OpenSDE Project
7 # Copyright (C) 2004 - 2006 The T2 SDE Project
8 # Copyright (C) 1998 - 2003 Clifford Wolf
10 # More information can be found in the files COPYING and README.
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; version 2 of the License. A copy of the
15 # GNU General Public License can be found in the file COPYING.
16 # --- SDE-COPYRIGHT-NOTE-END ---
18 # This script sets environment settings and parses the
19 # configuration file config/$config/config
21 # [BEGIN] of version section
22 sdever=trunk
23 # [END] of version section
25 crossnative=native ; stagelevel=${stagelevel:-1} ; arch=any
26 arch_sizeof_long_long=undef ; arch_sizeof_int=undef ; export arch_machine=undef
27 arch_sizeof_char_p=undef ; arch_sizeof_long=undef ; arch_bigendian=undef
28 arch_sizeof_short=undef ; arch_target=any-unknown-linux
30 if [ -f config/$config/config ]
31 then
32 # NOTE: ROCKCFG -> SDECFG automatized convertion
33 grep -q 'ROCKCFG' ./config/$config/config &&
34 sed -i -e 's,ROCKCFG,SDECFG,g' ./config/$config/config
36 . config/$config/config
37 else
38 echo
39 echo "ERROR: No configuration '$config' found!"
40 echo
41 echo "Please create a configuration using ./scripts/Config."
42 echo
43 exit 1
46 if [ "${!SDEDEBUG_*}" ]; then
47 echo "WARNING: Found SDEDEBUG_* in environment!" >&2
50 . lib/output/parse-config
52 [ "$SDECFG_CROSSBUILD" = 1 ] && crossnative=cross
53 arch="${SDECFG_ARCH:-none}" ; target="${SDECFG_TARGET:-none}"
55 # detect target chain
56 targetchain="$target"; x="$target"
57 while [ -f "target/$x/extends" ]; do
58 x="`cat target/$x/extends`"
59 targetchain="$targetchain $x"
60 done
62 if [ -f "architecture/$arch/archtest.out" ]
63 then . "architecture/$arch/archtest.out" ; fi
65 if [ -f "architecture/$arch/archtest.sh" ]
66 then . "architecture/$arch/archtest.sh" ; fi
68 base=$(pwd -P)
70 if [ "$ROCK_THIS_IS_CHROOT" = 1 ]
71 then
72 toolsdir=tools.chroot
73 else
74 if [ $stagelevel -le 1 -a "$SDECFG_USE_CROSSCC" = 1 ]
75 then
76 toolsdir=tools.cross
77 else
78 toolsdir=tools.native
82 new_path=
83 for x in ${PATH//:/ }; do
84 if [ -d "$x" -a -z "${x##/*}" -a -n "${x##$base/*}" -a \
85 "$x" != "$CMD_WRAPPER_MYPATH" -a "$x" != "." ]; then
86 new_path="$new_path:$x"
88 done
89 export PATH="${new_path#:}"
90 unset new_path
92 if [ $stagelevel -le 1 -a "$SDECFG_USE_CROSSCC" = 1 ] ; then
93 export PATH="$base/build/$SDECFG_ID/TOOLCHAIN/$toolsdir/crosscc:$PATH"
96 export PATH="$base/build/$SDECFG_ID/TOOLCHAIN/$toolsdir/bin:$PATH"
97 export PATH="$base/build/$SDECFG_ID/TOOLCHAIN/$toolsdir/wrapper:$PATH"
98 export PATH="$PATH:/usr/sbin:/sbin"
99 export LC_ALL=C ; unset LANG ; umask 022
101 export BUILDCC="cc" BUILD_CC="cc" HOSTCC="cc" HOST_CC="cc"
102 export BUILDCXX="c++" BUILD_CXX="c++" HOSTCXX="c++" HOST_CXX="c++"
104 unset CPP ARFLAGS ASFLAGS CFLAGS CXXFLAGS CPPFLAGS FFLAGS LDFLAGS
105 unset LD_LIBRARY_PATH LD_PRELOAD FLWRAPPER C_INCLUDE_PATH CONFIG_SITE
106 unset DISPLAY
108 export STRIP_WRAPPER_MYPATH="$base/build/$SDECFG_ID/TOOLCHAIN/$toolsdir/wrapper"
109 export STRIP_WRAPPER_NOLOOP=0
111 export INSTALL_WRAPPER_MYPATH="$base/build/$SDECFG_ID/TOOLCHAIN/$toolsdir/wrapper"
112 export INSTALL_WRAPPER_LOGFILE="/dev/null"
113 export INSTALL_WRAPPER_FILTER=
114 export INSTALL_WRAPPER_NOLOOP=0
116 export CMD_WRAPPER_MYPATH="$base/build/$SDECFG_ID/TOOLCHAIN/$toolsdir/wrapper"
117 export CMD_WRAPPER_LOGFILE= CMD_WRAPPER_DEBUG=0 CMD_WRAPPER_BYPASS=0
118 export CMD_WRAPPER_NOLOOP=0 ; unset CMD_WRAPPER_OTHERS_TMP
120 export UNAME_WRAPPER_LOGFILE=
122 if [ -f $base/build/$SDECFG_ID/TOOLCHAIN/$toolsdir/lib/wrapper-config ]
123 then . $base/build/$SDECFG_ID/TOOLCHAIN/$toolsdir/lib/wrapper-config ; fi
125 if [ "$stagelevel" -gt 1 -o "$SDECFG_USE_CROSSCC" = 0 ]
126 then
127 if [ -f $base/build/$SDECFG_ID/TOOLCHAIN/$toolsdir/lib/parse-config-fixarch ]
128 then . $base/build/$SDECFG_ID/TOOLCHAIN/$toolsdir/lib/parse-config-fixarch ; fi
130 arch_build="$arch_target" ; archprefix=
131 else
132 arch_build="`/bin/uname -m | sed 's/ppc/powerpc/'`-nocross-linux-gnu"
134 if [ -f $base/build/$SDECFG_ID/TOOLCHAIN/$toolsdir/lib/parse-config-fixarch ]
135 then . $base/build/$SDECFG_ID/TOOLCHAIN/$toolsdir/lib/parse-config-fixarch ; fi
137 if [ $stagelevel -eq 1 ]; then
138 archprefix="${arch_target}-"
139 if [ ! -f "$base/build/$SDECFG_ID/TOOLCHAIN/$toolsdir/`
140 `crosscc/${archprefix}gcc" ]
141 then archprefix="Cross_CC_not_built_so_far_" ; fi
145 export CC="${archprefix}cc" CXX="${archprefix}c++" CPP="${archprefix}cpp"
146 export AS="${archprefix}as" STRIP="${archprefix}strip"
147 export LD="${archprefix}ld" GASP="${archprefix}gasp"
148 export AR="${archprefix}ar" RANLIB="${archprefix}ranlib"
149 export NM="${archprefix}nm" KCC="${archprefix}kcc"
150 export F77="${archprefix}f77" MAKE="make"
151 export AWK="gawk" SED="sed"
153 # silently ignore tail / head and co related errors due to obsolete argument
154 # usage (fixes a lot of stuff)
155 export _POSIX2_VERSION=199209