--- motion-20051026-051001/configure.in	2005-10-08 16:11:00.000000000 +0200
+++ motion-20051026-051001-ffmpeg-configure/configure.in	2005-10-26 13:10:04.000000000 +0200
@@ -148,11 +148,10 @@ else if test "${FFMPEG}" = "yes"; then
 
 	if test -f /usr/bin/ffmpeg-config; then
 		FFMPEG_LIBS_DEB="`ffmpeg-config --libs avformat`"
-		FFMPEG_DEB="`ffmpeg-config --cflags`"
+		FFMPEG_CFLAGS_DEB="`ffmpeg-config --cflags`"
 		FFMPEG_OK="found"
-	fi	
-	
-	if test -f /usr/lib64/libavcodec.a -o -f /usr/lib64/libavcodec.so && test -f /usr/lib64/libavformat.a -o -f /usr/lib64/libavformat.so ; then
+		AC_MSG_RESULT(found for debian)
+	elif test -f /usr/lib64/libavcodec.a -o -f /usr/lib64/libavcodec.so && test -f /usr/lib64/libavformat.a -o -f /usr/lib64/libavformat.so ; then
 		AC_MSG_RESULT(found)
 		FFMPEG_OK="found"
 		FFMPEG="/usr/lib64"
@@ -203,17 +202,31 @@ else
 	fi
 fi
 
+#
+# Now check for ffmpeg headers ( avformat.h ) if ffmpeg libs were found
+#
+
 if test "${FFMPEG_OK}" = "found"; then
-	if test -f ${FFMPEG}/include/avformat.h; then
-		TEMP_CFLAGS="-I${FFMPEG}/include ${TEMP_CFLAGS}"
+	AC_MSG_CHECKING(for ffmpeg headers)
+	
+	if test "${FFMPEG_CFLAGS_DEB}" != "" ; then
+		FFMPEG_CFLAGS="${FFMPEG_CFLAGS_DEB}"
+		AC_MSG_RESULT(found for debian)
+	elif test -f ${FFMPEG}/include/avformat.h; then
+		AC_MSG_RESULT(found)
+		FFMPEG_CFLAGS="-I${FFMPEG}/include"
 	elif test -f ${FFMPEG}/avformat.h; then
-		TEMP_CFLAGS="-I${FFMPEG} ${TEMP_CFLAGS}"
+		AC_MSG_RESULT(found)
+		FFMPEG_CFLAGS="-I${FFMPEG}"
 	elif test -f `AS_DIRNAME([${FFMPEG}])`/include/avformat.h; then
-		TEMP_CFLAGS="-I`AS_DIRNAME([${FFMPEG}])`/include ${TEMP_CFLAGS}"
+		AC_MSG_RESULT(found)
+		FFMPEG_CFLAGS="-I`AS_DIRNAME([${FFMPEG}])`/include"
 	elif test -f `AS_DIRNAME([${FFMPEG}])`/include/ffmpeg/avformat.h; then
-		TEMP_CFLAGS="-I`AS_DIRNAME([${FFMPEG}])`/include/ffmpeg ${TEMP_CFLAGS}"
+		AC_MSG_RESULT(found)
+		FFMPEG_CFLAGS="-I`AS_DIRNAME([${FFMPEG}])`/include/ffmpeg"
 	else
 		AC_MSG_RESULT(not found)
+		FFMPEG_OK="no_found"
 		echo "**********************************************"
 		echo "*       avformat.h not found:                *"
 		echo "*    ALL FFMPEG FEATURES DISABLED            *"
@@ -224,16 +237,24 @@ if test "${FFMPEG_OK}" = "found"; then
 		echo ""
 	fi
 
-	
-	if test "${FFMPEG_LIBS_DEB}" != "" ; then
-		TEMP_LIBS="$TEMP_LIBS -L${FFMPEG} ${FFMPEG_LIBS_DEB}"	
-	else
-		TEMP_LIBS="$TEMP_LIBS -L${FFMPEG} -lavformat -lavcodec -lm -lz"
-		TEMP_LDFLAGS="$TEMP_LDFLAGS -L${FFMPEG}"
-	fi	
-	TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_FFMPEG"
-	FFMPEG_OBJ="ffmpeg.o"
-	AC_SUBST(FFMPEG_OBJ)
+#
+# If ffmpeg libs and headers have been found 
+#
+
+	if  test "${FFMPEG_OK}" = "found"; then	
+		if test "${FFMPEG_LIBS_DEB}" != ""; then
+			TEMP_LIBS="$TEMP_LIBS ${FFMPEG_LIBS_DEB}"
+#			TEMP_LDFLAGS="${TEMP_LDFLAGS} ${FFMPEG_LIBS_DEB}"
+		else
+			TEMP_LIBS="$TEMP_LIBS -L${FFMPEG} -lavformat -lavcodec -lm -lz"
+			TEMP_LDFLAGS="${TEMP_LDFLAGS} -L${FFMPEG}"
+		fi
+
+		TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_FFMPEG ${FFMPEG_CFLAGS}"
+
+		FFMPEG_OBJ="ffmpeg.o"
+		AC_SUBST(FFMPEG_OBJ)
+	fi
 fi	
 fi
 
