[AD] Patch to fix -lm on Allegro 4.3.10

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Here's is my first try at fixing the -lm issue on allegro-4.3.10.
Figured I'd send this in separately from the Haiku patch that I'm
working on.  I have not tested it out on anything other than Haiku, so
it needs to be verified that it would properly apply -lm where it's
needed on a system that does require -lm.  Note that Haiku (and BeOS)
has the math library built in and will fail if you try to link in -lm.
-scottmc
diff -urN allegro-4.3.10/addons/allegrogl/configure allegro-4.3.10-haiku/addons/allegrogl/configure
--- allegro-4.3.10/addons/allegrogl/configure	2008-01-19 23:57:16.000000000 +0000
+++ allegro-4.3.10-haiku/addons/allegrogl/configure	2008-09-13 19:57:44.000000000 +0000
@@ -3624,6 +3624,70 @@
   LIBS="-lpthread $LIBS"
 fi
 
+{ echo "$as_me:$LINENO: checking for cos in -lm" >&5
+echo $ECHO_N "checking for cos in -lm... $ECHO_C" >&6; }
+if test "${ac_cv_lib_m_cos+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lm  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char cos ();
+int
+main ()
+{
+return cos ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_cv_lib_m_cos=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_lib_m_cos=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_m_cos" >&5
+echo "${ECHO_T}$ac_cv_lib_m_cos" >&6; }
+if test $ac_cv_lib_m_cos = yes; then
+  LIBS="-lm $LIBS"
+fi
 
 
 if test -n "$agl_build_generic"; then
@@ -4247,7 +4311,7 @@
 	if test -n "$x_libraries"; then
 		LDFLAGS="-L$x_libraries $LDFLAGS"
 	fi
-	LIBS="-lXext -lX11 -lm $LIBS"
+	LIBS="-lXext -lX11 $LIBS"
 
 
 	if test -n "$agl_enable_xf86vidmode"; then
diff -urN allegro-4.3.10/addons/allegrogl/configure.in allegro-4.3.10-haiku/addons/allegrogl/configure.in
--- allegro-4.3.10/addons/allegrogl/configure.in	2008-01-01 11:20:16.000000000 +0000
+++ allegro-4.3.10-haiku/addons/allegrogl/configure.in	2008-09-13 19:56:10.000000000 +0000
@@ -54,7 +54,7 @@
 dnl Check for pthread support, which GL libs may require (e.g. FreeBSD)
 AC_CHECK_HEADER(pthread.h, , dontcare=y)
 AC_CHECK_LIB(pthread, pthread_create, LIBS="-lpthread $LIBS")
-
+AC_CHECK_LIB(m, cos, LIBS="-lm $LIBS")
 
 dnl Build Mesa generic driver
 if test -n "$agl_build_generic"; then
@@ -76,7 +76,7 @@
 	if test -n "$x_libraries"; then
 		LDFLAGS="-L$x_libraries $LDFLAGS"
 	fi
-	LIBS="-lXext -lX11 -lm $LIBS"
+	LIBS="-lXext -lX11 $LIBS"
 
 
 dnl Test for VidMode extension

diff -urN allegro-4.3.10/addons/jpgalleg/makefile.be allegro-4.3.10-haiku/addons/jpgalleg/makefile.be
--- allegro-4.3.10/addons/jpgalleg/makefile.be	2008-01-01 21:59:18.000000000 +0000
+++ allegro-4.3.10-haiku/addons/jpgalleg/makefile.be	2008-09-13 20:09:02.000000000 +0000
@@ -38,7 +38,7 @@
   endif
 endif
 
-LIBS = -lm `../../allegro-config --libs --addon`
+LIBS = `../../allegro-config --libs --addon`
 LDFLAGS = -L../../lib/$(PLATFORM_PATH)
 INSTALL_LIB_PATH = /boot/develop/lib/x86
 INSTALL_HEADER_PATH = /boot/develop/headers
diff -urN allegro-4.3.10/configure allegro-4.3.10-haiku/configure
--- allegro-4.3.10/configure	2008-01-19 23:57:12.000000000 +0000
+++ allegro-4.3.10-haiku/configure	2008-09-13 19:53:14.000000000 +0000
@@ -5436,6 +5436,14 @@
   allegro_build_normal_library=yes
   _programs="release"
 fi
+
+M_LIBS="-lm"
+case "$host_os" in
+  beos* | haiku*)
+      M_LIBS=""
+      ;;
+esac
+
 if test "X$allegro_build_static_programs" = "Xyes"; then
   LIBALLEG=lib/unix/lib$LIB_TO_LINK.a
   LINK_LIBALLEG="$LIBALLEG \$(LIBS)"
@@ -5444,7 +5452,7 @@
   _programs="statically linked $_programs"
 else
   LIBALLEG="lib/unix/lib${LIB_TO_LINK}-\$(shared_version).so lib/unix/lib${LIB_TO_LINK}_unsharable.a"
-  LINK_LIBALLEG="-Llib/unix -l${LIB_TO_LINK}-\$(shared_version) -l${LIB_TO_LINK}_unsharable -lm"
+  LINK_LIBALLEG="-Llib/unix -l${LIB_TO_LINK}-\$(shared_version) -l${LIB_TO_LINK}_unsharable $(M_LIBS)"
   LINK_WITH_STATIC_LIBS=no
   allegro_shared_libraries=yes
   _programs="dynamically linked $_programs"
@@ -11167,7 +11175,7 @@
 
 #-----------------------------------------------------------------------------#
 
-LIBS="-lm $LIBS"
+LIBS="$(M_LIBS) $LIBS"
 
 case "$allegro_system" in
 
diff -urN allegro-4.3.10/configure.in allegro-4.3.10-haiku/configure.in
--- allegro-4.3.10/configure.in	2008-01-03 20:47:10.000000000 +0000
+++ allegro-4.3.10-haiku/configure.in	2008-09-13 19:52:03.000000000 +0000
@@ -298,6 +298,15 @@
   allegro_build_normal_library=yes
   _programs="release"
 fi
+
+M_LIBS="-lm"
+case "$host_os" in
+  beos* | haiku*)
+      M_LIBS=""
+      ;;
+esac
+
+
 if test "X$allegro_build_static_programs" = "Xyes"; then
   LIBALLEG=lib/unix/lib$LIB_TO_LINK.a
   LINK_LIBALLEG="$LIBALLEG \$(LIBS)"
@@ -306,7 +315,7 @@
   _programs="statically linked $_programs"
 else
   LIBALLEG="lib/unix/lib${LIB_TO_LINK}-\$(shared_version).so lib/unix/lib${LIB_TO_LINK}_unsharable.a"
-  LINK_LIBALLEG="-Llib/unix -l${LIB_TO_LINK}-\$(shared_version) -l${LIB_TO_LINK}_unsharable -lm"
+  LINK_LIBALLEG="-Llib/unix -l${LIB_TO_LINK}-\$(shared_version) -l${LIB_TO_LINK}_unsharable $(M_LIBS)"
   LINK_WITH_STATIC_LIBS=no
   allegro_shared_libraries=yes
   _programs="dynamically linked $_programs"
@@ -873,7 +882,7 @@
 #-----------------------------------------------------------------------------#
 
 dnl Additional libraries.
-LIBS="-lm $LIBS"
+LIBS="$(M_LIBS) $LIBS"
 
 case "$allegro_system" in
 


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/