L4Re build system

Adam Lackorzynski adam at os.inf.tu-dresden.de
Mon Jan 9 00:17:27 CET 2012


Hi,

On Thu Jan 05, 2012 at 23:58:42 +0400, Ivan Loskutov wrote:
> 1. How to build library from *.cpp files? The library building if I rename
> *.cpp files to *.cc but it not easy. I tried to modify mk-files, see
> attached patch. *.cpp files compiled but don't linked correctly, *.cpp
> files added to linker command.

This should work:

--- mk/binary.inc
+++ mk/binary.inc
@@ -473,16 +473,23 @@
 vpath %-server.cc $(IDL_PATH)
 endif
 
+# convert list of c++ files names to .o files
+# arg: 1 - list of files
+#      2 - infix between the basename and the .o
+convert_cc_to_o_file = $(patsubst %.cc,%$(2).o, $(filter %.cc,$(1)))     \
+                       $(if $(BID_ALLOW_CPP_AS_CPLUSPLUS_FILE),          \
+		         $(patsubst %.cpp,%$(2).o,$(filter %.cpp,$(1))))
+
 # generic targetobjs
 # arg: 1 - target
 #      2 - infix between the basename and the .o
 #      3 - additional infix before .o in case of .cc files
 targetobjs_gen = $(SRC_C:.c=$(2).o) $(SRC_S:.S=$(2).o)                  \
-                 $(SRC_CC:.cc=$(2)$(3).o)                               \
+                 $(call convert_cc_to_o_file,$(SRC_CC),$(2)$(3))        \
                  $(foreach inter, $(OSYSTEM) $(1) $(1)_$(OSYSTEM),	\
                      $(SRC_C_$(inter):.c=$(2).o)			\
                      $(SRC_S_$(inter):.S=$(2).o)			\
-                     $(SRC_CC_$(inter):.cc=$(2)$(3).o))	                \
+                     $(call convert_cc_to_o_file,$(SRC_CC_$(inter)),$(2)$(3))) \
                  $(patsubst %.c,%$(2).o,$(call IDL_SRC_Cfn,$(1)))
 
 # a helper function to generate the object-files for a given target
@@ -697,6 +704,9 @@
 %:	%.cc
 	
 
+%:	%.cpp
+	
+
 %:	%.S
 	
 
> 2. How to correct add prebuild and postbuild rules to Makefile for prog and
> library roles?

For post processing something with INSTALL_TARGET and own target rule
with dependencies could be done. Pre processing with a dependency for
a target. What's your use-case?


Adam
-- 
Adam                 adam at os.inf.tu-dresden.de
  Lackorzynski         http://os.inf.tu-dresden.de/~adam/




More information about the l4-hackers mailing list