Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.o
*.so
config
44 changes: 38 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

include config

DESTDIR := /
DESTDIR := $(PREFIX)
LDIR := $(DESTDIR)/$(LUA_DIR)
WDIR := $(DESTDIR)/$(LUA_DIR)/wsapi
CDIR := $(DESTDIR)/$(LUA_LIBDIR)
Expand All @@ -22,7 +22,7 @@ fcgi: fastcgi
src/fastcgi/lfcgi.so: src/fastcgi/lfcgi.h
$(CC) $(CFLAGS) $(LDFLAGS) $(LIB_OPTION) -o src/fastcgi/lfcgi.so src/fastcgi/lfcgi.c -lfcgi $(INC)

install:
install: install-fcgi install-man
@mkdir -p $(LDIR) $(WDIR) $(BDIR)
@cp src/*.lua $(LDIR)
@cp src/wsapi/*.lua $(WDIR)
Expand All @@ -42,13 +42,45 @@ install-rocks: install
cp -r doc/* $(PREFIX)/doc

clean:
@rm -f config src/fastcgi/lfcgi.so
@rm -f src/fastcgi/lfcgi.so
@echo "Cleaning is done!"

test:
@echo "Running tests..."
LUA_PATH='$(LUA_PATH);./src/?.lua;./src/?/init.lua' lua tests/mock_test.lua
LUA_PATH='$(LUA_PATH);./src/?.lua;./src/?/init.lua' lua tests/test_request.lua
LUA_PATH='$(LUA_PATH);./src/?.lua;./src/?/init.lua' lua tests/test_metatable.lua
@echo "Tests finished."

snapshot:
git archive --format=tar --prefix=wsapi-$(VERSION)/ HEAD | gzip > wsapi-$(VERSION).tar.gz

rockspecs:
for pkg in wsapi wsapi-fcgi wsapi-xavante ; do cp rockspec/$$pkg-$(VERSION_OLD)-1.rockspec rockspec/$$pkg-$(VERSION_NEW)-1.rockspec ; done
for pkg in wsapi wsapi-fcgi wsapi-xavante; do sed -e "s/$(VERSION_OLD)/$(VERSION_NEW)/g" -i "" rockspec/$$pkg-$(VERSION_NEW)-1.rockspec ; done
for pkg in wsapi wsapi-fcgi wsapi-xavante; do git add rockspec/$$pkg-$(VERSION_NEW)-1.rockspec ; done
lua rockspec/generate_rockspecs.lua $(VERSION)
for pkg in wsapi wsapi-fcgi wsapi-xavante; do git add rockspec/$$pkg-$(VERSION)-1.rockspec ; done

uninstall: uninstall-fcgi uninstall-man
@echo "Uninstalling Lua WSAPI..."
@rm -f $(LDIR)/wsapi.lua
@rm -f $(WDIR)/*.lua
@rmdir $(WDIR) >/dev/null 2>&1 || true
@rm -f $(BDIR)/wsapi.cgi
@rm -f $(BDIR)/wsapi.fcgi
@echo "Uninstall of Lua WSAPI part is done."

uninstall-fcgi:
@echo "Uninstalling bundled Lua-fcgi lib..."
@rm -f $(CDIR)/lfcgi.so
@echo "Uninstall of bundled Lua-fcgi lib is done."


install-man:
@echo "Installing man page..."
@mkdir -p $(PREFIX)/share/man/man1
@cp doc/us/wsapi.1 $(PREFIX)/share/man/man1/wsapi.1
@echo "Man page installed to $(PREFIX)/share/man/man1/wsapi.1"

uninstall-man:
@echo "Uninstalling man page..."
@rm -f $(PREFIX)/share/man/man1/wsapi.1
@echo "Man page uninstalled."
69 changes: 0 additions & 69 deletions Makefile.win

This file was deleted.

56 changes: 48 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,59 @@ WSAPI's main influence is Ruby's Rack framework, but it was also influenced
by Python's WSGI (PEP 333). It's not a direct clone of either of them, though,
and tries to follow standard Lua idioms.

WSAPI is free software and uses the same license as Lua 5.1
WSAPI is free software and uses the same license as Lua 5.1.

## Status
Current version is 1.6.1. It supports both Lua 5.1 and Lua 5.2.

Current version is 1.7. It supports Lua 5.1, 5.2, and 5.3.

## Installation

### Using LuaRocks (recommended)

```bash
# To install the base WSAPI with CGI adapters
luarocks install wsapi

# To install the FastCGI adapter
luarocks install wsapi-fcgi

# To install the Xavante server adapter
luarocks install wsapi-xavante
```

### From source

1. **Configure the environment**:
Run the `configure` script to generate the configuration files. You can specify the Lua executable and an optional installation prefix.

```bash
./configure lua --prefix=/usr/local
```

Replace `lua` with the name of your Lua executable if it's different (e.g., `lua5.3`). The `--prefix` is optional, and `/usr/local` is the default.

2. **Compile the project**:
After configuration, compile the project with the `make` command.

```bash
make
```

3. **Install WSAPI**:
Finally, install the files on your system. You will likely need administrator permissions (sudo).

```bash
sudo make install
```

## Download
WSAPI can be downloaded from its LuaForge page. You can also get WSAPI using
LuaRocks:

luarocks install wsapi
The latest release can be downloaded from the [GitHub releases page](https://github.com/keplerproject/wsapi/releases).

## Latest Sources and Issue Tracker

## Latest Sources and Bug Tracker
WSAPI CVS and bug tracker are available at its Github page.
The source code and issue tracker are available at the [GitHub page](https://github.com/keplerproject/wsapi).

# History

Expand Down Expand Up @@ -129,4 +169,4 @@ WSAPI CVS and bug tracker are available at its Github page.
WSAPI was designed and developed by Fabio Mascarenhas and Andre Carregal,
and is maintained by Fabio Mascarenhas.

For more information please check the HTML documentation at /doc/us
For more information please check the HTML documentation at /doc/us
88 changes: 67 additions & 21 deletions configure
Original file line number Diff line number Diff line change
@@ -1,36 +1,82 @@
#!/bin/sh

if [ $1 == "--help" ]; then
echo "Usage: configure lua51"
echo "where lua51 is the name of your Lua executable"
exit 0
fi
prefix="/usr/local" # Default prefix

# Parse arguments
while [ "$1" != "" ]; do
case $1 in
--help )
echo "Usage: configure [lua_executable] [--prefix=/path/to/install]"
echo "Example: configure lua5.1 --prefix=/usr"
exit 0
;;
--prefix=* )
prefix="${1#*=}"
;;
* )
lua=$1
;;
esac
shift
done

echo "Trying to find where you installed Lua..."

if [ $1 != "" ]; then
lua=$1
else
lua="lua51"
if [ -z "$lua" ]; then
lua="lua"
fi

lua_bin=`which $lua`
lua_bin_dir=`dirname $lua_bin`

if [ -z "$lua_bin" ]; then
echo "Lua executable '$lua' not found in your PATH."
exit 1
fi

lua_version_string=$($lua -v 2>&1)
echo "Found Lua: $lua_version_string"

# Extract version number like 5.4
lua_version=$(echo $lua_version_string | sed -n 's/Lua \([0-9]\.[0-9]\).*/\1/p')

