Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added autotools support

  • Loading branch information...
commit 1aeea7ce3d00c1dc51baab23e558345bc66d5ba5 1 parent cfd391c
@saleyn saleyn authored
View
9 Makefile.am
@@ -1,7 +1,9 @@
+ACLOCAL_AMFLAGS = -I m4
+
TARBALL=zmq.tgz
TARBALL_EXCLUDE=/tmp/exclude.xxx
-SUBDIRS = src
+SUBDIRS = c_src src
#docs:
# @${MAKE} --directory=src $@
@@ -9,7 +11,10 @@ SUBDIRS = src
gitdocs: docs
./bin/update_docs
-tar:
+clean-bootstrap: distclean
+ rm -fr aclocal.m4 autom4te.cache build-aux config.h.in configure \
+ m4/l* m4/version Makefile.in priv doc zmq.tgz
+dist:
@echo Creating $(TARBALL)
@DIR=$${PWD##*/} && pushd .. > /dev/null && \
echo -e "*.o\n*.d\n.git\n*.tgz\n.*.*\n~\n.~*#\ntags\n" > $(TARBALL_EXCLUDE) && \
View
4 bootstrap
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+sed 's/[^=]\+=//' ./vsn.mk > m4/version
+autoreconf --install
View
30 c_src/Makefile
@@ -0,0 +1,30 @@
+ZMQ_DIR=/opt/zeromq-2.0.6
+
+ERL ?= erl
+ERL_INTERFACE_DIR=$(shell \
+ $(ERL) -eval 'io:format("~s\n", [code:lib_dir(erl_interface)]).' \
+ -noshell -s erlang halt)
+ERL_INSTALL_DIR := $(patsubst %/,%,$(dir $(ERL_INTERFACE_DIR)))
+ERL_INSTALL_DIR := $(patsubst %/,%,$(dir $(ERL_INSTALL_DIR)))
+
+ifeq (,$(ERL_INSTALL_DIR))
+$(error Erlang installation directory not found)
+endif
+
+LDFLAGS=-shared -fPIC ${ERL_INTERFACE_DIR}/lib/libei.a -L${ZMQ_DIR}/lib -lzmq -lpthread -luuid
+CFLAGS=-Wall -ggdb -O0 -I${ZMQ_DIR}/include \
+ -I$(ERL_INTERFACE_DIR)/include \
+ -I$(ERL_INSTALL_DIR)/usr/include
+CC=g++
+
+ifdef debug
+CFLAGS += -DZMQDRV_DEBUG
+endif
+
+all: ../priv/zmq_drv.so
+
+../priv/zmq_drv.so: zmq_drv.cpp
+ $(CC) -o $@ $< ${LDFLAGS} ${CFLAGS}
+
+clean:
+ rm -rf zmq_drv.o ../priv/zmq_drv.so
View
25 c_src/Makefile.in
@@ -0,0 +1,25 @@
+CXXFLAGS=@CXXFLAGS@
+LDFLAGS=@LDFLAGS@
+CXX=@CXX@
+debug=@DEBUG@
+package=@PACKAGE@
+version=@PACKAGE_VERSION@
+MKDIR_P=@MKDIR_P@
+INST_DIR=../priv
+
+zmq_drv_so_CXXFLAGS=-Wall $(if $(debug),-DZMQDRV_DEBUG) $(CXXFLAGS)
+zmq_drv_so_LDFLAGS=-shared -fPIC $(LDFLAGS) -lpthread
+
+all: $(INST_DIR) $(INST_DIR)/zmq_drv.so
+
+$(INST_DIR):
+ $(MKDIR_P) $@
+
+$(INST_DIR)/zmq_drv.so: zmq_drv.cpp
+ $(CXX) -o $@ $< ${zmq_drv_so_CXXFLAGS} ${zmq_drv_so_LDFLAGS}
+
+clean:
+ rm -rf zmq_drv.o ../priv/zmq_drv.so
+
+distclean: clean
+ rm Makefile
View
187 configure.ac
@@ -1,14 +1,183 @@
-dnl Process this file with autoconf to produce a configure script
-AC_PREREQ(2.56)
-AC_INIT(zmq)
-AM_INIT_AUTOMAKE(appexp, 0.1.00)
-AC_PROG_CC
-AC_PROG_RANLIB
+dnl AC_INIT([zmq], [0.0], [http://github.com/saleyn/erlzmq/issues])
+dnl AC_INIT([zmq], m4_normalize(esyscmd([. ./vsn.mk; echo ${VSN}])), [http://github.com/saleyn/erlzmq/issues])
+dnl Note that the `version' file needs to be created/deleted externally from vsn.mk
+AC_INIT([zmq], m4_normalize(m4_include(m4/version)), [http://github.com/saleyn/erlzmq/issues])
+AC_CONFIG_AUX_DIR([build-aux])
+AC_CONFIG_MACRO_DIR([m4])
+AM_INIT_AUTOMAKE([foreign no-dist -Wall -Werror])
-AC_ERLANG_CHECK_LIB([kernel])
-AC_ERLANG_CHECK_LIB([stdlib])
+AC_PROG_SED
+AC_PROG_CXX
+AC_CONFIG_HEADERS([config.h])
+dnl ------------------------------------------------------------------
+dnl Libtool.
+dnl ------------------------------------------------------------------
+
+dnl LT_INIT(disable-static)
+
+dnl AM_DISABLE_STATIC
+dnl AM_ENABLE_SHARED
+
+dnl AC_PROG_LIBTOOL
+dnl AC_PATH_PROG(PKG_CONFIG, pkg-config, [AC_MSG_ERROR([pkg-config was not found!])])
+
+dnl ------------------------------------------------------------------
+dnl Erlang environment.
+dnl ------------------------------------------------------------------
+
+AC_MSG_NOTICE([Erlang environment])
+
+dnl Check for erl_interface (used by port drivers).
+
+AC_ERLANG_CHECK_LIB([kernel],,
+ [AC_MSG_ERROR([kernel was not found!])])
+AC_ERLANG_CHECK_LIB([stdlib],,
+ [AC_MSG_ERROR([stdlib was not found!])])
+AC_ERLANG_CHECK_LIB([erl_interface],,
+ [AC_MSG_ERROR([erl_interface was not found!])])
+
+dnl Available flags.
+AC_ARG_WITH([erlang],
+ AC_HELP_STRING([--with-erlang=PATH],
+ [PATH to Erlang installation (optional)]),
+ with_erlang=${withval%/},
+ with_erlang="")
+
+dnl erl(1) is used to compile Erlang modules.
+if test "x${with_erlang}" = "x"; then
+ AC_ERLANG_PATH_ERL
+ AC_ERLANG_PATH_ERLC
+ AC_ERLANG_SUBST_ROOT_DIR
+else
+ erl_path="${with_erlang}/bin"
+ AC_ERLANG_PATH_ERL(, [$erl_path$PATH_SEPARATOR$PATH])
+ AC_ERLANG_PATH_ERLC(, [$erl_path$PATH_SEPARATOR$PATH])
+ AC_ERLANG_SUBST_ROOT_DIR
+fi
+
+if test "x${ERL}" = "x"; then
+ AC_MSG_ERROR([
+Erlang not found. Fill the ERL variable with erl(1) path or provide
+Erlang prefix with --with-erlang.])
+fi
+
+dnl Get ERTS version.
+ERLANG_CHECK_ERTS
+ERLANG_CHECK_RELEASE
AC_ERLANG_SUBST_ERTS_VER
-AC_OUTPUT(c_src/Makefile src/Makefile Makefile)
+dnl Determine directories for installation.
+dnl if test "x${prefix}" = "x"; then
+ dnl Inside Erlang lib directory.
+dnl ERLANG_INSTALL_LIB_DIR="${ERLANG_LIB_DIR}"
+dnl else
+ dnl Under $prefix
+dnl ERLANG_INSTALL_LIB_DIR="${prefix}"
+dnl fi
+
+dnl AC_ERLANG_SUBST_INSTALL_LIB_DIR
+dnl AC_ERLANG_SUBST_INSTALL_LIB_SUBDIR([zmq], ${PACKAGE_VERSION})
+
+AC_CHECK_HEADER([${ERLANG_DRV_INCLUDE}/erl_driver.h], [], [
+ AC_MSG_ERROR([Could not find the 'erl_driver.h' header.
+Are the Erlang headers installed? Use the '--with-erlang' option to specify the
+path to the Erlang include directory.])])
+
+
+dnl ------------------------------------------------------------------
+dnl Options.
+dnl ------------------------------------------------------------------
+
+dnl Debugging option.
+AC_ARG_ENABLE([debug],
+ AC_HELP_STRING([--enable-debug],
+ [turn on debugging [[default=yes]]]),,
+ enable_debug=no)
+if test "x${enable_debug}" = "xyes"; then
+ AC_DEFINE([DEBUG], [], [Enable debug])
+ AC_SUBST([DEBUG], [1])
+ AC_SUBST([ERL_FLAGS], [+debug_info -Ddebug])
+ CXXFLAGS="-O0 -DDEBUG"
+else
+ AC_SUBST([ERL_FLAGS], [])
+ CXXFLAGS="-O3 -DNDEBUG"
+fi
+
+dnl Treat warnings as errors.
+AC_ARG_ENABLE([warnings],
+ AC_HELP_STRING([--enable-warnings],
+ [treat warnings as errors [[default=yes]]]),,
+ enable_warnings="yes")
+if test "x${enable_warnings}" = "xyes" -a "x${GCC}" = "xyes"; then
+ CXXFLAGS="${CXXFLAGS% } -Werror"
+fi
+
+CXXFLAGS="-g ${CXXFLAGS% } -I${ERLANG_DRV_INCLUDE} -I${ERLANG_LIB_DIR_erl_interface}/include"
+
+dnl ------------------------------------------------------------------
+dnl Documentation.
+dnl ------------------------------------------------------------------
+
+AC_ARG_ENABLE([documentation],
+ AC_HELP_STRING([--enable-docs],
+ [build documentation [[default=yes]]]),,
+ enable_docs="yes")
+AM_CONDITIONAL(ENABLE_DOCUMENTATION, test "x${enable_docs}" = "xyes")
+
+dnl ------------------------------------------------------------------
+dnl Examples.
+dnl ------------------------------------------------------------------
+
+AC_ARG_ENABLE([examples],
+ AC_HELP_STRING([--enable-examples],
+ [build examples [[default=yes]]]),,
+ enable_examples="yes")
+AM_CONDITIONAL(ENABLE_EXAMPLES, test "x${enable_examples}" = "xyes")
+
+dnl ------------------------------------------------------------------
+dnl ZeroMQ
+dnl ------------------------------------------------------------------
+
+AC_ARG_WITH([zeromq],
+ AC_HELP_STRING([--with-zeromq=PATH],
+ [set PATH to the installation of zeromq library]),
+ [ZEROMQ_LIB=${with_zeromq}],
+ [ZEROMQ_LIB=""])
+
+AC_CHECK_HEADER([${ZEROMQ_LIB}/include/zmq.h], [], [
+ AC_MSG_ERROR([Could not find the 'zmq.h' header.
+Use the '--with-zeromq=PATH' option to specify location of ZeroMQ])])
+
+CXXFLAGS="${CXXFLAGS# } -I${with_zeromq}/include"
+LDFLAGS="${LDFLAGS# } -L${with_zeromq}/lib -lzmq"
+
+dnl ------------------------------------------------------------------
+dnl Output.
+dnl ------------------------------------------------------------------
+
+AC_MSG_NOTICE([Erlang environment])
+
+dnl Check for erl_interface (used by port drivers).
+AC_CONFIG_FILES([Makefile c_src/Makefile src/Makefile src/zmq.app])
+AC_OUTPUT
+
+dnl --------------------------------------------------
+dnl Configuration report
+dnl --------------------------------------------------
+
+echo
+AC_MSG_NOTICE([ == ${PACKAGE} ${PACKAGE_VERSION} ==])
+echo
+AC_MSG_NOTICE([ C++ compiler: ${CXX}])
+AC_MSG_NOTICE([ Erlang compiler: ${ERLC}])
+AC_MSG_NOTICE([ Erlang erts dir: ${ERLANG_ERTS_DIR}])
+AC_MSG_NOTICE([ Erlang erts ver: ${ERLANG_ERTS_VER}])
+AC_MSG_NOTICE([ Erlang lib dir: ${ERLANG_INSTALL_LIB_DIR}])
+AC_MSG_NOTICE([ erl_interface: ${ERLANG_LIB_DIR_erl_interface}])
+echo
+AC_MSG_NOTICE([ Debug/warnings: ${enable_debug}/${enable_warnings}])
+AC_MSG_NOTICE([ Documentation: ${enable_docs}])
+AC_MSG_NOTICE([ Examples: ${enable_examples}])
+echo
View
2  ebin/.gitignore
@@ -1 +1 @@
-*
+*.beam
View
87 m4/erlang.m4
@@ -0,0 +1,87 @@
+dnl-------------------------------------------------------------------
+dnl AC_ERLANG_SUBST_ERTS_VER
+dnl-------------------------------------------------------------------
+AC_DEFUN([AC_ERLANG_SUBST_ERTS_VER],
+ [AC_REQUIRE([AC_ERLANG_NEED_ERLC])[]dnl
+ AC_REQUIRE([AC_ERLANG_NEED_ERL])[]dnl
+ AC_CACHE_CHECK([for Erlang/OTP ERTS version],
+ [erlang_cv_erts_ver],
+ [AC_LANG_PUSH(Erlang)[]dnl
+ AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM([], [dnl
+ Version = erlang:system_info(version),
+ file:write_file("conftest.out", Version),
+ halt(0)])],
+ [erlang_cv_erts_ver=`cat conftest.out`],
+ [AC_MSG_FAILURE([test Erlang program execution failed])])
+ AC_LANG_POP(Erlang)[]dnl
+ ])
+ AC_SUBST([ERLANG_ERTS_VER], [$erlang_cv_erts_ver])
+ ])# AC_ERLANG_SUBST_ERTS_VER
+
+dnl-------------------------------------------------------------------
+dnl More functions to query Erlang environment.
+dnl-------------------------------------------------------------------
+
+dnl ERLANG_CHECK_ERTS([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
+dnl Substitudes
+dnl ERLANG_ERTS_DIR
+dnl ERLANG_ERTS_VER
+AC_DEFUN([ERLANG_CHECK_ERTS],
+[
+AC_REQUIRE([AC_ERLANG_SUBST_ROOT_DIR])[]dnl
+AC_CACHE_CHECK([for Erlang/OTP ERTS version],
+ [erlang_cv_erts_ver],
+ [
+ AC_LANG_PUSH(Erlang)[]dnl
+ AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM([], [dnl
+ file:write_file("conftest.out", erlang:system_info(version)),
+ halt(0)])],
+ [erlang_cv_erts_ver=`cat conftest.out`],
+ [if test ! -f conftest.out; then
+ AC_MSG_FAILURE([test Erlang program execution failed])
+ else
+ erlang_cv_erts_ver="not found"
+ fi])
+ AC_LANG_POP(Erlang)[]dnl
+ ])
+AC_CACHE_CHECK([for Erlang/OTP ERTS directory],
+ [erlang_cv_erts_dir],
+ [
+ erlang_cv_erts_dir="${ERLANG_ROOT_DIR}/erts-$erlang_cv_erts_ver"
+ erlang_cv_drv_include="${ERLANG_ROOT_DIR}/usr/include"
+ if test ! -d "$erlang_cv_erts_dir"; then
+ erlang_cv_erts_dir="${ERLANG_ROOT_DIR}/usr"
+ fi
+ ])
+AC_SUBST([ERLANG_ERTS_DIR], [$erlang_cv_erts_dir])
+AC_SUBST([ERLANG_ERTS_VER], [$erlang_cv_erts_ver])
+AC_SUBST([ERLANG_DRV_INCLUDE], [$erlang_cv_drv_include])
+AS_IF([test "$erlang_cv_erts_ver" = "not found"], [$2], [$1])
+])
+
+dnl ERLANG_CHECK_RELEASE()
+dnl Substitudes
+dnl ERLANG_RELEASE
+AC_DEFUN([ERLANG_CHECK_RELEASE],
+[
+AC_REQUIRE([AC_ERLANG_SUBST_ROOT_DIR])[]dnl
+AC_CACHE_CHECK([for Erlang/OTP release],
+ [erlang_cv_release],
+ [
+ AC_LANG_PUSH(Erlang)[]dnl
+ AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM([], [dnl
+ file:write_file("conftest.out", erlang:system_info(otp_release)),
+ halt(0)])],
+ [erlang_cv_release=`cat conftest.out`],
+ [if test ! -f conftest.out; then
+ AC_MSG_FAILURE([test Erlang program execution failed])
+ else
+ erlang_cv_release="not found"
+ fi])
+ AC_LANG_POP(Erlang)[]dnl
+ ])
+AC_SUBST([ERLANG_RELEASE], [$erlang_cv_release])
+])
View
36 src/Makefile.in
@@ -0,0 +1,36 @@
+ERL=@ERL@
+ERLC=@ERLC@
+DEBUG=@DEBUG@
+VSN=@PACKAGE_VERSION@
+ERL_FLAGS=@ERL_FLAGS@ -I../include
+ERL_SOURCES=$(wildcard *.erl)
+EBIN_DIR=../ebin
+DOC_DIR=../doc
+ERL_OBJECTS=$(ERL_SOURCES:%.erl=$(EBIN_DIR)/%.beam)
+DOC_FILES=$(DOC_DIR)/zmq.html
+
+all: $(ERL_OBJECTS) $(EBIN_DIR) $(EBIN_DIR)/zmq.app
+
+$(EBIN_DIR)/%.beam: %.erl
+ erlc $(ERL_FLAGS) -o ../ebin $<
+
+$(EBIN_DIR)/zmq.app: zmq.app.in
+ @[ -f $(subst .in,,$<) ] || (echo "Rerun configure script!" && exit 1)
+ mv -f $(subst .in,,$<) $@
+
+clean:
+ rm -f $(ERL_OBJECTS)
+ rm -fr $(DOC_DIR)
+
+distclean: clean
+ rm -f $(EBIN_DIR)/zmq.app
+
+docs: $(DOC_DIR) $(DOC_FILES)
+
+$(EBIN_DIR) $(DOC_DIR):
+ mkdir $@
+
+$(DOC_DIR)/zmq.html: zmq.erl overview.edoc
+ erl -noshell -run edoc_run application "'zmq'" '"."' \
+ '[{dir, "$(DOC_DIR)"}, {def, [{version, "$(VSN)"}]}]' -run init stop
+
View
11 src/zmq.app.src
@@ -0,0 +1,11 @@
+% This is an -*- erlang -*- file.
+
+{application, zmq,
+ [{description, "ZeroMQ"},
+ {vsn, "%VSN%"},
+ {modules, [zmq]},
+ {registered,[]},
+ {applications, [kernel,stdlib]},
+ {env, []}
+ ]
+}.
Please sign in to comment.
Something went wrong with that request. Please try again.