Fresco/config compiler.m4,1.3,1.4 so.m4,1.2,1.3

Tobias Hunger <[email protected]> Wed, 14 May 2003 17:42:16 -0500
Newsgroups gmane.comp.video.fresco.cvs
Message-ID <[email protected]>
Update of /cvs/fresco/Fresco/config
In directory purcel:/tmp/cvs-serv20833/config

Modified Files:
	compiler.m4 so.m4 
Log Message:
A couple of buildsystem fixes:
 * Reactivated some old code from Havard: --enable-optimization and
     --enable-debugging should work again (closes bug45)
 * --enable-c++-demos renamed to --enable-cxx-demos: Looks like
      autoconf does not like + in options (closes bug173)
 * Toplevel Makefile should check for "Makefile" in the subproject's dirs:
      --disable-sdl should now work, even if builddir == srcdir       
      (closes bug209)
 * Remove -rdynamic flag: We need gcc > 3.0 now and I can't find any 
      documentation on this flag anymore (closes bug79)
 * Various small cleanups like replacing macros that are getting obsolete)


Index: compiler.m4
===================================================================
RCS file: /cvs/fresco/Fresco/config/compiler.m4,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- compiler.m4	8 Nov 2000 23:19:43 -0000	1.3
+++ compiler.m4	14 May 2003 22:42:13 -0000	1.4
@@ -1,8 +1,8 @@
 dnl $Id$
-dnl This source file is a part of the Berlin Project.
+dnl This source file is a part of the Fersco Project.
 dnl Copyright (c) 1999 Ralf S. Engelschall <[email protected]>
 dnl Copyright (c) 2000 Momchil Velikov <[email protected]>
-dnl http://www.berlin-consortium.org/
+dnl http://www.fresco.org/
 dnl
 dnl This library is free software; you can redistribute it and/or
 dnl modify it under the terms of the GNU Library General Public
@@ -20,8 +20,7 @@
 dnl MA 02139, USA.
 dnl
 
-AC_DEFUN(AC_PROG_CC_CXX,[dnl
-
+AC_DEFUN(FRESCO_PROG_CC_CXX, [
 	user_g_CFLAGS=""
 	user_O_CFLAGS=""
 	user_g_CXXFLAGS=""
@@ -29,116 +28,155 @@
 
 	for flag in $CFLAGS ; do
 		case $flag in
-			*-g* ) user_g_CFLAGS="$user_g_CFLAGS $flag" ;;
-			*-O*|*-f* ) user_O_CFLAGS="$user_O_CFLAGS $flag" ;;
+			( *-g* ) user_g_CFLAGS="$user_g_CFLAGS $flag" ;;
+			( *-O*|*-f* ) user_O_CFLAGS="$user_O_CFLAGS $flag" ;;
 		esac
 	done
 	for flag in $CXXFLAGS ; do
 		case $flag in
-			*-g* ) user_g_CXXFLAGS="$user_g_CXXFLAGS $flag" ;;
-			*-O*|*-f* ) user_O_CXXFLAGS="$user_O_CXXFLAGS $flag" ;;
+			( *-g* ) user_g_CXXFLAGS="$user_g_CXXFLAGS $flag" ;;
+			( *-O*|*-f* ) user_O_CXXFLAGS="$user_O_CXXFLAGS $flag" ;;
 		esac
 	done
 
 	AC_PROG_CC
 	AC_PROG_CXX
 
-	CFLAGS=`echo "$CFLAGS" \
-        	| sed -e 's/ -g / /g' -e 's/ -g$//' -e 's/^-g //g' -e 's/^-g$//'`
-	CXXFLAGS=`echo "$CXXFLAGS" \
-        	| sed -e 's/ -g / /g' -e 's/ -g$//' -e 's/^-g //g' -e 's/^-g$//'`
+	CFLAGS=`echo "$CFLAGS" | \
+		sed -e "s/ -g / /g" -e "s/ -g$//" \
+		    -e "s/^-g //g" -e "s/^-g$//"`
+	CXXFLAGS=`echo "$CXXFLAGS" | \
+		sed -e "s/ -g / /g" -e "s/ -g$//" \
+		    -e "s/^-g //g" -e "s/^-g$//"`
+
 	changequote(<<, >>)
