Return to configure CVS log | Up to [local] / prex-old |
File: [local] / prex-old / configure (download)
Revision 1.1.1.1 (vendor branch), Tue Jun 3 09:38:40 2008 UTC (16 years, 1 month ago) by nbrk
Yeah, this is an initial import of Prex, portable real-time microkernel operating system. I wanna hack it for non-profit but fun, so let it in. |
#! /bin/sh # # Prex configuration script # quit() { cat >&2 <<ERRORMSG ERROR: $@ ERRORMSG exit 1 } usage() { if [ -n "$*" ]; then echo "configure: $*" fi cat <<USAGE Usage: configure [options] General options: --target=TARGET target system --cross-compile=PREFIX prefix for cros-compile tools --no-debug disable all debug code Supported targets: i386-pc i386-nommu arm-gba USAGE exit 1 } setdefaults() { [ -d conf ] || quit "configure must be run from the top source level" target="" cross="" srcdir=`pwd` } checkpath() { CONFIG_IN=$srcdir/conf/$arch/config.$arch-$platform CMDBOX_IN=$srcdir/conf/etc/cmdbox.conf CONFIG_MK=$srcdir/conf/config.mk CONFIG_H=$srcdir/conf/config.h [ -f $CONFIG_IN ] || quit "can not find $CONFIG_IN" } getoptions() { while [ $# != 0 ]; do case $1 in --*=*) option=`expr "x$1" : 'x\([^=]*\)='` optarg=`expr "x$1" : 'x[^=]*=\(.*\)'` ;; --*) option=$1 ;; *) usage "unrecognized option $1" ;; esac case $option in --help) usage ;; --target) target=$optarg ;; --cross-compile) cross=$optarg ;; --no-debug) nodebug=1 ;; *) usage "unrecognized option $1" ;; esac shift done } gettarget() { if [ "x$target" = x ] ; then echo "Warning: '--target' option was not specified" echo "The target system was set to 'i386-pc'" target="i386-pc" fi arch=`expr "x$target" : 'x\([^=]*\)-'` platform=`expr "x$target" : 'x[^=]*-\(.*\)'` case "$arch" in i386|arm|ppc|sh|mips) ;; *) quit "Unkown target architecture: $arch" ;; esac host_name=`uname -s` case $host_name in CYGWIN*) case $arch in i386) cross="i386-elf-" ;; arm) cross="arm-elf-" ;; ppc) cross="powerpc-eabi-" ;; sh) cross="sh-elf-" ;; mips) cross="mips-elf-" ;; esac ;; esac cc="${cross}gcc" } setparm() { echo "$1=$2" echo "$1=$2" >>$CONFIG_MK if [ "$2" = "n" ] ; then echo "#undef $1" >>$CONFIG_H else echo "#define $1 $2" >>$CONFIG_H fi } setgccoption() { if $cc $1 -S -xc /dev/null -o /dev/null > /dev/null 2>&1; then echo "CONFIG_CFLAGS+= $1" >>$CONFIG_MK fi } parseconfig() { while read line; do word=`expr "x$line" : 'x\(CONFIG_[A-Za-z0-9_=]*\)'` param=`expr "x$word" : 'x\([^=]*\)='` value=`expr "x$word" : 'x[^=]*=\([A-Za-z0-9]*\)'` if [ -n "$param" ] ; then setparm "$param" "$value" fi done < $1 echo "" >> $CONFIG_MK } main() { setdefaults getoptions "$@" gettarget checkpath echo "Processing configuration files..." echo "#" > $CONFIG_MK echo "# Automatically generated file. Don't edit" >> $CONFIG_MK echo "#" >> $CONFIG_MK echo "/*" > $CONFIG_H echo " * Automatically generated file. Don't edit" >> $CONFIG_H echo " */" >> $CONFIG_H # # Generate configuration parameters # parseconfig $CONFIG_IN parseconfig $CMDBOX_IN # # Check arch/platform setting # echo "SRCDIR=$srcdir" >> $CONFIG_MK echo "ARCH=$arch" >> $CONFIG_MK echo "PLATFORM=$platform" >> $CONFIG_MK [ "x$cross" != x ] && echo "CROSS_COMPILE=$cross" >> $CONFIG_MK [ "x$nodebug" != x ] && echo "NDEBUG=1" >> $CONFIG_MK echo "" >> $CONFIG_MK # # Check gcc options # setgccoption "-fno-stack-protector" setgccoption "-Wno-variadic-macros" } main "$@"