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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion configure.src
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ help=no
user_srcdir=
config_arguments=
skip_applications=
pkg_config=no
while test $# != 0; do
case $1 in
-srcdir=* | --srcdir=*)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions erts/configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 ----------------------------------------------------------------------
Expand All @@ -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],
Expand Down
19 changes: 18 additions & 1 deletion erts/emulator/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -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@
Expand Down Expand Up @@ -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"
Expand Down
31 changes: 31 additions & 0 deletions erts/erl_erts.pc.in
Original file line number Diff line number Diff line change
@@ -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
18 changes: 16 additions & 2 deletions lib/erl_interface/configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -58,6 +58,9 @@ else
host_os=win32
fi

EI_VERSION=ei_version
AC_SUBST(EI_VERSION)

TARGET=$host
AC_SUBST(TARGET)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
)
31 changes: 31 additions & 0 deletions lib/erl_interface/erl_ei.pc.in
Original file line number Diff line number Diff line change
@@ -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
19 changes: 18 additions & 1 deletion lib/erl_interface/src/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
#
Expand Down Expand Up @@ -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"
Expand Down