<URL: http://bugs.freeciv.org/Ticket/Display.html?id=40286 >

2008/6/16 Madeline Book:
>
> So would it be possible to use the autoconf tools to
> somehow make lua compile with the right defines? E.g.
> with -DLUA_USE_LINUX on my linux system.

 This patch for adds configure checks for functions conditionally used by lua.


 - ML

diff -Nurd -X.diff_ignore freeciv/autogen.sh freeciv/autogen.sh
--- freeciv/autogen.sh	2008-03-19 04:32:56.000000000 +0200
+++ freeciv/autogen.sh	2008-06-19 02:39:51.000000000 +0300
@@ -257,7 +257,7 @@
 fi
 
 echo "+ running $ACLOCAL ..."
-$ACLOCAL -I m4 $ACLOCAL_FLAGS || {
+$ACLOCAL -I m4 -I dependencies/m4 $ACLOCAL_FLAGS || {
   echo
   echo "$ACLOCAL failed - check that all needed development files are present on system"
   exit 1
diff -Nurd -X.diff_ignore freeciv/configure.ac freeciv/configure.ac
--- freeciv/configure.ac	2008-06-18 18:49:41.000000000 +0300
+++ freeciv/configure.ac	2008-06-19 02:29:52.000000000 +0300
@@ -690,6 +690,13 @@
   fi])
 fi
 
+dnl Checks needed for Lua. Get rid of these if system lua is ever used.
+gl_FUNC_MKSTEMP
+if test x$gl_cv_func_working_mkstemp = xyes ; then
+  AC_DEFINE([HAVE_MKSTEMP], [1], [Have working mkstemp])
+fi
+AC_CHECK_FUNCS([isatty popen _longjmp])
+
 dnl In the future we probably get rid of our own lua tree and use
 dnl lua from system.
 dnl LUA_AS_DEPENDENCY should be empty when using lua outside own our tree.
diff -Nurd -X.diff_ignore freeciv/dependencies/lua-5.1/src/localluaconf.h freeciv/dependencies/lua-5.1/src/localluaconf.h
--- freeciv/dependencies/lua-5.1/src/localluaconf.h	1970-01-01 02:00:00.000000000 +0200
+++ freeciv/dependencies/lua-5.1/src/localluaconf.h	2008-06-19 02:37:03.000000000 +0300
@@ -0,0 +1,33 @@
+/********************************************************************** 
+ Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+***********************************************************************/
+#ifndef FC__LOCALLUACONF_H
+#define FC__LOCALLUACONF_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef HAVE_MKSTEMP
+#define LUA_USE_MKSTEMP
+#endif
+#ifdef HAVE_ISATTY
+#define LUA_USE_ISATTY
+#endif
+#ifdef HAVE_POPEN
+#define LUA_USE_POPEN
+#endif
+#ifdef HAVE__LONGJMP
+#define LUA_USE_ULONGJMP
+#endif
+
+#endif /* FC__LOCALLUACONF_H */
diff -Nurd -X.diff_ignore freeciv/dependencies/lua-5.1/src/luaconf.h freeciv/dependencies/lua-5.1/src/luaconf.h
--- freeciv/dependencies/lua-5.1/src/luaconf.h	2008-06-18 18:49:35.000000000 +0300
+++ freeciv/dependencies/lua-5.1/src/luaconf.h	2008-06-19 01:35:42.000000000 +0300
@@ -11,6 +11,7 @@
 #include <limits.h>
 #include <stddef.h>
 
