我正在编写一个 r 包,它为libSBML
C库提供了一个包装器。
我使用rcppgsl
包作为参考,它查找头文件和 GNU 科学库的库文件的位置,GSL
并使用该信息编写configure
脚本Makevars
和Makevars.in
. 我目前不是为 Windows 构建的。在我的机器(macOS)上,libsbml
(SBML C 库)安装在通常的位置,即
头文件位于 -/usr/local/include/sbml
和库文件在 - /usr/local/lib
。事实上,如果在我的包Makevars
文件中使用以下内容,我可以构建我的包。
CXX=clang++
PKG_CPPFLAGS= -I/usr/local/include
PKG_LIBS= $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) /usr/local/lib/libsbml-static.a
但是,我想学习如何使用configure
脚本来查找库并使用该信息来构建包。configure.ac
from的相关部分rcppgsl
是
## Check for non-standard programs: gsl-config(1)
AC_PATH_PROG([GSL_CONFIG], [gsl-config])
## If gsl-config was found, let's use it
if test "${GSL_CONFIG}" != ""; then
# Use gsl-config for header and linker arguments
GSL_CFLAGS=`${GSL_CONFIG} --cflags`
GSL_LIBS=`${GSL_CONFIG} --libs`
else
AC_MSG_ERROR([gsl-config not found, is GSL installed?])
fi
我在相关位置替换GSL_CONFIG
为LIB_SBML
,即configure.ac
我正在使用的整个文件粘贴在下面(最后)。
但是,我没有看到configure
,Makevars
并且Makevars.in
正在生成(我在 中看到rcppgsl
)。这里的任何帮助将不胜感激!
为了完整起见,
ls -l | grep sbml
(in usr/local/include
) 的输出为
drwxrwxr-x 58 root admin 1856 Aug 1 2016 sbml
和ls -l | grep sbml
(in usr/local/lib
) 是
-rw-r--r-- 1 root wheel 7970584 Aug 2 2016 libsbml-static.a
-rwxr-xr-x 1 arcadmin staff 10453624 Nov 25 2014 libsbml.5.11.0.dylib
-rwxr-xr-x 1 root wheel 3813572 Aug 2 2016 libsbml.5.13.0.dylib
lrwxr-xr-x 1 root wheel 20 Aug 1 2016 libsbml.5.dylib -> libsbml.5.13.0.dylib
-rw-r--r-- 1 root wheel 13907656 Feb 26 2015 libsbml.a
lrwxr-xr-x 1 arcadmin staff 15 Mar 27 2015 libsbml.dylib -> libsbml.5.dylib
-rwxr-xr-x 1 root wheel 828 Feb 26 2015 libsbml.la
-rwxrwxr-x 1 root admin 13362732 Nov 25 2014 libsbmlj.jnilib
我的configure.ac
档案——
## Process this file with autoconf to produce a configure script.
##
## Configure.ac for RcppSBML
##
## Copyright (C) 2010 Romain Francois and Dirk Eddelbuettel
## Copyright (C) 2014 - 2015 Dirk Eddelbuettel
##
## Licensed under GNU GPL 2 or later
# The version set here will propagate to other files from here
AC_INIT([Rcppsbml], 0.1.0)
# Checks for common programs using default macros
AC_PROG_CC
## Use gsl-config to find arguments for compiler and linker flags
##
## Check for non-standard programs: gsl-config(1)
AC_PATH_PROG([LIB_SBML], [libsbml])
## If gsl-config was found, let's use it
if test "${LIB_SBML}" != ""; then
# Use gsl-config for header and linker arguments
SBML_CFLAGS=`${LIB_SBML} --cflags`
SBML_LIBS=`${LIB_SBML} --libs`
else
AC_MSG_ERROR([libsbml not found, is SBML installed?])
fi
# Now substitute these variables in src/Makevars.in to create src/Makevars
AC_SUBST(LIB_SBML)
AC_SUBST(LIB_SBML)
AC_OUTPUT(src/Makevars)