Open NicoHood opened 8 years ago
This is my patch (not sure if its good like this, but "it works")
# Check if an output object file directory was specified instead of the input file location
ifneq ($(OBJDIR),.)
# Prefix all the object filenames with the output object file directory path
OBJECT_FILES := $(addprefix $(patsubst %/,%,$(OBJDIR))/, $(OBJECT_FILES))
OBJECT_PATH := $(dir $(OBJECT_FILES))
$(shell mkdir -p $(OBJECT_PATH))
# Create the output object file directory if it does not exist and add it to the virtual path list
$(shell mkdir $(OBJDIR) 2> /dev/null)
VPATH += $(dir $(SRC))
endif
Sorry, I really haven't been looking at Github for ages - too much paid work that leaves me too unmotivated to look at my personal projects :(.
Just took a look at this. The issue with multiple object files with identical names is a very hard one to solve, specifically because of relative paths. Give SRC
of:
SRC = Test.c ../Library/Test.c
The resulting objects will be:
Test.o ../Library/Test.o
Which is fine to build in place. Unfortunately however, you can't easily rebase that path against a new object path in GNU make as far as I am aware, so simply adding a common OBJDIR
prefix $(addprefix $(patsubst %/,%,$(OBJDIR))/, $(OBJECT_FILES))
results in:
obj/Test.o obj/../Library/Test.o
I.e. objects are generated outside the desired root OBJDIR folder. That's why I enforce the unique name constraint on the input source files if you want to put all the objects into a flat OBJDIR
directly - stripping off the full base path of the input source files sidesteps the relative pathing issue.
You could possibly check for duplicate names and then name them with Test_1 Test_2? Or you could add a hash before each file which would be unique enough. A small CRC would not give too much trash output and serve the needs.
And what if we just replace ".." by "rel" and create this path?
I try to compile those files:
But I get this error:
If you look closer at the sources you will notice that
sha512.c
(and others) are available in two folders (but still different code inside). I think the folder structure is not kept in the output path and therefor this causes problems.Using latest dmbs release-20160403 or newer (from git).