Openembedded Yocto Native Hello World: Take 2

A while back I wrote about some problems I was having with native OpenEmbedded recipes that were building packages with raw Makefiles (no autotools). I wrote up the problem and the work around I was using here. I got some feedback pointing out what I was doing wrong but I guess my brain just didn’t process it. I was using uppercase variables while the GNU Make docs specifically call for lowercase! These variables get magically passed to Make likely through the environment and then everything just works.

So here’s my retraction: I was wrong :) The ‘hello world’ Makefile should look like this:

.PHONY : clean uninstall
 
prefix ?= /usr
exec_prefix ?= $(prefix)
bindir ?= $(exec_prefix)/bin
 
HELLO_src = hello.c
HELLO_bin = hello
HELLO_tgt = $(DESTDIR)$(bindir)/$(HELLO_bin)
 
all : $(HELLO_bin)
 
$(HELLO_bin) : $(HELLO_src)
 
$(HELLO_tgt) : $(HELLO_bin)
	install -d $(DESTDIR)$(bindir)
	install -m 0755 $^ $@
 
clean :
	rm $(HELLO_bin)
 
install : $(HELLO_tgt)
 
uninstall :
	rm $(HELLO_TGT)

You can download the recipe here: hello_1.1.bb.

Trackbacks & Pingbacks 1

  1. From technomasochism - openembedded yocto native hello world on 19 Aug 2012 at 14:29

    [...] I took the time to get to the bottom of the issue discussed in this post. There’s a new post here that explains the “right way” to use Makefiles with yocto. As always, the error in this [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *