# # hdw-linux Config script # # author: hackbard # # script initializing environment # hdw_status="" while [ "$1" ] ; do case "$1" in -stage) hdw_status="$2" ; shift 2 ;; *) echo echo "Usage:" echo echo " ./scripts/Config -stage " echo ;; esac done if [ -z "$hdw_status" ]; then echo "something went wrong. stage needs to be specified." exit 1 fi # execute Config file & create symlink to doc/README + doc/BUILD if [ -f ./Config ] ; then hdw_home_dir=`pwd` echo "setting hdw_home_dir to $hdw_home_dir" echo "reading ./Config file" . ./Config [ ! -s ./README ] && ln -s ./doc/README . [ ! -s ./BUILD ] && ln -s ./doc/BUILD . [ ! -s ./INSTALL ] && ln -s ./doc/INSTALL . [ ! -s ./License ] && ln -s ./doc/License . else echo "./Config file not found. are you in correct directory?" exit 1 fi # define the stage 0/1 prefix to use # default "static", though no static linking is done anymore in stage1 if [ -z "$hdw_stage1_prefix" ] ; then s1_prefix="static" # default else s1_prefix=$hdw_stage1_prefix fi # lets see what root is: root="" if [ "$hdw_crossbuild" != "0" -o "$hdw_status" -lt "2" ] ; then # check for properly configured build directory if [ -z "$hdw_build_dir" ] ; then echo "please set hdw_build_dir in ./Config!" exit 1 elif [ ! -d $hdw_build_dir ] ; then echo "please set _existing_ hdw_build_dir in ./Config" exit 1 else echo "hdw_build_dir variable set to $hdw_build_dir" root="$hdw_build_dir" fi fi # setting up general environment, now that we know $root set +h umask 022 export LC_ALL=POSIX [ "$hdw_status" -lt "2" -o "$hdw_crossbuild" != "0" ] && \ export PATH="$root/${s1_prefix}/bin:$PATH" # let's do optimization and care for crossbuilds # # as gnu autoconf terminology has been confusing me again and again, # there are a few comments following ;) # # ref: gcc docs - hardware models and configurations # @ http://gcc.gnu.org/onlinedocs/ # # --build: the system the actual executable is created on. uname will tell us. # you may set hdw_real_build, or # you may fake uname output using fake_utsname kernel module! if [ -n "`uname --version | grep sh-utils`" ] ; then hdw_arch_build="`uname -m -p | tr " " -`-linux-gnu" else hdw_arch_build="`uname -m`-unknown-linux-gnu" fi [ -n "$hdw_real_build" ] && hdw_arch_build="${hdw_real_build}-unknown-linux-gnu" # --target: the system for which the executable is going to produce code. case "$hdw_arch" in ia32) if [ -z "$hdw_arch_opt" ] ; then hdw_arch_target="i386-pc-linux-gnu" else hdw_arch_target="${hdw_arch_opt}-pc-linux-gnu" hdw_cflags="-march=${hdw_arch_opt}" fi hdw_arch_build=${hdw_arch_build//unknown/pc} ;; sparc*) if [ -z "$hdw_arch_opt" ] ; then hdw_arch_target="$hdw_arch-unknown-linux-gnu" else hdw_arch_target="$hdw_arch-unknown-linux-gnu" hdw_cflags="-march={hdw_arch_opt}" fi ;; ppc) hdw_arch_target="powerpc-unknown-linux-gnu" if [ -z "$hdw_arch_opt" ] ; then hdw_cflags="-mcpu=common" else hdw_cflags="-mcpu=${hdw_arch_opt}" fi hdw_arch_build=${hdw_arch_build//ppc/powerpc} ;; ppc64) hdw_arch_target="powerpc64-unknown-linux-gnu" if [ -z "$hdw_arch_opt" ] ; then hdw_cflags="-mcpu=common" else hdw_cflags="-mcpu=${hdw_arch_opt}" fi hdw_arch_build=${hdw_arch_build//ppc64/powerpc64} ;; mips) hdw_arch_target="mips-unknown-linux-gnu" if [ -z "$hdw_arch_opt" ] ; then echo "info: no optimization set" else hdw_cflags="-march=${hdw_arch_opt}" fi ;; *) echo "$hdw_arch_target not supported yet" echo "please choose a valid optimization and build platform." exit 1 ;; esac # --host: system where the created executable runs on. hdw_arch_host=${hdw_arch_build} [ "$hdw_status" != "0" ] && hdw_arch_host=${hdw_arch_target} # -O flag # optimization only at stages >= 1 [ -n "$hdw_opt" ] && hdw_cflags="-O${hdw_opt} $hdw_cflags" # build tools to use # should be the same like host imho, right? hdw_arch_prefix="$hdw_arch_host-" # print decissions for debugging ... echo "root variable set to '$root'" echo "hdw_arch_target variable set to $hdw_arch_target" echo "hdw_arch_build variable set to $hdw_arch_build" echo "hdw_arch_host variable ste to $hdw_arch_host" echo "hdw_arch_prefix variable set to $hdw_arch_prefix" echo "hdw_cflags variable set to $hdw_cflags" [ "$hdw_status" = "1" ] && echo "hdw_stage1_prefix set to '$s1_prefix'" # lets see what we are going to build if [ -z $hdw_target ] ; then echo "please set hdw_target in ./Config!" exit 1 elif [ ! -d ./targets/$hdw_target ] ; then echo "please set _existing_ hdw_target in ./Config!" exit 1 else echo "hdw_target variable set to $hdw_target" fi