1From 75625af541fd128f51079d0ffe5ef24645b8f421 Mon Sep 17 00:00:00 2001
2From: Darik Horn <dajhorn@vanadac.com>
3Date: Sun, 13 Apr 2014 12:51:15 -0400
4Subject: [PATCH] Create libsoftether.so and dynamically link the userland.
5
6Sharing object code between vpnbridge, vpnclient, vpnserver, and vpncmd
7reduces the binary size of SoftEther by 85% and its administrative memory
8footprint by 50%.
9
10[Upstream commit https://github.com/dajhorn/SoftEtherVPN/commit/75625af541fd128f51079d0ffe5ef24645b8f421]
11Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
12---
13 configure.ac                 |  1 +
14 src/Makefile.am              |  7 +++++--
15 src/libsoftether/Makefile.am | 34 ++++++++++++++++++++++++++++++++++
16 src/vpnbridge/Makefile.am    |  3 +--
17 src/vpnclient/Makefile.am    |  3 +--
18 src/vpncmd/Makefile.am       |  3 +--
19 src/vpnserver/Makefile.am    |  3 +--
20 7 files changed, 44 insertions(+), 10 deletions(-)
21 create mode 100644 src/libsoftether/Makefile.am
22
23diff --git a/configure.ac b/configure.ac
24index 4a3fc2ba..94639c44 100644
25--- a/configure.ac
26+++ b/configure.ac
27@@ -30,6 +30,7 @@ AC_CONFIG_FILES([
28 	src/Mayaqua/Makefile
29 	src/Cedar/Makefile
30 	src/hamcorebuilder/Makefile
31+	src/libsoftether/Makefile
32 	src/bin/hamcore/Makefile
33 	src/vpnserver/Makefile
34 	src/vpnclient/Makefile
35diff --git a/src/Makefile.am b/src/Makefile.am
36index dc745426..1d041d47 100644
37--- a/src/Makefile.am
38+++ b/src/Makefile.am
39@@ -22,5 +22,8 @@ SUBDIRS = Mayaqua Cedar
40 # This is a nodist helper.
41 SUBDIRS += hamcorebuilder
42
43-# These are final build products.
44-SUBDIRS += bin/hamcore vpnserver vpnclient vpnbridge vpncmd
45+# These are shared components.
46+SUBDIRS += libsoftether bin/hamcore
47+
48+# These are the final build products.
49+SUBDIRS += vpnserver vpnclient vpnbridge vpncmd
50diff --git a/src/libsoftether/Makefile.am b/src/libsoftether/Makefile.am
51new file mode 100644
52index 00000000..601920d9
53--- /dev/null
54+++ b/src/libsoftether/Makefile.am
55@@ -0,0 +1,34 @@
56+#  Copyright 2014 Darik Horn <dajhorn@vanadac.com>
57+#
58+#  This file is part of SoftEther.
59+#
60+#  SoftEther is free software: you can redistribute it and/or modify it under
61+#  the terms of the GNU General Public License as published by the Free
62+#  Software Foundation, either version 2 of the License, or (at your option)
63+#  any later version.
64+#
65+#  SoftEther is distributed in the hope that it will be useful, but WITHOUT ANY
66+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
67+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
68+#  details.
69+#
70+#  You should have received a copy of the GNU General Public License along with
71+#  SoftEther.  If not, see <http://www.gnu.org/licenses/>.
72+
73+
74+include $(top_srcdir)/autotools/softether.am
75+
76+lib_LTLIBRARIES = \
77+	libsoftether.la
78+
79+libsoftether_la_SOURCES =
80+
81+libsoftether_la_LDFLAGS = \
82+	-avoid-version
83+
84+libsoftether_la_LIBTOOLFLAGS = \
85+	--tag=disable-static
86+
87+libsoftether_la_LIBADD = \
88+	$(top_builddir)/src/Mayaqua/libmayaqua.la \
89+	$(top_builddir)/src/Cedar/libcedar.la
90diff --git a/src/vpnbridge/Makefile.am b/src/vpnbridge/Makefile.am
91index 35fe043d..fb91dd2d 100644
92--- a/src/vpnbridge/Makefile.am
93+++ b/src/vpnbridge/Makefile.am
94@@ -25,5 +25,4 @@ vpnbridge_SOURCES = \
95 	vpnbridge.c
96
97 vpnbridge_LDADD = \
98-	$(top_builddir)/src/Mayaqua/libmayaqua.la \
99-	$(top_builddir)/src/Cedar/libcedar.la
100+	$(top_builddir)/src/libsoftether/libsoftether.la
101diff --git a/src/vpnclient/Makefile.am b/src/vpnclient/Makefile.am
102index 1aa55330..c225c416 100644
103--- a/src/vpnclient/Makefile.am
104+++ b/src/vpnclient/Makefile.am
105@@ -25,5 +25,4 @@ vpnclient_SOURCES = \
106 	vpncsvc.c
107
108 vpnclient_LDADD = \
109-	$(top_builddir)/src/Mayaqua/libmayaqua.la \
110-	$(top_builddir)/src/Cedar/libcedar.la
111+	$(top_builddir)/src/libsoftether/libsoftether.la
112diff --git a/src/vpncmd/Makefile.am b/src/vpncmd/Makefile.am
113index d8042aa2..271affb0 100644
114--- a/src/vpncmd/Makefile.am
115+++ b/src/vpncmd/Makefile.am
116@@ -25,5 +25,4 @@ vpncmd_SOURCES = \
117 	vpncmd.c
118
119 vpncmd_LDADD = \
120-	$(top_builddir)/src/Mayaqua/libmayaqua.la \
121-	$(top_builddir)/src/Cedar/libcedar.la
122+	$(top_builddir)/src/libsoftether/libsoftether.la
123diff --git a/src/vpnserver/Makefile.am b/src/vpnserver/Makefile.am
124index c1c33570..1f7b7f98 100644
125--- a/src/vpnserver/Makefile.am
126+++ b/src/vpnserver/Makefile.am
127@@ -25,5 +25,4 @@ vpnserver_SOURCES = \
128 	vpnserver.c
129
130 vpnserver_LDADD = \
131-	$(top_builddir)/src/Mayaqua/libmayaqua.la \
132-	$(top_builddir)/src/Cedar/libcedar.la
133+	$(top_builddir)/src/libsoftether/libsoftether.la
134