[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
ignore specific file in VPATH/vpath
From: |
Jannick |
Subject: |
ignore specific file in VPATH/vpath |
Date: |
Wed, 9 May 2018 14:30:15 +0200 |
Hey,
I am having an issue with the make vpath/VPATH configuration where make
should ignore a specific existing file in vpath/VPATH. Here my case for
which any input from you is highly appreciated:
Cd'ed to the folder 'build', the objective is to build prog with the source
files prog.c and parse.y, both sitting in 'src':
+---build
| makefile
|
\---src
parse.c <<< disregard for a build in folder 'build'
parse.y
prog.c
The nasty thing is src/parse.c which unfortunately does exist, but should be
ignored for our project, since build/parse.c should be separately build
(from parse.y) and used instead.
Currently, I am not able - in an elegant way - to avoid that make uses
src/parse.c, unless make -B. The following makefile does the job, but it is
not very elegant to set up a vpath statement for each .c source file (this
is just a tiny example, in real life there might be many of those required).
$ cat makefile
src_dir = ../src
prog: prog.o parse.o
%.c: %.y
bison -o $@ $<
# vpath statement for each .c source file, not very elegant
vpath %.y $(src_dir)
vpath prog.c $(src_dir)
Alternatives:
1 - Using VPATH = $(src_dir) instead of the vpath block does not work, since
then make uses src/parse.c unless make -B.
2 - Another solution could be to copy the source files to build and take it
from there.
3 - My question: Is there any (easy) tweak to the makefile above (without
the given vpath block) to make that happen - or should be a copy to build
folder & compile method applied or something else I was not thinking of?
Separately, an additional note: make's YACC built-in recipe
%.c: %.y
# recipe to execute (built-in):
$(YACC.y) $<
mv -f y.tab.c $@
appears to assume that YACC/bison's output file name defaults to y.tab.c.
However, it is $*.tab.c for bison >= 3.0 (at least). Would that be worth an
enhancement to make to update to the new built-in recipe? Here I am not sure
which versions of yacc are out there and what their output files are named.
Many thanks for any input!
Regards,
J.
Signatures:
- GNU Make 4.2.1; Built for i686-pc-cygwin
- bison (GNU Bison) 3.0.4