Hello all!
I have a newbie question regarding creating a recipe for C code, where
the project already has a custom Makefile -which of course must be
used for the build.
>From what I recall, the recipe doesn't have to do anything special;
bitbake will pick up the Makefile and do the 'make'...
However, when experimenting with a v simple 'hello, world' C program
and Makefile, I find that am unable to get a 'debug build'
helloworld_dbg binary executable - it simply seems to use the default
$(CFLAGS) value and I can't seem to influence it, via the recipe or
the Makefile??
I've tried the CFLAGS:append approach as well as the TARGET_CFLAGS
setting but they don't seem to help.
Here's my (essential) recipe:
...
SRC_URI = "\
file://helloworld.c \
file://Makefile \
"
FILES:${PN} += "helloworld helloworld_dbg"
S = "${WORKDIR}"
# GCC: later option takes precedence
CFLAGS:append = " -g -ggdb -O0 -Wpedantic"
do_configure:prepend() {
bbplain ">>> WORKDIR = S = ${WORKDIR}"
bbplain ">>> build dir B = ${B}"
bbplain ">>> dest dir D = ${D}"
bbplain ">>> CFLAGS = ${CFLAGS}"
bbplain ">>> TARGET_CFLAGS = ${TARGET_CFLAGS}"
bbplain ">>> TMPDIR = ${TMPDIR} "
}
PARALLEL_MAKE = ""
do_install() {
install -d ${D}${bindir}
install -m 0755 ${S}/helloworld ${D}${bindir}
install -m 0755 ${S}/helloworld_dbg ${D}${bindir}
}
And my Makefile:
ALL := helloworld helloworld_dbg
all: ${ALL}
helloworld: helloworld.c
$(CC) $(CFLAGS) $(LDFLAGS) helloworld.c -o helloworld -Wall -O2
ls -l ./helloworld ; file ./helloworld
# strip --strip-all ./helloworld
helloworld_dbg: helloworld.c
$(CC) $(CFLAGS_DBG) $(LDFLAGS) helloworld.c -o helloworld_dbg -Wall
clean:
rm -f $(ALL)
The helloworld.c is the usual...
$ ls -l .../tmp-glibc/work/cortexa72-kaiwanTECH-linux/hellomake/1.0/helloworld*
-rwxr-xr-x 1 kaiwan kaiwan 77680 Jun 12 15:45
.../tmp-glibc/work/cortexa72-kaiwanTECH-linux/hellomake/1.0/helloworld*
-rw-rw-r-- 1 kaiwan kaiwan 83 May 30 11:08
.../tmp-glibc/work/cortexa72-kaiwanTECH-linux/hellomake/1.0/helloworld.c
-rwxr-xr-x 1 kaiwan kaiwan 77000 Jun 12 15:45
.../tmp-glibc/work/cortexa72-kaiwanTECH-linux/hellomake/1.0/helloworld_dbg2*
You can see that both binaries are essentially the same...
(I realize that an answer to a very similar query was posted here [1];
am just looking to see if there's any update).
[1]
https://stackoverflow.com/questions/34934869/why-does-bitbake-ignore-cflags-in-my-makefile
Thanks and regards,
Kaiwan.
--
Kaiwan N Billimoria
Founder, kaiwanTECH
kaiwantech.com | https://amazon.com/author/kaiwanbillimoria
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#63325): https://lists.yoctoproject.org/g/yocto/message/63325
Mute This Topic: https://lists.yoctoproject.org/mt/106629727/21656
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-