Makefile Syntax: Static Library lib $ (library) .a ($ objects)

I am updating some Makefiles to go from Make 3.81 to 3.82. In several places, the original author used something like this to create static libs:

all: lib$(library).a($objects)

It seems that every .o file is still created and inserts it into .a using ar:

g++ -O2 <snip> -o some_obj.o some_cpp.cpp
ar rv libsome_lib.a some_obj.o
etc...

This new version of make, however, is suffocating:

*** No rule to make target 'libsome_lib.a()', needed by 'all'

I can replace this shortcut with the way I'm used to it:

lib$(library).a: $(objects)
     ar -rs lib$(library).a $objects

Thanks.

EDIT

Looks like I need a better Makefile education. Here's a big excerpt from the original Makefile:

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) $< \
                      | sed '\''s/\($*\)\.o[ :]*/\1.o $@ : /g'\'' > $@; \
                      [ -s $@ ] || rm -f $@'
%.d: %.c
    $(SHELL) -ec '$(CXX) -M $(CPPFLAGS) $(CXXFLAGS) $< \
                      | sed '\''s/\($*\)\.o[ :]*/\1.o $@ : /g'\'' > $@; \
                      [ -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:
    <SNIP>

if neq($(MAKECMDGOALS),clean)
    include $(depends)
endif

When this works under 3.81, I get all the .d dependencies created, and then it starts g ++ using obj files. In 3.82, I get .d files, but no .o and make fails with "*** There is no rule to do ..."

+1
3

" ", gnu make. , . $(objects). . :

http://www.gnu.org/software/make/manual/make.html#Archive-Members

11.1

make. - :

 archive(member)

, ! , . ar , . -, , ar. , : hack.o foolib, hack.o:

 foolib(hack.o) : hack.o
         ar cr foolib hack.o

, , . : c , .

+4

, makefile , .

, :

lib$(library).a: $(objects)
     ar -rs $@ $^


- . ; .

, sources.inc , 3.81 3.82 :

experiment:
    @echo sources: $(sources)
    @echo objects: $(objects)
    @echo depends: $(depends)

, objects 3.82, .d 3.82, , depends , .

+3

, - xyz.cpp xyz.o, , . , .

, : $objects, libsome_lib.a() (.. ) ?

, , , (, , ). , , make , , , .

Cut'n'paste - : -)

+1

All Articles