[haiku-development] Re: Resource files (and other questions)

Hi Axel,

Axel Dörfler wrote:
Never needed to play with rdefs, but I'll give them a try.
Should the makefile-engine maybe include support for them, too?

Yes, that would be neat.
I have the patch for this. It is flexible enough to handle both .rdef and rsrc files simultaneously in the same makefile. Resource definitions must be defined in RDEFS variable. At the moment there are no dependencies handling for .rdef files. Are we need it?

MfG,
 S.Zharski.
diff -Naur /Krolik(gcc-4)/develop/etc/makefile /boot/develop/etc/makefile
--- /Krolik(gcc-4)/develop/etc/makefile 2009-05-14 07:20:32.000000000 +0000
+++ /boot/develop/etc/makefile  2009-05-14 22:37:07.000000000 +0000
@@ -32,8 +32,13 @@
 #      in folder names do not work well with this makefile.
 SRCS= 
 
-#      specify the resource files to use
+#      specify the resource definition files to use
 #      full path or a relative path to the resource file can be used.
+RDEFS= 
+       
+#      specify the resource files to use. 
+#      full path or a relative path to the resource file can be used.
+#      both RDEFS and RSRCS can be defined in the same makefile.
 RSRCS= 
 
 # @<-src@ 
diff -Naur /Krolik(gcc-4)/develop/etc/makefile-engine 
/boot/develop/etc/makefile-engine
--- /Krolik(gcc-4)/develop/etc/makefile-engine  2009-05-14 07:20:32.000000000 
+0000
+++ /boot/develop/etc/makefile-engine   2009-05-14 22:25:25.000000000 +0000
@@ -40,6 +40,8 @@
 #      specify the tools for adding and removing resources
        XRES            = xres
 
+#      specify the tools for compiling resource definition files
+       RESCOMP         = rc
 
 #      platform specific settings
 
@@ -267,6 +269,23 @@
        BUILD_LINE = $(LD) -o $@ $(OBJS) $(LDFLAGS)
 endif
 
+# pseudo-function for converting a list of resource definition files in RDEFS 
+# variable to a corresponding list of object files in $(OBJ_DIR)/xxx.rsrc
+# The "function" strips off the rdef file suffix (.rdef) and then strips 
+# of the directory name, leaving just the root file name.
+# It then appends the .rsrc suffix and prepends the $(OBJ_DIR)/ path
+define RDEFS_LIST_TO_RSRCS
+       $(addprefix $(OBJ_DIR)/, $(addsuffix .rsrc, $(foreach file, $(RDEFS), \
+       $(basename $(notdir $(file))))))
+endef
+
+#      create the resource definitions instruction in case RDEFS is not empty
+       ifeq ($(RDEFS), )
+               RSRCS +=
+       else
+               RSRCS += $(RDEFS_LIST_TO_RSRCS)
+       endif
+
 #      create the resource instruction
        ifeq ($(RSRCS), )
                DO_RSRCS :=
@@ -329,6 +348,12 @@
 $(OBJ_DIR)/%.o : %.CPP
        $(CC) -c $< $(INCLUDES) $(CFLAGS) -o $@
 
+# rules to compile resource definition files
+$(OBJ_DIR)/%.rsrc : %.rdef
+       $(RESCOMP) -o $@ $<
+$(OBJ_DIR)/%.rsrc : %.RDEF
+       $(RESCOMP) -o $@ $<
+
 #      rules to handle lex/flex and yacc/bison files
 
 $(OBJ_DIR)/%.o: %.l

Other related posts: