2 # hdw-linux Config script
6 # script initializing environment
13 -stage) hdw_status="$2" ; shift 2 ;;
17 echo " ./scripts/Config -stage <stagelevel>"
22 if [ -z "$hdw_status" ]; then
23 echo "something went wrong. stage needs to be specified."
27 # execute Config file & create symlink to doc/README + doc/BUILD
28 if [ -f ./Config ] ; then
30 echo "setting hdw_home_dir to $hdw_home_dir"
31 echo "reading ./Config file"
33 [ ! -s ./README ] && ln -s ./doc/README .
34 [ ! -s ./BUILD ] && ln -s ./doc/BUILD .
35 [ ! -s ./INSTALL ] && ln -s ./doc/INSTALL .
36 [ ! -s ./License ] && ln -s ./doc/License .
38 echo "./Config file not found. are you in correct directory?"
42 # define the stage 0/1 prefix to use
43 # default "static", though no static linking is done anymore in stage1
44 if [ -z "$hdw_stage1_prefix" ] ; then
45 s1_prefix="static" # default
47 s1_prefix=$hdw_stage1_prefix
50 # lets see what root is:
52 if [ "$hdw_crossbuild" != "0" -o "$hdw_status" -lt "2" ] ; then
53 # check for properly configured build directory
54 if [ -z "$hdw_build_dir" ] ; then
55 echo "please set hdw_build_dir in ./Config!"
57 elif [ ! -d $hdw_build_dir ] ; then
58 echo "please set _existing_ hdw_build_dir in ./Config"
61 echo "hdw_build_dir variable set to $hdw_build_dir"
66 # setting up general environment, now that we know $root
70 [ "$hdw_status" -lt "2" -o "$hdw_crossbuild" != "0" ] && \
71 export PATH="$root/${s1_prefix}/bin:$PATH"
73 # let's do optimization and care for crossbuilds
75 # as gnu autoconf terminology has been confusing me again and again,
76 # there are a few comments following ;)
78 # ref: gcc docs - hardware models and configurations
79 # @ http://gcc.gnu.org/onlinedocs/
82 # --build: the system the actual executable is created on. uname will tell us.
83 # you may set hdw_real_build, or
84 # you may fake uname output using fake_utsname kernel module!
85 if [ -n "`uname --version | grep sh-utils`" ] ; then
86 hdw_arch_build="`uname -m -p | tr " " -`-linux-gnu"
88 hdw_arch_build="`uname -m`-unknown-linux-gnu"
90 [ -n "$hdw_real_build" ] && hdw_arch_build="${hdw_real_build}-unknown-linux-gnu"
92 # --target: the system for which the executable is going to produce code.
94 ia32) if [ -z "$hdw_arch_opt" ] ; then
95 hdw_arch_target="i386-pc-linux-gnu"
97 hdw_arch_target="${hdw_arch_opt}-pc-linux-gnu"
98 hdw_cflags="-march=${hdw_arch_opt}"
100 hdw_arch_build=${hdw_arch_build//unknown/pc} ;;
101 sparc*) if [ -z "$hdw_arch_opt" ] ; then
102 hdw_arch_target="$hdw_arch-unknown-linux-gnu"
104 hdw_arch_target="$hdw_arch-unknown-linux-gnu"
105 hdw_cflags="-march={hdw_arch_opt}"
108 hdw_arch_target="powerpc-unknown-linux-gnu"
109 if [ -z "$hdw_arch_opt" ] ; then
110 hdw_cflags="-mcpu=common"
112 hdw_cflags="-mcpu=${hdw_arch_opt}"
114 hdw_arch_build=${hdw_arch_build//ppc/powerpc} ;;
116 hdw_arch_target="powerpc64-unknown-linux-gnu"
117 if [ -z "$hdw_arch_opt" ] ; then
118 hdw_cflags="-mcpu=common"
120 hdw_cflags="-mcpu=${hdw_arch_opt}"
122 hdw_arch_build=${hdw_arch_build//ppc64/powerpc64} ;;
123 mips) hdw_arch_target="mips-unknown-linux-gnu"
124 if [ -z "$hdw_arch_opt" ] ; then
125 echo "info: no optimization set"
127 hdw_cflags="-march=${hdw_arch_opt}"
129 *) echo "$hdw_arch_target not supported yet"
130 echo "please choose a valid optimization and build platform."
134 # --host: system where the created executable runs on.
135 hdw_arch_host=${hdw_arch_build}
136 [ "$hdw_status" != "0" ] && hdw_arch_host=${hdw_arch_target}
139 # optimization only at stages >= 1
140 [ -n "$hdw_opt" ] && hdw_cflags="-O${hdw_opt} $hdw_cflags"
143 # should be the same like host imho, right?
144 hdw_arch_prefix="$hdw_arch_host-"
146 # print decissions for debugging ...
147 echo "root variable set to '$root'"
148 echo "hdw_arch_target variable set to $hdw_arch_target"
149 echo "hdw_arch_build variable set to $hdw_arch_build"
150 echo "hdw_arch_host variable ste to $hdw_arch_host"
151 echo "hdw_arch_prefix variable set to $hdw_arch_prefix"
152 echo "hdw_cflags variable set to $hdw_cflags"
153 [ "$hdw_status" = "1" ] && echo "hdw_stage1_prefix set to '$s1_prefix'"
155 # lets see what we are going to build
156 if [ -z $hdw_target ] ; then
157 echo "please set hdw_target in ./Config!"
159 elif [ ! -d ./targets/$hdw_target ] ; then
160 echo "please set _existing_ hdw_target in ./Config!"
163 echo "hdw_target variable set to $hdw_target"