[haiku-development] How to compile Haiku application resources (rdef) in Jam.

Being a novice at Jam this took me quite some time to figure out, I am
sending it to haiku-development so other learning Haiku programmers can
figure out how application resource files work under Haiku and how to
automate the process the correct(?) way in Jam.

In this example I have a simple application with two C sources, in addition
to these source files I have a file called synku.rdef which contains my
application resources (app name, icon data, etc) (more on rdef's here:
http://www.haiku-os.org/documents/dev/compile_them_resources)

====================
Jamfile
====================
SubDir TOP ;
Main synku : main.c synnetwork.c ;
if $(OS) = HAIKU {
LINKLIBS on synku = -lnetwork ;
Object synku.rsrc : synku.rdef ;
Object synku : synku.rsrc ;
}


====================
Jamrules
====================
rule UserObject
{
switch $(>)
{
case *.rdef     : ResourceCompiler $(<) : $(>) ;
case *.rsrc     : ResourceLinker $(<) : $(>) ;
case *          : ECHO "unknown file type: " $(<) ;
}
}

rule ResourceCompiler
{
DEPENDS $(<) : $(>) ;
Clean clean : $(<) ;
}

actions ResourceCompiler
{
# convert rdef to rsrc
rc -o $(<) $(>) ;
}

rule ResourceLinker
{
DEPENDS $(<) : $(>) ;
Clean clean : $(<) ;
}

actions ResourceLinker
{
# push rsrc into final binary
xres -o $(<) $(>) ;
}

-- 
Thanks!
Alexander von Gluck

Other related posts: