From 91450723b277fc8fa2d4bcfecb762c30ab7bfb21 Mon Sep 17 00:00:00 2001
From: Warren Dukes <warren.dukes@gmail.com>
Date: Thu, 18 Mar 2004 03:29:25 +0000
Subject: [PATCH] bunch of autotool cleanups

git-svn-id: https://svn.musicpd.org/mpd/trunk@271 09075e82-0dd4-0310-85a5-a0d7c8717e4f
---
 autogen.sh             |  3 ++
 configure.ac           | 64 ++++++++++++++++++++++++------------------
 makedist.sh            |  2 +-
 src/Makefile.am        |  2 ++
 src/audio.h            |  2 ++
 src/audiofile_decode.c |  4 +--
 src/audiofile_decode.h |  2 ++
 src/buffer2array.h     |  2 ++
 src/charConv.h         |  2 ++
 src/command.h          |  2 ++
 src/conf.h             |  2 ++
 src/decode.h           |  5 ++--
 src/directory.h        |  2 ++
 src/flac_decode.c      |  3 +-
 src/flac_decode.h      |  2 ++
 src/interface.h        |  2 ++
 src/list.h             |  2 ++
 src/listen.h           |  2 ++
 src/log.h              |  2 ++
 src/ls.c               | 30 --------------------
 src/ls.h               |  4 +--
 src/mp3_decode.c       |  3 +-
 src/mp3_decode.h       |  2 ++
 src/mpd_types.h        |  2 ++
 src/myfprintf.h        |  2 ++
 src/ogg_decode.c       |  3 +-
 src/ogg_decode.h       |  2 ++
 src/path.c             | 12 ++++----
 src/path.h             |  2 ++
 src/pcm_utils.h        |  2 ++
 src/permission.h       |  2 ++
 src/player.c           |  1 -
 src/player.h           |  2 ++
 src/playerData.h       |  2 ++
 src/playlist.h         |  2 ++
 src/sig_handlers.h     |  2 ++
 src/song.c             |  6 ----
 src/song.h             |  2 ++
 src/stats.h            |  2 ++
 src/tables.h           |  2 ++
 src/tag.c              | 16 -----------
 src/tag.h              |  3 +-
 src/utils.h            |  2 ++
 src/volume.h           |  2 ++
 44 files changed, 119 insertions(+), 98 deletions(-)

diff --git a/autogen.sh b/autogen.sh
index 01a1e2a5d..272b13746 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -107,6 +107,9 @@ fi
 echo "  $ACLOCAL $ACLOCAL_FLAGS"
 $ACLOCAL $ACLOCAL_FLAGS
 
+echo "  autoheader"
+autoheader
+
 echo "  $LIBTOOLIZE --automake"
 $LIBTOOLIZE --automake
 
diff --git a/configure.ac b/configure.ac
index c3d76ff2f..93952589a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -13,8 +13,8 @@ AC_SUBST(MAD_SUBDIR)
 AC_SUBST(MAD_LIB)
 AC_SUBST(ID3_SUBDIR)
 AC_SUBST(ID3_LIB)
-AC_SUBST(MP4FF_SUBDIR)
 AC_SUBST(MP4FF_LIB)
+AC_SUBST(MP4FF_SUBDIR)
 AC_SUBST(MPD_LIBS)
 AC_SUBST(MPD_CFLAGS)
 
@@ -22,10 +22,11 @@ AC_PROG_CC
 AC_PROG_INSTALL
 AC_PROG_LIBTOOL
 
+AM_CONFIG_HEADER(config.h)
+
 MPD_CFLAGS="-Wall"
 MPD_LIBS=""
 
-AC_ARG_ENABLE(iconv,[  --disable-iconv     disable iconv support],,enable_iconv=yes)
 AC_ARG_ENABLE(ipv6,[  --disable-ipv6     disable IPv6 support],,enable_ipv6=yes)
 AC_ARG_ENABLE(ogg,[  --disable-ogg     disable ogg support],,enable_ogg=yes)
 AC_ARG_ENABLE(flac,[  --disable-flac    disable flac support],,enable_flac=yes)
@@ -44,9 +45,9 @@ AC_ARG_WITH(mad,[  --with-mad=PFX   Prefix where libmad is installed (optional)]
 AC_ARG_WITH(mad-libraries,[  --with-mad-libraries=DIR   Directory where libmad library is installed (optional)], mad_libraries="$withval", mad_libraries="")
 AC_ARG_WITH(mad-includes,[  --with-mad-includes=DIR   Directory where mad header files are installed (optional)], mad_includes="$withval", mad_includes="")
 
-AC_ARG_WITH(faad2,[  --with-faad2=PFX   Prefix where faad2 is installed], faad_prefix="$withval", faad_prefix="")
-AC_ARG_WITH(faad2-libraries,[  --with-faad-libraries=DIR   Directory where faad2 library is installed (optional)], faad_libraries="$withval", faad_libraries="")
-AC_ARG_WITH(faad2-includes,[  --with-faad-includes=DIR   Directory where faad2 header files are installed (optional)], faad_includes="$withval", faad_includes="")
+AC_ARG_WITH(faad,[  --with-faad=PFX   Prefix where faad2 is installed], faad_prefix="$withval", faad_prefix="")
+AC_ARG_WITH(faad-libraries,[  --with-faad-libraries=DIR   Directory where faad2 library is installed (optional)], faad_libraries="$withval", faad_libraries="")
+AC_ARG_WITH(faad-includes,[  --with-faad-includes=DIR   Directory where faad2 header files are installed (optional)], faad_includes="$withval", faad_includes="")
 
 AC_C_BIGENDIAN
 
@@ -55,20 +56,17 @@ AC_CHECK_SIZEOF(int)
 AC_CHECK_SIZEOF(long)
 AC_CHECK_SIZEOF(long long)
 
+AC_CHECK_FUNCS(strsep)
+
 AC_CHECK_LIB(socket,socket,MPD_LIBS="$MPD_LIBS -lsocket",)
 AC_CHECK_LIB(nsl,gethostbyname,MPD_LIBS="$MPD_LIBS -lnsl",)
 
 AC_CHECK_LIB(m,exp,MPD_LIBS="$MPD_LIBS -lm",)
 
-AC_CHECK_HEADER(langinfo.h,MPD_CFLAGS="$MPD_CFLAGS -DHAVE_LANGINFO",)
-AC_CHECK_HEADER(locale.h,MPD_CFLAGS="$MPD_CFLAGS -DHAVE_LOCALE",)
-
-if test x$enable_iconv = xyes; then
-	AC_CHECK_HEADER(iconv.h,MPD_CFLAGS="$MPD_CFLAGS -DHAVE_ICONV",enable_iconv=no)
-	if test x$enable_iconv = xyes; then
-		AC_CHECK_LIB(iconv,iconv,MPD_LIBS="$MPD_LIBS -liconv",)
-	fi
-fi
+AM_ICONV
+MPD_LIBS="$MPD_LIBS $LIBICONV"
+AM_LANGINFO_CODESET
+AM_LC_MESSAGES
 
 if test x$enable_ipv6 = xyes; then
 	AC_MSG_CHECKING(for ipv6)
@@ -83,14 +81,14 @@ AP_maGiC_VALUE
 #endif
 #endif
 	],
-	MPD_CFLAGS="$MPD_CFLAGS -DHAVE_IPV6"
+	AC_DEFINE(HAVE_IPV6, 1, [Define if IPv6 support present])
 	AC_MSG_RESULT([yes]),
 	AC_MSG_RESULT([no])
 )
 fi
 
 XIPH_PATH_AO(MPD_LIBS="$MPD_LIBS $AO_LIBS" MPD_CFLAGS="$MPD_CFLAGS $AO_CFLAGS",AC_MSG_ERROR(Must have libao installed!!!))
-AC_CHECK_HEADER(sys/soundcard.h,,[MPD_CFLAGS="$MPD_CFLAGS -DNO_OSS_MIXER";AC_MSG_WARN(Soundcard headers not found -- disabling mixer)])
+AC_CHECK_HEADER(sys/soundcard.h,,[AC_MSG_WARN(Soundcard headers not found -- disabling mixer);AC_DEFINE(NO_OSS_MIXER,1,[Define to disable OSS mixer support])])
 
 AC_MSG_CHECKING(for alsa)
 AC_EGREP_CPP([AP_maGiC_VALUE],
@@ -102,7 +100,7 @@ AP_maGiC_VALUE
 #endif
 #endif
 ],
-MPD_CFLAGS="$MPD_CFLAGS -DHAVE_ALSA"
+AC_DEFINE(HAVE_ALSA,1,[Define if alsa support is present])
 MPD_LIBS="$MPD_LIBS -lasound"
 AC_MSG_RESULT([yes]),
 AC_MSG_RESULT([no])
@@ -146,12 +144,12 @@ if test x$enable_id3 = xyes; then
 		LIBS=$oldlibs
 	fi
 	if test x$use_mpd_id3tag = xyes; then
