I have botan.h available in ${STAGING_INCDIR}/botan-2. I like to use it in my yocto recipe along with my Makefile, my ideal is let "compilation" mentioned in Makefile rather than occupy the recipe entirely. Attched is my recipe and Makefile
recipe.bb
SUMMARY = "Makefile Demo"
SECTION = "apps"
LICENSE = "CLOSED"
DEPENDS = "botan"
APP_NAME = "integrated_app"
localdir = "/usr/local"
bindir = "${localdir}/bin"
TARGET_CC_ARCH += "${LDFLAGS}"
SRC_URI = "file://main.cpp \
file://Makefile \
"
S = "${WORKDIR}"
inherit pkgconfig
do_compile() {
# make -f Makefile
oe_runmake
}
do_install () {
install -m 0755 -d ${D}${localdir}
install -m 0755 -d ${D}${bindir}
cd ${S}
install -m 0755 ${APP_NAME} ${D}${bindir}
}
FILES_${PN}-dev = ""
FILES_${PN} = "${bindir}/*"
Makefile
obj = main.o
target = integrated_app
S = "${WORKDIR}"
INC=/home/kjlau/yocto/build/tmp/work/cortexa8hf-neon-poky-linux-gnueabi/botan-app/1.0-r0/recipe-sysroot/usr/include/botan-2
all: $(obj)
${CXX} ${CXXFLAGS} ${LDFLAGS} $(obj) -o $(target)
%.o:%.cpp
${CXX} ${CXXFLAGS} -I ${INC} -c $^ -o $@
.PHONY: clean
clean:
rm -rf $(obj) $(target)
Although it can successfully compile, but i wonder can we make use of ${STAGING_INCDIR}/botan-2 in Makefile? I tried , it not work though.I dont thing i implement the INC correctly, i mean it does not "common enough" such as i can't be assumed everyuser is kjlau right? Anyway to make it better?
Thanks
You're looking for TARGET_CXXFLAGS
. Add the following to your recipe:
TARGET_CXXFLAGS += "-I ${STAGING_INC_DIR}/botan2"
. No need for S=${WORKDIR}
and INCDIR
in your Makefile.
Ideally, you'd add an install target in the Makefile and then your recipe would be as simple as:
SUMMARY = "Makefile Demo"
SECTION = "apps"
LICENSE = "CLOSED"
DEPENDS = "botan"
TARGET_CXXFLAGS += "-I ${STAGING_INC_DIR}/botan2"
SRC_URI = "file://main.cpp \
file://Makefile \
"
S = "${WORKDIR}"
inherit pkgconfig
I'm not sure but I'd say that you also don't need to inherit pkgconfig.