help-make
[Top][All Lists]
Advanced

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

Re: Help needed for writing a rule


From: Kaz Kylheku
Subject: Re: Help needed for writing a rule
Date: Fri, 25 Nov 2022 08:31:51 -0800
User-agent: Roundcube Webmail/1.4.13

On 2022-11-25 06:26, Patrick Begou wrote:
> Hi all,
> 
> I'm stuck for several hours in trying to write a rule for managing fortran 
> modules. My difficulty is that the Cray compiler requires a  module name 
> written in upper case.
> 
> example: if file is "toto_m.f90", it contains a module called "toto_m" and 
> the module file will be "TOTO_M.mod".
> 
> How can I write a generic rule for building TOTO_M.mod from toto_m.f90 source 
> and put it in the LIB folder ?
> 
> Of course,the following lines will not work as the "%" token will be in 
> uppercase on the right hand side.
> 
> # building only the mod file
> LIB/%_M.mod: %_m.f90
>         @echo "building $*_M.mod"
>         touch $@

Can you make symbolic links that have the upper case, and feed them to the 
compiler?

  LIB/%_m.mod: %_m.f90
          @echo "building $*_m.mod"
          touch $@
          ln -sf $@ $$(echo $*_m | tr [a-z] [A-Z]).mod

Here I have a working sample where I use a target-specific assignment to define
a variable called $(UC) which holds the upper-cased stem:

  $ make
  make: *** No rule to make target 'foo.in', needed by 'foo.out'.  Stop.
  $ touch foo.in
  $ make
  making foo.out (upcased as FOO.out)

Contents:

  $ cat Makefile
  %.out: UC = $$(echo $* | tr [a-z] [A-Z])

  %.out: %.in#
          @echo "making $*.out (upcased as $(UC).out)"

  foo.out: foo.in

The $* is evaluated at the time the target is dispatched, because it's
in a target-specific assignment. The $$ on $$(echo ...) ensures
that we get a literal $(echo ...) passed to the shell during
recipe execution.

Hope I didn't do anything wrong that makes this inapplicable to
your case!

Cheers ...




reply via email to

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