-		MPD_CFLAGS="$MPD_CFLAGS -DUSE_MPD_ID3TAG"
+		AC_DEFINE(USE_MPD_ID3TAG,1,[Define to use mpd libid3tag])
 		ID3_LIB="libid3tag/libid3tag.la"
 		ID3_SUBDIR="libid3tag"
 		AC_CONFIG_SUBDIRS(src/libid3tag)
 	fi
-	MPD_CFLAGS="$MPD_CFLAGS -DHAVE_ID3TAG"
+	AC_DEFINE(HAVE_ID3TAG,1,[Define to use id3tag])
 fi
 
 MAD_SUBDIR=""
@@ -189,12 +187,12 @@ if test x$enable_mp3 = xyes; then
 		LIBS=$oldlibs
 	fi
 	if test x$use_mpd_mad = xyes; then
-		MPD_CFLAGS="$MPD_CFLAGS -DUSE_MPD_MAD"
+		AC_DEFINE(USE_MPD_MAD,1,[Define to use mpd libmad])
 		MAD_LIB="libmad/libmad.la"
 		MAD_SUBDIR="libmad"
 		AC_CONFIG_SUBDIRS(src/libmad)
 	fi
-	MPD_CFLAGS="$MPD_CFLAGS -DHAVE_MAD"
+	AC_DEFINE(HAVE_MAD,1,[Define to use libmad])
 fi
 
 MP4FF_SUBDIR=""
@@ -208,7 +206,7 @@ if test x$enable_aac = xyes; then
     		FAAD_LIBS="-L$libdir"
   	fi
 
- 	FAAD_LIBS="$FAAD_LIBS -lfaad -lmp4v2"
+ 	FAAD_LIBS="$FAAD_LIBS -lfaad -lmp4v2 -lstdc++"
 
   	if test "x$faad_includes" != "x" ; then
   		FAAD_CFLAGS="-I$faad_includes"
@@ -220,11 +218,14 @@ if test x$enable_aac = xyes; then
 
 	oldcflags=$CFLAGS
 	oldlibs=$LIBS
-	CFLAGS="$CFLAGS $MPD_CFLAGS $FAAD_CFLAGS"
+	CFLAGS="$CFLAGS $MPD_CFLAGS $FAAD_CFLAGS -I."
 	LIBS="$LIBS $MPD_LIBS $FAAD_LIBS"
 	AC_CHECK_HEADER(faad.h,,enable_aac=no)
 	if test x$enable_aac = xyes; then
-		AC_CHECK_HEADER(mp4.h,,[enable_aac=no;AC_MSG_WARN(You need mp4v2 installed for AAC/MP4 decoding)])
+		AC_CHECK_HEADER(mp4.h,,[enable_aac=no;AC_MSG_WARN(
+			You need mp4v2 installed for AAC/MP4 decoding.
+			If mp4.h is present, be sure that mpeg4ip.h does not
+			include systems.h)])
 	fi
 	if test x$enable_aac = xyes; then
 		AC_CHECK_LIB(mp4v2, MP4Create,,[enable_aac=no;AC_MSG_WARN(You need mp4v2 installed for AAC/MP4 decoding)])
@@ -233,7 +234,10 @@ if test x$enable_aac = xyes; then
 		AC_CHECK_LIB(mp4v2, MP4MetadataDelete,,[enable_aac=no;AC_MSG_WARN(You need mp4v2 installed for AAC/MP4 decoding)])
 	fi
 	if test x$enable_aac = xyes; then
-		AC_CHECK_LIB(faad, faacDecDecode,[MPD_LIBS="$MPD_LIBS $FAAD_LIBS";MPD_CFLAGS="$MPD_CFLAGS $FAAD_CFLAGS -DHAVE_FAAD";MP4FF_SUBDIR="mp4ff";MP4FF_LIB="mp4ff/libmp4ff.la"],enable_aac=no)
+		AC_CHECK_LIB(faad, faacDecDecode,[MPD_LIBS="$MPD_LIBS $FAAD_LIBS";MPD_CFLAGS="$MPD_CFLAGS $FAAD_CFLAGS";MP4FF_SUBDIR="mp4ff";MP4FF_LIB="mp4ff/libmp4ff.la"],enable_aac=no)
+	fi
+	if test x$enable_aac = xyes; then
+		AC_DEFINE(HAVE_FAAD,1,[Define to use FAAD2 for AAC decoding])
 	fi
 	CFLAGS=$oldcflags
 	LIBS=$oldlibs
@@ -299,7 +303,7 @@ dnl
 fi
 
 if test x$enable_ogg = xyes; then
