| 1 |
# Makefile for lsqlite3 library for Lua |
| 2 |
# This file is old and crufty. |
| 3 |
# We recommend you make lsqlite3 using luarocks. |
| 4 |
# A local make+install (to test source changes) can be done with: |
| 5 |
# sudo luarocks make lsqlite3-0.9-1.rockspec |
| 6 |
# |
| 7 |
|
| 8 |
# manual setup (change these to reflect your Lua installation) |
| 9 |
# |
| 10 |
BASE= /usr/local |
| 11 |
LUAINC= -I$(BASE)/include |
| 12 |
LUALIB= |
| 13 |
SQLITE3INC= -I$(BASE)/include |
| 14 |
SQLITE3LIB= -L$(BASE)/lib -lsqlite3 |
| 15 |
# Windows' LUALIB is the same as the Lua executable's directory... |
| 16 |
# LUALIB= -L$(BASE)/bin -llua51 |
| 17 |
# |
| 18 |
POD2HTML= perl -x -S doc/pod2html.pl |
| 19 |
|
| 20 |
LUAEXE= lua |
| 21 |
|
| 22 |
INSTALL= install -p |
| 23 |
INSTALLPATH= $(LUAEXE) installpath.lua |
| 24 |
|
| 25 |
TMP=./tmp |
| 26 |
DISTDIR=./archive |
| 27 |
|
| 28 |
# OS detection |
| 29 |
# |
| 30 |
SHFLAGS=-shared |
| 31 |
UNAME= $(shell uname) |
| 32 |
ifeq "$(UNAME)" "Linux" |
| 33 |
_SO=so |
| 34 |
SHFLAGS=-shared -fPIC |
| 35 |
endif |
| 36 |
ifneq "" "$(findstring BSD,$(UNAME))" |
| 37 |
_SO=so |
| 38 |
endif |
| 39 |
ifeq "$(UNAME)" "Darwin" |
| 40 |
_SO=so |
| 41 |
SHFLAGS=-fPIC -arch i686 -arch x86_64 |
| 42 |
# SOFLAGS=-dynamiclib -single_module -undefined dynamic_lookup -arch i686 -arch x86_64 |
| 43 |
SOFLAGS=-dynamic -bundle -undefined dynamic_lookup -all_load -arch i686 -arch x86_64 |
| 44 |
endif |
| 45 |
ifneq "" "$(findstring msys,$(OSTYPE))" # 'msys' |
| 46 |
_SO=dll |
| 47 |
endif |
| 48 |
|
| 49 |
ifndef _SO |
| 50 |
$(error $(UNAME)) |
| 51 |
$(error Unknown OS) |
| 52 |
endif |
| 53 |
|
| 54 |
# no need to change anything below here - HAH! |
| 55 |
CFLAGS= $(INCS) $(DEFS) $(WARN) -O2 -fomit-frame-pointer $(SHFLAGS) |
| 56 |
WARN= -Wall #-ansi -pedantic -Wall |
| 57 |
INCS= $(LUAINC) $(SQLITE3INC) |
| 58 |
LIBS= $(LUALIB) $(SQLITE3LIB) |
| 59 |
|
| 60 |
MYNAME= sqlite3 |
| 61 |
MYLIB= l$(MYNAME) |
| 62 |
|
| 63 |
VER=$(shell svnversion -c . | sed 's/.*://') |
| 64 |
TARFILE = $(DISTDIR)/$(MYLIB)-$(VER).tar.gz |
| 65 |
|
| 66 |
OBJS= $(MYLIB).o |
| 67 |
T= $(MYLIB).$(_SO) |
| 68 |
|
| 69 |
all: $(T) |
| 70 |
|
| 71 |
test: $(T) |
| 72 |
$(LUAEXE) test.lua |
| 73 |
$(LUAEXE) tests-sqlite3.lua |
| 74 |
|
| 75 |
$(T): $(OBJS) |
| 76 |
$(CC) $(SHFLAGS) $(SOFLAGS) -o $@ $(OBJS) $(LIBS) |
| 77 |
|
| 78 |
install: $(T) |
| 79 |
$(INSTALL) $< `$(INSTALLPATH) $(MYLIB)` |
| 80 |
|
| 81 |
clean: |
| 82 |
rm -f $(OBJS) $T core core.* a.out test.db |
| 83 |
|
| 84 |
html: |
| 85 |
$(POD2HTML) --title="LuaSQLite 3" --infile=doc/lsqlite3.pod --outfile=doc/lsqlite3.html |
| 86 |
|
| 87 |
dist: html |
| 88 |
echo 'Exporting...' |
| 89 |
mkdir -p $(TMP) |
| 90 |
mkdir -p $(DISTDIR) |
| 91 |
svn export . $(TMP)/$(MYLIB)-$(VER) |
| 92 |
mkdir -p $(TMP)/$(MYLIB)-$(VER)/doc |
| 93 |
cp -p doc/lsqlite3.html $(TMP)/$(MYLIB)-$(VER)/doc |
| 94 |
echo 'Compressing...' |
| 95 |
tar -zcf $(TARFILE) -C $(TMP) $(MYLIB)-$(VER) |
| 96 |
rm -fr $(TMP)/$(MYLIB)-$(VER) |
| 97 |
echo 'Done.' |
| 98 |
|
| 99 |
.PHONY: all test clean dist install |