# $FreeWRT$
#-
# This file is part of the FreeWRT project. FreeWRT is copyrighted
# material, please see the LICENCE file in the top-level directory
# or at http://www.freewrt.org/licence for details.

include $(TOPDIR)/rules.mk

PKG_NAME:=		vim
PKG_VERSION:=		5.8
PKG_RELEASE:=		1
PKG_MD5SUM:=		89ab05bb5cd39eeb9e259503436c11ed

PKG_SOURCE_URL:=	ftp://ftp.vim.org/pub/vim/unix/
PKG_SOURCE:=		$(PKG_NAME)-$(PKG_VERSION)-src.tar.gz

include $(TOPDIR)/mk/package.mk

$(eval $(call PKG_template,VIM,vim,$(PKG_VERSION)-$(PKG_RELEASE),$(ARCH)))

# -Os segfaults vim in yank mode 
$(WRKBUILD)/.configured:
	(cd $(WRKBUILD)/src; rm -rf config.cache; \
		$(TARGET_CONFIGURE_OPTS) \
		CFLAGS="-fno-ident -I$(STAGING_DIR)/usr/include" \
		LDFLAGS="-L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib" \
		ac_cv_c_bigendian=no \
		ac_cv_sizeof_off_t=8 \
		ac_cv_sizeof_int=4 \
		./configure \
		--target=$(GNU_TARGET_NAME) \
		--host=$(GNU_TARGET_NAME) \
		--build=$(GNU_HOST_NAME) \
		--prefix=/usr \
		--exec-prefix=/usr \
		--bindir=/usr/bin \
		--sbindir=/usr/sbin \
		--libexecdir=/usr/lib \
		--sysconfdir=/etc \
		--datadir=/usr/share \
		--localstatedir=/var \
		--mandir=/usr/man \
		--infodir=/usr/info \
		--program-prefix="" \
		--disable-nls \
		--enable-min-features \
		--disable-gui \
		--without-x \
		--disable-multibyte \
		--disable-cscope \
		--disable-gpm \
		--with-tlib=ncurses \
	);
	touch $@

$(WRKBUILD)/.built: $(WRKBUILD)/.configured
	$(MAKE) -C $(WRKBUILD) \
		CC=$(TARGET_CC)
	touch $@

$(IPKG_VIM): 
	mkdir -p $(IDIR_VIM)/usr/bin
	mkdir -p $(IDIR_VIM)//usr/share/vim
	$(CP) ./files/vimrc $(IDIR_VIM)//usr/share/vim
	$(CP) $(WRKBUILD)/src/$(PKG_NAME) $(IDIR_VIM)/usr/bin/
	$(RSTRIP) $(IDIR_VIM)
	$(IPKG_BUILD) $(IDIR_VIM) $(PACKAGE_DIR)
