From 920026efebe8ef80ed737e99398caf19a8b1c617 Mon Sep 17 00:00:00 2001 From: Axel Kittenberger Date: Thu, 14 Oct 2010 13:52:01 +0000 Subject: [PATCH] coded a lua hello world --- Makefile.am | 5 +++++ autogen.sh | 9 +++++++++ configure.ac | 19 +++++++++++++++++++ lsyncd.c | 25 +++++++++++++++++++++++++ lsyncd.lua | 2 ++ 5 files changed, 60 insertions(+) create mode 100644 Makefile.am create mode 100755 autogen.sh create mode 100644 configure.ac create mode 100644 lsyncd.c create mode 100644 lsyncd.lua diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..4e0272f --- /dev/null +++ b/Makefile.am @@ -0,0 +1,5 @@ +AUTOMAKE_OPTIONS = foreign +CFLAGS = -Wall -pedantic $(LIBLUA_CFLAGS) +bin_PROGRAMS = lsyncd +lsyncd_SOURCES = lsyncd.c +lsyncd_LDADD = $(LIBLUA_LIBS) diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..01c075c --- /dev/null +++ b/autogen.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +echo "Generating configure files... may take a while." + +autoreconf --install --force && \ + echo "Preparing was successful if there was no error messages above." && \ + echo "Now type:" && \ + echo " ./configure && make" && \ + echo "Run './configure --help' for more information" diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..31ba6b0 --- /dev/null +++ b/configure.ac @@ -0,0 +1,19 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. +#AC_PREREQ(2.60) +AC_INIT(lsyncd, 2.0, axkibe@gmail.com) +AC_CONFIG_SRCDIR([lsyncd.c]) +AC_CONFIG_HEADER([config.h]) +AM_INIT_AUTOMAKE(lsyncd, main) +# Checks for programs. +AC_PROG_CC +AC_PROG_INSTALL +AC_PROG_MAKE_SET +# Checks for libraries. +PKG_CHECK_MODULES(LIBLUA, lua5.1) +# Checks for header files. +# Checks for typedefs, structures, and compiler characteristics. +# Checks for library functions. +AC_CHECK_HEADERS([sys/inotify.h]) +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT diff --git a/lsyncd.c b/lsyncd.c new file mode 100644 index 0000000..2ff5db1 --- /dev/null +++ b/lsyncd.c @@ -0,0 +1,25 @@ +#include +#include +#include +#include + +/* the Lua interpreter */ +lua_State* L; + +int main (int argc, char *argv[]) +{ + /* initialize Lua */ + L = lua_open(); + /* load Lua base libraries */ + luaL_openlibs(L); + /* register our function */ + //lua_register(L, "average", average); + /* run the script */ + luaL_dofile(L, "lsyncd.lua"); + /* cleanup Lua */ + lua_close(L); + /* pause */ + printf( "Press enter to exit..." ); + getchar(); + return 0; +} diff --git a/lsyncd.lua b/lsyncd.lua new file mode 100644 index 0000000..c1cc42b --- /dev/null +++ b/lsyncd.lua @@ -0,0 +1,2 @@ +print("Hello\n") +