I'm working on a project in C++ where I'd wish to implement the ability to add plugins. The compilation process is handled by Autotools. I've managed to set the file structure correct, and both the main project and the plugins are compiled, but for some reason the plugins are omitted when running make install
. When compiling and installing the plugins separately it works fine. Am I missing something here, or why are the plugins not installed from the top folder?
configure.ac
AC_PREREQ(2.58)
AC_INIT([Net Responsibility],[3.1r323],[[email protected]])
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
plugins/defaultReport/configure.ac
AC_PREREQ(2.58)
AC_INIT([Net Responsibility Plugin: Default Report],[0.1],[[email protected]])
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
plugins/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@
You need to setup nrlibdir
a little differently:
plugins/defaultReport/configure.ac
Remove this line:
AC_SUBST([nrlibdir], ["${libdir}/net-responsibility"])
plugins/defaultReport/Makefile.am
Add this line before nrlib_LTLIBRARIES
:
nrlibdir=$(libdir)/net-responsibility
This should help automake
get make install
right.
EDIT: I actually tried it this time. In addition to the above changes, remove the
install
and uninstall
targets in Makefile.am
. You should be attaching the postinst
, prerm
and postrm
targets to some other install hooks, perhaps something like:
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
Would work instead of those targets.