[llvm-commits] Multiple directories in a single library

Matthijs Kooijman matthijs at stdin.nl
Mon Nov 24 06:32:14 PST 2008


Hi all,

I've slightly updated the patch. Now, instead of depending on a .dir file that
is possibly in a subdir, it again depends just on $(ObjDir)/.dir. It also
executes an explicit mkdir before compiling a file.

The previous approach turned out to recompile stuff too often: Make threw away
.dir files that we would have liked to keep. This was probably because the
.PRECIOUS rules didn't apply because of the funky .. in the path, but those
rules wouldn't have applied to .dir files in subdirs anyway...

The patch is inlined below.

Gr.

Matthijs

Index: Makefile.rules
===================================================================
--- Makefile.rules	(revision 59957)
+++ Makefile.rules	(working copy)
@@ -541,6 +541,10 @@
   Sources := $(SOURCES)
 endif 
 
+ifdef EXTRA_SOURCES
+  Sources += $(patsubst $(PROJ_SRC_DIR)/%, %, $(EXTRA_SOURCES))
+endif
+
 ifdef BUILT_SOURCES
 Sources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
 endif
@@ -1123,16 +1127,19 @@
                   else $(RM) "$(ObjDir)/$*.d.tmp"; exit 1; fi
 
 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
+	$(Verb) $(MKDIR) $(dir $@) > /dev/null
 	$(Echo) "Compiling $*.cpp for $(BuildMode) build " $(PIC_FLAG)
 	$(Verb) if $(MAYBE_PIC_Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
 	        $(DEPEND_MOVEFILE)
 
 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
+	$(Verb) $(MKDIR) $(dir $@) > /dev/null
 	$(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
 	$(Verb) if $(MAYBE_PIC_Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
 	        $(DEPEND_MOVEFILE)
 
 $(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
+	$(Verb) $(MKDIR) $(dir $@) > /dev/null
 	$(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
 	$(Verb) if $(MAYBE_PIC_Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
 	        $(DEPEND_MOVEFILE)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20081124/4a6d729b/attachment.sig>


More information about the llvm-commits mailing list