I can't get "math.h" to work with eclipse kepler using "gcc arm" - eclipse

I used this tutorial to setup all of my software: http://www.angstromsandalgorithms.com/free-eclipse-arm-gcc-openocd-toolchain-for-windows-part-3-eclipse-ide/
I'm using an STM32F405RGT6 arm. I'm also on windows. I have tried adding -lm everywhere in the makefile and havn't had anything work. Basically I just want to be able to #include "math.h" so I can use the math functions...I'm also assuming placing -lm in the right place is all I need to do from all the google searches I've done...I'm also thinking my makefile might be not be linking things correctly and/or i might not have things linked properly in eclipse.
Here is my makefile:
# Makefile for compiling the Getting Started project
#-------------------------------------------------------------------------------
# User-modifiable options
#-------------------------------------------------------------------------------
# Trace level used for compilation
# (can be overriden by adding TRACE_LEVEL=#number to the command-line)
# TRACE_LEVEL_DEBUG 5
# TRACE_LEVEL_INFO 4
# TRACE_LEVEL_WARNING 3
# TRACE_LEVEL_ERROR 2
# TRACE_LEVEL_FATAL 1
# TRACE_LEVEL_NO_TRACE 0
TRACE_LEVEL = 4
# Optimization level
OPTIMIZATION = -O0
# Output file basename
OUTPUT = main
# Output directories
BIN = .
OBJ = obj
# library dirs
LIBRARYSRC = ./lib/src
STARTUPFILE = ./lib/startup_stm32f4xx.s
#-------------------------------------------------------------------------------
# Tools
#-------------------------------------------------------------------------------
# Tool suffix when cross-compiling
CROSS_COMPILE = arm-none-eabi-
CC = $(CROSS_COMPILE)gcc
SIZE = $(CROSS_COMPILE)size
STRIP = $(CROSS_COMPILE)strip
OBJCOPY = $(CROSS_COMPILE)objcopy
OBJDUMP = $(CROSS_COMPILE)objdump
LD = $(CROSS_COMPILE)ld
AS = $(CROSS_COMPILE)as
#-------------------------------------------------------------------------------
# Files
#-------------------------------------------------------------------------------
# include folders
INCLUDES = -I./
INCLUDES += -I./lib/
INCLUDES += -I./lib/inc/
INCLUDES += -I./lib/inc/../../
# Objects built from C source files
C_OBJECTS = $(OBJ)/main.o
C_OBJECTS += $(OBJ)/system_stm32f4xx.o
C_OBJECTS += $(OBJ)/stm32f4xx_gpio.o
C_OBJECTS += $(OBJ)/stm32f4xx_rcc.o
C_OBJECTS += $(OBJ)/stm32f4xx_it.o
# Objects built from Assembly source files
ASM_OBJECTS = $(OBJ)/startup_stm32f4xx.o
LINKER_SCRIPT = ./lib/stm32f4xx_flash.ld
#LINKER_SCRIPT = ./lib/stm32f4xx_flash_extsram.ld
# Append OBJ and BIN directories to output filename
OUTPUT := $(BIN)/$(OUTPUT)
#-------------------------------------------------------------------------------
# Rules
#-------------------------------------------------------------------------------
# Flags
CFLAGS = -Wall -fno-common -c -g -mcpu=cortex-m3 -mthumb
CFLAGS += -g $(OPTIMIZATION) $(INCLUDES) -DTRACE_LEVEL=$(TRACE_LEVEL)
ASFLAGS = -g -mapcs-32
LDFLAGS = -g -v -nostartfiles
OBJCOPYFLAGS = -O binary
OBJDUMPFLAGS = -x --syms -S
all: $(BIN) $(OBJ) $(OUTPUT).out
$(BIN) $(OBJ):
mkdir $#
$(OUTPUT).out: $(C_OBJECTS) $(ASM_OBJECTS) $(LINKER_SCRIPT)
# echo "..linking"
$(LD) $(LDFLAGS) -Map $(OUTPUT).map -T$(LINKER_SCRIPT) -o $(OUTPUT).out $(C_OBJECTS) $(ASM_OBJECTS) libgcc.a
$(OBJCOPY) $(OBJCOPYFLAGS) $(OUTPUT).out $(OUTPUT).bin
# $(OBJDUMP) $(OBJDUMPFLAGS) $(OUTPUT).out > $(OUTPUT).lss
# echo "...completed."
$(C_OBJECTS): main.c system_stm32f4xx.c
# echo ".compiling"
$(CC) $(CFLAGS) -o $(OBJ)/main.o main.c
$(CC) $(CFLAGS) -o $(OBJ)/system_stm32f4xx.o system_stm32f4xx.c
$(CC) $(CFLAGS) -o $(OBJ)/stm32f4xx_it.o stm32f4xx_it.c
# echo ".compiling libraries"
$(CC) $(CFLAGS) -o $(OBJ)/stm32f4xx_gpio.o $(LIBRARYSRC)/stm32f4xx_gpio.c
$(CC) $(CFLAGS) -o $(OBJ)/stm32f4xx_rcc.o $(LIBRARYSRC)/stm32f4xx_rcc.c
$(ASM_OBJECTS): $(STARTUPFILE)
# echo ".assembling"
$(AS) $(ASFLAGS) -o $(OBJ)/startup_stm32f4xx.o $(STARTUPFILE)
clean:
-rm -f $(OBJ)/*.o $(BIN)/*.out $(BIN)/*.bin $(BIN)/*.dmp $(BIN)/*.map $(BIN)/*.lss

Related

rpmbuild bad exit status error while creating binary RPM

It is my first time creating RPM package and I followed this documentation to build a simple RPM package. I created source RPM but I can't create binary RPM.
Here is the result when I execute rpmbuild --rebuild /SRPMS/bello-0.1.1.el8.src.rpm:
Installing ../SRPMS/bello-0.1-1.el8.src.rpm
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.LmHvbG
+ umask 022
+ cd /root/rpmbuild/BUILD
+ cd /root/rpmbuild/BUILD
+ rm -rf bello-0.1
+ /usr/bin/gzip -dc /root/rpmbuild/SOURCES/bello-0.1.tar.gz
+ /usr/bin/tar -xof -
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd bello-0.1
+ /usr/bin/chmod -Rf a+rX,u+w,g-w,o-w .
+ exit 0
Executing(%build): /bin/sh -e /var/tmp/rpm-tmp.k6UGT9
+ umask 022
+ cd /root/rpmbuild/BUILD
+ cd bello-0.1
+ CFLAGS='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection'
+ export CFLAGS
+ CXXFLAGS='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection'
+ export CXXFLAGS
+ FFLAGS='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -I/usr/lib64/gfortran/modules'
+ export FFLAGS
+ FCFLAGS='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -I/usr/lib64/gfortran/modules'
+ export FCFLAGS
+ LDFLAGS='-Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld'
+ export LDFLAGS
+ '[' 1 = 1 ']'
+++ dirname ./configure
++ find . -name config.guess -o -name config.sub
+ '[' 1 = 1 ']'
+ '[' x '!=' 'x-Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld' ']'
++ find . -name ltmain.sh
+ ./configure --build=x86_64-redhat-linux-gnu --host=x86_64-redhat-linux-gnu --program-prefix= --disable-dependency-tracking --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64 --libexecdir=/usr/libexec --localstatedir=/var --sharedstatedir=/var/lib --mandir=/usr/share/man --infodir=/usr/share/info
/var/tmp/rpm-tmp.k6UGT9: line 49: ./configure: No such file or directory
error: Bad exit status from /var/tmp/rpm-tmp.k6UGT9 (%build)
RPM build errors:
Bad exit status from /var/tmp/rpm-tmp.k6UGT9 (%build)
I get the same result when I execute rpmbuild -bb bello.spec command.
Here is my SPEC file:
Name: bello
Version: 0.1
Release: 1%{?dist}
Summary: Hello World example implemented in bash script
License: GPLv3+
URL: https://example.com/%{name}
Source0: https://example.com/%{name}/releases/%{name}-%{version}.tar.gz
Requires: bash
BuildArch: noarch
%description
some description for this basic code.
%prep
%setup -q
%build
%configure
%make_build
%install
mkdir -p %{buildroot}/%{_bindir}
install -m 0755 %{name} %{buildroot}/%{_bindir}/%{name}
%make_install
%files
%{_bindir}/%{name}
%license LICENSE
%doc add-docs-here
%changelog
* Tue Aug 30 2022 talat ayhan <fadedship#gmail.com> - 0.1-1
- First bello package
- Example second item in the changelog for version-release 0.1-1

Why make utility cannot find header file?

I have been working in Eclipse based IDE called Vitis (IDE from Xilinx).
I have an automatically generated software project containing three automatically
generated Makefiles. Organization of the project is following:
zynq_fsbl
-Makefile_level_01
-main.c
-zynq_fsbl_bsp
-Makefile_level_02
-ps7_cortexa9_0
-code
-include
-Config.h
-lib
-libsrc
-peripheral_01
-src
-driver_peripheral_01.c
-driver_peripheral_01.h
-Makefile_level_03_01
-peripheral_02
-src
-driver_peripheral_02.c
-driver_peripheral_02.h
-Makefile_level_03_02
- ... same pattern repeats for other perpherals
Makefile_level_01 contains:
# Auto Generated by Xilinx generate_app. Modify at your own risk
CC := arm-none-eabi-gcc
CC_FLAGS := -MMD -MP -mcpu=cortex-a9 -mfpu=vfpv3 -mfloat-abi=hard
CFLAGS :=
LN_FLAGS := -mcpu=cortex-a9 -mfpu=vfpv3 -mfloat-abi=hard -Wl,-build-id=none -specs=Xilinx.spec -lrsa -Wl,--start-group,-lxil,-lgcc,-lc,--end-group -Wl,--start-group,-lxilffs,-lxil,-lgcc,-lc,--end-group -Wl,--start-group,-lrsa,-lxil,-lgcc,-lc,--end-group -Wl,--gc-sections
c_SOURCES := $(wildcard *.c)
S_SOURCES := $(wildcard *.S)
INCLUDES := $(wildcard *.h)
OBJS := $(patsubst %.c, %.o, $(c_SOURCES))
OBJS += $(patsubst %.S, %.o, $(S_SOURCES))
LSCRIPT := -Tlscript.ld
CURRENT_DIR = $(shell pwd)
DEPFILES := $(patsubst %.o, %.d, $(OBJS))
LIBS := zynq_fsbl_bsp/ps7_cortexa9_0/lib/libxil.a
EXEC := executable.elf
INCLUDEPATH := -Izynq_fsbl_bsp/ps7_cortexa9_0/include -I.
LIBPATH := -Lzynq_fsbl_bsp/ps7_cortexa9_0/lib -L./
all: $(EXEC)
$(EXEC): $(LIBS) $(OBJS) $(INCLUDES)
$(CC) -o $# $(OBJS) $(CC_FLAGS) $(CFLAGS) $(LN_FLAGS) $(LIBPATH) $(LSCRIPT)
$(LIBS):
$(MAKE) -C zynq_fsbl_bsp
%.o:%.c
$(CC) $(CC_FLAGS) $(CFLAGS) -c $< -o $# $(INCLUDEPATH)
%.o:%.S
$(CC) $(CC_FLAGS) $(CFLAGS) -c $< -o $# $(INCLUDEPATH)
%.o:%.s
$(CC) $(CC_FLAGS) $(CFLAGS) -c $< -o $# $(INCLUDEPATH)
clean:
rm -rf $(OBJS) $(LIBS) $(EXEC) *.o
-include $(DEPFILES)
Makefile_level_02 contains:
# Makefile generated by Xilinx.
PROCESSOR = ps7_cortexa9_0
LIBRARIES = ${PROCESSOR}/lib/libxil.a
BSP_MAKEFILES := $(wildcard $(PROCESSOR)/libsrc/*/src/Makefile)
SUBDIRS := $(patsubst %/Makefile, %, $(BSP_MAKEFILES))
ifneq (,$(findstring win,$(RDI_PLATFORM)))
SHELL = CMD
endif
all: libs
#echo 'Finished building libraries'
include: $(addsuffix /make.include,$(SUBDIRS))
libs: $(addsuffix /make.libs,$(SUBDIRS))
clean: $(addsuffix /make.clean,$(SUBDIRS))
$(PROCESSOR)/lib/libxil.a: $(PROCESSOR)/lib/libxil_init.a
cp -f $< $#
%/make.include: $(if $(wildcard $(PROCESSOR)/lib/libxil_init.a),$(PROCESSOR)/lib/libxil.a,)
#echo "Running Make include in $(subst /make.include,,$#)"
$(MAKE) -C $(subst /make.include,,$#) -s include "SHELL=$(SHELL)" "COMPILER=arm-none-eabi-gcc" "ASSEMBLER=arm-none-eabi-as" "ARCHIVER=arm-none-eabi-ar" "COMPILER_FLAGS= -O2 -c" "EXTRA_COMPILER_FLAGS=-mcpu=cortex-a9 -mfpu=vfpv3 -mfloat-abi=hard -nostartfiles -g -Wall -Wextra"
%/make.libs: include
#echo "Running Make libs in $(subst /make.libs,,$#)"
$(MAKE) -C $(subst /make.libs,,$#) -s libs "SHELL=$(SHELL)" "COMPILER=arm-none-eabi-gcc" "ASSEMBLER=arm-none-eabi-as" "ARCHIVER=arm-none-eabi-ar" "COMPILER_FLAGS= -O2 -c" "EXTRA_COMPILER_FLAGS=-mcpu=cortex-a9 -mfpu=vfpv3 -mfloat-abi=hard -nostartfiles -g -Wall -Wextra"
%/make.clean:
$(MAKE) -C $(subst /make.clean,,$#) -s clean
clean:
rm -f ${PROCESSOR}/lib/libxil.a
Makefile_level_03 for peripheral_01 contains:
COMPILER=
ARCHIVER=
CP=cp
COMPILER_FLAGS=
EXTRA_COMPILER_FLAGS=
LIB=libxil.a
LEVEL=0
RELEASEDIR=../../../lib
INCLUDEDIR=../../../include
INCLUDES=-I./. -I${INCLUDEDIR}
INCLUDEFILES=*.h
LIBSOURCES=*.c
OUTS = *.o
libs:
echo "Compiling driver_peripheral_01 ..."
$(COMPILER) $(COMPILER_FLAGS) $(EXTRA_COMPILER_FLAGS) $(INCLUDES) $(LIBSOURCES)
$(ARCHIVER) -r ${RELEASEDIR}/${LIB} ${OUTS}
make clean
include:
${CP} $(INCLUDEFILES) $(INCLUDEDIR)
clean:
rm -rf ${OUTS}
My problem is that I am not able to compile the driver_peripheral_01.c module due to the problem with
Config.h header file inclusion. The "fatal error: Config.h: No such file or directory" is being invoked despite the fact that I have copied the header file in question into the include subdirectory in project directory structure. Does anybody have any idea why the make cannot find the Config.h header file? Thanks for any suggestions.

Listing SRC_URI of all packages/files needed to build Yocto image

I would like to list all files that bitbake will fetch when I bake an image.
Currently, I am able to get the SRC_URI of all files needed to bake a Yocto image by executing bitbake core-image-minimal -c fetchall and then parse log files.
Is there is a simpler way to get the same result without the need to download files ?
I am not sure bitbake supports such feature. Ideally, I am looking for a command that prints out the package name and lists all files with corresponding URL
> bitbake core-image-minimal -c fetchall --print-only
Generally bitbake doesn't provides such functionality.
But I was able to create a simple solution witch creating simple .bbclass file which is inherited in all recipes, by adding it into local.conf file, please see my steps in order to archive that:
Steps:
let's create a class print-src.bbclass file used to get and print SRC_URI variable (remember to store this class file in layer which is available in conf/bblayers.conf):
$ cat print-src.bbclass
python do_print_src () {
# should probably be indented
srcuri = d.getVar('SRC_URI', True).split()
bb.warn("SRC_URI look like: %s" % srcuri)
}
addtask do_print_src before do_fetch
Add INHERIT += "print-src" into Your conf/local.conf file
Edit: it is important to use bitbake --runonly option, that allows to run specific task of the taskgraph for the specified target (with --runonly option do_print_src needs to be used as print_src),
Edit: Please note that --runall=RUNALL and --runonly=RUNONLY was introduced with Yocto Sumo release 2.5,
$ bitbake core-image-minimal --runonly print_src
Loaded 1236 entries from dependency cache.
NOTE: Resolving any missing task queue dependencies
Build Configuration:
BB_VERSION = "1.37.0"
BUILD_SYS = "x86_64-linux"
NATIVELSBSTRING = "universal-4.8"
TARGET_SYS = "i586-poky-linux"
MACHINE = "qemux86"
DISTRO = "poky"
DISTRO_VERSION = "2.5"
TUNE_FEATURES = "m32 i586"
TARGET_FPU = ""
meta
meta-poky
meta-yocto-bsp = "master:13cc30cd7de4841990b600e83e1249c81a5171dd"
Initialising tasks: 100% |##########################################################################################################################################################################| Time: 0:00:00
NOTE: Executing RunQueue Tasks
WARNING: ptest-runner-2.2+gitAUTOINC+49956f65bb-r0 do_print_src: SRC_URI look like: ['git://git.yoctoproject.org/ptest-runner2']
WARNING: grep-3.1-r0 do_print_src: SRC_URI look like: ['http://ftp.gnu.org/gnu/grep/grep-3.1.tar.xz', 'file://0001-Unset-need_charset_alias-when-building-for-musl.patch']
...
...
NOTE: Tasks Summary: Attempted 201 tasks of which 0 didn't need to be rerun and all succeeded.
Summary: There were 202 WARNING messages shown.
Please see sample warning output log line:
WARNING: ptest-runner-2.2+gitAUTOINC+49956f65bb-r0 do_print_src: SRC_URI look like: ['git://git.yoctoproject.org/ptest-runner2'].
I patched poky to create *.src files in downloads that contains the effective fetch URL of the package.
bitbake/lib/bb/fetch2/__init__.py | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py
index b853da30bd..03e84e0919 100644
--- a/bitbake/lib/bb/fetch2/__init__.py
+++ b/bitbake/lib/bb/fetch2/__init__.py
## -1257,16 +1257,16 ## class FetchData(object):
# Note: .done and .lock files should always be in DL_DIR whereas localpath may not be.
if self.localpath and self.localpath.startswith(dldir):
- basepath = self.localpath
+ self.basepath = self.localpath
elif self.localpath:
- basepath = dldir + os.sep + os.path.basename(self.localpath)
+ self.basepath = dldir + os.sep + os.path.basename(self.localpath)
elif self.basepath or self.basename:
- basepath = dldir + os.sep + (self.basepath or self.basename)
+ self.basepath = dldir + os.sep + (self.basepath or self.basename)
else:
bb.fatal("Can't determine lock path for url %s" % url)
- self.donestamp = basepath + '.done'
- self.lockfile = basepath + '.lock'
+ self.donestamp = self.basepath + '.done'
+ self.lockfile = self.basepath + '.lock'
def setup_revisions(self, d):
self.revisions = {}
## -1607,6 +1607,15 ## class Fetch(object):
m = ud.method
localpath = ""
+ p = "%s.src"%ud.basepath
+ d = os.path.dirname(p)
+ if d != '':
+ bb.utils.mkdirhier(d)
+ with open(p, 'wb') as f:
+ data = "%s" % ud.url
+ f.write(bytes(data, 'ASCII'))
+ return True
+
if ud.lockfile:
lf = bb.utils.lockfile(ud.lockfile)
Running bitbake core-image-minimal -c fetchall results:
$> find downloads/ -name '*.src' | head -n 5
downloads/lzop-1.03.tar.gz.src
downloads/libtheora-1.1.1.tar.bz2.src
downloads/mpfr-3.1.5.tar.xz.src
downloads/makedevs.c.src
downloads/expat-2.2.0.tar.bz2.src
This is not an optimal solution but I hope that such feature gets its way to mainline stream.
I needed something like this and got part way there before now.
I can generate a messy list of URIs used by executing the following command:
bitbake -g zlib && cat recipe-depends.dot | \
grep -v -e '-native' | grep -v digraph | \
grep -v -e '-image' | awk '{print $1}' | \
sort | uniq | xargs -I {} -t bitbake -e {} | grep SRC_URI=
This gives you all the URIs and files used in a recipe and some comments.
Not a perfect solution but I will see if I can improve on it.
A bit manual and straight forward way is to build your image from scratch, and copy all the fetch logs, and go thru it.
$ mkdir fetch_logs
$ find tmp/work/ -type f -name log.do_fetch* | cpio -pdm fetch_logs
Now grep "Fetch(ing/er)" in this fetch_logs and it will provide info on which URL your recipe used to fetch the source. This will be helpful to see the final URI used to fetch in PREMIRROR based builds.
NOTE: if you have sstate-cache enabled and functional, you may not see do_fetch at all.
I wrote scripts based on the solution in the question.
Basically I need to make a cscope project of all the sources, and hence I need to list all URI and clone all repos.
I wrote 2 scripts 1) List all SRC_URI and Branches
2) Install(clone) all the code in a single directory
listURI.sh
#!/bin/bash
TMP_FILE="___x__2242230p.txt"
SRCH_FILE="log.do_fetch"
TIME=$(date +%Y-%m-%d-%H-%M)
OUT_FILE="Project-$TIME.txt"
DEF_BRANCH="master"
BRANCH=""
SRC_URI=""
function usage {
echo "Usage : $0 < -f | -g > <Component-List-file>"
echo "Options :"
echo " -f : Run bitbake fetch and collect URI"
echo " -g : Get URI from Already fetched Project"
}
if [ $# -eq 0 ]
then
usage
exit
fi
if [ "$1" == "-f" ] || [ "$1" == "-g" ];then
if [ "$1" == "-f" ] && [ -z "$2" ];then
echo "Should pass Project-Name after -f Option"
exit
fi
else
echo "Unknown Option"
usage
exit
fi
POKYROOTDIR=`basename "$PWD"`
#echo $POKYROOTDIR
if [[ $POKYROOTDIR != "build" ]];then
echo "You are not on poky/build (Sourced Poky) Directory"
exit 0
fi
POKYROOTDIR=$PWD
if [ "$1" == "-f" ];then
echo "Running === bitbake -c fetchall $2 -f --no-setscene =="
bitbake -c fetchall $2 -f --no-setscene
fi
if [ "$1" == "-g" ];then
if [ ! -d tmp/work ];then
echo " Please run == bitbake -c fetchall <image> -f --no-setscene == before this"
usage
exit
fi
fi
echo "Looking for URIs --- It may take couple of minuites!"
rm -rf $OUT_FILE
cd tmp/work
find . -name $SRCH_FILE -exec grep -i 'DEBUG: For url git' {} \; -print > $POKYROOTDIR/$TMP_FILE
cd $POKYROOTDIR
while IFS= read -r line
do
#echo "$line"
BRANCH=$(echo $line | awk -F"branch=" '/branch=/{print $2}' | sed -e 's/;/ /' | awk '{print $1}')
SRC_URI=$(echo $line | cut -d';' -f1-1 | awk -F"url" '/url/{print $2}' | awk '{print $1}' | sed -e 's/git:/ssh:/')
if [ ! -z "$BRANCH" ] && [ ! -z "$SRC_URI" ];then
echo "$BRANCH $SRC_URI" >> $OUT_FILE
elif [ ! -z "$SRC_URI" ];then
echo "$DEF_BRANCH $SRC_URI" >> $OUT_FILE
fi
if [ ! -z "$BRANCH" ];then
echo "Found URI : BRANCH:$BRANCH URI:$SRC_URI"
elif [ ! -z "$SRC_URI" ];then
echo "Found URI : BRANCH:Default URI:$SRC_URI"
fi
#echo "$BRANCH $SRC_URI" >> $OUT_FILE
done < "$TMP_FILE"
#echo "=================== OUT PUT ==========================="
#cat $OUT_FILE
rm -rf $TMP_FILE
echo "----------------INFO-----------------"
echo "Project Creation: Success"
echo "Project Path : $POKYROOTDIR"
echo "Project file : $OUT_FILE"
echo "-------------------------------------"
installURI.sh
#!/bin/bash
function usage {
echo "Usage : $0 <List-file>"
}
if [ $# -eq 0 ]
then
usage
exit
fi
if [ -z "$1" ];then
usage
exit
fi
if [ ! -z "$(ls -A $PWD)" ]; then
echo "Directory ($PWD) must be Empty.... else it will mess up project creation"
exit
fi
if [ ! -f $1 ];then
echo "list file ($1) not found"
usage
exit
fi
filename=$1
while read -r line; do
name="$line"
echo "Fetching Projects"
git clone -b $line
done < "$filename"
echo "----------------INFO-----------------"
echo "Project Creation: Success"
echo "Project Path : $PWD"
echo "-------------------------------------"

How to add a library (header + .c) compilation in MakeFile (Eclipse) ?

I'm working on a project, coding in C++, to develop a communication Modbus over TCP/IP between a Raspberry pi and an Arduino.
I have a basic exemple of "hello world" which works in Raspberry. I want to add the libmodbus library (.h and .c files) in my Eclipse Project, and test a server-unit-test provided. I have already added the directory in "Path and Symbol" (GNU C and GNU C++) and the "included ".
In the MakeFile, I have added the directory of the libmodbus file section (#Include paths). When I build the project, only the .h files are compiled, no the .c file. The "modbus.h" is recognized, but they are errors like "undefined reference to ....(modbus fonctions).
I have tested many solutions but it doesn't work yet.
Thanks in advance.
################################################################################
# MAKEFILE : RPi2Test01
################################################################################
#===============================================================================
# User compiling options
#===============================================================================
#HOST: PC, PCLINUX, ARM
HOST := PC
#HOST := PCLINUX
#HOST :: ARM
#TARGET: PC, ARM, RASPBERRYPI
#TARGET := PC
#TARGET := ARM
TARGET := RASPBERRYPI
#DEBUG: YES, NO
DEBUG := NO
#===============================================================================
# Compiling options
#===============================================================================
#-------------------------------------------------------------------------------
# Determine compiling environment #ENVIRONMENT: CYGWIN,LINUX,WCROSS,LCROSS,ARM
#-------------------------------------------------------------------------------
ifeq ($(HOST),PC)
ifeq ($(TARGET),PC)
ENVIRONMENT := CYGWIN
else
ENVIRONMENT := WCROSS
endif
else
ifeq ($(HOST),LINUXPC)
ifeq ($(TARGET),PC)
ENVIRONMENT := LINUX
else
ENVIRONMENT := LCROSS
endif
else
ifeq ($(HOST),ARM)
ENVIRONMENT := ARM
endif
endif
endif
#-------------------------------------------------------------------------------
# Customize: WIN32 (CYGWIN)
#-------------------------------------------------------------------------------
ifeq ($(ENVIRONMENT),CYGWIN)
PREFIX :=
BINPREFIX :=
CFLAGS := -std=gnu99 -Wno-write-strings
CFLAGS += -D_WIN32_ -D__CYGWIN__ -D_$(TARGET)_
CPPFLAGS := -pipe -g2 -Wall -Wno-write-strings -Wno-reorder
CPPFLAGS += -D_WIN32_ -D__CYGWIN__ -D_$(TARGET)_
LDFLAGS := -enable-auto-import
LIBEXT := .a
BINEXT := .exe
endif
#-------------------------------------------------------------------------------
# Customize: LINUX (LINUX)
#-------------------------------------------------------------------------------
ifeq ($(ENVIRONMENT),LINUX)
PREFIX :=
BINPREFIX :=
CFLAGS := -std=gnu99 -Wno-write-strings
CFLAGS += -D_LINUX_ -D_$(TARGET)_
CPPFLAGS := -Wno-write-strings -Wno-reorder
CPPFLAGS += -D_LINUX_ -D_$(TARGET)_
LDFLAGS := -g
LIBEXT := .a
BINEXT := .out
endif
#-------------------------------------------------------------------------------
# Customize: Cross-compiling CYGWIN to ARM-LINUX-LINARO (WCROSS)
#-------------------------------------------------------------------------------
ifeq ($(ENVIRONMENT),WCROSS)
PREFIX := arm-linux-gnueabihf-
BINPREFIX := /cygdrive/c/Linaro/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09/bin/
CFLAGS := -std=gnu99 -Wno-write-strings
CFLAGS += -D_LINUX_ -D_$(TARGET)_
CPPFLAGS := -Wno-write-strings -Wno-reorder
CPPFLAGS += -D_LINUX_ -D_$(TARGET)_
LDFLAGS := -g
LIBEXT := .a
BINEXT := .out
endif
#-------------------------------------------------------------------------------
# Customize: Cross-compiling LINUX to ARM-LINUX-LINARO (LCROSS)
#-------------------------------------------------------------------------------
ifeq ($(ENVIRONMENT),LCROSS)
PREFIX := arm-linux-gnueabihf-
BINPREFIX := /usr/local/Linaro/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09/bin/
CFLAGS := -std=gnu99 -Wno-write-strings
CFLAGS += -D_LINUX_ -D_$(TARGET)_
CPPFLAGS := -Wno-write-strings -Wno-reorder
CPPFLAGS += -D_LINUX_ -D_$(TARGET)_
LDFLAGS := -g
LIBEXT := .a
BINEXT := .out
endif
#-------------------------------------------------------------------------------
# Customize: ARM-LINUX-LINARO (ARM)
#-------------------------------------------------------------------------------
ifeq ($(ENVIRONMENT),ARM)
PREFIX :=
BINPREFIX :=
CFLAGS := -std=gnu99 -Wno-write-strings
CFLAGS += -D_LINUX_ -D_$(TARGET)_
CPPFLAGS := -Wno-write-strings -Wno-reorder
CPPFLAGS += -D_LINUX_ -D_$(TARGET)_
LDFLAGS := -g
LIBEXT := .a
BINEXT := .out
endif
#-------------------------------------------------------------------------------
# Compiling and linking features - Paths and libraries
#-------------------------------------------------------------------------------
CINC_PATH := $(INCLUDE)
CLIB_PATH := $(CLIB_PATH)
ifeq ($(ENVIRONMENT),ARM)
CINC_PATH += -I/usr/local/include
CLIB_PATH += -L/usr/local/lib
endif
ifeq ($(DEBUG),YES)
LIBSUBFIX := d
CPPFLAGS += -D_DEBUG_
else
LIBSUBFIX :=
CPPFLAGS +=
endif
LDADDLIBS += -lpthread -lrt -lm -lstdc++
#===============================================================================
# Building tools
#===============================================================================
CC := #$(BINPREFIX)$(PREFIX)gcc
CXX := #$(BINPREFIX)$(PREFIX)g++
LD := #$(BINPREFIX)$(PREFIX)ld
AR := #$(BINPREFIX)$(PREFIX)ar
MD := #mkdir -p
RM := #rm -rf
ECHO := #echo
#===============================================================================
# File pathts
#===============================================================================
SRCDIR := .
OBJPATH := ./OBJ
LIBPATH := ./LIB
GENPATH := ./BIN
#===============================================================================
# Source files
#===============================================================================
MAIN_HOME := $(SRCDIR)
CPP_SRCS_MAIN := $(MAIN_HOME)/RPi2Test01.cpp
#===============================================================================
# Object files
#===============================================================================
OBJS_MAIN := $(patsubst $(MAIN_HOME)/%.cpp, \
$(OBJPATH)/%.cpp.o, \
$(CPP_SRCS_MAIN))
#LIB_SRC := C:/libmodbus-3.0.6/src/%.c
#LIBSMAIN := $(patsubst C:/libmodbus-3.0.6/src/%.c, \
$(LIBPATH)/%.c.o, \
$(LIB_SRC))
#===============================================================================
# Building options
#===============================================================================
# Include paths
CINC_PATH += -I C:/libmodbus-3.0.6/src
CLIB_PATH += -L C:/libmodbus-3.0.6/src
CLIB_PATH += -L$(LIBPATH)
# Compiling and Linking options
CFLAGS := $(CINC_PATH) $(CFLAGS)
CPPFLAGS := $(CINC_PATH) $(CPPFLAGS)
LDFLAGS := $(CLIB_PATH) $(LDFLAGS)
#===============================================================================
# Building targets
#===============================================================================
BINMAIN := $(GENPATH)/RPi2Test01$(BINEXT)
#-------------------------------------------------------------------------------
# All targets
#-------------------------------------------------------------------------------
.PHONY: all
all: dirs $(BINMAIN)
#-------------------------------------------------------------------------------
# Building directories
#-------------------------------------------------------------------------------
dirs:
$(MD) $(OBJPATH)
$(MD) $(LIBPATH)
$(MD) $(GENPATH)
#-------------------------------------------------------------------------------
# Targets
#-------------------------------------------------------------------------------
$(BINMAIN): $(OBJS_MAIN) $(LIBSMAIN)
$(ECHO) 'Building target: $#'
$(CC) $(OBJS_MAIN) -o$# $(LDFLAGS) $(LDADDLIBS)
#-------------------------------------------------------------------------------
# Compiling
#-------------------------------------------------------------------------------
# File compiling: Main Programs ------------------------------------------------
$(OBJPATH)/%.cpp.o: $(MAIN_HOME)/%.cpp
$(ECHO) 'Building file: $<'
$(CXX) -c $(CPPFLAGS) -o$# $<
#===============================================================================
# Clean
#===============================================================================
.PHONY: clean
clean:
$(ECHO) 'Removing...'
$(RM) ${OBJPATH}/*.o ${OBJPATH}/*.err ${OBJPATH}/*.map
$(RM) ${GENPATH}/*.o ${GENPATH}/*.out ${GENPATH}/*.exe ${GENPATH}/*.tmp
$(RM) ${SRCDIR}/*.a ${OBJPATH}/*.a ${LIBPATH}/*.a ${GENPATH}/*.a
$(RM) ${SRCDIR}/*.so ${OBJPATH}/*.so ${LIBPATH}/*.so ${GENPATH}/*.so
$(RM) ${SRCDIR}/*.out.stackdump ${SRCDIR}/*.exe.stackdump
$(RM) ${GENPATH}/*.out.stackdump ${GENPATH}/*.exe.stackdump
$(RM) ${OBJPATH} ${LIBPATH} ${GENPATH}
$(RM) ./*.o ./*.out ./*.exe ./*.a ./*.so ./*.err ./*.map
$(RM) ./*.out.stackdump ./*.exe.stackdump
$(ECHO) 'Files removed'
You probably need to add -lmodbus to your LDADDLIBS variable:
LDADDLIBS += -lmodbus -lpthread -lrt -lm -lstdc++

Generic mexopts file for GCC/Clang OSX/Linux [R2014b]

It is a recurrent pain in the ice to set up this blurry mexopts.sh... I would just like a generic configuration that works with all combinations of:
Ubuntu 14+ and OSX 10.10+;
gcc 4.8+ and clang 3.5+
I don't want any dependence to Xcode for the OSX part, I don't mind editing that file manually to change version numbers occasionally, and I don't care about warnings regarding the GCC version.
Here is my chaotic mess so far, hopefully with a little help we can finally get something decent:
#
# mexopts.sh Shell script for configuring MEX-file creation script,
# mex. These options were tested with the specified compiler.
#
# usage: Do not call this file directly; it is sourced by the
# mex shell script. Modify only if you don't like the
# defaults after running mex. No spaces are allowed
# around the '=' in the variable assignment.
#
# Note: For the version of system compiler supported with this release,
# refer to the Supported and Compatible Compiler List at:
# http://www.mathworks.com/support/compilers/current_release/
#
#
# SELECTION_TAGs occur in template option files and are used by MATLAB
# tools, such as mex and mbuild, to determine the purpose of the contents
# of an option file. These tags are only interpreted when preceded by '#'
# and followed by ':'.
#
#SELECTION_TAG_MEX_OPT: Template Options file for building MEX-files
#
# Copyright 1984-2011 The MathWorks, Inc.
# $Revision: 1.78.4.18 $ $Date: 2012/11/15 06:22:54 $
#----------------------------------------------------------------------------
#
TMW_ROOT="$MATLAB"
MFLAGS=''
if [ "$ENTRYPOINT" = "mexLibrary" ]; then
MLIBS="-L$TMW_ROOT/bin/$Arch -lmx -lmex -lmat -lmwservices -lut"
else
MLIBS="-L$TMW_ROOT/bin/$Arch -lmx -lmex -lmat"
fi
case "$Arch" in
Undetermined)
#----------------------------------------------------------------------------
# Change this line if you need to specify the location of the MATLAB
# root directory. The script needs to know where to find utility
# routines so that it can determine the architecture; therefore, this
# assignment needs to be done while the architecture is still
# undetermined.
#----------------------------------------------------------------------------
MATLAB="$MATLAB"
;;
glnx86)
#----------------------------------------------------------------------------
echo "Error: Did not imbed 'options.sh' code"; exit 1 #imbed options.sh glnx86 12
#----------------------------------------------------------------------------
;;
glnxa64_gcc|glnxa64)
#----------------------------------------------------------------------------
RPATH="-Wl,-rpath-link,$TMW_ROOT/bin/$Arch"
#
CC='gcc'
CFLAGS='-ansi -D_GNU_SOURCE'
CFLAGS="$CFLAGS -fexceptions"
CFLAGS="$CFLAGS -fPIC -fno-omit-frame-pointer -pthread"
CLIBS="$RPATH $MLIBS -lm"
COPTIMFLAGS='-O2 -DNDEBUG'
CDEBUGFLAGS='-g'
#
CXX='g++'
CXXFLAGS='-ansi -D_GNU_SOURCE -std=c++0x'
CXXFLAGS="$CXXFLAGS -fPIC -fno-omit-frame-pointer -pthread"
CXXLIBS="$RPATH $MLIBS -lm"
CXXOPTIMFLAGS='-O2 -DNDEBUG'
CXXDEBUGFLAGS='-g'
#
FC='gfortran'
FFLAGS='-fexceptions -fbackslash'
FFLAGS="$FFLAGS -fPIC -fno-omit-frame-pointer"
FLIBS="$RPATH $MLIBS -lm"
FOPTIMFLAGS='-O'
FDEBUGFLAGS='-g'
#
LD="$COMPILER"
LDEXTENSION='.mexa64'
LDFLAGS="-pthread -shared -Wl,--version-script,$TMW_ROOT/extern/lib/$Arch/$MAPFILE -Wl,--no-undefined"
LDOPTIMFLAGS='-O'
LDDEBUGFLAGS='-g'
#
POSTLINK_CMDS=':'
#----------------------------------------------------------------------------
;;
glnxa64_clang)
#----------------------------------------------------------------------------
RPATH="-Wl,-rpath-link,$TMW_ROOT/bin/$Arch"
#
CC='clang'
CFLAGS="-fno-common -fexceptions -fPIC -fno-omit-frame-pointer -pthread"
CLIBS="$MLIBS -lstdc++"
COPTIMFLAGS='-O2 -DNDEBUG'
CDEBUGFLAGS='-g'
#
CXX='clang++'
CXXFLAGS="-fno-common -fexceptions -fPIC -fno-omit-frame-pointer -pthread"
CXXLIBS="$RPATH $MLIBS -lstdc++"
CXXOPTIMFLAGS='-O2 -DNDEBUG'
CXXDEBUGFLAGS='-g'
#
FC='gfortran'
FFLAGS='-fexceptions -fbackslash'
FFLAGS="$FFLAGS -fPIC -fno-omit-frame-pointer"
FLIBS="$RPATH $MLIBS -lm"
FOPTIMFLAGS='-O'
FDEBUGFLAGS='-g'
#
LD="$COMPILER"
LDEXTENSION='.mexa64'
LDFLAGS="-pthread -shared -Wl,--version-script,$TMW_ROOT/extern/lib/$Arch/$MAPFILE -Wl,--no-undefined"
LDOPTIMFLAGS='-O'
LDDEBUGFLAGS='-g'
POSTLINK_CMDS=':'
#----------------------------------------------------------------------------
;;
sol64|mac|maci)
#----------------------------------------------------------------------------
echo "Error: Did not imbed 'options.sh' code"; exit 1 #imbed options.sh sol64 12
#----------------------------------------------------------------------------
;;
maci64_clang|maci64)
#
SDKROOT=""
MACOSX_DEPLOYMENT_TARGET='10.10'
ARCHS='x86_64'
MAC_FLAGS="-arch $ARCHS -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET"
#
CC='clang'
CFLAGS="-fno-common $MAC_FLAGS"
CFLAGS="$CFLAGS -fexceptions"
CLIBS="$MLIBS -lstdc++"
COPTIMFLAGS='-O2 -DNDEBUG'
CDEBUGFLAGS='-g'
#
CXX='clang++'
CXXFLAGS="-fno-common -fexceptions $MAC_FLAGS"
CXXLIBS="$MLIBS -lstdc++"
CXXOPTIMFLAGS='-O2 -DNDEBUG'
CXXDEBUGFLAGS='-g'
#
FC='gfortran'
FFLAGS='-fexceptions -m64 -fbackslash'
FC_LIBDIR=`$FC -print-file-name=libgfortran.dylib 2>&1 | sed -n '1s/\/*libgfortran\.dylib//p'`
FC_LIBDIR2=`$FC -print-file-name=libgfortranbegin.a 2>&1 | sed -n '1s/\/*libgfortranbegin\.a//p'`
FLIBS="$MLIBS -L$FC_LIBDIR -lgfortran -L$FC_LIBDIR2 -lgfortranbegin"
FOPTIMFLAGS='-O'
FDEBUGFLAGS='-g'
#
LD="$CC"
LDEXTENSION='.mexmaci64'
LDFLAGS="-arch $ARCHS -Wl -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET"
LDFLAGS="$LDFLAGS -bundle -Wl,-exported_symbols_list,$TMW_ROOT/extern/lib/$Arch/$MAPFILE"
LDOPTIMFLAGS='-O'
LDDEBUGFLAGS='-g'
#
POSTLINK_CMDS=':'
#----------------------------------------------------------------------------
;;
maci64_gcc) # doesn't work
#
SDKROOT=""
MACOSX_DEPLOYMENT_TARGET='10.10'
ARCHS='x86_64'
MAC_FLAGS="-arch $ARCHS -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET"
RPATH="-Wl,$TMW_ROOT/bin/$Arch"
#
CC='gcc'
CFLAGS='-ansi -D_GNU_SOURCE'
CFLAGS="$CFLAGS -fexceptions $MAC_FLAGS"
CFLAGS="$CFLAGS -fPIC -fno-omit-frame-pointer -pthread"
CLIBS="$RPATH $MLIBS -lm"
COPTIMFLAGS='-O2 -DNDEBUG'
CDEBUGFLAGS='-g'
#
CXX='g++'
CXXFLAGS="-ansi -D_GNU_SOURCE $MAC_FLAGS"
CXXFLAGS="$CXXFLAGS -fPIC -fno-omit-frame-pointer -pthread"
CXXLIBS="$RPATH $MLIBS -lm"
CXXOPTIMFLAGS='-O2 -DNDEBUG'
CXXDEBUGFLAGS='-g'
#
FC='gfortran'
FFLAGS='-fexceptions -fbackslash'
FFLAGS="$FFLAGS -fPIC -fno-omit-frame-pointer"
FLIBS="$RPATH $MLIBS -lm"
FOPTIMFLAGS='-O'
FDEBUGFLAGS='-g'
#
LD="$CC"
LDEXTENSION='.mexmaci64'
LDFLAGS="$MAC_FLAGS -bundle -Wl,$TMW_ROOT/extern/lib/$Arch/$MAPFILE"
LDOPTIMFLAGS='-O'
LDDEBUGFLAGS='-g'
#
POSTLINK_CMDS=':'
#----------------------------------------------------------------------------
;;
esac
#############################################################################
#
# Architecture independent lines:
#
# Set and uncomment any lines which will apply to all architectures.
#
#----------------------------------------------------------------------------
# CC="$CC"
# CFLAGS="$CFLAGS"
# COPTIMFLAGS="$COPTIMFLAGS"
# CDEBUGFLAGS="$CDEBUGFLAGS"
# CLIBS="$CLIBS"
#
# FC="$FC"
# FFLAGS="$FFLAGS"
# FOPTIMFLAGS="$FOPTIMFLAGS"
# FDEBUGFLAGS="$FDEBUGFLAGS"
# FLIBS="$FLIBS"
#
# LD="$LD"
# LDFLAGS="$LDFLAGS"
# LDOPTIMFLAGS="$LDOPTIMFLAGS"
# LDDEBUGFLAGS="$LDDEBUGFLAGS"
#----------------------------------------------------------------------------
#############################################################################
You can see that I'm trying to get a different section for each combination arch_compiler. I can then manually select the compiler I want simply by ORing the case choice with the target architecture.