I want to create a library skipping one of the dependency file not to include while creating the same.
Eg:-
liba.so: a.o b.o c.o test.psm
<command for creating liba.so, which includes all its dependencies.>
Here when there is a change is any of its dependencies i have to create liba.so
file. But .so
file should include only .o files and not test.psm
file.
It will throw the error when we try to create .so file with non-object file.
Please help me how can we achieve this using GNUmake.
The best way to solve the problem is to avoid it. I see absolutely no reason to rebuild a library that exists already and whose prerequisites have not changed since it was last built. If for some bizarre reason one wants to ensure that the library's timestamp is not earlier than that of some associated documentation file, then the best alternatives would run along the lines of creating a separate process around maintaining or distributing that file. For example,
touch
a corresponding source file whenever the documentation file is changed; orBut if you must obey the dictates of a pointy-haired boss who will not accept pushback, then the answer to the actual question is that make
does not have any special variable or operator for designating subsets of rules' prerequisite lists, but you nevertheless have plenty of options for writing the recipe appropriately. This then becomes about the details of of the rule's recipe.
If one starts with
liba.so: a.o b.o c.o
$(archiver_command) $(archiver_options) a.o b.o c.o
then one can add test.psm
to the prerequisite list without any other changes.
Suppose one starts with a rule of this form, however:
liba.so: a.o b.o c.o
$(archiver_command) $(archiver_options) $^
. The recipe uses the automatic variable $^
to refer to the (whole) list of prerequisites, so if one adds test.psm
as a new prerequisite then it would be included, too, which you do not want. You have multiple options here, among them
The last alternative would be my recommendation. Specifically, it would look something like this:
A_OBJS = a.o b.o c.o
# ...
liba.so: $(A_OBJS) test.psm
$(archiver_command) $(archiver_options) $(A_OBJS)