Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pkg-config support for erl_interface #4527

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

joaohf
Copy link
Contributor

@joaohf joaohf commented Feb 17, 2021

pkg-config is a helper tool used when compiling applications and
libraries.

This commit introduces the file erl_ei.pc which will be installed
in the standard pkg-config directory.

Thus, using pkg-config like this:

pkg-config --libs --cflags erl_ei

Returns the correct libs and cflags that can be used by build tools
(like autotools);

-I/cross/sysroots/core2-32-vendor-linux/usr/lib/erlang/lib/erl_interface-4.0.2/include
-L/cross/sysroots/core2-32-vendor-linux/usr/lib/erlang/lib/erl_interface-4.0.2/lib -lei

@CLAassistant
Copy link

CLAassistant commented Feb 17, 2021

CLA assistant check
All committers have signed the CLA.

@joaohf
Copy link
Contributor Author

joaohf commented Feb 17, 2021

Hello,

I'm not sure with installing .pc (pkg-config files) is something desired. However, I have some use cases where pkg-config is useful when solving cross-compilation build.

Also, I'm not mastering in autoconf and I tried to hook the .pc installation for erl_interface.

@rickard-green rickard-green added the team:VM Assigned to OTP team VM label Feb 17, 2021
@rickard-green rickard-green self-assigned this Feb 22, 2021
@@ -683,6 +690,8 @@ release: opt
$(INSTALL_DIR) "$(RELSYSDIR)/src/prog"
$(INSTALL_DIR) "$(RELEASE_PATH)/usr/include"
$(INSTALL_DIR) "$(RELEASE_PATH)/usr/lib"
$(INSTALL_DIR) "$(DESTDIR)/$(libdir)/pkgconfig"
$(INSTALL_DATA) $(PKG-CONFIG) "$(DESTDIR)/$(libdir)/pkgconfig"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are problematic. It is possible to install OTP using paths determined by configure (and then this will work), but also using an explicitly given path at install time. This either using make release RELEASE_ROOT=<PATH> or ./otp_build release [-a] <PATH>. When giving the path at install time this will install erl_ei.pc at a completely different place than where OTP is installed.

A solution could be to only install erl_ei.pc when installing OTP using make install at the top. Info indicating that we are installing using the configured path then needs to be passed down to this make file. This can for example be done via a make variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, I got it.

@joaohf joaohf force-pushed the erl_interface-pkg-config branch from f1eeb74 to f025908 Compare March 13, 2021 19:56
PKG-CONFIG = \
$(TARGET)/erl_ei.pc

ifneq ($(DESTDIR),)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When calling ./otp_build release [-a] <PATH> or make release RELEASE_ROOT=<PATH> the DESTDIR is not defined, thus the pkg-config rule will not be called.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but DESTDIR is not necessarily used when installing with make install, so now erl_ei.pc will be lost when not using DESTDIR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. My next version will be like this:

./configure --enable-pkg-config

make install DESTDIR=<PATH>

or 

make install

Both will install pkg-config .pc file because the user has enabled pkg-config. However for otp_build release and make release cases, it will not take effect if the user hasn't enabled the pkg-config.

@joaohf joaohf force-pushed the erl_interface-pkg-config branch from f025908 to ddc7212 Compare March 20, 2021 21:08
@joaohf joaohf force-pushed the erl_interface-pkg-config branch from ddc7212 to eaa3e8e Compare March 31, 2021 02:06
joaohf added 2 commits March 30, 2021 23:17
pkg-config is a helper tool used when compiling applications and
libraries.

This commit introduces the file erl_ei.pc which will be installed
in the standard pkg-config directory.

Thus, using pkg-config like this:

    pkg-config --libs --cflags erl_ei

Returns the correct libs and cflags that can be used by build tools
(like autotools);

    -I/cross/sysroots/core2-32-vendor-linux/usr/lib/erlang/lib/erl_interface-4.0.2/include
    -L/cross/sysroots/core2-32-vendor-linux/usr/lib/erlang/lib/erl_interface-4.0.2/lib -lei

In order to enable the pkg-config installation a new configure option,
--enable-pkg-config, was introduced. The default is not install the
pkg-config file. And one could enable it using --enable-pkg-config
argument when calling configure script.
This commit introduces the file erl_erts.pc which will be installed
in the standard pkg-config directory.

Thus, using pkg-config like this:

    pkg-config --libs --cflags erl_erts

Returns the correct libs and cflags that can be used by build tools
(like autotools):

   -I/cross/sysroots/core2-32-vendor-linux/usr/lib/erlang/erts-11.1.8/include
@joaohf joaohf force-pushed the erl_interface-pkg-config branch from eaa3e8e to a004f4d Compare March 31, 2021 02:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team:VM Assigned to OTP team VM
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants