|
|
#!/bin/bash
|
|
|
#/*------------------------------------------------------------------------------
|
|
|
#-- This file is a part of the libuc, microcontroler library
|
|
|
#-- Copyright (C) 2011, Alexis Jeandet
|
|
|
#--
|
|
|
#-- This program is free software; you can redistribute it and/or modify
|
|
|
#-- it under the terms of the GNU General Public License as published by
|
|
|
#-- the Free Software Foundation; either version 3 of the License, or
|
|
|
#-- (at your option) any later version.
|
|
|
#--
|
|
|
#-- This program is distributed in the hope that it will be useful,
|
|
|
#-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
#-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
#-- GNU General Public License for more details.
|
|
|
#--
|
|
|
#-- You should have received a copy of the GNU General Public License
|
|
|
#-- along with this program; if not, write to the Free Software
|
|
|
#-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
#-------------------------------------------------------------------------------
|
|
|
#-- Author : Alexis Jeandet
|
|
|
#-- Mail : alexis.jeandet@gmail.com
|
|
|
#-------------------------------------------------------------------------------*/
|
|
|
|
|
|
function readFile {
|
|
|
more $1 | sed 's/#.*//' | grep -i $2' '
|
|
|
}
|
|
|
|
|
|
function getFilesList {
|
|
|
sed ':a;N;$!ba;s/\\\n/ /g' $1 | sed ':a;N;$!ba;s/\\ \n/ /g' | grep -i $2 | sed 's/\t//g'
|
|
|
}
|
|
|
|
|
|
function getObjFilesList {
|
|
|
SRCFILES=`getFilesList $PROJECTFILE SOURCES | sed 's/SOURCES//' | sed 's/+=//' | sed 's/\.c/\.o/g' | sed 's/\.s/\.o/g'`
|
|
|
echo $SRCFILES
|
|
|
}
|
|
|
|
|
|
function Template {
|
|
|
TEMPLATE=`readFile $1 "TEMPLATE" | sed s/TEMPLATE// | sed s/=// | sed 's/^[ \t]*//;s/[ \t]*$//'`
|
|
|
}
|
|
|
|
|
|
function Arch {
|
|
|
if [ -z "$2" ] ; then
|
|
|
ARCH=`readFile $1 "ARCH" | sed s/ARCH// | sed s/=// | sed 's/^[ \t]*//;s/[ \t]*$//'`
|
|
|
else
|
|
|
TEMP=`readFile $1 "$2.ARCH"`
|
|
|
if [ -z "$TEMP" ] ; then
|
|
|
ARCH=`readFile $1 "*.ARCH" | sed 's/*\.'ARCH// | sed s/=// | sed 's/^[ \t]*//;s/[ \t]*$//'`
|
|
|
else
|
|
|
ARCH=`readFile $1 "$2.ARCH" | sed s/$2'\.'ARCH// | sed s/=// | sed 's/^[ \t]*//;s/[ \t]*$//'`
|
|
|
fi
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
function Cpumodel {
|
|
|
if [ -z "$2" ] ; then
|
|
|
CPUMODEL=`readFile $1 "CPUMODEL" | sed s"/CPUMODEL//" | sed s/=// | sed 's/^[ \t]*//;s/[ \t]*$//'`
|
|
|
else
|
|
|
TEMP=`readFile $1 "$2.CPU"`
|
|
|
if [ -z "$TEMP" ] ; then
|
|
|
CPUMODEL=`readFile $1 "*.CPUMODEL" | sed 's/*\.CPUMODEL//' | sed s/=// | sed 's/^[ \t]*//;s/[ \t]*$//'`
|
|
|
else
|
|
|
CPUMODEL=`readFile $1 "$2.CPUMODEL" | sed s/$2'\.CPUMODEL//' | sed s/=// | sed 's/^[ \t]*//;s/[ \t]*$//'`
|
|
|
fi
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
|
|
|
function Target {
|
|
|
if [ -z "$2" ] ; then
|
|
|
TARGET=`readFile $1 "TARGET" | sed s/TARGET// | sed s/=// | sed 's/^[ \t]*//;s/[ \t]*$//'`
|
|
|
else
|
|
|
TARGET=`readFile $1 "$2.TARGET" | sed s/$2'\.'TARGET// | sed s/=// | sed 's/^[ \t]*//;s/[ \t]*$//'`
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
function Bspname {
|
|
|
if [ -z "$2" ] ; then
|
|
|
BSPNAME=`readFile $1 "BSPNAME" | sed s/BSPNAME// | sed s/=// | sed 's/^[ \t]*//;s/[ \t]*$//'`
|
|
|
else
|
|
|
BSPNAME=`readFile $1 "$2.BSPNAME" | sed s/$2'\.'BSPNAME// | sed s/=// | sed 's/^[ \t]*//;s/[ \t]*$//'`
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
function Objdir {
|
|
|
if [ -z "$2" ] ; then
|
|
|
OBJDIR=`readFile $1 "OBJDIR" | sed s/OBJDIR// | sed s/=// | sed 's/^[ \t]*//;s/[ \t]*$//'`
|
|
|
if [ -z "$OBJDIR" ] ; then
|
|
|
OBJDIR="obj"
|
|
|
fi
|
|
|
else
|
|
|
TEMP=`readFile $1 "$2.OBJDIR"`
|
|
|
if [ -z "$TEMP" ] ; then
|
|
|
OBJDIR=`readFile $1 "*.OBJDIR" | sed 's/*\.'OBJDIR// | sed s/=// | sed 's/^[ \t]*//;s/[ \t]*$//'`
|
|
|
if [ -z "$OBJDIR" ] ; then
|
|
|
OBJDIR="obj"
|
|
|
fi
|
|
|
else
|
|
|
OBJDIR=`readFile $1 "$2.OBJDIR" | sed s/$2'\.'OBJDIR// | sed s/=// | sed 's/^[ \t]*//;s/[ \t]*$//'`
|
|
|
if [ -z "$OBJDIR" ] ; then
|
|
|
OBJDIR="obj"
|
|
|
fi
|
|
|
fi
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
|
|
|
function Bindir {
|
|
|
if [ -z "$2" ] ; then
|
|
|
BINDIR=`readFile $1 "BINDIR" | sed s/BINDIR// | sed s/=// | sed 's/^[ \t]*//;s/[ \t]*$//'`
|
|
|
if [ -z "$BINDIR" ] ; then
|
|
|
BINDIR="bin"
|
|
|
fi
|
|
|
else
|
|
|
TEMP=`readFile $1 "$2.BINDIR"`
|
|
|
if [ -z "$TEMP" ] ; then
|
|
|
BINDIR=`readFile $1 "*.BINDIR" | sed 's/*\.'BINDIR// | sed s/=// | sed 's/^[ \t]*//;s/[ \t]*$//'`
|
|
|
if [ -z "$BINDIR" ] ; then
|
|
|
BINDIR="bin"
|
|
|
fi
|
|
|
else
|
|
|
BINDIR=`readFile $1 "$2.BINDIR" | sed s/$2'\.'BINDIR// | sed s/=// | sed 's/^[ \t]*//;s/[ \t]*$//'`
|
|
|
if [ -z "$BINDIR" ] ; then
|
|
|
BINDIR="bin"
|
|
|
fi
|
|
|
fi
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
|
|
|
function Targets {
|
|
|
TARGETS=`readFile $1 ".TARGET" | sed 's/\.TARGET.*//'`
|
|
|
}
|
|
|
|
|
|
function Libs_Inc {
|
|
|
if [ -z "$2" ] ; then
|
|
|
INCLUDEStmp=`readFile $1 "LIBS" | sed s/LIBS// |sed s/+//|sed s/=//| sed 's/^[ \t]*//;s/[ \t]*$//'`
|
|
|
for FILES in $INCLUDEStmp
|
|
|
do
|
|
|
INCLUDES+='$('"LIBUC_INC_DIR_""$FILES""_CMD) "
|
|
|
INC_LIBS_DEPS+='$('"LIBUC_INC_DIR_""$FILES"") "
|
|
|
done
|
|
|
else
|
|
|
TEMP=`readFile $1 "$2.LIBS"`
|
|
|
if [ -z "$TEMP" ] ; then
|
|
|
INCLUDEStmp=`readFile $1 "*.LIBS" | sed 's/*\.'LIBS// |sed s/+//|sed s/=//| sed 's/^[ \t]*//;s/[ \t]*$//'`
|
|
|
for FILES in $INCLUDEStmp
|
|
|
do
|
|
|
INCLUDES+='$('"LIBUC_INC_DIR_""$FILES""_CMD) "
|
|
|
INC_LIBS_DEPS+='$('"LIBUC_INC_DIR_""$FILES"") "
|
|
|
done
|
|
|
else
|
|
|
INCLUDEStmp=`readFile $1 "$2.LIBS" | sed s/$2'\.'LIBS// |sed s/+//|sed s/=//| sed 's/^[ \t]*//;s/[ \t]*$//'`
|
|
|
for FILES in $INCLUDEStmp
|
|
|
do
|
|
|
INCLUDES+='$('"LIBUC_INC_DIR_""$FILES""_CMD) "
|
|
|
INC_LIBS_DEPS+='$('"LIBUC_INC_DIR_""$FILES"") "
|
|
|
done
|
|
|
fi
|
|
|
fi
|
|
|
if [ -z "$2" ] ; then
|
|
|
INCLUDEStmp=`readFile $1 "INCLUDES" | sed s/INCLUDES// |sed s/+//|sed s/=//| sed 's/^[ \t]*//;s/[ \t]*$//'`
|
|
|
for FILES in $INCLUDEStmp
|
|
|
do
|
|
|
INCLUDES+="-I "$FILES" "
|
|
|
done
|
|
|
else
|
|
|
TEMP=`readFile $1 "$2.INCLUDES"`
|
|
|
if [ -z "$TEMP" ] ; then
|
|
|
INCLUDEStmp=`readFile $1 "*.INCLUDES" | sed 's/*\.'INCLUDES// |sed s/+//|sed s/=//| sed 's/^[ \t]*//;s/[ \t]*$//'`
|
|
|
for FILES in $INCLUDEStmp
|
|
|
do
|
|
|
INCLUDES+="-I "$FILES" "
|
|
|
done
|
|
|
else
|
|
|
INCLUDEStmp=`readFile $1 "$2.INCLUDES" | sed s/$2'\.'INCLUDES// |sed s/+//|sed s/=//| sed 's/^[ \t]*//;s/[ \t]*$//'`
|
|
|
for FILES in $INCLUDEStmp
|
|
|
do
|
|
|
INCLUDES+="-I "$FILES" "
|
|
|
done
|
|
|
fi
|
|
|
fi
|
|
|
|
|
|
}
|
|
|
|
|
|
function Libs_Link {
|
|
|
if [ -z "$2" ] ; then
|
|
|
LIBRARIEStmp=`readFile $1 "LIBS" | sed s/LIBS// |sed s/+//|sed s/=//| sed 's/^[ \t]*//;s/[ \t]*$//'`
|
|
|
for FILES in $LIBRARIEStmp
|
|
|
do
|
|
|
LIBRARIES+='$('"LIBUC_LIBS_DIR_""$FILES""_CMD) "'$('"LIBUC_LIBS_$FILES) "
|
|
|
BIN_LIBS_DEPS='$('"LIBUC_LIBS_DIR_""$FILES"")"
|
|
|
done
|
|
|
else
|
|
|
TEMP=`readFile $1 "$2.LIBS"`
|
|
|
if [ -z "$TEMP" ] ; then
|
|
|
LIBRARIEStmp=`readFile $1 "*.LIBS" | sed 's/*\.'LIBS// |sed s/+//|sed s/=//| sed 's/^[ \t]*//;s/[ \t]*$//'`
|
|
|
for FILES in $LIBRARIEStmp
|
|
|
do
|
|
|
LIBRARIES+='$('"LIBUC_LIBS_DIR_""$FILES""_CMD) "'$('"LIBUC_LIBS_$FILES) "
|
|
|
BIN_LIBS_DEPS='$('"LIBUC_LIBS_DIR_""$FILES"")"
|
|
|
done
|
|
|
else
|
|
|
LIBRARIEStmp=`readFile $1 "$2.LIBS" | sed s/$2'\.'LIBS// |sed s/+//|sed s/=//| sed 's/^[ \t]*//;s/[ \t]*$//'`
|
|
|
for FILES in $LIBRARIEStmp
|
|
|
do
|
|
|
LIBRARIES+='$('"LIBUC_LIBS_DIR_""$FILES""_CMD) "'$('"LIBUC_LIBS_$FILES) "
|
|
|
BIN_LIBS_DEPS='$('"LIBUC_LIBS_DIR_""$FILES"")"
|
|
|
done
|
|
|
fi
|
|
|
|
|
|
fi
|
|
|
|
|
|
}
|
|
|
|
|
|
function HeadersInstallPath {
|
|
|
if [ -z "$2" ] ; then
|
|
|
HEADERSINSTALLPATH=`readFile $1 "HEADERSINSTALLPATH" | sed s/HEADERSINSTALLPATH// | sed s/=// | sed 's/^[ \t]*//;s/[ \t]*$//'`
|
|
|
else
|
|
|
|
|
|
TEMP=`readFile $1 "$2.HEADERSINSTALLPATH"`
|
|
|
if [ -z "$TEMP" ] ; then
|
|
|
HEADERSINSTALLPATH=`readFile $1 "*.HEADERSINSTALLPATH" | sed 's/*\.'HEADERSINSTALLPATH// | sed s/=// | sed 's/^[ \t]*//;s/[ \t]*$//'`
|
|
|
else
|
|
|
HEADERSINSTALLPATH=`readFile $1 "$2.HEADERSINSTALLPATH" | sed s/$2'\.'HEADERSINSTALLPATH// | sed s/=// | sed 's/^[ \t]*//;s/[ \t]*$//'`
|
|
|
fi
|
|
|
fi
|
|
|
if [ -z "$HEADERSINSTALLPATH" ] ; then
|
|
|
echo "$0 error on file $1 you forget to give the headers install path"
|
|
|
echo " solution: set the varriable HEADERSINSTALLPATH in $1"
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
|
|
|
function ExtractCFLAGS {
|
|
|
if [ -z "$2" ] ; then
|
|
|
CFLAGS=`readFile $1 "CFLAGS" | sed s/CFLAGS/LIBUC_CFLAGS/ `
|
|
|
else
|
|
|
TEMP=`readFile $1 "$2.CFLAGS"`
|
|
|
if [ -z "$TEMP" ] ; then
|
|
|
CFLAGS=`readFile $1 "*.CFLAGS" | sed 's/*\.'CFLAGS/LIBUC_CFLAGS/ `
|
|
|
else
|
|
|
CFLAGS=`readFile $1 "$2.CFLAGS" | sed s/$2'\.'CFLAGS/LIBUC_CFLAGS/ `
|
|
|
fi
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
|
|
|
function ExtractLDFLAGS {
|
|
|
if [ -z "$2" ] ; then
|
|
|
LDFLAGS=`readFile $1 "LDFLAGS" | sed s/LDFLAGS/LIBUC_LDFLAGS/ `
|
|
|
else
|
|
|
TEMP=`readFile $1 "$2.LDFLAGS"`
|
|
|
if [ -z "$TEMP" ] ; then
|
|
|
LDFLAGS=`readFile $1 "*.LDFLAGS" | sed 's/*\.'LDFLAGS/LIBUC_LDFLAGS/ `
|
|
|
else
|
|
|
LDFLAGS=`readFile $1 "$2.LDFLAGS" | sed s/$2'\.'LDFLAGS/LIBUC_LDFLAGS/ `
|
|
|
fi
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
|
|
|
function ExtractODFLAGS {
|
|
|
if [ -z "$2" ] ; then
|
|
|
ODFLAGS=`readFile $1 "ODFLAGS" | sed s/ODFLAGS/LIBUC_ODFLAGS/ `
|
|
|
else
|
|
|
TEMP=`readFile $1 "$2.ODFLAGS"`
|
|
|
if [ -z "$TEMP" ] ; then
|
|
|
ODFLAGS=`readFile $1 "*.ODFLAGS" | sed 's/*\.'ODFLAGS/LIBUC_ODFLAGS/ `
|
|
|
else
|
|
|
ODFLAGS=`readFile $1 "$2.ODFLAGS" | sed s/$2'\.'ODFLAGS/LIBUC_ODFLAGS/ `
|
|
|
fi
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
|
|
|
function TargetInstallPath {
|
|
|
if [ -z "$2" ] ; then
|
|
|
TARGETINSTALLPATH=`readFile $1 "TARGETINSTALLPATH" | sed s/TARGETINSTALLPATH// | sed s/=// | sed 's/^[ \t]*//;s/[ \t]*$//'`
|
|
|
else
|
|
|
TEMP=`readFile $1 "$2.TARGETINSTALLPATH"`
|
|
|
if [ -z "$TEMP" ] ; then
|
|
|
TARGETINSTALLPATH=`readFile $1 '*.TARGETINSTALLPATH' | sed 's/*\.'TARGETINSTALLPATH// | sed s/=// | sed 's/^[ \t]*//;s/[ \t]*$//'`
|
|
|
|
|
|
else
|
|
|
TARGETINSTALLPATH=`readFile $1 "$2.TARGETINSTALLPATH" | sed s/$2'\.'TARGETINSTALLPATH// | sed s/=// | sed 's/^[ \t]*//;s/[ \t]*$//'`
|
|
|
fi
|
|
|
fi
|
|
|
if [ -z "$TARGETINSTALLPATH" ] ; then
|
|
|
echo "$0 error on file $1 you forget to give the target install path"
|
|
|
echo " solution: set the varriable TARGETINSTALLPATH in $1"
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
function getBSP {
|
|
|
if [ -z "$2" ] ; then
|
|
|
if(more $1 | sed 's/#.*//' | grep -i "BSP ="); then
|
|
|
BSP=`readFile $1 "BSP" | sed s/BSP// | sed s/=// | sed 's/^[ \t]*//;s/[ \t]*$//'`
|
|
|
fi
|
|
|
else
|
|
|
TEMP=`readFile $1 "$2.BSP"`
|
|
|
if [ -z "$TEMP" ] ; then
|
|
|
if(more $1 | sed 's/#.*//' | grep -i "*.BSP ="); then
|
|
|
BSP=`readFile $1 "*.BSP" | sed 's/*\.'BSP// | sed s/=// | sed 's/^[ \t]*//;s/[ \t]*$//'`
|
|
|
fi
|
|
|
else
|
|
|
if(more $1 | sed 's/#.*//' | grep -i "$2.BSP ="); then
|
|
|
BSP=`readFile $1 "$2.BSP" | sed s/$2'\.'BSP// | sed s/=// | sed 's/^[ \t]*//;s/[ \t]*$//'`
|
|
|
fi
|
|
|
fi
|
|
|
fi
|
|
|
if [ -z "$BSP" ] ; then
|
|
|
echo "$0 error on file $1 you forget to give the board support package"
|
|
|
echo " solution: set the varriable BSP in $1"
|
|
|
fi
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|