# bitbake/open embedded (oe/bb) building HOWTO

oe/bb: open embedded/bitbake
recipe: bitbake build recipe (.bb)

# debugging tips

- logs for each stage of  a package/image build (fetch, configure, compile, build, install)
are in build/tmp-<yada>/work/<target>/<package-version>/temp

- use the logs to see output from configure, make, etc. when things aren't working

###############
# license files
###############
- A license file is required in the recipe for packages, and an md5sum.
- The license file is usally called COPYING and is in the package root directory
- Typically, the file is part of the build, specified in the recipe as a FILE://<path>
where <path> is relative to the top of the package root. 
- oe/bb will provide the md5 sum in an error message if the sum is missing/incorrect (easy way), or you can compute it yourself if you have the package source (md5sum <path to license file>)

###############
# md5sum, sha256sum
###############
- oe/bb requires md5 and sha256 sums for downloaded packages
- if they are wrong in your recipe, the 
- oe/bb will provide the md5/sha256 sum in an error message if the sum is missing/incorrect

###############
# had trouble building socat package: redifined symbols, undefined symbols etc.
###############

- try building the package on the host using autotools (configure/make/make install) works)
- compared oe/bb configure logs 
- noted that CFLAGS were much simpler
- problem was that oe/bb runs autoreconf, and messes up dependencies.
- overrode bb/oe configure

do_configure(){
        ./configure  --build=i386-linux-gnu --host=gnu-linux-eabi --prefix=$(prefix)
}

- used default make and install

# some annotated recipes
###############
# socat
###############
SECTION = "console/network"
PROVIDES += "socat"
DEPENDS += "openssl readline"
DESCRIPTION = "Socat is a command line based utility that establishes two bidirectional byte streams and transfers data between them"
LICENSE = "GPL"
PR = "r0"
HOMEPAGE = "http://www.dest-unreach.org/socat/"

LIC_FILES_CHKSUM = "file://COPYING;md5=18810669f13b87348459e611d31ab760"

SRC_URI = "http://www.dest-unreach.org/socat/download/socat-${PV}.tar.gz"
SRC_URI[md5sum] = "0565dd58800e4c50534c61bbb453b771"
SRC_URI[sha256sum] = "e5214ad56b43fef00761e391417b5020d07f973113b398b6ddcc47bde771ffae"

inherit autotools 

do_configure(){
	./configure  --build=i386-linux-gnu --host=gnu-linux-eabi --prefix=$(prefix)
}

do_install_prepend(){
	mkdir -p ${D}${bindir}
	install -d ${D}${bindir} ${D}${mandir}/man1
}

#do_compile () {
#   make
#}

#do_install () {
#   DESTDIR=${D} oe_runmake install
# }

###############
# lcm
###############
DESCRIPTION = "Lightweight Communications and Marshalling"
HOMEPAGE = "https://code.google.com/p/lcm/"
LICENSE = "LGPLv3"

LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/LGPL-3.0;md5=bfccfe952269fff2b407dd11f2f3083b"

inherit autotools gettext pkgconfig
PR = "r0"

SRC_URI = "https://lcm.googlecode.com/files/lcm-${PV}.tar.gz"
SRC_URI[md5sum] = "3146793b15b5196eb48a10bc5f185bf5"
SRC_URI[sha256sum] = "23e3773b36bb73ff7ccc9b4076effe7530c96c00b8ecb171bfc2839b59517b0e"

S = "${WORKDIR}/lcm-${PV}"

#FILES_${PN}-dev += "lcm/usr/lib/*.so"
#FILES_${PN} += "/usr/bin/lcm-gen \
#/usr/bin/lcm-logplayer \
#/usr/bin/lcm-logger \
#/usr/include/* \
#/usr/lib/* \
#/usr/share/*"

###############
# libmodbus_3.0.3.bb (1/3)
###############
SUMMARY = "A Modbus library"
DESCRIPTION = "libmodbus is a C library designed to provide a fast and robust \
implementation of the Modbus protocol. It runs on Linux, Mac OS X, FreeBSD, \
QNX and Windows."
HOMEPAGE = "http://www.libmodbus.org/"
SECTION = "libs"

LICENSE = "LGPLv2.1+"
LIC_FILES_CHKSUM = "file://COPYING.LESSER;md5=4fbd65380cdd255951079008b364516c"

