Re: Compiling gtk apps on MingW



On Sun, Jul 03, 2005 at 09:37:49AM +0200, Gus Koppel wrote:

Makefiles are not supposed to contain (or evaluate, rather)
"`"-expressions.

Why not?  Backquotes work with most shells and thus you
don't depend on GNU make.

Anyway, make never evaluates ``-expressions, see below.
I have a Makefile which bascially consists only of

  PKGCONFIG = pkg-config
  GTK = gtk+-2.0
  LDFLAGS = `$(PKGCONFIG) $(GTK) --libs`
  CFLAGS = `$(PKGCONFIG) $(GTK) --cflags`

in my experimental Gtk+ directory, so I create foo.c, run
make foo and it compiles foo with Gtk+.  I could use
$(shell ...) too, but it would make no difference here.

'make' doesn't treat them the same way the shell does,
i.e. expanding them. 'make' provides the "shell" function for shell
command expansion instead. Study the 'make' documentation for further
information about this.

Which reveals make never evaluates `` in the first place.
Backquotes have no special meaning in Makefile, make
substitutes them literally and it's the shell what
subsequently expands them.  So unlike

FOO = $(echo $$RANDOM)
FOO := $(echo $$RANDOM)

where the first gives a different number each time it is
used and the second always the same (echo $$RANDOM is always
run once at the start), both

FOO = `echo $$RANDOM`
FOO := `echo $$RANDOM`

give different numbers each time they are used.  Both
behaviours can be useful:

FOO = $(shell ls)

foo:
        cd /tmp; echo $(FOO)

prints the contents of current directory.  But

FOO = `ls`

foo:
        cd /tmp; echo $(FOO)

prints the contents of /tmp -- it's the same as

foo:
        cd /tmp; echo `ls`

Yeti


--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?



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