I have the following files
├── configure.ac
├── main.cpp
├── Makefile.am
└── procs
├── Makefile.am
├── proc1
│ └── subprocs
│ ├── subprocA
│ │ ├── ProcA_SubprocA.cc
│ │ └── ProcA_SubprocA.h
│ └── subprocB
│ ├── ProcA_SubprocB.cc
│ └── ProcA_SubprocB.h
├── proc2
│ └── subprocs
│ ├── subprocA
│ │ ├── ProcB_SubprocA.cc
│ │ └── ProcB_SubprocA.h
│ └── subprocB
│ ├── ProcB_SubprocB.cc
│ └── ProcB_SubprocB.h
└── Subprocs.h
My goal is to create a library from everything in procs so it can be used in main.cpp which could look something like this:
main.cpp
#include "Subprocs.h"
int main(){
ProcA_SubprocA * p = new ProcA_SubprocA();
p->use();
delete p;
return 0;
}
I would like to have all the includes of the subprocs in Subprocs.h, so it can be used as some kind of interface:
Subprocs.h
#include "ProcA_SubprocA.h"
#include "ProcA_SubprocB.h"
#include "ProcB_SubprocA.h"
#include "ProcB_SubprocB.h"
My configure.ac looks like this:
configure.ac
AC_PREREQ([2.69])
AC_INIT([main], [0.1])
AM_INIT_AUTOMAKE([foreign subdir-objects])
#AC_CONFIG_MACRO_DIR([m4])
#LT_INIT
AC_PROG_CXX
AC_PROG_CC
AC_PROG_RANLIB
AC_CONFIG_FILES([Makefile procs/Makefile])
AC_OUTPUT
and my Makefile.am's like this
Makefile.am
SUBDIRS = procs
AM_CPPFLAGS = -Iprocs
bin_PROGRAMS = main
main_SOURCES = main.cpp
#added:
main_LDADD = procs/libprocs.a
#ACLOCAL_AMFLAGS = -I m4
procs/Makefile.am
AM_CPPFLAGS = -Iproc1/subprocs/subprocA -Iproc1/subprocs/subprocB \
-Iproc2/subprocs/subprocA -Iproc2/subprocs/subprocB
#lib_LIBRARIES = libprocs.la
noinst_LIBRARIES = libprocs.a
libprocs_a_SOURCES = Subprocs.h \
proc1/subprocs/subprocA/ProcA_SubprocA.cc proc1/subprocs/subprocA/ProcA_SubprocA.h \
proc1/subprocs/subprocB/ProcA_SubprocB.cc proc1/subprocs/subprocB/ProcA_SubprocB.h \
proc2/subprocs/subprocA/ProcB_SubprocA.cc proc2/subprocs/subprocA/ProcB_SubprocA.h \
proc2/subprocs/subprocB/ProcB_SubprocB.cc proc2/subprocs/subprocB/ProcB_SubprocB.h
When I type
#libtoolize && autoreconf -i -f && ./configure && make
autoreconf -i -f && ./configure && make
I get a file called libprocs.la in procs but I don't get a binary. I am also fairly certain that my Makefiles are wrong since I can't even compile main.cpp by hand.
Is it at all possible to do what I want here? Or am I overthinking this and I don't even need a library in the first place? The important part for me is that main.cpp only includes Subprocs.h which then contains all includes of the subprocs.
Thank you in advance!
libtoolizemodifies yourMakefile.amandconfigure.acfiles, which is why you mustautoreconfafterwards. If that's the way you intend to go (and it's by no means wrong) then thelibtoolizeandautoreconfshould be done once, not as part of every build. Moreover, in that case it would be the post-libtoolizefiles that would be relevant to this question (it looks like that may indeed be what you presented, but please clarify). - John Bollinger