Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

make does not realize that a relative path name dependency is the same as an absolute pathname target

Tags:

gnu-make

The following is a simplified makefile for a problem I'm having:

all: /tmp/makey/../filey
    @echo All done
/tmp/filey:
    @echo Filey

When I run make it says:

make-3.79.1-p7: * No rule to make target /tmp/makey/../filey', needed byall'. Stop.

Clearly it does not realize that /tmp/makey/../filey is the same as /tmp/filey. Any ideas how I can make this work?

Thanks

Ciao -- Murali

like image 720
user2221763 Avatar asked Oct 16 '25 20:10

user2221763


1 Answers

Newer versions of GNU make have $(abspath ...) and $(realpath ...) functions you can apply to your prerequisites and targets to resolve the paths to the same string. If you've constructed these names yourself (for example, $(PREFIX)/../filey) then you can use $(dir $(PREFIX))filey instead.

Other than that, there's no way to solve this problem. Make uses string matching on targets and if the strings are not identical, they don't match (there's a special case to ignore the simple prefix ./) Even if make understood this distinction (by applying abspath itself to each target name, maybe) it would still not help in the face of symbolic links for example.

The only "real" answer would be for make to understand something about the underlying file system (device IDs and inodes for example) that let you talk about files without referring to their pathname. However, in a portable program like make doing this is problematic.

like image 99
MadScientist Avatar answered Oct 19 '25 10:10

MadScientist



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!