vim: Import Android makefiles

Change-Id: Ib05975fee1c91082618c364f7cfa57f942d694db
diff --git a/Android.mk b/Android.mk
new file mode 100644
index 0000000..dbbaacf
--- /dev/null
+++ b/Android.mk
@@ -0,0 +1,212 @@
+
+vim_src := $(call my-dir)
+
+# ========================================================
+# etc/vimrc
+# ========================================================
+
+LOCAL_PATH := $(vim_src)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := vimrc
+LOCAL_MODULE_TAGS := eng
+LOCAL_MODULE_CLASS := ETC
+
+LOCAL_SRC_FILES := vimrc.android
+
+include $(BUILD_PREBUILT)
+
+# ========================================================
+# vim
+# ========================================================
+
+LOCAL_PATH := $(vim_src)/src
+include $(CLEAR_VARS)
+
+# vim variants: TINY SMALL CM NORMAL BIG HUGE
+#
+# NORMAL, BIG and HUGE are almost the same (1.1M)
+# TINY and SMALL are similar to busybox vi (460K)
+#
+# CM profile is between SMALL and NORMAL (780K)
+# with syntax and utf8 (mbyte) support
+#
+vim_variant := CM
+
+LOCAL_SRC_FILES := \
+	auto/pathdef.c \
+	blowfish.c \
+	buffer.c \
+	channel.c \
+	charset.c \
+	dict.c \
+	diff.c \
+	digraph.c \
+	edit.c \
+	eval.c \
+	evalfunc.c \
+	ex_cmds.c \
+	ex_cmds2.c \
+	ex_docmd.c \
+	ex_eval.c \
+	ex_getln.c \
+	fileio.c \
+	fold.c \
+	getchar.c \
+	hardcopy.c \
+	hashtab.c \
+	if_cscope.c \
+	if_xcmdsrv.c \
+	json.c \
+	list.c \
+	main.c \
+	mark.c \
+	mbyte.c \
+	memfile.c \
+	memline.c \
+	menu.c \
+	message.c \
+	misc1.c \
+	misc2.c \
+	move.c \
+	normal.c \
+	ops.c \
+	option.c \
+	os_unix.c \
+	popupmnu.c \
+	quickfix.c \
+	regexp.c \
+	screen.c \
+	search.c \
+	sha256.c \
+	spell.c \
+	syntax.c \
+	tag.c \
+	term.c \
+	ui.c \
+	undo.c \
+	userfunc.c \
+	version.c \
+	window.c
+
+# to reduce vim size, manually define wanted features
+ifeq ($(vim_variant),CM)
+    LOCAL_CFLAGS += -DFEAT_SMALL=1 -DFEAT_MBYTE=1 \
+	-DFEAT_SYN_HL=1 -DFEAT_CINDENT=1 -DFEAT_COMMENTS=1 -DFEAT_EVAL=1 -DFEAT_AUTOCMD=1 \
+	-DFEAT_USR_CMDS=1 -DFEAT_EX_EXTRA=1 -DFEAT_CMDL_COMPL=1 \
+	-DFEAT_LISTCMDS=1 -DFEAT_CMDL_INFO=1 -DFEAT_SEARCH_EXTRA=1
+ifeq ($(TARGET_IS_64_BIT), true)
+    LOCAL_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
+endif
+endif
+
+LOCAL_C_INCLUDES += \
+	external/libselinux/include \
+	external/libncurses/include \
+	$(LOCAL_PATH)/proto \
+	$(LOCAL_PATH)/auto
+
+LOCAL_SHARED_LIBRARIES += \
+	libselinux \
+	libncurses \
+	libm \
+	libdl
+
+LOCAL_CFLAGS += \
+	-DFEAT_$(vim_variant)=1 \
+	-DHAVE_CONFIG_H \
+	-DSYS_VIMRC_FILE=\"/system/etc/vimrc\"
+
+LOCAL_MODULE := vim
+LOCAL_MODULE_TAGS := eng
+LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
+LOCAL_REQUIRED_MODULES := vimrc
+include $(BUILD_EXECUTABLE)
+
+# ========================================================
+# vim runtime files
+# ========================================================
+ifeq (vim,$(filter vim, $(ALL_MODULES)))
+
+vim_runtime_path := $(vim_src)/runtime
+
+vim_runtime_files := \
+	scripts.vim \
+	indent.vim \
+	indoff.vim \
+	filetype.vim \
+	ftoff.vim
+
+vim_doc_files := \
+	help.txt intro.txt tags \
+	motion.txt editing.txt scroll.txt \
+	options.txt term.txt
+
+vim_colors_files := \
+	default.vim \
+	desert.vim
+
+vim_syntax_files := \
+	logcat.vim \
+	awk.vim \
+	config.vim \
+	conf.vim \
+	cpp.vim \
+	c.vim \
+	css.vim \
+	diff.vim \
+	doxygen.vim \
+	html.vim vb.vim \
+	xml.vim dtd.vim \
+	context.vim \
+	gitcommit.vim \
+	help.vim \
+	javascript.vim \
+	java.vim \
+	lua.vim \
+	manual.vim \
+	markdown.vim \
+	pod.vim \
+	sh.vim \
+	syncolor.vim \
+	synload.vim \
+	syntax.vim \
+	vim.vim
+
+vim_plugin_files := \
+	matchparen.vim \
+
+vim_autoload_files := \
+	spacehi.vim
+
+VIM_SHARED := $(TARGET_OUT)/usr/share/vim
+
+vim_runtime_files := \
+  $(vim_runtime_files) \
+  $(addprefix doc/, $(vim_doc_files)) \
+  $(addprefix colors/, $(vim_colors_files)) \
+  $(addprefix syntax/, $(vim_syntax_files)) \
+  $(addprefix plugin/, $(vim_plugin_files)) \
+  $(addprefix autoload/, $(vim_autoload_files)) \
+
+$(vim_runtime_files): $(LOCAL_BUILT_MODULE)
+	@echo "Install: $(VIM_SHARED)/$@"
+	@mkdir -p $(dir $(VIM_SHARED)/$@)
+	$(hide) cp $(vim_runtime_path)/$@ $(VIM_SHARED)/$@
+
+ALL_DEFAULT_INSTALLED_MODULES += $(vim_runtime_files)
+
+ALL_MODULES.$(LOCAL_MODULE).INSTALLED := \
+  $(ALL_MODULES.$(LOCAL_MODULE).INSTALLED) \
+  $(addprefix $(VIM_SHARED)/, $(vim_runtime_files))
+
+ifneq ($(filter B wB,$(MAKEFLAGS)),)
+# Allow to push runtime files with 'mmp -B'
+vim: $(vim_runtime_files)
+	@echo "Forced install of runtime files..."
+endif
+
+endif
+
+include $(call all-makefiles-under,$(vim_src))
+
diff --git a/src/version.c b/src/version.c
index 1224142..45b0553 100644
--- a/src/version.c
+++ b/src/version.c
@@ -50,7 +50,7 @@
     strcat(longVersion, ")");
 }
 # else
