title: Makefile Syntax: Static library lib$(library).a($objects)
body: <p>I'm updating some Makefiles to move from Make 3.81 to 3.82.  In multiple places, the original author used something like this to build static libs:</p>
  
  <pre><code>all: lib$(library).a($objects)
  </code></pre>
  
  <p>This seems to build each .o file in turn and insert it into the .a using ar:</p>
  
  <pre><code>g++ -O2 &lt;snip&gt; -o some_obj.o some_cpp.cpp
  ar rv libsome_lib.a some_obj.o
  etc...
  </code></pre>
  
  <p>This new make version, though, chokes with:</p>
  
  <pre><code>*** No rule to make target 'libsome_lib.a()', needed by 'all'
  </code></pre>
  
  <p>Am I safe to replace this shortcut with the way I'm used to doing this:</p>
  
  <pre><code>lib$(library).a: $(objects)
       ar -rs lib$(library).a $objects
  </code></pre>
  
  <p>Thanks.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Looks like I need a better Makefile education.  Here's a larger excerpt from the original Makefile:</p>
  
  <pre><code>CXXFLAGS += -O2 -g -Wall -Wunused-parameter \
      `pkg-config --cflags gthread-2.0 glibmm-2.4 gtkmm-2.4`
  
  libs +=  `pkg-config --libs gthread-2.0 glibmm-2.4` -lc
  
  %.d: %.cpp
      $(SHELL) -ec '$(CXX) -M $(CPPFLAGS) $(CXXFLAGS) $&lt; \
                        | sed '\''s/\($*\)\.o[ :]*/\1.o $@ : /g'\'' &gt; $@; \
                        [ -s $@ ] || rm -f $@'
  %.d: %.c
      $(SHELL) -ec '$(CXX) -M $(CPPFLAGS) $(CXXFLAGS) $&lt; \
                        | sed '\''s/\($*\)\.o[ :]*/\1.o $@ : /g'\'' &gt; $@; \
                        [ -s $@ ] || rm -f $@'
  
  from_sources = $(patsubst %.c,$(2),$(filter %.c, $(1)))  $(patsubst %.cpp,$(2),$(filter %.cpp, $(1)))
  
  sources = $(shell cat sources.inc)
  objects = $(call from_sources,$(sources),%.o)
  depends = $(call from_sources,$(sources),%.d)
  
  library = some_lib
  
  .PHONY: all clean fresh
  
  all: lib$(library).a($(objects))
  
  clean:
      &lt;SNIP&gt;
  
  if neq($(MAKECMDGOALS),clean)
      include $(depends)
  endif
  </code></pre>
  
  <p>When this runs under 3.81, I get all the .d dependences created, then make starts g++ing the obj files.  Under 3.82, I get the .d files but no .o and make fails with "***No rule to make..."</p>