2 # hdw-linux Config script
4 # author: hackbard@hackdaworld.org
6 # script initializing environment
13 -stage) stage="$2" ; shift 2 ;;
17 echo " ./scripts/Config -stage <stagelevel>"
23 if [ -z "$stage" ]; then
24 echo "something went wrong, no stage specified."
28 # execute Config file & create symlink to doc/README + doc/BUILD
29 if [ -f ./Config ] ; then
31 echo "setting hdw_home_dir to $hdw_home_dir"
32 echo "reading ./Config file"
34 [ ! -s ./README ] && ln -s ./doc/README .
35 [ ! -s ./BUILD ] && ln -s ./doc/BUILD .
36 [ ! -s ./INSTALL ] && ln -s ./doc/INSTALL .
37 [ ! -s ./License ] && ln -s ./doc/License .
39 echo "./Config file not found. are you in correct directory?"
43 # define the toolchain name, default: "toolchain"
44 [ -z "$hdw_tc_name" ] && hdw_tc_name="toolchain"
46 # lets see what root is:
48 if [ "$hdw_crossbuild" != "0" -o "$stage" -lt "2" ] ; then
49 # check for properly configured build directory
50 if [ -z "$hdw_build_dir" ] ; then
51 echo "please set hdw_build_dir in ./Config!"
53 elif [ ! -d $hdw_build_dir ] ; then
54 echo "please set _existing_ hdw_build_dir in ./Config"
57 echo "hdw_build_dir variable set to $hdw_build_dir"
62 # setting up general environment, now that we know $root
66 [ "$stage" -lt "2" -o "$hdw_crossbuild" != "0" ] && \
67 export PATH="$root/${hdw_tc_name}/bin:$PATH"
69 # let's do optimization and care for crossbuilds
71 # as gnu autoconf terminology has been confusing me again and again,
72 # there are a few comments following ;)
74 # ref: gcc docs - hardware models and configurations
75 # @ http://gcc.gnu.org/onlinedocs/
78 # --build: the system the actual executable is created on. uname will tell us.
79 # you may set hdw_real_build, or
80 # you may fake uname output using fake_utsname kernel module!
81 if [ -n "`uname --version | grep sh-utils`" ] ; then
82 hdw_arch_build="`uname -m -p | tr " " -`-linux-gnu"
84 hdw_arch_build="`uname -m`-unknown-linux-gnu"
86 [ -n "$hdw_real_build" ] && hdw_arch_build="${hdw_real_build}-unknown-linux-gnu"
88 # --target: the system for which the executable is going to produce code.
90 ia32) if [ -z "$hdw_arch_opt" ] ; then
91 hdw_arch_target="i386-pc-linux-gnu"
93 hdw_arch_target="${hdw_arch_opt}-pc-linux-gnu"
94 hdw_cflags="-march=${hdw_arch_opt}"
96 hdw_arch_build=${hdw_arch_build//unknown/pc} ;;
97 sparc*) if [ -z "$hdw_arch_opt" ] ; then
98 hdw_arch_target="$hdw_arch-unknown-linux-gnu"
100 hdw_arch_target="$hdw_arch-unknown-linux-gnu"
101 hdw_cflags="-march={hdw_arch_opt}"
104 hdw_arch_target="powerpc-unknown-linux-gnu"
105 if [ -z "$hdw_arch_opt" ] ; then
106 hdw_cflags="-mcpu=common"
108 hdw_cflags="-mcpu=${hdw_arch_opt}"
110 hdw_arch_build=${hdw_arch_build//ppc/powerpc} ;;
112 hdw_arch_target="powerpc64-unknown-linux-gnu"
113 if [ -z "$hdw_arch_opt" ] ; then
114 hdw_cflags="-mcpu=common"
116 hdw_cflags="-mcpu=${hdw_arch_opt}"
118 hdw_arch_build=${hdw_arch_build//ppc64/powerpc64} ;;
119 mips) hdw_arch_target="mips-unknown-linux-gnu"
120 if [ -z "$hdw_arch_opt" ] ; then
121 echo "info: no optimization set"
123 hdw_cflags="-march=${hdw_arch_opt}"
125 *) echo "$hdw_arch_target not supported yet"
126 echo "please choose a valid optimization and build platform."
130 # --host: system where the created executable runs on.
131 hdw_arch_host=${hdw_arch_build}
132 [ "$stage" != "0" -a "$hdw_crossbuild" = "0" ] && \
133 hdw_arch_host=${hdw_arch_target}
136 # optimization only at stages >= 1
137 if [ -n "$hdw_opt" -a "$stage" != "0" ] ; then
138 hdw_cflags="-O${hdw_opt} $hdw_cflags"
145 [ "$stage" != "0" ] && hdw_arch_prefix="$hdw_arch_target-"
147 # print decissions for debugging ...
148 echo "root variable set to '$root'"
149 echo "hdw_arch_target variable set to $hdw_arch_target"
150 echo "hdw_arch_build variable set to $hdw_arch_build"
151 echo "hdw_arch_host variable set to $hdw_arch_host"
152 echo "hdw_arch_prefix variable set to '$hdw_arch_prefix'"
153 echo "hdw_cflags variable set to '$hdw_cflags'"
154 echo "hdw_tc_name set to '$hdw_tc_name'"
156 # lets see what we are going to build
157 if [ -z $hdw_target ] ; then
158 echo "please set hdw_target in ./Config!"
160 elif [ ! -d ./targets/$hdw_target ] ; then
161 echo "please set _existing_ hdw_target in ./Config!"
164 echo "hdw_target variable set to $hdw_target"