sample-plugins: Partially autotoolize the sample-plugins build
PATCH 1/1 sample-plugins: Partially autotoolize the sample-plugins build
The sample-plugins have their own set of build/winbuild scripts in each of these plugin directories. This does not give a good way to reuse various macros the autoconf/automake/configure process enables; which can contain important macros to make some code build without errors or warnings.
Normally we would embrace the full autoconf/automake approach. But this is sample code which we only want to build per request and the built code should not be installed anywhere via 'make install'. But since we do use libtool other plug-ins being installed and automake gets kind of cranky when it comes to define certain build targets not following the expected use cases, we try to only embrace just enough of automake to get our main goals achieved.
This changeset kicks out the build scripts and replaces them with a single Makefile.plugins file, which defines the plugins we want to build by default when running 'make from the sample-plugins directory. Neither of these plugins are otherwise built by default. No sample-plugins are being installed. But we have enough strings attached to automake to grab the CFLAGS and LDFLAGS used by the rest of the code. This also makes it easy to use #include "config.h" in sample code, to also get various macros defined by the ./configure run.
This patch does not touch the winbuild scripts, as it seems building these sample-plugins on Windows requires a bit different compile and linking steps than *nix systems in general.
--- configure.ac | 1 + sample/sample-plugins/Makefile.am | 28 +++++++++++++++++ sample/sample-plugins/Makefile.plugins | 31 +++++++++++++++++++ sample/sample-plugins/defer/build | 15 --------- .../keying-material-exporter-demo/build | 15 --------- sample/sample-plugins/log/build | 15 --------- sample/sample-plugins/simple/build | 15 --------- 7 files changed, 60 insertions(+), 60 deletions(-) create mode 100644 sample/sample-plugins/Makefile.am create mode 100644 sample/sample-plugins/Makefile.plugins delete mode 100755 sample/sample-plugins/defer/build delete mode 100755 sample/sample-plugins/keying-material-exporter-demo/build delete mode 100755 sample/sample-plugins/log/build delete mode 100755 sample/sample-plugins/simple/build
configure.ac +1 -0
@@ -1433,6 +1433,7 @@ AC_CONFIG_FILES([ doc/doxygen/Makefile doc/doxygen/openvpn.doxyfile include/Makefile + sample/sample-plugins/Makefile src/Makefile src/compat/Makefile src/openvpn/Makefile
sample/sample-plugins/Makefile.am new file +28 -0
@@ -0,0 +1,28 @@ +# +# OpenVPN -- An application to securely tunnel IP networks +# over a single UDP port, with support for SSL/TLS-based +# session authentication and key exchange, +# packet encryption, packet authentication, and +# packet compression. +# +# Copyright (C) 2002-2020 OpenVPN Inc <[email protected]...> +# + +MAINTAINERCLEANFILES = \ + $(srcdir)/Makefile.in + +# We don't want automake to pull in libtool for building these +# sample-plugins. Even though this breaks the conceptual ideas +# around autoconf/automake/libtools ... these sample plug-ins +# are just sample code, not to be installed or distributed outside +# of the source tarball. Not even built by default, by design. +# +# We only add this as a simple and convenient way to build all +# these plug-ins with the same build parameters as the rest +# of the OpenVPN code. +# +# All the plugins which will be built are processed in this +# separate Makefile, which disconnects everything just enough +# to achieve our goal. +include Makefile.plugins +
sample/sample-plugins/Makefile.plugins new file +31 -0
@@ -0,0 +1,31 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Copyright (C) 2020 OpenVPN Inc <[email protected]...> +# + +# +# Plug-ins to build - listed entries should not carry any extensions +# +PLUGINS = \ + defer/simple \ + keying-material-exporter-demo/keyingmaterialexporter \ + log/log log/log_v3 \ + simple/base64 \ + simple/simple + +# All the plugins to build - rewritten with .so extension +all : $(foreach var, $(PLUGINS), $(var).so) + +# Compile step +.c.o : + test -d `dirname $@` || $(MKDIR_P) `dirname $@`; \ + $(CC) -c -o $@ $(CFLAGS) -I$(top_srcdir) -fPIC $< + +# Link step +%.so : %.o + $(CC) $(LDFLAGS) -shared -fPIC -o $@ $< + +# Clean up all build object and shared object files +clean : + rm -f $(foreach var, $(PLUGINS), $(var).o) \ + $(foreach var, $(PLUGINS), $(var).so)
sample/sample-plugins/defer/build deleted +0 -15
@@ -1,15 +0,0 @@ -#!/bin/sh - -# -# Build an OpenVPN plugin module on *nix. The argument should -# be the base name of the C source file (without the .c). -# - -# This directory is where we will look for openvpn-plugin.h -CPPFLAGS="${CPPFLAGS:--I../../../include}" - -CC="${CC:-gcc}" -CFLAGS="${CFLAGS:--O2 -Wall -g}" - -$CC $CPPFLAGS $CFLAGS -fPIC -c $1.c && \ -$CC $CFLAGS -fPIC -shared ${LDFLAGS} -Wl,-soname,$1.so -o $1.so $1.o -lc
sample/sample-plugins/keying-material-exporter-demo/build deleted +0 -15
@@ -1,15 +0,0 @@ -#!/bin/sh - -# -# Build an OpenVPN plugin module on *nix. The argument should -# be the base name of the C source file (without the .c). -# - -# This directory is where we will look for openvpn-plugin.h -CPPFLAGS="${CPPFLAGS:--I../../..}" - -CC="${CC:-gcc}" -CFLAGS="${CFLAGS:--O2 -Wall -g}" - -$CC $CPPFLAGS $CFLAGS -fPIC -c $1.c && \ -$CC $CFLAGS -fPIC -shared $LDFLAGS -Wl,-soname,$1.so -o $1.so $1.o -lc
sample/sample-plugins/log/build deleted +0 -15
@@ -1,15 +0,0 @@ -#!/bin/sh - -# -# Build an OpenVPN plugin module on *nix. The argument should -# be the base name of the C source file (without the .c). -# - -# This directory is where we will look for openvpn-plugin.h -CPPFLAGS="${CPPFLAGS:--I../../../include}" - -CC="${CC:-gcc}" -CFLAGS="${CFLAGS:--O2 -Wall -g}" - -$CC $CPPFLAGS $CFLAGS -fPIC -c $1.c && \ -$CC $CFLAGS -fPIC -shared $LDFLAGS -Wl,-soname,$1.so -o $1.so $1.o -lc
sample/sample-plugins/simple/build deleted +0 -15
@@ -1,15 +0,0 @@ -#!/bin/sh - -# -# Build an OpenVPN plugin module on *nix. The argument should -# be the base name of the C source file (without the .c). -# - -# This directory is where we will look for openvpn-plugin.h -CPPFLAGS="${CPPFLAGS:--I../../..}" - -CC="${CC:-gcc}" -CFLAGS="${CFLAGS:--O2 -Wall -g}" - -$CC $CPPFLAGS $CFLAGS -fPIC -c $1.c && \ -$CC $CFLAGS -fPIC -shared $LDFLAGS -Wl,-soname,$1.so -o $1.so $1.o -lc
Signature · 1 line
2.26.0
PATCH v2 1/1 sample-plugins: Partially autotoolize the sample-plugins build
The sample-plugins have their own set of build/winbuild scripts in each of these plugin directories. This does not give a good way to reuse various macros the autoconf/automake/configure process enables; which can contain important macros to make some code build without errors or warnings.
Normally we would embrace the full autoconf/automake approach. But this is sample code which we only want to build per request and the built code should not be installed anywhere via 'make install'. But since we do use libtool other plug-ins being installed and automake gets kind of cranky when it comes to define certain build targets not following the expected use cases, we try to only embrace just enough of automake to get our main goals achieved.
This changeset kicks out the build scripts and replaces them with a single Makefile.plugins file, which defines the plugins we want to build by default when running 'make from the sample-plugins directory. Neither of these plugins are otherwise built by default. No sample-plugins are being installed. But we have enough strings attached to automake to grab the CFLAGS and LDFLAGS used by the rest of the code. This also makes it easy to use #include "config.h" in sample code, to also get various macros defined by the ./configure run.
This patch does not touch the winbuild scripts, as it seems building these sample-plugins on Windows requires a bit different compile and linking steps than *nix systems in general.
---
v2 - Process README files with correct instructions and details
--- configure.ac | 1 + sample/sample-plugins/Makefile.am | 28 ++++++++++++++ sample/sample-plugins/Makefile.plugins | 31 ++++++++++++++++ sample/sample-plugins/README | 37 +++++++++++++++++++ sample/sample-plugins/defer/README | 16 -------- sample/sample-plugins/defer/build | 15 -------- .../keying-material-exporter-demo/build | 15 -------- sample/sample-plugins/log/build | 15 -------- sample/sample-plugins/simple/README | 16 -------- sample/sample-plugins/simple/build | 15 -------- 10 files changed, 97 insertions(+), 92 deletions(-) create mode 100644 sample/sample-plugins/Makefile.am create mode 100644 sample/sample-plugins/Makefile.plugins create mode 100644 sample/sample-plugins/README delete mode 100644 sample/sample-plugins/defer/README delete mode 100755 sample/sample-plugins/defer/build delete mode 100755 sample/sample-plugins/keying-material-exporter-demo/build delete mode 100755 sample/sample-plugins/log/build delete mode 100644 sample/sample-plugins/simple/README delete mode 100755 sample/sample-plugins/simple/build
configure.ac +1 -0
@@ -1433,6 +1433,7 @@ AC_CONFIG_FILES([ doc/doxygen/Makefile doc/doxygen/openvpn.doxyfile include/Makefile + sample/sample-plugins/Makefile src/Makefile src/compat/Makefile src/openvpn/Makefile
sample/sample-plugins/Makefile.am new file +28 -0
@@ -0,0 +1,28 @@ +# +# OpenVPN -- An application to securely tunnel IP networks +# over a single UDP port, with support for SSL/TLS-based +# session authentication and key exchange, +# packet encryption, packet authentication, and +# packet compression. +# +# Copyright (C) 2002-2020 OpenVPN Inc <[email protected]...> +# + +MAINTAINERCLEANFILES = \ + $(srcdir)/Makefile.in + +# We don't want automake to pull in libtool for building these +# sample-plugins. Even though this breaks the conceptual ideas +# around autoconf/automake/libtools ... these sample plug-ins +# are just sample code, not to be installed or distributed outside +# of the source tarball. Not even built by default, by design. +# +# We only add this as a simple and convenient way to build all +# these plug-ins with the same build parameters as the rest +# of the OpenVPN code. +# +# All the plugins which will be built are processed in this +# separate Makefile, which disconnects everything just enough +# to achieve our goal. +include Makefile.plugins +
sample/sample-plugins/Makefile.plugins new file +31 -0
@@ -0,0 +1,31 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Copyright (C) 2020 OpenVPN Inc <[email protected]...> +# + +# +# Plug-ins to build - listed entries should not carry any extensions +# +PLUGINS = \ + defer/simple \ + keying-material-exporter-demo/keyingmaterialexporter \ + log/log log/log_v3 \ + simple/base64 \ + simple/simple + +# All the plugins to build - rewritten with .so extension +all : $(foreach var, $(PLUGINS), $(var).so) + +# Compile step +.c.o : + test -d `dirname $@` || $(MKDIR_P) `dirname $@`; \ + $(CC) -c -o $@ $(CFLAGS) -I$(top_srcdir) -fPIC $< + +# Link step +%.so : %.o + $(CC) $(LDFLAGS) -shared -fPIC -o $@ $< + +# Clean up all build object and shared object files +clean : + rm -f $(foreach var, $(PLUGINS), $(var).o) \ + $(foreach var, $(PLUGINS), $(var).so)
sample/sample-plugins/README new file +37 -0
@@ -0,0 +1,37 @@ +OpenVPN plug-in examples. + +Examples provided: + +* authentication and logging +simple/simple.c -- using the --auth-user-pass-verify callback, verify + that the username/password is "foo"/"bar". +defer/simple.c -- using the --auth-user-pass-verify callback, + test deferred authentication. +log/log.c -- Extended variant of simple/simple.c which adds more + logging of what is happening inside the plug-in +log/log_v3.c -- A variant of log/log.c, which makes use of the + OpenVPN plug-in v3 API. This will also log even more + information related to certificates in use. + +* cryptography related +simple/base64.c -- Example using the OpenVPN exported base64 encode/decode + functions +keying-material-exporter-demo/keyingmaterialexporter.c + -- Example based on TLS Keying Material Exporters over HTTP [RFC-5705] + (openvpn/doc/keying-material-exporter.txt). For more details, see + keying-material-exporter-demo/README + + +To build on *BSD/Linux platforms: + + make (builds a default set of plug-ins) + make simple/simple.so + +To build on Windows platform (MinGW): + + cd simple; ./winbuild simple.so + +To use in OpenVPN, add to config file: + + plugin simple.so (Linux/BSD/etc.) + plugin simple.dll
sample/sample-plugins/defer/README deleted +0 -16
@@ -1,16 +0,0 @@ -OpenVPN plugin examples. - -Examples provided: - -simple.c -- using the --auth-user-pass-verify callback, - test deferred authentication. - -To build: - - ./build simple (Linux/BSD/etc.) - ./winbuild simple (MinGW on Windows) - -To use in OpenVPN, add to config file: - - plugin simple.so (Linux/BSD/etc.) - plugin simple.dll (MinGW on Windows)
sample/sample-plugins/defer/build deleted +0 -15
@@ -1,15 +0,0 @@ -#!/bin/sh - -# -# Build an OpenVPN plugin module on *nix. The argument should -# be the base name of the C source file (without the .c). -# - -# This directory is where we will look for openvpn-plugin.h -CPPFLAGS="${CPPFLAGS:--I../../../include}" - -CC="${CC:-gcc}" -CFLAGS="${CFLAGS:--O2 -Wall -g}" - -$CC $CPPFLAGS $CFLAGS -fPIC -c $1.c && \ -$CC $CFLAGS -fPIC -shared ${LDFLAGS} -Wl,-soname,$1.so -o $1.so $1.o -lc
sample/sample-plugins/keying-material-exporter-demo/build deleted +0 -15
@@ -1,15 +0,0 @@ -#!/bin/sh - -# -# Build an OpenVPN plugin module on *nix. The argument should -# be the base name of the C source file (without the .c). -# - -# This directory is where we will look for openvpn-plugin.h -CPPFLAGS="${CPPFLAGS:--I../../..}" - -CC="${CC:-gcc}" -CFLAGS="${CFLAGS:--O2 -Wall -g}" - -$CC $CPPFLAGS $CFLAGS -fPIC -c $1.c && \ -$CC $CFLAGS -fPIC -shared $LDFLAGS -Wl,-soname,$1.so -o $1.so $1.o -lc
sample/sample-plugins/log/build deleted +0 -15
@@ -1,15 +0,0 @@ -#!/bin/sh - -# -# Build an OpenVPN plugin module on *nix. The argument should -# be the base name of the C source file (without the .c). -# - -# This directory is where we will look for openvpn-plugin.h -CPPFLAGS="${CPPFLAGS:--I../../../include}" - -CC="${CC:-gcc}" -CFLAGS="${CFLAGS:--O2 -Wall -g}" - -$CC $CPPFLAGS $CFLAGS -fPIC -c $1.c && \ -$CC $CFLAGS -fPIC -shared $LDFLAGS -Wl,-soname,$1.so -o $1.so $1.o -lc
sample/sample-plugins/simple/README deleted +0 -16
@@ -1,16 +0,0 @@ -OpenVPN plugin examples. - -Examples provided: - -simple.c -- using the --auth-user-pass-verify callback, verify - that the username/password is "foo"/"bar". - -To build: - - ./build simple (Linux/BSD/etc.) - ./winbuild simple (MinGW on Windows) - -To use in OpenVPN, add to config file: - - plugin simple.so (Linux/BSD/etc.) - plugin simple.dll (MinGW on Windows)
sample/sample-plugins/simple/build deleted +0 -15
@@ -1,15 +0,0 @@ -#!/bin/sh - -# -# Build an OpenVPN plugin module on *nix. The argument should -# be the base name of the C source file (without the .c). -# - -# This directory is where we will look for openvpn-plugin.h -CPPFLAGS="${CPPFLAGS:--I../../..}" - -CC="${CC:-gcc}" -CFLAGS="${CFLAGS:--O2 -Wall -g}" - -$CC $CPPFLAGS $CFLAGS -fPIC -c $1.c && \ -$CC $CFLAGS -fPIC -shared $LDFLAGS -Wl,-soname,$1.so -o $1.so $1.o -lc
Signature · 1 line
2.26.0
Hi,
Quoted 5 lines · David Sommerseth
The sample-plugins have their own set of build/winbuild scripts in each of these plugin directories. This does not give a good way to reuse various macros the autoconf/automake/configure process enables; which can contain important macros to make some code build without errors or warnings.
This looks like a step in the right direction, but is not fully working yet - I tried both an "in-tree" and "out of tree" build, and it fails compilation with
sample-plugins$ gmake
test -d dirname defer/simple.o || ../../../openvpn/./install-sh -c -d dirname defer/simple.o; \
cc -c -o defer/simple.o -Wall -Wno-unused-parameter -Wno-unused-function -g -O2 -std=c99 -I../../../openvpn -fPIC ../../../openvpn/sample/sample-plugins/defer/simple.c ../../../openvpn/sample/sample-plugins/defer/simple.c:58:10: fatal error: 'openvpn-plugin.h' file
not found
#include "openvpn-plugin.h"
^~~~~~~~~~~~~~~~~~1 error generated.
openvpn-plugin.h is installed if you install openvpn first, but if you only build in tree, it seems to need an extra
-I$(top_srcdir)/include
to find openvpn-plugin.h
It also needs gmake - running "make" will do "nothing at all", which I found surprising, but did not investigate more closely. This is likely due to implicit rules that need to be written differently for BSD make.
I do not think this is a serious issue - just document it in the README, and it's still better than 4 individual "build" files, half of it who were missing the needed "-I" as well :-)
gert
Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you
feed honest figures into a computer, honest figures come out. Never doubted
it myself till I met a computer with a sense of humor."
Robert A. Heinlein, The Moon is a Harsh Mistress
Gert Doering - Munich, Germany [email protected]...Quoted 23 lines · Gert Doering
Hi,
Quoted 5 lines · David Sommerseth
The sample-plugins have their own set of build/winbuild scripts in each of these plugin directories. This does not give a good way to reuse various macros the autoconf/automake/configure process enables; which can contain important macros to make some code build without errors or warnings.
This looks like a step in the right direction, but is not fully working yet - I tried both an "in-tree" and "out of tree" build, and it fails compilation with
sample-plugins$ gmake
test -ddirname defer/simple.o|| ../../../openvpn/./install-sh -c -ddirname defer/simple.o; \
cc -c -odefer/simple.o-Wall -Wno-unused-parameter -Wno-unused-function -g -O2 -std=c99 -I../../../openvpn -fPIC../../../openvpn/sample/sample-plugins/defer/simple.c../../../openvpn/sample/sample-plugins/defer/simple.c:58:10: fatal error: 'openvpn-plugin.h' file
not found#include "openvpn-plugin.h" ^~~~~~~~~~~~~~~~~~1 error generated.
Quoted 6 lines
openvpn-plugin.his installed if you install openvpn first, but if you only build in tree, it seems to need an extra-I$(top_srcdir)/includeto find
openvpn-plugin.h
Hmmm ... I would have expected that to be picked up automatically, but clearly didn't watch the compile arguments carefully enough.
Quoted 3 lines
It also needs gmake - running "make" will do "nothing at all", which I found surprising, but did not investigate more closely. This is likely due to implicit rules that need to be written differently for BSD make.
Yikes ... I see potentially two issues here. BSD Make seems to lack support for $(foreach ...) and it does not grok '%.so : %.o' (which is Make "macro magic" to simplify rule writing). To avoid this and make it BSD Make compatible, we would probably need to go full-fledged automake - pulling in libtools (and the awkward .libs directories, .la/.lo files, etc, etc).
So if we're fine with reducing this to GNU Make only, the change is trivial.
Quoted 3 lines
I do not think this is a serious issue - just document it in the README, and it's still better than 4 individual "build" files, half of it who were missing the needed "-I" as well :-)
New updated patch coming very soon.
Signature · 4 lines
kind regards, David Sommerseth OpenVPN Inc
PATCH v3 1/1 sample-plugins: Partially autotoolize the sample-plugins build
In reply to David SommersethThe sample-plugins have their own set of build/winbuild scripts in each of these plugin directories. This does not give a good way to reuse various macros the autoconf/automake/configure process enables; which can contain important macros to make some code build without errors or warnings.
Normally we would embrace the full autoconf/automake approach. But this is sample code which we only want to build per request and the built code should not be installed anywhere via 'make install'. But since we do use libtool other plug-ins being installed and automake gets kind of cranky when it comes to define certain build targets not following the expected use cases, we try to only embrace just enough of automake to get our main goals achieved.
This changeset kicks out the build scripts and replaces them with a single Makefile.plugins file, which defines the plugins we want to build by default when running 'make from the sample-plugins directory. Neither of these plugins are otherwise built by default. No sample-plugins are being installed. But we have enough strings attached to automake to grab the CFLAGS and LDFLAGS used by the rest of the code. This also makes it easy to use #include "config.h" in sample code, to also get various macros defined by the ./configure run.
This patch does not touch the winbuild scripts, as it seems building these sample-plugins on Windows requires a bit different compile and linking steps than *nix systems in general.
---
v2 - Process README files with correct instructions and details v3 - Add missing -I$(top_srcdir)/include and explicitly state GNU Make
requirement
--- configure.ac | 1 + sample/sample-plugins/Makefile.am | 30 +++++++++++++++ sample/sample-plugins/Makefile.plugins | 31 ++++++++++++++++ sample/sample-plugins/README | 37 +++++++++++++++++++ sample/sample-plugins/defer/README | 16 -------- sample/sample-plugins/defer/build | 15 -------- .../keying-material-exporter-demo/build | 15 -------- sample/sample-plugins/log/build | 15 -------- sample/sample-plugins/simple/README | 16 -------- sample/sample-plugins/simple/build | 15 -------- 10 files changed, 99 insertions(+), 92 deletions(-) create mode 100644 sample/sample-plugins/Makefile.am create mode 100644 sample/sample-plugins/Makefile.plugins create mode 100644 sample/sample-plugins/README delete mode 100644 sample/sample-plugins/defer/README delete mode 100755 sample/sample-plugins/defer/build delete mode 100755 sample/sample-plugins/keying-material-exporter-demo/build delete mode 100755 sample/sample-plugins/log/build delete mode 100644 sample/sample-plugins/simple/README delete mode 100755 sample/sample-plugins/simple/build
configure.ac +1 -0
@@ -1433,6 +1433,7 @@ AC_CONFIG_FILES([ doc/doxygen/Makefile doc/doxygen/openvpn.doxyfile include/Makefile + sample/sample-plugins/Makefile src/Makefile src/compat/Makefile src/openvpn/Makefile
sample/sample-plugins/Makefile.am new file +30 -0
@@ -0,0 +1,30 @@ +# +# OpenVPN -- An application to securely tunnel IP networks +# over a single UDP port, with support for SSL/TLS-based +# session authentication and key exchange, +# packet encryption, packet authentication, and +# packet compression. +# +# Copyright (C) 2002-2020 OpenVPN Inc <[email protected]...> +# + +MAINTAINERCLEANFILES = \ + $(srcdir)/Makefile.in + +AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/include + +# We don't want automake to pull in libtool for building these +# sample-plugins. Even though this breaks the conceptual ideas +# around autoconf/automake/libtools ... these sample plug-ins +# are just sample code, not to be installed or distributed outside +# of the source tarball. Not even built by default, by design. +# +# We only add this as a simple and convenient way to build all +# these plug-ins with the same build parameters as the rest +# of the OpenVPN code. +# +# All the plugins which will be built are processed in this +# separate Makefile, which disconnects everything just enough +# to achieve our goal. +include Makefile.plugins +
sample/sample-plugins/Makefile.plugins new file +31 -0
@@ -0,0 +1,31 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Copyright (C) 2020 OpenVPN Inc <[email protected]...> +# + +# +# Plug-ins to build - listed entries should not carry any extensions +# +PLUGINS = \ + defer/simple \ + keying-material-exporter-demo/keyingmaterialexporter \ + log/log log/log_v3 \ + simple/base64 \ + simple/simple + +# All the plugins to build - rewritten with .so extension +all : $(foreach var, $(PLUGINS), $(var).so) + +# Compile step +.c.o : + test -d `dirname $@` || $(MKDIR_P) `dirname $@`; \ + $(CC) -c -o $@ $(CFLAGS) $(AM_CPPFLAGS) -fPIC $< + +# Link step +%.so : %.o + $(CC) $(LDFLAGS) -shared -fPIC -o $@ $< + +# Clean up all build object and shared object files +clean : + rm -f $(foreach var, $(PLUGINS), $(var).o) \ + $(foreach var, $(PLUGINS), $(var).so)
sample/sample-plugins/README new file +37 -0
@@ -0,0 +1,37 @@ +OpenVPN plug-in examples. + +Examples provided: + +* authentication and logging +simple/simple.c -- using the --auth-user-pass-verify callback, verify + that the username/password is "foo"/"bar". +defer/simple.c -- using the --auth-user-pass-verify callback, + test deferred authentication. +log/log.c -- Extended variant of simple/simple.c which adds more + logging of what is happening inside the plug-in +log/log_v3.c -- A variant of log/log.c, which makes use of the + OpenVPN plug-in v3 API. This will also log even more + information related to certificates in use. + +* cryptography related +simple/base64.c -- Example using the OpenVPN exported base64 encode/decode + functions +keying-material-exporter-demo/keyingmaterialexporter.c + -- Example based on TLS Keying Material Exporters over HTTP [RFC-5705] + (openvpn/doc/keying-material-exporter.txt). For more details, see + keying-material-exporter-demo/README + + +To build on *BSD/Linux platforms (requires GNU Make): + + gmake (builds a default set of plug-ins) + gmake simple/simple.so + +To build on Windows platform (MinGW): + + cd simple; ./winbuild simple.so + +To use in OpenVPN, add to config file: + + plugin simple.so (Linux/BSD/etc.) + plugin simple.dll
sample/sample-plugins/defer/README deleted +0 -16
@@ -1,16 +0,0 @@ -OpenVPN plugin examples. - -Examples provided: - -simple.c -- using the --auth-user-pass-verify callback, - test deferred authentication. - -To build: - - ./build simple (Linux/BSD/etc.) - ./winbuild simple (MinGW on Windows) - -To use in OpenVPN, add to config file: - - plugin simple.so (Linux/BSD/etc.) - plugin simple.dll (MinGW on Windows)
sample/sample-plugins/defer/build deleted +0 -15
@@ -1,15 +0,0 @@ -#!/bin/sh - -# -# Build an OpenVPN plugin module on *nix. The argument should -# be the base name of the C source file (without the .c). -# - -# This directory is where we will look for openvpn-plugin.h -CPPFLAGS="${CPPFLAGS:--I../../../include}" - -CC="${CC:-gcc}" -CFLAGS="${CFLAGS:--O2 -Wall -g}" - -$CC $CPPFLAGS $CFLAGS -fPIC -c $1.c && \ -$CC $CFLAGS -fPIC -shared ${LDFLAGS} -Wl,-soname,$1.so -o $1.so $1.o -lc
sample/sample-plugins/keying-material-exporter-demo/build deleted +0 -15
@@ -1,15 +0,0 @@ -#!/bin/sh - -# -# Build an OpenVPN plugin module on *nix. The argument should -# be the base name of the C source file (without the .c). -# - -# This directory is where we will look for openvpn-plugin.h -CPPFLAGS="${CPPFLAGS:--I../../..}" - -CC="${CC:-gcc}" -CFLAGS="${CFLAGS:--O2 -Wall -g}" - -$CC $CPPFLAGS $CFLAGS -fPIC -c $1.c && \ -$CC $CFLAGS -fPIC -shared $LDFLAGS -Wl,-soname,$1.so -o $1.so $1.o -lc
sample/sample-plugins/log/build deleted +0 -15
@@ -1,15 +0,0 @@ -#!/bin/sh - -# -# Build an OpenVPN plugin module on *nix. The argument should -# be the base name of the C source file (without the .c). -# - -# This directory is where we will look for openvpn-plugin.h -CPPFLAGS="${CPPFLAGS:--I../../../include}" - -CC="${CC:-gcc}" -CFLAGS="${CFLAGS:--O2 -Wall -g}" - -$CC $CPPFLAGS $CFLAGS -fPIC -c $1.c && \ -$CC $CFLAGS -fPIC -shared $LDFLAGS -Wl,-soname,$1.so -o $1.so $1.o -lc
sample/sample-plugins/simple/README deleted +0 -16
@@ -1,16 +0,0 @@ -OpenVPN plugin examples. - -Examples provided: - -simple.c -- using the --auth-user-pass-verify callback, verify - that the username/password is "foo"/"bar". - -To build: - - ./build simple (Linux/BSD/etc.) - ./winbuild simple (MinGW on Windows) - -To use in OpenVPN, add to config file: - - plugin simple.so (Linux/BSD/etc.) - plugin simple.dll (MinGW on Windows)
sample/sample-plugins/simple/build deleted +0 -15
@@ -1,15 +0,0 @@ -#!/bin/sh - -# -# Build an OpenVPN plugin module on *nix. The argument should -# be the base name of the C source file (without the .c). -# - -# This directory is where we will look for openvpn-plugin.h -CPPFLAGS="${CPPFLAGS:--I../../..}" - -CC="${CC:-gcc}" -CFLAGS="${CFLAGS:--O2 -Wall -g}" - -$CC $CPPFLAGS $CFLAGS -fPIC -c $1.c && \ -$CC $CFLAGS -fPIC -shared $LDFLAGS -Wl,-soname,$1.so -o $1.so $1.o -lc
Signature · 1 line
2.26.0
Hi,
Quoted 4 lines · David Sommerseth
---
v2 - Process README files with correct instructions and details v3 - Add missing -I$(top_srcdir)/include and explicitly state GNU Make
requirement
Unfortunately, we need a v4... stupid me...
For in-tree builds, it is working:
cc -c -o simple/simple.o -Wall -Wno-unused-parameter -Wno-unused-function -g -O2 -std=c99 -I../.. -I../../include -fPIC simple/simple.c cc -shared -fPIC -o simple/simple.so simple/simple.o
rm simple/simple.o
For out of tree builds, it is still failing:
cc -c -o simple/simple.o -Wall -Wno-unused-parameter -Wno-unused-function -g -O2 -std=c99 -I../../../openvpn -I../../../openvpn/include -fPIC ../../../openvpn/sample/sample-plugins/simple/simple.c ../../../openvpn/sample/sample-plugins/simple/simple.c:37:10: fatal error:
'openvpn-plugin.h' file not found
#include "openvpn-plugin.h"
^~~~~~~~~~~~~~~~~~because "openvpn-plugin.h" is not actually to be found in the source tree, but it's generated at compile time - so "-I../../include" will find it.
The other -I should maybe also be "-I../.."? What is it looking for in the $(top_builddir)? The only .h file in $(top_builddir) is "config-msvc.h" - config.h is in "../.."
But anyway, if I do "-I../../include", it compiles out of tree as well...
cc -c -o simple/simple.o -Wall -Wno-unused-parameter -Wno-unused-function -g -O2 -std=c99 -I../../../openvpn -I../../include -fPIC ../../../openvpn/sample/sample-plugins/simple/simple.c
gert
Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you
feed honest figures into a computer, honest figures come out. Never doubted
it myself till I met a computer with a sense of humor."
Robert A. Heinlein, The Moon is a Harsh Mistress
Gert Doering - Munich, Germany [email protected]...[resent from proper address]
Quoted 9 lines · Gert Doering
Hi,
Quoted 4 lines · David Sommerseth
---
v2 - Process README files with correct instructions and details v3 - Add missing -I$(top_srcdir)/include and explicitly state GNU Make
requirementUnfortunately, we need a v4... stupid me...
Nah, we share the blame here ... I forgot about the builddir variant. Which is very well documented in the automake documentation.
Quoted 3 lines
For in-tree builds, it is working:
cc -c -o
simple/simple.o-Wall -Wno-unused-parameter -Wno-unused-function -g
-O2 -std=c99 -I../.. -I../../include -fPIC simple/simple.c
Quoted 13 lines
cc -shared -fPIC -o simple/simple.so
simple/simple.ormsimple/simple.oFor out of tree builds, it is still failing:
cc -c -o
simple/simple.o-Wall -Wno-unused-parameter -Wno-unused-function -g -O2 -std=c99 -I../../../openvpn -I../../../openvpn/include -fPIC ../../.. /openvpn/sample/sample-plugins/simple/simple.c../../../openvpn/sample/sample-plugins/simple/simple.c:37:10: fatal error:
'openvpn-plugin.h' file not found#include "openvpn-plugin.h" ^~~~~~~~~~~~~~~~~~
Quoted 8 lines
because "
openvpn-plugin.h" is not actually to be found in the source tree, but it's generated at compile time - so "-I../../include" will find it.The other -I should maybe also be "-I../.."? What is it looking for in the $(top_builddir)? The only .h file in $(top_builddir) is "
config-msvc.h" -config.his in "../.."
This is actually covered in the AM_CPPFLAGS docs here:
<https://www.gnu.org/software/automake/manual/html_node/Program-Variables.html>
I'll submit a v4 fixing this.
Signature · 4 lines
kind regards, David Sommerseth OpenVPN Inc
PATCH v4 1/1 sample-plugins: Partially autotoolize the sample-plugins build
In reply to David SommersethThe sample-plugins have their own set of build/winbuild scripts in each of these plugin directories. This does not give a good way to reuse various macros the autoconf/automake/configure process enables; which can contain important macros to make some code build without errors or warnings.
Normally we would embrace the full autoconf/automake approach. But this is sample code which we only want to build per request and the built code should not be installed anywhere via 'make install'. But since we do use libtool other plug-ins being installed and automake gets kind of cranky when it comes to define certain build targets not following the expected use cases, we try to only embrace just enough of automake to get our main goals achieved.
This changeset kicks out the build scripts and replaces them with a single Makefile.plugins file, which defines the plugins we want to build by default when running 'make from the sample-plugins directory. Neither of these plugins are otherwise built by default. No sample-plugins are being installed. But we have enough strings attached to automake to grab the CFLAGS and LDFLAGS used by the rest of the code. This also makes it easy to use #include "config.h" in sample code, to also get various macros defined by the ./configure run.
This patch does not touch the winbuild scripts, as it seems building these sample-plugins on Windows requires a bit different compile and linking steps than *nix systems in general.
---
v2 - Process README files with correct instructions and details v3 - Add missing -I$(top_srcdir)/include and explicitly state GNU Make
requirement
v4 - Add missing $(top_builddir) references, preserve built .o files
--- configure.ac | 1 + sample/sample-plugins/Makefile.am | 35 ++++++++++++++++++ sample/sample-plugins/Makefile.plugins | 36 ++++++++++++++++++ sample/sample-plugins/README | 37 +++++++++++++++++++ sample/sample-plugins/defer/README | 16 -------- sample/sample-plugins/defer/build | 15 -------- .../keying-material-exporter-demo/build | 15 -------- sample/sample-plugins/log/build | 15 -------- sample/sample-plugins/simple/README | 16 -------- sample/sample-plugins/simple/build | 15 -------- 10 files changed, 109 insertions(+), 92 deletions(-) create mode 100644 sample/sample-plugins/Makefile.am create mode 100644 sample/sample-plugins/Makefile.plugins create mode 100644 sample/sample-plugins/README delete mode 100644 sample/sample-plugins/defer/README delete mode 100755 sample/sample-plugins/defer/build delete mode 100755 sample/sample-plugins/keying-material-exporter-demo/build delete mode 100755 sample/sample-plugins/log/build delete mode 100644 sample/sample-plugins/simple/README delete mode 100755 sample/sample-plugins/simple/build
configure.ac +1 -0
@@ -1433,6 +1433,7 @@ AC_CONFIG_FILES([ doc/doxygen/Makefile doc/doxygen/openvpn.doxyfile include/Makefile + sample/sample-plugins/Makefile src/Makefile src/compat/Makefile src/openvpn/Makefile
sample/sample-plugins/Makefile.am new file +35 -0
@@ -0,0 +1,35 @@ +# +# OpenVPN -- An application to securely tunnel IP networks +# over a single UDP port, with support for SSL/TLS-based +# session authentication and key exchange, +# packet encryption, packet authentication, and +# packet compression. +# +# Copyright (C) 2002-2020 OpenVPN Inc <[email protected]...> +# + +MAINTAINERCLEANFILES = \ + $(srcdir)/Makefile.in + +AM_CPPFLAGS = -I$(top_srcdir) -I$(top_builddir) \ + -I$(top_srcdir)/include -I$(top_builddir)/include + +# We don't want automake to pull in libtool for building these +# sample-plugins. Even though this breaks the conceptual ideas +# around autoconf/automake/libtools ... these sample plug-ins +# are just sample code, not to be installed or distributed outside +# of the source tarball. Not even built by default, by design. +# +# We only add this as a simple and convenient way to build all +# these plug-ins with the same build parameters as the rest +# of the OpenVPN code. +# +# All the plugins which will be built are processed in this +# separate Makefile, which disconnects everything just enough +# to achieve our goal. +include Makefile.plugins + + +dist-hook : + make -f Makefile.plugins clean +
sample/sample-plugins/Makefile.plugins new file +36 -0
@@ -0,0 +1,36 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Copyright (C) 2020 OpenVPN Inc <[email protected]...> +# + +# +# Plug-ins to build - listed entries should not carry any extensions +# +PLUGINS = \ + defer/simple \ + keying-material-exporter-demo/keyingmaterialexporter \ + log/log log/log_v3 \ + simple/base64 \ + simple/simple + +# All the plugins to build - rewritten with .so extension +all : $(foreach var, $(PLUGINS), $(var).so) + +# Do not automatically remove object files +# This is a special Make setting, to avoid adding an implicit +# 'rm' command on object files - due to the .c.o/%.so rules below +.PRECIOUS: %.o + +# Compile step +.c.o : + test -d `dirname $@` || $(MKDIR_P) `dirname $@`; \ + $(CC) -c -o $@ $(CFLAGS) $(AM_CPPFLAGS) -fPIC $< + +# Link step +%.so : %.o + $(CC) $(LDFLAGS) -shared -fPIC -o $@ $< + +# Clean up all build object and shared object files +clean : + rm -f $(foreach var, $(PLUGINS), $(var).o) \ + $(foreach var, $(PLUGINS), $(var).so)
sample/sample-plugins/README new file +37 -0
@@ -0,0 +1,37 @@ +OpenVPN plug-in examples. + +Examples provided: + +* authentication and logging +simple/simple.c -- using the --auth-user-pass-verify callback, verify + that the username/password is "foo"/"bar". +defer/simple.c -- using the --auth-user-pass-verify callback, + test deferred authentication. +log/log.c -- Extended variant of simple/simple.c which adds more + logging of what is happening inside the plug-in +log/log_v3.c -- A variant of log/log.c, which makes use of the + OpenVPN plug-in v3 API. This will also log even more + information related to certificates in use. + +* cryptography related +simple/base64.c -- Example using the OpenVPN exported base64 encode/decode + functions +keying-material-exporter-demo/keyingmaterialexporter.c + -- Example based on TLS Keying Material Exporters over HTTP [RFC-5705] + (openvpn/doc/keying-material-exporter.txt). For more details, see + keying-material-exporter-demo/README + + +To build on *BSD/Linux platforms (requires GNU Make): + + gmake (builds a default set of plug-ins) + gmake simple/simple.so + +To build on Windows platform (MinGW): + + cd simple; ./winbuild simple.so + +To use in OpenVPN, add to config file: + + plugin simple.so (Linux/BSD/etc.) + plugin simple.dll
sample/sample-plugins/defer/README deleted +0 -16
@@ -1,16 +0,0 @@ -OpenVPN plugin examples. - -Examples provided: - -simple.c -- using the --auth-user-pass-verify callback, - test deferred authentication. - -To build: - - ./build simple (Linux/BSD/etc.) - ./winbuild simple (MinGW on Windows) - -To use in OpenVPN, add to config file: - - plugin simple.so (Linux/BSD/etc.) - plugin simple.dll (MinGW on Windows)
sample/sample-plugins/defer/build deleted +0 -15
@@ -1,15 +0,0 @@ -#!/bin/sh - -# -# Build an OpenVPN plugin module on *nix. The argument should -# be the base name of the C source file (without the .c). -# - -# This directory is where we will look for openvpn-plugin.h -CPPFLAGS="${CPPFLAGS:--I../../../include}" - -CC="${CC:-gcc}" -CFLAGS="${CFLAGS:--O2 -Wall -g}" - -$CC $CPPFLAGS $CFLAGS -fPIC -c $1.c && \ -$CC $CFLAGS -fPIC -shared ${LDFLAGS} -Wl,-soname,$1.so -o $1.so $1.o -lc
sample/sample-plugins/keying-material-exporter-demo/build deleted +0 -15
@@ -1,15 +0,0 @@ -#!/bin/sh - -# -# Build an OpenVPN plugin module on *nix. The argument should -# be the base name of the C source file (without the .c). -# - -# This directory is where we will look for openvpn-plugin.h -CPPFLAGS="${CPPFLAGS:--I../../..}" - -CC="${CC:-gcc}" -CFLAGS="${CFLAGS:--O2 -Wall -g}" - -$CC $CPPFLAGS $CFLAGS -fPIC -c $1.c && \ -$CC $CFLAGS -fPIC -shared $LDFLAGS -Wl,-soname,$1.so -o $1.so $1.o -lc
sample/sample-plugins/log/build deleted +0 -15
@@ -1,15 +0,0 @@ -#!/bin/sh - -# -# Build an OpenVPN plugin module on *nix. The argument should -# be the base name of the C source file (without the .c). -# - -# This directory is where we will look for openvpn-plugin.h -CPPFLAGS="${CPPFLAGS:--I../../../include}" - -CC="${CC:-gcc}" -CFLAGS="${CFLAGS:--O2 -Wall -g}" - -$CC $CPPFLAGS $CFLAGS -fPIC -c $1.c && \ -$CC $CFLAGS -fPIC -shared $LDFLAGS -Wl,-soname,$1.so -o $1.so $1.o -lc
sample/sample-plugins/simple/README deleted +0 -16
@@ -1,16 +0,0 @@ -OpenVPN plugin examples. - -Examples provided: - -simple.c -- using the --auth-user-pass-verify callback, verify - that the username/password is "foo"/"bar". - -To build: - - ./build simple (Linux/BSD/etc.) - ./winbuild simple (MinGW on Windows) - -To use in OpenVPN, add to config file: - - plugin simple.so (Linux/BSD/etc.) - plugin simple.dll (MinGW on Windows)
sample/sample-plugins/simple/build deleted +0 -15
@@ -1,15 +0,0 @@ -#!/bin/sh - -# -# Build an OpenVPN plugin module on *nix. The argument should -# be the base name of the C source file (without the .c). -# - -# This directory is where we will look for openvpn-plugin.h -CPPFLAGS="${CPPFLAGS:--I../../..}" - -CC="${CC:-gcc}" -CFLAGS="${CFLAGS:--O2 -Wall -g}" - -$CC $CPPFLAGS $CFLAGS -fPIC -c $1.c && \ -$CC $CFLAGS -fPIC -shared $LDFLAGS -Wl,-soname,$1.so -o $1.so $1.o -lc
Signature · 1 line
2.26.0
Works for in-tree and out-of-tree builds now, both "just gmake" and "gmake simple/simple.so".
The gmake requirement is well documented and "good enough" for this dusty corner where people very rarely need to build stuff. (It might be solvable by replacing the (foreach) stuff with "the list contains the .so names, and the rule goes directly .c -> .so, not with an intermediate -- but I'm not sure it's actually good spending of our time)
Your patch has been applied to the master and release/2.5 branch.
commit 0b5141d8f946a274bf27b3592ac07dc9c6b0ee71 (master) commit 72d89d994840e2a47b7267054e77e82a908bf693 (release/2.5)
Author: David Sommerseth Date: Wed Sep 16 16:19:56 2020 +0200
sample-plugins: Partially autotoolize the sample-plugins build
Signed-off-by: David Sommerseth <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg21020.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering