[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Evaluation of variables inside make rules' dependencies
From: |
Dmitry N. Mikushin |
Subject: |
Evaluation of variables inside make rules' dependencies |
Date: |
Mon, 7 Mar 2011 05:06:40 +0300 |
Hi,
I'm trying to understand the behavior of the following example:
%.a: LIBNAME = $(shell echo $(notdir $(basename $@)) | sed s/lib// | \
tr '[a-z]' '[A-Z]' | tr '/' '_')
%.a: SOURCES = $($(LIBNAME)_SOURCES)
%.a: OBJECTS = $(addprefix $(STORE)/, $(addsuffix .o, $(SOURCES)))
%.a: DEPLIBS = $($(LIBNAME)_DEPLIBS)
%.a: DEFINES += $($(shell echo $(1) | tr '[a-z]' '[A-Z]' | tr '/' '_')_DEFINES)
%.a: INCLUDES += $($(shell echo $(1) | tr '[a-z]' '[A-Z]' | tr '/'
'_')_INCLUDES)
%.a: dirs $(OBJECTS)
@echo Packing static library $@ $(OBJECTS) ...
@$(AR) $(ARPARAMS) $@ $(OBJECTS)
The result is:
============
$(OBJECTS) seems to be empty inside line %.a: dirs $(OBJECTS), because
nested targets are not invoked, for example this one really should:
$(STORE)/%.c.o: %.c
@echo Creating object file for $< ...
@$(CCOMP) $(CPARAMS) $(DEFINES) $(INCLUDES) -c $< -o $@
However:
=========
$(OBJECTS) is correct inside command, since ar is looking for object
foo.c.o that should be compiled as dependency:
Packing static library bin/libfoo.a ...
ar: creating bin/libfoo.a
ar: .build/foo/foo.c.o: No such file or directory
The "dirs" target creates subdirectories.
So what's the difference between evaluating variable in dependency
line and in command?
Thanks,
- D.
- Evaluation of variables inside make rules' dependencies,
Dmitry N. Mikushin <=