# Makefile for PL/Lua
# $Id: Makefile,v 1.6 2008/01/09 17:56:18 carvalho Exp $

# Lua specific
PG_CPPFLAGS = -I/usr/include/lua5.1
LUALIB = lua5.1

# no need to edit below here

MODULES = plluac
#DATA = pllua.sql
EXTRA_CLEAN = *.lua.out *.lua.h *.o *~ */*~

PG_CONFIG = /usr/lib/postgresql/8.3/bin/pg_config
#PG_CONFIG = /usr/lib/postgresql/8.2/bin/pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)

include $(PGXS)

boot.lua.h : boot.lua
	luac -o $^.out $^
	lua convert.lua $^.out
init.lua.h : init.lua
	luac -o $^.out $^
	lua convert.lua $^.out


plluac.so : pllua-conversions.o pllua-api.o pllua-spi.o pllua-timestamp.o pllua-returnnext.o
	$(CC) -shared -o $@ $^ -l$(LUALIB)
#plluac.so : *.c
#	$(CC) $(CFLAGS) $(CPPFLAGS) -shared -o $@ $^ -l$(LUALIB)

pllua-api.c : boot.lua.h init.lua.h pllua.h
	touch pllua-api.c


	
