-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of ssh://github.com/moai/luamongo
- Loading branch information
Showing
18 changed files
with
213 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2014-2015 Francisco Zamora-Martinez ([email protected]) | ||
Copyright (c) 2009-2015 Zipline Games, Inc. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,106 @@ | ||
UNAME:= $(shell uname) | ||
PLAT= DetectOS | ||
|
||
CC= g++ | ||
CFLAGS= -Wall -g -O2 -shared -fPIC -I/usr/include/mongo `pkg-config --cflags lua5.2` `pkg-config --cflags libmongo-client` | ||
LUAFLAGS= $(shell pkg-config --cflags $(LUAPKG)) | ||
LUAPKG:= $(shell ( luajit -e 'print("luajit")' 2> /dev/null ) || lua5.2 -e 'print("lua5.2")' 2> /dev/null || lua5.1 -e 'print("lua5.1")' 2> /dev/null || lua -e 'print("lua" .. string.match(_VERSION, "%d+.%d+"))' 2> /dev/null) | ||
AR= ar rcu | ||
RANLIB= ranlib | ||
RM= rm -f | ||
LIBS=`pkg-config --libs lua5.2` -lmongoclient -lssl -lboost_thread -lboost_filesystem | ||
OUTLIB=mongo.so | ||
OUTLIB= mongo.so | ||
OBJS = main.o mongo_bsontypes.o mongo_dbclient.o mongo_replicaset.o mongo_connection.o mongo_cursor.o mongo_gridfile.o mongo_gridfs.o mongo_gridfschunk.o mongo_query.o utils.o mongo_cxx_extension.o mongo_gridfilebuilder.o | ||
|
||
LDFLAGS= $(LIBS) | ||
# macports | ||
ifneq ("$(wildcard /opt/local/include/mongo/client/dbclient.h)","") | ||
LUA:= $(shell echo $(LUAPKG) | sed 's/[0-9].[0-9]//g') | ||
VER:= $(shell echo $(LUAPKG) | sed 's/.*\([0-9].[0-9]\)/\1/g') | ||
LUAFLAGS:= $(shell pkg-config --cflags '$(LUA) >= $(VER)') | ||
MONGO_INCLUDE_DIR= /opt/local/include/mongo/ | ||
MONGO_LIB_DIR= /opt/local/lib | ||
CFLAGS:= -Wall -g -O2 -fPIC $(LUAFLAGS) -I$(MONGO_INCLUDE_DIR) | ||
LIBS:= $(shell pkg-config --libs "$(LUA) >= $(VER)") -lmongoclient -lssl -lboost_thread-mt -lboost_filesystem-mt -flat_namespace -bundle -L$(MONGO_LIB_DIR) -rdynamic | ||
endif | ||
|
||
OBJS = main.o mongo_bsontypes.o mongo_dbclient.o mongo_replicaset.o mongo_connection.o mongo_cursor.o mongo_gridfile.o mongo_gridfs.o mongo_gridfschunk.o mongo_query.o utils.o mongo_cxx_extension.o mongo_gridfilebuilder.o | ||
# homebrew | ||
ifneq ("$(wildcard /usr/local/include/mongo/client/dbclient.h)","") | ||
LUA:= $(shell echo $(LUAPKG) | sed 's/[0-9].[0-9]//g') | ||
VER:= $(shell echo $(LUAPKG) | sed 's/.*\([0-9].[0-9]\)/\1/g') | ||
LUAFLAGS:= $(shell pkg-config --cflags '$(LUA) >= $(VER)') | ||
MONGO_INCLUDE_DIR= /usr/local/include/mongo/ | ||
MONGO_LIB_DIR= /usr/local/lib | ||
CFLAGS:= -Wall -g -O2 -fPIC $(LUAFLAGS) -I$(MONGO_INCLUDE_DIR) | ||
LIBS:= $(shell pkg-config --libs "$(LUA) >= $(VER)") -lmongoclient -lssl -lboost_thread-mt -lboost_filesystem-mt -flat_namespace -bundle -L$(MONGO_LIB_DIR) -rdynamic | ||
endif | ||
|
||
UNAME = `uname` | ||
PLAT = DetectOS | ||
ifeq ("$(LIBS)", "") | ||
MONGOFLAGS:= $(shell pkg-config --cflags libmongo-client) | ||
CFLAGS:= -Wall -g -O2 -shared -fPIC -I/usr/include/mongo $(LUAFLAGS) $(MONGOFLAGS) | ||
LIBS:= $(shell pkg-config --libs $(LUAPKG)) -lmongoclient -lssl -lboost_thread -lboost_filesystem -lrt | ||
endif | ||
|
||
all: $(PLAT) | ||
LDFLAGS:= $(LIBS) | ||
|
||
DetectOS: | ||
all: check $(PLAT) | ||
|
||
DetectOS: check | ||
@make $(UNAME) | ||
|
||
Linux: | ||
@make -f Makefile.linux | ||
Linux: luamongo | ||
|
||
Darwin: checkdarwin luamongo | ||
|
||
check: | ||
@if [ -z $(LUAPKG) ]; then echo "Impossible to detect Lua version, you need LuaJIT, Lua 5.1 or Lua 5.2 installed!"; exit 1; fi | ||
@if [ -z $(LUAFLAGS) ]; then echo "Unable to configure with pkg-config, luamongo needs developer version of $(LUAPKG). You can force other Lua version by declaring variable LUAPKG=lua5.1 or LUAPKG=lua5.2"; exit 1; fi | ||
|
||
Darwin: | ||
@make -f Makefile.darwin | ||
checkdarwin: | ||
ifeq ("$(MONGO_LIB_DIR)", "") | ||
@echo "To build luamongo on Darwin, you must have either ports or homebrew (preferred) installed!" | ||
exit 1 | ||
endif | ||
|
||
echo: check | ||
@echo "CC = $(CC)" | ||
@echo "CFLAGS = $(CFLAGS)" | ||
@echo "AR = $(AR)" | ||
@echo "RANLIB = $(RANLIB)" | ||
@echo "RM = $(RM)" | ||
@echo "LDFLAGS = $(LDFLAGS)" | ||
|
||
clean: | ||
$(RM) $(OBJS) $(OUTLIB) | ||
|
||
.PHONY: all | ||
############################################################################~ | ||
|
||
|
||
luamongo: $(OBJS) | ||
$(CC) $(CFLAGS) $(OBJS) -o $(OUTLIB) $(LDFLAGS) | ||
|
||
main.o: main.cpp utils.h | ||
$(CC) -c -o $@ $< $(CFLAGS) | ||
mongo_dbclient.o: mongo_dbclient.cpp common.h utils.h | ||
$(CC) -c -o $@ $< $(CFLAGS) | ||
mongo_connection.o: mongo_connection.cpp common.h utils.h | ||
$(CC) -c -o $@ $< $(CFLAGS) | ||
mongo_cursor.o: mongo_cursor.cpp common.h utils.h | ||
$(CC) -c -o $@ $< $(CFLAGS) | ||
mongo_gridfile.o: mongo_gridfile.cpp common.h utils.h | ||
$(CC) -c -o $@ $< $(CFLAGS) | ||
mongo_gridfs.o: mongo_gridfs.cpp common.h utils.h | ||
$(CC) -c -o $@ $< $(CFLAGS) | ||
mongo_gridfschunk.o: mongo_gridfschunk.cpp common.h utils.h | ||
$(CC) -c -o $@ $< $(CFLAGS) | ||
mongo_query.o: mongo_query.cpp common.h utils.h | ||
$(CC) -c -o $@ $< $(CFLAGS) | ||
mongo_replicaset.o: mongo_replicaset.cpp common.h utils.h | ||
$(CC) -c -o $@ $< $(CFLAGS) | ||
mongo_bsontypes.o: mongo_bsontypes.cpp common.h | ||
$(CC) -c -o $@ $< $(CFLAGS) | ||
utils.o: utils.cpp common.h utils.h | ||
$(CC) -c -o $@ $< $(CFLAGS) | ||
mongo_cxx_extension.o: mongo_cxx_extension.cpp mongo_cxx_extension.h | ||
$(CC) -c -o $@ $< $(CFLAGS) | ||
mongo_gridfilebuilder.o: mongo_gridfilebuilder.cpp mongo_cxx_extension.h common.h utils.h | ||
$(CC) -c -o $@ $< $(CFLAGS) | ||
|
||
.PHONY: all check checkdarwin clean DetectOS Linux Darwin echo |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.