Re:How to adding pathes to dependencies in rules of `.d` files

"ljh" <[email protected]>
Newsgroups gmane.comp.gnu.make.general
Message-ID <[email protected]>
My Makefile used to build source files in the subdir is like this:

```
# build shared library with -fPIC, -shared
CFLAGS   = -fPIC # -g -O3 -fPIC # CXXFLAGS for .cpp
LDFLAGS  = -shared # -L../bar -Wl,-rpath,/foo/bar # -shared
LDLIBS   = # -lbar
CPPFLAGS = -MMD -MP # -I../bar
DIR      = $(BUILD_DIR)/foo

#LDFLAGS += -Wl,-rpath,'$$ORIGIN/../foo'

$(DIR)/foo : $(addprefix $(DIR)/,$(patsubst %.c,%.o,$(wildcard *.c)))  # .cpp
#	$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@  # CXX for .cpp

$(DIR)/%.o : %.c  # .cpp
	@mkdir -p $(dir $@)
	$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $&lt; # .cpp


-include $(shell find . -type f -name "*.d")
clean : ; -rm -fr $(DIR)
.PHONY : clean
```

The `.c`, `.h` files in the `.d` files are left without paths. 

```
$ cat build/foo/foo.d 
/home/ljh/Documents/make_outofsrc/src/build/foo/foo.o: foo.c foo.h
foo.h:
$
```
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.