[Top][All Lists]

[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


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/".

When I execute:
make src/application/SampleApplication

I see  "Building a Binary"

When I execute
make src/libraries/PluginOne/

I see "make: Nothing to be done for `src/libraries/PluginOne/'."

Can anyone explain why the pattern rule for the binary appears to
work, but the pattern rule for a .so library doesn't?


# Some Pattern Rules
%.o: %.cpp
        @echo "Building Object Files" %.o
        @echo "Building a Library"

%: %.o
        @echo "Building a Binary"


# Some variables to hold data
SOURCES      :=

# Build the first binary
local_bin       := src/application/SampleApplication
local_src       := src/application/SampleApplication.cpp src/
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/
local_src       := src/libraries/PluginOne/PluginOne.cpp src/libraries/
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]