Commit a0d59c8b by orangle

add new makefile

parent 224860e0
# Makefile for qrencode library for Lua # Makefile for qrencode library for Lua
version=0.1
LIBNAME= qrencode name=lua-resty-qrencode
LUA_VERSION = 5.1
LUAEXE= lua # See http://lua-users.org/wiki/BuildingModules for platform specific
# details.
ROCKSPEC= $(shell find . -name $(LIBNAME)-*-*.rockspec) ## Linux/BSD
PREFIX ?= /usr/local/openresty
#LDFLAGS += -shared
all: install ## OSX (Macports)
#PREFIX ?= /opt/local
LDFLAGS += -bundle -undefined dynamic_lookup
install: ## find your luajit path
luarocks make $(ROCKSPEC) LUA_INCLUDE_DIR ?= $(PREFIX)/luajit/include/luajit-2.1
LUA_LIB_DIR ?= $(PREFIX)/lualib
# Some versions of Solaris are missing isinf(). Add -DMISSING_ISINF to
# CFLAGS to work around this bug.
#CFLAGS ?= -g -Wall -pedantic -fno-inline
CFLAGS ?= -g -O3 -Wall -pedantic
override CFLAGS += -fpic -I$(LUA_INCLUDE_DIR) -lpng -lqrencode
INSTALL ?= install
test: .PHONY: all clean install
$(LUAEXE) test/test.lua
.PHONY: all test install all: qrencode.so
qrencode.so: qrencode.c
$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $^
install:
$(INSTALL) -d $(LUA_LIB_DIR)
$(INSTALL) qrencode.so $(LUA_LIB_DIR)
clean:
rm *.so
...@@ -11,36 +11,57 @@ qrencode is dependent on [libqrencode](http://fukuchi.org/works/qrencode/) ...@@ -11,36 +11,57 @@ qrencode is dependent on [libqrencode](http://fukuchi.org/works/qrencode/)
and [libpng](http://www.libpng.org/pub/png/libpng.html), so make sure these are installed and [libpng](http://www.libpng.org/pub/png/libpng.html), so make sure these are installed
before compile it. before compile it.
### MacOS
```
$ brew install libqrencode
$ https://github.com/orangle/lua-resty-qrencode.git
$ cd lua-resty-qrencode
$ make
$ make install
```
defalut openresty `PREFIX` is `/usr/local/openresty`, if you have a different path, please read `Makefile` and change the path.
### Other
please install libqrencode and libpng, and read Makefile.
## Example usage ## Example usage
```lua ```lua
qr = require "qrencode" location /qrcode {
content_by_lua_block {
-- print PNG data stream to stdout. local qr = require("qrencode")
local args = ngx.req.get_uri_args()
print(qr.encode("is ok?")) local text = args.text
print(qr:encode("is ok?"))
print(qr("is ok?")) if text == nil or text== "" then
ngx.say('need a text param')
-- print ansi char ngx.exit(404)
print(qr {text = "is ok?", ansi = true}) end
-- or pass a table : ngx.say(qr {
text=text,
print(qr { level="L",
text="is ok?", kanji=false,
level="L", ansi=true,
kanji=false, size=4,
ansi=true, margin=2,
size=4, symversion=0,
margin=2, dpi=78,
symversion=0, casesensitive=true,
dpi=78, foreground="48AF6D",
casesensitive=false, background="3FAF6F"
foreground="48AF6D", })
background="3FAF6F" }
} }
) ```
test url like
```
curl 'http://127.0.0.1:8008/qrcode?text=http://orangleliu.info'
``` ```
when pass a table, "text" is required and other is optional. when pass a table, "text" is required and other is optional.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment