diff --git a/astylerc b/astylerc
index 0170fbdc9431c1f5875bf75231dd88f8c692b06c..460124f66d7a1f71a6c4d0a168f9502e4755a059 100644
--- a/astylerc
+++ b/astylerc
@@ -12,4 +12,5 @@ indent-switches         # Indent 'switch' blocks so that the 'case X:' statement
 break-blocks            # Pad empty lines around header blocks (e.g. 'if', 'while'...).
 brackets=linux
 unpad=paren
+formatted
 -d
diff --git a/sflphone-common/Makefile.am b/sflphone-common/Makefile.am
index c5de2501fbb765d640061938f15ce4b259270a3a..22a5bfd63002c0aad55e909ccf821d0dd87b2988 100644
--- a/sflphone-common/Makefile.am
+++ b/sflphone-common/Makefile.am
@@ -24,13 +24,6 @@ doc:
 	@echo "D-Bus API HTML documentation has been generated in doc/dbus-api/doc/spec"
 	@echo ""
 
-indent:
-	@echo "Indenting code:"
-	if [ -f $(ASTYLERC) ] ; then \
-		$(indent) --options=$(ASTYLERC) --recursive *.cpp *.h; \
-	fi
-
-
 ACLOCAL_AMFLAGS = -I m4
 SUBDIRS = libs src ringtones man $(TESTS_DIR)
 EXTRA_DIST = m4/*.m4 tools/*.sh platform/* images/* README.gentoo
diff --git a/sflphone-common/globals.mak b/sflphone-common/globals.mak
index 345259a8ebd841547b2a9de24a508b6aba9d451a..82d93933f2b3021a08126d10db88adbb8267fd4a 100644
--- a/sflphone-common/globals.mak
+++ b/sflphone-common/globals.mak
@@ -7,7 +7,7 @@ sfllibdir=$(DESTDIR)$(libdir)/sflphone
 sflcodecdir=$(sfllibdir)/codecs
 sflplugindir=$(sfllibdir)/plugins
 
-ASTYLERC="../astylerc"
+ASTYLERC="$(top_srcdir)/../astylerc"
 indent="/usr/bin/astyle"
 
 # for pjsip
@@ -69,3 +69,10 @@ AM_CPPFLAGS = \
 	-DENABLE_TRACE \
          $(SPEEXCODEC) \
          $(GSMCODEC)
+
+
+indent:
+	@echo "Indenting code:"
+	if [ -f $(ASTYLERC) ] ; then \
+		find $(top_srcdir)/src/ -regex ".*\.\(h\|cpp\)" -exec $(indent) --options=$(ASTYLERC) {} \; ; \
+	fi
diff --git a/sflphone-common/src/Makefile.am b/sflphone-common/src/Makefile.am
index d97477c85f4debd7a397253f4053b4ebeb966c89..fff35078332d02e3e7d3abe45747ec52f11dee66 100644
--- a/sflphone-common/src/Makefile.am
+++ b/sflphone-common/src/Makefile.am
@@ -102,9 +102,4 @@ libsflphone_la_CFLAGS = \
 
 libsflphone_la_SOURCES =
 
-indent:
-	@echo "Indenting code:"
-	if [ -f $(ASTYLERC) ] ; then \
-		$(indent) --options=$(ASTYLERC) --recursive *.cpp *.h; \
-	fi
-
+all: indent