Possibly this would be helpful? # Usage: $(call toupper,<string>) # $1: string to be uppercased toupper = $(strip \ $(subst a,A,$(subst b,B,$(subst c,C,$(subst d,D,$(subst e,E, \ $(subst f,F,$(subst g,G,$(subst h,H,$(subst i,I,$(subst j,J,$(subst k,K, \ $(subst l,L,$(subst m,M,$(subst n,N,$(subst o,O,$(subst p,P,$(subst q,Q, \ $(subst r,R,$(subst s,S,$(subst t,T,$(subst u,U,$(subst v,V,$(subst w,W, \ $(subst x,X,$(subst y,Y,$(subst z,Z,$1)))))))))))))))))))))))))))
On Fri, Nov 25, 2022 at 11:33 AM Kaz Kylheku <k...@kylheku.com> wrote: > 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 ... > > >