-	CFLAGS=`echo $CFLAGS \
-        	| sed -e "s/ -O[0-9]* / /g" -e "s/ -O[0-9]*$//" \
-			-e "s/^-O[0-9]* //g" -e "s/^-O[0-9]*$//"`
-	CXXFLAGS=`echo $CXXFLAGS \
-        	| sed -e "s/ -O[0-9]* / /g" -e "s/ -O[0-9]*$//" \
-			-e "s/^-O[0-9]* //g" -e "s/^-O[0-9]*$//"`
+	CFLAGS=`echo "$CFLAGS" | \
+		sed -e "s/ -O[0-9]* / /g" -e "s/ -O[0-9]*$//" \
+		    -e "s/^-O[0-9]*//g" -e "s/^-O[0-9]*$//"`
+	CXXFLAGS=`echo "$CXXFLAGS" | \
+		sed -e "s/ -O[0-9]* / /g" -e "s/ -O[0-9]*$//" \
+		    -e "s/^-O[0-9]*//g" -e "s/^-O[0-9]*$//"`
 	changequote([, ])
 
 	if test ".$ac_cv_prog_gcc" = ".yes" ; then
 		for flag in "-pipe" ; do
 			case "$CFLAGS" in
-				*${flag}* ) ;;
-				*) CFLAGS="$CFLAGS $flag" ;;
+				( *${flag}* ) ;;
+				( *) CFLAGS="$CFLAGS $flag" ;;
 			esac
 			case "$CXXFLAGS" in
-				*${flag}* ) ;;
-				*) CXXFLAGS="$CXXFLAGS $flag" ;;
+				( *${flag}* ) ;;
+				( *) CXXFLAGS="$CXXFLAGS $flag" ;;
 			esac
 		done
 	fi
 ])
+
+AC_DEFUN(FRESCO_COMPILER_OPTION, [
+	AC_CACHE_CHECK([whether compiler option(s) $2 work],
+		[fresco_cv_stat_compiler_option_$1],
+		[
+			SAVE_CFLAGS="$CFLAGS"
+			SAVE_CXXFLAGS="$CXXFLAGS"
+			CFLAGS="$CFLAGS $3"
+			CXXFLAGS="$CXXFLAGS $3"
+			AC_TRY_COMPILE([],[], fresco_cv_stat_compiler_option_$1=yes, fresco_cv_stat_compiler_option_$1=no)
+			CFLAGS="$SAVE_CFLAGS"
+			CXXFLAGS="$SAVE_CXXFLAGS"
+		])
+	if test ".$fresco_cv_stat_compiler_option_$1" = .yes; then
+		[$4]
+	fi
+])
 	
