summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--0000-pkg-config.patch1503
-rw-r--r--coturn.spec159
-rw-r--r--turnserver-tmpfiles.conf1
-rw-r--r--turnserver.service26
-rw-r--r--turnserver.sysconfig1
5 files changed, 1690 insertions, 0 deletions
diff --git a/0000-pkg-config.patch b/0000-pkg-config.patch
new file mode 100644
index 0000000..47a8eaa
--- /dev/null
+++ b/0000-pkg-config.patch
@@ -0,0 +1,1503 @@
+diff --git a/configure b/configure
+index bc76478..4b66ebc 100755
+--- a/configure
++++ b/configure
+@@ -3,171 +3,48 @@
+ # Proprietary configure script of Coturn project
+
+ cleanup() {
+- rm -rf ${TMPCPROGC}
+- rm -rf ${TMPCPROGB}
+- rm -rf ${TH_TMPCPROGC}
+- rm -rf ${TH_TMPCPROGB}
+- rm -rf ${GCM_TMPCPROGC}
+- rm -rf ${GCM_TMPCPROGB}
+- rm -rf ${PQ_TMPCPROGC}
+- rm -rf ${PQ_TMPCPROGB}
+- rm -rf ${MYSQL_TMPCPROGC}
+- rm -rf ${MYSQL_TMPCPROGB}
+- rm -rf ${MONGO_TMPCPROGC}
+- rm -rf ${MONGO_TMPCPROGB}
+- rm -rf ${D_TMPCPROGC}
+- rm -rf ${D_TMPCPROGB}
+- rm -rf ${SQL_TMPCPROGC}
+- rm -rf ${SQL_TMPCPROGO}
+- rm -rf ${E_TMPCPROGC}
+- rm -rf ${E_TMPCPROGO}
+- rm -rf ${HR_TMPCPROGC}
+- rm -rf ${HR_TMPCPROGB}
+- rm -rf ${TMPCADDRPROGO}
++ rm -rf ${TMPCPROGC}
++ rm -rf ${TMPCPROGB}
++ rm -rf ${TH_TMPCPROGC}
++ rm -rf ${TH_TMPCPROGB}
++ rm -rf ${GCM_TMPCPROGC}
++ rm -rf ${GCM_TMPCPROGB}
++ rm -rf ${D_TMPCPROGC}
++ rm -rf ${D_TMPCPROGB}
++ rm -rf ${TMPCADDRPROGO}
+ }
+
+ testlibraw() {
+ ${CC} ${TMPCPROGC} -o ${TMPCPROGB} ${OSCFLAGS} ${OSLIBS} -${1} 2>>/dev/null
+ ER=$?
+ if ! [ ${ER} -eq 0 ] ; then
+- ${ECHO_CMD} "Library option -${1} cannot be used"
+- return 0
+- else
+- OSLIBS="${OSLIBS} -${1}"
+- return 1
++ ${ECHO_CMD} "Library option -${1} cannot be used"
++ return 1
+ fi
+-}
+
+-testsqlite_comp() {
+- SQLITE_LIBS=-lsqlite3
+- ${CC} -c ${SQL_TMPCPROGC} -o ${SQL_TMPCPROGO} ${OSCFLAGS} 2>>/dev/null
+- ER=$?
+- if ! [ ${ER} -eq 0 ] ; then
+- ${ECHO_CMD} "SQLite development is not installed properly"
+- return 0
+- else
+- DBLIBS="${DBLIBS} ${SQLITE_LIBS}"
+- return 1
+- fi
++ OSLIBS="${OSLIBS} -${1}"
+ }
+
+-testlibevent2_comp() {
+- ${CC} -c ${E_TMPCPROGC} -o ${E_TMPCPROGO} ${OSCFLAGS} 2>>/dev/null
+- ER=$?
+- if ! [ ${ER} -eq 0 ] ; then
+- ${ECHO_CMD} "Libevent2 development is not installed properly"
+- return 0
+- else
+- return 1
+- fi
+-}
+-
+-testhiredis() {
+- for inc in ${INCLUDEDIR}/hiredis /usr/local/include/hiredis /usr/hiredis /usr/include/hiredis
+- do
+- if [ -d ${inc} ] ; then
+- HIREDISCFLAGS="${HIREDISCFLAGS} -I${inc}"
+- fi
+- done
+- HIREDISLIBS=-lhiredis
+- ${CC} ${HR_TMPCPROGC} -o ${HR_TMPCPROGB} ${OSCFLAGS} ${DBLIBS} ${HIREDISCFLAGS} ${HIREDISLIBS} ${OSLIBS} 2>>/dev/null
+- ER=$?
+- if ! [ ${ER} -eq 0 ] ; then
+- ${ECHO_CMD}
+- ${ECHO_CMD} "HIREDIS DEVELOPMENT LIBRARY (libhiredis.*) AND/OR HEADERS (hiredis/*.h)"
+- ${ECHO_CMD} " ARE NOT INSTALLED PROPERLY ON THIS SYSTEM."
+- ${ECHO_CMD} " THAT'S OK BUT THE TURN SERVER IS BUILDING WITHOUT REDIS SUPPORT."
+- ${ECHO_CMD}
+- return 0
+- else
+- DBCFLAGS="${DBCFLAGS} ${HIREDISCFLAGS}"
+- DBLIBS="${DBLIBS} ${HIREDISLIBS}"
+- return 1
++# testpkg_server pkg1 pkg2 ...
++# If all libraries are found, adds them to DBCFLAGS/DBLIBS and returns success.
++# Otherwise, returns failure.
++testpkg_server() {
++ ADD_LIBS=`$PKGCONFIG --libs "$@" 2>/dev/null`
++ if [ $? -ne 0 ] ; then
++ return 1
+ fi
++ DBCFLAGS="${DBCFLAGS} `$PKGCONFIG --cflags "$@"`"
++ DBLIBS="${DBLIBS} $ADD_LIBS"
+ }
+
+-testlibpq() {
+- POSTCFLAGS="-I${PREFIX}/pgsql/include -I${PREFIX}/include/pgsql/ -I${PREFIX}/include/postgres/ -I${PREFIX}/postgres/include/ -I${PREFIX}/include/postgresql/ -I${PREFIX}/postgresql/include/"
+- POSTCFLAGS="${POSTCFLAGS} -I/usr/local/pgsql/include -I/usr/local/include/pgsql/ -I/usr/local/include/postgres/ -I/usr/local/postgres/include/ -I/usr/local/include/postgresql/ -I/usr/local/postgresql/include/"
+- POSTCFLAGS="${POSTCFLAGS} -I/usr/pgsql/include -I/usr/include/pgsql/ -I/usr/include/postgres/ -I/usr/postgres/include/ -I/usr/include/postgresql/ -I/usr/postgresql/include/"
+- for ilib in ${PREFIX}/pgsql/lib ${PREFIX}/lib/pgsql ${PREFIX}/lib64/pgsql /usr/local/pgsql/lib /usr/local/lib/pgsql /usr/local/lib64/pgsql /usr/pgsql/lib /usr/lib/pgsql /usr/lib64/pgsql ${PREFIX}/postgres/lib ${PREFIX}/lib/postgres ${PREFIX}/lib64/postgres /usr/local/postgres/lib /usr/local/lib/postgres /usr/local/lib64/postgres /usr/postgres/lib /usr/lib/postgres /usr/lib64/postgres ${PREFIX}/postgresql/lib ${PREFIX}/lib/postgresql ${PREFIX}/lib64/postgresql /usr/local/postgresql/lib /usr/local/lib/postgresql /usr/local/lib64/postgresql /usr/postgresql/lib /usr/lib/postgresql /usr/lib64/postgresql
+- do
+- if [ -d ${ilib} ] ; then
+- POSTLIBS="${POSTLIBS} -L${ilib}"
+- if ! [ -z "${TURN_ACCEPT_RPATH}" ] ; then
+- TURN_RPATH="${TURN_RPATH} -Wl,-rpath,${ilib}"
+- fi
+- fi
+- done
+- POSTLIBS="${OSLIBS} ${POSTLIBS} -lpq"
+- ${CC} ${PQ_TMPCPROGC} -o ${PQ_TMPCPROGB} ${OSCFLAGS} ${DBCFLAGS} ${POSTCFLAGS} ${DBLIBS} ${POSTLIBS} ${OSLIBS} 2>>/dev/null
+- ER=$?
+- if ! [ ${ER} -eq 0 ] ; then
+- ${ECHO_CMD}
+- ${ECHO_CMD} "POSTGRESQL DEVELOPMENT LIBRARY (libpq.a) AND/OR HEADER (libpq-fe.h)"
+- ${ECHO_CMD} " ARE NOT INSTALLED PROPERLY ON THIS SYSTEM."
+- ${ECHO_CMD} " THAT'S OK BUT THE TURN SERVER IS BUILDING WITHOUT POSTGRESQL DATABASE SUPPORT."
+- ${ECHO_CMD}
+- return 0
+- else
+- DBCFLAGS="${DBCFLAGS} ${POSTCFLAGS}"
+- DBLIBS="${DBLIBS} ${POSTLIBS}"
+- return 1
+- fi
+-}
+-
+-testlibmysql() {
+- MYSQL_CFLAGS="-I${PREFIX}/mysql/include -I${PREFIX}/include/mysql/"
+- MYSQL_CFLAGS="${MYSQL_CFLAGS} -I/usr/local/mysql/include -I/usr/local/include/mysql/"
+- MYSQL_CFLAGS="${MYSQL_CFLAGS} -I/usr/mysql/include -I/usr/include/mysql/"
+- for ilib in ${PREFIX}/mysql/lib ${PREFIX}/lib/mysql ${PREFIX}/lib64/mysql /usr/local/mysql/lib /usr/local/lib/mysql /usr/local/lib64/mysql /usr/mysql/lib /usr/lib/mysql /usr/lib64/mysql
+- do
+- if [ -d ${ilib} ] ; then
+- MYSQL_LIBS="${MYSQL_LIBS} -L${ilib}"
+- if ! [ -z "${TURN_ACCEPT_RPATH}" ] ; then
+- TURN_RPATH="${TURN_RPATH} -Wl,-rpath,${ilib}"
+- fi
+- fi
+- done
+- MYSQL_LIBS="${OSLIBS} ${MYSQL_LIBS} -lmysqlclient"
+- ${CC} ${MYSQL_TMPCPROGC} -o ${MYSQL_TMPCPROGB} ${OSCFLAGS} ${DBCFLAGS} ${DBLIBS} ${MYSQL_CFLAGS} ${MYSQL_LIBS} ${OSLIBS} 2>>/dev/null
+- ER=$?
+- if ! [ ${ER} -eq 0 ] ; then
+- ${ECHO_CMD}
+- ${ECHO_CMD} "MYSQL DEVELOPMENT LIBRARY (libmysqlclient) AND/OR HEADER (mysql.h)"
+- ${ECHO_CMD} " ARE NOT INSTALLED PROPERLY ON THIS SYSTEM."
+- ${ECHO_CMD} " THAT'S OK BUT THE TURN SERVER IS BUILDING WITHOUT MYSQL DATABASE SUPPORT."
+- ${ECHO_CMD}
+- return 0
+- else
+- DBCFLAGS="${DBCFLAGS} ${MYSQL_CFLAGS}"
+- DBLIBS="${DBLIBS} ${MYSQL_LIBS}"
+- return 1
+- fi
+-}
+-
+-testlibmongoc() {
+- for inc in ${INCLUDEDIR}/libmongoc-1.0 ${INCLUDEDIR}/libbson-1.0 /usr/local/include/libmongoc-1.0 /usr/local/include/libbson-1.0 /usr/libmongoc-1.0 /usr/libbson-1.0 /usr/include/libbson-1.0/ /usr/include/libmongoc-1.0/
+- do
+- if [ -d ${inc} ] ; then
+- MONGO_CFLAGS="${MONGO_CFLAGS} -I${inc}"
+- fi
+- done
+- MONGO_LIBS="-lmongoc-1.0 -lbson-1.0"
+- ${CC} ${MONGO_TMPCPROGC} -o ${MONGO_TMPCPROGB} ${OSCFLAGS} ${DBCFLAGS} ${DBLIBS} ${MONGO_CFLAGS} ${MONGO_LIBS} ${OSLIBS} 2>>/dev/null
+- ER=$?
+- if ! [ ${ER} -eq 0 ] ; then
+- ${ECHO_CMD}
+- ${ECHO_CMD} "MONGODB DEVELOPMENT LIBRARIES (libmongoc-1.0 and libbson-1.0) AND/OR HEADER (mongoc.h)"
+- ${ECHO_CMD} " ARE NOT INSTALLED PROPERLY ON THIS SYSTEM."
+- ${ECHO_CMD} " THAT'S OK BUT THE TURN SERVER IS BUILDING WITHOUT MONGODB SUPPORT."
+- ${ECHO_CMD}
+- return 0
+- else
+- DBCFLAGS="${DBCFLAGS} ${MONGO_CFLAGS}"
+- DBLIBS="${DBLIBS} ${MONGO_LIBS}"
+- return 1
++# Like testpkg_server, but adds flags to OSCFLAGS/OSLIBS
++testpkg_common() {
++ ADD_LIBS=`$PKGCONFIG --libs "$@" 2>/dev/null`
++ if [ $? -ne 0 ] ; then
++ return 1
+ fi
++ OSCFLAGS="${OSCFLAGS} `$PKGCONFIG --cflags "$@"`"
++ OSLIBS="${OSLIBS} $ADD_LIBS"
+ }
+
+ testlib() {
+@@ -175,61 +52,48 @@ testlib() {
+ }
+
+ pthread_testlib() {
++ if [ -n "${PTHREAD_LIBS}" ] ; then
++ OSLIBS="${OSLIBS} ${PTHREAD_LIBS}"
++ return
++ fi
+
+- SYSTEM=`uname`
++ if [ `uname` = "DragonFly" ] ; then
++ OSLIBS="${OSLIBS} -pthread"
++ TURN_NO_SCTP=1
++ return
++ fi
+
+- if [ "${SYSTEM}" = "DragonFly" ] ; then
+- OSLIBS="${OSLIBS} -pthread"
+- TURN_NO_SCTP=1
++ if [ -n `uname | grep -i bsd` ] ; then
++ OSLIBS="${OSLIBS} -pthread"
++ return
+ fi
+
+- ISBSD=`uname | grep -i bsd`
+- if ! [ -z "${ISBSD}" ] ; then
+- OSLIBS="${OSLIBS} -pthread"
++ ${CC} ${TH_TMPCPROGC} -o ${TH_TMPCPROGB} ${OSCFLAGS} ${OSLIBS} 2>/dev/null
++ if [ $? -eq 0 ] ; then
++ return
+ fi
+
+- if [ -z "${PTHREAD_LIBS}" ] ; then
+- ${CC} ${TH_TMPCPROGC} -o ${TH_TMPCPROGB} ${OSCFLAGS} ${OSLIBS} 2>>/dev/null
+- ER=$?
+- if [ ${ER} -eq 0 ] ; then
+- return 1
+- else
+- ${CC} ${TH_TMPCPROGC} -o ${TH_TMPCPROGB} ${OSCFLAGS} ${OSLIBS} -pthread 2>>/dev/null
+- ER=$?
+- if [ ${ER} -eq 0 ] ; then
+- OSLIBS="${OSLIBS} -pthread"
+- return 1
+- else
+- ${CC} ${TH_TMPCPROGC} -o ${TH_TMPCPROGB} ${OSCFLAGS} ${OSLIBS} -lpthread 2>>/dev/null
+- ER=$?
+- if [ ${ER} -eq 0 ] ; then
+- OSLIBS="${OSLIBS} -lpthread"
+- return 1
+- fi
+- fi
+- fi
+- else
+- OSLIBS="${OSLIBS} ${PTHREAD_LIBS}"
++ ${CC} ${TH_TMPCPROGC} -o ${TH_TMPCPROGB} ${OSCFLAGS} ${OSLIBS} -pthread 2>/dev/null
++ if [ $? -eq 0 ] ; then
++ OSLIBS="${OSLIBS} -pthread"
++ return
+ fi
+-
+
+- ${CC} ${TH_TMPCPROGC} -o ${TH_TMPCPROGB} ${OSCFLAGS} ${OSLIBS} 2>>/dev/null
+- ER=$?
+- if [ ${ER} -eq 0 ] ; then
+- return 1
+- else
+- ${CC} ${TH_TMPCPROGC} -o ${TH_TMPCPROGB} ${OSCFLAGS} ${OSLIBS} -D_GNU_SOURCE 2>>/dev/null
+- ER=$?
+- if [ ${ER} -eq 0 ] ; then
+- ${ECHO_CMD} "Older GNU pthread library found"
+- OSCFLAGS="${OSCFLAGS} -D_GNU_SOURCE"
+- return 1
+- else
+- ${ECHO_CMD} "Do not use pthreads"
+- fi
++ ${CC} ${TH_TMPCPROGC} -o ${TH_TMPCPROGB} ${OSCFLAGS} ${OSLIBS} -lpthread 2>/dev/null
++ if [ $? -eq 0 ] ; then
++ OSLIBS="${OSLIBS} -lpthread"
++ return
++ fi
++
++ ${CC} ${TH_TMPCPROGC} -o ${TH_TMPCPROGB} ${OSCFLAGS} ${OSLIBS} -pthread -D_GNU_SOURCE 2>/dev/null
++ if [ $? -eq 0 ] ; then
++ ${ECHO_CMD} "Older GNU pthread library found"
++ OSCFLAGS="${OSLIBS} -D_GNU_SOURCE"
++ OSLIBS="${OSLIBS} -pthread"
++ return
+ fi
+-
+- return 0
++
++ return 1
+ }
+
+ pthread_testbarriers() {
+@@ -238,33 +102,23 @@ pthread_testbarriers() {
+ ${CC} ${TH_TMPCPROGC} -o ${TH_TMPCPROGB} ${OSCFLAGS} ${OSLIBS} 2>>/dev/null
+ ER=$?
+ if ! [ ${ER} -eq 0 ] ; then
+- ${ECHO_CMD} "pthread barriers not found"
+- OSCFLAGS="${OSCFLAGS} -DTURN_NO_THREAD_BARRIERS"
++ ${ECHO_CMD} "pthread barriers not found"
++ OSCFLAGS="${OSCFLAGS} -DTURN_NO_THREAD_BARRIERS"
++ return 1
+ fi
+ }
+
+ gcm_testlib() {
+-
+- if [ -z "${TURN_NO_GCM}" ] ; then
+- ${CC} ${GCM_TMPCPROGC} -o ${GCM_TMPCPROGB} ${OSCFLAGS} ${OSLIBS} 2>>/dev/null
+- ER=$?
+- if [ ${ER} -eq 0 ] ; then
+- return 1
+- else
+- return 0
+- fi
+- else
+- return 0
+- fi
++ ${CC} ${GCM_TMPCPROGC} -o ${GCM_TMPCPROGB} ${OSCFLAGS} ${OSLIBS} 2>/dev/null
+ }
+
+ testdaemon() {
+
+- ${CC} ${D_TMPCPROGC} -o ${D_TMPCPROGB} ${OSCFLAGS} ${OSLIBS} 2>>/dev/null
+- ER=$?
+- if [ ${ER} -eq 0 ] ; then
+- OSCFLAGS="${OSCFLAGS} -DTURN_HAS_DAEMON"
+- fi
++ ${CC} ${D_TMPCPROGC} -o ${D_TMPCPROGB} ${OSCFLAGS} ${OSLIBS} 2>>/dev/null
++ ER=$?
++ if [ ${ER} -eq 0 ] ; then
++ OSCFLAGS="${OSCFLAGS} -DTURN_HAS_DAEMON"
++ fi
+ }
+
+ test_sin_len() {
+@@ -272,16 +126,16 @@ test_sin_len() {
+ ${CC} -c ${OSCFLAGS} -DTURN_HAS_SIN_LEN -Isrc ${TMPCADDRPROGC} -o ${TMPCADDRPROGO} 2>>/dev/null
+ ER=$?
+ if [ ${ER} -eq 0 ] ; then
+- OSCFLAGS="${OSCFLAGS} -DTURN_HAS_SIN_LEN"
+- ${ECHO_CMD} "Sockets code is fine: sin_len field present"
++ OSCFLAGS="${OSCFLAGS} -DTURN_HAS_SIN_LEN"
++ ${ECHO_CMD} "Sockets code is fine: sin_len field present"
+ else
+- ${CC} -c ${OSCFLAGS} -Isrc ${TMPCADDRPROGC} -o ${TMPCADDRPROGO} 2>>/dev/null
+- ER=$?
+- if [ ${ER} -eq 0 ] ; then
+- ${ECHO_CMD} "Sockets code is fine: no sin_len field present"
+- else
+- ${ECHO_CMD} "WARNING: trial compilation failed: src/client/ns_turn_ioaddr.c"
+- fi
++ ${CC} -c ${OSCFLAGS} -Isrc ${TMPCADDRPROGC} -o ${TMPCADDRPROGO} 2>>/dev/null
++ ER=$?
++ if [ ${ER} -eq 0 ] ; then
++ ${ECHO_CMD} "Sockets code is fine: no sin_len field present"
++ else
++ ${ECHO_CMD} "WARNING: trial compilation failed: src/client/ns_turn_ioaddr.c"
++ fi
+ fi
+ }
+
+@@ -296,15 +150,15 @@ cleanup
+ #########################
+
+ if [ -z "${ECHO_CMD}" ] ; then
+- ECHO_CMD=echo
++ ECHO_CMD=echo
+ fi
+
+ if [ -z "${FIND_CMD}" ] ; then
+- FIND_CMD=find
++ FIND_CMD=find
+ fi
+
+ if [ -z "${PORTNAME}" ] ; then
+- PORTNAME=turnserver
++ PORTNAME=turnserver
+ fi
+
+ #########################
+@@ -315,237 +169,229 @@ ac_prev=
+ ac_dashdash=
+ for ac_option
+ do
+- # If the previous option needs an argument, assign it.
+- if test -n "$ac_prev"; then
+- eval $ac_prev=\$ac_option
+- ac_prev=
+- continue
+- fi
+-
+- case $ac_option in
+- *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
+- *=) ac_optarg= ;;
+- *) ac_optarg=yes ;;
+- esac
+-
+- # Accept the important Cygnus configure options, so we can diagnose typos.
+-
+- case $ac_dashdash$ac_option in
+- --)
+- ac_dashdash=yes ;;
+-
+- -bindir | --bindir | --bindi | --bind | --bin | --bi)
+- ac_prev=BINDIR ;;
+- -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+- BINDIR=$ac_optarg ;;
+-
+- -localstatedir | --localstatedir | --localstatedi | --localstated | --localstate | --localstat)
+- ac_prev=LOCALSTATEDIR ;;
+- -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* | --localstate=* | --localstat=*)
+- LOCALSTATEDIR=$ac_optarg ;;
+-
+- -turndbdir | --turndbdir | --turndbdi | --turndbd | --turndb | --turnd)
+- ac_prev=TURNDBDIR ;;
+- -turndbdir=* | --turndbdir=* | --turndbdi=* | --turndbd=* | --turndb=* | --turnd=*)
+- TURNDBDIR=$ac_optarg ;;
+-
+- -datadir | --datadir | --datadi | --datad | -schemadir | --schemadir)
+- ac_prev=SCHEMADIR ;;
+- -datadir=* | --datadir=* | --datadi=* | --datad=* | -schemadir=* | --schemadir=*)
+- SCHEMADIR=$ac_optarg ;;
+-
+- -docdir | --docdir | --docdi | --doc | --do | -docsdir | --docsdir | --docsdi | --docs)
+- ac_prev=DOCDIR ;;
+- -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=* | -docsdir=* | --docsdir=* | --docsdi=* | --docs=*)
+- DOCSDIR=$ac_optarg ;;
+-
+- -examplesdir | --examplesdir | -examples | --examples)
+- ac_prev=EXAMPLESDIR ;;
+- -examplesdir=* | --examplesdir=* | -examples=* | --examples=*)
+- EXAMPLESDIR=$ac_optarg ;;
+-
+- -includedir | --includedir | --includedi | --included | --include \
+- | --includ | --inclu | --incl | --inc)
+- ac_prev=INCLUDEDIR ;;
+- -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+- | --includ=* | --inclu=* | --incl=* | --inc=*)
+- INCLUDEDIR=$ac_optarg ;;
+-
+- -turnincludedir | --turnincludedir)
+- ac_prev=TURNINCLUDEDIR ;;
+- -turnincludedir=* | --turnincludedir=*)
+- TURNINCLUDEDIR=$ac_optarg ;;
+-
+- -libdir | --libdir | --libdi | --libd)
+- ac_prev=LIBDIR ;;
+- -libdir=* | --libdir=* | --libdi=* | --libd=*)
+- LIBDIR=$ac_optarg ;;
+-
+- -mandir | --mandir | --mandi | --mand | --man | --ma | --m | -manprefix | --manprefix)
+- ac_prev=MAXPREFIX ;;
+- -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=* | -manprefix=* | --manprefix=*)
+- MANPREFIX=$ac_optarg ;;
+-
+- -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+- ac_prev=PREFIX ;;
+- -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+- PREFIX=$ac_optarg ;;
+-
+- -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+- | --syscon | --sysco | --sysc | --sys | --sy | -confdir | --confdir)
+- ac_prev=CONFDIR ;;
+- -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+- | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=* | -confdir=* | --confdir=*)
+- CONFDIR=$ac_optarg ;;
+-
+- -disable-rpath | --disable-rpath)
+- TURN_DISABLE_RPATH=1 ;;
+-
+- esac
+-
++ # If the previous option needs an argument, assign it.
++ if test -n "$ac_prev"; then
++ eval $ac_prev=\$ac_option
++ ac_prev=
++ continue
++ fi
++
++ case $ac_option in
++ *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
++ *=) ac_optarg= ;;
++ *) ac_optarg=yes ;;
++ esac
++
++ # Accept the important Cygnus configure options, so we can diagnose typos.
++
++ case $ac_dashdash$ac_option in
++ --)
++ ac_dashdash=yes ;;
++
++ -bindir | --bindir | --bindi | --bind | --bin | --bi)
++ ac_prev=BINDIR ;;
++ -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
++ BINDIR=$ac_optarg ;;
++
++ -localstatedir | --localstatedir | --localstatedi | --localstated | --localstate | --localstat)
++ ac_prev=LOCALSTATEDIR ;;
++ -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* | --localstate=* | --localstat=*)
++ LOCALSTATEDIR=$ac_optarg ;;
++
++ -turndbdir | --turndbdir | --turndbdi | --turndbd | --turndb | --turnd)
++ ac_prev=TURNDBDIR ;;
++ -turndbdir=* | --turndbdir=* | --turndbdi=* | --turndbd=* | --turndb=* | --turnd=*)
++ TURNDBDIR=$ac_optarg ;;
++
++ -datadir | --datadir | --datadi | --datad | -schemadir | --schemadir)
++ ac_prev=SCHEMADIR ;;
++ -datadir=* | --datadir=* | --datadi=* | --datad=* | -schemadir=* | --schemadir=*)
++ SCHEMADIR=$ac_optarg ;;
++
++ -docdir | --docdir | --docdi | --doc | --do | -docsdir | --docsdir | --docsdi | --docs)
++ ac_prev=DOCDIR ;;
++ -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=* | -docsdir=* | --docsdir=* | --docsdi=* | --docs=*)
++ DOCSDIR=$ac_optarg ;;
++
++ -examplesdir | --examplesdir | -examples | --examples)
++ ac_prev=EXAMPLESDIR ;;
++ -examplesdir=* | --examplesdir=* | -examples=* | --examples=*)
++ EXAMPLESDIR=$ac_optarg ;;
++
++ -includedir | --includedir | --includedi | --included | --include \
++ | --includ | --inclu | --incl | --inc)
++ ac_prev=INCLUDEDIR ;;
++ -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
++ | --includ=* | --inclu=* | --incl=* | --inc=*)
++ INCLUDEDIR=$ac_optarg ;;
++
++ -turnincludedir | --turnincludedir)
++ ac_prev=TURNINCLUDEDIR ;;
++ -turnincludedir=* | --turnincludedir=*)
++ TURNINCLUDEDIR=$ac_optarg ;;
++
++ -libdir | --libdir | --libdi | --libd)
++ ac_prev=LIBDIR ;;
++ -libdir=* | --libdir=* | --libdi=* | --libd=*)
++ LIBDIR=$ac_optarg ;;
++
++ -mandir | --mandir | --mandi | --mand | --man | --ma | --m | -manprefix | --manprefix)
++ ac_prev=MAXPREFIX ;;
++ -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=* | -manprefix=* | --manprefix=*)
++ MANPREFIX=$ac_optarg ;;
++
++ -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
++ ac_prev=PREFIX ;;
++ -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
++ PREFIX=$ac_optarg ;;
++
++ -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
++ | --syscon | --sysco | --sysc | --sys | --sy | -confdir | --confdir)
++ ac_prev=CONFDIR ;;
++ -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
++ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=* | -confdir=* | --confdir=*)
++ CONFDIR=$ac_optarg ;;
++
++ -disable-rpath | --disable-rpath)
++ TURN_DISABLE_RPATH=1 ;;
++
++ esac
++
+ done
+
+ if test -n "$ac_prev"; then
+- ac_option=--`echo $ac_prev | sed 's/_/-/g'`
+- as_fn_error $? "missing argument to $ac_option"
++ ac_option=--`echo $ac_prev | sed 's/_/-/g'`
++ as_fn_error $? "missing argument to $ac_option"
+ fi
+
+ #############################################
+
+ if [ -z "${PREFIX}" ] ; then
+
+- if [ -z "${prefix}" ] ; then
+-
+- SYSTEM=`uname`
+-
+- if [ "${SYSTEM}" = "NetBSD" ] ; then
+- # A little tough guy
+- PREFIX=/usr/pkg
+- elif [ "${SYSTEM}" = "SunOS" ] ; then
+- # A fat guy
+- PREFIX=/usr
+- else
+- # An ordinary person
+- PREFIX=/usr/local
+- fi
+- else
+- PREFIX=${prefix}
+- fi
++ if [ -z "${prefix}" ] ; then
++
++ SYSTEM=`uname`
++
++ if [ "${SYSTEM}" = "NetBSD" ] ; then
++ # A little tough guy
++ PREFIX=/usr/pkg
++ elif [ "${SYSTEM}" = "SunOS" ] ; then
++ # A fat guy
++ PREFIX=/usr
++ else
++ # An ordinary person
++ PREFIX=/usr/local
++ fi
++ else
++ PREFIX=${prefix}
++ fi
+ fi
+
+ if [ -z "${BINDIR}" ] ; then
+ if [ -z "${bindir}" ] ; then
+- BINDIR=${PREFIX}/bin
++ BINDIR=${PREFIX}/bin
+ else
+- BINDIR=${bindir}
++ BINDIR=${bindir}
+ fi
+ fi
+
+ if [ -z "${LOCALSTATEDIR}" ] ; then
+ if [ -z "${localstatedir}" ] ; then
+-
+- if [ "${PREFIX}" = "/usr" ] ; then
+- LOCALSTATEDIR=/var
+- else
+- LOCALSTATEDIR=${PREFIX}/var
+- fi
+-
++
++ if [ "${PREFIX}" = "/usr" ] ; then
++ LOCALSTATEDIR=/var
++ else
++ LOCALSTATEDIR=${PREFIX}/var
++ fi
++
+ else
+- LOCALSTATEDIR=${localstatedir}
++ LOCALSTATEDIR=${localstatedir}
+ fi
+ fi
+
+ if [ -z "${CONFDIR}" ] ; then
+ if [ -z "${confdir}" ] ; then
+- CONFDIR=${PREFIX}/etc
++ CONFDIR=${PREFIX}/etc
+ else
+- CONFDIR=${confdir}
++ CONFDIR=${confdir}
+ fi
+ fi
+
+ if [ -z "${MANPREFIX}" ] ; then
+ if [ -z "${manprefix}" ] ; then
+- MANPREFIX=${PREFIX}
++ MANPREFIX=${PREFIX}
+ else
+- MANPREFIX=${manprefix}
++ MANPREFIX=${manprefix}
+ fi
+ fi
+
+ if [ -z "${EXAMPLESDIR}" ] ; then
+ if [ -z "${examplesdir}" ] ; then
+- EXAMPLESDIR=${PREFIX}/share/examples/${PORTNAME}
++ EXAMPLESDIR=${PREFIX}/share/examples/${PORTNAME}
+ else
+- EXAMPLESDIR=${examplesdir}
++ EXAMPLESDIR=${examplesdir}
+ fi
+ fi
+
+ if [ -z "${DOCSDIR}" ] ; then
+ if [ -z "${docsdir}" ] ; then
+- DOCSDIR=${PREFIX}/share/doc/${PORTNAME}
++ DOCSDIR=${PREFIX}/share/doc/${PORTNAME}
+ else
+- DOCSDIR=${docsdir}
++ DOCSDIR=${docsdir}
+ fi
+ fi
+
+ if [ -z "${LIBDIR}" ] ; then
+ if [ -z "${libdir}" ] ; then
+- LIBDIR=${PREFIX}/lib
++ LIBDIR=${PREFIX}/lib
+ else
+- LIBDIR=${libdir}
++ LIBDIR=${libdir}
+ fi
+ fi
+
+ if [ -z "${SCHEMADIR}" ] ; then
+ if [ -z "${schemadir}" ] ; then
+- SCHEMADIR=${PREFIX}/share/${PORTNAME}
++ SCHEMADIR=${PREFIX}/share/${PORTNAME}
+ else
+- SCHEMADIR=${schemadir}
++ SCHEMADIR=${schemadir}
+ fi
+ fi
+
+ if [ -z "${INCLUDEDIR}" ] ; then
+ if [ -z "${includedir}" ] ; then
+- INCLUDEDIR=${PREFIX}/include
++ INCLUDEDIR=${PREFIX}/include
+ else
+- INCLUDEDIR=${includedir}
++ INCLUDEDIR=${includedir}
+ fi
+ fi
+
+ if [ -z "${TURNINCLUDEDIR}" ] ; then
+ if [ -z "${turnincludedir}" ] ; then
+- TURNINCLUDEDIR=${INCLUDEDIR}/turn
++ TURNINCLUDEDIR=${INCLUDEDIR}/turn
+ else
+- TURNINCLUDEDIR=${turnincludedir}
++ TURNINCLUDEDIR=${turnincludedir}
+ fi
+ fi
+
+ ###############################################
+
+ if [ -z "${ARCHIVERCMD}" ] ; then
+- ARCHIVERCMD="ar -r"
++ ARCHIVERCMD="ar -r"
+ fi
+
+ if [ -z "${MORECMD}" ]; then
+- MORECMD="cat"
++ MORECMD="cat"
+ fi
+
+-OSCFLAGS="-I${INCLUDEDIR} -I${PREFIX}/include/ -I/usr/local/include ${CFLAGS}"
++OSCFLAGS="${CFLAGS}"
+ OSLIBS="${LDFLAGS}"
+-for ilib in ${PREFIX}/lib/event2/ ${PREFIX}/lib/ /usr/local/lib/event2/ /usr/local/lib/ ${PREFIX}/lib64/event2/ ${PREFIX}/lib64/ /usr/local/lib64/event2/ /usr/local/lib64/
+-do
+- if [ -d ${ilib} ] ; then
+- OSLIBS="${OSLIBS} -L${ilib}"
+- TURN_RPATH="${TURN_RPATH} -Wl,-rpath,${ilib}"
+- fi
+-done
+
+-SYSTEM=`uname`
+-if [ "${SYSTEM}" = "NetBSD" ] ; then
+- OSCFLAGS="${OSCFLAGS} -I/usr/pkg/include"
+- OSLIBS="-L/usr/pkg/lib ${OSLIBS}"
+- if ! [ -z "${TURN_ACCEPT_RPATH}" ] ; then
+- TURN_RPATH="${TURN_RPATH} -Wl,-rpath,/usr/pkg/lib"
+- fi
++if [ `uname` = "NetBSD" ] ; then
++ OSCFLAGS="${OSCFLAGS} -I/usr/pkg/include"
++ OSLIBS="-L/usr/pkg/lib ${OSLIBS}"
++ if ! [ -z "${TURN_ACCEPT_RPATH}" ] ; then
++ TURN_RPATH="${TURN_RPATH} -Wl,-rpath,/usr/pkg/lib"
++ fi
+ fi
+
+ ###########################
+@@ -555,41 +401,41 @@ fi
+ type ginstall 2>>/dev/null
+ ER=$?
+ if [ ${ER} -eq 0 ] ; then
+- INSTALL_PROGRAM="ginstall"
+- INSTALL_MAN="ginstall"
+- INSTALL_SCRIPT="ginstall"
+- INSTALL_SHARED_LIB="ginstall"
+- INSTALL_STATIC_LIB="ginstall"
+- INSTALL_DATA="ginstall"
+- MKDIR="ginstall -d"
++ INSTALL_PROGRAM="ginstall"
++ INSTALL_MAN="ginstall"
++ INSTALL_SCRIPT="ginstall"
++ INSTALL_SHARED_LIB="ginstall"
++ INSTALL_STATIC_LIB="ginstall"
++ INSTALL_DATA="ginstall"
++ MKDIR="ginstall -d"
+ else
+- type install 2>>/dev/null
+- ER=$?
+- if [ ${ER} -eq 0 ] ; then
+- INSTALL_PROGRAM="install"
+- INSTALL_MAN="install"
+- INSTALL_SCRIPT="install"
+- INSTALL_SHARED_LIB="install"
+- INSTALL_STATIC_LIB="install"
+- INSTALL_DATA="install"
+- MKDIR="install -d"
+- else
+- INSTALL_PROGRAM="cp -pf"
+- INSTALL_MAN="cp -pf"
+- INSTALL_SCRIPT="cp -pf"
+- INSTALL_SHARED_LIB="cp -pf"
+- INSTALL_STATIC_LIB="cp -pf"
+- INSTALL_DATA="cp -pf"
+- MKDIR="mkdir -p"
+- fi
++ type install 2>>/dev/null
++ ER=$?
++ if [ ${ER} -eq 0 ] ; then
++ INSTALL_PROGRAM="install"
++ INSTALL_MAN="install"
++ INSTALL_SCRIPT="install"
++ INSTALL_SHARED_LIB="install"
++ INSTALL_STATIC_LIB="install"
++ INSTALL_DATA="install"
++ MKDIR="install -d"
++ else
++ INSTALL_PROGRAM="cp -pf"
++ INSTALL_MAN="cp -pf"
++ INSTALL_SCRIPT="cp -pf"
++ INSTALL_SHARED_LIB="cp -pf"
++ INSTALL_STATIC_LIB="cp -pf"
++ INSTALL_DATA="cp -pf"
++ MKDIR="mkdir -p"
++ fi
+ fi
+
+ type pkill 2>>/dev/null
+ ER=$?
+ if [ ${ER} -eq 0 ] ; then
+- PKILL_PROGRAM="pkill"
++ PKILL_PROGRAM="pkill"
+ else
+- PKILL_PROGRAM="${ECHO_CMD}"
++ PKILL_PROGRAM="${ECHO_CMD}"
+ fi
+
+ INSTALL_DIR="cp -rpf"
+@@ -604,9 +450,9 @@ else
+ type sqlite 2>>/dev/null
+ ER=$?
+ if [ ${ER} -eq 0 ] ; then
+- SQLITE_CMD="sqlite"
++ SQLITE_CMD="sqlite"
+ else
+- SQLITE_CMD=${ECHO_CMD}
++ SQLITE_CMD=${ECHO_CMD}
+ fi
+ fi
+
+@@ -614,10 +460,8 @@ fi
+ # Adjustments for Solaris
+ #############################
+
+-SYSTEM=`uname`
+-
+-if [ "${SYSTEM}" = "SunOS" ] ; then
+-# Solaris ? is this you ?!
++if [ `uname` = "SunOS" ] ; then
++ # Solaris ? is this you ?!
+ OSCFLAGS="${OSCFLAGS} -D__EXTENSIONS__ -D_XOPEN_SOURCE=500 -DTURN_NO_GETDOMAINNAME"
+ OSLIBS="${OSLIBS} -lnsl"
+ TURN_NO_SCTP=1
+@@ -630,9 +474,9 @@ fi
+ TMPDIR="."
+
+ if [ -d /var/tmp ] ; then
+- TMPDIR="/var/tmp"
++ TMPDIR="/var/tmp"
+ elif [ -d /tmp ] ; then
+- TMPDIR=/tmp
++ TMPDIR=/tmp
+ fi
+
+ ${ECHO_CMD} Use TMP dir ${TMPDIR}
+@@ -693,83 +537,6 @@ int main(int argc, char** argv) {
+ }
+ !
+
+-E_TMPCPROG=__test__ccomp__libevent2__$$
+-E_TMPCPROGC=${TMPDIR}/${E_TMPCPROG}.c
+-E_TMPCPROGO=${TMPDIR}/${E_TMPCPROG}.o
+-
+-cat > ${E_TMPCPROGC} <<!
+-#include <stdlib.h>
+-#include <event2/event.h>
+-int main(int argc, char** argv) {
+- return (int)(argv[argc][0]);
+-}
+-!
+-
+-SQL_TMPCPROG=__test__ccomp__sqlite__$$
+-SQL_TMPCPROGC=${TMPDIR}/${SQL_TMPCPROG}.c
+-SQL_TMPCPROGO=${TMPDIR}/${SQL_TMPCPROG}.o
+-
+-cat > ${SQL_TMPCPROGC} <<!
+-#include <stdlib.h>
+-#include <sqlite3.h>
+-int main(int argc, char** argv) {
+- return (int)(argv[argc][0]);
+-}
+-!
+-
+-HR_TMPCPROG=__test__ccomp__hiredis__$$
+-HR_TMPCPROGC=${TMPDIR}/${HR_TMPCPROG}.c
+-HR_TMPCPROGB=${TMPDIR}/${HR_TMPCPROG}
+-
+-cat > ${HR_TMPCPROGC} <<!
+-#include <stdlib.h>
+-#include <hiredis/hiredis.h>
+-#include <hiredis/async.h>
+-int main(int argc, char** argv) {
+- redisAsyncHandleRead(NULL);
+- return (int)(argv[argc][0]);
+-}
+-!
+-
+-PQ_TMPCPROG=__test__ccomp__libpq__$$
+-PQ_TMPCPROGC=${TMPDIR}/${PQ_TMPCPROG}.c
+-PQ_TMPCPROGB=${TMPDIR}/${PQ_TMPCPROG}
+-
+-cat > ${PQ_TMPCPROGC} <<!
+-#include <stdlib.h>
+-#include <libpq-fe.h>
+-int main(int argc, char** argv) {
+- return (argc+(PQprotocolVersion(NULL))+(int)(argv[0][0]));
+-}
+-!
+-
+-MYSQL_TMPCPROG=__test__ccomp__libmysql__$$
+-MYSQL_TMPCPROGC=${TMPDIR}/${MYSQL_TMPCPROG}.c
+-MYSQL_TMPCPROGB=${TMPDIR}/${MYSQL_TMPCPROG}
+-
+-cat > ${MYSQL_TMPCPROGC} <<!
+-#include <stdlib.h>
+-#include <mysql.h>
+-int main(int argc, char** argv) {
+- return (argc+
+- (int)(mysql_real_connect(NULL, NULL, NULL, NULL, NULL, 0, NULL, 0)!=0)+
+- (int)(argv[0][0]));
+-}
+-!
+-
+-MONGO_TMPCPROG=__test__ccomp__libmongoc__$$
+-MONGO_TMPCPROGC=${TMPDIR}/${MONGO_TMPCPROG}.c
+-MONGO_TMPCPROGB=${TMPDIR}/${MONGO_TMPCPROG}
+-
+-cat > ${MONGO_TMPCPROGC} <<!
+-#include <mongoc.h>
+-int main(int argc, char** argv) {
+- return (argc+
+- (int)(mongoc_client_new("mongodb://localhost:27017")!=0)+
+- (int)(argv[0][0]));
+-}
+-!
+-
+ ##########################
+ # What is our compiler ?
+ ##########################
+@@ -777,20 +544,30 @@ int main(int argc, char** argv) {
+ if [ -z "${CC}" ] ; then
+ CC=cc
+ ${CC} ${TMPCPROGC} ${OSCFLAGS} -o ${TMPCPROGB} 2>>/dev/null
+- ER=$?
+- if ! [ ${ER} -eq 0 ] ; then
+- CC=gcc
+- ${CC} ${TMPCPROGC} ${OSCFLAGS} -o ${TMPCPROGB} 2>>/dev/null
+- ER=$?
+- if ! [ ${ER} -eq 0 ] ; then
+- CC=clang
+- ${CC} ${TMPCPROGC} ${OSCFLAGS} -o ${TMPCPROGB} 2>>/dev/null
+- ER=$?
+- if ! [ ${ER} -eq 0 ] ; then
+- CC=unknown
+- fi
+- fi
+- fi
++ ER=$?
++ if ! [ ${ER} -eq 0 ] ; then
++ CC=gcc
++ ${CC} ${TMPCPROGC} ${OSCFLAGS} -o ${TMPCPROGB} 2>>/dev/null
++ ER=$?
++ if ! [ ${ER} -eq 0 ] ; then
++ CC=clang
++ ${CC} ${TMPCPROGC} ${OSCFLAGS} -o ${TMPCPROGB} 2>>/dev/null
++ ER=$?
++ if ! [ ${ER} -eq 0 ] ; then
++ ${ECHO_CMD} "ERROR: Failed to a find working C compiler"
++ cleanup
++ exit
++ fi
++ fi
++ fi
++else
++ ${CC} ${TMPCPROGC} ${OSCFLAGS} -o ${TMPCPROGB} 2>>/dev/null
++ ER=$?
++ if ! [ ${ER} -eq 0 ] ; then
++ ${ECHO_CMD} "ERROR: cannot use compiler ${CC} properly"
++ cleanup
++ exit
++ fi
+ fi
+
+ ${ECHO_CMD} "Compiler: ${CC}"
+@@ -799,18 +576,37 @@ if [ -z "${TURN_ACCEPT_RPATH}" ] ; then
+ ${CC} ${TMPCPROGC} ${OSCFLAGS} -o ${TMPCPROGB} -Wl,-rpath,/usr/lib 2>>/dev/null
+ ER=$?
+ if [ ${ER} -eq 0 ] ; then
+- TURN_ACCEPT_RPATH=1
++ TURN_ACCEPT_RPATH=1
+ fi
+ fi
+
+-${CC} ${TMPCPROGC} ${OSCFLAGS} -o ${TMPCPROGB} 2>>/dev/null
+-ER=$?
+-if ! [ ${ER} -eq 0 ] ; then
+- ${ECHO_CMD} "ERROR: cannot use compiler ${CC} properly"
+- cleanup
+- exit
++##########################
++# Which pkg-config?
++##########################
++
++if [ -z "$PKGCONFIG" ] ; then
++ for PKGCONFIG in pkgconf pkg-config ; do
++ if type "$PKGCONFIG" 2>/dev/null ; then
++ break
++ fi
++ PKGCONFIG=
++ done
++
++ if [ -z "$PKGCONFIG" ] ; then
++ ${ECHO_CMD} "ERROR: pkg-config not found"
++ cleanup
++ exit
++ fi
++else
++ if ! type "$PKGCONFIG" 2>/dev/null ; then
++ ${ECHO_CMD} "ERROR: cannot use $PKGCONFIG"
++ cleanup
++ exit
++ fi
+ fi
+
++${ECHO_CMD} "pkg-config: $PKGCONFIG"
++
+ ###########################
+ # Check if we can use GNU
+ # or Clang compiler flags
+@@ -827,26 +623,26 @@ if ! [ ${ER} -eq 0 ] ; then
+ ${CC} -Wall ${TMPCPROGC} ${OSCFLAGS} -o ${TMPCPROGB} 2>>/dev/null
+ ER=$?
+ if ! [ ${ER} -eq 0 ] ; then
+- ${ECHO_CMD} "Not an ordinary GNU or Clang compiler"
++ ${ECHO_CMD} "Not an ordinary GNU or Clang compiler"
+ else
+- ${ECHO_CMD} "g++ or something..."
+- GNUOSCFLAGS="-g -Wall -Wno-deprecated-declarations -Wextra -Wformat-security -Wpointer-arith -Wcast-qual"
+- ${CC} -Werror ${GNUOSCFLAGS} ${TMPCPROGC} ${OSCFLAGS} -o ${TMPCPROGB} 2>>/dev/null
+- ER=$?
+- if ! [ ${ER} -eq 0 ] ; then
+- ${ECHO_CMD} "Not an ordinary g++ compiler"
+- GNUOSCFLAGS="-x c++ -g -Wall -Wno-deprecated-declarations -Wextra -Wformat-security -Wpointer-arith -Wcast-qual"
+- ${CC} -Werror ${GNUOSCFLAGS} ${TMPCPROGC} ${OSCFLAGS} -o ${TMPCPROGB} 2>>/dev/null
+- ER=$?
+- if ! [ ${ER} -eq 0 ] ; then
+- ${ECHO_CMD} "Not an ordinary c++ compiler"
+- else
+- ${ECHO_CMD} "Clang++ compiler ?"
+- OSCFLAGS="${GNUOSCFLAGS} ${OSCFLAGS}"
+- fi
+- else
+- OSCFLAGS="${GNUOSCFLAGS} ${OSCFLAGS}"
+- fi
++ ${ECHO_CMD} "g++ or something..."
++ GNUOSCFLAGS="-g -Wall -Wno-deprecated-declarations -Wextra -Wformat-security -Wpointer-arith -Wcast-qual"
++ ${CC} -Werror ${GNUOSCFLAGS} ${TMPCPROGC} ${OSCFLAGS} -o ${TMPCPROGB} 2>>/dev/null
++ ER=$?
++ if ! [ ${ER} -eq 0 ] ; then
++ ${ECHO_CMD} "Not an ordinary g++ compiler"
++ GNUOSCFLAGS="-x c++ -g -Wall -Wno-deprecated-declarations -Wextra -Wformat-security -Wpointer-arith -Wcast-qual"
++ ${CC} -Werror ${GNUOSCFLAGS} ${TMPCPROGC} ${OSCFLAGS} -o ${TMPCPROGB} 2>>/dev/null
++ ER=$?
++ if ! [ ${ER} -eq 0 ] ; then
++ ${ECHO_CMD} "Not an ordinary c++ compiler"
++ else
++ ${ECHO_CMD} "Clang++ compiler ?"
++ OSCFLAGS="${GNUOSCFLAGS} ${OSCFLAGS}"
++ fi
++ else
++ OSCFLAGS="${GNUOSCFLAGS} ${OSCFLAGS}"
++ fi
+ fi
+ else
+ OSCFLAGS="${GNUOSCFLAGS} ${OSCFLAGS}"
+@@ -854,14 +650,12 @@ fi
+
+ ###########################
+ # Test some general-purpose
+-# libraries
++# libraries
+ ###########################
+
+ testlib socket
+ testlib rt
+-testlib wldap32
+-ER=$?
+-if ! [ ${ER} -eq 0 ] ; then
++if testlib wldap32; then
+ echo "CYGWIN ?"
+ fi
+ testlib wldap64
+@@ -879,25 +673,24 @@ test_sin_len
+ # Can we use multi-threading ?
+ ###########################
+
+-pthread_testlib
+-ER=$?
+-if [ ${ER} -eq 0 ] ; then
+- ${ECHO_CMD} "ERROR: Cannot find pthread library functions."
+- exit
++if ! pthread_testlib ; then
++ ${ECHO_CMD} "ERROR: Cannot find pthread library functions."
++ cleanup
++ exit
+ fi
+
+-if [ -z ${TURN_NO_THREAD_BARRIERS} ] ; then
+- pthread_testbarriers
+-else
+- TURN_NO_THREAD_BARRIERS="-DTURN_NO_THREAD_BARRIERS"
++if [ -z ${TURN_NO_THREAD_BARRIERS} ] ; then
++ pthread_testbarriers
++else
++ TURN_NO_THREAD_BARRIERS="-DTURN_NO_THREAD_BARRIERS"
+ fi
+
+-if [ -z ${TURN_IP_RECVERR} ] ; then
+- ${ECHO_CMD} "Ignore IP_RECVERR"
+-else
+- ${ECHO_CMD} "Use IP_RECVERR"
+- TURN_IP_RECVERR="-DTURN_IP_RECVERR"
+- OSCFLAGS="${OSCFLAGS} ${TURN_IP_RECVERR}"
++if [ -z ${TURN_IP_RECVERR} ] ; then
++ ${ECHO_CMD} "Ignore IP_RECVERR"
++else
++ ${ECHO_CMD} "Use IP_RECVERR"
++ TURN_IP_RECVERR="-DTURN_IP_RECVERR"
++ OSCFLAGS="${OSCFLAGS} ${TURN_IP_RECVERR}"
+ fi
+
+ ###########################
+@@ -910,10 +703,8 @@ testdaemon
+ # Test OpenSSL installation
+ ###########################
+
+-testlib crypto
+-ER=$?
+-if ! [ ${ER} -eq 0 ] ; then
+- ${ECHO_CMD} "Crypto SSL lib found."
++if testpkg_common libcrypto; then
++ ${ECHO_CMD} "OpenSSL Crypto lib found."
+ else
+ ${ECHO_CMD} "ERROR: OpenSSL Crypto development libraries are not installed properly in required location."
+ ${ECHO_CMD} "Abort."
+@@ -921,10 +712,8 @@ else
+ exit
+ fi
+
+-testlib ssl
+-ER=$?
+-if ! [ ${ER} -eq 0 ] ; then
+- ${ECHO_CMD} "SSL lib found."
++if testpkg_common libssl; then
++ ${ECHO_CMD} "OpenSSL SSL found."
+ else
+ ${ECHO_CMD} "ERROR: OpenSSL development libraries are not installed properly in required location."
+ ${ECHO_CMD} "Abort."
+@@ -936,88 +725,40 @@ fi
+ # Can we use GCM cipher ?
+ ###########################
+
+-if [ -z ${TURN_NO_GCM} ] ; then
+-
+-gcm_testlib
+-ER=$?
+-if [ ${ER} -eq 0 ] ; then
+- ${ECHO_CMD} "WARNING: Cannot find GCM support."
+- ${ECHO_CMD} "Turning GCM off."
+- TURN_NO_GCM="-DTURN_NO_GCM"
+-fi
+-
++if [ -z ${TURN_NO_GCM} ] ; then
++ if ! gcm_testlib ; then
++ ${ECHO_CMD} "WARNING: Cannot find GCM support."
++ ${ECHO_CMD} "Turning GCM off."
++ TURN_NO_GCM="-DTURN_NO_GCM"
++ fi
+ else
+- TURN_NO_GCM="-DTURN_NO_GCM"
++ TURN_NO_GCM="-DTURN_NO_GCM"
+ fi
+
+ ###########################
+ # Test Libevent2 setup
+ ###########################
+-testlibevent2_comp
+-ER=$?
+-if ! [ ${ER} -eq 0 ] ; then
+- ${ECHO_CMD} "Libevent2 development found."
++
++if testpkg_common libevent_core libevent_extra libevent_pthreads || testpkg_common libevent libevent_pthreads; then
++ ${ECHO_CMD} "Libevent2 runtime found."
+ else
+- ${ECHO_CMD} "ERROR: Libevent2 development libraries are not installed properly in required location."
+- ${ECHO_CMD} "ERROR: may be you have just too old libevent tool - then you have to upgrade it."
++ ${ECHO_CMD} "ERROR: Libevent2 runtime libraries not found or not compiled with threads support."
+ ${ECHO_CMD} "See the INSTALL file."
+ ${ECHO_CMD} "Abort."
+ cleanup
+ exit
+ fi
+
+-testlib event_core
+-ER=$?
+-if ! [ ${ER} -eq 0 ] ; then
+- ${ECHO_CMD} "Libevent2 runtime found."
+- testlib event_extra
+- ER=$?
+- if ! [ ${ER} -eq 0 ] ; then
+- ${ECHO_CMD} "Libevent2 runtime 'extra' found."
+- else
+- ${ECHO_CMD} "ERROR: Libevent2 'extra' runtime library is not installed properly in required location."
+- ${ECHO_CMD} "See the INSTALL file."
+- ${ECHO_CMD} "Abort."
+- cleanup
+- exit
+- fi
+-else
+- testlib event
+- ER=$?
+- if ! [ ${ER} -eq 0 ] ; then
+- ${ECHO_CMD} "Libevent2 runtime found (old style)."
++if [ -z "${TURN_NO_TLS}" ] ; then
++ if testpkg_server libevent_openssl; then
++ ${ECHO_CMD} "Libevent2 OpenSSL found."
+ else
+- ${ECHO_CMD} "ERROR: Libevent2 runtime libraries are not installed properly in required location."
+- ${ECHO_CMD} "See the INSTALL file."
+- ${ECHO_CMD} "Abort."
+- cleanup
+- exit
++ ${ECHO_CMD} "ERROR: Libevent2 development libraries are not compiled with OpenSSL support."
++ ${ECHO_CMD} "TLS will be disabled."
++ TURN_NO_TLS="-DTURN_NO_TLS"
+ fi
+-fi
+-
+-if [ -z "${TURN_NO_TLS}" ] ; then
+-
+- testlib event_openssl
+- ER=$?
+- if ! [ ${ER} -eq 0 ] ; then
+- ${ECHO_CMD} "Libevent2 openssl found."
+- else
+- ${ECHO_CMD} "ERROR: Libevent2 development libraries are not compiled with OpenSSL support."
+- ${ECHO_CMD} "TLS will be disabled."
+- TURN_NO_TLS="-DTURN_NO_TLS"
+- fi
+-
+-else
+- TURN_NO_TLS="-DTURN_NO_TLS"
+-fi
+-
+-testlib event_pthreads
+-ER=$?
+-if ! [ ${ER} -eq 0 ] ; then
+- ${ECHO_CMD} "Libevent2 pthreads found."
+ else
+- ${ECHO_CMD} "ERROR: Libevent2 development libraries are not compiled with threads support."
+- exit
++ TURN_NO_TLS="-DTURN_NO_TLS"
+ fi
+
+ ###########################
+@@ -1025,41 +766,19 @@ fi
+ ###########################
+
+ if [ -z "${TURN_NO_SQLITE}" ] ; then
+-
+- testlib sqlite3
+- ER=$?
+- if ! [ ${ER} -eq 0 ] ; then
+- ${ECHO_CMD} "SQLite library found."
+- else
+- ${ECHO_CMD} "SQLite3 development library cannot be found."
+- TURN_NO_SQLITE="-DTURN_NO_SQLITE"
+- fi
+-
+- if [ -z "${TURN_NO_SQLITE}" ] ; then
+- testsqlite_comp
+- ER=$?
+- if ! [ ${ER} -eq 0 ] ; then
+- ${ECHO_CMD} "SQLite development found."
+- else
+- ${ECHO_CMD} "SQLite development libraries are not installed properly in required location."
+- TURN_NO_SQLITE="-DTURN_NO_SQLITE"
+- fi
+- fi
+-
+- if ! [ -z "${TURN_NO_SQLITE}" ] ; then
+- ${ECHO_CMD}
+- ${ECHO_CMD} "SQLite DEVELOPMENT LIBRARY (libsqlite3) AND/OR HEADER (sqlite3.h)"
+- ${ECHO_CMD} " ARE NOT INSTALLED PROPERLY ON THIS SYSTEM."
+- ${ECHO_CMD} " THAT'S OK BUT THE TURN SERVER IS BUILDING WITHOUT SQLITE SUPPORT."
+- ${ECHO_CMD}
+- fi
++ if testpkg_server sqlite3; then
++ ${ECHO_CMD} "SQLite library found."
++ else
++ ${ECHO_CMD} "SQLite3 development library cannot be found. Building without SQLite3 support."
++ TURN_NO_SQLITE="-DTURN_NO_SQLITE"
++ fi
+ else
+- TURN_NO_SQLITE="-DTURN_NO_SQLITE"
+- SQLITE_CMD=${ECHO_CMD}
++ TURN_NO_SQLITE="-DTURN_NO_SQLITE"
++ SQLITE_CMD=${ECHO_CMD}
+ fi
+
+ if [ -z "${TURNDBDIR}" ] ; then
+- TURNDBDIR=${LOCALSTATEDIR}/db
++ TURNDBDIR=${LOCALSTATEDIR}/db
+ fi
+
+ ###########################
+@@ -1067,16 +786,14 @@ fi
+ ###########################
+
+ if [ -z "${TURN_NO_PQ}" ] ; then
+-
+- testlibpq
+- ER=$?
+- if ! [ ${ER} -eq 0 ] ; then
+- ${ECHO_CMD} "PostgreSQL found."
+- else
+- TURN_NO_PQ="-DTURN_NO_PQ"
+- fi
++ if testpkg_server libpq; then
++ ${ECHO_CMD} "PostgreSQL found."
++ else
++ ${ECHO_CMD} "PostgreSQL development library cannot be found. Building without PostgreSQL support."
++ TURN_NO_PQ="-DTURN_NO_PQ"
++ fi
+ else
+- TURN_NO_PQ="-DTURN_NO_PQ"
++ TURN_NO_PQ="-DTURN_NO_PQ"
+ fi
+
+ ###########################
+@@ -1084,16 +801,14 @@ fi
+ ###########################
+
+ if [ -z "${TURN_NO_MYSQL}" ] ; then
+-
+- testlibmysql
+- ER=$?
+- if ! [ ${ER} -eq 0 ] ; then
+- ${ECHO_CMD} "MySQL found."
+- else
+- TURN_NO_MYSQL="-DTURN_NO_MYSQL"
+- fi
++ if testpkg_server mariadb || testpkg_server mysqlclient ; then
++ ${ECHO_CMD} "MySQL found."
++ else
++ ${ECHO_CMD} "MySQL development library cannot be found. Building without MySQL support."
++ TURN_NO_MYSQL="-DTURN_NO_MYSQL"
++ fi
+ else
+- TURN_NO_MYSQL="-DTURN_NO_MYSQL"
++ TURN_NO_MYSQL="-DTURN_NO_MYSQL"
+ fi
+
+ ###########################
+@@ -1101,16 +816,14 @@ fi
+ ###########################
+
+ if [ -z "${TURN_NO_MONGO}" ] ; then
+-
+- testlibmongoc
+- ER=$?
+- if ! [ ${ER} -eq 0 ] ; then
+- ${ECHO_CMD} "MongoDB found."
+- else
+- TURN_NO_MONGO="-DTURN_NO_MONGO"
+- fi
++ if testpkg_server libmongoc-1.0; then
++ ${ECHO_CMD} "MongoDB found."
++ else
++ ${ECHO_CMD} "MongoDB development library cannot be found. Building without MongoDB support."
++ TURN_NO_MONGO="-DTURN_NO_MONGO"
++ fi
+ else
+- TURN_NO_MONGO="-DTURN_NO_MONGO"
++ TURN_NO_MONGO="-DTURN_NO_MONGO"
+ fi
+
+ ###########################
+@@ -1118,19 +831,14 @@ fi
+ ###########################
+
+ if [ -z "${TURN_NO_HIREDIS}" ] ; then
+-
+- testhiredis
+-
+- ER=$?
+- if ! [ ${ER} -eq 0 ] ; then
+- ${ECHO_CMD} "Hiredis found."
+- else
+- TURN_NO_HIREDIS="-DTURN_NO_HIREDIS"
+- fi
+-
++ if testpkg_server hiredis; then
++ ${ECHO_CMD} "Hiredis found."
++ else
++ ${ECHO_CMD} "Hiredis development library cannot be found. Building without Redis support."
++ TURN_NO_HIREDIS="-DTURN_NO_HIREDIS"
++ fi
+ else
+- TURN_NO_HIREDIS="-DTURN_NO_HIREDIS"
+-
++ TURN_NO_HIREDIS="-DTURN_NO_HIREDIS"
+ fi
+
+ ###############################
+@@ -1138,22 +846,21 @@ fi
+ ###############################
+
+ if [ -z "${LDCONFIG}" ] ; then
+- ISBSD=`uname | grep -i bsd`
+- if [ -z "${ISBSD}" ] ; then
+- ISLINUX=`uname | grep -i linux`
+- if [ -z "${ISLINUX}" ] ; then
+- SYSTEM=`uname`
+- if [ "${SYSTEM}" = "SunOS" ] ; then
+- LDCONFIG="crle -u -l"
+- else
+- LDCONFIG=${ECHO_CMD}
+- fi
+- else
+- LDCONFIG="ldconfig -n"
+- fi
+- else
+- LDCONFIG="ldconfig -m"
+- fi
++ ISBSD=`uname | grep -i bsd`
++ if [ -z "${ISBSD}" ] ; then
++ ISLINUX=`uname | grep -i linux`
++ if [ -z "${ISLINUX}" ] ; then
++ if [ `uname` = "SunOS" ] ; then
++ LDCONFIG="crle -u -l"
++ else
++ LDCONFIG=${ECHO_CMD}
++ fi
++ else
++ LDCONFIG="ldconfig -n"
++ fi
++ else
++ LDCONFIG="ldconfig -m"
++ fi
+ fi
+
+ ###############################
+@@ -1162,11 +869,11 @@ fi
+
+ if [ -z "${TURN_NO_SCTP}" ] ; then
+ if [ -z "${TURN_SCTP_INCLUDE}" ] ; then
+- if [ -f /usr/include/netinet/sctp.h ] ; then
+- TURN_SCTP_INCLUDE="-DTURN_SCTP_INCLUDE=\"</usr/include/netinet/sctp.h>\""
+- fi
++ if [ -f /usr/include/netinet/sctp.h ] ; then
++ TURN_SCTP_INCLUDE="-DTURN_SCTP_INCLUDE=\"</usr/include/netinet/sctp.h>\""
++ fi
+ else
+- TURN_SCTP_INCLUDE="-DTURN_SCTP_INCLUDE=\"\\\"${TURN_SCTP_INCLUDE}\\\"\""
++ TURN_SCTP_INCLUDE="-DTURN_SCTP_INCLUDE=\"\\\"${TURN_SCTP_INCLUDE}\\\"\""
+ fi
+ else
+ TURN_NO_SCTP="-DTURN_NO_SCTP"
+@@ -1179,10 +886,10 @@ fi
+ OSCFLAGS="${OSCFLAGS} ${TURN_NO_SCTP} ${TURN_SCTP_INCLUDE} ${TURN_NO_THREAD_BARRIERS} ${TURN_NO_DTLS} ${TURN_NO_GCM} ${TURN_NO_TLS} -DINSTALL_PREFIX=${PREFIX} -DTURNDB=${TURNDBDIR}/turndb"
+
+ if ! [ -z "${TURN_ACCEPT_RPATH}" ] ; then
+- if [ -z "${TURN_DISABLE_RPATH}" ] ; then
+- TURN_RPATH="${TURN_RPATH} -Wl,-rpath,/usr/local/lib"
+- OSLIBS="${OSLIBS} ${TURN_RPATH}"
+- fi
++ if [ -z "${TURN_DISABLE_RPATH}" ] ; then
++ TURN_RPATH="${TURN_RPATH} -Wl,-rpath,/usr/local/lib"
++ OSLIBS="${OSLIBS} ${TURN_RPATH}"
++ fi
+ fi
+
+ ${ECHO_CMD} PREFIX="${PREFIX}" LOCALSTATEDIR="${LOCALSTATEDIR}" OSLIBS="${OSLIBS}" DBLIBS="${DBLIBS}" OSCFLAGS="${OSCFLAGS}" DBCFLAGS="${DBCFLAGS}" $@
diff --git a/coturn.spec b/coturn.spec
new file mode 100644
index 0000000..f4b296b
--- /dev/null
+++ b/coturn.spec
@@ -0,0 +1,159 @@
+%bcond_without sqlite
+%bcond_with postgresql
+%bcond_with mysql
+%bcond_with mongodb
+%bcond_with redis
+
+Name: coturn
+Version: 4.5.0.8
+Release: 1%{?dist}
+Summary: TURN server
+
+License: BSD
+URL: https://github.com/coturn/coturn
+Source0: https://github.com/coturn/coturn/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz
+Source10: turnserver.sysconfig
+Source11: turnserver.service
+Source12: turnserver-tmpfiles.conf
+Patch0: 0000-pkg-config.patch
+
+BuildRequires: gcc
+BuildRequires: libevent-devel >= 2.0
+BuildRequires: openssl-devel
+BuildRequires: systemd-devel
+%if %{with sqlite}
+BuildRequires: sqlite-devel
+%endif
+%if %{with postgresql}
+BuildRequires: postgresql-devel
+%endif
+%if %{with mysql}
+BuildRequires: mariadb-devel
+%endif
+%if %{with mongodb}
+BuildRequires: mongo-c-driver-devel
+%endif
+%if %{with redis}
+BuildRequires: hiredis-devel
+%endif
+
+%description
+The TURN Server is a VoIP media traffic NAT traversal server and gateway. It can be used as a general-purpose network traffic TURN server and gateway, too.
+
+%package static
+Summary: ...
+%description static
+...
+
+%package utils
+Summary: ...
+%description utils
+...
+
+%package server
+Requires(pre): shadow-utils
+Summary: ...
+%description server
+...
+
+%package examples
+Summary: ...
+%description examples
+...
+
+%prep
+%setup -q
+%patch0 -p1
+
+%build
+CFLAGS="${CFLAGS:-%optflags}" ; export CFLAGS ; \
+CXXFLAGS="${CXXFLAGS:-%optflags}" ; export CXXFLAGS ; \
+FFLAGS="${FFLAGS:-%optflags}" ; export FFLAGS ; \
+TURN_NO_SQLITE=%{!?with_sqlite:1} \
+TURN_NO_PQ=%{!?with_postgresql:1} \
+TURN_NO_MYSQL=%{!?with_mysql:1} \
+TURN_NO_MONGO=%{!?with_mongodb:1} \
+TURN_NO_HIREDIS=%{!?with_redis:1} \
+./configure \
+ --prefix=%{_prefix} \
+ --bindir=%{_bindir} \
+ --sysconfdir=%{_sysconfdir} \
+ --docdir=%{_docdir}/turnserver \
+ --datadir=%{_datadir}/turnserver \
+ --examplesdir=%{_docdir}/turnserver/examples \
+ --includedir=%{_includedir} \
+ --libdir=%{_libdir} \
+ --libexecdir=%{_libexecdir} \
+ --localstatedir=%{_localstatedir} \
+ --mandir=%{_datadir} \
+ --turndbdir=%{_localstatedir}/lib/turnserver \
+ --disable-rpath
+
+make %{?_smp_mflags}
+
+
+%install
+%make_install
+rm %{buildroot}%{_docdir}/turnserver/{schema.mongo.sh,schema.sql,schema.stats.redis,schema.userdb.redis}
+mv %{buildroot}%{_sysconfdir}/turnserver.conf{.default,}
+diff -q %{buildroot}%{_bindir}/{turnserver,turnadmin}
+ln -f %{buildroot}%{_bindir}/{turnserver,turnadmin}
+%if %{with sqlite}
+rm %{buildroot}%{_localstatedir}/lib/turnserver/turndb
+%endif
+
+install -Dm0644 %SOURCE10 %{buildroot}%{_sysconfdir}/sysconfig/turnserver
+install -Dm0644 %SOURCE11 %{buildroot}%{_unitdir}/turnserver.service
+install -Dm0644 %SOURCE12 %{buildroot}%{_tmpfilesdir}/turnserver.conf
+
+chmod a-x %{buildroot}%{_mandir}/*/*
+chmod a-x %{buildroot}%{_libdir}/*.a
+
+%pre server
+getent group turnserver >/dev/null 2>&1 || groupadd -r turnserver 2>&1 || :
+getent passwd turnserver >/dev/null 2>&1 || useradd -r -l -g turnserver -G turnserver -d %{_localstatedir}/lib/turnserver -s /sbin/nologin -c "coturn TURN server" turnserver >/dev/null 2>&1 || :
+
+%post server
+systemd-tmpfiles --create >/dev/null 2>&1 || :
+%systemd_post turnserver.service
+
+%preun server
+%systemd_preun turnserver.service
+
+%postun server
+%systemd_postun turnserver.service
+
+%files static
+%{_includedir}/turn
+%{_libdir}/libturnclient.a
+
+%files utils
+%{_bindir}/turnutils_natdiscovery
+%{_bindir}/turnutils_oauth
+%{_bindir}/turnutils_peer
+%{_bindir}/turnutils_stunclient
+%{_bindir}/turnutils_uclient
+%{_mandir}/man1/turnutils.1.gz
+%{_mandir}/man1/turnutils_natdiscovery.1.gz
+%{_mandir}/man1/turnutils_oauth.1.gz
+%{_mandir}/man1/turnutils_peer.1.gz
+%{_mandir}/man1/turnutils_stunclient.1.gz
+%{_mandir}/man1/turnutils_uclient.1.gz
+
+%files server
+%attr (0644, root, root) %config(noreplace) %{_sysconfdir}/turnserver.conf
+%{_bindir}/turnadmin
+%{_bindir}/turnserver
+%{_datadir}/turnserver
+%{_docdir}/turnserver
+%exclude %{_docdir}/turnserver/examples
+%{_mandir}/man1/coturn.1.gz
+%{_mandir}/man1/turnadmin.1.gz
+%{_mandir}/man1/turnserver.1.gz
+%attr (0750, turnserver, turnserver) %dir /var/lib/turnserver
+%config(noreplace) %{_sysconfdir}/sysconfig/turnserver
+%{_unitdir}/turnserver.service
+%{_tmpfilesdir}/turnserver.conf
+
+%files examples
+%{_docdir}/turnserver/examples
diff --git a/turnserver-tmpfiles.conf b/turnserver-tmpfiles.conf
new file mode 100644
index 0000000..049d0e3
--- /dev/null
+++ b/turnserver-tmpfiles.conf
@@ -0,0 +1 @@
+d /run/turnserver 0750 turnserver turnserver -
diff --git a/turnserver.service b/turnserver.service
new file mode 100644
index 0000000..20ff461
--- /dev/null
+++ b/turnserver.service
@@ -0,0 +1,26 @@
+[Unit]
+Description=turnserver
+Documentation=man:coturn(1) man:turnadmin(1) man:turnserver(1)
+After=syslog.target network.target
+
+[Service]
+User=turnserver
+Group=turnserver
+Type=forking
+EnvironmentFile=/etc/sysconfig/turnserver
+PIDFile=/run/turnserver/turnserver.pid
+ExecStart=/usr/bin/turnserver -o --pidfile /run/turnserver/turnserver.pid -c /etc/turnserver.conf $EXTRA_OPTIONS
+ExecStopPost=/usr/bin/rm -f /run/turnserver/turnserver.pid
+Restart=on-abort
+StandardOutput=journal
+
+LimitCORE=infinity
+LimitNOFILE=999999
+LimitNPROC=60000
+LimitRTPRIO=infinity
+LimitRTTIME=7000000
+CPUSchedulingPolicy=other
+UMask=0007
+
+[Install]
+WantedBy=multi-user.target
diff --git a/turnserver.sysconfig b/turnserver.sysconfig
new file mode 100644
index 0000000..1d02ff0
--- /dev/null
+++ b/turnserver.sysconfig
@@ -0,0 +1 @@
+EXTRA_OPTIONS=""