SRC_URI = "http://github.com/downloads/stephane/${BPN}/${BP}.tar.gz"

inherit autotools pkgconfig

SRC_URI[md5sum] = "b5042d833c6c132e6fb2551af133a342"
SRC_URI[sha256sum] = "6fc7cf91f7293e522afde6ae5fc605c6cd7bdca4ee2ec953db5bb91158ab8677"

###############
# libmodbus_git.bb (2/3)
###############
require libmodbus.inc

#SRCREV = "6254ede9156095ee0300"
SRCREV = "v3.0.3"

PV = "3.0.3+gitr${SRCPV}"

PR = "${INC_PR}.0"

DEFAULT_PREFERENCE = "-1"

SRC_URI = "git://github.com/stephane/libmodbus;branch=master;protocol=git"
S = "${WORKDIR}/git"

###############
# libmodbus.inc (3/3)
###############
DESCRIPTION = "A Modbus library for Linux, Mac OS X, FreeBSD, QNX and Win32"
HOMEPAGE = "http://www.libmodbus.org/"
SECTION = "libs"
PRIORITY = "optional"
LICENSE = "LGPLv2.1+"
INC_PR = "r0"

inherit autotools pkgconfig

###############
# zeromq_3.2.2.bb (1/3)
###############

SUMMARY = "ZeroMQ messaging library"
DESCRIPTION = "The 0MQ lightweight messaging kernel is \ 
a library which extends the standard socket interfaces \
with features traditionally provided by specialised \
messaging middleware products."
HOMEPAGE = "http://www.zeromq.org/"
SECTION = "libs/network"

LICENSE = "LGPLv3+"
LIC_FILES_CHKSUM = "file://COPYING.LESSER;md5=ad8c3bd15d88ea9d4509fc89bebc915c"

SRC_URI = "http://download.zeromq.org/${BP}.tar.gz"
#"https://github.com/zeromq/zeromq3-x.git"

inherit autotools pkgconfig

SRC_URI[md5sum] = ""
SRC_URI[sha256sum] = ""
#SRC_URI[md5sum] = "b5042d833c6c132e6fb2551af133a342"
#SRC_URI[sha256sum] = "6fc7cf91f7293e522afde6ae5fc605c6cd7bdca4ee2ec953db5bb91158ab8677"
require zeromq.inc

###############
# zeromq_git.bb (2/3)
###############

SRCREV = "v3.2.0"

PV = "3.2.0+gitr${SRCPV}"

PR = "${INC_PR}.0"

DEFAULT_PREFERENCE = "-1"

SRC_URI = "https://github.com/zeromq/zeromq3-x.git;branch=master;protocol=git"
S = "${WORKDIR}/git"

###############
# zeromq.inc (2/3)
###############
DESCRIPTION = "The 0MQ lightweight messaging kernel is \ 
a library which extends the standard socket interfaces \
with features traditionally provided by specialised \
messaging middleware products."
HOMEPAGE = "http://www.zeromq.org/"
SECTION = "libs/network"
LICENSE = "LGPLv3+"

SECTION = "libs/network"
PRIORITY = "optional"
INC_PR = "r0"

inherit autotools pkgconfig

###############
# xfoce_0.1.bb 
###############
DESCRIPTION = "xFOCE firmware package"
HOMEPAGE = "http://www.xfoce.org"
LICENSE = "GPLv3"
SECTION = "console/scientific"
PRIORITY = "optional"
PR = "r0"

SRC_URI = "file:///home/headley/oe/sources/xfoce-0.1.tar.gz"

inherit autotools 

LIC_FILES_CHKSUM = "file://COPYING;md5=2a4b374377ac2f3f7867a789acae7e55"
SRC_URI[md5sum] = "bf57c9fce27fc96edfb2fa93163a0696"
SRC_URI[sha256sum] = "6e6c0fd9d2eefbd5cbd58e71bf3311d2a53d3ffe65f690bb46c0bd8602ffa1c5"

XFOCE_LDFLAGS = "'-L${STAGING_LIBDIR}/i386-linux-gnu'"
XFOCE_LIBS = "'-lpthread -lrt -lzmq'"

EXTRA_OECONF += "LDFLAGS=${XFOCE_LDFLAGS} LIBS=${XFOCE_LIBS}"