# TODO:
# clarify situation with references. should we really reference objects, passed as args to callbacks? if someone will store that object in a global environment and use later?
# autotools
# switch to common object struct?
# tests?
# more examples
# llm should use lua/stdlib, no dependency on glib? though it still needs glib headers... maybe, indirectly :/
# separate lm and glib, now it is completely different projects // and one, probably, will die... :(
PREFIX=${PWD}/inst
DOCDIR=$(PREFIX)/share/doc/liblua-loudmouth
SOLIBDIR=$(PREFIX)/lib/lua/5.1
LUALIBDIR=$(PREFIX)/share/lua/5.1
CC=gcc
LD=gcc
LIBTOOL=libtool
INSTALL=install
CFLAGS=-g -O0 -Wall
LDFLAGS=-g -O0
LTFLAGS=
TARGETS=loudmouth.la glib.la
LMCFLAGS=`pkg-config --cflags lua5.1 loudmouth-1.0 glib-2.0`
GLIBCFLAGS=`pkg-config --cflags lua5.1 glib-2.0`
# add this flag to cflags, if your loudmouth have lm_connection_get_keep_alive_rate ()
#LMCFLAGS += -DHAVE_LM_CONNECTION_GET_KEEP_ALIVE_RATE
LMLIBS=`pkg-config --libs lua5.1 loudmouth-1.0 glib-2.0`
GLIBLIBS=`pkg-config --libs lua5.1 glib-2.0`
LMSOURCES=util.c lm_types.c lm_proxy.c lm_ssl.c lm_connection.c lm_message.c lm_message_node.c lm_message_handler.c lm.c
GLIBSOURCES=glib.c glib_types.c glib_main_context.c glib_source.c glib_timeout.c util.c
LMOBJECTS=$(LMSOURCES:.c=.lo)
GLIBOBJECTS=$(GLIBSOURCES:.c=.lo)
DOCS=$(TARGETS:.la=.html)
all: $(TARGETS)
loudmouth.la: $(LMOBJECTS)
$(LIBTOOL) $(LTFLAGS) --mode=link $(LD) $(LDFLAGS) -module -rpath $(SOLIBDIR) -o $@ $^ $(LMLIBS)
glib.la: $(GLIBOBJECTS)
$(LIBTOOL) $(LTFLAGS) --mode=link $(LD) $(LDFLAGS) -module -rpath $(SOLIBDIR) -o $@ $^ $(GLIBLIBS)
# FIXME: CFLAGS...
%.lo: %.c
$(LIBTOOL) $(LTFLAGS) --mode=compile $(CC) $(CFLAGS) $(LMCFLAGS) -c $^
test: loudmouth.la glib.la
cd .libs && lua ../test.lua
test2: glib.la
cd .libs && lua ../test2.lua
doc: $(DOCS)
loudmouth.html: docgen.pl $(LMSOURCES)
./docgen.pl $(LMSOURCES) > $@
glib.html: docgen.pl $(GLIBSOURCES)
./docgen.pl $(GLIBSOURCES) > $@
install: $(TARGETS) $(SOLIBDIR) $(LUALIBDIR)
$(LIBTOOL) $(LTFLAGS) --mode=install $(INSTALL) loudmouth.la $(SOLIBDIR)/loudmouth.la
$(INSTALL) -m 644 lm.lua $(LUALIBDIR)/lm.lua
$(LIBTOOL) $(LTFLAGS) --mode=install $(INSTALL) glib.la $(SOLIBDIR)/glib.la
$(LIBTOOL) $(LTFLAGS) --mode=finish $(SOLIBDIR)
install-doc: doc test.lua $(DOCDIR)
$(INSTALL) -m 644 -t $(DOCDIR) $(DOCS)
$(INSTALL) -d $(DOCDIR)/examples
$(INSTALL) -m 644 -t $(DOCDIR)/examples test.lua
$(PREFIX):
$(INSTALL) -D -d $@
$(DOCDIR): $(PREFIX)
$(INSTALL) -D -d $@
$(SOLIBDIR): $(PREFIX)
$(INSTALL) -D -d $@
$(LUALIBDIR): $(PREFIX)
$(INSTALL) -D -d $@
uninstall:
$(LIBTOOL) $(LTFLAGS) --mode=uninstall rm -f $(SOLIBDIR)/loudmouth.la
$(LIBTOOL) $(LTFLAGS) --mode=uninstall rm -f $(SOLIBDIR)/glib.la
rm -f $(LUALIBDIR)/lm.lua
clean:
$(LIBTOOL) $(LTFLAGS) --mode=clean rm -f $(TARGETS) $(LMOBJECTS) $(GLIBOBJECTS) $(DOCS)