Skip to content

Commit

Permalink
use autotools for build and install
Browse files Browse the repository at this point in the history
  • Loading branch information
radiumce committed Aug 23, 2012
1 parent 7eefb84 commit ba1b5b9
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 30 deletions.
9 changes: 0 additions & 9 deletions HowTo

This file was deleted.

11 changes: 11 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
SUBDIRS = src
libdir = $(prefix)/erlyssh/lib
lib_LTLIBRARIES = libreadlinedrv.la
libreadlinedrv_la_SOURCES = $(top_srcdir)/native/linux/readline_drv.c
INCLUDES = -I $(ERLANG_ROOT_DIR)/usr/include
libreadlinedrv_la_LIBADD = -lreadline -lhistory
bin_PROGRAMS = essh

essh:
echo "#!/bin/sh\n" > essh
echo "erl -noinput -pa $(prefix)/erlyssh/ebin -run essh start $(libdir) \$${ESSH_LIST_HOME}/\$$* " >>essh
4 changes: 0 additions & 4 deletions README.md

This file was deleted.

27 changes: 27 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.68])
AC_INIT([readline_drv], [0.1], [radiumce@gmail.com])
AM_INIT_AUTOMAKE([foreign])
AC_PROG_LIBTOOL
AC_CONFIG_SRCDIR([native/linux/readline_drv.c])

AC_ERLANG_NEED_ERLC
AC_ERLANG_SUBST_ROOT_DIR
AC_ERLANG_SUBST_LIB_DIR
# Checks for programs.
AC_PROG_CC

CFLAGS="$CFLAGS -L/opt/local/lib -L/usr/lib -L/usr/local/lib -I/opt/local/include/readline -I/opt/include -I/usr/local/include"


# Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_SIZE_T

# Checks for library functions.
AC_FUNC_MALLOC
AC_CHECK_FUNCS([getcwd isascii select strdup strerror strrchr])

AC_CONFIG_FILES([Makefile src/Makefile])
AC_OUTPUT
Binary file removed native/linux/.DS_Store
Binary file not shown.
7 changes: 0 additions & 7 deletions native/linux/README

This file was deleted.

16 changes: 8 additions & 8 deletions native/linux/readline_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ typedef struct {
static char *line_read = (char*)NULL;
static char *prompt = "essh>: ";

static ErlDrvData readline_drv_start(ErlDrvPort port, char *buff){
static ErlDrvData libreadlinedrv_start(ErlDrvPort port, char *buff){

readline_data* d = (readline_data*)driver_alloc(sizeof(readline_data));
d->port = port;
return (ErlDrvData)d;
}

static void readline_drv_stop(ErlDrvData handle)
static void libreadlinedrv_stop(ErlDrvData handle)
{
driver_free((char*)handle);
}

static void readline_drv_output(ErlDrvData handle, char *buff, int bufflen)
static void libreadlinedrv_output(ErlDrvData handle, char *buff, int bufflen)
{
readline_data* d = (readline_data*)handle;

Expand All @@ -42,19 +42,19 @@ static void readline_drv_output(ErlDrvData handle, char *buff, int bufflen)

ErlDrvEntry readline_driver_entry = {
NULL, /* F_PTR init, N/A */
readline_drv_start, /* L_PTR start, called when port is opened */
readline_drv_stop, /* F_PTR stop, called when port is closed */
readline_drv_output, /* F_PTR output, called when erlang has sent */
libreadlinedrv_start, /* L_PTR start, called when port is opened */
libreadlinedrv_stop, /* F_PTR stop, called when port is closed */
libreadlinedrv_output, /* F_PTR output, called when erlang has sent */
NULL, /* F_PTR ready_input, called when input descriptor ready */
NULL, /* F_PTR ready_output, called when output descriptor ready */
"readline_drv", /* char *driver_name, the argument to open_port */
"libreadlinedrv", /* char *driver_name, the argument to open_port */
NULL, /* F_PTR finish, called when unloaded */
NULL, /* F_PTR control, port_command callback */
NULL, /* F_PTR timeout, reserved */
NULL /* F_PTR outputv, reserved */
};

DRIVER_INIT(readline_drv) /* must match name in driver_entry */
DRIVER_INIT(libreadlinedrv) /* must match name in driver_entry */
{
return &readline_driver_entry;
}
14 changes: 14 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#erlsrcdir = $(prefix)/src
#erlsrc_DATA = essh.erl \
# essh_agent.erl \
# essh_scheduler.erl

erlbeamdir = $(prefix)/erlyssh/ebin
erlbeam_DATA = essh.beam \
essh_agent.beam \
essh_scheduler.beam

CLEANFILES = $(erlbeam_DATA)
SUFFIXES = .erl .beam
.erl.beam:
$(ERLC) $(ERLCFLAGS) -b beam $<
3 changes: 1 addition & 2 deletions src/essh.erl
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@
%% External functions
%% ====================================================================
%%
%% TODO: Add description of start/function_arity
%%
start(StartParas) ->
[SharedPath, FilePath | Command] = StartParas,
StartCommand = get_start_command(Command, ""),
SharedLib = "readline_drv",
SharedLib = "libreadlinedrv",
%io:format("starting essh server~n"),
essh_scheduler:start(),
gen_server:start_link({local,?MODULE}, ?MODULE, [SharedPath, SharedLib, FilePath, StartCommand], []).
Expand Down

0 comments on commit ba1b5b9

Please sign in to comment.