if [ -z "$lua_version" ]; then
echo "Could not determine Lua version."
exit 1
fi

lua_bin_dir=`dirname $lua_bin`
lua_root=`dirname $lua_bin_dir`

if [ $lua_root != "" ]; then
echo "Lua is in $lua_root"
echo "Writing config"
lua_share=$lua_root/share/lua/5.1
lua_lib=$lua_root/lib/lua/5.1
bin_dir=$lua_root/bin
if [ "$lua_root" != "" ] && [ -d "$lua_root" ]; then
echo "Found Lua in $lua_root"

# Try to find include directory
if [ -d "$lua_root/include/lua$lua_version" ]; then
lua_inc="$lua_root/include/lua$lua_version"
elif [ -d "$lua_root/include" ]; then
lua_inc="$lua_root/include"
else
echo "Could not find Lua include directory."
exit 1
fi

echo "Found Lua includes in $lua_inc"
echo "Writing config file..."

lua_share="$lua_root/share/lua/$lua_version"
lua_lib_dir="$lua_root/lib/lua/$lua_version"
bin_dir="$lua_root/bin"

echo "LIB_OPTION= -shared -fPIC" > config
echo "LUA_DIR= $lua_share" >> config
echo "BIN_DIR= $bin_dir" >> config
echo "LUA_LIBDIR= $lua_lib" >> config
echo "Now run 'make && sudo make install'"
echo "LUA_LIBDIR= $lua_lib_dir" >> config
echo "INC= -I$lua_inc" >> config
echo "LDFLAGS= -llua$lua_version" >> config
echo "PREFIX= $prefix" >> config # Add PREFIX to config

echo "Configuration complete."
echo "Now run 'make'"
else
echo "Lua not found, please install Lua 5.1 (and put in your PATH)"
fi

echo "Could not determine Lua installation directory."
fi
Loading