-AC_DEFUN(AC_CHECK_DEBUGGING,[dnl
+AC_DEFUN(FRESCO_CHECK_DEBUGGING, [
+	AC_REQUIRE([AC_CANONICAL_HOST])
 
-	AC_ARG_ENABLE(debug,dnl
-[  --enable-debug          build for debugging (default=no)],
-	[dnl
+	AC_ARG_ENABLE(debugging, AC_HELP_STRING([--enable-debugging], [build for debugging (default=no)]),
+	[
 		if test ".$enableval" = ".yes" ; then
+			msg="enabled";
 			if test ".$user_g_CFLAGS" != . ; then
 				CFLAGS="$CFLAGS $user_g_CFLAGS"
+				msg="$msg, using specified CFLAGS"
 			else
-				CFLAGS="$CFLAGS -g"
 				if test ".$ac_cv_prog_gcc" = ".yes" ; then
-				         AC_COMPILER_OPTION(cggdb3, -ggdb3, -ggdb3,
+					 AC_LANG_SAVE
+					 AC_LANG(C)
+				         FRESCO_COMPILER_OPTION(cggdb3, [-ggdb3 for C], -ggdb3,
 						CFLAGS="$CFLAGS -ggdb3")
+					 AC_LANG_RESTORE
+				else
+					 CFLAGS="$CFLAGS -g"
 				fi
 			fi
 
 			if test ."$user_g_CXXFLAGS" != . ; then
 				CXXFLAGS="$CXXFLAGS $user_g_CXXFLAGS"
+				msg="$msg, using specified CXXFLAGS"
 			else
-				CXXFLAGS="$CXXFLAGS -g"
 				if test ."$ac_cv_prog_gcc" = ."yes" ; then
 					AC_LANG_SAVE
-					AC_LANG_CPLUSPLUS
-					AC_COMPILER_OPTION(cxxggdb3, -ggdb3, -ggdb3,
+					AC_LANG(C++)
+                                        FRESCO_COMPILER_OPTION(cxxggdb3, [-ggdb3 for C++], -ggdb3,
 						CXXFLAGS="$CXXFLAGS -ggdb3")
 					AC_LANG_RESTORE
+				else
+					CXXFLAGS="$CXXFLAGS -g"
 				fi
 			fi
-			msg=enabled
-			AC_DEFINE(DEBUG)
+			AC_DEFINE(DEBUG, [], [Enable debugging code?])
+			AC_SUBST(DEBUG)
+			AC_MSG_CHECKING(for compilation debug mode)
+			AC_MSG_RESULT([$msg])
 		else
-			msg=disabled
+			AC_MSG_CHECKING(for compilation debug mode)
+			AC_MSG_RESULT(disabled, ignoring CFLAGS and CXXFLAGS)
+		fi
+	],[
+		msg="Setting none of my own"
+		if test ."$user_g_CFLAGS" != . ; then
+			CFLAGS="$CFLAGS $user_g_CFLAGS"
+			msg="$msg, using specified CFLAGS";
+		fi
+		if test ."$user_g_CXXFLAGS" != . ; then
+			CXXFLAGS="$CXXFLAGS $user_g_CXXFLAGS"
+			msg="$msg, using specified CXXFLAGS";
 		fi
 		AC_MSG_CHECKING(for compilation debug mode)
-		AC_MSG_RESULT($msg)
-	],[dnl
-		CFLAGS="$CFLAGS $user_g_CFLAGS"
-		CXXFLAGS="$CXXFLAGS $user_g_CXXFLAGS"
-		AC_MSG_CHECKING(for compilation debug mode)
-		AC_MSG_RESULT(default)
+		AC_MSG_RESULT([$msg])
 	])
 ])
 
-AC_DEFUN(AC_CHECK_OPTIMIZE,[dnl
-
+AC_DEFUN(FRESCO_CHECK_OPTIMIZE, [
 	AC_REQUIRE([AC_CANONICAL_HOST])
 
-	AC_ARG_ENABLE(optimize,dnl
-[  --enable-optimize          build with optimization (default=no)],
-	[dnl
+	AC_ARG_ENABLE(optimization, AC_HELP_STRING([--enable-optimization], [build with optimization (default=no)]),
+	[
 		if test ".$enableval" = ".yes" ; then
+			msg="enabled"
 			if test ".$user_O_CFLAGS" != "." ; then
 				CFLAGS="$CFLAGS $user_O_CFLAGS"
+				msg="$msg, using specified CFLAGS"
 			else
 				if test ".$ac_cv_prog_gcc" = ".yes" ; then
 					OPT_CFLAGS='-O3 -funroll-loops -fstrength-reduce -fomit-frame-pointer -ffast-math'
-					AC_COMPILER_OPTION(coptimize_std,
+					AC_LANG_SAVE
+					AC_LANG(C)
+					FRESCO_COMPILER_OPTION(coptimize_std,
 						[-f<xxx> for C],
 						$OPT_CFLAGS,
 						CFLAGS="$CFLAGS $OPT_CFLAGS")
 					case $host_cpu in
 					i?86*|?86*)
-						OPT_CFLAGS='-malign-functions=4 -malign-jumps=4 -malign-loops=4' 
-						AC_COMPILER_OPTION(coptimize_x86,
+						OPT_CFLAGS='-falign-functions=4 -falign-jumps=4 -falign-loops=4' 
+						FRESCO_COMPILER_OPTION(coptimize_x86,
 							[-f<xxx> for x86 CPU],
 							$OPT_CFLAGS,
 							CFLAGS="$CFLAGS $OPT_CFLAGS")
 							;;
 					esac
+					AC_LANG_RESTORE
 				else
 					CFLAGS="$CFLAGS -O"
 				fi
@@ -146,37 +184,47 @@
 
 			if test ".$user_O_CXXFLAGS" != "." ; then
 				CXXFLAGS="$CXXFLAGS $user_O_CXXFLAGS"
+				msg="$msg, using specified CXXFLAGS"
 			else
 				if test ."$ac_cv_prog_gcc" = ."yes" ; then
 					OPT_CXXFLAGS='-O3 -funroll-loops -fstrength-reduce -ffast-math'
-					AC_COMPILER_OPTION(cxxoptimize_std,
+					AC_LANG_SAVE
+					AC_LANG(C++)
+					FRESCO_COMPILER_OPTION(cxxoptimize_std,
 						[-f<xxx> for C++],
 						$OPT_CXXFLAGS,
 						CXXFLAGS="$CXXFLAGS $OPT_CXXFLAGS")
 					case $host_cpu in
 					i?86*|?86*)
-						OPT_CXXFLAGS='-malign-functions=4 -malign-jumps=4 -malign-loops=4' 
-						AC_COMPILER_OPTION(cxxoptimize_x86,
+						OPT_CXXFLAGS='-falign-functions=4 -falign-jumps=4 -falign-loops=4' 
+						FRESCO_COMPILER_OPTION(cxxoptimize_x86,
 							[-f<xxx> for x86 CPU],
 							$OPT_CXXFLAGS,
 							CXXFLAGS="$CXXFLAGS $OPT_CXXFLAGS")
 							;;
 					esac
+					AC_LANG_RESTORE
 				else
 					CXXFLAGS="$CXXFLAGS -O"
 				fi
 			fi
-			msg=enabled
+			AC_MSG_CHECKING(for compilation optimize mode)
+			AC_MSG_RESULT([$msg])
 		else
-			msg=disabled
+			AC_MSG_CHECKING(for compilation optimize mode)
+			AC_MSG_RESULT([disabled, ignoring specified CFLAGS and CXXFLAGS])
 		fi
-
-		AC_MSG_CHECKING(for compilation optimize mode)
-		AC_MSG_RESULT(msg)
-	],[dnl
-		CFLAGS="$CFLAGS $user_O_CFLAGS"
-		CXXFLAGS="$CXXFLAGS $user_O_CXXFLAGS"
-		AC_MSG_CHECKING(for compilation optimize mode)
-		AC_MSG_RESULT(default)
+	],[
+		msg="Setting none of my own"
+		if test ."$user_O_CFLAGS" != . ; then
+			CFLAGS="$CFLAGS $user_O_CFLAGS"
+			msg="$msg, using specified CFLAGS";
+		fi
+		if test ."$user_O_CXXFLAGS" != . ; then
+			CXXFLAGS="$CXXFLAGS $user_O_CXXFLAGS"
+			msg="$mesgm using specified CXXFLAGS";
+		fi
+		AC_MSG_CHECKING(for compilation optimize  mode)
+		AC_MSG_RESULT([$msg])
 	])
 ])

Index: so.m4
===================================================================
RCS file: /cvs/fresco/Fresco/config/so.m4,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- so.m4	29 May 2002 06:49:42 -0000	1.2
+++ so.m4	14 May 2003 22:42:13 -0000	1.3
@@ -26,7 +26,7 @@
 
 	dnl TODO: Add checks to set the right flag for all compilers
 	SO_CXXFLAGS="-fPIC"
-	SO_LDFLAGS="-shared -rdynamic"
+	SO_LDFLAGS="-shared"
 
 	AC_SUBST(SO_CXXFLAGS)
 	AC_SUBST(SO_LDFLAGS)