From 3eaa6b4618f568b27f65d656737dd5c2023aad4f Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Fri, 30 Apr 2021 04:37:20 +0300 Subject: [PATCH 45/45] Generate separate configuration header to be used for in-tree liblua build Definitions from full fc_config.h can cause trouble in liblua build. Generate and use separate config header that has just the definitions needed in liblua build. Reported by jdlh See osdn #42114 Signed-off-by: Marko Lindqvist --- configure.ac | 2 +- dependencies/lua-5.4/src/localluaconf.h | 5 +-- gen_headers/.gitignore | 1 + gen_headers/Makefile.am | 1 + gen_headers/liblua_config.h.in | 47 +++++++++++++++++++++++++ gen_headers/meson_liblua_config.h.in | 47 +++++++++++++++++++++++++ meson.build | 31 ++++++++++++---- 7 files changed, 123 insertions(+), 11 deletions(-) create mode 100644 gen_headers/liblua_config.h.in create mode 100644 gen_headers/meson_liblua_config.h.in diff --git a/configure.ac b/configure.ac index f59b089595..e7ab4f5350 100644 --- a/configure.ac +++ b/configure.ac @@ -11,7 +11,7 @@ AC_CONFIG_SRCDIR([common/game.c]) AC_CONFIG_AUX_DIR(bootstrap) # This can't be quoted or automake will fail AC_CONFIG_MACRO_DIR([m4]) ifdef([AC_CONFIG_MACRO_DIRS],[AC_CONFIG_MACRO_DIRS([dependencies/m4])]) -AC_CONFIG_HEADERS([gen_headers/fc_config.h gen_headers/freeciv_config.h]) +AC_CONFIG_HEADERS([gen_headers/fc_config.h gen_headers/freeciv_config.h gen_headers/liblua_config.h]) AC_CANONICAL_HOST AC_USE_SYSTEM_EXTENSIONS AC_C_BIGENDIAN diff --git a/dependencies/lua-5.4/src/localluaconf.h b/dependencies/lua-5.4/src/localluaconf.h index d3fdf8f500..fa58005bcd 100644 --- a/dependencies/lua-5.4/src/localluaconf.h +++ b/dependencies/lua-5.4/src/localluaconf.h @@ -14,12 +14,9 @@ #define FC__LOCALLUACONF_H #ifdef HAVE_CONFIG_H -#include +#include #endif -/* Lua headers want to define VERSION to lua version */ -#undef VERSION - #if defined(HAVE_MKSTEMP) && defined(FREECIV_HAVE_UNISTD_H) #define LUA_USE_MKSTEMP #endif diff --git a/gen_headers/.gitignore b/gen_headers/.gitignore index 8089a16580..9fa7108d60 100644 --- a/gen_headers/.gitignore +++ b/gen_headers/.gitignore @@ -1,5 +1,6 @@ /Makefile.in /Makefile +/liblua_config.h /fc_config.h /fc_config.h.in /freeciv_config.h diff --git a/gen_headers/Makefile.am b/gen_headers/Makefile.am index a6b04da2c1..cdfbedee9b 100644 --- a/gen_headers/Makefile.am +++ b/gen_headers/Makefile.am @@ -2,6 +2,7 @@ EXTRA_DIST = \ generate_version_header.sh \ + liblua_config.h.in \ freeciv_config.h.in BUILT_SOURCES = version_gen.h diff --git a/gen_headers/liblua_config.h.in b/gen_headers/liblua_config.h.in new file mode 100644 index 0000000000..4740316f92 --- /dev/null +++ b/gen_headers/liblua_config.h.in @@ -0,0 +1,47 @@ +/*********************************************************************** + 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. +***********************************************************************/ + +/* This header is generated from gen_headers/liblua_config.h.in. + It includes definitions needed by the in-tree liblua compilation. */ + +#ifndef FC__LIBLUA_CONFIG_H +#define FC__LIBLUA_CONFIG_H + +/* mkstemp() available */ +#undef HAVE_MKSTEMP + +/* unistd.h available */ +#undef FREECIV_HAVE_UNISTD_H + +/* popen() available */ +#undef HAVE_POPEN + +/* pclose() available */ +#undef HAVE_PCLOSE + +/* _longjmp() available */ +#undef HAVE__LONGJMP + +/* _setjmp() available */ +#undef HAVE__SETJMP + +/* gmtime_r() available */ +#undef HAVE_GMTIME_R + +/* localtime_r() available */ +#undef HAVE_LOCALTIME_R + +/* fseeko() available */ +#undef HAVE_FSEEKO + +#endif /* FC__LIBLUA_CONFIG_H */ diff --git a/gen_headers/meson_liblua_config.h.in b/gen_headers/meson_liblua_config.h.in new file mode 100644 index 0000000000..4148501cb5 --- /dev/null +++ b/gen_headers/meson_liblua_config.h.in @@ -0,0 +1,47 @@ +/*********************************************************************** + 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. +***********************************************************************/ + +/* This header is generated from gen_headers/meson_liblua_config.h.in. + It includes definitions needed by the in-tree liblua compilation. */ + +#ifndef FC__LIBLUA_CONFIG_H +#define FC__LIBLUA_CONFIG_H + +/* mkstemp() available */ +#mesondefine HAVE_MKSTEMP + +/* unistd.h available */ +#mesondefine FREECIV_HAVE_UNISTD_H + +/* popen() available */ +#mesondefine HAVE_POPEN + +/* pclose() available */ +#mesondefine HAVE_PCLOSE + +/* _longjmp() available */ +#mesondefine HAVE__LONGJMP + +/* _setjmp() available */ +#mesondefine HAVE__SETJMP + +/* gmtime_r() available */ +#mesondefine HAVE_GMTIME_R + +/* localtime_r() available */ +#mesondefine HAVE_LOCALTIME_R + +/* fseeko() available */ +#mesondefine HAVE_FSEEKO + +#endif /* FC__LIBLUA_CONFIG_H */ diff --git a/meson.build b/meson.build index 43cdbd774d..ff61e8ffa0 100644 --- a/meson.build +++ b/meson.build @@ -16,6 +16,7 @@ host_system = host_machine.system() priv_conf_data = configuration_data() pub_conf_data = configuration_data() +liblua_conf_data = configuration_data() pub_conf_data.set('FREECIV_AI_MOD_LAST', 3) priv_conf_data.set('LOCALEDIR', @@ -137,14 +138,10 @@ priv_functions = [ 'getline', 'getnameinfo', 'getpwuid', - 'gmtime_r', 'inet_aton', 'inet_ntop', 'inet_pton', - 'localtime_r', 'opendir', - 'pclose', - 'popen', 'putenv', 'select', 'setenv', @@ -160,9 +157,7 @@ priv_functions = [ 'usleep', 'vprintf', 'vsnprintf', - '_longjmp', '_mkdir', - '_setjmp', '_strcoll', '_stricoll', 'fcntl', @@ -175,6 +170,27 @@ foreach func : priv_functions endif endforeach +liblua_functions = [ + 'mkstemp', + 'popen', + 'pclose', + '_longjmp', + '_setjmp', + 'gmtime_r', + 'localtime_r', + 'fseeko' + ] + +foreach func : liblua_functions + if c_compiler.has_function(func) + liblua_conf_data.set('HAVE_' + func.underscorify().to_upper(), 1) + endif +endforeach + +if c_compiler.has_header('unistd.h') + liblua_conf_data.set('FREECIV_HAVE_UNISTD_H', 1) +endif + if c_compiler.has_function('BCryptGenRandom', args: '-lbcrypt') bcrypt_lib_dep = c_compiler.find_library('bcrypt') priv_conf_data.set('HAVE_BCRYPTGENRANDOM', 1) @@ -314,6 +330,9 @@ configure_file(input : 'gen_headers/meson_fc_config.h.in', configure_file(input : 'gen_headers/meson_freeciv_config.h.in', output : 'freeciv_config.h', configuration: pub_conf_data) +configure_file(input : 'gen_headers/meson_liblua_config.h.in', + output : 'liblua_config.h', + configuration: liblua_conf_data) add_global_arguments('-DHAVE_CONFIG_H', language: 'c') -- 2.30.2