Browse code

adds libsems1-dev package, to build modules out-of-tree

based on a patch by Michael Prokop mprokop at sipwise dot com

Stefan Sayer authored on 20/10/2011 23:16:41
Showing 10 changed files
... ...
@@ -93,8 +93,9 @@ LDFLAGS += -lm
93 93
 GETOS=$(COREPATH)/compat/getos
94 94
 GETARCH=$(COREPATH)/compat/getarch
95 95
 
96
-OS   := $(shell $(CC) $(EXTRA_CFLAGS) -o $(GETOS) $(GETOS).c && $(GETOS))
97
-ARCH := $(shell $(CC) $(EXTRA_CFLAGS) -o $(GETARCH) $(GETARCH).c && $(GETARCH))
96
+
97
+OS   := $(shell if [ -f $(GETOS) ] ; then $(GETOS); else  $(CC) $(EXTRA_CFLAGS) -o $(GETOS) $(GETOS).c && $(GETOS); fi)
98
+ARCH := $(shell if [ -f $(GETARCH) ] ; then $(GETARCH); else $(CC) $(EXTRA_CFLAGS) -o $(GETARCH) $(GETARCH).c && $(GETARCH); fi)
98 99
 
99 100
 ifdef USE_THREADPOOL
100 101
 CPPFLAGS += -DSESSION_THREADPOOL
101 102
new file mode 100644
... ...
@@ -0,0 +1,10 @@
1
+plug_in_name = myapp
2
+
3
+module_ldflags =
4
+module_cflags  = 
5
+
6
+COREPATH ?=/usr/include/sems
7
+DEFSPATH ?=/usr/include/sems
8
+app_module_dir=.
9
+
10
+include $(COREPATH)/plug-in/Makefile.app_module
0 11
new file mode 100644
... ...
@@ -0,0 +1,42 @@
1
+#include "MyApp.h"
2
+#include "log.h"
3
+
4
+#define MOD_NAME "myapp"
5
+
6
+EXPORT_SESSION_FACTORY(MyAppFactory,MOD_NAME);
7
+
8
+MyAppFactory::MyAppFactory(const string& _app_name)
9
+  : AmSessionFactory(_app_name)
10
+{
11
+}
12
+
13
+int MyAppFactory::onLoad()
14
+{
15
+    return 0;
16
+}
17
+
18
+AmSession* MyAppFactory::onInvite(const AmSipRequest& req, const string& app_name,
19
+				  const map<string,string>& app_params)
20
+{
21
+    return new MyAppDialog();
22
+}
23
+
24
+MyAppDialog::MyAppDialog()
25
+{
26
+}
27
+
28
+MyAppDialog::~MyAppDialog()
29
+{
30
+}
31
+
32
+void MyAppDialog::onSessionStart()
33
+{
34
+    DBG("MyAppDialog::onSessionStart: Hello World!\n");
35
+}
36
+
37
+void MyAppDialog::onBye(const AmSipRequest& req)
38
+{
39
+    DBG("onBye: stopSession\n");
40
+    setStopped();
41
+}
42
+
0 43
new file mode 100644
... ...
@@ -0,0 +1,28 @@
1
+#ifndef _MYAPP_H_
2
+#define _MYAPP_H_
3
+
4
+#include "AmSession.h"
5
+
6
+class MyAppFactory: public AmSessionFactory
7
+{
8
+public:
9
+    MyAppFactory(const string& _app_name);
10
+
11
+    int onLoad();
12
+    AmSession* onInvite(const AmSipRequest& req, const string& app_name,
13
+			const map<string,string>& app_params);
14
+};
15
+
16
+class MyAppDialog : public AmSession
17
+{
18
+    
19
+ public:
20
+    MyAppDialog();
21
+    ~MyAppDialog();
22
+
23
+    void onSessionStart();
24
+    void onBye(const AmSipRequest& req);
25
+};
26
+
27
+#endif
28
+
0 29
new file mode 100644
... ...
@@ -0,0 +1,15 @@
1
+
2
+MyApp
3
+
4
+This is an empty template for a SEMS application plug-in written in C++.
5
+
6
+It can reside out of the SEMS source tree and just needs the libsems1-dev
7
+package installed to be compiled. For this to work, in the Makefile the
8
+following needs to be defined:
9
+ plug_in_name = myapp
10
+ COREPATH ?=/usr/include/sems
11
+ DEFSPATH ?=/usr/include/sems
12
+ app_module_dir=.
13
+ include $(COREPATH)/plug-in/Makefile.app_module
14
+
15
+
... ...
@@ -1,7 +1,8 @@
1 1
 COREPATH ?=../..
