Skip to content

Commit

Permalink
Fix build on OSX/Archlinux and add README
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
ashleyh authored and tarruda committed Feb 1, 2014
1 parent 72cf89b commit 2d00ead
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 42 deletions.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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


12 changes: 12 additions & 0 deletions config/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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 <libintl.h>
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"
Expand Down
15 changes: 9 additions & 6 deletions config/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
17 changes: 16 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
9 changes: 2 additions & 7 deletions src/ex_cmds2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));

/*
Expand Down Expand Up @@ -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).
*/
Expand Down
9 changes: 3 additions & 6 deletions src/ex_docmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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"},
Expand Down
3 changes: 1 addition & 2 deletions src/ex_getln.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/mbyte.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 0 additions & 8 deletions src/os_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
22 changes: 11 additions & 11 deletions src/vim.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <libintl.h>
# 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()
Expand Down

0 comments on commit 2d00ead

Please sign in to comment.