-	MPD_CFLAGS="$MPD_CFLAGS -DHAVE_OGG"
+	AC_DEFINE(HAVE_OGG,1,[Define for ogg vorbis support])
 fi
 
 if test x$enable_flac = xyes; then
@@ -325,14 +329,18 @@ fi
 
 
 if test x$enable_flac = xyes; then
-	MPD_CFLAGS="$MPD_CFLAGS -DHAVE_FLAC"
+	AC_DEFINE(HAVE_FLAC,1,[Define for FLAC support])
 fi
 
 if test x$enable_audiofile = xyes; then
-	AM_PATH_AUDIOFILE(0.1.7, MPD_LIBS="$MPD_LIBS -laudiofile" MPD_CFLAGS="$MPD_CFLAGS -DHAVE_AUDIOFILE",
+	AM_PATH_AUDIOFILE(0.1.7, MPD_LIBS="$MPD_LIBS $AUDIOFILE_LIBS" MPD_CFLAGS="$MPD_CFLAGS $AUDIOFILE_CFLAGS",
 		[enable_audiofile=no;AC_MSG_WARN(You need audiofile  -- disabling audiofile support)])
 fi
 
+if test x$enable_audiofile = xyes; then
+	AC_DEFINE(HAVE_AUDIOFILE,1,[Define for audiofile support])
+fi
+
 AC_OUTPUT(src/mp4ff/Makefile doc/Makefile src/Makefile Makefile )
 
 echo ""
diff --git a/makedist.sh b/makedist.sh
index 9e3405c7f..4a6f171c3 100644
--- a/makedist.sh
+++ b/makedist.sh
@@ -1,4 +1,4 @@
 make distclean
-./autogen.sh --enable-mpd-mad --enable-mpd-id3tag
+./autogen.sh --enable-mpd-mad --enable-mpd-id3tag --disable-aac
 make 
 make dist
diff --git a/src/Makefile.am b/src/Makefile.am
index 808d14cfb..a663cca7f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -13,3 +13,5 @@ mpd_SOURCES = main.c buffer2array.c interface.c command.c playlist.c ls.c \
 
 mpd_CFLAGS = $(MPD_CFLAGS)
 mpd_LDADD = $(MPD_LIBS) $(ID3_LIB) $(MAD_LIB) $(MP4FF_LIB)
+
+DIST_SUBDIRS = mp4ff
diff --git a/src/audio.h b/src/audio.h
index 07c842dc1..da9784d1b 100644
--- a/src/audio.h
+++ b/src/audio.h
@@ -19,6 +19,8 @@
 #ifndef AUDIO_H
 #define AUDIO_H
 
+#include "../config.h"
+
 #include "mpd_types.h"
 
 #include <stdio.h>
diff --git a/src/audiofile_decode.c b/src/audiofile_decode.c
index 7c44cdce8..9683ce177 100644
--- a/src/audiofile_decode.c
+++ b/src/audiofile_decode.c
@@ -18,10 +18,10 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-#ifdef HAVE_AUDIOFILE
-
 #include "audiofile_decode.h"
 
+#ifdef HAVE_AUDIOFILE
+
 #include "command.h"
 #include "utils.h"
 #include "audio.h"
diff --git a/src/audiofile_decode.h b/src/audiofile_decode.h
index d0bc8d9be..536c3ce02 100644
--- a/src/audiofile_decode.h
+++ b/src/audiofile_decode.h
@@ -21,6 +21,8 @@
 #ifndef AUDIOFILE_DECODE_H
 #define AUDIOFILE_DECODE_H
 
+#include "../config.h"
+
 #ifdef HAVE_AUDIOFILE
 
 #include "playerData.h"
diff --git a/src/buffer2array.h b/src/buffer2array.h
index 1aad24fc6..74ebffbbb 100644
--- a/src/buffer2array.h
+++ b/src/buffer2array.h
@@ -19,6 +19,8 @@
 #ifndef BUFFER_2_ARRAY_H
 #define BUFFER_2_ARRAY_H
 
+#include "../config.h"
+
 int buffer2array(char * buffer, char *** array);
 
 void freeArgArray(char ** array, int argArrayLength);
diff --git a/src/charConv.h b/src/charConv.h
index 61909b7f1..8c5dbdc49 100644
--- a/src/charConv.h
+++ b/src/charConv.h
@@ -19,6 +19,8 @@
 #ifndef CHAR_CONV_H
 #define CHAR_CONV_H
 
+#include "../config.h"
+
 int setCharSetConversion(char * to, char * from);
 
 char * convStrDup(char * string);
diff --git a/src/command.h b/src/command.h
index 36a4600a6..2692c6b58 100644
--- a/src/command.h
+++ b/src/command.h
@@ -19,6 +19,8 @@
 #ifndef COMMAND_H
 #define COMMAND_H
 
+#include "../config.h"
+
 #include <stdio.h>
 
 #define COMMAND_RETURN_KILL	10
diff --git a/src/conf.h b/src/conf.h
index 8afca42eb..ca9defaf1 100644
--- a/src/conf.h
+++ b/src/conf.h
@@ -19,6 +19,8 @@
 #ifndef CONF_H
 #define CONF_H
 
+#include "../config.h"
+
 #define CONF_PORT				0
 #define CONF_MUSIC_DIRECTORY			1
 #define CONF_PLAYLIST_DIRECTORY			2
diff --git a/src/decode.h b/src/decode.h
index bb32de588..ea52dd858 100644
--- a/src/decode.h
+++ b/src/decode.h
@@ -19,6 +19,8 @@
 #ifndef DECODE_H
 #define DECODE_H
 
+#include "../config.h"
+
 #include <stdio.h>
 #include <sys/param.h>
 
@@ -26,8 +28,7 @@
 #define DECODE_TYPE_OGG		1
 #define DECODE_TYPE_FLAC	2
 #define DECODE_TYPE_AUDIOFILE 	3
-#define DECODE_TYPE_AAC 	4
-#define DECODE_TYPE_MP4 	5
+#define DECODE_TYPE_MP4 	4
 
 #define DECODE_STATE_STOP	0
 #define DECODE_STATE_DECODE	1
diff --git a/src/directory.h b/src/directory.h
index d6813d365..f701fe81a 100644
--- a/src/directory.h
+++ b/src/directory.h
@@ -19,6 +19,8 @@
 #ifndef DIRECTORY_H
 #define DIRECTORY_H
 
+#include "../config.h"
+
 #include "song.h"
 
 #include <stdio.h>
diff --git a/src/flac_decode.c b/src/flac_decode.c
index de59001f1..5e51b4ea8 100644
--- a/src/flac_decode.c
+++ b/src/flac_decode.c
@@ -16,9 +16,10 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-#ifdef HAVE_FLAC
 #include "flac_decode.h"
 
+#ifdef HAVE_FLAC
+
 #include "utils.h"
 #include "log.h"
 #include "pcm_utils.h"
diff --git a/src/flac_decode.h b/src/flac_decode.h
index 66c90ff4a..773d5d0f0 100644
--- a/src/flac_decode.h
+++ b/src/flac_decode.h
@@ -19,6 +19,8 @@
 #ifndef FLAC_DECODE_H
 #define FLAC_DECODE_H
 
+#include "../config.h"
+
 #include "playerData.h"
 
 #include <stdio.h>
diff --git a/src/interface.h b/src/interface.h
index 84ab2869c..b2a8b1a26 100644
--- a/src/interface.h
+++ b/src/interface.h
@@ -19,6 +19,8 @@
 #ifndef INTERFACE_H
 #define INTERFACE_H
 
+#include "../config.h"
+
 #include <stdio.h>
 #include <time.h>
 #include <sys/types.h>
diff --git a/src/list.h b/src/list.h
index 8a38ba4fe..4ae32160a 100644
--- a/src/list.h
+++ b/src/list.h
@@ -20,6 +20,8 @@
 #ifndef LIST_H
 #define LIST_H
 
+#include "../config.h"
+
 #include <stdlib.h>
 
 /* used to make a list where free() will be used to free data in list */
diff --git a/src/listen.h b/src/listen.h
index 7c9bed9bd..dd5e32d8c 100644
--- a/src/listen.h
+++ b/src/listen.h
@@ -19,6 +19,8 @@
 #ifndef LISTEN_H
 #define LISTEN_H
 
+#include "../config.h"
+
 extern int listenSocket;
 
 int establish(unsigned short port);
diff --git a/src/log.h b/src/log.h
index 9b4ceaeeb..59871f171 100644
--- a/src/log.h
+++ b/src/log.h
@@ -19,6 +19,8 @@
 #ifndef LOG_H
 #define LOG_H
 
+#include "../config.h"
+
 #include "myfprintf.h"
 
 #define LOG_LEVEL_LOW		0
diff --git a/src/ls.c b/src/ls.c
index f80c7209c..de4f2562d 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -126,7 +126,6 @@ int isMusic(char * utf8file, time_t * mtime) {
 	if((ret = isWave(utf8file,mtime))) return ret;
 #endif
 #ifdef HAVE_FAAD
-	if((ret = isAac(utf8file,mtime))) return ret;
 	if((ret = isMp4(utf8file,mtime))) return ret;
 #endif
 
@@ -281,35 +280,6 @@ int isMp4(char * utf8file, time_t * mtime) {
 	return 0;
 }
 
-int isAac(char * utf8file, time_t * mtime) {
-	struct stat st;
-	char * file = utf8ToFsCharset(utf8file);
-	char * actualFile = file;
-
-	if(actualFile[0]!='/') actualFile = rmp2amp(file);
-
-	if(stat(actualFile,&st)==0) {
-		if(S_ISREG(st.st_mode)) {
-			char * dup;
-			char * cLast;
-			char * cNext;
-			int ret = 0;
-			dup = strdup(file);
-			cNext = cLast = strtok(dup,".");
-			while((cNext = strtok(NULL,"."))) cLast = cNext;
-			if(cLast && 0==strcasecmp(cLast,"aac")) {
-				if(mtime) *mtime = st.st_mtime;
-				ret = 1;
-			}
-			free(dup);
-			return ret;
-		}
-		else return 0;
-	}
-
-	return 0;
-}
-
 int isMp3(char * utf8file, time_t * mtime) {
 	struct stat st;
 	char * file = utf8ToFsCharset(utf8file);
diff --git a/src/ls.h b/src/ls.h
index 063dc7dbd..ab5c218ac 100644
--- a/src/ls.h
+++ b/src/ls.h
@@ -19,6 +19,8 @@
 #ifndef LS_H
 #define LS_H
 
+#include "../config.h"
+
 #include <stdio.h>
 #include <time.h>
 
@@ -26,8 +28,6 @@ int lsPlaylists(FILE * fp, char * utf8path);
 
 int isMp3(char * utf8file, time_t * mtime);
 
-int isAac(char * utf8file, time_t * mtime);
-
 int isMp4(char * utf8file, time_t * mtime);
 
 int isOgg(char * utf8file, time_t * mtime);
diff --git a/src/mp3_decode.c b/src/mp3_decode.c
index d588165b4..ede0af6e3 100644
--- a/src/mp3_decode.c
+++ b/src/mp3_decode.c
@@ -16,9 +16,10 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#include "mp3_decode.h"
+
 #ifdef HAVE_MAD
 
-#include "mp3_decode.h"
 #include "pcm_utils.h"
 #ifdef USE_MPD_MAD
 #include "libmad/mad.h"
diff --git a/src/mp3_decode.h b/src/mp3_decode.h
index 918b5a46c..82e8f103b 100644
--- a/src/mp3_decode.h
+++ b/src/mp3_decode.h
@@ -19,6 +19,8 @@
 #ifndef MP3_DECODE_H
 #define MP3_DECODE_H
 
+#include "../config.h"
+
 #ifdef HAVE_MAD
 
 #include "playerData.h"
diff --git a/src/mpd_types.h b/src/mpd_types.h
index 7e64daba1..7a81fef63 100644
--- a/src/mpd_types.h
+++ b/src/mpd_types.h
@@ -19,6 +19,8 @@
 #ifndef MPD_TYPES_H
 #define MPD_TYPES_H
 
+#include "../config.h"
+
 typedef unsigned char	mpd_uint8;
 typedef signed char	mpd_sint8;
 
diff --git a/src/myfprintf.h b/src/myfprintf.h
index 6014eb6f3..b169b895c 100644
--- a/src/myfprintf.h
+++ b/src/myfprintf.h
@@ -19,6 +19,8 @@
 #ifndef MYFPRINTF_H
 #define MYFPRINTF_H
 
+#include "../config.h"
+
 #include <stdio.h>
 
 void myfprintfStdLogMode(FILE * out, FILE * err);
diff --git a/src/ogg_decode.c b/src/ogg_decode.c
index bcc0f6ee5..1aaa4d6be 100644
--- a/src/ogg_decode.c
+++ b/src/ogg_decode.c
@@ -16,9 +16,10 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-#ifdef HAVE_OGG
 #include "ogg_decode.h"
 
+#ifdef HAVE_OGG
+
 #include "command.h"
 #include "utils.h"
 #include "audio.h"
diff --git a/src/ogg_decode.h b/src/ogg_decode.h
index 8e4bd0fe3..a2e3076a5 100644
--- a/src/ogg_decode.h
+++ b/src/ogg_decode.h
@@ -19,6 +19,8 @@
 #ifndef OGG_DECODE_H
 #define OGG_DECODE_H
 
+#include "../config.h"
+
 #include "playerData.h"
 
 #include <stdio.h>
diff --git a/src/path.c b/src/path.c
index a7f143dc7..d475d356b 100644
--- a/src/path.c
+++ b/src/path.c
@@ -24,8 +24,8 @@
 #include <stdlib.h>
 #include <string.h>
 
-#ifdef HAVE_LOCALE
-#ifdef HAVE_LANGINFO
+#ifdef HAVE_LC_MESSAGES
+#ifdef HAVE_LANGINFO_CODESET
 #include <locale.h>
 #include <langinfo.h>
 #endif
@@ -87,8 +87,8 @@ char * getFsCharset() {
 }
 
 void initPaths() {
-#ifdef HAVE_LOCALE
-#ifdef HAVE_LANGINFO
+#ifdef HAVE_LC_MESSAGES
+#ifdef HAVE_LANGINFO_CODESET
 	char * originalLocale;
 #endif
 #endif
@@ -97,8 +97,8 @@ void initPaths() {
 	if(getConf()[CONF_FS_CHARSET]) {
 		charset = strdup(getConf()[CONF_FS_CHARSET]);
 	}
-#ifdef HAVE_LOCALE
-#ifdef HAVE_LANGINFO
+#ifdef HAVE_LC_MESSAGES
+#ifdef HAVE_LANGINFO_CODESET
 	else if((originalLocale = setlocale(LC_ALL,""))) {
 		char * temp;
 
diff --git a/src/path.h b/src/path.h
index 73cae2700..dc66a0733 100644
--- a/src/path.h
+++ b/src/path.h
@@ -19,6 +19,8 @@
 #ifndef PATH_H
 #define PATH_H
 
+#include "../config.h"
+
 #include <sys/param.h>
 
 extern char musicDir[MAXPATHLEN+1];
diff --git a/src/pcm_utils.h b/src/pcm_utils.h
index 649c51779..dcd5a31a9 100644
--- a/src/pcm_utils.h
+++ b/src/pcm_utils.h
@@ -19,6 +19,8 @@
 #ifndef PCM_UTILS_H
 #define PMC_UTILS_H
 
+#include "../config.h"
+
 #include "audio.h"
 
 #include <stdlib.h>
diff --git a/src/permission.h b/src/permission.h
index 6117ee468..d45f735eb 100644
--- a/src/permission.h
+++ b/src/permission.h
@@ -19,6 +19,8 @@
 #ifndef PERMISSION_H
 #define PERMISSION_H
 
+#include "../config.h"
+
 #define PERMISSION_READ		1
 #define PERMISSION_ADD		2
 #define PERMISSION_CONTROL	4
diff --git a/src/player.c b/src/player.c
index 63c8fed7b..084edd1b5 100644
--- a/src/player.c
+++ b/src/player.c
@@ -178,7 +178,6 @@ int playerPlay(FILE * fp, char * utf8file) {
 	else if(isWave(utf8file,NULL)) pc->decodeType = DECODE_TYPE_AUDIOFILE;
 #endif
 #ifdef HAVE_FAAD
-	else if(isAac(utf8file,NULL)) pc->decodeType = DECODE_TYPE_AAC;
 	else if(isMp4(utf8file,NULL)) pc->decodeType = DECODE_TYPE_MP4;
 #endif
 	else {
diff --git a/src/player.h b/src/player.h
index 51f9e04ed..ca1cfa6a8 100644
--- a/src/player.h
+++ b/src/player.h
@@ -19,6 +19,8 @@
 #ifndef PLAYER_H
 #define PLAYER_H
 
+#include "../config.h"
+
 #include "mpd_types.h"
 
 #include <stdio.h>
diff --git a/src/playerData.h b/src/playerData.h
index 830829fed..7da51e7b3 100644
--- a/src/playerData.h
+++ b/src/playerData.h
@@ -19,6 +19,8 @@
 #ifndef PLAYER_DATA_H
 #define PLAYER_DATA_H
 
+#include "../config.h"
+
 #include "audio.h"
 #include "player.h"
 #include "decode.h"
diff --git a/src/playlist.h b/src/playlist.h
index 00d0f9e3c..d5042c9b5 100644
--- a/src/playlist.h
+++ b/src/playlist.h
@@ -19,6 +19,8 @@
 #ifndef PLAYLIST_H
 #define PLAYLIST_H
 
+#include "../config.h"
+
 #include "song.h"
 
 #include <stdio.h>
diff --git a/src/sig_handlers.h b/src/sig_handlers.h
index 7128574b3..994f1eb33 100644
--- a/src/sig_handlers.h
+++ b/src/sig_handlers.h
@@ -19,6 +19,8 @@
 #ifndef SIG_HANDLERS_H
 #define SIG_HANDLERS_H
 
+#include "../config.h"
+
 void initSigHandlers();
 
 void finishSigHandlers();
diff --git a/src/song.c b/src/song.c
index 377487cbd..ac60692ad 100644
--- a/src/song.c
+++ b/src/song.c
@@ -79,9 +79,6 @@ Song * newSong(char * utf8file) {
 	}
 #endif
 #ifdef HAVE_FAAD
-	else if(isAac(utf8file,&(song->mtime))) {
-		song->tag = aacTagDup(utf8file);
-	}
 	else if(isMp4(utf8file,&(song->mtime))) {
 		song->tag = mp4TagDup(utf8file);
 	}
@@ -249,9 +246,6 @@ int updateSongInfo(Song * song) {
 	}
 #endif
 #ifdef HAVE_FAAD
-	else if(isAac(utf8file,&(song->mtime))) {
-		song->tag = aacTagDup(utf8file);
-	}
 	else if(isMp4(utf8file,&(song->mtime))) {
 		song->tag = mp4TagDup(utf8file);
 	}
diff --git a/src/song.h b/src/song.h
index 768a6aa04..895e6cf4f 100644
--- a/src/song.h
+++ b/src/song.h
@@ -19,6 +19,8 @@
 #ifndef SONG_H
 #define SONG_H
 
+#include "../config.h"
+
 #define SONG_BEGIN	"songList begin"
 #define SONG_END	"songList end"
 
diff --git a/src/stats.h b/src/stats.h
index 383a8db65..dd009909d 100644
--- a/src/stats.h
+++ b/src/stats.h
@@ -19,6 +19,8 @@
 #ifndef STATS_H
 #define STATS_H
 
+#include "../config.h"
+
 #include <stdio.h>
 
 typedef struct _Stats {
diff --git a/src/tables.h b/src/tables.h
index aaf05a3e9..e797f638a 100644
--- a/src/tables.h
+++ b/src/tables.h
@@ -19,6 +19,8 @@
 #ifndef TABLES_H
 #define TABLES_H
 
+#include "../config.h"
+
 #include "song.h"
 
 #include <stdio.h>
diff --git a/src/tag.c b/src/tag.c
index c854e9b2f..1a0acb3ea 100644
--- a/src/tag.c
+++ b/src/tag.c
@@ -299,22 +299,6 @@ MpdTag * mp4TagDup(char * utf8file) {
 
 	return ret;
 }
-
-MpdTag * aacTagDup(char * utf8file) {
-	MpdTag * ret = NULL;
-	int time;
-
-#warning getMp4TotalTime needs implementing
-	//time = getAacTotalTime(rmp2amp(utf8ToFsCharset(utf8file)));
-	time = 0;
-
-	if(time>=0) {
-		if(!ret) ret = newMpdTag();
-		ret->time = time;
-	}
-
-	return ret;
-}
 #endif
 
 #ifdef HAVE_OGG
diff --git a/src/tag.h b/src/tag.h
index 36fa76aec..d6ca809df 100644
--- a/src/tag.h
+++ b/src/tag.h
@@ -19,6 +19,8 @@
 #ifndef TAG_H
 #define TAG_H
 
+#include "../config.h"
+
 #include <stdio.h>
 
 typedef struct _MpdTag {
@@ -39,7 +41,6 @@ MpdTag * mp3TagDup(char * utf8file);
 
 #ifdef HAVE_FAAD
 MpdTag * mp4TagDup(char * utf8file);
-MpdTag * aacTagDup(char * utf8file);
 #endif
 
 #ifdef HAVE_OGG
diff --git a/src/utils.h b/src/utils.h
index 6abef6d8a..025f469e5 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -19,6 +19,8 @@
 #ifndef UTILS_H
 #define UTILS_H
 
+#include "../config.h"
+
 #include <stdio.h>
 
 char * myFgets(char * buffer, int bufferSize, FILE * fp);
diff --git a/src/volume.h b/src/volume.h
index 6af44bf93..efd4e158c 100644
--- a/src/volume.h
+++ b/src/volume.h
@@ -19,6 +19,8 @@
 #ifndef VOLUME_H
 #define VOLUME_H
 
+#include "../config.h"
+
 #include <stdio.h>
 
 #define VOLUME_MIXER_OSS	"oss"