+#include "localluaconf.h"
 
 /*
 ** ==================================================================
diff -Nurd -X.diff_ignore freeciv/dependencies/m4/mkstemp.m4 freeciv/dependencies/m4/mkstemp.m4
--- freeciv/dependencies/m4/mkstemp.m4	1970-01-01 02:00:00.000000000 +0200
+++ freeciv/dependencies/m4/mkstemp.m4	2008-06-19 02:07:02.000000000 +0300
@@ -0,0 +1,56 @@
+#serial 17
+
+# Copyright (C) 2001, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# On some hosts (e.g., HP-UX 10.20, SunOS 4.1.4, Solaris 2.5.1), mkstemp has a
+# silly limit that it can create no more than 26 files from a given template.
+# Other systems lack mkstemp altogether.
+# On OSF1/Tru64 V4.0F, the system-provided mkstemp function can create
+# only 32 files per process.
+# On systems like the above, arrange to use the replacement function.
+AC_DEFUN([gl_FUNC_MKSTEMP],
+[
+  AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
+  AC_REQUIRE([AC_SYS_LARGEFILE])
+
+  AC_CACHE_CHECK([for working mkstemp],
+    [gl_cv_func_working_mkstemp],
+    [
+      mkdir conftest.mkstemp
+      AC_RUN_IFELSE(
+	[AC_LANG_PROGRAM(
+	  [AC_INCLUDES_DEFAULT],
+	  [[int i;
+	    off_t large = (off_t) 4294967295u;
+	    if (large < 0)
+	      large = 2147483647;
+	    for (i = 0; i < 70; i++)
+	      {
+		char templ[] = "conftest.mkstemp/coXXXXXX";
+		int (*mkstemp_function) (char *) = mkstemp;
+		int fd = mkstemp_function (templ);
+		if (fd < 0 || lseek (fd, large, SEEK_SET) != large)
+		  return 1;
+		close (fd);
+	      }
+	    return 0;]])],
+	[gl_cv_func_working_mkstemp=yes],
+	[gl_cv_func_working_mkstemp=no],
+	[gl_cv_func_working_mkstemp=no])
+      rm -rf conftest.mkstemp
+    ])
+
+  if test $gl_cv_func_working_mkstemp != yes; then
+    REPLACE_MKSTEMP=1
+    AC_LIBOBJ([mkstemp])
+    gl_PREREQ_MKSTEMP
+  fi
+])
+
+# Prerequisites of lib/mkstemp.c.
+AC_DEFUN([gl_PREREQ_MKSTEMP],
+[
+])
diff -Nurd -X.diff_ignore freeciv/dependencies/m4/stdlib_h.m4 freeciv/dependencies/m4/stdlib_h.m4
--- freeciv/dependencies/m4/stdlib_h.m4	1970-01-01 02:00:00.000000000 +0200
+++ freeciv/dependencies/m4/stdlib_h.m4	2008-06-19 02:21:35.000000000 +0300
@@ -0,0 +1,47 @@
+# stdlib_h.m4 serial 7
+dnl Copyright (C) 2007, 2008 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_STDLIB_H],
+[
+  AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
+  gl_CHECK_NEXT_HEADERS([stdlib.h])
+])
+
+AC_DEFUN([gl_STDLIB_MODULE_INDICATOR],
+[
+  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
+  AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
+  GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
+])
+
+AC_DEFUN([gl_STDLIB_H_DEFAULTS],
+[
+  GNULIB_MALLOC_POSIX=0;  AC_SUBST([GNULIB_MALLOC_POSIX])
+  GNULIB_REALLOC_POSIX=0; AC_SUBST([GNULIB_REALLOC_POSIX])
+  GNULIB_CALLOC_POSIX=0;  AC_SUBST([GNULIB_CALLOC_POSIX])
+  GNULIB_GETSUBOPT=0;     AC_SUBST([GNULIB_GETSUBOPT])
+  GNULIB_MKDTEMP=0;       AC_SUBST([GNULIB_MKDTEMP])
+  GNULIB_MKSTEMP=0;       AC_SUBST([GNULIB_MKSTEMP])
+  GNULIB_PUTENV=0;        AC_SUBST([GNULIB_PUTENV])
+  GNULIB_RPMATCH=0;       AC_SUBST([GNULIB_RPMATCH])
+  GNULIB_SETENV=0;        AC_SUBST([GNULIB_SETENV])
+  GNULIB_STRTOD=0;        AC_SUBST([GNULIB_STRTOD])
+  GNULIB_UNSETENV=0;      AC_SUBST([GNULIB_UNSETENV])
+  dnl Assume proper GNU behavior unless another module says otherwise.
+  HAVE_CALLOC_POSIX=1;    AC_SUBST([HAVE_CALLOC_POSIX])
+  HAVE_GETSUBOPT=1;       AC_SUBST([HAVE_GETSUBOPT])
+  HAVE_MALLOC_POSIX=1;    AC_SUBST([HAVE_MALLOC_POSIX])
+  HAVE_MKDTEMP=1;         AC_SUBST([HAVE_MKDTEMP])
+  HAVE_REALLOC_POSIX=1;   AC_SUBST([HAVE_REALLOC_POSIX])
+  HAVE_RPMATCH=1;         AC_SUBST([HAVE_RPMATCH])
+  HAVE_SETENV=1;          AC_SUBST([HAVE_SETENV])
+  HAVE_STRTOD=1;          AC_SUBST([HAVE_STRTOD])
+  HAVE_UNSETENV=1;        AC_SUBST([HAVE_UNSETENV])
+  REPLACE_MKSTEMP=0;      AC_SUBST([REPLACE_MKSTEMP])
+  REPLACE_PUTENV=0;       AC_SUBST([REPLACE_PUTENV])
+  REPLACE_STRTOD=0;       AC_SUBST([REPLACE_STRTOD])
+  VOID_UNSETENV=0;        AC_SUBST([VOID_UNSETENV])
+])
diff -Nurd -X.diff_ignore freeciv/Makefile.am freeciv/Makefile.am
--- freeciv/Makefile.am	2008-06-18 18:49:41.000000000 +0300
+++ freeciv/Makefile.am	2008-06-19 02:39:50.000000000 +0300
@@ -1,6 +1,6 @@
 ## Process this file with automake to produce Makefile.in
 
-ACLOCAL_AMFLAGS = -I m4
+ACLOCAL_AMFLAGS = -I m4 -I dependencies/m4
 
 if CLIENT
 CSUBDIRS = client
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to