#
# (CAPI*)
#
# An implementation of Common ISDN API 2.0 for Asterisk
#
# Makefile, based on the Asterisk Makefile, Coypright (C) 1999, Mark Spencer
#
# Copyright (C) 2002,2003, Junghanns.NET GmbH
#
# Klaus-Peter Junghanns <kapejod@ns1.jnetdns.de>
#
# This program is free software and may be modified and 
# distributed under the terms of the GNU Public License.
#

.EXPORT_ALL_VARIABLES:

INSTALL_PREFIX=
ASTERISK_HEADER_DIR=$(INSTALL_PREFIX)/usr/include

MODULES_DIR=$(INSTALL_PREFIX)/usr/lib/asterisk/modules

PROC=$(shell uname -m)

DEBUG=-g #-pg
INCLUDE=-I$(ASTERISK_HEADER_DIR)
CFLAGS=-pipe -Wall -Wmissing-prototypes -Wmissing-declarations $(DEBUG) $(INCLUDE) -D_REENTRANT -D_GNU_SOURCE
CFLAGS+=-O6
CFLAGS+=$(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi)
CFLAGS+=$(shell if uname -m | grep -q ppc; then echo "-fsigned-char"; fi)

# uncomment the following line if you really never ever want early b3 connects,
# you can also configure it in the dialstring, this is just for performance
#CFLAGS+=-DNEVER_EVER_EARLY_B3_CONNECTS

# uncommnet next line to force dtmf software detection/generation, can also be configured
# in capi.conf on a perdevice basis (softdtmf=1)
#CFLAGS+=-DFORCE_SOFTWARE_DTMF

# uncomment the next line if you are in the ulaw world
#CFLAGS+=-DCAPI_ULAW

# very experimental echo squelching
CFLAGS+=-DCAPI_ES

#gains
CFLAGS+=-DCAPI_GAIN

# what do to with call waiting connect indications?
# uncomment the next line for call deflection in that case
#CFLAGS+=-DDEFLECT_ON_CIRCUITBUSY

# audio sync
CFLAGS+=-DCAPI_SYNC

# if you want to compile against latest (non-stable) asterisk cvs
CFLAGS+=-DUNSTABLE_CVS

LIBS=-ldl -lpthread -lm
CC=gcc
INSTALL=install

SHAREDOS=chan_capi.so app_capiCD.so app_capiHOLD.so app_capiRETRIEVE.so app_capiECT.so app_capiMCID.so app_capiNoES.so

CFLAGS+=-Wno-missing-prototypes -Wno-missing-declarations

CFLAGS+=-DCRYPTO

all: $(SHAREDOS)

clean:
	rm -f *.so *.o

%.so : %.o
	$(CC) -shared -Xlinker -x -o $@ $<

chan_capi.so: chan_capi.o
	$(CC) -shared -Xlinker -x -o $@ chan_capi.o -lcapi20

install: all
	for x in $(SHAREDOS); do $(INSTALL) -m 755 $$x $(MODULES_DIR) ; done

config: all
	cp capi.conf $(INSTALL_PREFIX)/etc/asterisk/

