Skip to content

Commit

Permalink
Add --with-system-libsafec flag to link against system libsafec
Browse files Browse the repository at this point in the history
Specifying the --with-system-libsafec flag shall allow the configuration
program to search for and, if found, to link against the libsafec library
that is installed in the system.

After configuring --with-system-libsafec, the compilation will may with
following error:

In file included from /usr/include/libsafec/safe_lib.h:43,
                  from est_server_http.c:39:
/usr/include/libsafec/safe_types.h:42:9: error: unknown type name 'size_t'
   42 | typedef size_t  rsize_t;
      |         ^~~~~~

The system libsafec lacks including stddef.h in its safe_types.h.

Fix that by moving libsafec include directives below the openssl; the latter apparently
does the inclusion of the necessary stddef.h at some point.

Signed-off-by: Aleksandr Makarov <[email protected]>
  • Loading branch information
Aleksandr Makarov committed Jul 17, 2020
1 parent 0d6b817 commit 0f8de87
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 14 deletions.
6 changes: 5 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,9 @@ examples = example/client example/client-simple example/client-brski example/ser
endif
endif

SUBDIRS = safe_c_stub src $(libest_jni) $(examples)
if ! WITH_SYSTEM_LIBSAFEC
builtin_libsafec = safe_c_stub
endif

SUBDIRS = $(builtin_libsafec) src $(libest_jni) $(examples)
EXTRA_DIST = autogen.sh example/util LICENSE README.brski $(srcdir)/build.gradle $(srcdir)/example/build_examples.gradle
41 changes: 31 additions & 10 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ AM_INIT_AUTOMAKE([subdir-objects])

AC_PROG_CC
AM_PROG_CC_C_O
PKG_PROG_PKG_CONFIG
LT_INIT
AC_CANONICAL_HOST
case $host in
Expand Down Expand Up @@ -187,22 +188,39 @@ AC_ARG_WITH([libcoap-dir],
]
)

SAFEC_STUB_DIR='$(abs_top_builddir)/safe_c_stub'
AC_SUBST(SAFEC_STUB_DIR)
safecdir="$SAFEC_STUB_DIR"
AC_SUBST([SAFEC_DIR], "$safecdir")
AC_SUBST([SAFEC_CFLAGS], "$safecdir/include")
AC_SUBST([SAFEC_LDFLAGS], "$safecdir/lib")
AC_ARG_WITH(system-libsafec,
AS_HELP_STRING([--with-system-libsafec],
[select to use libsafec installed in the system]),
[],
[with_system_libsafec="no"])

CFLAGS="$CFLAGS -Wall -I$safecdir/include"
LDFLAGS="$LDFLAGS -L$safecdir/lib"
LIBS="$LIBS -lsafe_lib"
AC_MSG_CHECKING(which libsafec to use)
AM_CONDITIONAL([WITH_SYSTEM_LIBSAFEC], [test "$with_system_libsafec" = "yes"])
AM_COND_IF([WITH_SYSTEM_LIBSAFEC], AC_MSG_RESULT([system]), AC_MSG_RESULT([built-in]))
AM_COND_IF([WITH_SYSTEM_LIBSAFEC],
[
PKG_CHECK_MODULES([libsafec], [libsafec])
LIBS="$LIBS $libsafec_LIBS"
CFLAGS="$CFLAGS $libsafec_CFLAGS"
CPPFLAGS="$CPPFLAGS $libsafec_CFLAGS"
],[
SAFEC_STUB_DIR='$(abs_top_builddir)/safe_c_stub'
AC_SUBST(SAFEC_STUB_DIR)
safecdir="$SAFEC_STUB_DIR"
AC_SUBST([SAFEC_DIR], "$safecdir")
AC_SUBST([SAFEC_CFLAGS], "$safecdir/include")
AC_SUBST([SAFEC_LDFLAGS], "$safecdir/lib")
CFLAGS="$CFLAGS -Wall -I$safecdir/include"
LDFLAGS="$LDFLAGS -L$safecdir/lib"
LIBS="$LIBS -lsafe_lib"
])

AC_PREFIX_DEFAULT([/usr/local/est])

cp confdefs.h est_config.h

AC_CONFIG_FILES([Makefile version safe_c_stub/Makefile safe_c_stub/lib/Makefile src/Makefile src/est/Makefile])
AC_CONFIG_FILES([Makefile version src/Makefile src/est/Makefile])
AM_COND_IF([ENABLE_JNI],
[AC_CONFIG_FILES([java/jni/Makefile])])
AM_COND_IF([ENABLE_EXAMPLES],
Expand All @@ -212,5 +230,8 @@ AM_COND_IF([ENABLE_EXAMPLES],
[],
[AC_CONFIG_FILES([example/server/Makefile example/proxy/Makefile])])
])
AM_COND_IF([WITH_SYSTEM_LIBSAFEC],
[],
[AC_CONFIG_FILES([safe_c_stub/Makefile safe_c_stub/lib/Makefile])])

AC_OUTPUT
6 changes: 3 additions & 3 deletions src/est/est_server_http.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#include "safe_lib.h"
#include "safe_str_lib.h"
#include "safe_mem_lib.h"
#ifdef WIN32
#include <WS2tcpip.h>
#endif
#include <openssl/err.h>
#include <openssl/ssl.h>
#include <openssl/x509v3.h>
#include "safe_lib.h"
#include "safe_str_lib.h"
#include "safe_mem_lib.h"
#if defined(_WIN32)
#define _CRT_SECURE_NO_WARNINGS // Disable deprecation warning in VS2005
#else
Expand Down

0 comments on commit 0f8de87

Please sign in to comment.