[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Avoid relinking when .so file changes
From: |
Henrik Carlqvist |
Subject: |
Re: Avoid relinking when .so file changes |
Date: |
Sat, 01 Jul 2006 20:48:47 +0200 |
User-agent: |
Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity.) |
variablecloudiness@gmail.com wrote:
> I have a Makefile (GNU Make 3.80). Let's say I have a target
> for a binary called 'myBinary'. myBinary depends on a few .so
> files. When I type 'make myBinary', and the files that generate
> those .so files change, I want the .so files regenerated.
>
> I don't, however, want 'myBinary' relinked, since the interface to
> the .so file hasn't changed--relinking is unnecessary.
But you want the .so file created if it doesn't already exist I suppose?
> So far, my Makefile looks like this:
>
> myBinary: myBinary.o myLibrary.so
> g++ --go-go-gadget-linker
One way to fix this would be:
myBinary: myBinary.o $(filter-out $(wildcard myLibrary.so), myLibrary.so)
g++ --go-go-gadget-linker
With the above rule myBinary depends on myLibrary.so if it doesn't
already exist. But if the file already exist it doesn't care if it is
newer than myBinary. I usually use this method for dependencies on
directories, something like this:
$(O_DIR)/%.o: $(C_DIR)/%.c $(filter-out $(wildcard $(O_DIR)), $(O_DIR))
$(O_DIR):
mkdir -f $@
Above I want a directory created before I can put files in that directory.
However, once the directory is created I don't want to rebuild files in
it only because it has gotten a new time stamp. Every time a file is
created or deleted in a directory the time stamp of the directory gets
updated.
> How do I change this Makefile to keep the relinking from happening?
> Dropping the .so dependency creates pain, because then 'make -j' doesn't
> work right.
What is the problem with make -j? To me it seems as if dropping the
dependency only would cause the .so file not to be created, regardless of
if the -j flag is used.
regards Henrik
--
The address in the header is only to prevent spam. My real address is:
hc8(at)uthyres.com Examples of addresses which go to spammers:
root@variousus.net root@localhost