What I want to do is to create a new shared library called libxxx that links against another shared library called libzzz, this shared library has an independent “pkg-config”-like tool, let’s say it’s called “zzz-config” which gives the cflags needed by the compilation phase when using the libzzz.
What I want to do is:
- Create configure/makefile, etc.. using autotools like automake, autoconf, etc;
- It must use the
zzz-configscript cited above; - It must generate automatic dependencies for sources;
- It must have a mode for building debug (with no optimization) and release (with optimizations) builds;
- The sources are in C++;
- It must target for a shared library;
- It must read sources for a
srcdirectory and put compiled files in another directory
I’ve read almost all available tutorials for autotools but I was not able to figure a way to do that, if you can point some example would be very kindly.
Thank you !
My suggestion is to use CMake instead of
autotools. It’s much easier to work with and it will also create platform-dependent projects to work with (i.e. Makefile-based projects, Visual Studio projects, Eclipse CDT projects, etc.).It will also create
debugorreleaseprojects, depending on theCMAKE_BUILD_TYPEvariable value.Creating the
libxxxlibrary is as simple as:where
LIBXXX_SOURCESis a variable that holds the sources.Linking the two libraries is just as easy (see target_link_libraries):
To get the compilation flags from the
zzz-configscript you would use the execute_process command like so:Then you can set the
CMAKE_C_FLAGSor theCMAKE_CXX_FLAGSvariable to setup the required compilation flags.