help-gnu-utils
[Top][All Lists]
Advanced

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

GNU Make - Problem defining pattern rules


From: Dave
Subject: GNU Make - Problem defining pattern rules
Date: Wed, 28 Apr 2010 13:31:14 -0700 (PDT)
User-agent: G2/1.0

Hi,

I've put together a simple makefile that builds a binary and a
library.  I've defined some pattern rules, so that I can control how
the binaries and libraries can be built (in the real world I'd want to
build lots of binaries and libraries).
The pattern for the binary works, but the pattern for the library
isn't getting called  - can anyone help me?

The makefile is listed below.
I have defined a pattern rule for building a binary that prints
"Building a Binary" and a pattern rule for building a .so that prints
"Building a Library".  I have two targets
"src/application/SampleApplication" and "src/libraries/PluginOne/
libPluginOne.so".

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?

Thanks



----------------------------------------------------------
# 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)
-------------------------------------------------------------



reply via email to

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