makefile - Print the prerequisites to a target -
this duplicate of this question, has not been answered, can see.
here goal: able print prerequisites target.
i have kind of solution feels hack me.
say target all, , has prerequisites, in file named makefile-1:
all: foo all: bar baz i can use makefile named makefile-2:
all: ifeq ($(show),yes) echo $^ else cat $^ endif this kind of gives me need, when invoked properly:
$ make -f makefile-1 -f makefile-2 cat foo bar baz $ make -s show=yes -f makefile-1 -f makefile-2 foo bar baz but not sure if prerequisite has recipe in original makefile, or if there better/cleaner way.
an easier way show prerequisites target without building target use -p option (as suggested here) , -q options together, suggested on gnu-make manual page (long name option --print-data-base):
make -qp | grep '^all:' this print database , select line has target all , prerequisites. if there rule target, @ end of same paragraph (if understanding format of output correctly).
if multiple makefiles used, 1 can specify of them -f option:
make -f makefile-1 -f makefile-2 -qp this of course collect prerequisites same target makefiles, target cannot have rule specified in more 1 file.
Comments
Post a Comment