2
+DEFSPATH ?=$(COREPATH)/..
2 3
 .DEFAULT_GOAL := all
3 4
 
4
-include $(COREPATH)/../Makefile.defs
5
+include $(DEFSPATH)/Makefile.defs
5 6
 
6 7
 LIB_LDFLAGS  += $(module_ldflags)
7 8
 CPPFLAGS += -I $(COREPATH)
... ...
@@ -10,7 +11,7 @@ CFLAGS   += $(module_cflags)
10 11
 CPPFLAGS += $(module_cflags)
11 12
 CXXFLAGS += $(module_cflags)
12 13
 
13
-app_module_dir = $(COREPATH)/lib
14
+app_module_dir ?= $(COREPATH)/lib
14 15
 
15 16
 lib_name = $(plug_in_name).so
16 17
 lib_full_name ?= $(app_module_dir)/$(lib_name)
... ...
@@ -87,21 +88,24 @@ $(plug_in_name)_lib:
87 88
 		fi ; \
88 89
 	done
89 90
 
90
-%.d: %.cpp Makefile $(COREPATH)/plug-in/Makefile.app_module $(COREPATH)/../Makefile.defs
91
+%.d: %.cpp Makefile $(COREPATH)/plug-in/Makefile.app_module $(DEFSPATH)/Makefile.defs
91 92
 	$(CXX) -MM $< $(CXXFLAGS) $(CPPFLAGS) > $@
92 93
 
93
-%.d: %.c Makefile $(COREPATH)/plug-in/Makefile.app_module $(COREPATH)/../Makefile.defs
94
+%.d: %.c Makefile $(COREPATH)/plug-in/Makefile.app_module $(DEFSPATH)/Makefile.defs
94 95
 	$(CC) -MM $< $(CFLAGS) $(CPPFLAGS) > $@
95 96
 
96
-%.o: %.cpp %.d $(COREPATH)/../Makefile.defs
97
+%.o: %.cpp %.d $(DEFSPATH)/Makefile.defs
97 98
 	$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@
98 99
 
99
-%.o: %.c %.d $(COREPATH)/../Makefile.defs
100
+%.o: %.c %.d $(DEFSPATH)/Makefile.defs
100 101
 	$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
101 102
 
102
-
103 103
 $(lib_full_name): $(lib_name)
104
+ifneq ($(lib_full_name),$(lib_name))
105
+ifneq ($(lib_full_name),./$(lib_name))
104 106
 	cp $(lib_name) $(lib_full_name)
107
+endif
108
+endif
105 109
 
106 110
 $(lib_name): $(objs) $(module_extra_objs) Makefile
107 111
 	$(LD) -o $(lib_name) $(objs) $(module_extra_objs) $(LIB_LDFLAGS)
... ...
@@ -1,5 +1,7 @@
1 1
 COREPATH ?=../..
2
-include $(COREPATH)/../Makefile.defs
2
+DEFSPATH ?=$(COREPATH)/..
3
+
4
+include $(DEFSPATH)/Makefile.defs
3 5
 
4 6
 LIB_LDFLAGS  += $(module_ldflags)
5 7
 CPPFLAGS += -I $(COREPATH) -I $(COREPATH)/amci 
... ...
@@ -42,14 +44,18 @@ install: $(lib_name) $(extra_install)
42 44
 .PHONY: install-cfg
43 45
 install-cfg : $(extra_install_cfg)
44 46
 
45
-%.d: %.c Makefile $(COREPATH)/plug-in/Makefile.audio_module $(COREPATH)/../Makefile.defs
47
+%.d: %.c Makefile $(COREPATH)/plug-in/Makefile.audio_module $(DEFSPATH)/Makefile.defs
46 48
 	$(CC) -MM $< $(CPPFLAGS) $(CFLAGS) > $@
