Re:Makefile with out of source build Re: How to adding pathes to dependencies in rules of `.d` files

2023-03-06 Thread ljh
Update. I did not use addprefix in the link rule. # Makefile for top dir # $(call makever,1.2.3) # major.minor.patch # libtool manual: -version-number define makever @ $(MAKE) -C $@ soname=lib$@.so.$(word 1,$(subst ., ,$(1))) @ cp $(OBJDIR)/$@/$@ $(OBJDIR)/$@/lib$@.so.$(1)

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

2023-03-05 Thread Paul Smith
On Sun, 2023-03-05 at 04:13 +0800, ljh wrote: > 1. In thie out of source version, I can not omit recipes in both > building and linking rules. This make it a bit complicated. I'm not sure I understand the problem. If the question is, is there a way to use the normal built-in implicit rules for ma

Makefile with out of source build Re: How to adding pathes to dependencies in rules of `.d` files

2023-03-04 Thread ljh
Updated. Suggestions are most welcome. Thanks --- # Makefile for top dir # $(call makever,1.2.3) # major.minor.patch define makever $(MAKE) -C $@ soname=lib$@.so.$(word 1,$(subst ., ,$(1))) @ cp $(OBJDIR)/$@/$@ $(OBJDIR)/$@/lib$@.so.$(1) @ cd $(OBJDIR)/$@; ln -f -s $(OBJDIR)/$@/lib$@.s

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

2023-03-04 Thread ljh
Updated. Accept a path parameter on command line from the user. # Makefile for top dir # $(call version_number,1.2.3) # major.minor.patch # libtool manual 4.2: -version-number define version_number $(MAKE) -C $@ soname=lib$@.so.$(word 1,$(subst ., ,$(1))) @ cp $(OBJDIR)/$@/$@ $(OB

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

2023-03-04 Thread ljh
Can you please give me suggestions to improve it. 1. In thie out of source version, I can not omit recipes in both building and linking rules. This make it a bit complicated. 2. if I put # comment at the end of the line of export OBJDIR, it causes mysterious error message in rules involve the v

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

2023-03-04 Thread ljh
Hi Paul, I finally work it out. Thank you very much for the great help. $ tree --charset C . |-- foo | |-- foo.c | |-- foo.h | `-- Makefile |-- main | |-- main.c | `-- Makefile |-- Makefile `-- objdir_tmp |-- foo | |-- foo | |-- foo.d | |-- foo.o | |-- li

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

2023-03-04 Thread Paul Smith
On Sat, 2023-03-04 at 21:49 +0800, ljh wrote: > I managed to do out-of-source build. > > I use `CPPFLAGS += -MMD -MP` to generate `.d` files. > The `.d` files and the source files are not in the same directory > now. `make` addes path the the target `.o` part, > but not the prerequisites parts

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

2023-03-04 Thread ljh
Hi community, I managed to do out-of-source build. I use `CPPFLAGS += -MMD -MP` to generate `.d` files. The `.d` files and the source files are not in the same directory now. `make` addes path the the target `.o` part, but not the prerequisites parts `.c`, `.h`. So, the rules in `.d` files wil