#
# Copyright (C) 2003, 2004 by Voop as
#
# This program is distributed under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2, or (at your
# option) any later version.
#
#	$Id: Makefile,v 1.14 2005/04/04 23:21:09 tholo Exp $
#

DEBUG+=		-g -fno-inline-functions

SOFLAGS+=	-shared
#SOFLAGS+=	-dynamic -bundle -undefined suppress -force_flat_namespace

CFLAGS+=	-O3 -W -Wall -Wmissing-prototypes -Wstrict-prototypes -Wshadow \
		$(DEBUG) -D_REENTRANT -I/usr/include/pcre
LDFLAGS+=	$(DEBUG)
LDLIBS+=	-lpthread

CFLAGS+=	-DWITH_MYSQL -I/usr/include/mysql
LDFLAGS+=	-L/usr/lib/mysql
LDLIBS+=	-lmysqlclient -lz

LDLIBS+=	-lpcre

HDRS=
SRCS=		rate_engine.c pcre_subst.c
OBJS:=		$(SRCS:%.c=%.o)
MOD=		rate_engine.so

ASTLIBDIR=	/usr/lib/asterisk/modules
ASTCONFDIR=	/etc/asterisk
BINDIR=		/usr/bin

.PHONY:		all

all:		$(MOD)

$(MOD):		$(OBJS)
	$(CC) $(LDFLAGS) $(SOFLAGS) -o $@ $(OBJS) $(LDLIBS)

.PHONY:		clean

clean:
	rm -f .depend $(MOD) $(OBJS) *.bak

.PHONY:		depend

depend .depend:
	$(CC) -M $(SRCS) >.depend

.PHONY:		install

install:	all
	install -m 755 $(MOD) $(ASTLIBDIR)

.PHONY:		samples

samples:
	install -m 644 rate_engine.conf.sample $(ASTCONFDIR)/rate_engine.conf

ifneq ($(wildcard .depend),)
include .depend
endif
