configure.ac 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. #
  2. # Copyright 2012 Xamarin Inc
  3. #
  4. AC_INIT(eglib, [0.3],
  5. [http://bugzilla.xamarin.com/enter_bug.cgi?classification=Mono])
  6. AC_CONFIG_SRCDIR([README])
  7. AC_CONFIG_MACRO_DIR([m4])
  8. AC_CANONICAL_SYSTEM
  9. AC_CANONICAL_HOST
  10. AM_INIT_AUTOMAKE([1.9 dist-bzip2 tar-ustar no-dist-gzip foreign])
  11. AC_CONFIG_HEADERS([config.h])
  12. AM_MAINTAINER_MODE
  13. m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
  14. AC_PROG_CC
  15. AM_PROG_LIBTOOL
  16. # Use dolt (http://dolt.freedesktop.org/) instead of libtool for building.
  17. DOLT
  18. GNUC_PRETTY=
  19. GNUC_UNUSED=
  20. BREAKPOINT="G_STMT_START { raise (SIGTRAP); } G_STMT_END"
  21. if test x$GCC = xyes; then
  22. GNUC_UNUSED='__attribute__((__unused__))'
  23. GNUC_NORETURN='__attribute__((__noreturn__))'
  24. case $host_cpu in
  25. i*86|x86_64) BREAKPOINT="G_STMT_START { __asm__ (\"int \$03\"); } G_STMT_END" ;;
  26. esac
  27. fi
  28. AC_SUBST(GNUC_PRETTY)
  29. AC_SUBST(GNUC_UNUSED)
  30. AC_SUBST(GNUC_NORETURN)
  31. AC_SUBST(BREAKPOINT)
  32. # We use a separate variable to pass down CPPFLAGS and CFLAGS from the main mono
  33. # configure, because of autoconf brokeness
  34. if test "x$CPPFLAGS_FOR_EGLIB" != "x"; then
  35. CPPFLAGS=$CPPFLAGS_FOR_EGLIB
  36. fi
  37. if test "x$CFLAGS_FOR_EGLIB" != "x"; then
  38. CFLAGS=$CFLAGS_FOR_EGLIB
  39. fi
  40. CFLAGS="$CFLAGS -g -D_GNU_SOURCE"
  41. AM_CONDITIONAL(CROSS_COMPILING, [test x$cross_compiling = xyes])
  42. AC_C_BIGENDIAN([ORDER=G_BIG_ENDIAN],[ORDER=G_LITTLE_ENDIAN])
  43. platform_darwin=no
  44. platform_android=no
  45. case $host in
  46. *-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows*)
  47. PATHSEP='\\'
  48. SEARCHSEP=';'
  49. OS="WIN32"
  50. PIDTYPE='void *'
  51. ;;
  52. *-*darwin*)
  53. platform_darwin=yes
  54. PATHSEP='/'
  55. SEARCHSEP=':'
  56. OS="UNIX"
  57. PIDTYPE='int'
  58. ;;
  59. *-*-linux-android*)
  60. platform_android=yes
  61. AC_DEFINE(PLATFORM_ANDROID,1,[Targeting the Android platform])
  62. PATHSEP='/'
  63. SEARCHSEP=':'
  64. OS="UNIX"
  65. PIDTYPE='int'
  66. ;;
  67. *)
  68. PATHSEP='/'
  69. SEARCHSEP=':'
  70. OS="UNIX"
  71. PIDTYPE='int'
  72. ;;
  73. esac
  74. case $host in
  75. *-*-solaris*)
  76. CFLAGS="$CFLAGS -D_POSIX_PTHREAD_SEMANTICS"
  77. ;;
  78. esac
  79. case $target in
  80. arm*-darwin*|aarch64*-*)
  81. CFLAGS="$CFLAGS -U_FORTIFY_SOURCE"
  82. ;;
  83. i*86-*-darwin*)
  84. ORDER=G_LITTLE_ENDIAN
  85. ;;
  86. *-*-openbsd*)
  87. CFLAGS="$CFLAGS -pthread"
  88. LDFLAGS="$LDFLAGS -pthread"
  89. ;;
  90. esac
  91. target_osx=no
  92. target_ios=no
  93. if test "x$platform_darwin" = "xyes"; then
  94. AC_TRY_COMPILE([#include "TargetConditionals.h"],[
  95. #if TARGET_IPHONE_SIMULATOR == 1 || TARGET_OS_IPHONE == 1
  96. #error fail this for ios
  97. #endif
  98. return 0;
  99. ], [
  100. AC_DEFINE(TARGET_OSX,1,[The JIT/AOT targets OSX])
  101. target_osx=yes
  102. ], [
  103. AC_DEFINE(TARGET_IOS,1,[The JIT/AOT targets iOS])
  104. target_ios=yes
  105. ])
  106. AC_DEFINE(TARGET_MACH,1,[The JIT/AOT targets Apple platforms])
  107. fi
  108. AC_SUBST(ORDER)
  109. AC_SUBST(CFLAGS)
  110. AC_SUBST(PATHSEP)
  111. AC_SUBST(SEARCHSEP)
  112. AC_SUBST(OS)
  113. AC_SUBST(PIDTYPE)
  114. AM_CONDITIONAL(HOST_WIN32, test x$OS = xWIN32)
  115. AM_CONDITIONAL(TARGET_WIN32, test x$OS = xWIN32)
  116. AM_CONDITIONAL(PLATFORM_DARWIN, test x$platform_darwin = xyes)
  117. AM_CONDITIONAL(PLATFORM_ANDROID, test x$platform_android = xyes)
  118. AC_CHECK_SIZEOF(int)
  119. AC_CHECK_SIZEOF(void *)
  120. AC_CHECK_SIZEOF(long)
  121. AC_CHECK_SIZEOF(long long)
  122. AC_CHECK_FUNCS(strlcpy stpcpy strtok_r rewinddir vasprintf)
  123. AC_CHECK_FUNCS(getrlimit)
  124. #
  125. # Mono currently supports 10.6, but strndup is not available prior to 10.7; avoiding
  126. # the detection of strndup on OS X so Mono built on 10.7+ still runs on 10.6. This can be
  127. # removed once support for 10.6 is dropped.
  128. #
  129. # iOS detection of strndup and getpwuid_r is faulty for some reason so let's simply avoid it
  130. #
  131. if test x$target_osx = xyes; then
  132. AC_CHECK_FUNCS(getpwuid_r)
  133. elif test x$target_ios = xno; then
  134. AC_CHECK_FUNCS(strndup getpwuid_r)
  135. fi
  136. AM_CONDITIONAL(NEED_VASPRINTF, test x$have_vasprintf = x )
  137. AM_ICONV()
  138. AC_SEARCH_LIBS(sqrtf, m)
  139. # nanosleep may not be part of libc, also search it in other libraries
  140. AC_SEARCH_LIBS(nanosleep, rt)
  141. AC_SEARCH_LIBS(dlopen, dl)
  142. old_ldflags="${LDFLAGS}"
  143. LDFLAGS="${LDFLAGS} -Wl,-export-dynamic"
  144. AC_TRY_LINK(, [int i;], found_export_dynamic=yes, found_export_dynamic=no)
  145. if test $found_export_dynamic = no; then
  146. LDFLAGS="${old_ldflags}"
  147. fi
  148. AC_MSG_CHECKING(for varargs macros)
  149. AC_TRY_COMPILE([],[
  150. int foo (int i, int j);
  151. #define bar(...) foo (1, __VA_ARGS__)
  152. void main () {
  153. bar (2);
  154. }
  155. ],have_iso_varargs=yes,have_iso_varargs=no)
  156. AC_MSG_RESULT($have_iso_varargs)
  157. G_HAVE_ISO_VARARGS=0
  158. if test "x$have_iso_varargs" = "xyes"; then
  159. G_HAVE_ISO_VARARGS=1
  160. fi
  161. AC_SUBST(G_HAVE_ISO_VARARGS)
  162. AC_CHECK_HEADERS(getopt.h sys/select.h sys/time.h sys/wait.h pwd.h langinfo.h iconv.h localcharset.h sys/types.h sys/resource.h)
  163. AC_CHECK_HEADER(alloca.h, [HAVE_ALLOCA_H=1], [HAVE_ALLOCA_H=0])
  164. AC_SUBST(HAVE_ALLOCA_H)
  165. if test $ac_cv_sizeof_void_p = $ac_cv_sizeof_int; then
  166. GPOINTER_TO_INT="((gint) (ptr))"
  167. GPOINTER_TO_UINT="((guint) (ptr))"
  168. GINT_TO_POINTER="((gpointer) (v))"
  169. GUINT_TO_POINTER="((gpointer) (v))"
  170. GSIZE="int"
  171. GSIZE_FORMAT='"u"'
  172. G_GUINT64_FORMAT='"llu"'
  173. G_GINT64_FORMAT='"lld"'
  174. G_GUINT32_FORMAT='"lu"'
  175. G_GINT32_FORMAT='"ld"'
  176. elif test $ac_cv_sizeof_void_p = $ac_cv_sizeof_long; then
  177. GPOINTER_TO_INT="((gint)(long) (ptr))"
  178. GPOINTER_TO_UINT="((guint)(long) (ptr))"
  179. GINT_TO_POINTER="((gpointer)(glong) (v))"
  180. GUINT_TO_POINTER="((gpointer)(gulong) (v))"
  181. GSIZE="long"
  182. GSIZE_FORMAT='"lu"'
  183. G_GUINT64_FORMAT='"lu"'
  184. G_GINT64_FORMAT='"ld"'
  185. G_GUINT32_FORMAT='"u"'
  186. G_GINT32_FORMAT='"d"'
  187. elif test $ac_cv_sizeof_void_p = $ac_cv_sizeof_long_long; then
  188. GPOINTER_TO_INT="((gint)(long long) (ptr))"
  189. GPOINTER_TO_UINT="((guint)(unsigned long long) (ptr))"
  190. GINT_TO_POINTER="((gpointer)(long long) (v))"
  191. GUINT_TO_POINTER="((gpointer)(unsigned long long) (v))"
  192. GSIZE="long long"
  193. GSIZE_FORMAT='"I64u"'
  194. G_GUINT64_FORMAT='"I64u"'
  195. G_GINT64_FORMAT='"I64i"'
  196. G_GUINT32_FORMAT='"I32u"'
  197. G_GINT32_FORMAT='"I32i"'
  198. else
  199. AC_MSG_ERROR([unsupported pointer size])
  200. fi
  201. AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
  202. pkg_config_path=
  203. AC_ARG_WITH(crosspkgdir, [ --with-crosspkgdir=/path/to/pkg-config/dir Change pkg-config dir to custom dir],
  204. if test x$with_crosspkgdir = "x"; then
  205. if test -s $PKG_CONFIG_PATH; then
  206. pkg_config_path=$PKG_CONFIG_PATH
  207. fi
  208. else
  209. pkg_config_path=$with_crosspkgdir
  210. PKG_CONFIG_PATH=$pkg_config_path
  211. export PKG_CONFIG_PATH
  212. fi
  213. )
  214. AC_ARG_ENABLE(werror, [ --enable-werror Pass -Werror to the C compiler], werror_flag=$enableval, werror_flag=no)
  215. if test x$werror_flag = xyes; then
  216. WERROR_CFLAGS="-Werror"
  217. fi
  218. AC_SUBST([WERROR_CFLAGS])
  219. AC_SUBST(GPOINTER_TO_INT)
  220. AC_SUBST(GPOINTER_TO_UINT)
  221. AC_SUBST(GINT_TO_POINTER)
  222. AC_SUBST(GUINT_TO_POINTER)
  223. AC_SUBST(GSIZE)
  224. AC_SUBST(GSIZE_FORMAT)
  225. AC_SUBST(G_GUINT64_FORMAT)
  226. AC_SUBST(G_GINT64_FORMAT)
  227. AC_SUBST(G_GUINT32_FORMAT)
  228. AC_SUBST(G_GINT32_FORMAT)
  229. AC_OUTPUT([
  230. Makefile
  231. m4/Makefile
  232. src/Makefile
  233. src/eglib-config.h
  234. test/Makefile
  235. ])