-char	*longVersion = VIM_VERSION_LONG_DATE __DATE__ " " __TIME__ ")";
+char	*longVersion = VIM_VERSION_LONG;
 # endif
 #else
 char	*longVersion = VIM_VERSION_LONG;
diff --git a/src/xxd/Android.mk b/src/xxd/Android.mk
new file mode 100644
index 0000000..03f3bef
--- /dev/null
+++ b/src/xxd/Android.mk
@@ -0,0 +1,17 @@
+LOCAL_PATH:= $(call my-dir)
+
+# ========================================================
+# xxd (hex editor)
+# ========================================================
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= \
+	xxd.c
+
+LOCAL_CFLAGS := -DUNIX
+
+LOCAL_MODULE := xxd
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
+include $(BUILD_EXECUTABLE)
+
diff --git a/vim.sh b/vim.sh
new file mode 100644
index 0000000..10e0724
--- /dev/null
+++ b/vim.sh
@@ -0,0 +1,13 @@
+#!/system/bin/sh
+
+if [ "`ttysize`" = "0 0" ]; then
+
+	# call busybox resize to allow vim fullscreen
+	resize
+
+	# export COLUMNS=`stty size | cut -d " " -f 2`
+	# export LINES=`stty size | cut -d " " -f 1`
+	# echo "$COLUMNS x $LINES"
+fi
+
+vim $*
diff --git a/vimrc.android b/vimrc.android
new file mode 100644
index 0000000..3c95fdb
--- /dev/null
+++ b/vimrc.android
@@ -0,0 +1,111 @@
+" vimrc default android config file
+" 
+" Adapted for Android by tpruvot@github
+" Last change: 2014 Jul 22 (UTF-8)
+
+" When started as "evim", evim.vim will already have done these settings.
+if v:progname =~? "evim"
+  finish
+endif
+
+" Use Vim settings, rather than Vi settings (much better!).
+" This must be first, because it changes other options as a side effect.
+set nocompatible
+
+" allow backspacing over everything in insert mode
+set backspace=indent,eol,start
+
+" swap directories
+set directory=.,/data/local/tmp,/tmp
+
+if has("vms")
+  set nobackup		" do not keep a backup file, use versions instead
+else
+" set backup		" keep a backup file (restore to previous version)
+  set undofile		" keep an undo file (undo changes after closing)
+endif
+set history=50		" keep 50 lines of command line history
+set ruler		" show the cursor position all the time
+set showcmd		" display incomplete commands
+set incsearch		" do incremental searching
+
+set viminfo="NONE"
+
+" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
+" let &guioptions = substitute(&guioptions, "t", "", "g")
+
+" Don't use Ex mode, use Q for formatting
+map Q gq
+
+" CTRL-U in insert mode deletes a lot.  Use CTRL-G u to first break undo,
+" so that you can undo CTRL-U after inserting a line break.
+inoremap <C-U> <C-G>u<C-U>
+
+" In many terminal emulators the mouse works just fine, thus enable it.
+if has('mouse')
+  set mouse=a
+endif
+
+" Switch syntax highlighting on, when the terminal has colors
+" Also switch on highlighting the last used search pattern.
+if &t_Co > 2 || has("gui_running")
+  syntax on
+  set hlsearch
+endif
+
+" Only do this part when compiled with support for autocommands.
+if has("autocmd")
+
+  " Enable file type detection.
+  " Use the default filetype settings, so that mail gets 'tw' set to 72,
+  " 'cindent' is on in C files, etc.
+  " Also load indent files, to automatically do language-dependent indenting.
+  filetype plugin indent on
+
+  " Put these in an autocmd group, so that we can delete them easily.
+  augroup vimrcEx
+  au!
+
+  " For all text files set 'textwidth' to 78 characters.
+  autocmd FileType text setlocal textwidth=78
+
+  " When editing a file, always jump to the last known cursor position.
+  " Don't do it when the position is invalid or when inside an event handler
+  " (happens when dropping a file on gvim).
+  " Also don't do it when the mark is in the first line, that is the default
+  " position when opening a file.
+  autocmd BufReadPost *
+    \ if line("'\"") > 1 && line("'\"") <= line("$") |
+    \   exe "normal! g`\"" |
+    \ endif
+
+  augroup END
+
+else
+
+  set autoindent		" always set autoindenting on
+
+endif " has("autocmd")
+
+" UTF-8 support
+if has("multi_byte")
+  if &termencoding == ""
+    let &termencoding = "utf-8"
+  endif
+  set encoding=utf-8
+  setglobal fileencoding=utf-8
+  " setglobal bomb " Do not force BOM headers
+  set fileencodings=ucs-bom,utf-8,latin1
+endif
+
+if has("syntax")
+  source /system/usr/share/vim/autoload/spacehi.vim
+endif
+
+" Convenient command to see the difference between the current buffer and the
+" file it was loaded from, thus the changes you made.
+" Only define it when not defined already.
+if !exists(":DiffOrig")
+  command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
+		  \ | wincmd p | diffthis
+endif