Home > Archive > Unix Programming > February 2006 > makefile comples targets and dependencies
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
makefile comples targets and dependencies
|
|
|
| I need to have for complex rules and targets, at least I think they are
comples, to avoid copying the same thing over and over.
Here's a sample of what I have and tried.
gmake 3.79 HPUX
__BEGIN__
define stuff
@echo $(1); sleep 10
endef
PROJ := proj1 proj2 proj3 proj4 proj5 proj6 proj7
BB := bb1 bb2 bb3 bb4 bb5 bb6 bb7
all : $(PROJ)
$(filter proj1,$(PROJ)) : proj1
$(PROJ) : $(addprefix %_ , $(BB))
$(call stuff,$@)
# this is line 24 by hitting arrow down
$(addprefix %_ , $(BB)) :
$(call stuff,$@)
__END__
I need every project to depend on <proj>_<bb>
Then <proj>_<bb> to do a call Using this would eliminate from having
to write 49 rules to make sure that every proj has every bb. This will
go even deeper but this will do for the question. I have to provide
entry for many levels and most will be empty commands
When I execute the above I get :
Makefile:24: *** mixed implicit and normal rules. Stop.
| |
|
| billy wrote:
> I need to have for complex rules and targets, at least I think they are
> comples, to avoid copying the same thing over and over.
> Here's a sample of what I have and tried.
> gmake 3.79 HPUX
> __BEGIN__
> define stuff
> @echo $(1); sleep 10
> endef
>
>
> PROJ := proj1 proj2 proj3 proj4 proj5 proj6 proj7
> BB := bb1 bb2 bb3 bb4 bb5 bb6 bb7
>
> all : $(PROJ)
>
> $(filter proj1,$(PROJ)) : proj1
>
> $(PROJ) : $(addprefix %_ , $(BB))
> $(call stuff,$@)
> # this is line 24 by hitting arrow down
> $(addprefix %_ , $(BB)) :
> $(call stuff,$@)
> __END__
>
> I need every project to depend on <proj>_<bb>
> Then <proj>_<bb> to do a call Using this would eliminate from having
> to write 49 rules to make sure that every proj has every bb. This will
> go even deeper but this will do for the question. I have to provide
> entry for many levels and most will be empty commands
>
> When I execute the above I get :
> Makefile:24: *** mixed implicit and normal rules. Stop.
I cannot figure anything out about your situation from the above. Happy
to try to help though. Can you try explaining just one case, more
fully, perhaps starting with target, prerequisites, rules? In English,
preferably. Then we can generalise that, using the mechanisms make
provides.
--Toby
| |
| Måns Rullgård 2006-02-24, 6:59 pm |
| "toby" <toby@telegraphics.com.au> writes:
> billy wrote:
>
> I cannot figure anything out about your situation from the above. Happy
> to try to help though. Can you try explaining just one case, more
> fully, perhaps starting with target, prerequisites, rules? In English,
> preferably. Then we can generalise that, using the mechanisms make
> provides.
make -d will print lots of information about how it's deciding what to
build.
--
Måns Rullgård
mru@inprovide.com
| |
|
| M=E5ns Rullg=E5rd wrote:
> "toby" <toby@telegraphics.com.au> writes:
>
>
> make -d will print lots of information about how it's deciding what to
> build.
I'm not confident that the OP has a makefile working sufficiently to be
debugged. It looks as if it's heading in an excessively baroque
direction. I'd first like to try to understand what he is trying to
achieve and then find the natural 'make way'.
>=20
> --=20
> M=E5ns Rullg=E5rd
> mru@inprovide.com
| |
|
| As you see above I have 7 projects and 7 bb's. Every bb is to be a
part of every proj.
So I will need rules/dependencies like the following
proj1 : proj1_bb1
proj1 : proj1_bb2
proj1 : proj1_bb3
proj1 : proj1_bb4
proj1 : proj1_bb5
proj1 : proj1_bb6
proj1 : proj1_bb7
proj2 : proj2_bb1
proj2 : proj2_bb2
....
The dependencies need to be created <proj>_<bb>
Another layer will be added later, but If I can get this working then
another layer will be just a cut and paste.
So instead of having 49 independent rules that all perfrom the same
functions, but with just differents names , <proj> , <bb> I could pass
the 2 names to a call statement $(call stuff, <proj>, <bb> )
If I can't get this to work I will have to create over 500 individual
rules.
| |
|
| billy wrote:
> As you see above I have 7 projects and 7 bb's. Every bb is to be a
> part of every proj.
Your rules below seem to imply that projX is built (only) from a set of
files projX_bbY ?
> So I will need rules/dependencies like the following
>
> proj1 : proj1_bb1
>
> proj1 : proj1_bb2
>
> proj1 : proj1_bb3
>
> proj1 : proj1_bb4
>
> proj1 : proj1_bb5
>
> proj1 : proj1_bb6
>
> proj1 : proj1_bb7
>
> proj2 : proj2_bb1
>
> proj2 : proj2_bb2
>
> ...
>
>
> The dependencies need to be created <proj>_<bb>
> Another layer will be added later, but If I can get this working then
> another layer will be just a cut and paste.
>
> So instead of having 49 independent rules that all perfrom the same
> functions, but with just differents names , <proj> , <bb> I could pass
> the 2 names to a call statement $(call stuff, <proj>, <bb> )
> If I can't get this to work I will have to create over 500 individual
> rules.
If the 'projX_bbY' files already exist (aren't created by further
rules), then you can set up dependencies with simple wildcards:
proj1 : proj1_bb[1-7]
# buildcmd -o $@ $^
proj2 : proj2_bb[1-7]
# buildcmd -o $@ $^
Pattern rules may also help, in particular if projX_bbY are derived
files (not pre-existing, but created by other rules). You may want to
list specific targets somewhere, for instance in a rule for 'all':
all : proj1 proj2 proj42 # and so on
proj% : proj%_bb1 proj%_bb2 # and so on
# buildcmd -o $@ $^
(Pattern rules and wildcards don't work together.)
| |
| Andrei Voropaev 2006-02-28, 3:58 am |
| On 2006-02-27, billy <bp1497@att.com> wrote:
[...]
>
> The dependencies need to be created <proj>_<bb>
[...]
> functions, but with just differents names , <proj> , <bb> I could pass
> the 2 names to a call statement $(call stuff, <proj>, <bb> )
Have you checked 'info make'? In section "Functions" -> "Eval function"
you'll find an example that may serve your needs. Though probably you
may be able to do everything in some other way.
--
Minds, like parachutes, function best when open
|
|
|
|
|