On Tue, 15 May 2018 19:24:06 -0400, Paul Smith wrote: > My only suggestion other than what you've got (using pattern rules to ensure > that the build/ versions of the files have different names than the src/ > versions) is to force the right version by providing a pathname, so that it > won't match via vpath. For example, you could write your rule like this: > > src_dir = ../src > prog: prog.o parse.o > vpath %.y $(src_dir) > vpath %.c $(CURDIR) $(src_dir) > > # remove the default rule for %.c:%.y > %.c: %.y > > # Define a new rule that builds a local .c > $(CURDIR)/%.c : %.y > bison ... > > I'm not exactly sure that you need to add $(CURDIR) to vpath %.c but you > probably do. > > I didn't test this but it seems like it should work.
Thanks for this suggestion! For the record here a simplified version which works and suits the objective to properly build in 'build'. The point is to prefix the target of c files to be generated with './' (was $(CURDIR) in your suggestion). That make make ignore src/parse.c. Moreover, the vpath statements can be replaced by one single VPATH statement. VPATH = ../src prog: prog.o parse.o # remove the default rule for %.c:%.y %.c: %.y # Define a new rule that builds a local .c ./%.c : %.y bison -o $@ $< This makes script pretty simple now. Many thanks again for taking the time. Regards, J. _______________________________________________ Help-make mailing list Help-make@gnu.org https://lists.gnu.org/mailman/listinfo/help-make