47 49
 
48
-%.o: %.c %.d $(COREPATH)/../Makefile.defs
50
+%.o: %.c %.d $(DEFSPATH)/Makefile.defs
49 51
 	$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
50 52
 
51 53
 $(lib_full_name): $(lib_name)
54
+ifneq ($(lib_full_name),$(lib_name))
55
+ifneq ($(lib_full_name),./$(lib_name))
52 56
 	cp $(lib_name) $(lib_full_name)
57
+endif
58
+endif
53 59
 
54 60
 $(lib_name): $(objs)  Makefile
55 61
 	$(LD) -o $(lib_name) $(objs) $(LIB_LDFLAGS)
... ...
@@ -23,4 +23,15 @@ Description: contains the python modules for SEMS
23 23
  depend upon python. This module will enable you to use the applications using the embedded
24 24
  python interpreter and script new applications in python.
25 25
 
26
-
26
+Package: libsems1-dev
27
+Architecture: any
28
+Section: libdevel
29
+Depends: ${misc:Depends}
30
+Description: development files for SIP Express Media Server
31
+ SEMS, the SIP Express Media Server, is a free, high performance,
32
+ extensible media server for SIP (RFC3261) based VoIP services.
33
+ It features voicemail, conferencing, announcements, pre-call
34
+ announcements, prepaid service, calling card service etc.
35
+ .
36
+ This package contains the files needed to compile programs
37
+ against sems.
27 38
new file mode 100644
... ...
@@ -0,0 +1,11 @@
1
+Makefile.defs usr/include/sems/
2
+core/*.h usr/include/sems/
3
+core/SampleArray.cc usr/include/sems/
4
+core/sip/*.h usr/include/sems/sip/
5
+core/plug-in/Makefile.app_module usr/include/sems/plug-in/
6
+core/plug-in/Makefile.audio_module usr/include/sems/plug-in/
7
+core/ampi usr/include/sems/
8
+core/amci usr/include/sems/
9
+core/compat/*.h usr/include/sems/compat/
10
+core/compat/*.c usr/include/sems/compat/
11
+core/rtp usr/include/sems/
... ...
@@ -34,6 +34,7 @@ ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
34 34
 	INSTALL_PROGRAM += -s
35 35
 endif
36 36
 
37
+
37 38
 configure: configure-stamp
38 39
 configure-stamp:
39 40
 	dh_testdir
... ...
@@ -70,7 +71,8 @@ install: build
70 71
 	dh_testdir
71 72
 	dh_testroot
72 73
 	dh_clean -k
73
-	dh_installdirs
74
+	dh_install
75
+#	dh_installdirs
74 76
 
75 77
 # Add here commands to install the package into debian/sems
76 78
 	USE_SPANDSP=yes LONG_DEBUG_MESSAGE=yes CPPFLAGS="$(CPPFLAGS)" \
... ...
@@ -87,9 +89,6 @@ install: build
87 89
 		prefix=/usr \
88 90
 		cfg-target=/etc/sems/
89 91
 
90
-# fix etc/ser dir location
91
-#	mv -f $(CURDIR)/debian/ser/usr/etc $(CURDIR)/debian/ser
92
-
93 92
 # install only the python modules
94 93
 	USE_SPANDSP=yes LONG_DEBUG_MESSAGE=yes CPPFLAGS="$(CPPFLAGS)" \
95 94
 	$(MAKE) -C apps/ install \
... ...
@@ -131,6 +130,11 @@ binary-common:
131 130
 	dh_strip
132 131
 	dh_compress 
133 132
 	dh_fixperms
133
+
134
+#       fixperms (rightly) sets 644 to getos/getarch (should it be somewhere else?)
135
+	chmod 755 $(CURDIR)/debian/libsems1-dev/usr/include/sems/compat/getos
136
+	chmod 755 $(CURDIR)/debian/libsems1-dev/usr/include/sems/compat/getarch
137
+
134 138
 #	dh_makeshlibs
135 139
 	dh_installdeb
136 140
 #	dh_perl