From 2d00ead2e57653b771354a564f9a760c2ce0d18e Mon Sep 17 00:00:00 2001 From: aph Date: Fri, 31 Jan 2014 18:10:18 +0000 Subject: [PATCH] Fix build on OSX/Archlinux and add README - remove SELinux dependency for now - OSX: find libintl.h - OSX: fix compile errors - OSX: use hack around gettext nonsense - fix gettext on ubuntu - work around Arch's lack of -ltermcap - add README.md --- README.md | 26 ++++++++++++++++++++++++++ config/CMakeLists.txt | 12 ++++++++++++ config/config.h.in | 15 +++++++++------ src/CMakeLists.txt | 17 ++++++++++++++++- src/ex_cmds2.c | 9 ++------- src/ex_docmd.c | 9 +++------ src/ex_getln.c | 3 +-- src/mbyte.c | 2 +- src/os_unix.c | 8 -------- src/vim.h | 22 +++++++++++----------- 10 files changed, 81 insertions(+), 42 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 00000000000000..43a61e4e1bc558 --- /dev/null +++ b/README.md @@ -0,0 +1,26 @@ +Dependencies +============ + +For Ubuntu 12.04: + + sudo apt-get install build-essential cmake libncurses5-dev + +TODO: release the Dockerfile which has this in it + +TODO: Arch instructions + +TODO: OSX instructions + + +Building +======== + +To generate the `Makefile`s: + + make cmake + +To build and run the tests: + + make test + + diff --git a/config/CMakeLists.txt b/config/CMakeLists.txt index 3d9fd04c25a9be..36ffb0c81067a8 100644 --- a/config/CMakeLists.txt +++ b/config/CMakeLists.txt @@ -1,9 +1,21 @@ include(CheckTypeSize) +include(CheckCSourceCompiles) + check_type_size("int" SIZEOF_INT) check_type_size("long" SIZEOF_LONG) check_type_size("time_t" SIZEOF_TIME_T) check_type_size("off_t" SIZEOF_OFF_T) +check_c_source_compiles(" +#include + +int main(int argc, char** argv) { + gettext(\"foo\"); + bindtextdomain(\"foo\", \"bar\"); + bind_textdomain_codeset(\"foo\", \"bar\"); + textdomain(\"foo\"); +}" HAVE_WORKING_LIBINTL) + # generate configuration header and update include directories configure_file ( "${PROJECT_SOURCE_DIR}/config/config.h.in" diff --git a/config/config.h.in b/config/config.h.in index 6606c78c87f125..60729562af5131 100644 --- a/config/config.h.in +++ b/config/config.h.in @@ -14,7 +14,6 @@ #define _FILE_OFFSET_BITS 64 #define HAVE_ATTRIBUTE_UNUSED 1 #define HAVE_BCMP 1 -#define HAVE_BIND_TEXTDOMAIN_CODESET 1 #define HAVE_DATE_TIME 1 #define HAVE_DIRENT_H 1 #define HAVE_DLFCN_H 1 @@ -33,7 +32,6 @@ #define HAVE_GETPWNAM 1 #define HAVE_GETPWUID 1 #define HAVE_GETRLIMIT 1 -#define HAVE_GETTEXT 1 #define HAVE_GETTIMEOFDAY 1 #define HAVE_GETWD 1 #define HAVE_ICONV 1 @@ -61,7 +59,8 @@ #define HAVE_READLINK 1 #define HAVE_RENAME 1 #define HAVE_SELECT 1 -#define HAVE_SELINUX 1 +// TODO: add proper cmake check +// #define HAVE_SELINUX 1 #define HAVE_SETENV 1 #define HAVE_SETJMP_H 1 #define HAVE_SETPGID 1 @@ -82,11 +81,13 @@ #define HAVE_STRING_H 1 #define HAVE_STRINGS_H 1 #define HAVE_STRNCASECMP 1 -#define HAVE_STROPTS_H 1 +// TODO: add proper cmake check +// #define HAVE_STROPTS_H 1 #define HAVE_STRPBRK 1 #define HAVE_STRTOL 1 #define HAVE_SVR4_PTYS 1 -#define HAVE_SYSCONF 1 +// TODO: add proper cmake check +// #define HAVE_SYSCONF 1 #define HAVE_SYSINFO 1 #define HAVE_SYSINFO_MEM_UNIT 1 #define HAVE_SYS_IOCTL_H 1 @@ -96,7 +97,8 @@ #define HAVE_SYS_SELECT_H 1 #define HAVE_SYS_STATFS_H 1 #define HAVE_SYS_SYSCTL_H 1 -#define HAVE_SYS_SYSINFO_H 1 +// TODO: add proper cmake check +// #define HAVE_SYS_SYSINFO_H 1 #define HAVE_SYS_TIME_H 1 #define HAVE_SYS_TYPES_H 1 #define HAVE_SYS_UTSNAME_H 1 @@ -115,6 +117,7 @@ #define HAVE_UTIMES 1 #define HAVE_WCHAR_H 1 #define HAVE_WCTYPE_H 1 +#cmakedefine HAVE_WORKING_LIBINTL #define RETSIGTYPE void #define SIGRETURN return #define SYS_SELECT_WITH_SYS_TIME 1 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 65138a6d5de514..48aa9250fe2fa5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -14,5 +14,20 @@ file( GLOB IO_SOURCES io/*.c ) add_executable (vim ${NEOVIM_SOURCES} ${IO_SOURCES}) -target_link_libraries (vim m termcap selinux) +target_link_libraries (vim m) + +include(CheckLibraryExists) +check_library_exists(termcap tgetent "" HAVE_LIBTERMCAP) + +if (HAVE_LIBTERMCAP) + target_link_libraries(vim termcap) +else() + check_library_exists(curses tgetent "" HAVE_LIBCURSES) + if (HAVE_LIBCURSES) + target_link_libraries(vim curses) + else() + message(FATAL_ERROR "can't find something resembling -ltermcap") + endif() +endif() + include_directories ("${PROJECT_SOURCE_DIR}/src/proto") diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c index 42ccf5a416a67f..0162031b75d709 100644 --- a/src/ex_cmds2.c +++ b/src/ex_cmds2.c @@ -3349,11 +3349,7 @@ char_u * get_mess_lang() { } /* Complicated #if; matches with where get_mess_env() is used below. */ -#if (defined(FEAT_EVAL) && !((defined(HAVE_LOCALE_H) || defined(X_LOCALE)) \ - && defined(LC_MESSAGES))) \ - || ((defined(HAVE_LOCALE_H) || defined(X_LOCALE)) \ - && (defined(FEAT_GETTEXT) || defined(FEAT_MBYTE)) \ - && !defined(LC_MESSAGES)) +#ifdef HAVE_WORKING_LIBINTL static char_u *get_mess_env __ARGS((void)); /* @@ -3411,8 +3407,7 @@ void set_lang_var() { set_vim_var_string(VV_LC_TIME, loc, -1); } -#if (defined(HAVE_LOCALE_H) || defined(X_LOCALE)) \ - && (defined(FEAT_GETTEXT) || defined(FEAT_MBYTE)) +#ifdef HAVE_WORKING_LIBINTL /* * ":language": Set the language (locale). */ diff --git a/src/ex_docmd.c b/src/ex_docmd.c index d3d9c256beefb6..88fe8e1c5d3a97 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -206,8 +206,7 @@ static void ex_X __ARGS((exarg_T *eap)); static void ex_fold __ARGS((exarg_T *eap)); static void ex_foldopen __ARGS((exarg_T *eap)); static void ex_folddo __ARGS((exarg_T *eap)); -#if !((defined(HAVE_LOCALE_H) || defined(X_LOCALE)) \ - && (defined(FEAT_GETTEXT) || defined(FEAT_MBYTE))) +#ifndef HAVE_WORKING_LIBINTL # define ex_language ex_ni #endif # define ex_sign ex_ni @@ -3161,8 +3160,7 @@ char_u *buff; /* buffer for command string */ xp->xp_pattern = arg; break; -#if (defined(HAVE_LOCALE_H) || defined(X_LOCALE)) \ - && (defined(FEAT_GETTEXT) || defined(FEAT_MBYTE)) +#ifdef HAVE_WORKING_LIBINTL case CMD_language: p = skiptowhite(arg); if (*p == NUL) { @@ -4452,8 +4450,7 @@ static struct { {EXPAND_HELP, "help"}, {EXPAND_HIGHLIGHT, "highlight"}, {EXPAND_HISTORY, "history"}, -#if (defined(HAVE_LOCALE_H) || defined(X_LOCALE)) \ - && (defined(FEAT_GETTEXT) || defined(FEAT_MBYTE)) +#ifdef HAVE_WORKING_LIBINTL {EXPAND_LOCALES, "locale"}, #endif {EXPAND_MAPPINGS, "mapping"}, diff --git a/src/ex_getln.c b/src/ex_getln.c index ee9fc079fe36f5..dbef0a9449e346 100644 --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -3783,8 +3783,7 @@ int options; /* EW_ flags */ {EXPAND_AUGROUP, get_augroup_name, TRUE, TRUE}, {EXPAND_CSCOPE, get_cscope_name, TRUE, TRUE}, {EXPAND_PROFILE, get_profile_name, TRUE, TRUE}, -#if (defined(HAVE_LOCALE_H) || defined(X_LOCALE)) \ - && (defined(FEAT_GETTEXT) || defined(FEAT_MBYTE)) +#ifdef HAVE_WORKING_LIBINTL {EXPAND_LANGUAGE, get_lang_arg, TRUE, FALSE}, {EXPAND_LOCALES, get_locales, TRUE, FALSE}, #endif diff --git a/src/mbyte.c b/src/mbyte.c index 66f26826c49acd..8b7abe15eefbd3 100644 --- a/src/mbyte.c +++ b/src/mbyte.c @@ -612,7 +612,7 @@ char_u * mb_init() { set_string_option_direct((char_u *)"fencs", -1, (char_u *)"ucs-bom,utf-8,default,latin1", OPT_FREE, 0); -#if defined(HAVE_BIND_TEXTDOMAIN_CODESET) && defined(FEAT_GETTEXT) +#ifdef HAVE_WORKING_LIBINTL /* GNU gettext 0.10.37 supports this feature: set the codeset used for * translated messages independently from the current locale. */ (void)bind_textdomain_codeset(VIMPACKAGE, diff --git a/src/os_unix.c b/src/os_unix.c index 83a65cf9b5252d..cf50cfb28e37eb 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -623,14 +623,6 @@ static char *signal_stack; static void init_signal_stack() { if (signal_stack != NULL) { # ifdef HAVE_SIGALTSTACK -# if defined(__APPLE__) && (!defined(MAC_OS_X_VERSION_MAX_ALLOWED) \ - || MAC_OS_X_VERSION_MAX_ALLOWED <= 1040) - /* missing prototype. Adding it to osdef?.h.in doesn't work, because - * "struct sigaltstack" needs to be declared. */ - extern int sigaltstack __ARGS((const struct sigaltstack *ss, - struct sigaltstack *oss)); -# endif - sigstk.ss_sp = signal_stack; sigstk.ss_size = SIGSTKSZ; sigstk.ss_flags = 0; diff --git a/src/vim.h b/src/vim.h index 3095dbf54193b2..93f66cf4380007 100644 --- a/src/vim.h +++ b/src/vim.h @@ -336,22 +336,22 @@ typedef unsigned long u8char_T; /* long should be 32 bits or more */ # define USE_IM_CONTROL #endif -/* - * For dynamically loaded gettext library. Currently, only for Win32. - */ - - -/* - * The _() stuff is for using gettext(). It is a no-op when libintl.h is not - * found or the +multilang feature is disabled. - */ +#ifdef HAVE_WORKING_LIBINTL # include # define _(x) gettext((char *)(x)) +// XXX do we actually need this? # ifdef gettext_noop -# define N_(x) gettext_noop(x) +# define N_(x) gettext_noop(x) # else -# define N_(x) x +# define N_(x) x # endif +#else +# define _(x) ((char *)(x)) +# define N_(x) x +# define bindtextdomain(x, y) /* empty */ +# define bind_textdomain_codeset(x, y) /* empty */ +# define textdomain(x) /* empty */ +#endif /* * flags for update_screen()