OpenWrt Forum Archive

Topic: dovecot fts-elasticsearch plugin package creating

The content of this topic has been archived on 6 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I am trying to compile a dovecot plugin that can use elasticsearch, which is basically a wrapper that sends json commands to elasticsearch nodes.

https://github.com/ascendantcom/fts-elasticsearch

the normal compile sequence is:
./autogen.sh
./configure --with-dovecot=/path/to/dovecot/src/root
make
make install

I haven't found any package Makefile example with autogen.sh, so I think this means I have to setup my own configure/Makefiles??

So far I have the following Makefile placed in package/fts-elasticsearch and it seems to take care of the downloading and dependencies (dovecot + libjson-c).

include $(TOPDIR)/rules.mk
                                                                                                                                                                                     
PKG_NAME:=fts-elasticsearch     
PKG_VERSION:=20150731
PKG_RELEASE=1                                                                                                                                                                        
                                                                                                                                                                                     
PKG_SOURCE:=$(PKG_NAME)-$(PKG_SOURCE_VERSION).tar.bz2                                                                                                
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)                                                                                                             
PKG_SOURCE_URL:=https://github.com/ascendantcom/fts-elasticsearch.git
PKG_SOURCE_PROTO:=git                                                                                                                                                           
PKG_SOURCE_VERSION:=HEAD                                                                                                                                                             
include $(INCLUDE_DIR)/package.mk
                                                                                                                                            
define Package/fts-elasticsearch
  SECTION:=mail                                                                                                                                                                      
  CATEGORY:=Mail                                                                                                                                                                     
  DEPENDS:=+dovecot +libjson-c
  TITLE:=fts-elasticsearch plugin for dovecot
endef                                                                                                                                                                                
                                                                                                                                                                                     
define Package/fts-elasticsearch/description
  fts-elasticsearch plugin for dovecot
endef                                                                                                                                                                                
                                                                                                                                                                                     
$(eval $(call BuildPackage,fts-elasticsearch))

What I don't seem to be able to grasp is what needs to be in the package Makefile so that I can incorporate the following from src/Makefile.am so I can compile the actual code?

AM_CFLAGS= \
    -I$(dovecotdir)/src/plugins/fts \
        $(LIBDOVECOT_INCLUDE) 

AM_LDFLAGS= -ljson-c 

lib21_fts_elasticsearch_plugin_la_LDFLAGS = -module -avoid-version

lib21_fts_elasticsearch_plugin_ladir = $(dovecot_pkglibdir)
lib21_fts_elasticsearch_plugin_la_LTLIBRARIES = lib21_fts_elasticsearch_plugin.la
lib21_fts_elasticsearch_plugin_la_SOURCES = fts-elasticsearch-plugin.c fts-backend-elasticsearch.c elasticsearch-conn.c

Is it just me or is the package making documentation really cryptic?  I suppose it's very difficult to cover all possible ways to compile.

Any packaging experts here whom can throw me a few Makefile lines on what to try?

Anyone else have done any dovecot plugin packages?

I guess first I need to know how to invoke the following in the package Makefile:

CC  -I$BUILD_DIR/$(dovecotdir)/src/plugins/fts  $BUILD_DIR/$(LIBDOVECOT_INCLUDE) -ljson-c fts-elasticsearch-plugin.c fts-backend-elasticsearch.c elasticsearch-conn.c

and compile it to lib21_fts_elasticsearch_plugin.la

???

(Last edited by whoisterencelee on 6 Aug 2015, 11:49)

For these who followed similar train of thought:

1)  I found that the best resource to learn about the buildroot based Makefile is going to the *.mk in openwrt/include and start with package.mk

2)  the autogen.sh compile sequence is taken care by autotools.mk and is invoked by the following in the Makefile (it wasn't  clear for me that this is really the case):

FIXUP:=autoreconf

3)  Package/Install directive is required in the Makefile in order for it to do downloading/compiling.

4)  Package can be individually compiled using:

make package/fts-elasticsearch/compile V=s


So with below Makefile I can download the source and start compiling.

But got a problem with "configure" thinking that one of the compiler test should be able to compile an executable program?  I am guessing since I am doing a cross-compile the mips-openwrt-gcc compiler doesn't generate an executable that my host machine can execute.

config.log:

configure:4898: result: no
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "fts-elasticsearch"
| #define PACKAGE_TARNAME "fts-elasticsearch"
| #define PACKAGE_VERSION "0.1.0"
| #define PACKAGE_STRING "fts-elasticsearch 0.1.0"
| #define PACKAGE_BUGREPORT "https://github.com/ascendantcom/fts-elasticsearch"
| #define PACKAGE_URL ""
| #define FTS_ELASTICSEARCH_NAME "fts-elasticsearch"
| #define FTS_ELASTICSEARCH_VERSION "0.1.0"
| /* end confdefs.h.  */
|
| int
| main ()
| {
|
|   ;
|   return 0;
| }
configure:4903: error: in `/home/terence/openwrt/barrier/openwrt/build_dir/target-mips_34kc_uClibc-0.9.33.2/fts-elasticsearch-20150731':
configure:4905: error: C compiler cannot create executables

Makefile:

include $(TOPDIR)/rules.mk

PKG_NAME:=fts-elasticsearch
PKG_VERSION:=20150731
PKG_SOURCE_VERSION:=HEAD
PKG_RELEASE=$(PKG_SOURCE_VERSION)

PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/ascendantcom/fts-elasticsearch.git
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz

#PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)

#DUMP:=yes
PKG_FIXUP:=autoreconf
#PKG_FIXUP:=patch-libtool
#PKG_FIXUP:=gettext-version

CONFIGURE_ARGS += \
        --with-dovecot=$(BUILD_DIR)/dovecot-2.2.13/src

include $(INCLUDE_DIR)/package.mk

define Package/fts-elasticsearch
  TITLE:=fts-elasticsearch plugin for dovecot
  CATEGORY:=Mail
  SECTION:=mail
  DEPENDS:=+dovecot +libjson-c
  URL:=https://github.com/ascendantcom/fts-elasticsearch.git
endef

define Package/fts-elasticsearch/description
  fts-elasticsearch plugin for dovecot
endef

define Package/fts-elasticsearch/install
  echo test
endef

$(eval $(call BuildPackage,fts-elasticsearch))

According to config.log there is a fstack-protector-strong option that's not being recognized by the cross compiler.

How to disable it?
Where do I put fno-stack-protector-strong in the package Makefile?

You can use TARGET_CFLAGS += to add any flags into your OpenWRT Makefile for the package as shown below:

TARGET_CFLAGS += fno-stack-protector-strong

BTW, R U sure it is fno-stack-protector-strong and not -fno-stack-protector-strong ?

Thanks mazilo

TARGET_CFLAGS += -fno-stack-protector-strong

with dash before fno, seems to got me pass the executable test error.

Now it's this:

configure: WARNING: unrecognized options: --disable-nls
configure: loading site script /home/terence/openwrt/barrier/openwrt/include/site/mips-openwrt-linux-uclibc
configure: error: cannot find install-sh, install.sh, or shtool in "." "./.." "./../.."

The configure: WARNING: unrecognized options: --disable-nls is harmless, AFAICT.

But, this configure: error: cannot find install-sh, install.sh, or shtool in "." "./.." "./../.." needs some fixes.

(Last edited by mazilo on 20 Oct 2015, 05:17)

Regarding:

configure: error: cannot find install-sh, install.sh, or shtool in "." "./.." "./../.."

Turns out on arch linux install-sh is in /usr/share/automake-1.15/

How to specific the am_aux_dir?

The discussion might have continued from here.