[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: GNU Make - Problem defining pattern rules
From: |
Manuel Collado |
Subject: |
Re: GNU Make - Problem defining pattern rules |
Date: |
Thu, 29 Apr 2010 13:24:52 +0200 |
User-agent: |
Thunderbird 2.0.0.23 (Windows/20090812) |
Dave escribió:
...
When I execute:
make src/application/SampleApplication
I see "Building a Binary"
When I execute
make src/libraries/PluginOne/libPluginOne.so
I see "make: Nothing to be done for `src/libraries/PluginOne/
libPluginOne.so'."
Can anyone explain why the pattern rule for the binary appears to
work, but the pattern rule for a .so library doesn't?
After expanding the variable values and stripping down the file paths,
it seems that the relevant part of your Makefile can be reduced to:
%.so: %.o
@echo "Building a Library"
libPluginOne.so: PluginOne.o ...
The last, explicit rule doesn't match the first, implicit rule (note the
'lib' prefix), and contains no actions, so ... "Nothing to do ..."
...
----------------------------------------------------------
# Some Pattern Rules
#
%.o: %.cpp
@echo "Building Object Files"
%.so: %.o
@echo "Building a Library"
%: %.o
@echo "Building a Binary"
.SUFFIXES: .so
# Some variables to hold data
#
PROGRAMS :=
LIBRARIES :=
SOURCES :=
# Build the first binary
#
local_bin := src/application/SampleApplication
local_src := src/application/SampleApplication.cpp src/
application/MessagePrinter.cpp
local_objs := $(subst .cpp,.o,$(local_src))
PROGRAMS += $(local_bin)
SOURCES += $(local_src)
$(local_bin): $(local_objs)
# Build the first library
#
local_lib := src/libraries/PluginOne/libPluginOne.so
local_src := src/libraries/PluginOne/PluginOne.cpp src/libraries/
PluginOne/HelperClass.cpp
local_objs := $(subst .cpp,.o,$(local_src))
LIBRARIES += $(local_lib)
SOURCES += $(local_src)
$(local_lib): $(local_objs)
-------------------------------------------------------------
--
Manuel Collado - http://lml.ls.fi.upm.es/~mcollado