From 62ccf3248fb0eff8d65e8debea793ea7552bf00f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Henrique=20Ferreira=20de=20Freitas?= Date: Tue, 30 Mar 2021 23:17:29 -0300 Subject: [PATCH 1/2] Add pkg-config support for erl_interface 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. --- configure.src | 14 +++++++++++++- lib/erl_interface/configure.in | 18 ++++++++++++++++-- lib/erl_interface/erl_ei.pc.in | 31 +++++++++++++++++++++++++++++++ lib/erl_interface/src/Makefile.in | 19 ++++++++++++++++++- 4 files changed, 78 insertions(+), 4 deletions(-) create mode 100644 lib/erl_interface/erl_ei.pc.in diff --git a/configure.src b/configure.src index c0a195b147a8..987d25a66ed5 100644 --- a/configure.src +++ b/configure.src @@ -48,6 +48,7 @@ help=no user_srcdir= config_arguments= skip_applications= +pkg_config=no while test $# != 0; do case $1 in -srcdir=* | --srcdir=*) @@ -135,7 +136,10 @@ while test $# != 0; do pie_cflags="-fno-PIE" pie_ldflags="-no-pie" ;; - CFLAGS=* | LDFLAGS=*) + --enable-pkg-config) + pkg_config=yes + ;; + CFLAGS=* | LDFLAGS=*) flgs_var=`expr "$1" : '\([^=]*\)=.*'` flgs_val=`expr "$1" : '[^=]*=\(.*\)'` eval $flgs_var=\$flgs_val @@ -308,6 +312,14 @@ else esac fi +case "$pkg_config" in + no) + ;; + yes) + config_arguments="$config_arguments --enable-pkg-config" + ;; +esac + config_arguments="$config_arguments --disable-option-checking" if test $bootstrap_only = no; then diff --git a/lib/erl_interface/configure.in b/lib/erl_interface/configure.in index fa07048424f0..d4982da9c7a3 100644 --- a/lib/erl_interface/configure.in +++ b/lib/erl_interface/configure.in @@ -24,8 +24,8 @@ # Find the erl_interface version number and set m4 macro to it. # We do this because AC_INIT can't handle shell variables. Still broken. -dnl m4_define(EI_VERSION,`grep EI_VSN ../vsn.mk | sed 's/^.*=[ ]*//'`) -dnl m4_define(EI_VERSION,regexp(m4_include(VERSION),[version \([-.0-9A-Za-z]+\)],[\1])) +m4_define([ei_version],`grep EI_VSN $srcdir/vsn.mk | sed 's/^.*=[ ]*//' | awk 'NR==1{print $1}'`) +#dnl m4_define(EI_VERSION,regexp(m4_include(VERSION),[version \([-.0-9A-Za-z]+\)],[\1])) AC_INIT() @@ -58,6 +58,9 @@ else host_os=win32 fi +EI_VERSION=ei_version +AC_SUBST(EI_VERSION) + TARGET=$host AC_SUBST(TARGET) @@ -85,6 +88,16 @@ AC_ARG_ENABLE(mask-real-errno, esac ], [ mask_real_errno=yes ]) +AC_ARG_ENABLE(pkg-config, +[ --enable-pkg-config install pkg-config file], +[ case "$enableval" in + no) enable_pkg_config= ;; + *) enable_pkg_config=yes ;; + esac ], +[ enable_pkg_config= ]) + +ENABLE_PKG_CONFIG=$enable_pkg_config +AC_SUBST(ENABLE_PKG_CONFIG) dnl ---------------------------------------------------------------------- dnl Checks for programs @@ -374,4 +387,5 @@ LDFLAGS="$LDFLAGS $sanitizers" AC_OUTPUT( src/$host/Makefile:src/Makefile.in src/$host/eidefs.mk:src/eidefs.mk.in + src/$host/erl_ei.pc:erl_ei.pc.in ) diff --git a/lib/erl_interface/erl_ei.pc.in b/lib/erl_interface/erl_ei.pc.in new file mode 100644 index 000000000000..0b5d439af197 --- /dev/null +++ b/lib/erl_interface/erl_ei.pc.in @@ -0,0 +1,31 @@ +/* + * %CopyrightBegin% + * + * Copyright Ericsson AB 1998-2021. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * %CopyrightEnd% + */ +prefix=@prefix@/lib/erlang/lib/erl_interface +version=@EI_VERSION@ +includedir=${prefix}-${version}/include +libdir=${prefix}-${version}/lib + +Name: erl_ei +Description: The Erl_Interface library contains \ + functions that help you integrate programs \ + written in C and Erlang. +Version: ${version} +Cflags: -I${includedir} +Libs: -L${libdir} -lei diff --git a/lib/erl_interface/src/Makefile.in b/lib/erl_interface/src/Makefile.in index 061fd05a1d9d..816c05e94866 100644 --- a/lib/erl_interface/src/Makefile.in +++ b/lib/erl_interface/src/Makefile.in @@ -42,6 +42,10 @@ include $(TARGET)/eidefs.mk include $(ERL_TOP)/make/output.mk +prefix = @prefix@ +exec_prefix = @exec_prefix@ +libdir = @libdir@ + EBINDIR=../ebin APP_FILE= erl_interface.app @@ -114,6 +118,8 @@ INSTALL_DIR = @INSTALL_DIR@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ +ENABLE_PKG_CONFIG = @ENABLE_PKG_CONFIG@ + # The default library (no extra extension in name) is for Unix with # thread support if exists. For windows MD is the default. # @@ -668,7 +674,18 @@ EXTRA = \ README.internal \ $(TARGET)/eidefs.mk -release: opt +PKG-CONFIG = \ + $(TARGET)/erl_ei.pc + +ifdef ENABLE_PKG_CONFIG +pkg-config: + $(INSTALL_DIR) "$(DESTDIR)/$(libdir)/pkgconfig" + $(INSTALL_DATA) $(PKG-CONFIG) "$(DESTDIR)/$(libdir)/pkgconfig" +else +pkg-config: +endif + +release: opt pkg-config $(INSTALL_DIR) "$(RELSYSDIR)/include" $(INSTALL_DIR) "$(RELSYSDIR)/lib" $(INSTALL_DIR) "$(RELSYSDIR)/bin" From a004f4dc714a6a0103ac2ac20c64c3d122fd3214 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Henrique=20Ferreira=20de=20Freitas?= Date: Tue, 30 Mar 2021 23:17:11 -0300 Subject: [PATCH 2/2] Add pkg-config support for erts 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 --- erts/configure.in | 22 ++++++++++++++++++++++ erts/emulator/Makefile.in | 19 ++++++++++++++++++- erts/erl_erts.pc.in | 31 +++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 erts/erl_erts.pc.in diff --git a/erts/configure.in b/erts/configure.in index 418a111922f1..14373e1ec25f 100644 --- a/erts/configure.in +++ b/erts/configure.in @@ -21,11 +21,16 @@ dnl %CopyrightEnd% dnl The string "FIXME convbreak" means that there is a break of dnl autoconf convention that should be cleaned up. +m4_define([erts_version],`grep VSN $srcdir/vsn.mk | sed 's/^.*=[ ]*//' | awk 'NR==1{print $1}'`) + AC_INIT(vsn.mk) AC_PREREQ(2.59) LM_PRECIOUS_VARS +ERTS_VERSION=erts_version +AC_SUBST(ERTS_VERSION) + dnl We check if -Werror was given on command line and if so dnl we disable it for the configure and only use it when dnl actually building erts @@ -3592,6 +3597,22 @@ CFLAGS="$CFLAGS $sanitizers" LDFLAGS="$LDFLAGS $sanitizers" ]) + +dnl ---------------------------------------------------------------------- +dnl Enable pkg-config. +dnl ---------------------------------------------------------------------- + +AC_ARG_ENABLE(pkg-config, +[ --enable-pkg-config install pkg-config file], +[ case "$enableval" in + no) enable_pkg_config= ;; + *) enable_pkg_config=yes ;; + esac ], +[ enable_pkg_config= ]) + +ENABLE_PKG_CONFIG=$enable_pkg_config +AC_SUBST(ENABLE_PKG_CONFIG) + dnl ---------------------------------------------------------------------- dnl Output the result. dnl ---------------------------------------------------------------------- @@ -3605,6 +3626,7 @@ AC_CONFIG_FILES([ include/internal/$host/erts_internal.mk:include/internal/erts_internal.mk.in lib_src/$host/Makefile:lib_src/Makefile.in ../make/$host/otp.mk:../make/otp.mk.in + emulator/$host/erl_erts.pc:erl_erts.pc.in ]) AC_CONFIG_FILES([../make/make_emakefile:../make/make_emakefile.in], diff --git a/erts/emulator/Makefile.in b/erts/emulator/Makefile.in index c3449c5f7398..f1c6bf9baa9e 100644 --- a/erts/emulator/Makefile.in +++ b/erts/emulator/Makefile.in @@ -23,6 +23,12 @@ include ../vsn.mk include $(ERL_TOP)/make/$(TARGET)/otp.mk -include $(TARGET)/gen_git_version.mk +prefix = @prefix@ +exec_prefix = @exec_prefix@ +libdir = @libdir@ + +ENABLE_PKG_CONFIG = @ENABLE_PKG_CONFIG@ + ENABLE_ALLOC_TYPE_VARS = @ENABLE_ALLOC_TYPE_VARS@ JIT_ENABLED=@JIT_ENABLED@ JIT_ARCH=@JIT_ARCH@ @@ -506,12 +512,23 @@ ifeq ($(TARGET),win32) RELEASE_INCLUDES += sys/$(ERLANG_OSTYPE)/erl_win_dyn_driver.h endif +PKG-CONFIG = \ + $(TARGET)/erl_erts.pc + +ifdef ENABLE_PKG_CONFIG +pkg-config: + $(INSTALL_DIR) "$(DESTDIR)/$(libdir)/pkgconfig" + $(INSTALL_DATA) $(PKG-CONFIG) "$(DESTDIR)/$(libdir)/pkgconfig" +else +pkg-config: +endif + .PHONY: release_spec ifdef VOID_EMULATOR release_spec: @echo $(VOID_EMULATOR)' - omitted target release_spec (install)' else -release_spec: all +release_spec: all pkg-config $(INSTALL_DIR) "$(RELSYSDIR)" $(INSTALL_DIR) "$(RELSYSDIR)/src" $(INSTALL_DIR) "$(RELSYSDIR)/include" diff --git a/erts/erl_erts.pc.in b/erts/erl_erts.pc.in new file mode 100644 index 000000000000..d32955b51aa2 --- /dev/null +++ b/erts/erl_erts.pc.in @@ -0,0 +1,31 @@ +/* + * %CopyrightBegin% + * + * Copyright Ericsson AB 1998-2021. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * %CopyrightEnd% + */ +prefix=@prefix@/lib/erlang/erts +version=@ERTS_VERSION@ +includedir=${prefix}-${version}/include +libdir=${prefix}-${version}/lib + +Name: erl_erts +Description: The Erlang Runtime System Application, ERTS, contains \ + include file for erlang driver and \ + Native Implemented Functions writers. +Version: ${version} +Cflags: -I${includedir} +Libs: -L${libdir} -lerts