From a3b4c6ac6c1aa8424104e9de5a58fb24ee8aba69 Mon Sep 17 00:00:00 2001 From: Timothy Boronczyk Date: Sun, 23 Feb 2014 18:32:22 -0800 Subject: [PATCH 1/4] Rename src/config* to src/lfconfig* to prevent clash with autotools-generated files --- Makefile | 2 +- src/{config.c => lfconfig.c} | 2 +- src/{config.h => lfconfig.h} | 0 src/lua-fastcgi.c | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) rename src/{config.c => lfconfig.c} (99%) rename src/{config.h => lfconfig.h} (100%) diff --git a/Makefile b/Makefile index 8823add..60583e8 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ debug: CFLAGS+=-g -DDEBUG debug: LDFLAGS+=-lrt debug: lua-fastcgi -lua-fastcgi: src/lua-fastcgi.o src/lfuncs.o src/lua.o src/config.o +lua-fastcgi: src/lua-fastcgi.o src/lfuncs.o src/lua.o src/lfconfig.o $(CC) $^ $(LDFLAGS) -o $@ clean: diff --git a/src/config.c b/src/lfconfig.c similarity index 99% rename from src/config.c rename to src/lfconfig.c index 0969bba..8070d8e 100644 --- a/src/config.c +++ b/src/lfconfig.c @@ -6,7 +6,7 @@ #include #include -#include "config.h" +#include "lfconfig.h" // Checks if a file exists diff --git a/src/config.h b/src/lfconfig.h similarity index 100% rename from src/config.h rename to src/lfconfig.h diff --git a/src/lua-fastcgi.c b/src/lua-fastcgi.c index 91907fe..1d51929 100644 --- a/src/lua-fastcgi.c +++ b/src/lua-fastcgi.c @@ -12,7 +12,7 @@ #include #include "lua.h" -#include "config.h" +#include "lfconfig.h" #include "lua-fastcgi.h" From 9ab4e228fd15de84b57fd6323ea03c8d39638f01 Mon Sep 17 00:00:00 2001 From: Timothy Boronczyk Date: Sun, 23 Feb 2014 20:37:12 -0800 Subject: [PATCH 2/4] Adding #ifndef wrappings in headaer files to prevent multiple definitions --- src/lfconfig.h | 5 +++++ src/lfuncs.h | 5 +++++ src/lua-fastcgi.h | 4 ++++ src/lua.h | 5 +++++ 4 files changed, 19 insertions(+) diff --git a/src/lfconfig.h b/src/lfconfig.h index 9b9a8da..af6082f 100644 --- a/src/lfconfig.h +++ b/src/lfconfig.h @@ -1,3 +1,6 @@ +#ifndef LFCONFIG_H +#define LFCONFIG_H + typedef struct { char *listen; int backlog; @@ -14,3 +17,5 @@ typedef struct { LF_config *LF_createconfig(); int LF_loadconfig(LF_config *, char *); + +#endif diff --git a/src/lfuncs.h b/src/lfuncs.h index 6229e9f..c624443 100644 --- a/src/lfuncs.h +++ b/src/lfuncs.h @@ -1,3 +1,6 @@ +#ifndef LFUNCS_H +#define LFUNCS_H + // Writes FCGI output followed by a carriage return int LF_print(lua_State *); @@ -12,3 +15,5 @@ int LF_loadfile(lua_State *); // dofile() function with sandboxing security measures int LF_dofile(lua_State *); + +#endif diff --git a/src/lua-fastcgi.h b/src/lua-fastcgi.h index 0526846..5770444 100644 --- a/src/lua-fastcgi.h +++ b/src/lua-fastcgi.h @@ -1,5 +1,9 @@ +#ifndef LUA_FASTCGI_H +#define LUA_FASTCGI_H + typedef struct { LF_config *config; int socket; } LF_params; +#endif diff --git a/src/lua.h b/src/lua.h index b29698b..66031a2 100644 --- a/src/lua.h +++ b/src/lua.h @@ -1,3 +1,6 @@ +#ifndef LUA_H +#define LUA_H + #define LF_ERRNONE 0 #define LF_ERRANY 1 #define LF_ERRACCESS 2 @@ -29,3 +32,5 @@ void LF_emptystack(lua_State *); int LF_fileload(lua_State *, const char *, char *); int LF_loadscript(lua_State *); void LF_closestate(lua_State *); + +#endif From 90c078307250586979e13957db0a371cd4c79e00 Mon Sep 17 00:00:00 2001 From: Timothy Boronczyk Date: Sun, 23 Feb 2014 20:41:10 -0800 Subject: [PATCH 3/4] Adding basic autotools build files --- Makefile | 18 ------------------ Makefile.am | 1 + configure.ac | 22 ++++++++++++++++++++++ src/Makefile.am | 15 +++++++++++++++ 4 files changed, 38 insertions(+), 18 deletions(-) delete mode 100644 Makefile create mode 100644 Makefile.am create mode 100644 configure.ac create mode 100644 src/Makefile.am diff --git a/Makefile b/Makefile deleted file mode 100644 index 60583e8..0000000 --- a/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -CFLAGS=-c -std=gnu99 -Wall -LDFLAGS=-O2 -Wl,-Bstatic -lfcgi -llua5.1 -Wl,-Bdynamic -lm -lpthread - - -.c.o: - $(CC) $(CFLAGS) $< -o $@ - -all: lua-fastcgi - -debug: CFLAGS+=-g -DDEBUG -debug: LDFLAGS+=-lrt -debug: lua-fastcgi - -lua-fastcgi: src/lua-fastcgi.o src/lfuncs.o src/lua.o src/lfconfig.o - $(CC) $^ $(LDFLAGS) -o $@ - -clean: - rm -f src/*.o lua-fastcgi diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..af437a6 --- /dev/null +++ b/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = src diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..e6345c2 --- /dev/null +++ b/configure.ac @@ -0,0 +1,22 @@ +m4_define([LF_MAJOR], 1) +m4_define([LF_MINOR], 0) +m4_define([LF_PATCH], 0) +m4_define([LF_BUGS], []) + +AC_PREREQ([2.64]) +AC_INIT([lua-fastcgi], [LF_MAJOR.LF_MINOR.LF_PATCH], [LF_BUGS]) +AC_CONFIG_SRCDIR([src/lua-fastcgi.c]) + +AM_INIT_AUTOMAKE([foreign -Wall -Werror]) +AM_CONFIG_HEADER([config.h]) + +AC_LANG([C]) +AC_PROG_CC + +AC_CHECK_HEADERS([ctype.h errno.h fcgiapp.h fcgi_config.h fcntl.h inttypes.h]) +AC_CHECK_HEADERS([lua5.1/lauxlib.h lua5.1/lua.h lua5.1/lualib.h]) +AC_CHECK_HEADERS([pthread.h stdint.h stdio.h stdlib.h string.h sys/mman.h]) +AC_CHECK_HEADERS([sys/resource.h sys/stat.h sys/time.h time.h unistd.h]) + +AC_CONFIG_FILES([Makefile src/Makefile]) +AC_OUTPUT diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..44c7dc0 --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,15 @@ +AM_CFLAGS = +AM_CFLAGS += -std=gnu99 -Wall -O2 + +bin_PROGRAMS = lua-fastcgi + +lua_fastcgi_LDADD = +lua_fastcgi_LDADD += -lfcgi -llua5.1 -lm -lpthread + + +lua_fastcgi_SOURCES = \ + lfconfig.c lfconfig.h \ + lfuncs.c lfuncs.h \ + lua.c lua.h \ + lua-fastcgi.c lua-fastcgi.h + From f8cdc783d0476f5de4709b547c898547439ef590 Mon Sep 17 00:00:00 2001 From: Timothy Boronczyk Date: Sun, 23 Feb 2014 20:46:57 -0800 Subject: [PATCH 4/4] Added compile instructions to README.md --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index e1c32e3..16a0f20 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,11 @@ Ubuntu will likely work without any changes. Other flavors of Linux should work with little to no effort. Other Unix-like operating systems are untested and unsupported, for now. +To compile lua-fastcgi: + + autoreconf --install + ./configure + make running -------