help-make
[Top][All Lists]
Advanced

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

Re: about :: sign and % sign problems


From: Paul D. Smith
Subject: Re: about :: sign and % sign problems
Date: Wed, 26 Apr 2006 10:08:02 -0400

%% Lin George <address@hidden> writes:

  lg> Do you also know the difference between :: and :? I can not
  lg> understand what related parts of GNU make manual is talking about
  lg> and there is also no samples in the manual dealing with this
  lg> point.

Normally if you tried this, for example:

    install:
            cp foo $(DESTDIR)
    install:
            cp bar $(DESTDIR)

make would fail because you are defining multiple rules for a single
target.  If you use "::" instead, it will work:

    install::
            cp foo $(DESTDIR)
    install::
            cp bar $(DESTDIR)

because here make keeps both targets; both commands will run when you
run "make install".

In this simple example it's not necessary; you could just write:

    install:
            cp foo $(DESTDIR)
            cp bar $(DESTDIR)

and get the same behavior.  However, double-colon rules can be very handy
if you have complex makefiles with lots of included makefiles, for
example; then each makefile can have its own "install::" target and you
don't have to worry about it.


Another interesting thing is that each instance of the target is
evaluated independently and only those instances which are out of date
are invoked.  In the above example presumably a file "install" never
exists so the target is always out of date (or more commonly, it's
declared .PHONY).  It's difficult to come up with a situation where this
is useful, but not impossible I suppose.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.paulandlesley.org
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist




reply via email to

[Prev in Thread] Current Thread [Next in Thread]