add --with-libfusepkg config option for custom lib

When configuring a user can provide a path to the fuse3.pc
pkg-config file in their custom libfuse build, and the configure
script will extract and set the appropriate compiler and linker
flags using pkg-config.

We prepend the flags to CPPFLAGS and LDFLAGS (unless they happen
to already have been provided, in which case we avoid duplicates).

This should ensure that the subsequent checks for fuse3 headers
and symbols succeeds, checking the custom libfuse path first
before searching for any other libfuse installations.
This commit is contained in:
Chris Darroch 2019-02-05 21:36:52 -08:00
Родитель 8153e4054c
Коммит 0492c6a26e
3 изменённых файлов: 78 добавлений и 1 удалений

2
.gitignore поставляемый
Просмотреть файл

@ -17,7 +17,7 @@
/libprojfs-*.tar.*z
/ltmain.sh
/m4/*
!/m4/ax_*.m4
!/m4/ax*.m4
/missing
/projfs.pc
/t/.prove

Просмотреть файл

@ -76,9 +76,38 @@ AC_SUBST([libprojfs_export_regex])
AC_CHECK_PROGS([DIFF], [diff])
AC_ARG_VAR([DIFF], [File comparison tool])
AC_CHECK_PROGS([PKGCONFIG], [pkg-config])
AC_ARG_VAR([PKGCONFIG], [Package configuration tool])
AC_CHECK_PROGS([PROVE], [prove])
AC_ARG_VAR([PROVE], [TAP harness command, e.g., 'prove -v'])
# TODO: remove explicit --with-libfusepkg when we no longer need a custom
# libfuse, and/or when we no longer use FUSE at all
AC_ARG_WITH([libfusepkg],
[AS_HELP_STRING([--with-libfusepkg=PCFILE],
[Use FUSE library with pkg-config .pc file PCFILE])]
)dnl
# NOTE: altering user-supplied CPPFLAGS and LDFLAGS is normally frowned upon,
# but we want to make using a custom libfuse installation easy
AS_IF([test ":$with_libfusepkg" != ":no" &&
test ":$with_libfusepkg" != ":yes" &&
test ":$with_libfusepkg" != ":"],
[AC_MSG_NOTICE([querying pkg-config using $with_libfusepkg file])
fuse_includedir=$("$PKGCONFIG" "$with_libfusepkg" --variable=includedir) ||
AC_MSG_ERROR([Failed to get libfuse include path using $with_libfusepkg])
fuse_libdir=$("$PKGCONFIG" "$with_libfusepkg" --variable=libdir) ||
AC_MSG_ERROR([Failed to get libfuse library path using $with_libfusepkg])
fuse_cppflags="-I$fuse_includedir"
AXLOCAL_PREPEND_FLAG([$fuse_cppflags], [CPPFLAGS])dnl
fuse_ldflags="-Wl,-R$fuse_libdir"
AXLOCAL_PREPEND_FLAG([$fuse_ldflags], [LDFLAGS])dnl
fuse_ldflags="-L$fuse_libdir"
AXLOCAL_PREPEND_FLAG([$fuse_ldflags], [LDFLAGS])dnl
]dnl
)dnl
pkgconfigdir='${libdir}/pkgconfig'
AC_ARG_WITH([pkgconfigdir],

48
m4/axlocal_prepend_flag.m4 поставляемый Normal file
Просмотреть файл

@ -0,0 +1,48 @@
# SYNOPSIS
#
# AXLOCAL_PREPEND_FLAG(FLAG, [FLAGS-VARIABLE])
#
# DESCRIPTION
#
# FLAG is prepended to the FLAGS-VARIABLE shell variable, with a space
# added in between.
#
# If FLAGS-VARIABLE is not specified, the current language's flags (e.g.
# CFLAGS) is used. FLAGS-VARIABLE is not changed if it already contains
# FLAG. If FLAGS-VARIABLE is unset in the shell, it is set to exactly
# FLAG.
#
# NOTE: Implementation based on AX_APPEND_FLAG by
# Guido U. Draheim <guidod@gmx.de> and
# Maarten Bosmans <mkbosmans@gmail.com>
#
# LICENSE
#
# Copyright (C) 2019 GitHub, Inc.
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 1
AC_DEFUN([AXLOCAL_PREPEND_FLAG],
[dnl
AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_SET_IF
AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])])
AS_VAR_SET_IF(FLAGS,[
AS_CASE([" AS_VAR_GET(FLAGS) "],
[*" $1 "*], [AC_RUN_LOG([: FLAGS already contains $1])],
[
AS_VAR_COPY(tmp_flags,FLAGS)
AS_VAR_SET(FLAGS,["$1 $tmp_flags"])
AC_RUN_LOG([: FLAGS="$FLAGS"])
])
],
[
AS_VAR_SET(FLAGS,[$1])
AC_RUN_LOG([: FLAGS="$FLAGS"])
])
AS_VAR_POPDEF([FLAGS])dnl
])dnl AXLOCAL_PREPEND_FLAG