help-make
[Top][All Lists]
Advanced

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

Handling '=' in a filename together with $(eval )


From: Alejandro Colomar
Subject: Handling '=' in a filename together with $(eval )
Date: Thu, 13 Feb 2025 15:46:18 +0100

Hi!

I'm trying to find a way to correctly handle files with a '=' in their
name with make(1).  I know I'm doing something in the edge of what's
possible, so the answer may very well be "you can't", but if it's
possible, I'd like to learn how.  The reason is that the file exists in
another project, and I'd like to use it with my Makefile; I can't fix
the filename.

I already found a trick some time ago for handling ':' in filenames, so
I expected the same trick would work, but it doesn't.

Consider this directory:

        $ tree
        .
        ├── Makefile
        ├── src
        └── tmp

        3 directories, 1 file

This is how I'm handling filenames with a ':'.  I just add an escape:

        alx@devuan:~/tmp/symbolds$ cat Makefile 
        obj := obj/asd\:fgh

        all: $(obj)

        $(info $(obj) : obj/% : src/%)
        $(eval $(obj) : obj/% : src/%)

        $(obj):
                touch $@
        alx@devuan:~/tmp/symbolds$ make
        obj/asd\:fgh : obj/% : src/%
        make: *** No rule to make target 'src/asd:fgh', needed by 
'obj/asd:fgh'.  Stop.

(The failure is intentional.  That error message helps me see that
 make(1) did understand me; I just didn't provide the prerequisite.)

When I try the same trick with a '=', I'm not sure what make(1) is
interpreting, though:

        alx@devuan:~/tmp/symbolds$ cat Makefile 
        obj := obj/asd\=fgh

        all: $(obj)

        $(info $(obj) : obj/% : src/%)
        $(eval $(obj) : obj/% : src/%)

        $(obj):
                touch $@
        alx@devuan:~/tmp/symbolds$ make
        obj/asd\=fgh : obj/% : src/%
        touch obj/asd\=fgh
        touch: cannot touch 'obj/asd=fgh': No such file or directory
        make: *** [Makefile:9: obj/asd\=fgh] Error 1

It somehow think the prerequisites are met, but I didn't provide them.
Somehow, make(1) is misunderstanding me.  Can I workaround this in a
different way?  (The $(eval ) is necessary; if not, it would be easier.)


Have a lovely day!
Alex

-- 
<https://www.alejandro-colomar.es/>

Attachment: signature.asc
Description: PGP signature


reply via email to

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