Module: sems Branch: master Commit: c88ed81e385147273570963b8dfd14b97471afc9 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=c88ed81e385147273570963b8dfd14b97471afc9
Author: Stefan Sayer <[email protected]> Committer: Stefan Sayer <[email protected]> Date: Fri Oct 21 01:16:41 2011 +0200 adds libsems1-dev package, to build modules out-of-tree based on a patch by Michael Prokop mprokop at sipwise dot com --- Makefile.defs | 5 ++- apps/examples/out_of_tree/Makefile | 10 +++++++ apps/examples/out_of_tree/MyApp.cpp | 42 ++++++++++++++++++++++++++++++++ apps/examples/out_of_tree/MyApp.h | 28 +++++++++++++++++++++ apps/examples/out_of_tree/Readme.myapp | 15 +++++++++++ core/plug-in/Makefile.app_module | 18 ++++++++----- core/plug-in/Makefile.audio_module | 12 +++++++-- pkg/debian/control | 13 +++++++++- pkg/debian/libsems1-dev.install | 11 ++++++++ pkg/debian/rules | 12 ++++++--- 10 files changed, 149 insertions(+), 17 deletions(-) diff --git a/Makefile.defs b/Makefile.defs index 68ade21..18d6076 100644 --- a/Makefile.defs +++ b/Makefile.defs @@ -93,8 +93,9 @@ LDFLAGS += -lm GETOS=$(COREPATH)/compat/getos GETARCH=$(COREPATH)/compat/getarch -OS := $(shell $(CC) $(EXTRA_CFLAGS) -o $(GETOS) $(GETOS).c && $(GETOS)) -ARCH := $(shell $(CC) $(EXTRA_CFLAGS) -o $(GETARCH) $(GETARCH).c && $(GETARCH)) + +OS := $(shell if [ -f $(GETOS) ] ; then $(GETOS); else $(CC) $(EXTRA_CFLAGS) -o $(GETOS) $(GETOS).c && $(GETOS); fi) +ARCH := $(shell if [ -f $(GETARCH) ] ; then $(GETARCH); else $(CC) $(EXTRA_CFLAGS) -o $(GETARCH) $(GETARCH).c && $(GETARCH); fi) ifdef USE_THREADPOOL CPPFLAGS += -DSESSION_THREADPOOL diff --git a/apps/examples/out_of_tree/Makefile b/apps/examples/out_of_tree/Makefile new file mode 100644 index 0000000..e19445f --- /dev/null +++ b/apps/examples/out_of_tree/Makefile @@ -0,0 +1,10 @@ +plug_in_name = myapp + +module_ldflags = +module_cflags = + +COREPATH ?=/usr/include/sems +DEFSPATH ?=/usr/include/sems +app_module_dir=. + +include $(COREPATH)/plug-in/Makefile.app_module diff --git a/apps/examples/out_of_tree/MyApp.cpp b/apps/examples/out_of_tree/MyApp.cpp new file mode 100644 index 0000000..5c6b279 --- /dev/null +++ b/apps/examples/out_of_tree/MyApp.cpp @@ -0,0 +1,42 @@ +#include "MyApp.h" +#include "log.h" + +#define MOD_NAME "myapp" + +EXPORT_SESSION_FACTORY(MyAppFactory,MOD_NAME); + +MyAppFactory::MyAppFactory(const string& _app_name) + : AmSessionFactory(_app_name) +{ +} + +int MyAppFactory::onLoad() +{ + return 0; +} + +AmSession* MyAppFactory::onInvite(const AmSipRequest& req, const string& app_name, + const map<string,string>& app_params) +{ + return new MyAppDialog(); +} + +MyAppDialog::MyAppDialog() +{ +} + +MyAppDialog::~MyAppDialog() +{ +} + +void MyAppDialog::onSessionStart() +{ + DBG("MyAppDialog::onSessionStart: Hello World!\n"); +} + +void MyAppDialog::onBye(const AmSipRequest& req) +{ + DBG("onBye: stopSession\n"); + setStopped(); +} + diff --git a/apps/examples/out_of_tree/MyApp.h b/apps/examples/out_of_tree/MyApp.h new file mode 100644 index 0000000..9fc18d5 --- /dev/null +++ b/apps/examples/out_of_tree/MyApp.h @@ -0,0 +1,28 @@ +#ifndef _MYAPP_H_ +#define _MYAPP_H_ + +#include "AmSession.h" + +class MyAppFactory: public AmSessionFactory +{ +public: + MyAppFactory(const string& _app_name); + + int onLoad(); + AmSession* onInvite(const AmSipRequest& req, const string& app_name, + const map<string,string>& app_params); +}; + +class MyAppDialog : public AmSession +{ + + public: + MyAppDialog(); + ~MyAppDialog(); + + void onSessionStart(); + void onBye(const AmSipRequest& req); +}; + +#endif + diff --git a/apps/examples/out_of_tree/Readme.myapp b/apps/examples/out_of_tree/Readme.myapp new file mode 100644 index 0000000..d0d82ba --- /dev/null +++ b/apps/examples/out_of_tree/Readme.myapp @@ -0,0 +1,15 @@ + +MyApp + +This is an empty template for a SEMS application plug-in written in C++. + +It can reside out of the SEMS source tree and just needs the libsems1-dev +package installed to be compiled. For this to work, in the Makefile the +following needs to be defined: + plug_in_name = myapp + COREPATH ?=/usr/include/sems + DEFSPATH ?=/usr/include/sems + app_module_dir=. + include $(COREPATH)/plug-in/Makefile.app_module + + diff --git a/core/plug-in/Makefile.app_module b/core/plug-in/Makefile.app_module index ad8587d..990df30 100644 --- a/core/plug-in/Makefile.app_module +++ b/core/plug-in/Makefile.app_module @@ -1,7 +1,8 @@ COREPATH ?=../.. +DEFSPATH ?=$(COREPATH)/.. .DEFAULT_GOAL := all -include $(COREPATH)/../Makefile.defs +include $(DEFSPATH)/Makefile.defs LIB_LDFLAGS += $(module_ldflags) CPPFLAGS += -I $(COREPATH) @@ -10,7 +11,7 @@ CFLAGS += $(module_cflags) CPPFLAGS += $(module_cflags) CXXFLAGS += $(module_cflags) -app_module_dir = $(COREPATH)/lib +app_module_dir ?= $(COREPATH)/lib lib_name = $(plug_in_name).so lib_full_name ?= $(app_module_dir)/$(lib_name) @@ -87,21 +88,24 @@ $(plug_in_name)_lib: fi ; \ done -%.d: %.cpp Makefile $(COREPATH)/plug-in/Makefile.app_module $(COREPATH)/../Makefile.defs +%.d: %.cpp Makefile $(COREPATH)/plug-in/Makefile.app_module $(DEFSPATH)/Makefile.defs $(CXX) -MM $< $(CXXFLAGS) $(CPPFLAGS) > $@ -%.d: %.c Makefile $(COREPATH)/plug-in/Makefile.app_module $(COREPATH)/../Makefile.defs +%.d: %.c Makefile $(COREPATH)/plug-in/Makefile.app_module $(DEFSPATH)/Makefile.defs $(CC) -MM $< $(CFLAGS) $(CPPFLAGS) > $@ -%.o: %.cpp %.d $(COREPATH)/../Makefile.defs +%.o: %.cpp %.d $(DEFSPATH)/Makefile.defs $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@ -%.o: %.c %.d $(COREPATH)/../Makefile.defs +%.o: %.c %.d $(DEFSPATH)/Makefile.defs $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ - $(lib_full_name): $(lib_name) +ifneq ($(lib_full_name),$(lib_name)) +ifneq ($(lib_full_name),./$(lib_name)) cp $(lib_name) $(lib_full_name) +endif +endif $(lib_name): $(objs) $(module_extra_objs) Makefile $(LD) -o $(lib_name) $(objs) $(module_extra_objs) $(LIB_LDFLAGS) diff --git a/core/plug-in/Makefile.audio_module b/core/plug-in/Makefile.audio_module index b7f5454..48bbd95 100644 --- a/core/plug-in/Makefile.audio_module +++ b/core/plug-in/Makefile.audio_module @@ -1,5 +1,7 @@ COREPATH ?=../.. -include $(COREPATH)/../Makefile.defs +DEFSPATH ?=$(COREPATH)/.. + +include $(DEFSPATH)/Makefile.defs LIB_LDFLAGS += $(module_ldflags) CPPFLAGS += -I $(COREPATH) -I $(COREPATH)/amci @@ -42,14 +44,18 @@ install: $(lib_name) $(extra_install) .PHONY: install-cfg install-cfg : $(extra_install_cfg) -%.d: %.c Makefile $(COREPATH)/plug-in/Makefile.audio_module $(COREPATH)/../Makefile.defs +%.d: %.c Makefile $(COREPATH)/plug-in/Makefile.audio_module $(DEFSPATH)/Makefile.defs $(CC) -MM $< $(CPPFLAGS) $(CFLAGS) > $@ -%.o: %.c %.d $(COREPATH)/../Makefile.defs +%.o: %.c %.d $(DEFSPATH)/Makefile.defs $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@ $(lib_full_name): $(lib_name) +ifneq ($(lib_full_name),$(lib_name)) +ifneq ($(lib_full_name),./$(lib_name)) cp $(lib_name) $(lib_full_name) +endif +endif $(lib_name): $(objs) Makefile $(LD) -o $(lib_name) $(objs) $(LIB_LDFLAGS) diff --git a/pkg/debian/control b/pkg/debian/control index 42f832a..10ec3b4 100644 --- a/pkg/debian/control +++ b/pkg/debian/control @@ -23,4 +23,15 @@ Description: contains the python modules for SEMS depend upon python. This module will enable you to use the applications using the embedded python interpreter and script new applications in python. - +Package: libsems1-dev +Architecture: any +Section: libdevel +Depends: ${misc:Depends} +Description: development files for SIP Express Media Server + SEMS, the SIP Express Media Server, is a free, high performance, + extensible media server for SIP (RFC3261) based VoIP services. + It features voicemail, conferencing, announcements, pre-call + announcements, prepaid service, calling card service etc. + . + This package contains the files needed to compile programs + against sems. diff --git a/pkg/debian/libsems1-dev.install b/pkg/debian/libsems1-dev.install new file mode 100644 index 0000000..77c28cb --- /dev/null +++ b/pkg/debian/libsems1-dev.install @@ -0,0 +1,11 @@ +Makefile.defs usr/include/sems/ +core/*.h usr/include/sems/ +core/SampleArray.cc usr/include/sems/ +core/sip/*.h usr/include/sems/sip/ +core/plug-in/Makefile.app_module usr/include/sems/plug-in/ +core/plug-in/Makefile.audio_module usr/include/sems/plug-in/ +core/ampi usr/include/sems/ +core/amci usr/include/sems/ +core/compat/*.h usr/include/sems/compat/ +core/compat/*.c usr/include/sems/compat/ +core/rtp usr/include/sems/ diff --git a/pkg/debian/rules b/pkg/debian/rules index 3aad0a8..a2b2182 100755 --- a/pkg/debian/rules +++ b/pkg/debian/rules @@ -34,6 +34,7 @@ ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) INSTALL_PROGRAM += -s endif + configure: configure-stamp configure-stamp: dh_testdir @@ -70,7 +71,8 @@ install: build dh_testdir dh_testroot dh_clean -k - dh_installdirs + dh_install +# dh_installdirs # Add here commands to install the package into debian/sems USE_SPANDSP=yes LONG_DEBUG_MESSAGE=yes CPPFLAGS="$(CPPFLAGS)" \ @@ -87,9 +89,6 @@ install: build prefix=/usr \ cfg-target=/etc/sems/ -# fix etc/ser dir location -# mv -f $(CURDIR)/debian/ser/usr/etc $(CURDIR)/debian/ser - # install only the python modules USE_SPANDSP=yes LONG_DEBUG_MESSAGE=yes CPPFLAGS="$(CPPFLAGS)" \ $(MAKE) -C apps/ install \ @@ -131,6 +130,11 @@ binary-common: dh_strip dh_compress dh_fixperms + +# fixperms (rightly) sets 644 to getos/getarch (should it be somewhere else?) + chmod 755 $(CURDIR)/debian/libsems1-dev/usr/include/sems/compat/getos + chmod 755 $(CURDIR)/debian/libsems1-dev/usr/include/sems/compat/getarch + # dh_makeshlibs dh_installdeb # dh_perl _______________________________________________ Semsdev mailing list [email protected] http://lists.iptel.org/mailman/listinfo/semsdev
