diff --git a/.gitignore b/.gitignore
index 4868b2d33fec92b5959c28ff9e63297d62090ea6..f20a6c9fb8bf35dcff9c3e602e85e53f28aeafa4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,20 +1,19 @@
+build/aclocal.m4
+build/autom4te.cache
 build/aux/*
+build/config.*
+build/configure
+build/configure~
 build/cluster/*
+build/libtool
+build/Makefile
+build/Makefile.in
 build/sphere/*
 build/testing/*
 build/trapping/*
 build/libnptm/*
 containers/singularity/*.sif
 doc/build/*
-src/aclocal.m4
-src/autom4te.cache
-src/config.*
-src/configure
-src/configure~
-src/libtool
-src/m4
-src/Makefile
-src/Makefile.in
 src/*/.deps
 src/*/objects/*
 src/*/dynobjects/*
diff --git a/build/Makefile.am b/build/Makefile.am
new file mode 100644
index 0000000000000000000000000000000000000000..de0719e43d884037d7fb6b5a7e4102fb8964901b
--- /dev/null
+++ b/build/Makefile.am
@@ -0,0 +1,16 @@
+AUTOMAKE_OPTIONS=subdir-objects
+lib_LTLIBRARIES=libnptm.la
+libnptm_la_SOURCES=../src/libnptm/algebraic.cpp ../src/libnptm/clu_subs.cpp ../src/libnptm/Commons.cpp ../src/libnptm/Configuration.cpp ../src/libnptm/file_io.cpp ../src/libnptm/lapack_calls.cpp ../src/libnptm/logging.cpp ../src/libnptm/magma_calls.cpp ../src/libnptm/Parsers.cpp ../src/libnptm/sph_subs.cpp ../src/libnptm/tfrfme.cpp ../src/libnptm/TransitionMatrix.cpp ../src/libnptm/tra_subs.cpp ../src/libnptm/types.cpp
+bin_PROGRAMS=edfb_clu clu np_cluster edfb_sph sph np_sphere frfme lffft np_trapping
+edfb_clu_SOURCES=../src/cluster/edfb_clu.f
+clu_SOURCES=../src/cluster/clu.f
+np_cluster_SOURCES=../src/cluster/np_cluster.cpp ../src/cluster/cluster.cpp
+edfb_sph_SOURCES=../src/sphere/edfb_sph.f
+sph_SOURCES=../src/sphere/sph.f
+np_sphere_SOURCES=../src/sphere/np_sphere.cpp ../src/sphere/sphere.cpp
+frfme_SOURCES=../src/trapping/frfme.f
+lffft_SOURCES=../src/trapping/lffft.f
+np_trapping_SOURCES=../src/trapping/np_trapping.cpp ../src/trapping/cfrfme.cpp ../src/trapping/clffft.cpp
+check_PROGRAMS=test_TEDF test_TTMS
+test_TEDF_SOURCES=../src/testing/test_TEDF.cpp
+test_TTMS_SOURCES=../src/testing/test_TTMS.cpp
diff --git a/src/configure.ac b/build/configure.ac
similarity index 91%
rename from src/configure.ac
rename to build/configure.ac
index 57f5b735964079bcebd32985d40fd552e8efa735..14554b1513045008accadbebb1cde55ba23689d7 100644
--- a/src/configure.ac
+++ b/build/configure.ac
@@ -6,10 +6,10 @@
 AC_INIT([np_tmcode], [8.04], [giovanni.lamura@inaf.it])
 
 # Folder structure safety check
-AC_CONFIG_SRCDIR([libnptm/TransitionMatrix.cpp])
+AC_CONFIG_SRCDIR([../src/libnptm/TransitionMatrix.cpp])
 
 # Auxiliary build folder
-AC_CONFIG_AUX_DIR([../build/aux])
+AC_CONFIG_AUX_DIR([aux])
 
 # automake initialization
 AM_INIT_AUTOMAKE([-Wall -Werror foreign])
diff --git a/src/Makefile.am b/src/Makefile.am
deleted file mode 100644
index 037d6dc3f4716f90fd53dc30849636760ed2eb42..0000000000000000000000000000000000000000
--- a/src/Makefile.am
+++ /dev/null
@@ -1,16 +0,0 @@
-AUTOMAKE_OPTIONS=subdir-objects
-lib_LTLIBRARIES=libnptm.la
-libnptm_la_SOURCES=libnptm/algebraic.cpp libnptm/clu_subs.cpp libnptm/Commons.cpp libnptm/Configuration.cpp libnptm/file_io.cpp libnptm/lapack_calls.cpp libnptm/logging.cpp libnptm/magma_calls.cpp libnptm/Parsers.cpp libnptm/sph_subs.cpp libnptm/tfrfme.cpp libnptm/TransitionMatrix.cpp libnptm/tra_subs.cpp libnptm/types.cpp
-bin_PROGRAMS=edfb_clu clu np_cluster edfb_sph sph np_sphere frfme lffft np_trapping
-edfb_clu_SOURCES=cluster/edfb_clu.f
-clu_SOURCES=cluster/clu.f
-np_cluster_SOURCES=cluster/np_cluster.cpp cluster/cluster.cpp
-edfb_sph_SOURCES=sphere/edfb_sph.f
-sph_SOURCES=sphere/sph.f
-np_sphere_SOURCES=sphere/np_sphere.cpp sphere/sphere.cpp
-frfme_SOURCES=trapping/frfme.f
-lffft_SOURCES=trapping/lffft.f
-np_trapping_SOURCES=trapping/np_trapping.cpp trapping/cfrfme.cpp trapping/clffft.cpp
-check_PROGRAMS=test_TEDF test_TTMS
-test_TEDF_SOURCES=testing/test_TEDF.cpp
-test_TTMS_SOURCES=testing/test_TTMS.cpp