help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

building templates


From: Martin Kleinschmidt
Subject: building templates
Date: Wed, 9 Apr 2003 18:59:38 +0200
User-agent: Mutt/1.4i

Hi,

I am trying to do something like templates with fortran.
No problems on the implementation so far, but i have trouble, writing an
appropriate Makefile.

I have files xaaa.F, xbbb.F, which contain C preprocessor directives.
>From each of these files, i want to generate different objects by passing
different variables to the C preprocessor.
e.g. I want to generate zaaa.o and daaa.o from xaaa.F, 
and zbbb.o and dbbb.o from xbbb.F
There will be multiple x???.F files but from each x???.F I will need to
generate at most 4 (probably only 2) different objects.

so what I did:

writing it explicitly:

ZWHICH = -DMY_Z
zaaa.f: xaaa.F
        $(CC) -E -P $(ZWHICH) $< -o $@

and subsequently applying the standard rules for %.o:%.f

I thought of doing something like

z%.f: x%.F
        $(CC) -E -P $(ZWHICH) $< -o $@

but that would break all other z*.o (which do not depend on an x???.F)
Okay - I could place my templates in a separate directory, but 
a) I don't want that and 
b) I want to learn something about makefiles :-)


I tried:

ZOBJS = zaaa.o zbbb.o
$(foreach object, $(ZOBJS), $(eval \
$(object): $(patsubst z%.o, x%.F, $(object)) \
        $(CC) $(PREFLAG) $(ZWHICH) $< -o $@))

but make can't find a rule:

make: *** No rule to make target `zaaa.o', needed by `program'.  Stop.


I tried:

ZOBJS = zaaa.o zbbb.o
define XTEMPLATE
 $(1):  $(patsubst z%.o, x%.F, $(1))
        $(CC) -E -P $(ZWHICH)  $(patsubst z%.o, x%.F, $(1)) -o tmp.f
        $(FC) $(FFLAGS) -c tmp.f -o  $(1)
endef
$(foreach object, $(ZOBJS), $(eval $(call XTEMPLATE, $(object))))

but make can't find a rule here, too.

Any hints from the make gurus? What am I doing wrong? 

thanks

   ...martin




reply via email to

[Prev in Thread] Current Thread [Next in Thread]