How to use automake/autoconf with subdirectories properly?

  automake, autotools, c++

I am looking to use automake for a project with a lot of subdirectories. What I want to achieve is compiling all of the source code in all of the subdirectories into one executable on linux.

Right now I am using subdir-objects where I have to manually specify the paths of each of the source code files for the entire heirarchy.

I had tried using LTLIBRARIES approach using Makefile.am for each of the subdirectories, but for some reason the program does not compile and gives me a lot of undefined reference errors.

And right now my Makefile.am file looks like this:

AUTOMAKE_OPTIONS = subdir-objects
bin_PROGRAMS = a.out
a_out_SOURCES = EntryPoint.cpp ./glad/src/glad.cpp ./ImageLoader/ImageLoader.cpp ./FileIO/FileIO.cpp ./Debug/DebugLog.cpp ./Object/Object.cpp 
./Texture/Texture.cpp ./Window/Window.cpp ./Shader/Shader.cpp
include_HEADERS = ./glad/include/glad/glad.h ./ImageLoader/stb_image.h ./FileIO/FileIO.h ./Debug/DebugLog.h ./Object/Object.h 
./Texture/Texture.h ./Window/Window.h ./Shader/Shader.h
a_out_LDADD = -lGLEW -lGL -lsfml-graphics -lsfml-window -lsfml-system -ldl -lglfw -lm

Is there a better way to do this?

Source: Windows Questions C++

LEAVE A COMMENT