1From c5e5d7e93c6f3302adf5821c29c4efdb7630e418 Mon Sep 17 00:00:00 2001
2From: Darik Horn <dajhorn@vanadac.com>
3Date: Sat, 12 Apr 2014 17:46:04 -0400
4Subject: [PATCH] Create autotools plumbing for SoftEther.
5
6Add autoconf and automake capabilities to SoftEther so that it can be built
7like this:
8
9	# autoreconf --force --install
10	# ./configure
11	# make install DESTDIR=/tmp/softether
12
13All standard configure parameters are supported, plus:
14
15	# ./configure --enable-debug
16
17Autotools support makes porting, cross compiling, and optimization much easier.
18
19These GNU autoconf-archive components are used for dependency checking:
20
21  * ax_check_openssl.m4
22  * ax_check_zlib.m4
23  * ax_lib_readline.m4
24  * ax_pthread.m4
25  * ax_with_curses.m4
26
27NB: http://www.gnu.org/software/autoconf-archive/
28
29[Upstream commit: https://github.com/dajhorn/SoftEtherVPN/commit/c5e5d7e93c6f3302adf5821c29c4efdb7630e418]
30Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
31[Fabrice: update for 4.30-9700-beta]
32Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
33---
34 Makefile.am                    |  21 ++
35 autotools/ax_check_openssl.m4  | 124 ++++++++++
36 autotools/ax_check_zlib.m4     | 142 +++++++++++
37 autotools/ax_lib_readline.m4   | 107 +++++++++
38 autotools/ax_pthread.m4        | 332 ++++++++++++++++++++++++++
39 autotools/ax_with_curses.m4    | 518 +++++++++++++++++++++++++++++++++++++++++
40 autotools/softether.am         |  39 ++++
41 configure.ac                   |  96 ++++++++
42 configure => manual_configure  |   0
43 src/Cedar/Makefile.am          |  82 +++++++
44 src/Makefile.am                |  26 +++
45 src/Mayaqua/Makefile.am        |  43 ++++
46 src/bin/hamcore/Makefile.am    |  29 +++
47 src/hamcorebuilder/Makefile.am |  29 +++
48 src/vpnbridge/Makefile.am      |  29 +++
49 src/vpnclient/Makefile.am      |  29 +++
50 src/vpncmd/Makefile.am         |  29 +++
51 src/vpnserver/Makefile.am      |  29 +++
52 18 files changed, 1704 insertions(+)
53 create mode 100644 Makefile.am
54 create mode 100644 autotools/ax_check_openssl.m4
55 create mode 100644 autotools/ax_check_zlib.m4
56 create mode 100644 autotools/ax_lib_readline.m4
57 create mode 100644 autotools/ax_pthread.m4
58 create mode 100644 autotools/ax_with_curses.m4
59 create mode 100644 autotools/softether.am
60 create mode 100644 configure.ac
61 rename configure => manual_configure (100%)
62 create mode 100644 src/Cedar/Makefile.am
63 create mode 100644 src/Makefile.am
64 create mode 100644 src/Mayaqua/Makefile.am
65 create mode 100644 src/bin/hamcore/Makefile.am
66 create mode 100644 src/hamcorebuilder/Makefile.am
67 create mode 100644 src/vpnbridge/Makefile.am
68 create mode 100644 src/vpnclient/Makefile.am
69 create mode 100644 src/vpncmd/Makefile.am
70 create mode 100644 src/vpnserver/Makefile.am
71
72diff --git a/Makefile.am b/Makefile.am
73new file mode 100644
74index 00000000..aa73b2ba
75--- /dev/null
76+++ b/Makefile.am
77@@ -0,0 +1,21 @@
78+#  Copyright 2014 Darik Horn <dajhorn@vanadac.com>
79+#
80+#  This file is part of SoftEther.
81+#
82+#  SoftEther is free software: you can redistribute it and/or modify it under
83+#  the terms of the GNU General Public License as published by the Free
84+#  Software Foundation, either version 2 of the License, or (at your option)
85+#  any later version.
86+#
87+#  SoftEther is distributed in the hope that it will be useful, but WITHOUT ANY
88+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
89+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
90+#  details.
91+#
92+#  You should have received a copy of the GNU General Public License along with
93+#  SoftEther.  If not, see <http://www.gnu.org/licenses/>.
94+
95+
96+ACLOCAL_AMFLAGS = -I autotools
97+include $(top_srcdir)/autotools/softether.am
98+SUBDIRS = src
99diff --git a/autotools/ax_check_openssl.m4 b/autotools/ax_check_openssl.m4
100new file mode 100644
101index 00000000..a87c5a6b
102--- /dev/null
103+++ b/autotools/ax_check_openssl.m4
104@@ -0,0 +1,124 @@
105+# ===========================================================================
106+#     http://www.gnu.org/software/autoconf-archive/ax_check_openssl.html
107+# ===========================================================================
108+#
109+# SYNOPSIS
110+#
111+#   AX_CHECK_OPENSSL([action-if-found[, action-if-not-found]])
112+#
113+# DESCRIPTION
114+#
115+#   Look for OpenSSL in a number of default spots, or in a user-selected
116+#   spot (via --with-openssl).  Sets
117+#
118+#     OPENSSL_INCLUDES to the include directives required
119+#     OPENSSL_LIBS to the -l directives required
120+#     OPENSSL_LDFLAGS to the -L or -R flags required
121+#
122+#   and calls ACTION-IF-FOUND or ACTION-IF-NOT-FOUND appropriately
123+#
124+#   This macro sets OPENSSL_INCLUDES such that source files should use the
125+#   openssl/ directory in include directives:
126+#
127+#     #include <openssl/hmac.h>
128+#
129+# LICENSE
130+#
131+#   Copyright (c) 2009,2010 Zmanda Inc. <http://www.zmanda.com/>
132+#   Copyright (c) 2009,2010 Dustin J. Mitchell <dustin@zmanda.com>
133+#
134+#   Copying and distribution of this file, with or without modification, are
135+#   permitted in any medium without royalty provided the copyright notice
136+#   and this notice are preserved. This file is offered as-is, without any
137+#   warranty.
138+
139+#serial 8
140+
141+AU_ALIAS([CHECK_SSL], [AX_CHECK_OPENSSL])
142+AC_DEFUN([AX_CHECK_OPENSSL], [
143+    found=false
144+    AC_ARG_WITH([openssl],
145+        [AS_HELP_STRING([--with-openssl=DIR],
146+            [root of the OpenSSL directory])],
147+        [
148+            case "$withval" in
149+            "" | y | ye | yes | n | no)
150+            AC_MSG_ERROR([Invalid --with-openssl value])
151+              ;;
152+            *) ssldirs="$withval"
153+              ;;
154+            esac
155+        ], [
156+            # if pkg-config is installed and openssl has installed a .pc file,
157+            # then use that information and don't search ssldirs
158+            AC_PATH_PROG([PKG_CONFIG], [pkg-config])
159+            if test x"$PKG_CONFIG" != x""; then
160+                OPENSSL_LDFLAGS=`$PKG_CONFIG openssl --libs-only-L 2>/dev/null`
161+                if test $? = 0; then
162+                    OPENSSL_LIBS=`$PKG_CONFIG openssl --libs-only-l 2>/dev/null`
163+                    OPENSSL_INCLUDES=`$PKG_CONFIG openssl --cflags-only-I 2>/dev/null`
164+                    found=true
165+                fi
166+            fi
167+
168+            # no such luck; use some default ssldirs
169+            if ! $found; then
170+                ssldirs="/usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr"
171+            fi
172+        ]
173+        )
174+
175+
176+    # note that we #include <openssl/foo.h>, so the OpenSSL headers have to be in
177+    # an 'openssl' subdirectory
178+
179+    if ! $found; then
180+        OPENSSL_INCLUDES=
181+        for ssldir in $ssldirs; do
182+            AC_MSG_CHECKING([for openssl/ssl.h in $ssldir])
183+            if test -f "$ssldir/include/openssl/ssl.h"; then
184+                OPENSSL_INCLUDES="-I$ssldir/include"
185+                OPENSSL_LDFLAGS="-L$ssldir/lib"
186+                OPENSSL_LIBS="-lssl -lcrypto"
187+                found=true
188+                AC_MSG_RESULT([yes])
189+                break
190+            else
191+                AC_MSG_RESULT([no])
192+            fi
193+        done
194+
195+        # if the file wasn't found, well, go ahead and try the link anyway -- maybe
196+        # it will just work!
197+    fi
198+
199+    # try the preprocessor and linker with our new flags,
200+    # being careful not to pollute the global LIBS, LDFLAGS, and CPPFLAGS
201+
202+    AC_MSG_CHECKING([whether compiling and linking against OpenSSL works])
203+    echo "Trying link with OPENSSL_LDFLAGS=$OPENSSL_LDFLAGS;" \
204+        "OPENSSL_LIBS=$OPENSSL_LIBS; OPENSSL_INCLUDES=$OPENSSL_INCLUDES" >&AS_MESSAGE_LOG_FD
205+
206+    save_LIBS="$LIBS"
207+    save_LDFLAGS="$LDFLAGS"
208+    save_CPPFLAGS="$CPPFLAGS"
209+    LDFLAGS="$LDFLAGS $OPENSSL_LDFLAGS"
210+    LIBS="$OPENSSL_LIBS $LIBS"
211+    CPPFLAGS="$OPENSSL_INCLUDES $CPPFLAGS"
212+    AC_LINK_IFELSE(
213+        [AC_LANG_PROGRAM([#include <openssl/ssl.h>], [SSL_new(NULL)])],
214+        [
215+            AC_MSG_RESULT([yes])
216+            $1
217+        ], [
218+            AC_MSG_RESULT([no])
219+            $2
220+        ])
221+    CPPFLAGS="$save_CPPFLAGS"
222+    LDFLAGS="$save_LDFLAGS"
223+    LIBS="$save_LIBS"
224+
225+    AC_SUBST([OPENSSL_INCLUDES])
226+    AC_SUBST([OPENSSL_LIBS])
227+    AC_SUBST([OPENSSL_LDFLAGS])
228+])
229diff --git a/autotools/ax_check_zlib.m4 b/autotools/ax_check_zlib.m4
230new file mode 100644
231index 00000000..ae5705f6
232--- /dev/null
233+++ b/autotools/ax_check_zlib.m4
234@@ -0,0 +1,142 @@
235+# ===========================================================================
236+#       http://www.gnu.org/software/autoconf-archive/ax_check_zlib.html
237+# ===========================================================================
238+#
239+# SYNOPSIS
240+#
241+#   AX_CHECK_ZLIB([action-if-found], [action-if-not-found])
242+#
243+# DESCRIPTION
244+#
245+#   This macro searches for an installed zlib library. If nothing was
246+#   specified when calling configure, it searches first in /usr/local and
247+#   then in /usr, /opt/local and /sw. If the --with-zlib=DIR is specified,
248+#   it will try to find it in DIR/include/zlib.h and DIR/lib/libz.a. If
249+#   --without-zlib is specified, the library is not searched at all.
250+#
251+#   If either the header file (zlib.h) or the library (libz) is not found,
252+#   shell commands 'action-if-not-found' is run. If 'action-if-not-found' is
253+#   not specified, the configuration exits on error, asking for a valid zlib
254+#   installation directory or --without-zlib.
255+#
256+#   If both header file and library are found, shell commands
257+#   'action-if-found' is run. If 'action-if-found' is not specified, the
258+#   default action appends '-I${ZLIB_HOME}/include' to CPFLAGS, appends
259+#   '-L$ZLIB_HOME}/lib' to LDFLAGS, prepends '-lz' to LIBS, and calls
260+#   AC_DEFINE(HAVE_LIBZ). You should use autoheader to include a definition
261+#   for this symbol in a config.h file. Sample usage in a C/C++ source is as
262+#   follows:
263+#
264+#     #ifdef HAVE_LIBZ
265+#     #include <zlib.h>
266+#     #endif /* HAVE_LIBZ */
267+#
268+# LICENSE
269+#
270+#   Copyright (c) 2008 Loic Dachary <loic@senga.org>
271+#   Copyright (c) 2010 Bastien Chevreux <bach@chevreux.org>
272+#
273+#   This program is free software; you can redistribute it and/or modify it
274+#   under the terms of the GNU General Public License as published by the
275+#   Free Software Foundation; either version 2 of the License, or (at your
276+#   option) any later version.
277+#
278+#   This program is distributed in the hope that it will be useful, but
279+#   WITHOUT ANY WARRANTY; without even the implied warranty of
280+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
281+#   Public License for more details.
282+#
283+#   You should have received a copy of the GNU General Public License along
284+#   with this program. If not, see <http://www.gnu.org/licenses/>.
285+#
286+#   As a special exception, the respective Autoconf Macro's copyright owner
287+#   gives unlimited permission to copy, distribute and modify the configure
288+#   scripts that are the output of Autoconf when processing the Macro. You
289+#   need not follow the terms of the GNU General Public License when using
290+#   or distributing such scripts, even though portions of the text of the
291+#   Macro appear in them. The GNU General Public License (GPL) does govern
292+#   all other use of the material that constitutes the Autoconf Macro.
293+#
294+#   This special exception to the GPL applies to versions of the Autoconf
295+#   Macro released by the Autoconf Archive. When you make and distribute a
296+#   modified version of the Autoconf Macro, you may extend this special
297+#   exception to the GPL to apply to your modified version as well.
298+
299+#serial 14
300+
301+AU_ALIAS([CHECK_ZLIB], [AX_CHECK_ZLIB])
302+AC_DEFUN([AX_CHECK_ZLIB],
303+#
304+# Handle user hints
305+#
306+[AC_MSG_CHECKING(if zlib is wanted)
307+zlib_places="/usr/local /usr /opt/local /sw"
308+AC_ARG_WITH([zlib],
309+[  --with-zlib=DIR         root directory path of zlib installation @<:@defaults to
310+                          /usr/local or /usr if not found in /usr/local@:>@
311+  --without-zlib          to disable zlib usage completely],
312+[if test "$withval" != no ; then
313+  AC_MSG_RESULT(yes)
314+  if test -d "$withval"
315+  then
316+    zlib_places="$withval $zlib_places"
317+  else
318+    AC_MSG_WARN([Sorry, $withval does not exist, checking usual places])
319+  fi
320+else
321+  zlib_places=
322+  AC_MSG_RESULT(no)
323+fi],
324+[AC_MSG_RESULT(yes)])
325+
326+#
327+# Locate zlib, if wanted
328+#
329+if test -n "${zlib_places}"
330+then
331+	# check the user supplied or any other more or less 'standard' place:
332+	#   Most UNIX systems      : /usr/local and /usr
333+	#   MacPorts / Fink on OSX : /opt/local respectively /sw
334+	for ZLIB_HOME in ${zlib_places} ; do
335+	  if test -f "${ZLIB_HOME}/include/zlib.h"; then break; fi
336+	  ZLIB_HOME=""
337+	done
338+
339+  ZLIB_OLD_LDFLAGS=$LDFLAGS
340+  ZLIB_OLD_CPPFLAGS=$CPPFLAGS
341+  if test -n "${ZLIB_HOME}"; then
342+        LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib"
343+        CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include"
344+  fi
345+  AC_LANG_SAVE
346+  AC_LANG_C
347+  AC_CHECK_LIB([z], [inflateEnd], [zlib_cv_libz=yes], [zlib_cv_libz=no])
348+  AC_CHECK_HEADER([zlib.h], [zlib_cv_zlib_h=yes], [zlib_cv_zlib_h=no])
349+  AC_LANG_RESTORE
350+  if test "$zlib_cv_libz" = "yes" && test "$zlib_cv_zlib_h" = "yes"
351+  then
352+    #
353+    # If both library and header were found, action-if-found
354+    #
355+    m4_ifblank([$1],[
356+                CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include"
357+                LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib"
358+                LIBS="-lz $LIBS"
359+                AC_DEFINE([HAVE_LIBZ], [1],
360+                          [Define to 1 if you have `z' library (-lz)])
361+               ],[
362+                # Restore variables
363+                LDFLAGS="$ZLIB_OLD_LDFLAGS"
364+                CPPFLAGS="$ZLIB_OLD_CPPFLAGS"
365+                $1
366+               ])
367+  else
368+    #
369+    # If either header or library was not found, action-if-not-found
370+    #
371+    m4_default([$2],[
372+                AC_MSG_ERROR([either specify a valid zlib installation with --with-zlib=DIR or disable zlib usage with --without-zlib])
373+                ])
374+  fi
375+fi
376+])
377diff --git a/autotools/ax_lib_readline.m4 b/autotools/ax_lib_readline.m4
378new file mode 100644
379index 00000000..056f25c2
380--- /dev/null
381+++ b/autotools/ax_lib_readline.m4
382@@ -0,0 +1,107 @@
383+# ===========================================================================
384+#      http://www.gnu.org/software/autoconf-archive/ax_lib_readline.html
385+# ===========================================================================
386+#
387+# SYNOPSIS
388+#
389+#   AX_LIB_READLINE
390+#
391+# DESCRIPTION
392+#
393+#   Searches for a readline compatible library. If found, defines
394+#   `HAVE_LIBREADLINE'. If the found library has the `add_history' function,
395+#   sets also `HAVE_READLINE_HISTORY'. Also checks for the locations of the
396+#   necessary include files and sets `HAVE_READLINE_H' or
397+#   `HAVE_READLINE_READLINE_H' and `HAVE_READLINE_HISTORY_H' or
398+#   'HAVE_HISTORY_H' if the corresponding include files exists.
399+#
400+#   The libraries that may be readline compatible are `libedit',
401+#   `libeditline' and `libreadline'. Sometimes we need to link a termcap
402+#   library for readline to work, this macro tests these cases too by trying
403+#   to link with `libtermcap', `libcurses' or `libncurses' before giving up.
404+#
405+#   Here is an example of how to use the information provided by this macro
406+#   to perform the necessary includes or declarations in a C file:
407+#
408+#     #ifdef HAVE_LIBREADLINE
409+#     #  if defined(HAVE_READLINE_READLINE_H)
410+#     #    include <readline/readline.h>
411+#     #  elif defined(HAVE_READLINE_H)
412+#     #    include <readline.h>
413+#     #  else /* !defined(HAVE_READLINE_H) */
414+#     extern char *readline ();
415+#     #  endif /* !defined(HAVE_READLINE_H) */
416+#     char *cmdline = NULL;
417+#     #else /* !defined(HAVE_READLINE_READLINE_H) */
418+#       /* no readline */
419+#     #endif /* HAVE_LIBREADLINE */
420+#
421+#     #ifdef HAVE_READLINE_HISTORY
422+#     #  if defined(HAVE_READLINE_HISTORY_H)
423+#     #    include <readline/history.h>
424+#     #  elif defined(HAVE_HISTORY_H)
425+#     #    include <history.h>
426+#     #  else /* !defined(HAVE_HISTORY_H) */
427+#     extern void add_history ();
428+#     extern int write_history ();
429+#     extern int read_history ();
430+#     #  endif /* defined(HAVE_READLINE_HISTORY_H) */
431+#       /* no history */
432+#     #endif /* HAVE_READLINE_HISTORY */
433+#
434+# LICENSE
435+#
436+#   Copyright (c) 2008 Ville Laurikari <vl@iki.fi>
437+#
438+#   Copying and distribution of this file, with or without modification, are
439+#   permitted in any medium without royalty provided the copyright notice
440+#   and this notice are preserved. This file is offered as-is, without any
441+#   warranty.
442+
443+#serial 6
444+
445+AU_ALIAS([VL_LIB_READLINE], [AX_LIB_READLINE])
446+AC_DEFUN([AX_LIB_READLINE], [
447+  AC_CACHE_CHECK([for a readline compatible library],
448+                 ax_cv_lib_readline, [
449+    ORIG_LIBS="$LIBS"
450+    for readline_lib in readline edit editline; do
451+      for termcap_lib in "" termcap curses ncurses; do
452+        if test -z "$termcap_lib"; then
453+          TRY_LIB="-l$readline_lib"
454+        else
455+          TRY_LIB="-l$readline_lib -l$termcap_lib"
456+        fi
457+        LIBS="$ORIG_LIBS $TRY_LIB"
458+        AC_TRY_LINK_FUNC(readline, ax_cv_lib_readline="$TRY_LIB")
459+        if test -n "$ax_cv_lib_readline"; then
460+          break
461+        fi
462+      done
463+      if test -n "$ax_cv_lib_readline"; then
464+        break
465+      fi
466+    done
467+    if test -z "$ax_cv_lib_readline"; then
468+      ax_cv_lib_readline="no"
469+    fi
470+    LIBS="$ORIG_LIBS"
471+  ])
472+
473+  if test "$ax_cv_lib_readline" != "no"; then
474+    LIBS="$LIBS $ax_cv_lib_readline"
475+    AC_DEFINE(HAVE_LIBREADLINE, 1,
476+              [Define if you have a readline compatible library])
477+    AC_CHECK_HEADERS(readline.h readline/readline.h)
478+    AC_CACHE_CHECK([whether readline supports history],
479+                   ax_cv_lib_readline_history, [
480+      ax_cv_lib_readline_history="no"
481+      AC_TRY_LINK_FUNC(add_history, ax_cv_lib_readline_history="yes")
482+    ])
483+    if test "$ax_cv_lib_readline_history" = "yes"; then
484+      AC_DEFINE(HAVE_READLINE_HISTORY, 1,
485+                [Define if your readline library has \`add_history'])
486+      AC_CHECK_HEADERS(history.h readline/history.h)
487+    fi
488+  fi
489+])dnl
490diff --git a/autotools/ax_pthread.m4 b/autotools/ax_pthread.m4
491new file mode 100644
492index 00000000..d383ad5c
493--- /dev/null
494+++ b/autotools/ax_pthread.m4
495@@ -0,0 +1,332 @@
496+# ===========================================================================
497+#        http://www.gnu.org/software/autoconf-archive/ax_pthread.html
498+# ===========================================================================
499+#
500+# SYNOPSIS
501+#
502+#   AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
503+#
504+# DESCRIPTION
505+#
506+#   This macro figures out how to build C programs using POSIX threads. It
507+#   sets the PTHREAD_LIBS output variable to the threads library and linker
508+#   flags, and the PTHREAD_CFLAGS output variable to any special C compiler
509+#   flags that are needed. (The user can also force certain compiler
510+#   flags/libs to be tested by setting these environment variables.)
511+#
512+#   Also sets PTHREAD_CC to any special C compiler that is needed for
513+#   multi-threaded programs (defaults to the value of CC otherwise). (This
514+#   is necessary on AIX to use the special cc_r compiler alias.)
515+#
516+#   NOTE: You are assumed to not only compile your program with these flags,
517+#   but also link it with them as well. e.g. you should link with
518+#   $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS
519+#
520+#   If you are only building threads programs, you may wish to use these
521+#   variables in your default LIBS, CFLAGS, and CC:
522+#
523+#     LIBS="$PTHREAD_LIBS $LIBS"
524+#     CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
525+#     CC="$PTHREAD_CC"
526+#
527+#   In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant
528+#   has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to that name
529+#   (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
530+#
531+#   Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the
532+#   PTHREAD_PRIO_INHERIT symbol is defined when compiling with
533+#   PTHREAD_CFLAGS.
534+#
535+#   ACTION-IF-FOUND is a list of shell commands to run if a threads library
536+#   is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it
537+#   is not found. If ACTION-IF-FOUND is not specified, the default action
538+#   will define HAVE_PTHREAD.
539+#
540+#   Please let the authors know if this macro fails on any platform, or if
541+#   you have any other suggestions or comments. This macro was based on work
542+#   by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help
543+#   from M. Frigo), as well as ac_pthread and hb_pthread macros posted by
544+#   Alejandro Forero Cuervo to the autoconf macro repository. We are also
545+#   grateful for the helpful feedback of numerous users.
546+#
547+#   Updated for Autoconf 2.68 by Daniel Richard G.
548+#
549+# LICENSE
550+#
551+#   Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
552+#   Copyright (c) 2011 Daniel Richard G. <skunk@iSKUNK.ORG>
553+#
554+#   This program is free software: you can redistribute it and/or modify it
555+#   under the terms of the GNU General Public License as published by the
556+#   Free Software Foundation, either version 3 of the License, or (at your
557+#   option) any later version.
558+#
559+#   This program is distributed in the hope that it will be useful, but
560+#   WITHOUT ANY WARRANTY; without even the implied warranty of
561+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
562+#   Public License for more details.
563+#
564+#   You should have received a copy of the GNU General Public License along
565+#   with this program. If not, see <http://www.gnu.org/licenses/>.
566+#
567+#   As a special exception, the respective Autoconf Macro's copyright owner
568+#   gives unlimited permission to copy, distribute and modify the configure
569+#   scripts that are the output of Autoconf when processing the Macro. You
570+#   need not follow the terms of the GNU General Public License when using
571+#   or distributing such scripts, even though portions of the text of the
572+#   Macro appear in them. The GNU General Public License (GPL) does govern
573+#   all other use of the material that constitutes the Autoconf Macro.
574+#
575+#   This special exception to the GPL applies to versions of the Autoconf
576+#   Macro released by the Autoconf Archive. When you make and distribute a
577+#   modified version of the Autoconf Macro, you may extend this special
578+#   exception to the GPL to apply to your modified version as well.
579+
580+#serial 21
581+
582+AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD])
583+AC_DEFUN([AX_PTHREAD], [
584+AC_REQUIRE([AC_CANONICAL_HOST])
585+AC_LANG_PUSH([C])
586+ax_pthread_ok=no
587+
588+# We used to check for pthread.h first, but this fails if pthread.h
589+# requires special compiler flags (e.g. on True64 or Sequent).
590+# It gets checked for in the link test anyway.
591+
592+# First of all, check if the user has set any of the PTHREAD_LIBS,
593+# etcetera environment variables, and if threads linking works using
594+# them:
595+if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
596+        save_CFLAGS="$CFLAGS"
597+        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
598+        save_LIBS="$LIBS"
599+        LIBS="$PTHREAD_LIBS $LIBS"
600+        AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
601+        AC_TRY_LINK_FUNC([pthread_join], [ax_pthread_ok=yes])
602+        AC_MSG_RESULT([$ax_pthread_ok])
603+        if test x"$ax_pthread_ok" = xno; then
604+                PTHREAD_LIBS=""
605+                PTHREAD_CFLAGS=""
606+        fi
607+        LIBS="$save_LIBS"
608+        CFLAGS="$save_CFLAGS"
609+fi
610+
611+# We must check for the threads library under a number of different
612+# names; the ordering is very important because some systems
613+# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
614+# libraries is broken (non-POSIX).
615+
616+# Create a list of thread flags to try.  Items starting with a "-" are
617+# C compiler flags, and other items are library names, except for "none"
618+# which indicates that we try without any flags at all, and "pthread-config"
619+# which is a program returning the flags for the Pth emulation library.
620+
621+ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
622+
623+# The ordering *is* (sometimes) important.  Some notes on the
624+# individual items follow:
625+
626+# pthreads: AIX (must check this before -lpthread)
627+# none: in case threads are in libc; should be tried before -Kthread and
628+#       other compiler flags to prevent continual compiler warnings
629+# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
630+# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
631+# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
632+# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
633+# -pthreads: Solaris/gcc
634+# -mthreads: Mingw32/gcc, Lynx/gcc
635+# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
636+#      doesn't hurt to check since this sometimes defines pthreads too;
637+#      also defines -D_REENTRANT)
638+#      ... -mt is also the pthreads flag for HP/aCC
639+# pthread: Linux, etcetera
640+# --thread-safe: KAI C++
641+# pthread-config: use pthread-config program (for GNU Pth library)
642+
643+case ${host_os} in
644+        solaris*)
645+
646+        # On Solaris (at least, for some versions), libc contains stubbed
647+        # (non-functional) versions of the pthreads routines, so link-based
648+        # tests will erroneously succeed.  (We need to link with -pthreads/-mt/
649+        # -lpthread.)  (The stubs are missing pthread_cleanup_push, or rather
650+        # a function called by this macro, so we could check for that, but
651+        # who knows whether they'll stub that too in a future libc.)  So,
652+        # we'll just look for -pthreads and -lpthread first:
653+
654+        ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags"
655+        ;;
656+
657+        darwin*)
658+        ax_pthread_flags="-pthread $ax_pthread_flags"
659+        ;;
660+esac
661+
662+# Clang doesn't consider unrecognized options an error unless we specify
663+# -Werror. We throw in some extra Clang-specific options to ensure that
664+# this doesn't happen for GCC, which also accepts -Werror.
665+
666+AC_MSG_CHECKING([if compiler needs -Werror to reject unknown flags])
667+save_CFLAGS="$CFLAGS"
668+ax_pthread_extra_flags="-Werror"
669+CFLAGS="$CFLAGS $ax_pthread_extra_flags -Wunknown-warning-option -Wsizeof-array-argument"
670+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([int foo(void);],[foo()])],
671+                  [AC_MSG_RESULT([yes])],
672+                  [ax_pthread_extra_flags=
673+                   AC_MSG_RESULT([no])])
674+CFLAGS="$save_CFLAGS"
675+
676+if test x"$ax_pthread_ok" = xno; then
677+for flag in $ax_pthread_flags; do
678+
679+        case $flag in
680+                none)
681+                AC_MSG_CHECKING([whether pthreads work without any flags])
682+                ;;
683+
684+                -*)
685+                AC_MSG_CHECKING([whether pthreads work with $flag])
686+                PTHREAD_CFLAGS="$flag"
687+                ;;
688+
689+                pthread-config)
690+                AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no])
691+                if test x"$ax_pthread_config" = xno; then continue; fi
692+                PTHREAD_CFLAGS="`pthread-config --cflags`"
693+                PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
694+                ;;
695+
696+                *)
697+                AC_MSG_CHECKING([for the pthreads library -l$flag])
698+                PTHREAD_LIBS="-l$flag"
699+                ;;
700+        esac
701+
702+        save_LIBS="$LIBS"
703+        save_CFLAGS="$CFLAGS"
704+        LIBS="$PTHREAD_LIBS $LIBS"
705+        CFLAGS="$CFLAGS $PTHREAD_CFLAGS $ax_pthread_extra_flags"
706+
707+        # Check for various functions.  We must include pthread.h,
708+        # since some functions may be macros.  (On the Sequent, we
709+        # need a special flag -Kthread to make this header compile.)
710+        # We check for pthread_join because it is in -lpthread on IRIX
711+        # while pthread_create is in libc.  We check for pthread_attr_init
712+        # due to DEC craziness with -lpthreads.  We check for
713+        # pthread_cleanup_push because it is one of the few pthread
714+        # functions on Solaris that doesn't have a non-functional libc stub.
715+        # We try pthread_create on general principles.
716+        AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>
717+                        static void routine(void *a) { a = 0; }
718+                        static void *start_routine(void *a) { return a; }],
719+                       [pthread_t th; pthread_attr_t attr;
720+                        pthread_create(&th, 0, start_routine, 0);
721+                        pthread_join(th, 0);
722+                        pthread_attr_init(&attr);
723+                        pthread_cleanup_push(routine, 0);
724+                        pthread_cleanup_pop(0) /* ; */])],
725+                [ax_pthread_ok=yes],
726+                [])
727+
728+        LIBS="$save_LIBS"
729+        CFLAGS="$save_CFLAGS"
730+
731+        AC_MSG_RESULT([$ax_pthread_ok])
732+        if test "x$ax_pthread_ok" = xyes; then
733+                break;
734+        fi
735+
736+        PTHREAD_LIBS=""
737+        PTHREAD_CFLAGS=""
738+done
739+fi
740+
741+# Various other checks:
742+if test "x$ax_pthread_ok" = xyes; then
743+        save_LIBS="$LIBS"
744+        LIBS="$PTHREAD_LIBS $LIBS"
745+        save_CFLAGS="$CFLAGS"
746+        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
747+
748+        # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
749+        AC_MSG_CHECKING([for joinable pthread attribute])
750+        attr_name=unknown
751+        for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
752+            AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>],
753+                           [int attr = $attr; return attr /* ; */])],
754+                [attr_name=$attr; break],
755+                [])
756+        done
757+        AC_MSG_RESULT([$attr_name])
758+        if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
759+            AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE], [$attr_name],
760+                               [Define to necessary symbol if this constant
761+                                uses a non-standard name on your system.])
762+        fi
763+
764+        AC_MSG_CHECKING([if more special flags are required for pthreads])
765+        flag=no
766+        case ${host_os} in
767+            aix* | freebsd* | darwin*) flag="-D_THREAD_SAFE";;
768+            osf* | hpux*) flag="-D_REENTRANT";;
769+            solaris*)
770+            if test "$GCC" = "yes"; then
771+                flag="-D_REENTRANT"
772+            else
773+                # TODO: What about Clang on Solaris?
774+                flag="-mt -D_REENTRANT"
775+            fi
776+            ;;
777+        esac
778+        AC_MSG_RESULT([$flag])
779+        if test "x$flag" != xno; then
780+            PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
781+        fi
782+
783+        AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT],
784+            [ax_cv_PTHREAD_PRIO_INHERIT], [
785+                AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]],
786+                                                [[int i = PTHREAD_PRIO_INHERIT;]])],
787+                    [ax_cv_PTHREAD_PRIO_INHERIT=yes],
788+                    [ax_cv_PTHREAD_PRIO_INHERIT=no])
789+            ])
790+        AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes"],
791+            [AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have PTHREAD_PRIO_INHERIT.])])
792+
793+        LIBS="$save_LIBS"
794+        CFLAGS="$save_CFLAGS"
795+
796+        # More AIX lossage: compile with *_r variant
797+        if test "x$GCC" != xyes; then
798+            case $host_os in
799+                aix*)
800+                AS_CASE(["x/$CC"],
801+                  [x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6],
802+                  [#handle absolute path differently from PATH based program lookup
803+                   AS_CASE(["x$CC"],
804+                     [x/*],
805+                     [AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])],
806+                     [AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])])])
807+                ;;
808+            esac
809+        fi
810+fi
811+
812+test -n "$PTHREAD_CC" || PTHREAD_CC="$CC"
813+
814+AC_SUBST([PTHREAD_LIBS])
815+AC_SUBST([PTHREAD_CFLAGS])
816+AC_SUBST([PTHREAD_CC])
817+
818+# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
819+if test x"$ax_pthread_ok" = xyes; then
820+        ifelse([$1],,[AC_DEFINE([HAVE_PTHREAD],[1],[Define if you have POSIX threads libraries and header files.])],[$1])
821+        :
822+else
823+        ax_pthread_ok=no
824+        $2
825+fi
826+AC_LANG_POP
827+])dnl AX_PTHREAD
828diff --git a/autotools/ax_with_curses.m4 b/autotools/ax_with_curses.m4
829new file mode 100644
830index 00000000..e4cbd31b
831--- /dev/null
832+++ b/autotools/ax_with_curses.m4
833@@ -0,0 +1,518 @@
834+# ===========================================================================
835+#      http://www.gnu.org/software/autoconf-archive/ax_with_curses.html
836+# ===========================================================================
837+#
838+# SYNOPSIS
839+#
840+#   AX_WITH_CURSES
841+#
842+# DESCRIPTION
843+#
844+#   This macro checks whether a SysV or X/Open-compatible Curses library is
845+#   present, along with the associated header file.  The NcursesW
846+#   (wide-character) library is searched for first, followed by Ncurses,
847+#   then the system-default plain Curses.  The first library found is the
848+#   one returned.
849+#
850+#   The following options are understood: --with-ncursesw, --with-ncurses,
851+#   --without-ncursesw, --without-ncurses.  The "--with" options force the
852+#   macro to use that particular library, terminating with an error if not
853+#   found.  The "--without" options simply skip the check for that library.
854+#   The effect on the search pattern is:
855+#
856+#     (no options)                           - NcursesW, Ncurses, Curses
857+#     --with-ncurses     --with-ncursesw     - NcursesW only [*]
858+#     --without-ncurses  --with-ncursesw     - NcursesW only [*]
859+#                        --with-ncursesw     - NcursesW only [*]
860+#     --with-ncurses     --without-ncursesw  - Ncurses only [*]
861+#     --with-ncurses                         - NcursesW, Ncurses [**]
862+#     --without-ncurses  --without-ncursesw  - Curses only
863+#                        --without-ncursesw  - Ncurses, Curses
864+#     --without-ncurses                      - NcursesW, Curses
865+#
866+#   [*]  If the library is not found, abort the configure script.
867+#
868+#   [**] If the second library (Ncurses) is not found, abort configure.
869+#
870+#   The following preprocessor symbols may be defined by this macro if the
871+#   appropriate conditions are met:
872+#
873+#     HAVE_CURSES             - if any SysV or X/Open Curses library found
874+#     HAVE_CURSES_ENHANCED    - if library supports X/Open Enhanced functions
875+#     HAVE_CURSES_COLOR       - if library supports color (enhanced functions)
876+#     HAVE_CURSES_OBSOLETE    - if library supports certain obsolete features
877+#     HAVE_NCURSESW           - if NcursesW (wide char) library is to be used
878+#     HAVE_NCURSES            - if the Ncurses library is to be used
879+#
880+#     HAVE_CURSES_H           - if <curses.h> is present and should be used
881+#     HAVE_NCURSESW_H         - if <ncursesw.h> should be used
882+#     HAVE_NCURSES_H          - if <ncurses.h> should be used
883+#     HAVE_NCURSESW_CURSES_H  - if <ncursesw/curses.h> should be used
884+#     HAVE_NCURSES_CURSES_H   - if <ncurses/curses.h> should be used
885+#
886+#   (These preprocessor symbols are discussed later in this document.)
887+#
888+#   The following output variable is defined by this macro; it is precious
889+#   and may be overridden on the ./configure command line:
890+#
891+#     CURSES_LIB  - library to add to xxx_LDADD
892+#
893+#   The library listed in CURSES_LIB is NOT added to LIBS by default. You
894+#   need to add CURSES_LIB to the appropriate xxx_LDADD line in your
895+#   Makefile.am.  For example:
896+#
897+#     prog_LDADD = @CURSES_LIB@
898+#
899+#   If CURSES_LIB is set on the configure command line (such as by running
900+#   "./configure CURSES_LIB=-lmycurses"), then the only header searched for
901+#   is <curses.h>.  The user may use the CPPFLAGS precious variable to
902+#   override the standard #include search path.  If the user needs to
903+#   specify an alternative path for a library (such as for a non-standard
904+#   NcurseW), the user should use the LDFLAGS variable.
905+#
906+#   The following shell variables may be defined by this macro:
907+#
908+#     ax_cv_curses           - set to "yes" if any Curses library found
909+#     ax_cv_curses_enhanced  - set to "yes" if Enhanced functions present
910+#     ax_cv_curses_color     - set to "yes" if color functions present
911+#     ax_cv_curses_obsolete  - set to "yes" if obsolete features present
912+#
913+#     ax_cv_ncursesw      - set to "yes" if NcursesW library found
914+#     ax_cv_ncurses       - set to "yes" if Ncurses library found
915+#     ax_cv_plaincurses   - set to "yes" if plain Curses library found
916+#     ax_cv_curses_which  - set to "ncursesw", "ncurses", "plaincurses" or "no"
917+#
918+#   These variables can be used in your configure.ac to determine the level
919+#   of support you need from the Curses library.  For example, if you must
920+#   have either Ncurses or NcursesW, you could include:
921+#
922+#     AX_WITH_CURSES
923+#     if test "x$ax_cv_ncursesw" != xyes && test "x$ax_cv_ncurses" != xyes; then
924+#         AC_MSG_ERROR([requires either NcursesW or Ncurses library])
925+#     fi
926+#
927+#   If any Curses library will do (but one must be present and must support
928+#   color), you could use:
929+#
930+#     AX_WITH_CURSES
931+#     if test "x$ax_cv_curses" != xyes || test "x$ax_cv_curses_color" != xyes; then
932+#         AC_MSG_ERROR([requires an X/Open-compatible Curses library with color])
933+#     fi
934+#
935+#   Certain preprocessor symbols and shell variables defined by this macro
936+#   can be used to determine various features of the Curses library.  In
937+#   particular, HAVE_CURSES and ax_cv_curses are defined if the Curses
938+#   library found conforms to the traditional SysV and/or X/Open Base Curses
939+#   definition.  Any working Curses library conforms to this level.
940+#
941+#   HAVE_CURSES_ENHANCED and ax_cv_curses_enhanced are defined if the
942+#   library supports the X/Open Enhanced Curses definition.  In particular,
943+#   the wide-character types attr_t, cchar_t and wint_t, the functions
944+#   wattr_set() and wget_wch() and the macros WA_NORMAL and _XOPEN_CURSES
945+#   are checked.  The Ncurses library does NOT conform to this definition,
946+#   although NcursesW does.
947+#
948+#   HAVE_CURSES_COLOR and ax_cv_curses_color are defined if the library
949+#   supports color functions and macros such as COLOR_PAIR, A_COLOR,
950+#   COLOR_WHITE, COLOR_RED and init_pair().  These are NOT part of the
951+#   X/Open Base Curses definition, but are part of the Enhanced set of
952+#   functions.  The Ncurses library DOES support these functions, as does
953+#   NcursesW.
954+#
955+#   HAVE_CURSES_OBSOLETE and ax_cv_curses_obsolete are defined if the
956+#   library supports certain features present in SysV and BSD Curses but not
957+#   defined in the X/Open definition.  In particular, the functions
958+#   getattrs(), getcurx() and getmaxx() are checked.
959+#
960+#   To use the HAVE_xxx_H preprocessor symbols, insert the following into
961+#   your system.h (or equivalent) header file:
962+#
963+#     #if defined HAVE_NCURSESW_CURSES_H
964+#     #  include <ncursesw/curses.h>
965+#     #elif defined HAVE_NCURSESW_H
966+#     #  include <ncursesw.h>
967+#     #elif defined HAVE_NCURSES_CURSES_H
968+#     #  include <ncurses/curses.h>
969+#     #elif defined HAVE_NCURSES_H
970+#     #  include <ncurses.h>
971+#     #elif defined HAVE_CURSES_H
972+#     #  include <curses.h>
973+#     #else
974+#     #  error "SysV or X/Open-compatible Curses header file required"
975+#     #endif
976+#
977+#   For previous users of this macro: you should not need to change anything
978+#   in your configure.ac or Makefile.am, as the previous (serial 10)
979+#   semantics are still valid.  However, you should update your system.h (or
980+#   equivalent) header file to the fragment shown above. You are encouraged
981+#   also to make use of the extended functionality provided by this version
982+#   of AX_WITH_CURSES, as well as in the additional macros
983+#   AX_WITH_CURSES_PANEL, AX_WITH_CURSES_MENU and AX_WITH_CURSES_FORM.
984+#
985+# LICENSE
986+#
987+#   Copyright (c) 2009 Mark Pulford <mark@kyne.com.au>
988+#   Copyright (c) 2009 Damian Pietras <daper@daper.net>
989+#   Copyright (c) 2012 Reuben Thomas <rrt@sc3d.org>
990+#   Copyright (c) 2011 John Zaitseff <J.Zaitseff@zap.org.au>
991+#
992+#   This program is free software: you can redistribute it and/or modify it
993+#   under the terms of the GNU General Public License as published by the
994+#   Free Software Foundation, either version 3 of the License, or (at your
995+#   option) any later version.
996+#
997+#   This program is distributed in the hope that it will be useful, but
998+#   WITHOUT ANY WARRANTY; without even the implied warranty of
999+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
1000+#   Public License for more details.
1001+#
1002+#   You should have received a copy of the GNU General Public License along
1003+#   with this program. If not, see <http://www.gnu.org/licenses/>.
1004+#
1005+#   As a special exception, the respective Autoconf Macro's copyright owner
1006+#   gives unlimited permission to copy, distribute and modify the configure
1007+#   scripts that are the output of Autoconf when processing the Macro. You
1008+#   need not follow the terms of the GNU General Public License when using
1009+#   or distributing such scripts, even though portions of the text of the
1010+#   Macro appear in them. The GNU General Public License (GPL) does govern
1011+#   all other use of the material that constitutes the Autoconf Macro.
1012+#
1013+#   This special exception to the GPL applies to versions of the Autoconf
1014+#   Macro released by the Autoconf Archive. When you make and distribute a
1015+#   modified version of the Autoconf Macro, you may extend this special
1016+#   exception to the GPL to apply to your modified version as well.
1017+
1018+#serial 15
1019+
1020+AU_ALIAS([MP_WITH_CURSES], [AX_WITH_CURSES])
1021+AC_DEFUN([AX_WITH_CURSES], [
1022+    AC_ARG_VAR([CURSES_LIB], [linker library for Curses, e.g. -lcurses])
1023+    AC_ARG_WITH([ncurses], [AS_HELP_STRING([--with-ncurses],
1024+        [force the use of Ncurses or NcursesW])],
1025+        [], [with_ncurses=check])
1026+    AC_ARG_WITH([ncursesw], [AS_HELP_STRING([--without-ncursesw],
1027+        [do not use NcursesW (wide character support)])],
1028+        [], [with_ncursesw=check])
1029+
1030+    ax_saved_LIBS=$LIBS
1031+    AS_IF([test "x$with_ncurses" = xyes || test "x$with_ncursesw" = xyes],
1032+        [ax_with_plaincurses=no], [ax_with_plaincurses=check])
1033+
1034+    ax_cv_curses_which=no
1035+
1036+    # Test for NcursesW
1037+
1038+    AS_IF([test "x$CURSES_LIB" = x && test "x$with_ncursesw" != xno], [
1039+        LIBS="$ax_saved_LIBS -lncursesw"
1040+
1041+        AC_CACHE_CHECK([for NcursesW wide-character library], [ax_cv_ncursesw], [
1042+            AC_LINK_IFELSE([AC_LANG_CALL([], [initscr])],
1043+                [ax_cv_ncursesw=yes], [ax_cv_ncursesw=no])
1044+        ])
1045+        AS_IF([test "x$ax_cv_ncursesw" = xno && test "x$with_ncursesw" = xyes], [
1046+            AC_MSG_ERROR([--with-ncursesw specified but could not find NcursesW library])
1047+        ])
1048+
1049+        AS_IF([test "x$ax_cv_ncursesw" = xyes], [
1050+            ax_cv_curses=yes
1051+            ax_cv_curses_which=ncursesw
1052+            CURSES_LIB="-lncursesw"
1053+            AC_DEFINE([HAVE_NCURSESW], [1], [Define to 1 if the NcursesW library is present])
1054+            AC_DEFINE([HAVE_CURSES],   [1], [Define to 1 if a SysV or X/Open compatible Curses library is present])
1055+
1056+            AC_CACHE_CHECK([for working ncursesw/curses.h], [ax_cv_header_ncursesw_curses_h], [
1057+                AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1058+                        @%:@define _XOPEN_SOURCE_EXTENDED 1
1059+                        @%:@include <ncursesw/curses.h>
1060+                    ]], [[
1061+                        chtype a = A_BOLD;
1062+                        int b = KEY_LEFT;
1063+                        chtype c = COLOR_PAIR(1) & A_COLOR;
1064+                        attr_t d = WA_NORMAL;
1065+                        cchar_t e;
1066+                        wint_t f;
1067+                        int g = getattrs(stdscr);
1068+                        int h = getcurx(stdscr) + getmaxx(stdscr);
1069+                        initscr();
1070+                        init_pair(1, COLOR_WHITE, COLOR_RED);
1071+                        wattr_set(stdscr, d, 0, NULL);
1072+                        wget_wch(stdscr, &f);
1073+                    ]])],
1074+                    [ax_cv_header_ncursesw_curses_h=yes],
1075+                    [ax_cv_header_ncursesw_curses_h=no])
1076+            ])
1077+            AS_IF([test "x$ax_cv_header_ncursesw_curses_h" = xyes], [
1078+                ax_cv_curses_enhanced=yes
1079+                ax_cv_curses_color=yes
1080+                ax_cv_curses_obsolete=yes
1081+                AC_DEFINE([HAVE_CURSES_ENHANCED],   [1], [Define to 1 if library supports X/Open Enhanced functions])
1082+                AC_DEFINE([HAVE_CURSES_COLOR],      [1], [Define to 1 if library supports color (enhanced functions)])
1083+                AC_DEFINE([HAVE_CURSES_OBSOLETE],   [1], [Define to 1 if library supports certain obsolete features])
1084+                AC_DEFINE([HAVE_NCURSESW_CURSES_H], [1], [Define to 1 if <ncursesw/curses.h> is present])
1085+            ])
1086+
1087+            AC_CACHE_CHECK([for working ncursesw.h], [ax_cv_header_ncursesw_h], [
1088+                AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1089+                        @%:@define _XOPEN_SOURCE_EXTENDED 1
1090+                        @%:@include <ncursesw.h>
1091+                    ]], [[
1092+                        chtype a = A_BOLD;
1093+                        int b = KEY_LEFT;
1094+                        chtype c = COLOR_PAIR(1) & A_COLOR;
1095+                        attr_t d = WA_NORMAL;
1096+                        cchar_t e;
1097+                        wint_t f;
1098+                        int g = getattrs(stdscr);
1099+                        int h = getcurx(stdscr) + getmaxx(stdscr);
1100+                        initscr();
1101+                        init_pair(1, COLOR_WHITE, COLOR_RED);
1102+                        wattr_set(stdscr, d, 0, NULL);
1103+                        wget_wch(stdscr, &f);
1104+                    ]])],
1105+                    [ax_cv_header_ncursesw_h=yes],
1106+                    [ax_cv_header_ncursesw_h=no])
1107+            ])
1108+            AS_IF([test "x$ax_cv_header_ncursesw_h" = xyes], [
1109+                ax_cv_curses_enhanced=yes
1110+                ax_cv_curses_color=yes
1111+                ax_cv_curses_obsolete=yes
1112+                AC_DEFINE([HAVE_CURSES_ENHANCED], [1], [Define to 1 if library supports X/Open Enhanced functions])
1113+                AC_DEFINE([HAVE_CURSES_COLOR],    [1], [Define to 1 if library supports color (enhanced functions)])
1114+                AC_DEFINE([HAVE_CURSES_OBSOLETE], [1], [Define to 1 if library supports certain obsolete features])
1115+                AC_DEFINE([HAVE_NCURSESW_H],      [1], [Define to 1 if <ncursesw.h> is present])
1116+            ])
1117+
1118+            AC_CACHE_CHECK([for working ncurses.h], [ax_cv_header_ncurses_h_with_ncursesw], [
1119+                AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1120+                        @%:@define _XOPEN_SOURCE_EXTENDED 1
1121+                        @%:@include <ncurses.h>
1122+                    ]], [[
1123+                        chtype a = A_BOLD;
1124+                        int b = KEY_LEFT;
1125+                        chtype c = COLOR_PAIR(1) & A_COLOR;
1126+                        attr_t d = WA_NORMAL;
1127+                        cchar_t e;
1128+                        wint_t f;
1129+                        int g = getattrs(stdscr);
1130+                        int h = getcurx(stdscr) + getmaxx(stdscr);
1131+                        initscr();
1132+                        init_pair(1, COLOR_WHITE, COLOR_RED);
1133+                        wattr_set(stdscr, d, 0, NULL);
1134+                        wget_wch(stdscr, &f);
1135+                    ]])],
1136+                    [ax_cv_header_ncurses_h_with_ncursesw=yes],
1137+                    [ax_cv_header_ncurses_h_with_ncursesw=no])
1138+            ])
1139+            AS_IF([test "x$ax_cv_header_ncurses_h_with_ncursesw" = xyes], [
1140+                ax_cv_curses_enhanced=yes
1141+                ax_cv_curses_color=yes
1142+                ax_cv_curses_obsolete=yes
1143+                AC_DEFINE([HAVE_CURSES_ENHANCED], [1], [Define to 1 if library supports X/Open Enhanced functions])
1144+                AC_DEFINE([HAVE_CURSES_COLOR],    [1], [Define to 1 if library supports color (enhanced functions)])
1145+                AC_DEFINE([HAVE_CURSES_OBSOLETE], [1], [Define to 1 if library supports certain obsolete features])
1146+                AC_DEFINE([HAVE_NCURSES_H],       [1], [Define to 1 if <ncurses.h> is present])
1147+            ])
1148+
1149+            AS_IF([test "x$ax_cv_header_ncursesw_curses_h" = xno && test "x$ax_cv_header_ncursesw_h" = xno && test "x$ax_cv_header_ncurses_h_with_ncursesw" = xno], [
1150+                AC_MSG_WARN([could not find a working ncursesw/curses.h, ncursesw.h or ncurses.h])
1151+            ])
1152+        ])
1153+    ])
1154+
1155+    # Test for Ncurses
1156+
1157+    AS_IF([test "x$CURSES_LIB" = x && test "x$with_ncurses" != xno && test "x$ax_cv_curses_which" = xno], [
1158+        LIBS="$ax_saved_LIBS -lncurses"
1159+
1160+        AC_CACHE_CHECK([for Ncurses library], [ax_cv_ncurses], [
1161+            AC_LINK_IFELSE([AC_LANG_CALL([], [initscr])],
1162+                [ax_cv_ncurses=yes], [ax_cv_ncurses=no])
1163+        ])
1164+        AS_IF([test "x$ax_cv_ncurses" = xno && test "x$with_ncurses" = xyes], [
1165+            AC_MSG_ERROR([--with-ncurses specified but could not find Ncurses library])
1166+        ])
1167+
1168+        AS_IF([test "x$ax_cv_ncurses" = xyes], [
1169+            ax_cv_curses=yes
1170+            ax_cv_curses_which=ncurses
1171+            CURSES_LIB="-lncurses"
1172+            AC_DEFINE([HAVE_NCURSES], [1], [Define to 1 if the Ncurses library is present])
1173+            AC_DEFINE([HAVE_CURSES],  [1], [Define to 1 if a SysV or X/Open compatible Curses library is present])
1174+
1175+            AC_CACHE_CHECK([for working ncurses/curses.h], [ax_cv_header_ncurses_curses_h], [
1176+                AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1177+                        @%:@include <ncurses/curses.h>
1178+                    ]], [[
1179+                        chtype a = A_BOLD;
1180+                        int b = KEY_LEFT;
1181+                        chtype c = COLOR_PAIR(1) & A_COLOR;
1182+                        int g = getattrs(stdscr);
1183+                        int h = getcurx(stdscr) + getmaxx(stdscr);
1184+                        initscr();
1185+                        init_pair(1, COLOR_WHITE, COLOR_RED);
1186+                    ]])],
1187+                    [ax_cv_header_ncurses_curses_h=yes],
1188+                    [ax_cv_header_ncurses_curses_h=no])
1189+            ])
1190+            AS_IF([test "x$ax_cv_header_ncurses_curses_h" = xyes], [
1191+                ax_cv_curses_color=yes
1192+                ax_cv_curses_obsolete=yes
1193+                AC_DEFINE([HAVE_CURSES_COLOR],     [1], [Define to 1 if library supports color (enhanced functions)])
1194+                AC_DEFINE([HAVE_CURSES_OBSOLETE],  [1], [Define to 1 if library supports certain obsolete features])
1195+                AC_DEFINE([HAVE_NCURSES_CURSES_H], [1], [Define to 1 if <ncurses/curses.h> is present])
1196+            ])
1197+
1198+            AC_CACHE_CHECK([for working ncurses.h], [ax_cv_header_ncurses_h], [
1199+                AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1200+                        @%:@include <ncurses.h>
1201+                    ]], [[
1202+                        chtype a = A_BOLD;
1203+                        int b = KEY_LEFT;
1204+                        chtype c = COLOR_PAIR(1) & A_COLOR;
1205+                        int g = getattrs(stdscr);
1206+                        int h = getcurx(stdscr) + getmaxx(stdscr);
1207+                        initscr();
1208+                        init_pair(1, COLOR_WHITE, COLOR_RED);
1209+                    ]])],
1210+                    [ax_cv_header_ncurses_h=yes],
1211+                    [ax_cv_header_ncurses_h=no])
1212+            ])
1213+            AS_IF([test "x$ax_cv_header_ncurses_h" = xyes], [
1214+                ax_cv_curses_color=yes
1215+                ax_cv_curses_obsolete=yes
1216+                AC_DEFINE([HAVE_CURSES_COLOR],    [1], [Define to 1 if library supports color (enhanced functions)])
1217+                AC_DEFINE([HAVE_CURSES_OBSOLETE], [1], [Define to 1 if library supports certain obsolete features])
1218+                AC_DEFINE([HAVE_NCURSES_H],       [1], [Define to 1 if <ncurses.h> is present])
1219+            ])
1220+
1221+            AS_IF([test "x$ax_cv_header_ncurses_curses_h" = xno && test "x$ax_cv_header_ncurses_h" = xno], [
1222+                AC_MSG_WARN([could not find a working ncurses/curses.h or ncurses.h])
1223+            ])
1224+        ])
1225+    ])
1226+
1227+    # Test for plain Curses (or if CURSES_LIB was set by user)
1228+
1229+    AS_IF([test "x$with_plaincurses" != xno && test "x$ax_cv_curses_which" = xno], [
1230+        AS_IF([test "x$CURSES_LIB" != x], [
1231+            LIBS="$ax_saved_LIBS $CURSES_LIB"
1232+        ], [
1233+            LIBS="$ax_saved_LIBS -lcurses"
1234+        ])
1235+
1236+        AC_CACHE_CHECK([for Curses library], [ax_cv_plaincurses], [
1237+            AC_LINK_IFELSE([AC_LANG_CALL([], [initscr])],
1238+                [ax_cv_plaincurses=yes], [ax_cv_plaincurses=no])
1239+        ])
1240+
1241+        AS_IF([test "x$ax_cv_plaincurses" = xyes], [
1242+            ax_cv_curses=yes
1243+            ax_cv_curses_which=plaincurses
1244+            AS_IF([test "x$CURSES_LIB" = x], [
1245+                CURSES_LIB="-lcurses"
1246+            ])
1247+            AC_DEFINE([HAVE_CURSES], [1], [Define to 1 if a SysV or X/Open compatible Curses library is present])
1248+
1249+            # Check for base conformance (and header file)
1250+
1251+            AC_CACHE_CHECK([for working curses.h], [ax_cv_header_curses_h], [
1252+                AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1253+                        @%:@include <curses.h>
1254+                    ]], [[
1255+                        chtype a = A_BOLD;
1256+                        int b = KEY_LEFT;
1257+                        initscr();
1258+                    ]])],
1259+                    [ax_cv_header_curses_h=yes],
1260+                    [ax_cv_header_curses_h=no])
1261+            ])
1262+            AS_IF([test "x$ax_cv_header_curses_h" = xyes], [
1263+                AC_DEFINE([HAVE_CURSES_H], [1], [Define to 1 if <curses.h> is present])
1264+
1265+                # Check for X/Open Enhanced conformance
1266+
1267+                AC_CACHE_CHECK([for X/Open Enhanced Curses conformance], [ax_cv_plaincurses_enhanced], [
1268+                    AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1269+                            @%:@define _XOPEN_SOURCE_EXTENDED 1
1270+                            @%:@include <curses.h>
1271+                            @%:@ifndef _XOPEN_CURSES
1272+                            @%:@error "this Curses library is not enhanced"
1273+                            "this Curses library is not enhanced"
1274+                            @%:@endif
1275+                        ]], [[
1276+                            chtype a = A_BOLD;
1277+                            int b = KEY_LEFT;
1278+                            chtype c = COLOR_PAIR(1) & A_COLOR;
1279+                            attr_t d = WA_NORMAL;
1280+                            cchar_t e;
1281+                            wint_t f;
1282+                            initscr();
1283+                            init_pair(1, COLOR_WHITE, COLOR_RED);
1284+                            wattr_set(stdscr, d, 0, NULL);
1285+                            wget_wch(stdscr, &f);
1286+                        ]])],
1287+                        [ax_cv_plaincurses_enhanced=yes],
1288+                        [ax_cv_plaincurses_enhanced=no])
1289+                ])
1290+                AS_IF([test "x$ax_cv_plaincurses_enhanced" = xyes], [
1291+                    ax_cv_curses_enhanced=yes
1292+                    ax_cv_curses_color=yes
1293+                    AC_DEFINE([HAVE_CURSES_ENHANCED], [1], [Define to 1 if library supports X/Open Enhanced functions])
1294+                    AC_DEFINE([HAVE_CURSES_COLOR],    [1], [Define to 1 if library supports color (enhanced functions)])
1295+                ])
1296+
1297+                # Check for color functions
1298+
1299+                AC_CACHE_CHECK([for Curses color functions], [ax_cv_plaincurses_color], [
1300+                    AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1301+                        @%:@define _XOPEN_SOURCE_EXTENDED 1
1302+                        @%:@include <curses.h>
1303+                        ]], [[
1304+                            chtype a = A_BOLD;
1305+                            int b = KEY_LEFT;
1306+                            chtype c = COLOR_PAIR(1) & A_COLOR;
1307+                            initscr();
1308+                            init_pair(1, COLOR_WHITE, COLOR_RED);
1309+                        ]])],
1310+                        [ax_cv_plaincurses_color=yes],
1311+                        [ax_cv_plaincurses_color=no])
1312+                ])
1313+                AS_IF([test "x$ax_cv_plaincurses_color" = xyes], [
1314+                    ax_cv_curses_color=yes
1315+                    AC_DEFINE([HAVE_CURSES_COLOR], [1], [Define to 1 if library supports color (enhanced functions)])
1316+                ])
1317+
1318+                # Check for obsolete functions
1319+
1320+                AC_CACHE_CHECK([for obsolete Curses functions], [ax_cv_plaincurses_obsolete], [
1321+                AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1322+                        @%:@include <curses.h>
1323+                    ]], [[
1324+                        chtype a = A_BOLD;
1325+                        int b = KEY_LEFT;
1326+                        int g = getattrs(stdscr);
1327+                        int h = getcurx(stdscr) + getmaxx(stdscr);
1328+                        initscr();
1329+                    ]])],
1330+                    [ax_cv_plaincurses_obsolete=yes],
1331+                    [ax_cv_plaincurses_obsolete=no])
1332+                ])
1333+                AS_IF([test "x$ax_cv_plaincurses_obsolete" = xyes], [
1334+                    ax_cv_curses_obsolete=yes
1335+                    AC_DEFINE([HAVE_CURSES_OBSOLETE], [1], [Define to 1 if library supports certain obsolete features])
1336+                ])
1337+            ])
1338+
1339+            AS_IF([test "x$ax_cv_header_curses_h" = xno], [
1340+                AC_MSG_WARN([could not find a working curses.h])
1341+            ])
1342+        ])
1343+    ])
1344+
1345+    AS_IF([test "x$ax_cv_curses"          != xyes], [ax_cv_curses=no])
1346+    AS_IF([test "x$ax_cv_curses_enhanced" != xyes], [ax_cv_curses_enhanced=no])
1347+    AS_IF([test "x$ax_cv_curses_color"    != xyes], [ax_cv_curses_color=no])
1348+    AS_IF([test "x$ax_cv_curses_obsolete" != xyes], [ax_cv_curses_obsolete=no])
1349+
1350+    LIBS=$ax_saved_LIBS
1351+])dnl
1352diff --git a/autotools/softether.am b/autotools/softether.am
1353new file mode 100644
1354index 00000000..e5e91eeb
1355--- /dev/null
1356+++ b/autotools/softether.am
1357@@ -0,0 +1,39 @@
1358+#  Copyright 2014 Darik Horn <dajhorn@vanadac.com>
1359+#
1360+#  This file is part of SoftEther.
1361+#
1362+#  SoftEther is free software: you can redistribute it and/or modify it under
1363+#  the terms of the GNU General Public License as published by the Free
1364+#  Software Foundation, either version 2 of the License, or (at your option)
1365+#  any later version.
1366+#
1367+#  SoftEther is distributed in the hope that it will be useful, but WITHOUT ANY
1368+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1369+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
1370+#  details.
1371+#
1372+#  You should have received a copy of the GNU General Public License along with
1373+#  SoftEther.  If not, see <http://www.gnu.org/licenses/>.
1374+
1375+
1376+if CONFIGURE_ENABLE_DEBUG
1377+DEBUG_CFLAGS = -g -D_DEBUG -DDEBUG
1378+else
1379+DEBUG_CFLAGS = -DNDEBUG -DVPN_SPEED
1380+endif
1381+
1382+AM_CFLAGS = \
1383+	$(DEBUG_CFLAGS) \
1384+	-I$(top_srcdir)/src \
1385+	-I$(top_srcdir)/src/Mayaqua \
1386+	-I$(top_srcdir)/src/Cedar \
1387+	-DUNIX \
1388+	-DUNIX_LINUX \
1389+	-D_REENTRANT \
1390+	-DREENTRANT \
1391+	-D_THREAD_SAFE \
1392+	-D_THREADSAFE \
1393+	-DTHREAD_SAFE \
1394+	-DTHREADSAFE \
1395+	-D_FILE_OFFSET_BITS=64 \
1396+	-fsigned-char
1397diff --git a/configure.ac b/configure.ac
1398new file mode 100644
1399index 00000000..4a3fc2ba
1400--- /dev/null
1401+++ b/configure.ac
1402@@ -0,0 +1,96 @@
1403+#  Copyright 2014 Darik Horn <dajhorn@vanadac.com>
1404+#
1405+#  This file is part of SoftEther.
1406+#
1407+#  SoftEther is free software: you can redistribute it and/or modify it under
1408+#  the terms of the GNU General Public License as published by the Free
1409+#  Software Foundation, either version 2 of the License, or (at your option)
1410+#  any later version.
1411+#
1412+#  SoftEther is distributed in the hope that it will be useful, but WITHOUT ANY
1413+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1414+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
1415+#  details.
1416+#
1417+#  You should have received a copy of the GNU General Public License along with
1418+#  SoftEther.  If not, see <http://www.gnu.org/licenses/>.
1419+
1420+
1421+AC_INIT([SoftEther], [1], [http://www.vpnusers.com/], [softether], [http://www.softether.org/])
1422+AC_CONFIG_AUX_DIR([autotools])
1423+AC_CONFIG_MACRO_DIR([autotools])
1424+AM_INIT_AUTOMAKE([foreign -Wall -Werror])
1425+AM_PROG_AR
1426+AC_PROG_CC
1427+AC_PROG_LIBTOOL
1428+AC_CONFIG_HEADERS([softether_config.h])
1429+AC_CONFIG_FILES([
1430+	Makefile
1431+	src/Makefile
1432+	src/Mayaqua/Makefile
1433+	src/Cedar/Makefile
1434+	src/hamcorebuilder/Makefile
1435+	src/bin/hamcore/Makefile
1436+	src/vpnserver/Makefile
1437+	src/vpnclient/Makefile
1438+	src/vpnbridge/Makefile
1439+	src/vpncmd/Makefile
1440+])
1441+
1442+
1443+AC_ARG_ENABLE(
1444+	[debug],
1445+	AS_HELP_STRING([--enable-debug], [build SoftEther with debugging features]),
1446+	[debug=yes]
1447+)
1448+AM_CONDITIONAL([CONFIGURE_ENABLE_DEBUG], [test _"$debug" = _yes])
1449+
1450+
1451+AX_PTHREAD([
1452+	AC_SUBST(PTHREAD_CC)
1453+	AC_SUBST(PTHREAD_CFLAGS)
1454+	AC_SUBST(PTHREAD_LIBS)
1455+],[
1456+	AC_MSG_ERROR([pthread capabilities not found])
1457+])
1458+
1459+CC="$PTHREAD_CC"
1460+CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
1461+LIBS="$PTHREAD_LIBS $LIBS"
1462+
1463+
1464+AX_CHECK_OPENSSL([
1465+	AC_SUBST(OPENSSL_LIBS)
1466+	AC_SUBST(OPENSSL_LDFLAGS)
1467+],[
1468+	AC_MSG_ERROR([openssl not found])
1469+])
1470+
1471+LIBS="$LIBS $OPENSSL_LIBS"
1472+LDFLAGS="$LDFLAGS $OPENSSL_LDFLAGS"
1473+
1474+
1475+# This macro automatically updates build variables.
1476+AX_CHECK_ZLIB(, AC_MSG_ERROR([zlib not found]))
1477+
1478+
1479+AX_WITH_CURSES
1480+if test "_$ax_cv_curses" != _yes
1481+then
1482+	AC_MSG_ERROR([libcurses, libncurses, or libncursesw not found])
1483+else
1484+	AC_SUBST(CURSES_LIB)
1485+	LIBS="$LIBS $CURSES_LIB"
1486+fi
1487+
1488+
1489+AX_LIB_READLINE
1490+if test "_$ax_cv_lib_readline" = _no
1491+then
1492+	AC_MSG_ERROR([libreadline not found])
1493+else
1494+	: This macro automatically updates build variables.
1495+fi
1496+
1497+
1498+AC_OUTPUT
1499--- a/configure	2017-07-16 04:53:31.000000000 +0200
1500+++ b/configure	1970-01-01 01:00:00.000000000 +0100
1501@@ -1,112 +0,0 @@
1502-#!/bin/sh
1503-
1504-echo '---------------------------------------------------------------------'
1505-echo 'SoftEther VPN for Unix'
1506-echo
1507-echo 'Copyright (c) Daiyuu Nobori.'
1508-echo 'Copyright (c) SoftEther VPN Project, University of Tsukuba, Japan.'
1509-echo 'Copyright (c) SoftEther Corporation.'
1510-echo 'Copyright (c) all contributors on SoftEther VPN project in GitHub.'
1511-echo
1512-echo 'License: The Apache License, Version 2.0'
1513-echo
1514-echo 'Read and understand README.TXT, LICENSE.TXT and WARNING.TXT before use.'
1515-echo '---------------------------------------------------------------------'
1516-echo
1517-
1518-echo 'Welcome to the corner-cutting configure script !'
1519-echo
1520-
1521-OS=""
1522-case "`uname -s`" in
1523-Linux)
1524-	OS="linux"
1525-	;;
1526-FreeBSD)
1527-	OS="freebsd"
1528-	;;
1529-SunOS)
1530-	OS="solaris"
1531-	;;
1532-Darwin)
1533-	OS="macos"
1534-	;;
1535-OpenBSD)
1536-	OS="openbsd"
1537-	;;
1538-*)
1539-	echo 'Select your operating system below:'
1540-	echo ' 1: Linux'
1541-	echo ' 2: FreeBSD'
1542-	echo ' 3: Solaris'
1543-	echo ' 4: Mac OS X'
1544-	echo ' 5: OpenBSD'
1545-	echo
1546-	echo -n 'Which is your operating system (1 - 5) ? : '
1547-	read TMP
1548-	echo
1549-	if test "$TMP" = "1"
1550-	then
1551-		OS="linux"
1552-	fi
1553-	if test "$TMP" = "2"
1554-	then
1555-		OS="freebsd"
1556-	fi
1557-	if test "$TMP" = "3"
1558-	then
1559-		OS="solaris"
1560-	fi
1561-	if test "$TMP" = "4"
1562-	then
1563-		OS="macos"
1564-	fi
1565-	if test "$TMP" = "5"
1566-	then
1567-		OS="openbsd"
1568-	fi
1569-
1570-	if test "$OS" = ""
1571-	then
1572-		echo "Wrong number."
1573-		exit 1
1574-	fi
1575-	;;
1576-esac
1577-
1578-CPU=""
1579-case "`uname -m`" in
1580-x86_64|amd64|aarch64|arm64|armv8*|mips64|ppc64|sparc64|alpha|ia64)
1581-	CPU=64bit
1582-	;;
1583-i?86|x86pc|i86pc|armv4*|armv5*|armv6*|armv7*)
1584-	CPU=32bit
1585-	;;
1586-*)
1587-	echo 'Select your CPU bits below:'
1588-	echo ' 1: 32-bit'
1589-	echo ' 2: 64-bit'
1590-	echo
1591-	echo -n 'Which is the type of your CPU (1 - 2) ? : '
1592-	read TMP
1593-	echo
1594-	if test "$TMP" = "1"
1595-	then
1596-		CPU="32bit"
1597-	fi
1598-	if test "$TMP" = "2"
1599-	then
1600-		CPU="64bit"
1601-	fi
1602-
1603-	if test "$CPU" = ""
1604-	then
1605-		echo "Wrong number."
1606-		exit 1
1607-	fi
1608-	;;
1609-esac
1610-
1611-cp src/makefiles/${OS}_${CPU}.mak Makefile
1612-
1613-echo "The Makefile is generated. Run 'make' to build SoftEther VPN."
1614--- a/manual_configure	1970-01-01 01:00:00.000000000 +0100
1615+++ b/manual_configure	2017-07-16 04:53:31.000000000 +0200
1616@@ -0,0 +1,112 @@
1617+#!/bin/sh
1618+
1619+echo '---------------------------------------------------------------------'
1620+echo 'SoftEther VPN for Unix'
1621+echo
1622+echo 'Copyright (c) SoftEther VPN Project at University of Tsukuba, Japan.'
1623+echo 'Copyright (c) Daiyuu Nobori. All Rights Reserved.'
1624+echo
1625+echo 'This program is free software; you can redistribute it and/or'
1626+echo 'modify it under the terms of the GNU General Public License'
1627+echo 'version 2 as published by the Free Software Foundation.'
1628+echo
1629+echo 'Read and understand README.TXT, LICENSE.TXT and WARNING.TXT before use.'
1630+echo '---------------------------------------------------------------------'
1631+echo
1632+
1633+echo 'Welcome to the corner-cutting configure script !'
1634+echo
1635+
1636+OS=""
1637+case "`uname -s`" in
1638+Linux)
1639+	OS="linux"
1640+	;;
1641+FreeBSD)
1642+	OS="freebsd"
1643+	;;
1644+SunOS)
1645+	OS="solaris"
1646+	;;
1647+Darwin)
1648+	OS="macos"
1649+	;;
1650+OpenBSD)
1651+	OS="openbsd"
1652+	;;
1653+*)
1654+	echo 'Select your operating system below:'
1655+	echo ' 1: Linux'
1656+	echo ' 2: FreeBSD'
1657+	echo ' 3: Solaris'
1658+	echo ' 4: Mac OS X'
1659+	echo ' 5: OpenBSD'
1660+	echo
1661+	echo -n 'Which is your operating system (1 - 5) ? : '
1662+	read TMP
1663+	echo
1664+	if test "$TMP" = "1"
1665+	then
1666+		OS="linux"
1667+	fi
1668+	if test "$TMP" = "2"
1669+	then
1670+		OS="freebsd"
1671+	fi
1672+	if test "$TMP" = "3"
1673+	then
1674+		OS="solaris"
1675+	fi
1676+	if test "$TMP" = "4"
1677+	then
1678+		OS="macos"
1679+	fi
1680+	if test "$TMP" = "5"
1681+	then
1682+		OS="openbsd"
1683+	fi
1684+
1685+	if test "$OS" = ""
1686+	then
1687+		echo "Wrong number."
1688+		exit 1
1689+	fi
1690+	;;
1691+esac
1692+
1693+CPU=""
1694+case "`uname -m`" in
1695+x86_64|amd64|aarch64|arm64|armv8*|mips64|ppc64|sparc64|alpha|ia64)
1696+	CPU=64bit
1697+	;;
1698+i?86|x86pc|i86pc|armv4*|armv5*|armv6*|armv7*)
1699+	CPU=32bit
1700+	;;
1701+*)
1702+	echo 'Select your CPU bits below:'
1703+	echo ' 1: 32-bit'
1704+	echo ' 2: 64-bit'
1705+	echo
1706+	echo -n 'Which is the type of your CPU (1 - 2) ? : '
1707+	read TMP
1708+	echo
1709+	if test "$TMP" = "1"
1710+	then
1711+		CPU="32bit"
1712+	fi
1713+	if test "$TMP" = "2"
1714+	then
1715+		CPU="64bit"
1716+	fi
1717+
1718+	if test "$CPU" = ""
1719+	then
1720+		echo "Wrong number."
1721+		exit 1
1722+	fi
1723+	;;
1724+esac
1725+
1726+cp src/makefiles/${OS}_${CPU}.mak Makefile
1727+
1728+echo "The Makefile is generated. Run 'make' to build SoftEther VPN."
1729diff --git a/src/Cedar/Makefile.am b/src/Cedar/Makefile.am
1730new file mode 100644
1731index 00000000..5346537d
1732--- /dev/null
1733+++ b/src/Cedar/Makefile.am
1734@@ -0,0 +1,82 @@
1735+#  Copyright 2014 Darik Horn <dajhorn@vanadac.com>
1736+#
1737+#  This file is part of SoftEther.
1738+#
1739+#  SoftEther is free software: you can redistribute it and/or modify it under
1740+#  the terms of the GNU General Public License as published by the Free
1741+#  Software Foundation, either version 2 of the License, or (at your option)
1742+#  any later version.
1743+#
1744+#  SoftEther is distributed in the hope that it will be useful, but WITHOUT ANY
1745+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1746+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
1747+#  details.
1748+#
1749+#  You should have received a copy of the GNU General Public License along with
1750+#  SoftEther.  If not, see <http://www.gnu.org/licenses/>.
1751+
1752+
1753+include $(top_srcdir)/autotools/softether.am
1754+
1755+noinst_LTLIBRARIES = libcedar.la
1756+
1757+libcedar_la_SOURCES = \
1758+	Account.c \
1759+	Admin.c \
1760+	AzureClient.c \
1761+	AzureServer.c \
1762+	Bridge.c \
1763+	BridgeUnix.c \
1764+	BridgeWin32.c \
1765+	Cedar.c \
1766+	CedarPch.c \
1767+	Client.c \
1768+	CM.c \
1769+	Command.c \
1770+	Connection.c \
1771+	Console.c \
1772+	Database.c \
1773+	DDNS.c \
1774+	EM.c \
1775+	EtherLog.c \
1776+	Hub.c \
1777+	Interop_OpenVPN.c \
1778+	Interop_SSTP.c \
1779+	IPsec.c \
1780+	IPsec_EtherIP.c \
1781+	IPsec_IKE.c \
1782+	IPsec_IkePacket.c \
1783+	IPsec_IPC.c \
1784+	IPsec_L2TP.c \
1785+	IPsec_PPP.c \
1786+	IPsec_Win7.c \
1787+	Layer3.c \
1788+	Link.c \
1789+	Listener.c \
1790+	Logging.c \
1791+	Nat.c \
1792+	NativeStack.c \
1793+	NM.c \
1794+	NullLan.c \
1795+	Protocol.c \
1796+	Radius.c \
1797+	Remote.c \
1798+	Sam.c \
1799+	SecureInfo.c \
1800+	SecureNAT.c \
1801+	SeLowUser.c \
1802+	Server.c \
1803+	Session.c \
1804+	SM.c \
1805+	SW.c \
1806+	UdpAccel.c \
1807+	UT.c \
1808+	VG.c \
1809+	Virtual.c \
1810+	VLan.c \
1811+	VLanUnix.c \
1812+	VLanWin32.c \
1813+	WaterMark.c \
1814+	WebUI.c \
1815+	WinUi.c \
1816+	Wpc.c
1817diff --git a/src/Makefile.am b/src/Makefile.am
1818new file mode 100644
1819index 00000000..dc745426
1820--- /dev/null
1821+++ b/src/Makefile.am
1822@@ -0,0 +1,26 @@
1823+#  Copyright 2014 Darik Horn <dajhorn@vanadac.com>
1824+#
1825+#  This file is part of SoftEther.
1826+#
1827+#  SoftEther is free software: you can redistribute it and/or modify it under
1828+#  the terms of the GNU General Public License as published by the Free
1829+#  Software Foundation, either version 2 of the License, or (at your option)
1830+#  any later version.
1831+#
1832+#  SoftEther is distributed in the hope that it will be useful, but WITHOUT ANY
1833+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1834+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
1835+#  details.
1836+#
1837+#  You should have received a copy of the GNU General Public License along with
1838+#  SoftEther.  If not, see <http://www.gnu.org/licenses/>.
1839+
1840+
1841+# These components are built as libtool convenience libraries.
1842+SUBDIRS = Mayaqua Cedar
1843+
1844+# This is a nodist helper.
1845+SUBDIRS += hamcorebuilder
1846+
1847+# These are final build products.
1848+SUBDIRS += bin/hamcore vpnserver vpnclient vpnbridge vpncmd
1849diff --git a/src/Mayaqua/Makefile.am b/src/Mayaqua/Makefile.am
1850new file mode 100644
1851index 00000000..6b8dc1a6
1852--- /dev/null
1853+++ b/src/Mayaqua/Makefile.am
1854@@ -0,0 +1,43 @@
1855+#  Copyright 2014 Darik Horn <dajhorn@vanadac.com>
1856+#
1857+#  This file is part of SoftEther.
1858+#
1859+#  SoftEther is free software: you can redistribute it and/or modify it under
1860+#  the terms of the GNU General Public License as published by the Free
1861+#  Software Foundation, either version 2 of the License, or (at your option)
1862+#  any later version.
1863+#
1864+#  SoftEther is distributed in the hope that it will be useful, but WITHOUT ANY
1865+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1866+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
1867+#  details.
1868+#
1869+#  You should have received a copy of the GNU General Public License along with
1870+#  SoftEther.  If not, see <http://www.gnu.org/licenses/>.
1871+
1872+
1873+include $(top_srcdir)/autotools/softether.am
1874+
1875+noinst_LTLIBRARIES = libmayaqua.la
1876+
1877+libmayaqua_la_SOURCES = \
1878+	Cfg.c \
1879+	Encrypt.c \
1880+	FileIO.c \
1881+	Internat.c \
1882+	Kernel.c \
1883+	Mayaqua.c \
1884+	Memory.c \
1885+	Microsoft.c \
1886+	Network.c \
1887+	Object.c \
1888+	OS.c \
1889+	Pack.c \
1890+	Secure.c \
1891+	Str.c \
1892+	Table.c \
1893+	TcpIp.c \
1894+	Tick64.c \
1895+	Tracking.c \
1896+	Unix.c \
1897+	Win32.c
1898diff --git a/src/bin/hamcore/Makefile.am b/src/bin/hamcore/Makefile.am
1899new file mode 100644
1900index 00000000..37b0291e
1901--- /dev/null
1902+++ b/src/bin/hamcore/Makefile.am
1903@@ -0,0 +1,29 @@
1904+#  Copyright 2014 Darik Horn <dajhorn@vanadac.com>
1905+#
1906+#  This file is part of SoftEther.
1907+#
1908+#  SoftEther is free software: you can redistribute it and/or modify it under
1909+#  the terms of the GNU General Public License as published by the Free
1910+#  Software Foundation, either version 2 of the License, or (at your option)
1911+#  any later version.
1912+#
1913+#  SoftEther is distributed in the hope that it will be useful, but WITHOUT ANY
1914+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1915+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
1916+#  details.
1917+#
1918+#  You should have received a copy of the GNU General Public License along with
1919+#  SoftEther.  If not, see <http://www.gnu.org/licenses/>.
1920+
1921+
1922+include $(top_srcdir)/autotools/softether.am
1923+
1924+# This is required to use a custom build rule with -Wall and -Werror enabled.
1925+AUTOMAKE_OPTIONS = -Wno-override
1926+EXEEXT =
1927+HAMCOREBUILDER = $(top_builddir)/src/hamcorebuilder/hamcorebuilder
1928+
1929+sbin_PROGRAMS = hamcore.se2
1930+
1931+hamcore.se2$(EXEEXT): $(HAMCOREBUILDER)
1932+	$(HAMCOREBUILDER) $(top_srcdir)/src/bin/hamcore $@
1933diff --git a/src/hamcorebuilder/Makefile.am b/src/hamcorebuilder/Makefile.am
1934new file mode 100644
1935index 00000000..a22429f0
1936--- /dev/null
1937+++ b/src/hamcorebuilder/Makefile.am
1938@@ -0,0 +1,29 @@
1939+#  Copyright 2014 Darik Horn <dajhorn@vanadac.com>
1940+#
1941+#  This file is part of SoftEther.
1942+#
1943+#  SoftEther is free software: you can redistribute it and/or modify it under
1944+#  the terms of the GNU General Public License as published by the Free
1945+#  Software Foundation, either version 2 of the License, or (at your option)
1946+#  any later version.
1947+#
1948+#  SoftEther is distributed in the hope that it will be useful, but WITHOUT ANY
1949+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1950+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
1951+#  details.
1952+#
1953+#  You should have received a copy of the GNU General Public License along with
1954+#  SoftEther.  If not, see <http://www.gnu.org/licenses/>.
1955+
1956+
1957+include $(top_srcdir)/autotools/softether.am
1958+
1959+noinst_PROGRAMS = \
1960+	hamcorebuilder
1961+
1962+hamcorebuilder_SOURCES = \
1963+	hamcorebuilder.c
1964+
1965+hamcorebuilder_LDADD = \
1966+	$(top_builddir)/src/Mayaqua/libmayaqua.la \
1967+	$(top_builddir)/src/Cedar/libcedar.la
1968diff --git a/src/vpnbridge/Makefile.am b/src/vpnbridge/Makefile.am
1969new file mode 100644
1970index 00000000..35fe043d
1971--- /dev/null
1972+++ b/src/vpnbridge/Makefile.am
1973@@ -0,0 +1,29 @@
1974+#  Copyright 2014 Darik Horn <dajhorn@vanadac.com>
1975+#
1976+#  This file is part of SoftEther.
1977+#
1978+#  SoftEther is free software: you can redistribute it and/or modify it under
1979+#  the terms of the GNU General Public License as published by the Free
1980+#  Software Foundation, either version 2 of the License, or (at your option)
1981+#  any later version.
1982+#
1983+#  SoftEther is distributed in the hope that it will be useful, but WITHOUT ANY
1984+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1985+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
1986+#  details.
1987+#
1988+#  You should have received a copy of the GNU General Public License along with
1989+#  SoftEther.  If not, see <http://www.gnu.org/licenses/>.
1990+
1991+
1992+include $(top_srcdir)/autotools/softether.am
1993+
1994+sbin_PROGRAMS = \
1995+	vpnbridge
1996+
1997+vpnbridge_SOURCES = \
1998+	vpnbridge.c
1999+
2000+vpnbridge_LDADD = \
2001+	$(top_builddir)/src/Mayaqua/libmayaqua.la \
2002+	$(top_builddir)/src/Cedar/libcedar.la
2003diff --git a/src/vpnclient/Makefile.am b/src/vpnclient/Makefile.am
2004new file mode 100644
2005index 00000000..1aa55330
2006--- /dev/null
2007+++ b/src/vpnclient/Makefile.am
2008@@ -0,0 +1,29 @@
2009+#  Copyright 2014 Darik Horn <dajhorn@vanadac.com>
2010+#
2011+#  This file is part of SoftEther.
2012+#
2013+#  SoftEther is free software: you can redistribute it and/or modify it under
2014+#  the terms of the GNU General Public License as published by the Free
2015+#  Software Foundation, either version 2 of the License, or (at your option)
2016+#  any later version.
2017+#
2018+#  SoftEther is distributed in the hope that it will be useful, but WITHOUT ANY
2019+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
2020+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
2021+#  details.
2022+#
2023+#  You should have received a copy of the GNU General Public License along with
2024+#  SoftEther.  If not, see <http://www.gnu.org/licenses/>.
2025+
2026+
2027+include $(top_srcdir)/autotools/softether.am
2028+
2029+sbin_PROGRAMS = \
2030+	vpnclient
2031+
2032+vpnclient_SOURCES = \
2033+	vpncsvc.c
2034+
2035+vpnclient_LDADD = \
2036+	$(top_builddir)/src/Mayaqua/libmayaqua.la \
2037+	$(top_builddir)/src/Cedar/libcedar.la
2038diff --git a/src/vpncmd/Makefile.am b/src/vpncmd/Makefile.am
2039new file mode 100644
2040index 00000000..d8042aa2
2041--- /dev/null
2042+++ b/src/vpncmd/Makefile.am
2043@@ -0,0 +1,29 @@
2044+#  Copyright 2014 Darik Horn <dajhorn@vanadac.com>
2045+#
2046+#  This file is part of SoftEther.
2047+#
2048+#  SoftEther is free software: you can redistribute it and/or modify it under
2049+#  the terms of the GNU General Public License as published by the Free
2050+#  Software Foundation, either version 2 of the License, or (at your option)
2051+#  any later version.
2052+#
2053+#  SoftEther is distributed in the hope that it will be useful, but WITHOUT ANY
2054+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
2055+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
2056+#  details.
2057+#
2058+#  You should have received a copy of the GNU General Public License along with
2059+#  SoftEther.  If not, see <http://www.gnu.org/licenses/>.
2060+
2061+
2062+include $(top_srcdir)/autotools/softether.am
2063+
2064+sbin_PROGRAMS = \
2065+	vpncmd
2066+
2067+vpncmd_SOURCES = \
2068+	vpncmd.c
2069+
2070+vpncmd_LDADD = \
2071+	$(top_builddir)/src/Mayaqua/libmayaqua.la \
2072+	$(top_builddir)/src/Cedar/libcedar.la
2073diff --git a/src/vpnserver/Makefile.am b/src/vpnserver/Makefile.am
2074new file mode 100644
2075index 00000000..c1c33570
2076--- /dev/null
2077+++ b/src/vpnserver/Makefile.am
2078@@ -0,0 +1,29 @@
2079+#  Copyright 2014 Darik Horn <dajhorn@vanadac.com>
2080+#
2081+#  This file is part of SoftEther.
2082+#
2083+#  SoftEther is free software: you can redistribute it and/or modify it under
2084+#  the terms of the GNU General Public License as published by the Free
2085+#  Software Foundation, either version 2 of the License, or (at your option)
2086+#  any later version.
2087+#
2088+#  SoftEther is distributed in the hope that it will be useful, but WITHOUT ANY
2089+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
2090+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
2091+#  details.
2092+#
2093+#  You should have received a copy of the GNU General Public License along with
2094+#  SoftEther.  If not, see <http://www.gnu.org/licenses/>.
2095+
2096+
2097+include $(top_srcdir)/autotools/softether.am
2098+
2099+sbin_PROGRAMS = \
2100+	vpnserver
2101+
2102+vpnserver_SOURCES = \
2103+	vpnserver.c
2104+
2105+vpnserver_LDADD = \
2106+	$(top_builddir)/src/Mayaqua/libmayaqua.la \
2107+	$(top_builddir)/src/Cedar/libcedar.la
2108