encukou / py3c

A Python 2/3 compatibility layer for C extensions
http://py3c.readthedocs.org
MIT License
59 stars 20 forks source link

Makefile: fix DESTDIR support #48

Closed davvid closed 3 years ago

davvid commented 3 years ago

The makefile will fail if ran as:

make DESTDIR=/tmp/stage prefix=/opt/this/does/not/exist install

The reason is that the Makefile runs "realpath" on the calculated $(prefix)/include directory, but this will return an empty string when the path does not yet exist, leading to a broken py3c.pc pkg-config file.

Furthermore, we were trying to do "mkdir -p $(includedir)" which simply cannot work when the install prefix is read-only, for example when creating RPMs or preparing packages where the final prefix is not writeable by the build process.

Fix these issues by using abspath on the specified $(includedir) and and removing the mkdir handling.

The "install" target already handles prefixing paths with $(DESTDIR) so this is the last missing piece towards making it work robustly in typical situations.

Signed-off-by: David Aguilar davvid@gmail.com

encukou commented 3 years ago

Thanks, this makes sense!

encukou commented 3 years ago

(The CI failure is unrelated.)

encukou commented 3 years ago

Thank you!