我正在使用C ++开发一个项目,我希望能够实现添加插件的功能。编译过程由Autotools处理。我已设法正确设置文件结构,并且主项目和插件都已编译,但出于某种原因,在运行make install
时省略了插件。单独编译和安装插件时,它可以正常工作。我在这里遗漏了什么,或者为什么没有从顶层文件夹安装插件?
configure.ac
AC_PREREQ(2.58)
AC_INIT([Net Responsibility],[3.1r323],[contact@netresponsibility.com])
AC_SUBST([LIBTOOL_DEPS])
AC_CONFIG_AUX_DIR([.])
AC_CONFIG_SRCDIR([src/main.cpp])
AC_CONFIG_SUBDIRS([plugins/defaultReport])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([scripts/m4])
AC_CANONICAL_SYSTEM
AC_LANG([C++])
AC_PREFIX_PROGRAM([make])
AM_INIT_AUTOMAKE([subdir-objects])
LT_PREREQ([2.2])
LT_INIT([shared])
# Checks for programs.
AC_PROG_CXX
AC_PROG_INSTALL
# Checks for header files.
AC_HEADER_STDC
...
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
Makefile.am
# Main library
lib_LTLIBRARIES = libNetResponsibility.la
libNetResponsibility_la_SOURCES = \
@top_srcdir@/src/MainApplication.cpp\
...
libNetResponsibility_la_CPPFLAGS = $(cppFlags)
libNetResponsibility_la_LDFLAGS = -no-undefined $(ldFlags)
# Minimal executable
bin_PROGRAMS = net-responsibility
net_responsibility_SOURCES = @top_srcdir@/src/main.cpp
net_responsibility_LDADD = -lNetResponsibility
dist_pkgdata_DATA = \
$(top_srcdir)/data/txt.xml\
$(top_srcdir)/COPYING
dist_pkgdata_SCRIPTS = $(top_srcdir)/scripts/init.d
dist_noinst_SCRIPTS = $(top_srcdir)/scripts/postinst\
$(top_srcdir)/scripts/prerm
AM_LDFLAGS = -L/usr/local/lib -L/usr/lib
ACLOCAL_AMFLAGS = -I scripts/m4
incDirs = -I$(top_srcdir)/include
ldFlags = -L/usr/local/lib -L/usr/lib
cppFlags = $(incDirs)\
-DPKGDATADIR='$(pkgdatadir)'\
-DPKGLIBDIR='$(pkglibdir)'\
-DDATABASEDIR='$(databasedir)'\
-DPIDDIR='$(piddir)'\
@CPPFLAGS@
AM_CXXFLAGS = $(incDirs) @CXXFLAGS@
AM_CPPFLAGS = $(cppFlags)
EXTRA_DIST = $(top_srcdir)/lib $(top_srcdir)/include
SUBDIRS = . plugins/defaultReport
install: install-am postinst
uninstall: prerm uninstall-am postrm
postinst:
$(top_srcdir)/scripts/postinst $(pkgdatadir) $(initdir)
prerm:
$(top_srcdir)/scripts/prerm $(pkgdatadir) $(initdir)
postrm:
rm -f $(piddir)/net-responsibility.pid
rm -f $(pkgdatadir)/blacklist.xml
rm -f $(pkgdatadir)/config.xml
rm -rf $(pkgdatadir)/reports
rm -f $(databasedir)/net-responsibility.db
rm -f $(initdir)/net-responsibility
.PHONY: prerm postinst postrm
插件/ defaultReport / configure.ac
AC_PREREQ(2.58)
AC_INIT([Net Responsibility Plugin: Default Report],[0.1],[contact@netresponsibility.com])
AC_SUBST([LIBTOOL_DEPS])
AC_SUBST([nrlibdir], ["${libdir}/net-responsibility"])
AC_CONFIG_AUX_DIR([.])
AC_CONFIG_SRCDIR([src/Report.cpp])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])
AC_LANG([C++])
AC_PREFIX_PROGRAM([make])
AM_INIT_AUTOMAKE([subdir-objects])
LT_PREREQ([2.2])
LT_INIT([shared])
# Checks for programs.
AC_PROG_CXX
AC_PROG_INSTALL
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
插件/ defaultReport / Makefile.am
# General settings
ACLOCAL_AMFLAGS = -I m4
ldFlags = -L/usr/local/lib -L/usr/lib
AM_CXXFLAGS = @CXXFLAGS@
# Module specific settings
nrlib_LTLIBRARIES = defaultReport.la
defaultReport_la_SOURCES = \
src/Report.cpp
defaultReport_la_LDFLAGS = -module -no-undefined $(ldFlags)
defaultReport_la_LIBADD = -lNetResponsibility
defaultReport_la_CPPFLAGS = -I../../include @CPPFLAGS@
答案 0 :(得分:2)
您需要稍微设置nrlibdir
:
<强>插件/ defaultReport / configure.ac 强>
删除此行:
AC_SUBST([nrlibdir], ["${libdir}/net-responsibility"])
<强>插件/ defaultReport / Makefile.am 强>
在nrlib_LTLIBRARIES
之前添加此行:
nrlibdir=$(libdir)/net-responsibility
这应有助于automake
让make install
正确。
install
中的uninstall
和Makefile.am
个目标。您应该将postinst
,prerm
和postrm
目标附加到其他一些安装挂钩,可能类似于:
install-data-hook:
$(top_srcdir)/scripts/postinst $(pkgdatadir) $(initdir)
uninstall-local:
$(top_srcdir)/scripts/prerm $(pkgdatadir) $(initdir)
uninstall-hook:
rm -f $(piddir)/net-responsibility.pid
rm -f $(pkgdatadir)/blacklist.xml
rm -f $(pkgdatadir)/config.xml
rm -rf $(pkgdatadir)/reports
rm -f $(databasedir)/net-responsibility.db
rm -f $(initdir)/net-responsibility
将会有效而不是那些目标。