##// END OF EJS Templates
IIC library for lpc17xx started
IIC library for lpc17xx started

File last commit:

r4:cbb4685a2e27 default
r6:9626d775d625 default
Show More
libucmake
189 lines | 5.5 KiB | text/plain | TextLexer
#!/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
#-------------------------------------------------------------------------------*/
TEMPLATE=""
ARCH=""
TARGET=""
SRCFILES=""
INCLUDES=""
LIBRARIES=""
HEADERSINSTALLPATH=""
TARGETINSTALLPATH=""
BSP="generic"
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 Template {
TEMPLATE=`more $1 | grep -i "TEMPLATE " | sed s/TEMPLATE// | sed s/=// | sed 's/^[ \t]*//;s/[ \t]*$//'`
}
function Arch {
ARCH=`more $1 | grep -i "ARCH " | sed s/ARCH// | sed s/=// | sed 's/^[ \t]*//;s/[ \t]*$//'`
}
function Target {
TARGET=`more $1 | grep -i "TARGET " | sed s/TARGET// | sed s/=// | sed 's/^[ \t]*//;s/[ \t]*$//'`
}
function Libs_Inc {
INCLUDEStmp=`more $1 | grep -i "LIBS " | sed s/LIBS// |sed s/+//|sed s/=//| sed 's/^[ \t]*//;s/[ \t]*$//'`
for FILES in $INCLUDEStmp
do
INCLUDES+='$('"LIBUC_INC_DIR_$FILES) "
done
}
function Libs_Link {
LIBRARIEStmp=`more $1 | grep -i "LIBS " | sed s/LIBS// |sed s/+//|sed s/=//| sed 's/^[ \t]*//;s/[ \t]*$//'`
for FILES in $LIBRARIEStmp
do
LIBRARIES+='$('"LIBUC_LIBS_DIR_$FILES) "'$('"LIBUC_LIBS_$FILES) "
done
}
function HeadersInstallPath {
HEADERSINSTALLPATH=`more $1 | grep -i "HEADERSINSTALLPATH" | sed s/HEADERSINSTALLPATH// | sed s/=// | sed 's/^[ \t]*//;s/[ \t]*$//'`
}
function TargetInstallPath {
TARGETINSTALLPATH=`more $1 | grep -i "TARGETINSTALLPATH" | sed s/TARGETINSTALLPATH// | sed s/=// | sed 's/^[ \t]*//;s/[ \t]*$//'`
}
function getBSP {
if(more $1 | grep -i "BSP ="); then
BSP=`more $1 | grep -i "BSP" | sed s/BSP// | sed s/=// | sed 's/^[ \t]*//;s/[ \t]*$//'`
fi
}
if [ -z "$1" ] ; then
echo "try to find a project file ..."
TMP=`ls *.pro`
i=1
for Files in $TMP
do
echo "found $Files"
PROJECTFILES[i]=$Files
i=$((i + 1))
done
if [ -z "${PROJECTFILES[1]}" ]; then
exit
else
PROJECTFILE=${PROJECTFILES[1]}
fi
else
PROJECTFILE=$1
fi
CURRENTDIR=`pwd`
Template $PROJECTFILE
echo "Template = $TEMPLATE"
echo '' > Makefile
echo 'PROJECTDIR = `pwd`'>> Makefile
echo "LIBUC = $libuc2" >> Makefile
if(echo $TEMPLATE | grep -i 'dir'); then
echo 'include $(LIBUC)/rules/common/rules.mk' >> Makefile
SUBDIRS=`getFilesList $PROJECTFILE SUBDIRS | sed 's/SUBDIRS//' | sed 's/=//' | sed 's/+//' `
CURRENTDIR=`pwd`
echo "" >> Makefile
echo 'all:subdir' >> Makefile
for DIRS in $SUBDIRS
do
echo "enter $DIRS"
cd $DIRS
echo "run $0"
$0
cd $CURRENTDIR
echo "exit $DIRS"
if [ -e "$DIRS/Makefile" ]; then
echo " make -C $DIRS">> Makefile
fi
done
echo " @echo Code compiled" >> Makefile
echo "" >> Makefile
echo 'clean:' >> Makefile
for DIRS in $SUBDIRS
do
if [ -e "$DIRS/Makefile" ]; then
echo " make clean -C $DIRS">> Makefile
fi
done
echo " @echo Code compiled" >> Makefile
echo "" >> Makefile
else
Target $PROJECTFILE
Arch $PROJECTFILE
Libs_Inc $PROJECTFILE
Libs_Link $PROJECTFILE
HeadersInstallPath $PROJECTFILE
TargetInstallPath $PROJECTFILE
getBSP $PROJECTFILE
echo "Current BSP is $BSP"
echo $SRCFILES >> Makefile
if(echo $TEMPLATE|grep -i app); then
getFilesList $PROJECTFILE HEADERS >> Makefile
getFilesList $PROJECTFILE SOURCES | sed 's/SOURCES/APPSOURCES/' >> Makefile
echo 'OBJECTFILES = $(APPSOURCES:.c=.o)'>> Makefile
echo "ARCH = "'$(LIBUC)'"/rules/$ARCH" >> Makefile
echo "TARGET=$TARGET">> Makefile
echo "LIBUC_INCLUDES=$INCLUDES">> Makefile
echo "LIBUC_LIBRARIES=$LIBRARIES">> Makefile
echo "TARGETINSTALLPATH=$TARGETINSTALLPATH">> Makefile
echo "HEADERSINSTALLPATH=$HEADERSINSTALLPATH">> Makefile
echo "BSP=$BSP">> Makefile
echo 'include $(ARCH)/rules.mk' >> Makefile
echo '' >> Makefile
echo 'all:bin' >> Makefile
echo " @echo Code compiled" >> Makefile
echo '' >> Makefile
else
if(echo $TEMPLATE|grep -i lib); then
getFilesList $PROJECTFILE HEADERS >> Makefile
getFilesList $PROJECTFILE SOURCES | sed 's/SOURCES/LIBSOURCES/' >> Makefile
echo 'OBJECTFILES = $(LIBSOURCES:.c=.o)'>> Makefile
echo "ARCH = "'$(LIBUC)'"/rules/$ARCH" >> Makefile
echo "TARGET=$TARGET">> Makefile
echo "LIBUC_INCLUDES=$INCLUDES">> Makefile
echo "LIBUC_LIBRARIES=$LIBRARIES">> Makefile
echo "TARGETINSTALLPATH=$TARGETINSTALLPATH">> Makefile
echo "HEADERSINSTALLPATH=$HEADERSINSTALLPATH">> Makefile
echo "BSP=$BSP">> Makefile
echo 'include $(ARCH)/rules.mk' >> Makefile
echo '' >> Makefile
echo 'all:lib' >> Makefile
echo " @echo Code compiled" >> Makefile
fi
fi
fi