bug-make
[Top][All Lists]
Advanced

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

Re: make doesn't honor -n switch plus wrong target selection


From: Paul Smith
Subject: Re: make doesn't honor -n switch plus wrong target selection
Date: Mon, 10 Sep 2007 08:40:01 -0400

On Mon, 2007-09-10 at 15:37 +0530, Jeenu V wrote:
> Please see the attached package.

It's difficult for us to unpack and debug larger packages.  It's easier
if you provide just a single makefile, and also show the command you
invoked and show the output you received (cut and paste, please)

> Problem 1: Make is not recognizing the first available target "all"
> and is going behind another one. I have specified it as ".PHONY" have
> written "all" as the first target. But still make seems to skip it. 
> 
> Problem 2: Apart from the first bug, even if I specify -n switch, make
> tries to *execute* the commands for the target.
> 
> There are a couple of variables set using the "shell" function.
> Interestingly, if I comment those out, make seems to work well! 

Your problem is here:

        DIRS = $(shell ls)

The result of this is a list of all files in the current directory,
which includes the subdirectories you want... BUT it also includes the
Makefile itself!  This is the same as writing:

        DIRS = Makefile  dir1  dir2  dir3

So that means this target:

        $(DIRS): compile_common

becomes this:

        Makefile  dir1  dir2  dir3: compile_common

Since you've shown make how to rebuild the Makefile, and the
prerequisites are .PHONY so they always get rebuilt, make will always
run these rules (see the GNU make manual section "How Makefiles are
Remade" in the chapter "Writing Makefiles").

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.mad-scientist.us
 "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]