[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Question about target files
From: |
Raleigh Rinehart |
Subject: |
Re: Question about target files |
Date: |
Wed, 09 Feb 2011 10:50:24 -0600 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101207 Lightning/1.0b2 Thunderbird/3.1.7 |
On 2/9/2011 9:05 AM, Faruk Kuşcan wrote:
Hello,
I'm new to make. I'm trying to write a makefile which looks at ../src/
directory and looks for updated cpp, c, hpp, h, ipp files. If they are
updated then I want to do the recipe. I wrote following lines.
abcde.abc : ../src/*.cpp ../src/*.c ../src/*.h ../src/*.hpp ../src/*.ipp
recipe...
However my problem is this; in some cases I don't have .c files or .h files.
But I may have sometimes. I don't know about that. So I want to write all
possibilities. Make looks at the directory and then tells me "there is no
*.h file in that directory" . How can I handle this?
Thanks.
Good day.
Faruk Kuscan
this is easily handled using the $(wildcard ) make function. So your
example might looks something like this:
SRC_DIR := ../src
c_src = $(wildcard $(SRC_DIR)/*.c)
cpp_src = $(wildcard $(SRC_DIR)/*.c)
ipp_src = $(wildcard $(SRC_DIR)/*.ipp)
headers = $(wildcard $(SRC_DIR)/*.h) $(wildcard $(SRC_DIR)/*.hpp)
abcde.abc: $(c_src) $(cpp_src) $(ipp_src) $(headers)
recipe
...
However, I wonder what you are trying to accomplish? Do you really want
to explicitly define the .h/.hpp files as prerequisites in this way? Or
would using a dependency generation tool and Make's include directive
work? You might also want to look at vpath.
What is the target abcde.abc producing? Should it really depend on the
src files or should it depend on the object files produced (by a
compiler) instead? This way your are letting the rules that do the
compilation worry about when to update files.
If you give us some more info on what you want to accomplish then we can
provide some more detailed help.
I take that since you've found this list, you've also found the Gnu Make
manual, you might want to give a quick look through to see what other
built-in functions make has.
Also the book Managing Projects with GNU Make, Third Edition is an
invaluable resource, especially for someone just starting out. You can
find an open version here: http://wanderinghorse.net/computing/make/
hope this helps,
-raleigh