[sr-dev] Makefile bug fixes and Dragonfly BSD port
Vincent Stemen
vince.lists at ngtek.org
Sun Jul 25 05:29:28 CEST 2010
Hi.
I have ported kamailio to Dragonfly BSD and fixed a couple of bugs in
the build system in the process. I have 4 patches to the Makefiles
which I created for kamailio-3.0.1, but have verified will apply to the
current master branch. Two are bug fixes and the other 2 are to get it
to compile and run on Dragonfly.
I have attached all 4 patches to this email. There are comments in
the top of each of the patches about what they do. All patches can be
applied from the root of the source tree.
It turns out that kamailio is not going to serve our needs at this time,
so I don't have much more time to put into it. However, I am in hopes
that the developers will utilize the patches for Dragonfly as well.
I would like to see kamailio natively support Dragonfly BSD for the
benefit of both communities and in case we ever need it ourselves in the
future, since our environment is all Dragonfly BSD based.
The patches primarily just make kamailio treat Dragonfly the same as
FreeBSD.
kamailio-3.0.1 compiled, installed, and ran successfully with these
patches. However, after applying them to todays master branch from the
git repository, make was successful, but "make install" errored with
install -m 755 msilo.so
/u1/falcon/ports/kamailio-20100724/package/kamailio-20100724/kamailio-20100724/usr/pkg/lib/ser/modules_s
CC (gcc) [M nathelper.so] nathelper.o
CC (gcc) [M nathelper.so] natping.o
CC (gcc) [M nathelper.so] nhelpr_funcs.o
CC (gcc) [M nathelper.so] rtpproxy_stream.o
rtpproxy_stream.c: In function 'rtpproxy_stream':
rtpproxy_stream.c:61: error: array type has incomplete element type
rtpproxy_stream.c:61: warning: unused variable 'v'
rtpproxy_stream.c: In function 'rtpproxy_stop_stream':
rtpproxy_stream.c:151: error: array type has incomplete element type
rtpproxy_stream.c:151: warning: unused variable 'v'
gmake[1]: *** [rtpproxy_stream.o] Error 1
gmake: *** [install-modules_s] Error 1
I don't know if it is Dragonfly related or if it is just a temporary bug
introduced in the current master branch.
Additional notes:
To successfully compile on Dragonfly BSD after applying the patches
to kamailio-3.0.1 these are the commands I used.
# export CFLAGS=-D__FreeBSD__
# gmake prefix=/usr/pkg
# gmake prefix=/usr/pkg install
Regards,
Vince
-------------- next part --------------
#!/bin/sh
#
# Created by: Vincent Stemen <vince.lists at ngtek.org>
# Date: Wed Jul 7 00:37:49 CDT 2010
# This patch file is self applying.
# It can be applied by directly executing it in the directory of the
# file, being patched, or it can be applied the usual way
# (e.g. patch < this_patch_file).
#
# This fixes Makefile.defs to properly handle $DESTDIR as a base
# installation directory for packaging, etc.
patch < $0
exit
--- Makefile.defs.orig 2010-07-06 23:40:27 -0500
+++ Makefile.defs 2010-07-07 00:34:58 -0500
@@ -271,9 +271,8 @@
# Doxygen directory
doxygen_dir=doc/doxygen
- # install location
-DESTDIR ?= $(LOCALBASE)
-PREFIX ?= $(DESTDIR)
+# install location
+PREFIX ?= $(LOCALBASE)
prefix = $(PREFIX)
# install path is $(basedir) $(prefix)
# example:
@@ -281,7 +280,7 @@
# basedir=/tmp
# prefix=/usr/local
-BASEDIR ?=
+BASEDIR ?= $(DESTDIR)
basedir = $(BASEDIR)
# install prefixes for various stuff
cfg_prefix = $(basedir)$(prefix)
-------------- next part --------------
#!/bin/sh
#
# Created by: Vincent Stemen <vince.lists at ngtek.org>
# Date: Mon Jul 5 23:24:50 CDT 2010
# This patch file is self applying.
# It can be applied by directly executing it in the directory of the
# file, being patched, or it can be applied the usual way
# (e.g. patch < this_patch_file).
#
# This fixes a bug. It called make directly which breaks on platforms
# where it is being compiled under gmake.
patch < $0
exit
--- modules_k/db_text/Makefile.orig 2010-07-05 23:22:42 -0500
+++ modules_k/db_text/Makefile 2010-07-05 23:23:40 -0500
@@ -24,7 +24,7 @@
# extra install for kamailio
install-dbtext-scripts: $(bin_prefix)/$(bin_dir)
- DBTEXTON=yes make -C ../../utils/kamctl/ install-modules
+ DBTEXTON=yes $(MAKE) -C ../../utils/kamctl/ install-modules
install-scripts: install-dbtext-scripts
-------------- next part --------------
#!/bin/sh
#
# Created by: Vincent Stemen <vince.lists at ngtek.org>
# Date: Mon Jul 5 22:56:40 CDT 2010
# This patch file is self applying.
# It can be applied by directly executing it in the directory of the
# file, being patched, or it can be applied the usual way
# (e.g. patch < this_patch_file).
#
# Patch to add Dragonfly BSD support
patch < $0
exit
--- utils/sercmd/Makefile.orig 2010-03-08 15:29:00 -0600
+++ utils/sercmd/Makefile 2010-07-05 22:50:32 -0500
@@ -29,7 +29,12 @@
# from a module Makefile)
#LIBS:=$(filter-out -lfl -ldl -lpthread -lssl -lcrypto, $(LIBS))
-LIBS:= -lresolv
+ifeq ($(OS), dragonfly)
+ LIBS:= -L$(LOCALBASE)/lib
+else
+ LIBS:= -lresolv
+endif
+
ifeq ($(OS), solaris)
LIBS+= -L$(LOCALBASE)/lib -lxnet -lnsl
endif
-------------- next part --------------
#!/bin/sh
#
# Created by: Vincent Stemen <vince.lists at ngtek.org>
# Date: Mon Jul 5 20:10:20 CDT 2010
# This patch file is self applying.
# It can be applied by directly executing it in the directory of the
# file, being patched, or it can be applied the usual way
# (e.g. patch < this_patch_file).
#
# Patch to add Dragonfly BSD support
#
# This also simplifies the platform directory path settings so that the
# ifeq() statements are not nested 5 levels deep.
patch < $0
exit
--- Makefile.defs.orig 2010-07-05 16:56:23 -0500
+++ Makefile.defs 2010-07-05 20:07:42 -0500
@@ -219,45 +219,54 @@
# lib/$(MAIN_NAME)/modules , lib/$(MAIN_NAME)/modules-s, lib/$(MAIN_NAME)/modules-k
modules_dir = lib/$(MAIN_NAME)/
lib_dir = lib/$(MAIN_NAME)/
+
+doc_dir = doc/$(MAIN_NAME)/
+man_dir = man/
+data_dir = $(MAIN_NAME)/
+
ifeq ($(OS), linux)
doc_dir = share/doc/$(MAIN_NAME)/
man_dir = share/man/
data_dir = share/$(MAIN_NAME)/
LOCALBASE ?= /usr/local
-else
+endif
+
ifeq ($(OS), freebsd)
doc_dir = share/doc/$(MAIN_NAME)/
man_dir = man/
data_dir = share/$(MAIN_NAME)/
LOCALBASE ?= /usr/local
-else
+endif
+
ifeq ($(OS), openbsd)
doc_dir = share/doc/$(MAIN_NAME)/
man_dir = man/
data_dir = share/$(MAIN_NAME)/
LOCALBASE ?= /usr/local
-else
+endif
+
ifeq ($(OS), netbsd)
doc_dir = share/doc/$(MAIN_NAME)/
man_dir = man/
data_dir = share/$(MAIN_NAME)/
LOCALBASE ?= /usr/pkg
-else
-ifeq ($(OS), darwin)
+endif
+
+ifeq ($(OS), dragonfly)
doc_dir = share/doc/$(MAIN_NAME)/
man_dir = man/
data_dir = share/$(MAIN_NAME)/
- LOCALBASE ?= /usr/local
-else
- doc_dir = doc/$(MAIN_NAME)/
+ LOCALBASE ?= /usr/pkg
+endif
+
+ifeq ($(OS), darwin)
+ doc_dir = share/doc/$(MAIN_NAME)/
man_dir = man/
- data_dir = $(MAIN_NAME)/
+ data_dir = share/$(MAIN_NAME)/
LOCALBASE ?= /usr/local
endif
-endif
-endif
-endif
-endif
+
+LOCALBASE ?= /usr/local
# Doxygen directory
doxygen_dir=doc/doxygen
@@ -605,10 +614,18 @@
# adds support for Application Server interface
# Sometimes is needes correct non-quoted $OS. HACK: gcc translates known OS to number ('linux'), so there is added underscore
+# Tell it that dragonflybsd is equivelent to compiling for freebsd.
+# This will cause __OS_freebsd to be defined below.
+ifeq ($(OS), dragonfly)
+ EQUIV_OS := freebsd
+else
+ EQUIV_OS := $(OS)
+endif
+
C_DEFS= $(extra_defs) \
-DNAME='"$(MAIN_NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
-DOS='$(OS)_' -DOS_QUOTED='"$(OS)"' -DCOMPILER='"$(CC_VER)"'\
- -D__CPU_$(ARCH) -D__OS_$(OS) \
+ -D__CPU_$(ARCH) -D__OS_$(EQUIV_OS) \
-DSER_VER=$(SER_VER) \
-DCFG_DIR='"$(cfg_target)"'\
-DPKG_MALLOC \
@@ -1776,6 +1793,50 @@
endif # SCTP
endif
+ifeq ($(OS), dragonfly)
+ C_DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN \
+ -DHAVE_SCHED_YIELD -DHAVE_MSGHDR_MSG_CONTROL \
+ -DHAVE_CONNECT_ECONNRESET_BUG -DHAVE_TIMEGM \
+ -DHAVE_NETINET_IN_SYSTM
+ ifneq ($(found_lock_method), yes)
+ C_DEFS+= -DUSE_PTHREAD_MUTEX # try pthread sems
+ found_lock_method=yes
+ LIBS+= -pthread #dlopen is in libc
+ else
+ LIBS= #dlopen is in libc
+ endif
+ # check for ver >= 4.1
+ ifeq ($(shell [ $(OSREL_N) -gt 4001 ] && echo has_kqueue), has_kqueue)
+ ifeq ($(NO_KQUEUE),)
+ C_DEFS+=-DHAVE_KQUEUE
+ endif
+ endif
+ ifeq ($(NO_SELECT),)
+ C_DEFS+=-DHAVE_SELECT
+ endif
+ YACC=yacc
+ # sctp support
+ ifeq ($(SCTP),1)
+ # test to see if the devfiles and lib are installed
+ sctp_dev_locations := /usr/include/netinet/sctp.h \
+ $(LOCALBASE)/include/netinet/sctp.h
+ sctp_dev_path := $(wildcard $(sctp_dev_locations))
+ ifeq ($(sctp_dev_path),)
+$(info "sctp development files not installed -- sctp disabled")
+ override SCTP :=
+ endif
+ ifeq ($(shell [ $(OSREL_N) -lt 7000 ] && echo sctp), sctp)
+$(info "old freebsd version (>= 7.0 needed) -- sctp disabled")
+ override SCTP :=
+ endif
+
+ ifeq ($(SCTP),1)
+ C_DEFS+=-DUSE_SCTP
+ LIBS+= # no extra libs needed on freebsd
+ endif
+ endif # SCTP
+endif
+
ifeq ($(OS), openbsd)
C_DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 \
-DHAVE_UNION_SEMUN -DHAVE_MSGHDR_MSG_CONTROL \
More information about the sr-dev
mailing list