[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Does Debian supports backticks in the Makefile?



On Sun, Jul 10, 2022 at 11:13:45PM -0500, Igor Korot wrote:
> libpostgres_la_CXXFLAGS = -D__WXGTK__ \
>     -I../../dbinterface \
>     `pg_config \
>     --includedir`

You're asking whether this works in a variable definition inside a
Makefile.  I'm assuming you're using GNU make.

Well, let's TEST IT AND SEE.  Sheeeesh.


unicorn:~$ cd tmp
unicorn:~/tmp$ vi Makefile
unicorn:~/tmp$ cat Makefile
foo = abc `echo def` ghi

bar = jkl \
	`echo \
	mno` \
	pqr

one:
	echo $(foo)

two:
	echo $(bar)
unicorn:~/tmp$ make one
echo abc `echo def` ghi
abc def ghi
unicorn:~/tmp$ make two
echo jkl `echo mno` pqr
jkl mno pqr
unicorn:~/tmp$ make --version | head -n1
GNU Make 4.3


So, what do we conclude from this?  The backticks are not expanded when
the make variable is defined.  They're included literally in the variable's
contents.  They get passed to the shell command that make executes, and
the shell interprets them as a command substitution.

On a personal note, I find this construction extremely ugly:

	`pg_config \
	--includedir`

I can't see any sensible reason why you would write a command
substitution this way, with the command's single argument on a separate
line from the command itself.  That's part of the reason why I tested it
separately in my demonstration.  The other part is that I thought,
perhaps, the command substitution might have been handled by make itself,
during the variable definition.  And if that were the case, then perhaps
splitting it across lines might have confused make, and caused it not to
work.

But as we saw in the test, it works the same either way.


Reply to: