help-make
[Top][All Lists]
Advanced

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

RE: Must be very simple


From: Paul D. Smith
Subject: RE: Must be very simple
Date: Mon, 20 Mar 2006 11:06:05 -0500

%% "PATTON, BILLY \(SBCSI\)" <address@hidden> writes:

  pb> Probably has something to do with the fact that I'm using sh
  pb> syntax where I should be using make syntax.

Yes.

  pb> I've tried this:
  pb> $(if -f $(SRC_TREE)/$(1)/make.include,$(shell echo "$(1)
  pb> exists"),$(shell echo "$(1) not exists"))

And, what would lead you to believe that would work? :-).  Is there any
mention of "-f" being a valid expression in the GNU make manual?

Remember, make != shell.  Makefiles can CONTAIN shell scripts, in
certain very specific places, but make does not RUN shell scripts
itself.  It forks a shell to do so (in certain very specific places).

  pb> Is the -f $(SRC_TREE)/$(1)/make.include is causing the problem.

It's not "causing a problem", it's just not doing what you expect.  Read
the docs for the if function in the GNU make manual and see how the
expression for the conditional is treated.

  pb> Probably,  How do I test for the existance of a file?
  pb> $(shell -f $(SRC_TREE)/$(1)/make.include)

No.  What happens when you type:

    -f /some/dir/make.include

to your shell prompt?  That's what'll happen when you give that command
to the shell.

  pb> Just tried this
  pb> $(if $(shell test -f $(SRC_TREE)/$(1)/make.include),$(shell echo "$(1)
  pb> exists"),$(shell echo "$(1) not exists"))

No.  See above.

  pb> I don't need to include both. make.include files from the SRC_TREE and
  pb> MAKEINC_DIR

  pb> So from a make command how do I check for the existance of a file
  pb> to include.  I have a possible 450+

You haven't really described what you want to do.  Are you trying to
include either one file or another?  Or any file that already exists?
Or ... ?


The normal way to check for the existence of files is to use the
$(wildcard ...) function.  To include all files ending in .d:

    include $(wildcard *.d)

To include the first existing file in a list of files:

    include $(firstword $(wildcard file1.mk file2.mk file3.mk))

etc.

-- 
-------------------------------------------------------------------------------
 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]