Permalink
Browse files

Add a makefile so people can now choose 3 build options (make, cmake,

or lua-rocks).
  • Loading branch information...
1 parent 3f0f323 commit fcd945c7bd8ee8a43d96aa0cf5ccd36b6a38ef0b Brian Maher committed Oct 18, 2011
Showing with 73 additions and 1 deletion.
  1. +62 −0 Makefile
  2. +11 −1 README
View
62 Makefile
@@ -0,0 +1,62 @@
+# This Makefile is based on LuaSec's Makefile. Thanks to the LuaSec developers.
+# Inform the location to intall the modules
+LUAPATH = /usr/share/lua/5.1
+LUACPATH = /usr/lib/lua/5.1
+INCDIR = -I/usr/include/lua5.1
+LIBDIR = -L/usr/lib
+
+# For Mac OS X: set the system version
+MACOSX_VERSION = 10.4
+
+CMOD = yajl.so
+OBJS = lua_yajl.o
+
+LIBS = -lyajl -llua -lm
+WARN = -Wall -pedantic
+
+BSD_CFLAGS = -O2 -fPIC $(WARN) $(INCDIR) $(DEFS)
+BSD_LDFLAGS = -O -shared -fPIC $(LIBDIR)
+
+LNX_CFLAGS = -O2 -fPIC $(WARN) $(INCDIR) $(DEFS)
+LNX_LDFLAGS = -O -shared -fPIC $(LIBDIR)
+
+MAC_ENV = env MACOSX_DEPLOYMENT_TARGET='$(MACVER)'
+MAC_CFLAGS = -O2 -fPIC -fno-common $(WARN) $(INCDIR) $(DEFS)
+MAC_LDFLAGS = -bundle -undefined dynamic_lookup -fPIC $(LIBDIR)
+
+CC = gcc
+LD = $(MYENV) gcc
+CFLAGS = $(MYCFLAGS)
+LDFLAGS = $(MYLDFLAGS)
+
+.PHONY: all clean install none linux bsd macosx
+
+all:
+ @echo "Usage: $(MAKE) <platform>"
+ @echo " * linux"
+ @echo " * bsd"
+ @echo " * macosx"
+
+install: $(CMOD)
+ cp $(CMOD) $(LUACPATH)
+
+uninstall:
+ rm $(LUACPATH)/yajl.so
+
+linux:
+ @$(MAKE) $(CMOD) MYCFLAGS="$(LNX_CFLAGS)" MYLDFLAGS="$(LNX_LDFLAGS)" INCDIR="$(INCDIR)" LIBDIR="$(LIBDIR)" DEFS="$(DEFS)"
+
+bsd:
+ @$(MAKE) $(CMOD) MYCFLAGS="$(BSD_CFLAGS)" MYLDFLAGS="$(BSD_LDFLAGS)" INCDIR="$(INCDIR)" LIBDIR="$(LIBDIR)" DEFS="$(DEFS)"
+
+macosx:
+ @$(MAKE) $(CMOD) MYCFLAGS="$(MAC_CFLAGS)" MYLDFLAGS="$(MAC_LDFLAGS)" MYENV="$(MAC_ENV)" INCDIR="$(INCDIR)" LIBDIR="$(LIBDIR)" DEFS="$(DEFS)"
+
+clean:
+ rm -f $(OBJS) $(CMOD)
+
+.c.o:
+ $(CC) -c $(CFLAGS) $(DEFS) $(INCDIR) -o $@ $<
+
+$(CMOD): $(OBJS)
+ $(LD) $(LDFLAGS) $(LIBDIR) $(OBJS) $(LIBS) -o $@
View
12 README
@@ -28,9 +28,19 @@
To use this library, you need yajl version 2.x, get it here:
http://lloyd.github.com/yajl/
-To build this library, you need CMake, get it here:
+To build this library, you can use CMake (which is how yajl is built):
http://www.cmake.org/cmake/resources/software.html
+...or you can use lua rocks.
+
+...or you can use GNU Make. If the headers and/or library are
+installed in non-standard locations, simply set the LIBDIR and/or
+INCDIR make variables. For example:
+
+ make macosx \
+ LIBDIR='-L/opt/lua/lib -L/opt/yajl/lib' \
+ INCDIR='-I/opt/lua/include -I/opt/yajl/include'
+
Loading the library:
If you built the library as a loadable package

0 comments on commit fcd945c

Please sign in to comment.