diff --git a/Makefile b/Makefile deleted file mode 100644 index 8823add..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/config.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/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 ------- 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 + 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 85% rename from src/config.h rename to src/lfconfig.h index 9b9a8da..af6082f 100644 --- a/src/config.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.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" 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