#################################################################################
#
# Makefile
#
# Makefile for the OpenH323 wrapper library and the ASTERISK channel
# driver module.
#
# Copyright (c) 2002-2004 InAccess Networks
# Michalis Manousos <manousos@inaccessnetworks.com>
# Dimitris Economou <decon@inaccessnetworks.com>
#
# This file is part of "H.323 support for ASTERISK"
#
# "H.323 support for ASTERISK" is free software;
# you can redistribute it and/or modify it under the terms of the
# GNU General Public License as published by the Free Software Foundation;
# either version 2 of the License, or (at your option) any later version. 
#
# "H.323 support for ASTERISK" is distributed in the hope that it will be 
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details. 
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 
#
# $Id: Makefile,v 1.42 2004/06/25 16:35:32 manousos Exp $
#
#################################################################################

# Export all variables to child processes
.EXPORT_ALL_VARIABLES:

#################################################################################
###### START OF USER CONFIGURABLE PARAMETERS 

#
# Install everything under this directory
#
DESTDIR=

#
# Set PWLIBDIR variable to the directory containing the sources of 
# PWlib library. You must build 'pwlib' before trying to 
# compile asterisk-oh323. Do not use the installed library of your
# distribution. It won't work.
#
PWLIBDIR=/root/src/oh323/pwlib

#
# Set OPENH323LIBDIR variable to the directory containing the sources of
# OpenH323 library. You must build 'openh323' before trying to 
# compile asterisk-oh323. Do not use the installed library of your
# distribution. It won't work.
#
OPENH323DIR=/root/src/oh323/openh323

#
# Set ASTERISKINCDIR variable to the directory containing the sources of
# Asterisk PBX.
#
ASTERISKINCDIR=/root/src/asterisk/include

#
# Set ASTERISKMODDIR variable to the directory where ASTERISK's modules reside.
# The "chan_oh323.so" driver will be installed in this directory.
#
ASTERISKMODDIR=/usr/lib/asterisk/modules

#
# Set ASTERISKETCDIR variable to the directory where ASTERISK's configuration
# files reside. The "oh323.conf" file will be installed in this directory.
#
ASTERISKETCDIR=/etc/asterisk

#
# Set OH323WRAPLIBDIR variable to the directory where oh323wrap library
# will be installed. You SHOULD add this directory to your 
# LD_LIBRARY_PATH shell variable, or to the /etc/ld.so.conf
# file and run "ldconfig" after the installation of asterisk-oh323.
#
OH323WRAPLIBDIR=/usr/local/lib

#
# Set SSLINCDIR variable to the directory where ssl/crypto
# include files are installed.
#
SSLINCDIR=/usr/include/openssl

#
# Set SSLLIBDIR variable to the directory where ssl/crypto
# libraries are installed.
#
SSLLIBDIR=/usr/lib

#
# Set WRAPTRACING to 1 to enable debug information from the OpenH323Wrap
# library or to 0 to disable it.
#
WRAPTRACING=1

#
# Set WRAPSTAT to 1 to build a static wrapper library
#
WRAPSTAT=0

#
# Define options that were used during Asterisk compilation
#
#DEBUG_THREADS=1
#DO_CRASH=1

#
# Extra compilation options. Here you should add the options
# PWLIB, OPENH323 were compiled with.
#
#NOVIDEO=1
#NO_SPEEX=1
#NOAUDIOCODECS=1
#NOTRACE=1
#NO_IPv6=1
#P_PTHREADS=1

#HAS_OH323MODS=1
#SKIP_SUFFIX=1

###### END OF USER CONFIGURABLE PARAMETERS 
#################################################################################

#
# Definition of variables
#
SHELL:= /bin/sh
SUBDIRS=wrapper asterisk-driver
.PHONY: subdirs_all subdir_install subdir_clean rpm rpm_clean $(SUBDIRS)
CC=gcc
CPP=g++
MAKE=make
INSTALL=install
TOUCH=touch
AR=ar
OH323WRAPINCLUDE= \
				 -I$(PWLIBDIR)/include/ptlib/unix \
				 -I$(PWLIBDIR)/include \
				 -I$(OPENH323DIR)/include \
				 -I$(OPENH323DIR)/include/openh323 \
				 -I../asterisk-driver
#				 -I$(SSLINCDIR)
OPENH323USERFLAGS=
ifdef	NOVIDEO
OPENH323USERFLAGS += NOVIDEO=1
endif
ifdef	NOAUDIOCODECS
OPENH323USERFLAGS += NOAUDIOCODECS=1
endif
ifdef	NOSPEEX
OPENH323USERFLAGS += NO_SPEEX=1
endif
ifdef	NOTRACE
OPENH323USERFLAGS += NOTRACE=1
endif
ifdef	NO_IPv6
OPENH323USERFLAGS += NO_IPv6=1
endif
ifdef	P_PTHREADS
OPENH323USERFLAGS += P_PTHREADS=1
endif
OPENH323FLAGS=$(shell make $(OPENH323USERFLAGS) --no-print-directory -s \
		-C $(OPENH323DIR) \
		PWLIBDIR=$(PWLIBDIR) OPENH323DIR=$(OPENH323DIR) ccflags)
CPPFLAGS=$(OPENH323FLAGS) -Wall -x c++ -Os
ASTERISKINCLUDE=-I$(ASTERISKINCDIR) -I../wrapper
CFLAGS=-Wall
ifdef	HAS_OH323MODS
CPPFLAGS += -DHAS_OH323MODS
CFLAGS += -DHAS_OH323MODS
endif

ifdef DEBUG_THREADS
CFLAGS += -DDEBUG_THREADS
ifdef DO_CRASH
CFLAGS += -DDO_CRASH
endif
endif

#
# Rules
#
all: subdirs_all

install: all subdirs_install

clean: subdirs_clean rpm_clean

opt: all

subdirs_all:
	for x in $(SUBDIRS); do $(MAKE) -C $$x all || exit 1 ; done

subdirs_install:
	for x in $(SUBDIRS); do $(MAKE) -C $$x install || exit 1 ; done

subdirs_clean:
	for x in $(SUBDIRS); do $(MAKE) -C $$x clean || exit 1 ; done

rpm:
	$(MAKE) -C rpm rpm

rpm_clean:
	$(MAKE) -C rpm rpm_clean

