diff options
-rw-r--r-- | Graphics.c | 10 | ||||
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | configure.ac | 12 |
3 files changed, 22 insertions, 2 deletions
@@ -30,6 +30,10 @@ from The Open Group. * Author: Davor Matic, MIT X Consortium */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include <X11/IntrinsicP.h> #include <X11/StringDefs.h> #include <X11/Xfuncs.h> @@ -46,7 +50,11 @@ from The Open Group. #define min(x, y) (((int)(x) < (int)(y)) ? (x) : (y)) #define max(x, y) (((int)(x) > (int)(y)) ? (x) : (y)) #ifndef rint -#define rint(x) floor(x + 0.5) +# if HAVE_LRINT +# define rint(x) lrint(x) +# else +# define rint(x) floor(x + 0.5) +# endif #endif /*****************************************************************************\ diff --git a/Makefile.am b/Makefile.am index 7a5ca35..88cc611 100644 --- a/Makefile.am +++ b/Makefile.am @@ -23,7 +23,7 @@ SUBDIRS=man bin_PROGRAMS = bitmap bmtoa atobm bitmap_CFLAGS = $(CWARNFLAGS) $(BITMAP_CFLAGS) -bitmap_LDADD = $(BITMAP_LIBS) -lm +bitmap_LDADD = $(BITMAP_LIBS) $(MATH_LIBS) bitmap_SOURCES = \ BitEdit.c \ CutPaste.c \ diff --git a/configure.ac b/configure.ac index ecb71ce..c3fcba9 100644 --- a/configure.ac +++ b/configure.ac @@ -42,6 +42,18 @@ AM_PROG_CC_C_O AC_CHECK_FUNCS([mkstemp]) +# Math libraries & functions +# - some compilers use builtin inlines for floor when optimizing +# - lrint() is a C99 addition not found on some older systems +# - must do the libm check first so that the lrint check will have it in $LIBS +save_LIBS="$LIBS" +AC_SEARCH_LIBS([floor], [m]) +AC_SEARCH_LIBS([lrint], [m]) +AC_CHECK_FUNCS([lrint]) +MATH_LIBS="$LIBS" +LIBS="$save_LIBS" +AC_SUBST([MATH_LIBS]) + # Obtain compiler/linker options from dependencies PKG_CHECK_MODULES(BMTOA, x11 xmu) PKG_CHECK_MODULES(ATOBM, xproto) |