#!/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="" 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]*$//'` } Template $1 Target $1 Arch $1 Libs_Inc $1 Libs_Link $1 HeadersInstallPath $1 TargetInstallPath $1 echo $SRCFILES > Makefile getFilesList $1 HEADERS >> Makefile getFilesList $1 SOURCES >> Makefile echo 'PROJECTDIR = `pwd`'>> Makefile echo 'OBJECTFILES = $(SOURCES:.c=.o)'>> Makefile echo "LIBUC = $libuc2" >> 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 'include $(ARCH)/rules.mk' >> Makefile if(echo $TEMPLATE|grep -i app); then echo '' >> Makefile echo 'all:bin' >> Makefile echo " @echo Code compiled" >> Makefile else if(echo $TEMPLATE|grep -i lib); then echo '' >> Makefile echo 'all:lib' >> Makefile echo " @echo Code compiled" >> Makefile else if(echo $TEMPLATE|grep -i dir); then echo '' >> Makefile echo 'all:subdir' >> Makefile echo " @echo Code compiled" >> Makefile fi fi fi echo $TEMPLATE echo $TARGET echo $ARCH